Skip to content

Instantly share code, notes, and snippets.

View hagino3000's full-sized avatar

Takashi Nishibayashi hagino3000

View GitHub Profile
@hagino3000
hagino3000 / cybozu-connect.js
Created August 15, 2011 04:51
Cybozu-connect API for Node
/**
* cybozu-connect for Node
*/
var jsdom = require('jsdom'),
XMLHttpRequest = require('XMLHttpRequest').XMLHttpRequest;
var document,
window,
$,
CBLabs = {},
@hagino3000
hagino3000 / result by Node
Created September 14, 2011 04:28
JavaScript speed check
Modern Style Spent: 896 ms
Primitive Style Spent: 766 ms
@hagino3000
hagino3000 / cardfliper.js
Created September 21, 2011 04:20
devquiz
(function() {
var cardsNum = document.querySelectorAll('.card').length;
for (var i=0; i<cardsNum; i++) {
for (var j=i+1; j<cardsNum; j++) {
flip(i);
flip(j);
}
}
function flip(idx) {
@hagino3000
hagino3000 / client.js
Created December 8, 2011 18:42
WebSocket with binary data
var socket = null;
function bootstrap() {
// 適当な図形を描画
var c = document.getElementById('mycanvas');
var ctx = c.getContext('2d');
ctx.globalalpha = 0.3;
for(var i=0; i<1000; i++) {
ctx.beginPath();
@hagino3000
hagino3000 / testApp.cpp
Created January 1, 2012 17:21
openFrameworks + OpenNI Sample
#include "testApp.h"
#include <iostream>
#include <XnCppWrapper.h>
#define MAX_DEPTH 10000
void errorCheck(XnStatus status) {
if (status != XN_STATUS_OK) {
@hagino3000
hagino3000 / method_missing.js
Last active January 16, 2020 13:11
__noSuchMethod__ for Chrome
/**
* Enable route to __noSuchMethod__ when unknown method calling.
*
* @param {Object} obj Target object.
* @return {Object}
*/
function enableMethodMissing(obj) {
var functionHandler = createBaseHandler({});
functionHandler.get = function(receiver, name) {
@hagino3000
hagino3000 / .vimrc
Created April 25, 2012 03:13
My .vimrc
" viとの互換性をOFF
set nocompatible
" エンコーディング設定
set enc=utf-8
set fencs=iso-2022-jp,euc-jp,cp932,utf-8
set ambiwidth=double
" 検索機能の設定
set ignorecase
@hagino3000
hagino3000 / gist:2904435
Created June 10, 2012 07:59
Get neuro properties
import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.*;
import org.json.JSONArray;
@hagino3000
hagino3000 / urlfetch.js
Created July 10, 2012 07:03
Simple URL fetch for node
module.exports = function urlFetch(urlString, callback) {
var url = require('url').parse(urlString);
var module = url.protocol === 'https:' ? require('https') : require('http');
require('http').get({
host: url.hostname,
port: url.port,
path: url.path
}, function(res) {
var body = '';
res.on('data', function(chunk) {
@hagino3000
hagino3000 / cube_root.scm
Created July 17, 2012 10:41
SICP study (1.1.7)
;; Newton法の手続きを繰り返す手続き
(define (curt-iter guess x)
(if (good-enough? guess x)
guess
(curt-iter (improve guess x)
x)))
;; 近似を得る手続き
(define (improve guess x)
(/ (+ (* 2 guess)