Skip to content

Instantly share code, notes, and snippets.

View mather's full-sized avatar
🐻
friendly bear

Eisuke Kuwahata mather

🐻
friendly bear
View GitHub Profile
@mather
mather / amazon_shorten.user.js
Last active December 16, 2015 15:49
Amazonの商品URLを短くして商品名からリンクします。駄作なので改善案が欲しい。
// ==UserScript==
// @name Amazon Shorten URL Clipper
// @namespace https://gist.github.com/mather
// @version 0.4
// @updateURL https://gist.github.com/mather/5458140/raw/amazon_shorten.user.js
// @description Amazon商品のショートURLを作成して、商品名を含めたツイートボタンを作成します。
// @match http://www.amazon.co.jp/*
// @match http://www.amazon.com/*
// @copyright 2013+, mather
// ==/UserScript==
@mather
mather / gist:4951569
Last active December 13, 2015 17:58
Futureを使ってみる。 Scala 2.10.0
import scala.concurrent._
/* futureを使うときにExecutionContextが必要。 */
implicit val execctx = ExecutionContext.global
/* futureはscala.concurrentパッケージに定義されているシンタックスシュガー */
val a = future { Thread sleep 100000 ; "hoge" }
/* 次のFutureの処理を合成 */
val b = a flatMap ( (str:String) => future { "fuga" + str } )
@mather
mather / tzset_test.c
Created February 12, 2013 10:36
tzsetで何が変わるのか
#include <stdio.h>
#include <time.h>
void print_time(const time_t t)
{
char buf[128];
size_t str_size = 0;
str_size = strftime(buf, 127, "%Y/%m/%d %H:%M:%S", localtime(&t));
buf[str_size] = 0;
@mather
mather / stat_test.c
Last active December 12, 2015 10:48
stat関数でできることをチェック。コマンドライン引数でファイルとかシンボリックリンクとか指定するとstatまたはlstatを呼び出してチェックできる。
CC = gcc
OPT = -O2 -Wall
BIN = stat_test
default: bin
bin: $(BIN)
stat_test: stat_test.o
$(CC) $(OPT) -o $@ $<
@mather
mather / ParserSample.scala
Created November 30, 2012 16:40
Parser Test
import scala.util.parsing.combinator.JavaTokenParsers
object ParserSample extends JavaTokenParsers {
/*
* RegexParserで定義されたメソッド。
* default(=true) だと行末の改行などが無視される。
*/
override def skipWhitespace = false
/*