Skip to content

Instantly share code, notes, and snippets.

View ynaoto's full-sized avatar

Naoto Yoshioka ynaoto

View GitHub Profile
@ynaoto
ynaoto / spawn.php
Last active December 14, 2015 22:29
Command launch process with watching the possible error at launching stage.
function spawn($command_line, $dir)
{
$descriptorspec = [
0 => [ "pipe", "r" ], // stdin
1 => [ "pipe", "w" ], // stdout
2 => [ "pipe", "w" ], // stderr
];
$process = proc_open($command_line, $descriptorspec, $pipes, $dir);
if (!is_resource($process)) {
@ynaoto
ynaoto / log.php
Last active December 14, 2015 22:29
An error logger function for debug purpose.
function log($msg)
{
$args = func_get_args();
array_shift($args); // $msg
error_log(array_reduce($args, function($v, $w) {
return $v . var_export($w, true);
}, $msg));
}
@ynaoto
ynaoto / config_gnugo_osx
Created March 14, 2013 06:01
Configure 'gnugo' for Mac OS-X Mountain Lion
./configure CC=cc
@ynaoto
ynaoto / config_gnushogi_osx
Created March 14, 2013 06:03
Configure 'gnushogi' for Mac OS-X Mountain Lion.
./configure --prefix=/opt/local/ CC=cc
@ynaoto
ynaoto / makefile.local_gps_osx
Created March 14, 2013 06:07
makefile.local to build GTPShogi OSI library on Mac OS-X Mountain Lion.
CXX = c++
GXX = $(CXX) # a quick and dirty hack to use clang compiler instead of gnu
INCLUDES += -I/opt/local/include/
LDFLAGS += -L/opt/local/lib/
#CPUOPTION = -march=core2
CPUOPTION = -march=native
#USE_TBB_SCALABLE_ALLOCATOR = 1
USE_TCMALLOC = 0
#LOADLIBES += -lboost_system -liconv
@ynaoto
ynaoto / config_daemonshogi_osx
Last active December 14, 2015 22:29
Configure to build 'daemonshogi-0.7.0' on Mac OS-X Mountain Lion. Just use MacPorts to install a lot of additional packages will be required during the build process.
./configure --prefix=/opt/local/ CPPFLAGS=-I/opt/local/include/ LDFLAGS=-L/opt/local/lib LIBS=-liconv
@ynaoto
ynaoto / Rakefile
Created March 22, 2013 14:44
Rakefile to handle .litcoffee
LITCOFFEES = FileList['*.litcoffee']
JSS = LITCOFFEES.ext('.js')
rule '.js' => '.litcoffee' do |t|
sh "coffee -c #{t.source}"
end
task :default => JSS
task :watch do
@ynaoto
ynaoto / Makefile
Last active December 15, 2015 07:10
Makefile to handle .litcoffee
.SUFFIXES: .litcoffee .js
JSS = a.js b.js c.js
all: $(JSS)
.litcoffee.js:
coffee -c $<
watch:
coffee -wc $(JSS:.js=.litcoffee)
@ynaoto
ynaoto / uid.coffee
Created March 22, 2013 14:55
Enough unique id
uid = ((Math.random() * 10000)|0) +
'-' + Date.now() +
'-' + ((Math.random() * 10000)|0)
@ynaoto
ynaoto / tween.coffee
Created March 23, 2013 04:45
an animation effect that shows a phantom that moves $from to $to.
tween = ($from, $to, therefore) ->
$a = $from.clone()
$from.css(opacity: 0.75)
$a.css(position: 'absolute')
.css($from.offset())
.css('border-color', 'transparent')
$from.parent().append $a
$a.animate $to.position(),
complete: ->
$a.remove()