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
| #! /usr/bin/env python | |
| # coding: utf-8 | |
| # | |
| # update/delete google appengine entity by sql like syntax... | |
| # | |
| # sample: | |
| # - update | |
| # noresult('update MyModel set name = \'hoge\', age = 10') # update all entities | |
| # noresult('update MyModel set name = \'fuga\' where id = 10') # update entities which is specified in where clause | |
| # * unavailable - multiple inequality filter property |
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
| #!/usr/bin/python2.6 | |
| # coding: utf-8 | |
| import cgi | |
| import re | |
| import urllib | |
| from BeautifulSoup import BeautifulSoup as bs | |
| def conv(txt): | |
| lst = [] |
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
| Imports Microsoft.Scripting | |
| Imports Microsoft.Scripting.Hosting | |
| Imports IronPython.Hosting | |
| Public Class Form1 | |
| Dim beziers As New List(Of Object) | |
| Dim working As ArrayList = Nothing | |
| Dim ctrls As New List(Of Point) | |
| Dim index() As Integer = {-1, -1} | |
| Dim focuses() As Integer = {-1, -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
| # https://twitter.com/#!/mnzktw/status/128811724907360256 | |
| def to26(n): return n and (to26(n / 26) if n / 26 > 0 else []) + [n % 26] or [0] | |
| def toA1(n): return ''.join(['ABCDEFGHIJKLMNOPQRSTUVWXYZ'[d if i == len(to26(n - 1)) - 1 else d-1] for i,d in enumerate(to26(n - 1))]) | |
| print map(toA1, [1, 10, 2000, 30000, 500000, 1000000]) # => ['A', 'J', 'BXX', 'ARIV', 'ABKPT', 'BDWGN'] |
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
| #!/usr/bin/env pypy | |
| from random import choice | |
| from string import ascii_letters as ls | |
| import time | |
| import StringIO | |
| try: | |
| import __pypy__ | |
| except: | |
| pass |
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
| from multiprocessing import Queue as mQueue, Process | |
| from multiprocessing.sharedctypes import Value | |
| import ctypes | |
| import time | |
| import random | |
| def consumer(i, q): | |
| while True: | |
| item = q.get() | |
| if item is None: |
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
| # ref: http://d.hatena.ne.jp/tasukuchan/20100420/how_to_use_pyftpdlib | |
| from pyftpdlib import ftpserver | |
| authorizer = ftpserver.DummyAuthorizer() | |
| authorizer.add_user('user', 'password', './user', perm='elradfmw') | |
| ftp_handler = ftpserver.FTPHandler | |
| ftp_handler.authorizer = authorizer | |
| address = ('localhost', 21) | |
| ftpd = ftpserver.FTPServer(address, ftp_handler) | |
| ftpd.serve_forever() |
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
| #!/bin/sh | |
| tbl=deny.sqlite3 | |
| log=/var/log/auth.log | |
| sqlite3 $tbl 'create table if not exists hosts (ipaddr varchar(255) primary key);' | |
| for addr in $(grep Invalid $log | awk '{print $10}' | sort | uniq) | |
| do | |
| sqlite3 deny.sqlite3 "insert or ignore into hosts values ('$addr')" | |
| done |
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
| #!/bin/sh | |
| # 桁揃えされていないファイル(ex. 1.jpg,...,10.jpg,...etc) | |
| # を数値順に表示する。 | |
| # | |
| /bin/ls -1 $1 \ | |
| | tee /tmp/ls.txt \ | |
| | egrep -o '[0-9]+' \ | |
| | awk '{printf("%010d\n",$_)}' \ | |
| | paste - /tmp/ls.txt \ | |
| | sort -k1 \ |
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
| job = set([ | |
| # id name | |
| (1, 'animator'), | |
| (2, 'blacksmith'), | |
| (3, 'cook'), | |
| (4, 'doctor'), | |
| (5, 'engineer'), | |
| (6, 'founder'), | |
| (7, 'guitarist'), | |
| ]) |