Skip to content

Instantly share code, notes, and snippets.

@hagino3000
hagino3000 / Observable.js
Created November 27, 2010 07:29
Ovservable for JavaScript Classes
/**
* To class Observable
*
*/
function Observable() {}
Observable.prototype = {
/**
*
@hagino3000
hagino3000 / ofxOpenNI to ofOpenCV
Created March 6, 2011 09:54
Transfer depth data from ofxOpenNI to ofOpenCV
#ifndef _NEOCOS
#define _NEOCOS
#include "ofMain.h"
#include "ofxOpenNI.h"
#include "myDepthGenerator.h"
class neocos : public ofBaseApp{
@hagino3000
hagino3000 / 1st script
Created March 8, 2011 09:51
Setup Ubuntu Server
#!/bin/bash
sudo locale-gen ja_JP.UTF-8
sudo update-locale LANG=ja_JP.UTF-8
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get -y install zsh
sudo apt-get -y install screen
sudo apt-get -y install vim
@hagino3000
hagino3000 / app.js
Created March 14, 2011 21:15
JSON-RPC for node (express)
/**
* Module dependencies.
*/
var express = require('express');
var rpcMethods = require('./methods.js');
var app = module.exports = express.createServer();
// Configuration
@hagino3000
hagino3000 / gist:897783
Created April 1, 2011 05:20
Handle location event And HTTP get by Objective-C
-(NSString*)locationString:(CLLocation *)newLocation {
NSDateFormatter * formatter = [[[NSDateFormatter alloc] init] autorelease];
[formatter setTimeStyle:NSDateFormatterMediumStyle];
return [NSString stringWithFormat:@"(%@) Location %.06f %.06f %@", ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) ? @"bg" : @"fg", newLocation.coordinate.latitude, newLocation.coordinate.longitude, [formatter stringFromDate:newLocation.timestamp]];
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
@hagino3000
hagino3000 / mongotransaction.js
Created April 12, 2011 04:17
Mongo transaction module
// For node-mongodb-native (npm install mongodb)
var mongodb = require('mongodb');
var MongoTransaction = function(db) {
this.db = db;
this.queue = [];
this.running = false;
this.failureFn = function(){};
}
@hagino3000
hagino3000 / error
Created April 14, 2011 03:52
Failed install node-mongodb-native (MacOSX)
`--> sudo npm install mongodb
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info preinstall [email protected]
npm info install [email protected]
uname: illegal option -- o
usage: uname [-amnprsv]
Not building native library for cygwin
make -C ./external-libs/bson
@hagino3000
hagino3000 / setup.sh
Created April 29, 2011 09:21
Setup my mac
chsh -s /opt/local/bin/zsh
mkdir dev
cd dev
hg clone https://bitbucket.org/hagino_3000/confs
cd confs
./pull.sh
@hagino3000
hagino3000 / main.cpp
Created July 19, 2011 15:14
Control Kinect tilt motor by OpenNI USB Interface
#include <stdlib.h>
#include <stdexcept>
#include <iostream>
#include <XnCppWrapper.h>
#include <XnUSB.h>
#define VID_MICROSOFT 0x45e
#define PID_NUI_MOTOR 0x02b0
XN_USB_DEV_HANDLE dev;
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>HTML file template</title>
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.8.0/build/reset/reset-min.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
</head>
<body>
</body>