Skip to content

Instantly share code, notes, and snippets.

@doloopwhile
doloopwhile / gist:690b3142bffca2f03fe8
Created February 22, 2015 10:00
パンは危険な食べ物
ある食べ物が身体にいいという話はよく聞きますが、アメリカの調査結果によれば、パンは危険な食べ物だということがわかりました。パン食が増えている日本も他人事ではありません!
その驚愕の事実をご紹介します。
・犯罪者の98%はパンを食べている
・パンを日常的に食べて育った子供の約半数は、テストが平均点以下である
・暴力的犯罪の90%は、パンを食べてから24時間以内に起きている
・パンは中毒症状を引き起こす。被験者に最初はパンと水を与え、後に水だけを与える実験をすると、2日もしないうちにパンを異常にほしがる
・新生児にパンを与えると、のどをつまらせて苦しがる
・18世紀、どの家も各自でパンを焼いていた頃、平均寿命は50歳だった
import sys
numbers = []
for line in sys.stdin:
numbers.append([int(s) for s in line.split()])
L, _, _ = numbers[0]
connections = {}
for x, y, y2 in numbers[1:]:
@doloopwhile
doloopwhile / fractal.png
Last active August 29, 2015 14:10
Sierpinski gasket with Elm
fractal.png
@doloopwhile
doloopwhile / gist:e808ddafe76f0dcefeee
Last active March 11, 2024 02:26
302 Found / 303 See Other / 307 Temporary Redirect

3つのリダイレクトの違い

実はGET(とHEAD)でリクエストされた時の動作は変わりません。 違いはPOST(やPUT/DELETE/OPTIONS)でリクエストされた時の動作です。

**"307 Temporary Redirect(一時的リダイレクト)"**は最初のURLでは実際の処理は行わず、リダイレクト先に改めてリクエストを出し直して欲しい時に使います。 したがって、最初のリクエストがPOSTであれば、 ブラウザはリダイレクト先にもPOSTを使います。 "301 Moved Permanently(恒久的リダイレクト)"の「一時的」版であると思えばよいでしょう。

import String
import Graphics.Input (Input, input)
import Graphics.Input.Field as Field
lhd : Input Field.Content
lhd = input Field.noContent
rhd : Input Field.Content
rhd = input Field.noContent
#!/usr/bin/env ruby
require 'yaml'
require 'pp'
ARGV.each do |a|
y = open(a) do |f|
YAML.load(f)
end
sort = lambda do |x|
import Text
main : Element
main = collage 500 500 [scale 0.5 (form (500, 500))]
form (w, h) =
toForm
(layers
[ fittedImage w h "/shells.jpg"
, container w h bottomLeft (centered (Text.color white (toText "She sells sea shells.")))
@doloopwhile
doloopwhile / open-gvim.sh
Created September 4, 2014 02:51
A script to open file in gvim (suport "/path/to/file:42" format)
#!/bin/bash
#
# open-gvim.sh
#
# - Open a file with gvim
# - If there is running gvim open file in there.
# - Open "path with line number" (like "/path/to/file:42" printed in grep and etc.)
if [ "$#" -eq 0 ]; then
if vim --serverlist | grep -q GVIM; then
@doloopwhile
doloopwhile / align.go
Created July 29, 2014 01:49
Align table
package main
func main() {
}
@doloopwhile
doloopwhile / git-rebase-i-peco
Last active August 29, 2015 14:03
git-rebase-i-peco: select rebase -i target
#!/bin/bash
set -o pipefail
set -e
HASH=$(git log --oneline | peco | cut -d " " -f 1)
if [ "$?" -ne 0 -o -z "$HASH" ]; then
exit 1
fi
git rebase -i "$HASH" $@
# install: