Skip to content

Instantly share code, notes, and snippets.

View zhhb's full-sized avatar

Ten zhhb

View GitHub Profile
# Android SDK setup
## Install Java
```bash
sudo apt-get update
sudo dpkg --add-architecture i386
sudo apt-get install libbz2-1.0:i386
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1
sudo apt-get install openjdk-8-jdk openjdk-8-jre
@zhhb
zhhb / class_decorator.ts
Created November 1, 2016 08:30 — forked from remojansen/class_decorator.ts
TypeScript Decorators Examples
function logClass(target: any) {
// save a reference to the original constructor
var original = target;
// a utility function to generate instances of a class
function construct(constructor, args) {
var c : any = function () {
return constructor.apply(this, args);
}
@zhhb
zhhb / .block
Created August 27, 2016 02:50 — forked from mbostock/.block
Canvas Bar Chart
license: gpl-3.0
@zhhb
zhhb / basic_auth_nodejs_test.js
Created June 29, 2016 10:58 — forked from charlesdaniel/basic_auth_nodejs_test.js
Example of HTTP Basic Auth in NodeJS
var http = require('http');
var server = http.createServer(function(req, res) {
// console.log(req); // debug dump the request
// If they pass in a basic auth credential it'll be in a header called "Authorization" (note NodeJS lowercases the names of headers in its request object)
var auth = req.headers['authorization']; // auth is in base64(username:password) so we need to decode the base64
console.log("Authorization Header is: ", auth);
@zhhb
zhhb / README.md
Created June 20, 2016 02:21 — forked from GerHobbelt/README.md
JISON sample wrapper showcasing custom error handlers (stripped JavaScript, ... where more must be done)

This code is a stripped version of actual production code hich employs this JISON clone:

(https://github.com/GerHobbelt/jison)

hence make sure to diff that one against vanilla to see differences/features.


code shows .yy.parseError, lexer.post_lex, parser.post_parser, how to get the token identifier strings from the JISON-generated parser class, etc.

@zhhb
zhhb / grammar-extract.jison
Created June 8, 2016 09:58 — forked from GerHobbelt/grammar-extract.jison
snip&snap extracts from our major JISON grammar file, showcasing 'code sections' a la BISON plus a few other bits & tricks. Note the %{ ... %} sections which are JISON's 'code sections'. Also note the code following that last '%%' marker: that is another 'code section' - and the most important one.
%options ranges
%options backtrack_lexer
/*
* lexical grammar
* ===============
*
* This section defines the lexer rules for our formula parser. The rules are checked from top to bottom, so order is import
* here!
*
@zhhb
zhhb / svg-image2.js
Created May 10, 2016 06:30 — forked from iwek/svg-image2.js
D3js click function to save SVG as dataurl in IMG tag, load into CANVAS and save as PNG dataurl, and auto download the actual PNG file.
d3.select("#save").on("click", function(){
var html = d3.select("svg")
.attr("version", 1.1)
.attr("xmlns", "http://www.w3.org/2000/svg")
.node().parentNode.innerHTML;
//console.log(html);
var imgsrc = 'data:image/svg+xml;base64,'+ btoa(html);
var img = '<img src="'+imgsrc+'">';
d3.select("#svgdataurl").html(img);
@zhhb
zhhb / mysql_uninstall.txt
Created March 25, 2016 04:18 — forked from ismaild/mysql_uninstall.txt
uninstall mysql, Mac OSX
1. Backup any databases you have using mysqldump
2. Stop MySQL using the pref panel
3. Open Terminal and type in the following commands
4. sudo rm /usr/local/mysql
5. sudo rm -rf /usr/local/mysql*
6. sudo rm -rf /Library/StartupItems/MySQLCOM
7. sudo rm -rf /Library/PreferencePanes/My*
8. edit /etc/hostconfig and remove the line MYSQLCOM=-YES- (May not be necessary)
9. rm -rf ~/Library/PreferencePanes/My*
10. sudo rm -rf /Library/Receipts/mysql*
@zhhb
zhhb / rAF.js
Created March 16, 2016 08:37 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];