Skip to content

Instantly share code, notes, and snippets.

@ikasamt
ikasamt / gist:141800
Created July 7, 2009 01:02
hoge.txtはスレッドの内容をテキストのままコピペしたファイル
data = File.read('hoge.txt')
timestamps = data.scan(/2005\/05\/26\(木\)\s(\d{2}:\d{2}:\d{2})/)
p timestamps.length
hash = {}
timestamps.each do |timestamp|
if hash[timestamp].nil?
hash[timestamp] = 1
else
hash[timestamp] += 1
end
#
# ソースコードリーティング支援スクリプト
# --------------------------------------
# 特定のディレクトリ下のファイルを再帰的に読み込み、大きなテキストファイルにする
# プリントアウトして読むためのソースを作ることを目的としている
#
$KCODE = 'u'
require 'jcode'
class Rule(object):
""" Handles each routing rule. """
def __init__(self, pattern, **param):
super(Rule, self).__init__()
self.pattern = pattern[:-1] if pattern.endswith('/') else pattern
self.regex = self.pattern
self.param = param
self.matches = re.findall(':([^/.]+)', self.pattern)
<?php
// http://wpdocs.sourceforge.jp/プラグイン_API#Filters
// wordpress向けプラグイン
// これはモックです動作しません。
// 自動リンクを生成する
function mindia_autolink_filter($content) {
$username = 'hoge';
$words = something_api($username);
$linked_words = array();
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="Hello Wave">
<Require feature="wave-preview" />
</ModulePrefs>
<Content type="html">
<![CDATA[
Hello, Wave!
]]>
</Content>
<?php
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ikasamt
ikasamt / gist:218369
Created October 26, 2009 01:53
config.py of logging module at python2.5 have a little bug in load configration file , this is bugfix patch for that.
*** config_old.py 2009-10-26 10:45:06.000000000 +0900
--- config_new.py 2009-10-26 10:47:58.000000000 +0900
***************
*** 108,113 ****
--- 108,114 ----
if not len(flist):
return {}
flist = string.split(flist, ",")
+ flist = map(lambda x: string.strip(x), flist)
formatters = {}
#`wget http://www.python.org/ftp/python/2.5.5/Python-2.5.5.tar.bz2`
#`tar -jxf Python-2.5.5.tar.bz2`
#`cd Python-2.5.5`
#`./configure`
#`make`
#`sudo make install`
lines = <<-CODE
wget http://www.python.org/ftp/python/2.5.5/Python-2.5.5.tar.bz2
tar -jxf Python-2.5.5.tar.bz2
$KCODE="utf-8"
puts 'You\'re swell!'
puts "Youre swell!"
puts "文字列最後の円マーク: \\"
puts "\\2,500"
puts "\\2,500"
@ikasamt
ikasamt / sha256_performanceTest.py
Created February 14, 2011 00:35
sha256関数の呼び出し方と実行速度確認
import hashlib
import datetime
loop_size = 100 *1000
start_time = datetime.datetime.now()
for i in range(loop_size):
source_data = '123456%d' % i
v = hashlib.sha256(source_data).hexdigest()
end_time = datetime.datetime.now()