Skip to content

Instantly share code, notes, and snippets.

View xingrz's full-sized avatar

XiNGRZ xingrz

View GitHub Profile
Wind.Async.Binding.fromCallbackAndNext = (function(original) {
// return functionAsync(arg1, arg2, ..., AsyncMethod)
return (function() {
var asyncArgs = arguments; // (arg1, arg2, ..., AsyncMethod)
if (asyncArgs < 1) return;
var asyncMethod = asyncArgs[asyncArgs.length - 1];
var program = require('commander');
var Wind = require('wind'),
Binding = Wind.Async.Binding;
//Wind.logger.level = Wind.Logging.Level.WARN;
program.chooseAsync = Binding.fromCallback(program.choose);
/*program.chooseAsync = Binding.fromCallback(function(list, fn) {
@xingrz
xingrz / app.js
Created January 23, 2013 15:35
Seems to be a "best practice" of developing with [mongoose](http://mongoosejs.com).
var mongoose = require('mongoose')
mongoose.connect('mongodb://localhost/mydb', function () {
console.log('mongodb connected')
})
@xingrz
xingrz / a.js
Created January 23, 2013 15:52
A依赖B,C依赖B,C直接修改了B中的属性,A中的B的属性会不会被改变?
var b = require('./b')
console.log(b.val)
process.nextTick(function () {
var c = require('./c')
console.log(b.val)
})
function StringBuilder () {
this._strings = []
}
StringBuilder.prototype.append = function (str) {
this._strings.push(str)
}
StringBuilder.prototype.toString = function () {
return this._strings.join('')
@xingrz
xingrz / article.js
Last active August 29, 2015 13:56
XX-Style
var router = require('xx').router
, marked = require('marked')
exports.create = router()
.shouldAuthed()
.shouldNotContains([ 'id', 'creator' ])
exports.show = router()
.visable([ 'title', 'content' ])
.map('content', marked.render)
@xingrz
xingrz / gist:9115622
Last active August 29, 2015 13:56
glass::NativeEyeGestureService::isGestureSupported(int) const
; glass::NativeEyeGestureService::isGestureSupported(int) const
push {r4, r5, r6, lr} ; XREF=0x483c
mov r4, r0
ldr r0, = 0x2bb4
mov r5, r1
add r0, pc
ldr r0, [r0]
blx 0x38ac
ldr r4, [r4, #0xc]
cbz r4, 0x4808
String enabledNotificationListeners = Settings.Secure.getString(context.getContentResolver(), "enabled_notification_listeners");
// check to see if the enabledNotificationListeners String contains our package name
if (enabledNotificationListeners == null || !enabledNotificationListeners.contains(context.getPackageName())) {
// in this situation we know that the user has not granted the app the Notification access permission
throw new Exception();
} else {
doSomethingThatRequiresNotificationAccessPermission();
}
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<title>出口资讯</title>
<meta charset="utf8">
<style>
body {
margin: 0;
padding: 0 100px;
background: black;
@xingrz
xingrz / td.sh
Last active August 29, 2015 14:00
Teardown Glass
#!/bin/sh
YELLOW="\033[33m"
PINK="\033[36m"
RESET="\033[0m"
echo "$PINK Extracting $1...$RESET"
zip=$1
rom=${zip%.*}
mkdir $rom