Skip to content

Instantly share code, notes, and snippets.

@cloverrose
cloverrose / ama.py
Created April 14, 2012 08:39
example amazon search using bottlenose and ElementTree
#coding: utf-8
access_key_id=''
secret_key=''
associate_tag='-22'
region='JP'
comic=u'ONE PIECE'
xmlns='{http://webservices.amazon.com/AWSECommerceService/2011-08-01}'
node=2278488051#本>漫画・アニメ・BL>コミック
zassi_node=13384021#本>雑誌
import bottlenose
@cloverrose
cloverrose / ama_asin.py
Created April 14, 2012 09:28
example bottlenose.ASIN search
#coding: utf-8
access_key_id=''
secret_key=''
associate_tag='-22'
region='JP'
xmlns='{http://webservices.amazon.com/AWSECommerceService/2011-08-01}'
import bottlenose
from xml.etree.ElementTree import fromstring
def getASIN():
amazon=bottlenose.Amazon(access_key_id,secret_key,associate_tag,Region=region)
@cloverrose
cloverrose / .xmodmaprc
Created April 28, 2012 23:06
Keyboard mapping : JP keyboard -> US keyboard like
! unusing en-mark key next to BackSpace -> backslash (bar when push shift)
keycode 132 = backslash bar
! unusing right bracket next to enter -> return
keycode 51 = Return
! unusing muhenkan and henkan next to space -> space
keycode 102 = space
keycode 100 = space
@cloverrose
cloverrose / run_test_error.py
Created May 19, 2012 04:31
[Django] [python manage.py test] this is error program!! Django組み込みのテストを拡張してtest.py以外のスクリプト(mytest.pyやawesome.py)内のdoctestも実行できるようにする
# -*- coding:utf-8 -*-
"""
this is error program
これは間違いを示すためのプログラムです。
(1)と(2)のforループはmodels.pyに記述された
doctestを複数回テストスイーツに追加してしまいます。
その結果、予期しないテストが実行されてしまいます。
例えば、doctest内でデータベースに値を追加するコードがあったとすると、
複数回同じ値を追加することになります。
"""
@cloverrose
cloverrose / run_test.py
Created May 19, 2012 05:51
[Django] [python manage.py test] Django組み込みのテストを拡張してtest.py以外のスクリプト(mytest.pyやawesome.py)内のdoctestも実行できるようにする
# -*- coding:utf-8 -*-
from django.utils import unittest
from django.db.models import get_app, get_apps
from django.test import _doctest as doctest
from django.test.simple import DjangoTestSuiteRunner,build_suite,doctestOutputChecker,build_test,DocTestRunner,reorder_suite,TestCase,get_tests
from django.test import simple
my_test_modules=['mytest','awesome']
@cloverrose
cloverrose / ipython_config.py
Created June 23, 2012 22:54
IPython. 1)>>> 2)... 3)Ctrl-D 4)separate in and out
# Configuration file for ipython.
c = get_config()
#------------------------------------------------------------------------------
# InteractiveShellApp configuration
#------------------------------------------------------------------------------
# A Mixin for applications that start InteractiveShell instances.
#
@cloverrose
cloverrose / princessButtercup.io
Created August 12, 2012 13:27
seven language "Io" p59
unless := method(
(call sender doMessage(call message argAt(0))) ifFalse(
call sender doMessage(call message argAt(1))) ifTrue(
call sender doMessage(call message argAt(2)))
)
westley := Object clone
westley trueLove := true
princessButtercup := Object clone
westley sendMessage := method(princessButtercup unless(trueLove,
("It is false" println), ("It is true" println)))
@cloverrose
cloverrose / fib.io
Created August 12, 2012 14:37
Seven language "Io" p61
// Seven language "Io" day2 Q1
// fib
fib_recur := method(if((call sender doMessage(call message argAt(0))) == 1, 1,
if((call sender doMessage(call message argAt(0))) == 2, 1,
fib_recur( (call sender doMessage(call message argAt(0))) -1) +
fib_recur( (call sender doMessage(call message argAt(0))) -2))))
(fib_recur(1) == 1 and
fib_recur(2) == 1 and
@cloverrose
cloverrose / fib.pl
Created August 20, 2012 15:29
Seven languages "Prolog" day2
% Seven languages "Prolog" day2
fib(1, [1]).
fib(2, [1, 1]).
fib(N, [Head|[X|[Y|Tail]]]) :- fib(M, [X|[Y|Tail]]), N is M + 1, Head is X + Y.
import Image
def getpix(img, r, g=0, b=0):
ret = []
sizex, sizey = img.size
for x in range(sizex):
for y in range(sizey):
_r, _g, _b, _a = img.getpixel((x, y))
if _r == r and _g == g and _b == b: