This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shell > vagrant box add centos http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130309.box | |
shell > vagrant init centos | |
shell > vi Vagrantfile | |
# Vagrantfile below: #1.Vagrantfile | |
shell > vagrant up | |
: | |
: | |
shell > vagrant ssh-config db1 >> $HOME/.ssh/config | |
shell > vagrant ssh-config db2 >> $HOME/.ssh/config | |
shell > vagrant ssh-config db3 >> $HOME/.ssh/config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thread | |
Socket | |
Server | |
Timer := Object clone | |
Timer do ( | |
counter := 0 | |
increment := method( | |
counter = counter + 1 | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Timer := Object clone do ( | |
ScheduleUnit := Object clone do( | |
newSlot("command", nil) | |
newSlot("period", nil) | |
init := method( | |
self initial := Date now asNumber | |
self current := Date now asNumber | |
) | |
execute := method( | |
self current = Date now asNumber |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.io.FileOutputStream; | |
public class A { | |
public static void main(String...args) throws java.io.IOException { | |
final File file = new File("/tmp/a"); | |
final FileOutputStream output = new FileOutputStream(file); | |
Thread th0 = new Thread(new Runnable(){ | |
public void run() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var util = require('util'); | |
var async = require('async'); | |
var Bitmap = require('./bitmap'); | |
// | |
// ニコニコ動画の【東方】Bad Apple!! PV【影絵】 <http://www.nicovideo.jp/watch/sm8628149> | |
// を 30fps な bitmap に分割したので、 | |
// それを読み込みつつ、コンソールに表示してみる。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var async = require('async'); | |
var mysql = require('mysql'); | |
var request = require('request'); | |
var qs = require('querystring'); | |
var Posterous = function(user, password, apiToken){ | |
this.user = user; | |
this.password = password; | |
this.token = apiToken; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var crypto = require('crypto'); | |
var b = crypto.createHash('md5').update('hoge').digest('binary'); | |
var c = crypto.createHash('md5').update('hoge').digest('hex'); | |
var d = []; for(var i = 0; i < b.length; ++i){ if(b.charCodeAt(i) < 10){ d.push('0' + b.charCodeAt(i).toString(16)) } else { d.push(b.charCodeAt(i).toString(16)) } } | |
c | |
==> 'ea703e7aa1efda0064eaa507d9e8ab7e' | |
d.join('') | |
==> 'ea703e7aa1efda0064eaa507d9e8ab7e' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Trie { | |
private $root; | |
public function __construct() { | |
$this->root = new TrieNode; | |
} | |
public function addString($str, $index){ | |
$this->root->addString($str, $index); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// buffer size(65536) を超えてしまうと、上手くframe分割とかされないようなので | |
// なんとかしてみようとする試み(データは送れるけど、、、版) | |
// | |
WebSocket.prototype._create_frame = function(opcode, d, last_frame) { | |
if(typeof last_frame === 'undefined') { | |
last_frame = true; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ti-websocket-client を RFC6455 に対応してみようとする試み。(未完成) | |
// * 下記を参考にtitanium的に置き換えてみる | |
// https://github.com/einaros/ws/blob/master/lib/Sender.js | |
// https://github.com/einaros/ws/blob/master/lib/BufferUtilWindows.js | |
// | |
WebSocket.prototype._create_frame = function(opcode, d, last_frame) { | |
if(typeof last_frame === 'undefined') { | |
last_frame = true; |
NewerOlder