This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for i in $@ | |
| do | |
| (sleep $i; echo $i) & | |
| done | |
| wait | |
| # sh ./sleep.sh 5 9 0 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import fractions | |
| def reduce(p, q): | |
| common = fractions.gcd(p, q) | |
| return (p // common, q // common) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [alias] | |
| co = checkout | |
| st = status | |
| cm = commit -m | |
| graph = log --graph --decorate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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色ターミナル |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "{0:02d}:{1:02d}".format(8, 8) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| from PIL import Image | |
| import cv | |
| import urllib2 | |
| import cStringIO | |
| import pdb | |
| SIZE = 200 | |
| class UrlImgTrimmer: |