Skip to content

Instantly share code, notes, and snippets.

View anarcher's full-sized avatar
😞

myoung-su,shin anarcher

😞
View GitHub Profile
from gearman import GearmanClient
from gearman.task import Task
JOB_SERVER = ['127.0.0.1:4730']
if __name__ == '__main__':
client = GearmanClient(JOB_SERVER)
ret3 = client.do_task(Task("hello","task...",timeout=1))
print ret3
ret = client("hello","world")
@anarcher
anarcher / example.html
Created December 3, 2009 09:52
history.right.js
<script type="text/javascript" src="./right-src.js"></script>
<script type="text/javascript" src="./history.right.js"></script>
<script type="text/javascript">
var observer = new Observer();
observer.observe('change', function(hash) {
alert(hash);
});
var aHistory = new History({
#1. 딕셔너리 만들때
key = (1,2,3,4,5)
value =('a','b','c','d','e')
b = zip(key,value)
print b
> { 1 : "a" , 2 : "b" }
print b[1]
> "a"
#2. 문자 포맷팅.
@anarcher
anarcher / by-name parameter.scala
Created August 18, 2010 05:05
Scala Currying & By-name parameter (function value)
scala> def a(x : => Unit) { print("a") }
a: (x: => Unit)Unit
scala> a {
| print("b")
| }
@anarcher
anarcher / twitter_dispatch_example.scala
Created August 22, 2010 05:07
twitter dispatch example scala
scala> import dispatch._
import dispatch._
scala> import Http._
import Http._
scala> import json.Js._
import json.Js._
scala> import twitter._
import twitter4j._
val listener = new StatusListener {
override def onStatus(status:Status) {
println(status.getText)
}
override def onDeletionNotice(notice : StatusDeletionNotice) {}
override def onTrackLimitationNotice(numOfLimitStatues : Int) {}
override def onException(ex : Exception) { ex.printStackTrace }
}
scala> import net.liftweb.mongodb._
import net.liftweb.mongodb._
scala> import org.bson.types.ObjectId
import org.bson.types.ObjectId
scala> MongoDB.defineDb(HFDB, MongoAddress(MongoHost("localhost", 27017), "hotflow"))
scala> import models._
import models._
@anarcher
anarcher / CollectionStyle.scala
Created September 5, 2010 15:36
MongoDB-SoySauce-sketch
val db = MongoDB("hotflow")
db('post) < ("postId" -> 1212 ) :: ("post" -> "text" ) :: ("username" -> "anarcher") :: Nil
db 'post ? ("postId" -> 121) | (0,10)
db('post).find( ("postId" -> 121) ).limit(10).offset(0)
db.getMongoDb
db.getCollection("post")
임의의 알파벳 시퀀스를 입력받아서, 해당 알파벳으로 만들 수 있는 순서의 조합을 모두 구한다.
결과는 문자열의 오름차순으로 정렬하려 출력한다. 예를 들어, "AB", "BA" 가 있는 경우 "AB"가 "BA"보다 먼저 나와야 한다.
ex)
"ABC" -> "ABC", "ACB", "BAC", "BCA", "CAB", "CBA"
"AAB" -> "AAB", "ABA", "BAA"
"ABA" -> "AAB", "ABA", "BAA"
"000" -> "000"
@anarcher
anarcher / urlfetch_example.scala
Created September 22, 2010 12:34
google app engine URLFetch scala example
import com.google.appengine.api.urlfetch._
import java.net.URL
import java.net.URLEncoder
val urlFetch = URLFetchServiceFactory.getURLFetchService()
val url = new URL("http://me2day.net/api/get_posts/anarch.json")
val req = new HTTPRequest(url,HTTPMethod.GET)
val params = Map("scope" -> "all")
val qs = Map(params : _* ).foldLeft("")((qs,p) => { (if(qs != "") qs+"&" else qs)+"%s=%s".format(p._1,p._2) })
req.setPayload(qs.getBytes)