Skip to content

Instantly share code, notes, and snippets.

View fd00's full-sized avatar
💤
Always sleepy

Daisuke Fujimura (fd0) fd00

💤
Always sleepy
View GitHub Profile
#!/bin/sh
kernel=$(uname -r)
kernel=$(echo "${kernel}" | sed -e 's/(.*)//')
packages=$(($(cygcheck -cd | wc -l) - 2))
cpu=$(cat /proc/cpuinfo | grep 'model name' | sed -e 's/^.*: *//')
# removes (R) and (TM) from the CPU name so it fits in a standard 80 window
cpu=$(echo "${cpu}" | awk '$1=$1' | sed 's/([A-Z]\{1,2\})//g')
#!/bin/bash
for var in `compgen -A variable`
do
if [[ `declare -p $var` =~ "declare -a" ]]
then
x=`printf '${!%s[@]}' $var`
eval "keys=$x"
for key in $keys
do
x=`printf '${%s[%s]}' $var $key`
@fd00
fd00 / MultiServerExample.php
Created July 14, 2012 02:19
MultiServerExample.php
<?php
require_once '../src/phozzil/Phozzil.php';
use phozzil\net\MultiServer;
use phozzil\net\MultiServerAdapter;
abstract class MultiServerAdapterExample extends MultiServerAdapter
{
public function __construct($port)
@fd00
fd00 / Map.php
Created July 29, 2012 21:05
Map.php
public function each($function)
{
if (!is_callable($function)) {
throw new IllegalArgumentException('function must be callable');
}
foreach ($this->instance as $index => $key) {
$function($key, $this->instance[$key]);
}
}
@fd00
fd00 / funcall.php
Created August 13, 2012 15:02
funcall.php
<?php
fc_add_pre('require_once', 'pre_require_once');
fc_add_post('require_once', 'post_require_once');
require_once 'OS/Guess.php';
function pre_require_once($args)
{
printf("pre require_once (%s)\n", $args[0]);
@fd00
fd00 / csv2json-0.1-1bl1.src.patch
Created September 30, 2012 13:53
csv2json-0.1-1bl1.src.patch
--- origsrc/csv2json/process.c 2011-12-16 01:24:33.000000000 +0900
+++ src/csv2json/process.c 2012-09-25 08:20:48.875314100 +0900
@@ -13,6 +13,7 @@ int process(FILE *file, char *sep) {
char *p = buf;
list *l = NULL;
+ printf("[");
while((p = fgets(buf, BUFLEN, file)) != NULL) {
if(first) {
first = 0;
@fd00
fd00 / Archive.php
Created October 9, 2012 09:23
src/phozzil/io/archive/Archive.php
<?php
namespace phozzil\io\archive;
use phozzil\io\FileNotFoundException;
use phozzil\io\FileSystem;
use phozzil\io\IOException;
use phozzil\lang\IllegalArgumentException;
require_once 'File/Archive.php';
@fd00
fd00 / ThreadExample.php
Created October 18, 2012 14:27
ThreadExample.php
<?php
class ThreadExample extends Thread
{
public function run()
{
$id = $this->getThreadId();
printf("ID[%d] : start & sleep\n", $id);
sleep($id % 10);
printf("ID[%d] : done\n", $id);
}
cygport 0.14.1
PF = libpinyin-1.0.0-1bl2
S = /cygdrive/c/Users/fd0/src/libpinyin/libpinyin-1.0.0-1bl2/src/libpinyin-1.0.0
B = /cygdrive/c/Users/fd0/src/libpinyin/libpinyin-1.0.0-1bl2/build
D = /cygdrive/c/Users/fd0/src/libpinyin/libpinyin-1.0.0-1bl2/inst
C = /cygdrive/c/Users/fd0/src/libpinyin/libpinyin-1.0.0-1bl2/src/libpinyin-1.0.0/CYGWIN-PATCHES
T = /cygdrive/c/Users/fd0/src/libpinyin/libpinyin-1.0.0-1bl2/temp
CBUILD = x86_64-pc-cygwin
CHOST = x86_64-pc-cygwin
cygport 0.14.1
PF = libpinyin-1.0.0-1bl2
S = /cygdrive/c/Users/fd0/src/libpinyin/libpinyin-1.0.0-1bl2/src/libpinyin-1.0.0
B = /cygdrive/c/Users/fd0/src/libpinyin/libpinyin-1.0.0-1bl2/build
D = /cygdrive/c/Users/fd0/src/libpinyin/libpinyin-1.0.0-1bl2/inst
C = /cygdrive/c/Users/fd0/src/libpinyin/libpinyin-1.0.0-1bl2/src/libpinyin-1.0.0/CYGWIN-PATCHES
T = /cygdrive/c/Users/fd0/src/libpinyin/libpinyin-1.0.0-1bl2/temp
CBUILD = x86_64-pc-cygwin
CHOST = x86_64-pc-cygwin