Category Archives: 程式語言

Gson usage : formJson

avoid to face the exception ‘java.lang.ClassCastException With com.google.gson.internal.LinkedTreeMap cannot be cast to…’, we use the TypeToken to convert json to List public class Object { @SerializedName(“n”) private String name; @SerializedName(“i”) private String id; public String getName() { return name; } … Continue reading

Posted in Java | Leave a comment

Redirect stdout to logFile in shell script

exec > >(tee -i logfile.txt) source: stackoverflow: redirect COPY of stdout to log file from within bash script itself

Posted in Shell Script | Leave a comment

find unused files and delete them

find /var/log/radius/radacct -type f -name “reply*” -mtime +60 -exec rm -rf {} \; -mtime N — more than N days without being edited -exec CMD {} \; — comands, {} means the files which be found.

Posted in Linux, Shell Script | Leave a comment

[Java] unicode to string

public static void main(String[] args) { try { String abc = “0043006F0077006D0061002E002E002E90808ACB”; System.out.print(getString(abc)); } catch (Exception e) { System.out.println(“err”); } } public static String getString(String strValue) { StringBuilder str = new StringBuilder(); String temp; for (int i = 0; i … Continue reading

Posted in Java | Leave a comment

[CSS] Removing outline on image map area

Ref. Removing outline on image map area HTML <img class=”map” src=”…” usemap=”…” hidefocus=”true” /> CSS img.map, map area{ outline: none; }

Posted in CSS | Leave a comment

[PHP] Output debug information to console

echo “<script>console.log( ‘Debug Objects: ” . $data . “‘ );</script>”; Ref. stackoverflow: How can I write to console in PHP?

Posted in PHP | Leave a comment

[HBase] run hbase command by ruby

echo ‘list.each {|t| truncate t}; quit;’ | hbase shell or Drop Table echo ‘list.each {|t| disable t; drop t}; quit;’ | hbase shell Scan Table list.each {|t| print t; scan t, {LIMIT=>1};}

Posted in HBase, Ruby | Leave a comment

[jsTree] Populating the tree using JSON

Using Json $(‘#using_json’).jstree({ ‘core’ : { ‘data’ : [ ‘Simple root node’, { ‘text’ : ‘Root node 2’, ‘state’ : { ‘opened’ : true, ‘selected’ : true }, ‘children’ : [ { ‘text’ : ‘Child 1’ }, ‘Child 2’ ] … Continue reading

Posted in jsTree | Leave a comment

[jsTree] Expand and collapse buttons.

<input type=”button” value=”Expand All” onclick=”$(‘#jsTreeID’).jstree(‘open_all’);”> <input type=”button” value=”Collapse All” onclick=”$(‘#jsTreeID’).jstree(‘close_all’);”> Ref: jsTree: adding Expand All and Collapse All buttons

Posted in jsTree | Leave a comment

[JavaScript][jQuery] How to enable/disable select field?

[jQuery] $(‘input[type=radio][name=ldap-sync-type]’).change(function() { if (this.value == ‘0’) { $(“select[name=day-option]”).prop(“disabled”, true); $(“select[name=clock-option]”).prop(“disabled”, true); } else if (this.value == ‘1’) { $(“select[name=day-option]”).prop(“disabled”, false); $(“select[name=clock-option]”).prop(“disabled”, false); } }); [JavaScript] $(‘input[type=radio][name=ldap-sync-type]’).change(function() { if (this.value == ‘0’) { $(“select[name=day-option]”).attr(“disabled”, “disabled”); $(“select[name=clock-option]”).attr(“disabled”, “disabled”); } else if … Continue reading

Posted in JavaScript, jQuery | Leave a comment