Category Archives: 程式語言

Parse JSON string via command line

Ref.:How to parse JSON string via command line on Linux Ubuntu: apt-get install jq Mac: brew install jq

Posted in Shell Script | Leave a comment

[Java] To use Arrays.asList function, must be careful…

Ref: java.util.Arrays.asList用法及注意事项 java集合中部分异常java.lang.UnsupportedOperationException一个共同点 Because the ArrayList made by Arrays.asList function could not be modified anymore…

Posted in Java | Leave a comment

[Java] JSON escape special character

Ref: 剑飘江湖的博客 – JSON格式数据中特殊字符的处理 public static String stringToJson(String s) { if (StringUtils.isEmpty(s)) { return s; } StringBuffer sb = new StringBuffer (); for (int i=0; i<s.length(); i++) { char c = s.charAt(i); switch (c) { case ‘”‘: sb.append(“\””); break; /*case … Continue reading

Posted in Java | Leave a comment

[Java] New arraylist with value

Ref: stackoverflow: Initialization of an ArrayList in one line List<String> places = Arrays.asList(“Buenos Aires”, “Córdoba”, “La Plata”);

Posted in Java | Leave a comment

[Java] Get key from value

Ref: Java Hashmap: How to get key from value? private Object getKeyFromValue(Map map, Object value) { for (Object object : map.keySet()) { if (map.get(object).equals(value)) { return object; } } return null; }

Posted in Java | Leave a comment

[Java] Check Json body.

Ref: stackoverflow:How to check whether a given string is valid JSON in Java public boolean isJSONValid(String test) { try { new JSONObject(test); } catch (JSONException ex) { // edited, to include @Arthur’s comment // e.g. in case JSONArray is valid … Continue reading

Posted in Java | Leave a comment

sed 筆記

每第9個”;”換行 Ref: http://arstechnica.com/civis/viewtopic.php?f=20&t=370486 sed -E ‘s/(([^;];){8}[^;]);/1n/g’ sed.txt 擷取 plist= 與 ;erUid 中間的字串 sed -e ‘s/.plist=(.);erUid.*/1/p’

Posted in sed | Leave a comment

[Java] Eclipse IDE.

Download and install JDK. Edit Windows Environment setting. (Advanced system settings => Advance => Environment variables => Choose Path and click edited => Add the location of the bin folder of the JDK installation.) Ex: “C:Program Files (x86)Javajre1.8.0_31bin” Check the … Continue reading

Posted in Eclipse, Java | Leave a comment

[Gitbook] 使用 Windows 視窗編輯器

試著使用 Windows 的視窗編輯器來撰寫 Gitbook 目前測試了 Miu 跟 MarkdownPad 這兩個編輯器 不過前者 Miu 因為 Liveview 並不支援 HTML 語法,所以被我拋棄了 等他有支援再回去用看看 PS. Mac 上大家推的都是 Mou 而用 Windows 寫 Gitbook 就不像在 Linux 上有 gitbook init 可以產生相對映的 md 檔案 就改之前寫的 parse.py 來產生吧 (這邊使用的 python 版本是 3.0) … Continue reading

Posted in Python | Leave a comment

[Python] SyntaxError: Missing parentheses in call to ‘print’

因為在 Ubuntu 上目前安裝的 Python 版本還是 2.7 而之前在 Windows 安裝的版本為 3.0 導至把 Ubuntu 上寫好的 code 拿至 Windows 上編譯時會發生下列錯誤… SyntaxError: Missing parentheses in call to ‘print’ 這時候參考stackoverflow: What does “SyntaxError: Missing parentheses in call to ‘print’” mean in Python? 得知要把 print 語法修正一下 … Continue reading

Posted in Python | Leave a comment