Skip to content

Instantly share code, notes, and snippets.

@nowelium
nowelium / gist:1768174
Created February 8, 2012 10:54
ti-websocket-client-diff
#
# なぜか、大きな data を送信しようとすると parse できなくなることがある(逆にそこそこ大きいと成功したりとか)
# ので、length < BUFFER_SIZE の部分はコメントアウトしてみた(hybiの仕様とか見てない)
#
--- ti-websocket-client.org.js 2012-02-08 19:47:03.000000000 +0900
+++ ti-websocket-client.own.js 2012-02-08 19:50:54.000000000 +0900
@@ -872,6 +872,7 @@
type: Ti.Codec.TYPE_BYTE
});
@nowelium
nowelium / latch.js
Created January 13, 2012 03:05
CountdownLatch
var CountdownLatch = function (limit){
this.limit = limit;
this.count = 0;
this.waitBlock = function (){};
};
CountdownLatch.prototype.countDown = function (){
this.count = this.count + 1;
if(this.limit <= this.count){
return this.waitBlock();
}
@nowelium
nowelium / async-utils.js
Created November 18, 2011 12:33
async.js helpers
//
// async.js <https://github.com/caolan/async> helpers(utils)
// only work on nodejs
//
var async = require('async');
var ControlFlow = function (){};
ControlFlow.prototype.initialize = function (){
var tasks = {};
Object.defineProperty(tasks, 'length', {
@nowelium
nowelium / yet_another_express_csrf
Created November 18, 2011 12:19
yet-another-express-csrf
const crypto = require('crypto');
const connect = require('connect');
exports.token = function(request, response){
if(request.session){
var lastAccess = request.session.lastAccess;
var csrf = crypto.createHash('md5').update('' + Date.now() + lastAccess).digest('hex');
return request.session['csrf'] = csrf;
}
return null;
@nowelium
nowelium / app.js
Created October 17, 2011 13:43
connect-auth example (using: multi strategy, multi scope)
const express = require('express');
const auth = require('connect-auth');
const app = express.createServer();
// see: https://gist.github.com/1292608
(function (){
// yet another google oauth2
Object.defineProperty(auth, 'GoogleV2', {
get: function() {
return require('./lib/connect-oauth-google-v2/google2');
@nowelium
nowelium / app.js
Created October 17, 2011 13:30
connect-oauth-google-v2(userinfo request)
const auth = require('connect-auth');
(function (){
// yet another google oauth2
Object.defineProperty(auth, 'GoogleV2', {
get: function() {
return require('./lib/connect-oauth-google-v2/google2');
},
enumerable:true
});
})();
#foo .a + .b {
background-color: red;
}
#foo .a .b {
background-color: blue;
}
@nowelium
nowelium / plugin.py
Created August 19, 2011 12:08
TiMob(android) generated AndroidManifest.xml rewrite plugin (ins android:screenOrientation attribute)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Titanium Compiler plugin
# com.github.nowelium.titanium.plugin.androidmanifest
#
import os
import sys
@nowelium
nowelium / args.js
Created August 18, 2011 11:16
args
var foo = function(a, b, c){
return a + ":" + b + ":" + c
};
var bar = function (){
return foo.apply(null, arguments);
};
bar('hello', 'js', 'world')
// ==> 'hello:js:world'
@nowelium
nowelium / js
Created August 18, 2011 11:00
override method
var Hoge = function (){};
Hoge.prototype.foo = function (){
return 'hello';
};
var a = new Hoge();
a.foo();
# ==> 'hello'
var bar = function (){