Skip to content

Instantly share code, notes, and snippets.

View ynaoto's full-sized avatar

Naoto Yoshioka ynaoto

View GitHub Profile
@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()
@ynaoto
ynaoto / get_redirect.php
Created March 26, 2013 02:38
Delegate GET request to another PHP.
$q = http_build_query($_REQUEST);
header("Location: foo.php?$q");
# adduser foo
# passwd foo
# visudo
@ynaoto
ynaoto / gist:6061998
Created July 23, 2013 12:27
Install PEAR, PHP_CodeSniffer and PHPCompatibility on Max OS
sudo php /usr/lib/php/install-pear-nozlib.phar
sudo pear install PHP_CodeSniffer
cd /usr/lib/php/pear/PHP/CodeSniffer/Standards
sudo mv ~/git/PHPCompatibility .
sudo cp php.ini.default php.ini
sudo vi php.ini # add /usr/lib/php/pear to include_path
phpcs --standard=PHPCompatibility a.php
@ynaoto
ynaoto / gist:6794477
Created October 2, 2013 14:16
ローカルな git ディレクトリを取り込む
cd foo # .git があって github で管理しているところ
git remote add a /bar # ローカルな .git があるところ
git subtree add --prefix=bar a master
git push
git remote rm a
@ynaoto
ynaoto / gist:6886096
Created October 8, 2013 15:00
Hello World
a;main(){int b=++a+a,c=b+b,d=c+c,e=d+d,f=e+e,g=f+f,h=g+f+c,i=d+b+a,j=g+d;char s[]={j,h+a,h+d,h+d,h+i,f,j+e-a,h+i,h+e-b,h+d,h,b+d,--a};puts(s);}
@ynaoto
ynaoto / gh-pages
Created October 24, 2013 15:51
github pages
git checkout gh-pages
git merge master
git push origin gh-pages
Add the following 2 lines to the [remote "origin"] section of .git/config:
push = +refs/heads/master:refs/heads/gh-pages
push = +refs/heads/master:refs/heads/master
@ynaoto
ynaoto / gist:7148614
Created October 25, 2013 02:29
あるレポの一部を、他のレポにコピー
cd /src_repo
git subtree split -P path/to/folder -b PathToFolder_branch
cd /dst_repo
git pull /src_repo PathToFolder_branch
git push
cd /src_repo
git branch -D PathToFolder_branch
@ynaoto
ynaoto / xpng
Created December 9, 2013 05:31
PNGファイルの構造をざざっと見る
#include <stdio.h>
#include <ctype.h>
typedef unsigned char BYTE;
typedef int INT4;
int main()
{
BYTE pngHdr[8];
BYTE buf4[4];