Skip to content

Instantly share code, notes, and snippets.

for i in $@
do
(sleep $i; echo $i) &
done
wait
# sh ./sleep.sh 5 9 0 2
@cocodrips
cocodrips / A.py
Created May 11, 2014 11:48
GCJ Round1C のこーど
def solve(p, q):
p, q = reduce(p, q)
c = 1
while 2 * p < q:
if q % 2 == 0:
q //= 2
else:
return -1
c +=1
@cocodrips
cocodrips / reduce.py
Last active August 29, 2015 14:01
p / q を約分する
import fractions
def reduce(p, q):
common = fractions.gcd(p, q)
return (p // common, q // common)
[alias]
co = checkout
st = status
cm = commit -m
graph = log --graph --decorate
#utf setting
set-window-option -g utf8 on
set-window-option -g mode-keys emacs
set-window-option -g automatic-rename off
setw -g window-status-current-attr underscore
set-option -g default-shell /bin/zsh
# 256色ターミナル
def memoize(f):
table = {}
def func(*args):
if not args in table:
table[args] = f(*args)
return table[args]
return func
@memoize
def fi(n):
@cocodrips
cocodrips / format.py
Created April 10, 2014 14:49
string format
"{0:02d}:{1:02d}".format(8, 8)
@cocodrips
cocodrips / cmain.cpp
Last active August 29, 2015 13:58
競技プログラミング用テンプレ
#include <iostream>
#include <map>
#include <string>
#include <vector>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
using namespace std;
@cocodrips
cocodrips / ElevatorLimit.py
Created April 3, 2014 09:35
SRM201 div2 500
class ElevatorLimit:
def getRange(self, enter, exit, physicalLimit):
minimum = 1e100
maximum = -1e100
current = 0
for en, ex in zip(enter, exit):
current -= ex
minimum = min(minimum, current)
current += en
@cocodrips
cocodrips / url_img_trimmer.py
Last active July 23, 2016 03:54
urlから画像を取得してトリミングする
# -*- coding: utf-8 -*-
from PIL import Image
import cv
import urllib2
import cStringIO
import pdb
SIZE = 200
class UrlImgTrimmer: