Skip to main content

Posts

NodeJS Cheatsheet

Remote debug nodejs app / use chrome developers to detect memory leaksStep 1 enable remote debug on a running nodejs processkill -SIGUSR1 $NODEJS_PID Now your nodejs process (V8) is listening on port 5858Step 2 run node-inspector# node-inspector --web-port=8081 Node Inspector v0.12.8 Visit http://127.0.0.1:8081/?port=5858 to start debugging.
Recent posts

Python cheatsheet

Get content of URLimporturllib2printurllib2.urlopen('http://google.com').read()Remove chars and split by , from a string convert to list'jshfjshfjsh[]'.translate(None,'[] "\n').split(',')Diff between two arraysset(['first','second','third'])-set(['first','second'])

Java Cheatsheet

Initialize 2 dim arrayint[][]arr=newint[2][2];print two dim arrayjava.util.Arrays.deepToString(table)Read stdinScannersc=newScanner(System.in);while(sc.hasNextLine()){System.out.println(sc.nextLine());}spaced delimeted string to streamimportjava.util.stream.*;importjava.util.regex.*;Streamstream=Pattern.compile(" ").splitAsStream(scanner.nextLine());