Skip to content

Instantly share code, notes, and snippets.

View shiumachi's full-sized avatar

Sho Shimauchi shiumachi

View GitHub Profile
#!/bin/bash
#
# move all files in dir1,dir2,... to dirX
#
for i in `ls -1 dir*/*`;do
mv ${i} dirX
done
#!/usr/bin/python
# print prime number between 2 - N with re module, where N is argv[1]
# very very slow
import sys,re
r = re.compile('^(..+)\\1+$')
N = int(sys.argv[1])
for i in xrange(2,N):
if not r.match('x' * i):
import time
import psyco
psyco.full()
def alloc(size, default = 0): return [default] * size
print "No,time"
for i in xrange(9):
t0 = time.clock()
N = pow(10,i)
a = alloc(N)
import time
import psyco
psyco.full()
print "No,time"
for i in xrange(8):
t0 = time.clock()
N = pow(10,i)
a = []
for j in xrange(N):
import time
import random
import psyco
psyco.full()
print "No,time"
for i in xrange(8):
t0 = time.clock()
N = pow(10,i)
for j in xrange(N):
import time
import random
import psyco
psyco.full()
a = []
for i in xrange(10000000):
a.append(random.randint(1,100000000))
print "No,time"
import time
import psyco
psyco.full()
print "No,time"
for i in xrange(9):
t0 = time.clock()
N = pow(10,i)
a = 0
for j in xrange(N):
import sys
import time
import psyco
psyco.full()
print "No,time"
for i in xrange(8):
t0 = time.clock()
N = pow(10,i)
a = 0.0
@shiumachi
shiumachi / detect_us_phone_number.sh
Created January 12, 2011 14:56
detect us phone number using regexp
#!/bin/sh
grep -H -e "^\(([0-9]\{3\})\|[0-9]\{3\}-\)[0-9]\{3\}-[0-9]\{4\}$" test.in