I hereby claim:
- I am seungha-kim on github.
- I am seungha (https://keybase.io/seungha) on keybase.
- I have a public key ASD-JkeF-XAvj-3k3NTxSDus07GPvR5R06YqfMielfesvQo
To claim this, I am signing this object:
# Monte Carlo method | |
# http://en.wikipedia.org/wiki/Monte_Carlo_method | |
from random import random as rnd | |
from math import sqrt | |
trial = 1000000 | |
hit = 0 | |
for i in range(trial): | |
if sqrt(rnd()**2 + rnd()**2) < 1: | |
hit += 1 | |
print 1.0*hit/trial*4 |
# Shows the procedures of metaclass initializing (__init__, __prepare__) | |
# tested in Python 3.4 | |
class MetaClass(type): | |
def __init__(self, name, bases, clsdict): | |
print('Class defined :') | |
print('mro', self.mro()) | |
print('name', name) | |
print('bases', bases) |
""" | |
Method resolution order with diamond inheritance | |
>>> print(Class3.mro()) | |
[Class3, Class1_2, Class1_1, Class2, Class0, <class 'object'>] | |
""" | |
class Meta(type): | |
def __repr__(self): | |
return self.__name__ | |
class Class0(metaclass=Meta): | |
pass |
with recursive fibo(ord, m, n) as ( | |
values (1, 1, 1) | |
union all | |
select ord+1, n, m+n from fibo where ord < 10 | |
) select m from fibo; | |
/* result : | |
m | |
---- | |
1 | |
1 |
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
foo = 1 | |
# expected [1, 1, 1] | |
gen = (foo for i in range(3)) | |
# but... | |
foo = 2 | |
list(gen) | |
# result: [2, 2, 2] |
var express = require('express'); | |
var EventEmitter = require('events'); | |
var bodyParser = require('body-parser'); | |
var app = express(); | |
var messageRouter = new EventEmitter(); | |
app.use(bodyParser.urlencoded({ extended: false })); | |
app.use(express.static('.')); |
:f bower_components/purescript-prelude/src/Prelude.js | |
:m bower_components/purescript-prelude/src/Prelude.purs | |
:f bower_components/purescript-eff/src/Control/Monad/Eff.js | |
:m bower_components/purescript-eff/src/Control/Monad/Eff.purs | |
:f bower_components/purescript-console/src/Control/Monad/Eff/Console.js | |
:m bower_components/purescript-console/src/Control/Monad/Eff/Console.purs | |
:f bower_components/purescript-eff/src/Control/Monad/Eff/Unsafe.js | |
:m bower_components/purescript-eff/src/Control/Monad/Eff/Unsafe.purs | |
import Prelude | |
import Control.Monad.Eff.Console |
I hereby claim:
To claim this, I am signing this object:
#3366CC | |
#DC3912 | |
#FF9900 | |
#109618 | |
#990099 | |
#3B3EAC | |
#0099C6 | |
#DD4477 | |
#66AA00 | |
#B82E2E |