Skip to content

Instantly share code, notes, and snippets.

View ynaoto's full-sized avatar

Naoto Yoshioka ynaoto

View GitHub Profile
# -*- coding: utf-8 -*-
import sys
import codecs
sys.stdout = codecs.getwriter('utf_8')(sys.stdout)
import itertools
for a in ["".join(p) for p in itertools.permutations(u"たかやまうこん")]:print a
background(255, 0, 0);
PImage img = loadImage("179033_486608097723_1903922_n.jpg");
img.loadPixels();
int n = img.width * img.height;
for (int i = 0; i < n; i++) {
color c = img.pixels[i];
float a = alpha(c);
float r = red(c);
float g = green(c);
float b = blue(c);
@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 / 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 / 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 / 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)