Skip to content

Instantly share code, notes, and snippets.

View masahitojp's full-sized avatar
🎯
Focusing

Masato Nakamura masahitojp

🎯
Focusing
View GitHub Profile
@masahitojp
masahitojp / gist:1632335
Created January 18, 2012 10:25
unittest2.skipIfのラップクラス
import random
import unittest
platform = "linux"
# for class
def platform_skip_test(platform_list):
def _platform_skip_test(c):
is_skip = (platform in platform_list)
for m in c.__dict__:
@masahitojp
masahitojp / gist:1686632
Created January 27, 2012 02:39
pattern matchの練習。Regexpでpattern matchして数値文字列を変換する
val r = """^(\d+)$""".r
var hoge = "123456789" match {
case r(n) => n.toInt
case _ => println("Do not matched")
}
val huga = Array("9876") match {
case n if n.size ==1 =>
n(0) match {
case re(t) => t.toInt
@masahitojp
masahitojp / gist:1716424
Created February 1, 2012 10:40
Play2.0ではsession.getIDがないよ
package controllers
import play.api._
import play.api.mvc._
import play.libs
import java.util.UUID;
import play.cache.Cache
object Application extends Controller {
!SLIDE
<img src="http://www.playframework.org/public/2.0/images/mini-logo.png" />
!SLIDE
one
!SLIDE
@masahitojp
masahitojp / gist:1948563
Created March 1, 2012 09:35
underscore.jsのglobalへの変数"_"の定義部分のみの抜きだし
(function(global){
var a = function(){console.log("test");};
global.a =a;
})(this || window);
console.log(typeof window.a);
console.log(window.a());
@masahitojp
masahitojp / py
Created March 16, 2012 11:11
mongoDBの検証用
// query
var query={
"updated_time" : {
"$gte" : ISODate("2012-01-09T00:00:00Z"),
"$lte" : ISODate("2012-01-10T00:00:00Z")
}
}
// 1500件データ投入
var JSTDate = function(str) { return ISODate(str + 'T00+09:00'); };
def center(str :String, num :Int):String = {
val temp = " " * ((num - str.length + 1)/2)
val rtn = temp + str + temp
rtn.substring(0,num)
}
val dan = 4;
val dan_position = dan * 2 - 1
List(0,1,2,3).map(s=>println(center("*" * (1+s*2), dan_position)))
>>> a = [i for i in xrange(10)]
>>> a
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> add_oddth = lambda lst:reduce(lambda a,b:a+b ,lst[0::2])
>>> add_oddth(a)
20
https://raw.github.com/gist/2693387/8f05be9c1bf7fc83bfdd93858cb77edd68d5ec71/code_reading.md

分散ハッシュテーブルは、、堅牢なP2Pネットワークに不可欠な要素です。すべてのコピーが同じデータを共有するアプリケーションを作成する方法を学びます。

分散コンピューティングでは、分散ハッシュ表(DHTs)は最近、画期的な効果があった。混沌とした、アドホックトポロジの第一世代の P2P アーキテクチャは新生の証明可能なプロパティと優れたパフォーマンスとトポロジのセットに取って代わられています。 DHTアルゴリズムの知識は、分散アプリケーションの将来の発展に重要な要素になるでしょう。