Skip to content

Instantly share code, notes, and snippets.

<?php
$data = str_repeat("a", 1024*1024);
fwrite(STDOUT, $data);
fwrite(STDERR, $data);
exit(0);
?>
@matsu-chara
matsu-chara / github.html
Created October 22, 2013 17:19
pandocでmarkdownからgithubみたいなhtmlを生成するためのテンプレート pandoc -s --template=github.html ~~.md -o ~~.html のように使う
<!DOCTYPE html>
<html$if(lang)$ lang="$lang$"$endif$>
<head>
<meta charset="utf-8">
<meta name="generator" content="pandoc">
$for(author-meta)$
<meta name="author" content="$author-meta$">
$endfor$
$if(date-meta)$
<meta name="dcterms.date" content="$date-meta$">
@matsu-chara
matsu-chara / jlatexdiff_win.bat
Created October 24, 2013 09:52
latexdiffが日本語で動かなかったのでなんとかした。 線を引く機能なんてなかった。というか必要なかった > jlatexdff_win.bat before.tex after.tex で実行するとdiff.texが生成されます。 ディレクトリ内のtemp*.texが消えるので注意。 依存:latexdiff, nkf, sed
nkf -w %1 > temp1.tex
nkf -w %2 > temp2.tex
latexdiff -e utf8 temp1.tex temp2.tex >temp3.tex
nkf temp3.tex > temp4.tex
sed -e "s/\providecommand{.DIFadd}\[1\]{{.protect.color{blue}.uwave{#1}}}/\\providecommand{\\\\DIFadd}[1]{{\\\\protect\\\\color{red}#1}}/" ^
-e "s/\providecommand{.DIFdel}\[1\]{{.protect.color{red}.sout{#1}}}/\\providecommand{\\\\DIFdel}[1]{}/" ^
temp4.tex > temp5.tex
nkf -w temp5.tex > diff.tex
update
# Add Repository
tap phinze/homebrew-cask
tap homebrew/versions
tap homebrew/binary
tap homebrew/dupes
tap homebrew/homebrew-php
tap homebrew/science
tap sanemat/font
@matsu-chara
matsu-chara / gist:fef0c9fe1e79d75a54b5
Last active August 29, 2015 14:04
rubyのバージョンを新しくしたときの操作
rbenv install ほげほげ
rbenv global ほげほげ
~/.dotfiles/updateEnv.sh
package main
import (
"fmt"
"sync"
)
func work(num int, ch chan int) {
// Do Somthing
ch <- num
@matsu-chara
matsu-chara / api.sh
Last active August 29, 2015 14:07
各種webAPI用の関数
# yoを送信
function yo() {
[[ -n "$1" ]] && youser="$1" || youser='<default_yo_target_user_name>'
curl -s \
-d "api_token=<api-token>" \
-d "username=$youser" \
http://api.justyo.co/yo/
}
# pushoverで通知を送信
@matsu-chara
matsu-chara / sync_sh.js
Last active August 29, 2015 14:07
nodeで同期コマンド実行(おしゃべりhubot)
# npm install execSync --save
sh=require('execSync')
_.map(entries, (e)-> sh.run "SayKotoeri2 \"#{e.title}\"")
@matsu-chara
matsu-chara / gist:ff5e82747a246c3a485f
Created April 15, 2015 03:52
generator fizzbuzz in JS
require("babel/polyfill");
function* fizbuzgen() {
for(var i = 0;; ++i) {
if(i % 15 === 0) { yield "fizzbuzz"; }
else if(i % 5 === 0) { yield "buzz"; }
else if(i % 3 === 0) { yield "fizz"; }
else { yield "" + i; }
}
}
data Node = Leaf Integer | Branch Node Node
depth tree = case tree of
Leaf _ -> 1
Branch a b -> 1 + max (depth a) (depth b)
depth_tail tree = depth' tree id
where
depth' (Leaf _) cont = cont 1
depth' (Branch a b) cont =