Skip to content

Instantly share code, notes, and snippets.

@yuitest
yuitest / weightchoice.py
Last active August 29, 2015 13:57
重み付け乱択
# coding: utf-8
import random
import bisect
# 手本: http://qiita.com/methane/items/045982489cd7cf3720b3
# 変更点: append のメソッドを追加。
class WeightChoice(object):
def append(self, item, score):
@yuitest
yuitest / pytable.py
Created April 2, 2014 23:59
table を無理やり突っ込む
# coding: utf-8
from __future__ import unicode_literals, print_function
import sqlite3
import itertools
import types
import uuid
def table(connection, iterable, name=None):
if name is None:
UPPER_LINE_SYMMETRY = 'ABCDEHIKMOTUVWXY'
HORIOZANAL_LINE_SYMMETRY = 'BCDEHIKOX'
VERTICAL_LINE_SYMMETRY = 'AHIMOTUVWXY'
POINT_SYMMETRY = 'HINOSXZ'
BOTH_SYMMETRY = 'HIOX'
MIRROR_PAIR = 'MW'
ROTATION_PAIR = 'NZ'
# coding: utf-8
from __future__ import print_function
# kwargs にドメイン名による名前空間作っていろいろさせると捗る
def printer(x, *args, **kwargs):
print(x)
@yuitest
yuitest / mock.html
Created April 7, 2014 11:42
かなりシンプルな HTML のひな形。
<html>
<head>
<meta charset="utf-8">
<title>ここにタイトルを入れる</title>
<!-- <script src="http://code.jquery.com/jquery-latest.js"></script>-->
<style>
.simple {
margin: 0 auto;
font-family: "Courier New", monospace;
width: 50%; min-width: 80em;
笑わせようと必死過ぎて笑えないお笑い芸人
ゆるキャラ競争の激化
@yuitest
yuitest / eco.sh
Created April 11, 2014 13:52
自縄自縛する!
#!/bin/sh
ulimit -c 0
ulimit -d 8
ulimit -l 64
ulimit -m 0
ulimit -n 100
ulimit -p 8
ulimit -s 120
ulimit -t 1
ulimit -v 30000
sudo apt-get update
sudo apt-get install -y language-pack-ja
sudo apt-get install -y curl
sudo apt-get install -y python-pip virtualenvwrapper python-dev
@yuitest
yuitest / gist:10476459
Created April 11, 2014 15:08
Haskell っぽい zip 関数をもしシェルスクリプトでやりたいなら xargs
$ seq 1 10 | xargs -P 1 -L 2 echo
# 出力結果
1 2
3 4
5 6
7 8
9 10
@yuitest
yuitest / stdiocontrol.sh
Created April 11, 2014 16:54
引数を標準入出力につなぎ替えて、残りの引数を実行するシェルスクリプト
#!/bin/sh
exec < $1
shift
exec >> $1
shift
exec $*