Skip to content

Instantly share code, notes, and snippets.

print "Hello, World!\n"
# on python 3.*, print ("Hello, World!\n")
@lesguillemets
lesguillemets / listen_to_skype.bash
Created August 26, 2013 15:13
skype の シューーン↑↑ \ぴょっ/ を耐久 400 回.聞きたくてたまらないあなたに. aplay の入ってる環境でしか動作しません.Mac なら afplay でうまくいくかもしれないとの噂. もちろん skype の音声ファイルの場所が違うかもしれませんしその辺はよきにはからえ.
#!/bin/bash
for i in `seq 1 400`;
do
printf "%3d\t" "$i"
aplay /usr/share/skype/sounds/SkypeLogin.wav
done
class Hello(object):
def __init__(self, friend):
self.friend = friend
def sayhello(self):
print "Hello, %s!"%(self.friend)
# helloworld = Hello('World')
# helloworld.sayhello()
for element in a:
do_something_with(element)
# 1
for element in a
do_something_with(element)
end
# 2
a.each do |element|
do_something_with(element)
end
#!/usr/bin/python
# encoding:utf-8
import random
class Neuron(object):
# 神経細胞体 class.
# i) synapse からの入力を受けることができ,
# ii) ある間にうけた入力の総和が threshold を超えれば
# iii) 発火し,本人から出ていく synapse に伝達される.
@lesguillemets
lesguillemets / NerveSystem.py
Created October 2, 2013 09:40
nerve system emulator (?) license : MIT
#!/usr/bin/python
# encoding:utf-8
import random
THRESHOLD = 1 # threshold for neuron's firing.
SYNAPSE_LIMIT = 4 # how strong synapses are allowed to be.
LTPRATIO = 1.1 # LTP : strength = strength*LTPRATIO
FORGETRATIO = 0.95 # A little forgetfullness
SUPPRESSION_RATIO = 0.5 # the frequency of suppressive synapses
SUP_WEAKNESS = 0.7 # when initialising,
b :: Integral a => a -> a -> a --なんか数が2個入ったら中で色々やって数が1個出て来るような b っていうものがあるとするわね
b m n
| m == 0 = f n -- b の頭に 0, 尻になんか入ったらこうなる
| n == 0 = b (m-1) 1 -- b の頭に 0 より大きい数,尻に 0 が入った場合こうなる
| otherwise = b m $ b (m+1) n -- b の頭にも尻にも 0 でない数が入った場合こうなる
f :: Integral a => a -> a -- f っていうのは数が1個入ったら中で色々やって数が1個出てくるようなもの
f n = n + 1 -- この f は入った数に 1 を加えて出すというルールってことにしましょうか
#!/usr/bin/python
'''
heapsort
from : https://en.wikipedia.org/wiki/Heapsort#Pseudocode
'''
def heapsort(a):
''' input : an unordered array a'''
count = len(a)
# first place a in max-heap order
#!/usr/bin/python
# coding:utf-8
# from : http://urasunday.com/u-2_09/comic/002_001.html
class B(object):
def __init__(self, m, n, f=lambda n: n+1):
self.m = m
self.n = n
self.f = f