Skip to content

Instantly share code, notes, and snippets.

View kuenishi's full-sized avatar
🎴

UENISHI Kota kuenishi

🎴
View GitHub Profile
# 謎のスクリプト
# a script that ties the files with same prefix,
import sys, os, re
prefix = sys.argv[1]
suffix = '.avi'
valid = re.compile( r'^%s%s' % (prefix, suffix) )
list = os.listdir('.')
@kuenishi
kuenishi / iTunes2twitter.py
Created November 2, 2009 06:59
iTunesで再生中の曲をTwitterに垂れ流す
from Foundation import *
from ScriptingBridge import *
import time, twitter
iTunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes")
prev = current = iTunes.currentTrack().name()
api = twitter.Api("kuenishi", "***********")
while(True):
if (current != prev): # new track has came!
@kuenishi
kuenishi / gist:226650
Created November 5, 2009 02:35
print the code in python
print open(__file__).read()
@kuenishi
kuenishi / index.py
Created December 22, 2009 05:19
an easy desktop search script for windows - simple filename-matching-with-keywords index (LICENSE: MIT)
# index-generation script for search.py - an easy desktop search script
import sys, os, re, pickle, stat
pfile = "_filelist.pkl"
path_separator = "\\"
#class File:
# def __init__(self, path, filename):
# self.path = path
# self.filename = filename
@kuenishi
kuenishi / topn.py
Created January 2, 2010 08:29
top-N-elements-only container
# Copyright (c) 2010 UENISHI Kota
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
@kuenishi
kuenishi / dets_test.erl
Created January 25, 2010 14:24
dets's max-data per file test.
% MIT License: http://www.opensource.org/licenses/mit-license.php
%
% as the data exceeds data-size limit of one dets file,
% dets:insert/2 returns {error,{{bad_object,read_buckets},"test.dets"}}.
module(dets_test).
-export([test/0]).
-module(hex).
-export([itos/1, hashs/1]).
-type hexchar() :: 48..57 | 65..70 .
-spec itos( I::non_neg_integer() )-> [ hexchar() ].
itos(I) when is_integer(I)->
lists:reverse(itos_(I)).
@kuenishi
kuenishi / watchdog.c
Created March 6, 2010 17:44
instead of omake -P.
/*
Copyright (c) 2010 kuenishi <kuenishi_at_gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-module(yc). % Y Combinator
-compile(export_all).
-spec f( Fact::fun( (integer())-> integer() ) )-> fun((integer())-> integer()).
f(Fact)-> fun (1)-> 1;(X)-> X*Fact(X-1) end.
-spec y( F::fun( (fun((TypeA)-> TypeB)) -> fun((TypeA)-> TypeB) ))-> fun((TypeA)->TypeB).
y(F)-> fun(X)-> (F( y(F)))(X) end.
-spec do(integer())-> integer().
(* solving http://recruit.drecom.co.jp/event2010
State the minimum combination of initial value
in Fibonacci series including 7110.
※limit to Natural number
7110を含むフィボナッチ数列で、
初期値の組み合わせが一番小さいものをあげろ。
※自然数に限る *)