This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import akka.actor.{Props, Actor, ActorSystem} | |
class A extends Actor { | |
override def receive = { | |
case other => println(other) | |
} | |
} | |
object Main extends App { | |
val system = ActorSystem("main") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func myHandlerFunc(i int) http.HanderFunc { | |
return func(w http.ResponseWriter, r *http.Request) { | |
str := fmt.Sprintf("hello %d", i) | |
w.Write([]byte(str)) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"bufio" | |
"os" | |
) | |
func main() { | |
f := os.Open("somefile") | |
defer f.Close | |
rdr := bufio.NewReader(f) | |
for { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ( | |
ErrInvalidCommand = errors.New("invalid command") | |
ErrInvalidNumArgs = errors.New("wrong num args") | |
ErrInvalidInt = errors.New("invalid int") | |
) | |
const ( | |
create = "CREATE" | |
modify = "MODIFY" | |
set = "SET" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "github.com/gorilla/mux" | |
func main() { | |
r := mux.NewRouter() | |
r.HandleFunc("/reservations/{key}", func1).Methods("POST") | |
r.HandleFunc("/values/{key}/{lock_id}", func2).Queries("release", "").Methods("POST") | |
r.HandleFunc("/values/{key}", func3).Methods("PUT") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.actor._ | |
class PhotosLoader extends Actor { | |
override def act() { | |
loop { | |
react { | |
case photoToLoad:PhotoToLoad => | |
val bmp = getBitmap(photoToLoad.url) | |
if(bmp != null) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package my.package | |
import java.util.concurrent.CountDownLatch; | |
import java.util.concurrent.atomic.AtomicReference; | |
import java.util.concurrent.TimeUnit; | |
import java.util.Map; | |
import java.util.HashMap; | |
long requestTimeout = 5; | |
TimeUnit requestTimeoutUnit = TimeUnit.SECONDS;//wait max 5 seconds for StackMob requests to return. if longer, fail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public ResponseToProcess execute(ProcessedAPIRequest request, SDKServiceProvider provider) { | |
String url1 = "http://www.bing.com/search?q=kawasaki+ninja"; | |
GetRequest req1 = new GetRequest(url1); | |
String url2 = "http://www.bing.com/search?q=honda+nighthawk"; | |
GetRequest req2 = new GetRequest(url2); | |
String url3 = "http://www.bing.com/search?q=bmw+1300s"; | |
GetRequest req3 = new GetRequest(url3); | |
HttpService http = provider.getHttpService(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public ResponseToProcess execute(ProcessedAPIRequest request, SDKServiceProvider provider) { | |
HttpService http = provider.getHttpService(); | |
String url = "http://stackmob.com"; | |
GetRequest req = new GetRequest(url); | |
HttpResponse resp = http.get(req); | |
Map<String, String> map = new HashMap<String, String>(); | |
map.put("response_code", resp.getCode()); | |
map.put("url", url); | |
return new ResponseToProcess(HttpURLConnection.HTTP_OK, map); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scalaz._ | |
import Scalaz._ | |
import scalaz.concurrent._ | |
import java.util.concurrent.atomic._ | |
//the representation of a "chunk" of data (including errors or EOF) | |
//this was the best name I could ever come up with, but it seems like there's a better one | |
sealed trait Chunk { | |
def fold[T](valid: Array[Byte] => T, error: Throwable => T, eof: => T) = this match { | |
case ValidBytes(data) => valid(data) |
OlderNewer