This file contains 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 re | |
# ref: Regular Expression Cookbook p.26 | |
text = """!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ | |
aaa | |
bbb | |
""" | |
This file contains 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
#! /usr/bin/env python3 | |
import random | |
from wsgiref import simple_server | |
誰 = ['太郎', '二郎', '花子'] | |
どこ = ['東京', '大阪', '名古屋'] | |
どうした = ['泳いだ', '走った', '仕事した'] | |
def pick(l): |
This file contains 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
#!/bin/bash | |
# Create Ansible directory layaout based on Ansible Documentation http://docs.ansible.com/ansible/playbooks_best_practices.html | |
# | |
# inventory file for production servers | |
touch production | |
# inventory file for staging environment | |
touch staging |
This file contains 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
#!/bin/sh | |
# | |
# there are many symbolic link which link to some file in OLDDIR in directory SYBDIR. | |
# one day, OLDDIR has suddenly been moved to NEWDIR, and all symbolic link | |
# in SYBDIR has been dead. | |
# you can't link from NEWDIR to OLDDIR in some reason. | |
# this script renewal all symbolic file target to new one. | |
# | |
OLDDIR=dir1 |
This file contains 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
#!/bin/bash | |
# | |
# move all files in dir1,dir2,... to dirX | |
# | |
for i in `ls -1 dir*/*`;do | |
mv ${i} dirX | |
done |
This file contains 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
#!/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): |
This file contains 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 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): |
This file contains 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 time | |
import random | |
import psyco | |
psyco.full() | |
a = [] | |
for i in xrange(10000000): | |
a.append(random.randint(1,100000000)) | |
print "No,time" |
This file contains 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 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) |
This file contains 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 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): |
OlderNewer