Skip to content

Instantly share code, notes, and snippets.

import collection.mutable.Queue
import se.scalablesolutions.akka.actor.Actor
import Actor._
case class Enqeue(msg:String)
case class Deqeue(f : (String) => Unit)
class QueueingActor extends Actor {
private val queue = new Queue[String]
println(queue)
@brianhsu
brianhsu / gist:767888
Created January 6, 2011 13:35
連線猜數字 Actor 模擬版
import scala.actors.Actor
import scala.actors.Actor._
import scala.util.Random
/**
* 猜數字伺服器回傳的結果
*
* @param x 使用者輸入的答案
* @param a 猜數字遊戲裡的A(數字對,位置也對)
@jamiew
jamiew / pimp_prompt.sh
Created January 21, 2011 17:55
put this in your .bashrc/.bash_profile... works with both git and svn
parse_git_branch() {
ref=$(git symbolic-ref -q HEAD 2> /dev/null) || return
printf "${1:-(%s)}" "${ref#refs/heads/}"
}
parse_svn_revision() {
local DIRTY REV=$(svn info 2>/dev/null | grep Revision | sed -e 's/Revision: //')
[ "$REV" ] || return
[ "$(svn st)" ] && DIRTY=' *'
echo "(r$REV$DIRTY)"
@t0ster
t0ster / gist:792488
Created January 23, 2011 22:02
Python like import in coffee-script
Ti.API.debug "In tango.init"
IMPORTED = []
# Setting sys.path
sys = {}
sys.path = ['site-packages', '.']
class ImportError extends Error
constructor: (@message, @fileName, @lineNumber) ->
@splhack
splhack / Makefile
Created May 6, 2011 02:17
Makefile for adb
SRCS+= adb.c
SRCS+= adb_client.c
SRCS+= commandline.c
SRCS+= console.c
SRCS+= file_sync_client.c
SRCS+= fdevent.c
SRCS+= get_my_path_linux.c
SRCS+= services.c
SRCS+= sockets.c
SRCS+= transport.c
nnoremap <Leader>pa :<C-u>call PerlReplacePackageName()<CR>
function! PerlPackageNameFromFile()
let filename = expand('%:p')
let package = substitute(filename, '^.*/lib/', '', '')
let package = substitute(package, '\.pm$', '', '')
let package = substitute(package, '/', '::', 'g')
return package
endfunction
@ggd543
ggd543 / 思考一下TernaryOp.test中发生了什么.scala
Created November 23, 2011 07:30
一个比较难懂的隐式转换过程
object TernaryOp {
class Ternary[T](t: T) {
println("Ternary")
def is[R](bte: BranchThenElse[T,R]) = {
println("is ... ")
if (bte.branch(t)) bte.then(t) else bte.elze(t)
}
}
class Branch[T](branch: T => Boolean) {
println("branch");
@asouza
asouza / scala2.10-reflection
Created March 6, 2012 14:34
Scala 2.10 new Reflection API
import scala.reflect.api._
import scala.reflect.runtime._
import scala.reflect.runtime.Mirror._
object Pimps{
implicit def pimp(str:String) = new {
def test = println("hello")
}
}
@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@amscotti
amscotti / md5.coffee
Last active January 18, 2021 12:54
MD5 hashing
crypto = require('crypto');
#Quick MD5 of text
text = "MD5 this text!"
md5hash1 = crypto.createHash('md5').update(text).digest("hex")
#MD5 of text with updates
m = crypto.createHash('md5')
m.update("MD5 ")
m.update("this ")