This file contains hidden or 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
| // http://stackoverflow.com/questions/8104846/chart-of-ienumerable-linq-equivalents-in-scala | |
| xs.Aggregate(accumFunc) -> xs.reduceLeft(accumFunc) | |
| xs.Aggregate(seed, accumFunc) -> xs.foldLeft(seed)(accumFunc) | |
| xs.Aggregate(seed, accumFunc, trans) -> trans(xs.foldLeft(seed)(accumFunc)) | |
| xs.All(pred) -> xs.forall(pred) | |
| xs.Any() -> xs.nonEmpty | |
| xs.Any(pred) -> xs.exists(pred) | |
| xs.AsEnumerable() -> xs.asTraversable // roughly | |
| xs.Average() -> xs.sum / xs.length |
This file contains hidden or 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.Actor | |
| import akka.actor.ActorSystem | |
| import akka.actor.Props | |
| case class RequestMessage(req: String) | |
| case class ResponseMessage(resp: String) | |
| class ClientActor extends Actor { | |
| def receive = { | |
| case ResponseMessage(resp: String) => println(resp) |
This file contains hidden or 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.collection.mutable.ListBuffer | |
| object HelloWorld { | |
| def Start() { | |
| println("OnStart") | |
| } | |
| def Complete() { | |
| println("OnComplete") |
This file contains hidden or 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
| async void Main() | |
| { | |
| var cnn = new SqlConnection("Data Source=ERPDBUAT;Initial Catalog=Enterprise_Misc; Integrated Security=true"); | |
| cnn.Open(); | |
| var cmd = new SqlCommand("SELECT * FROM ShopService.DivisionRules WHERE DivCode = 'MHL001'", cnn); | |
| await cmd.ExecuteReaderAsync().ContinueWith(async rdr => { | |
| await rdr.Result.ReadAsync().ContinueWith(ok => { | |
| rdr.Result.GetBoolean(rdr.Result.GetOrdinal("IsMobileEnabled")).Dump(); | |
| rdr.Result.GetBoolean(rdr.Result.GetOrdinal("IsWebEnabled")).Dump(); |
This file contains hidden or 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
| async System.Threading.Tasks.Task Main() | |
| { | |
| await Get("http://bbc.co.uk").ContinueWith(async r => { | |
| using(var resp = r.Result.GetResponseStream()) | |
| { | |
| var content = new MemoryStream(); | |
| await resp.CopyToAsync(content); | |
| var html = System.Text.Encoding.Default.GetString(content.ToArray()); | |
| html.Dump(); // linqpad | |
| } |
This file contains hidden or 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
| // Given a simple web server sample: | |
| func main() { | |
| config := "this is some config" | |
| http.Handle("/", HandleDefaultRoute(config)) | |
| http.ListenAndServe(":8080", nil) | |
| } | |
| func HandleDefaultRoute(config string) http.HandlerFunc { |
This file contains hidden or 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 ( | |
| "bufio" | |
| "flag" | |
| "fmt" | |
| "log" | |
| "os" | |
| "regexp" | |
| "strings" |
This file contains hidden or 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 ( | |
| "fmt" | |
| "sort" | |
| ) | |
| type Person struct { | |
| Title string | |
| FirstName string |
This file contains hidden or 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
| void Main() | |
| { | |
| // create a pipeline task | |
| var mytask = new Task<OrderMatrixMessage>(); | |
| // register aspects | |
| mytask.Wrap(new LoggingAspect<OrderMatrixMessage>()); | |
| mytask.Wrap(new ExceptionLoggingAspect<OrderMatrixMessage>()); | |
| mytask.Wrap(new AsyncAspect<OrderMatrixMessage>()); | |
This file contains hidden or 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 ( | |
| "fmt" | |
| "sync" | |
| "time" | |
| ) | |
| func main() { | |
| var w sync.WaitGroup |