Skip to content

Instantly share code, notes, and snippets.

View pingjiang's full-sized avatar
🎯
Focusing

平江 pingjiang

🎯
Focusing
View GitHub Profile
@pingjiang
pingjiang / call_cocoa_in_cpp
Created August 15, 2014 09:06
This program shows how to access Cocoa GUI from pure C/C++ and build a truly functional GUI application (although very simple).
/*
* test1.cpp
* This program shows how to access Cocoa GUI from pure C/C++
* and build a truly functional GUI application (although very simple).
*
* Compile using:
* g++ -framework Cocoa -o test1 test1.cpp
*
* that will output 'test1' binary.
*/
@pingjiang
pingjiang / lisp.cpp
Created March 29, 2013 11:19 — forked from ofan/lisp.cpp
Lisp interpreter in 90 lines of C++
I've enjoyed reading Peter Norvig's recent articles on Lisp. He implements a Scheme interpreter in 90 lines of Python in the first, and develops it further in the second.
Just for fun I wondered if I could write one in C++. My goals would be
1. A Lisp interpreter that would complete Peter's Lis.py test cases correctly...
2. ...in no more than 90 lines of C++.
Although I've been thinking about this for a few weeks, as I write this I have not written a line of the code. I'm pretty sure I will achieve 1, and 2 will be... a piece of cake!
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 / 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 / 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
}
});
};