Skip to content

Instantly share code, notes, and snippets.

View pingjiang's full-sized avatar
🎯
Focusing

pragmatic_jiang pingjiang

🎯
Focusing
View GitHub Profile
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;
public class JsonQueryEngine {
public static List<String> getExpressionValues(String expression, String propertySeperator, JSONObject jsonObject) throws Exception{
String[] nodesList = expression.split(propertySeperator);//Splitting each property in expression
// ==UserScript==
// @name Use Markdown, sometimes, in your HTML.
// @author Paul Irish <http://paulirish.com/>
// @link http://git.io/data-markdown
// @match *
// ==/UserScript==
// If you're not using this as a userscript just delete from this line up. It's cool, homey.
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Script that is used by PRESUBMIT.py to run style checks on Java files."""
import os
import subprocess
import xml.dom.minidom
CHROMIUM_SRC = os.path.normpath(
os.path.join(os.path.dirname(__file__),
os.pardir, os.pardir, os.pardir))
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<!--
See installation instructions: https://sites.google.com/a/chromium.org/dev/checkstyle
-->
<module name="Checker">
<property name="severity" value="warning"/>
<property name="charset" value="UTF-8"/>
<module name="TreeWalker">
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<!--
Checkstyle-Configuration: Android checkstyle by Enea
Description: none
-->
@pingjiang
pingjiang / server_browser_bootstrap.js
Created October 15, 2014 05:54
server and browser javascript bootstrap code.
(function() {
var root = this;
var _ = function() {
};
// Export the object for **Node.js**, with
// backwards-compatibility for the old `require()` API. If we're in
@pingjiang
pingjiang / nodejs-inherits.js
Created October 13, 2014 15:18
nodejs-inherits
var inherits = function (ctor, superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false
}
});
};
@pingjiang
pingjiang / nodejs-inherits-EventEmitter.js
Created October 13, 2014 15:17
nodejs-inherits-EventEmitter
var util = require("util");
var events = require("events");
function MyStream() {
events.EventEmitter.call(this);
}
util.inherits(MyStream, events.EventEmitter);
MyStream.prototype.write = function(data) {
@pingjiang
pingjiang / loop_trap.js
Created October 13, 2014 14:54
NodeJS Loop trap, callback is called nextTick.
var fs = require('fs');
var files = ['a.txt', 'b.txt', 'c.txt'];
for (var i = 0; i < files.length; i++) {
fs.readFile(files[i], 'utf-8', function(err, contents) {
console.log(files[i] + ': ' + contents);
});
}
@pingjiang
pingjiang / fab.js
Created October 13, 2014 14:09
better memoized fabnacci
function fab(n) {
if (n < 3) {
return 1;
}
var p1=1, p2=1, p;
function _fab(m) {
if (m < n) {
p = p1 + p2;
p1 = p2;
p2 = p;