Skip to content

Instantly share code, notes, and snippets.

Sho Shimauchi shiumachi

Block or report user

Report or block shiumachi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@shiumachi
shiumachi / match_literal_text.py
Created Feb 3, 2014
制御文字や句読点にマッチする正規表現
View match_literal_text.py
import re
# ref: Regular Expression Cookbook p.26
text = """!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
aaa
bbb
"""
@shiumachi
shiumachi / sentence_generator.py
Created Jun 4, 2014
簡単な文章を自動生成するWSGIサーバ
View sentence_generator.py
#! /usr/bin/env python3
import random
from wsgiref import simple_server
= ['太郎', '二郎', '花子']
どこ = ['東京', '大阪', '名古屋']
どうした = ['泳いだ', '走った', '仕事した']
def pick(l):
@shiumachi
shiumachi / create_ansible_directory_layout.sh
Created Sep 4, 2015
Create Ansible Directory Layout Based on Ansible Document
View create_ansible_directory_layout.sh
#!/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
View update_all_link.sh
View filemove1.sh
#!/bin/bash
#
# move all files in dir1,dir2,... to dirX
#
for i in `ls -1 dir*/*`;do
mv ${i} dirX
done
View prime_list_regexp.py
#!/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):
View randtest.py
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):
View sort.py
import time
import random
import psyco
psyco.full()
a = []
for i in xrange(10000000):
a.append(random.randint(1,100000000))
print "No,time"
View alloc.py
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)
View append.py
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):
You can’t perform that action at this time.