Skip to content

Instantly share code, notes, and snippets.

View nashibao's full-sized avatar

Naoki Shibayama nashibao

View GitHub Profile
@nashibao
nashibao / co.js
Last active January 2, 2016 09:09
minimum coroutine module (without error handling, dictionary). like https://github.com/visionmedia/co.
var co = function(fn){
function is_gen(obj) {
return obj && obj.constructor && 'GeneratorFunctionPrototype' == obj.constructor.name;
}
return function(done){
var gen = fn;
if(typeof gen == 'function')
gen = gen();
module.exports = {
format: 'json',
apiVersion: '2013-11-04',
endpointPrefix: 'kinesis',
jsonVersion: '1.1',
serviceFullName: 'Amazon Kinesis',
signatureVersion: 'v4',
targetPrefix: 'Kinesis_20131104',
timestampFormat: 'iso8601',
operations: {
package Redis::Custom;
use strict;
use warnings;
# Redis::Custom->setup_custom_command( $redis, 'sjaccardstore', $lua_script, 1 );
sub setup_custom_command {
my ($package, $redis, $command_name, $lua_script, $key_count, @binded_values) = @_;
my ($sha1) = $redis->script_load( $lua_script );
var cluster = require('cluster');
var PORT = +process.env.PORT || 1337;
if (cluster.isMaster) {
// In real life, you'd probably use more than just 2 workers,
// and perhaps not put the master and worker in the same file.
cluster.fork();
cluster.fork();
cluster.on('disconnect', function(worker) {
@yields
yields / License
Last active December 12, 2015 02:39
quick plugin for st3 to build components on save.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@pxsta
pxsta / app.js
Created October 22, 2012 14:44
Socket.io-Express3.x-session
"use strict";
var express = require('express')
, http = require('http')
, path = require('path')
, io = require('socket.io')
, connect = require("express/node_modules/connect")
, Session = express.session.Session
, app = express();
//メモリストアかRedisのどちらかでセッションを保存
@matope
matope / Dynamo: Amazonの高可用性Key-value Store.markdown
Last active November 18, 2022 17:54
Dynamo: Amazonの高可用性Key-value Store[和訳]
@mungomash
mungomash / gist:1575536
Created January 7, 2012 18:14
Octopress cheat sheet
# create a new post
rake new_post["title"]
# re-build the site including any recent changes
rake generate
# run WEBrick server locally on port 4000
rake preview
# push changes to github (master branch)
@FugueNation
FugueNation / almost a module
Created December 10, 2011 14:56
Ultra fast Metrics with Node.js & Redis's bitmaps
var EventEmitter = require("events").EventEmitter,
redis = require("redis"),
dateformat = require("dateformat");
function population32(x)
{
x -= ((x >> 1) & 0x55555555);
x = (((x >> 2) & 0x33333333) + (x & 0x33333333));
x = (((x >> 4) + x) & 0x0f0f0f0f);
x += (x >> 8);