Skip to content

Instantly share code, notes, and snippets.

@mootoh
mootoh / jsx.sublime-build
Created March 13, 2014 02:39
Jump to errors in language-jsx file while building with make in Sublime Text 2
// put this in ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/User
{
"cmd": ["make"],
"selector": "source.jsx",
"path": "/usr/local/bin:$PATH",
"working_dir": "${project_path:${folder:${file_path}}}",
"file_regex": "^\\[(.*\\.jsx):([0-9]+):().*\\] (.*)"
}
// http://blog.niw.at/post/46781091124
% vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'precise32' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Adding box 'precise32' (v0) for provider: virtualbox
default: Downloading: http://files.vagrantup.com/precise32.box
==> default: Successfully added box 'precise32' (v0) for 'virtualbox'!
- (void) imageReceived:(NSNotification *)notification {
NSLog(@"imageReceived");
dispatch_async(dispatch_get_global_queue(0, 0), ^() {
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(64, 64, 200, 200)];
label.text = @"label should be added";
[self.view addSubview:label];
[self.view setNeedsDisplay];
[self.view setNeedsLayout];
});
@mootoh
mootoh / gist:f5db6f11c4167476a758
Created June 2, 2014 05:34
cocos2d drawScene
Director::drawScene
Scene(Node)::visit
matrix transform
push & set model_view matrix to it
sort all children
for child in children whose zOrder < 0:
child.visit
@mootoh
mootoh / gist:2766
Created July 27, 2008 08:37
バックトラック法による 8クイーンの解法
#
# exercise of backtracking algorithm.
# 2008.07.26
#
require 'pp'
# (x, y) のマスに置けるか
def test(x, y, board)
x.times do |i|
# 左
@mootoh
mootoh / nouns.js
Created September 16, 2014 02:46
collect nouns from HTTP POST request body, and return the result as an JSON array.
var fs = require('fs')
, http = require('http')
, Mecab = require('mecab-async')
, mecab = new Mecab()
;
function toNouns(text, callback) {
mecab.parse(text.toString(), function(err, result) {
if (err) callback(err, null);
var nouns = result.map(function(elm) {
@mootoh
mootoh / to_nouns.rb
Created September 16, 2014 03:40
Collect nouns from HTTP POST data and get back as JSON array
require 'natto'
require 'webrick'
require 'json'
def to_nouns(text)
nm = Natto::MeCab.new
results = []
nm.parse(text) do |n|
type = n.feature.split(/,/).first
next unless type == '名詞'
@mootoh
mootoh / classifier.rb
Created September 16, 2014 07:33
HTTPD that classifies word to noun/other
require 'classifier'
require 'stemmer'
require 'webrick'
require 'json'
# load the previous state if exists
bayes = nil
fh = open('classifier.dump')
if fh
puts 'load'
#!/usr/bin/env ruby
#
# knapsack problem solution by DP
#
# from:
# Cプログラマのためのアルゴリズムとデータ構造
# ISBN:4797304952
# pp. 349
#
# author:
#!/usr/bin/env ruby
#
# knapsack problem solution by backtracking.
#
# from:
# Cプログラマのためのアルゴリズムとデータ構造
# ISBN:4797304952
# pp. 348
#
# author: