Skip to content

Instantly share code, notes, and snippets.

@toshikazuhorii
toshikazuhorii / dump_memory.c
Last active December 16, 2015 11:48
バイナリダンプ用 Helper ref: http://qiita.com/items/af61f02772e8a06caca8
void dump_memory(const void* data, size_t length) {
const int LINE_BYTES = 16;
char buffer[LINE_BYTES + 1];
buffer[LINE_BYTES] = 0;
for (int i = 0; i < length; i++) {
if (i % LINE_BYTES == 0) {
printf("%06x: ", i);
}
@toshikazuhorii
toshikazuhorii / gist:2667078
Created May 12, 2012 15:05
RubyMotionのレイアウト制御ライブラリMotion-layoutsのサンプルを使って遊んでみた。
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.applicationFrame)
@window.rootViewController = ExamMotionLayoutViewController.alloc.init
@window.rootViewController.wantsFullScreenLayout = true
@window.makeKeyAndVisible
return true
end
end
object CsvParser3 extends RegexParsers {
def eol = '\n'
def cell = "\"" ~> "[^\"]*".r <~ "\""
def row = repsep(cell, ",") <~ eol
def headerRow = row ^^ { cells => new HeaderRow(cells) }
def dataRow = ( rep( ("\"" ~> "[^\"]*".r <~ "\",") | ("[^,\n]*".r <~ ",") ) ~ ( ("\"" ~> "[^\"]*".r <~ "\"\n") | ("[^,\n]*".r <~ "\n") ) ) ^^ { cells => new DataRow(cells._1 ::: List(cells._2)) }
def all = headerRow ~ rep(dataRow) ^^ { res => res._1 :: res._2 }
def parse(input: String): ParseResult[List[Row]] = parseAll(all, input)
}
@toshikazuhorii
toshikazuhorii / gist:1109141
Created July 27, 2011 10:54 — forked from seratch/gist:1108560
Daimon.scala #8 やってみよう
/**
* Daimon.scala #8 やってみよう
* http://d.hatena.ne.jp/seratch2/20110507/1304777166
* 以下のPlayer、Gameをそれぞれアクターとして定義して山手線ゲームをコメント例のように実行できるようにしてください。
*/
import actors.Actor
class Get
case class IsUsed(station: Station)
@toshikazuhorii
toshikazuhorii / gist:1097098
Created July 21, 2011 12:31
#daimonscala
class StringWithReverses(str: String) {
def reverseOrder(): String = {
var rev = new StringBuilder(str.length)
(0 until str.length) foreach { (i) => rev.append(str.charAt(str.length-1-i)) }
rev.toString()
}
def reverseCases(): String = {
var rev = new StringBuilder(str.length)
(0 until str.length) foreach { (i) =>