Skip to content

Instantly share code, notes, and snippets.

@yatt
yatt / A.cbl
Created February 22, 2012 17:08
my first coding experience in COBOL; CODEFORCES Surprise Language Round #5 http://codeforces.com/contest/153
IDENTIFICATION DIVISION.
PROGRAM-ID. SOLUTION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A PIC 9(10) VALUE ZEROES.
01 B PIC 9(10) DISPLAY VALUE ZEROES.
01 STR PIC X(11).
01 I PIC 9(10) VALUE ZEROES.
01 FLAG PIC 9 VALUE ZEROES.
@yatt
yatt / infinite_NAMEKO_extension.js
Created February 24, 2012 08:19
無限なめこ拡張; ブラウザのjsコンソールなどで「jQuery.getScript('http://bit.ly/xoQxZN')」で実行されます。
$('#txt').append($("<form onsubmit=\"return $('#screen_name').val(),namekoSrc = goldenSrc = 'http://api.dan.co.jp/twicon/' + $('#screen_name').val() + '/bigger',$('img').attr('src', 'http://api.dan.co.jp/twicon/' + $('#screen_name').val() + '/bigger'),$('#message').text('無限' + $('#screen_name').val()),false;\">screen_name:<input type='text' id='screen_name'/></form>"))
@yatt
yatt / case-insensitive.diff
Created February 25, 2012 11:55
a patch for nginx to allow case-insensitive http method
--- nginx-1.0.12/src/http/ngx_http_parse.c 2012-02-06 05:02:59.000000000 +0900
+++ tmp/nginx/src/http/ngx_http_parse.c 2012-02-25 20:38:10.167048823 +0900
@@ -146,6 +146,14 @@
break;
}
+ /* capitalize HTTP method */
+ {
+ int i;
+ for (i = 0; isalpha(p[i]); i++)
@yatt
yatt / impsqlite3.py
Created March 3, 2012 21:13
a python sciprt for importing csv file to sqlite3 database
#! /usr/bin/python
# coding: utf-8
################################################################
# date: 2012-03-03
# name: impsqlite3
# author: brainfs/yatt darknesssharp@gmail.com
#
# pretty csv import program for sqlite3
# 2012-03-02 supporting csv which is quoted each column by '"'
@yatt
yatt / datatable_performance.vb
Created March 17, 2012 18:53
System.Data.DataTableの走査に係る、Rows使用時と不使用時の計算量オーダー比較
Imports System.Diagnostics
Module Module1
Dim n As Long = 100
Sub Main()
Dim dt As DataTable
Dim n As Integer = 10000
Dim sw As New Stopwatch
Dim x As Long
#!/usr/bin/env python
# coding: utf-8
import pydot
import sub
def walk(root, graph):
#node = pydot.Node('"' + str(root.id) + '"')#root.name)
node = pydot.Node(root.name)
graph.add_node(node)
for child in root.getChildren():
@yatt
yatt / bing.sh
Created March 22, 2012 16:31
bashでいかにしておっぱい画像をダウンロードするか〜2012
#! /bin/sh
# サンプル: 5並列でキーワード「XXX」で画像検索、ダウンロード
# $ for n in $(seq 0 50 199); do sh ~/bing.sh XXX $n 50 | xargs -t -P 5 -L 10 wget -q;done
KEY=# assign your application key; bing api requires application key
QUERY=$(python -c "import urllib; print urllib.quote('$1')")
START=0
COUNT=50
if [ $# -gt 1 ];
then
@yatt
yatt / cls.py
Created March 31, 2012 17:30
output class hierarchy as png image
#! /usr/bin/python2.6
# coding: utf-8
import inspect
import tree as vis
import imp
# https://github.com/yatt/twitterlib
from twitterlib import *
#class A(object):pass
#class B(A):pass
@yatt
yatt / skiplist.py
Created April 6, 2012 10:50
skiplist.py
#! /usr/bin/python2.6
# coding: utf-8
# ref: http://live-e.naist.jp/sensor_overlay/5/doc/yoshida.pdf
# ref: http://en.wikipedia.org/wiki/Skip_list
# ref: http://msdn.microsoft.com/en-us/library/Aa289151
# 利点
# バランス操作が不要
# lock-free
@yatt
yatt / nimport.py
Created April 12, 2012 06:49
import module via network in python
#! /usr/bin/python2.6
import os
import urlparse
import tempfile
import urllib
import imp
def load(url, mod):
ofs = tempfile.NamedTemporaryFile()
try: