Skip to content

Instantly share code, notes, and snippets.

@mootoh
mootoh / trello-todo.js
Created December 8, 2015 05:18
Fetch all Checklist items from all boards belong to you.
// Fetch all Checklist items from all boards belong to you
function list(id, lists) {
var found = lists.filter(function(list) {
return list.id == id;
});
if (found.length > 0) {
return found[0];
} else {
return null;
}
@mootoh
mootoh / gpu_panic.txt
Created November 13, 2015 00:25
GPU Panic on resume
MacBook Pro 15-inch Mid 2010
Mac OS X 10.11.1 El Capitan
Anonymous UUID: C954D324-371C-A05D-BEFC-FABD49B32EC8
Thu Nov 12 19:23:01 2015
*** Panic Report ***
panic(cpu 1 caller 0xffffff7f85622bad): "GPU Panic: [<None>] 3 3 7f 0 0 0 0 3 : NVRM[0/1:0:0]: Read Error 0x00000100: CFG 0xffffffff 0xffffffff 0xffffffff, BAR0 0xd2000000 0xffffff911f5ef000 0x0a5480a2, D0, P3/4\n"@/Library/Caches/com.apple.xbs/Sources/AppleGraphicsControl/AppleGraphicsControl-3.11.33.1/src/AppleMuxControl/kext/GPUPanic.cpp:127
Backtrace (CPU 1), Frame : Return Address
@mootoh
mootoh / accelog.java
Created May 26, 2015 04:53
Android app that logs linear accelerometer stream
package net.mootoh.accelog;
import android.app.Activity;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.os.Environment;
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs"),
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var Response = {
@mootoh
mootoh / polymorphism.m
Created March 5, 2015 05:01
Realm polymorphism test case
// http://stackoverflow.com/questions/28849498/assigning-property-to-subclass-of-rlmobject/28859297#28859297
#import <XCTest/XCTest.h>
#import <Realm/Realm.h>
@interface Base : RLMObject
@property NSInteger id;
@end
@interface Derived : Base
@property NSString *derivedInfo;
@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'
@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 / 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 / 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
- (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];
});