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 utils = utils || {}; | |
utils.linq = function(){ | |
range = function(start, end){ | |
var numbers = []; | |
for(var x=start; x<=end;x++) | |
numbers.push(x); | |
return numbers; | |
} |
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
// set up arrays | |
var numbers = [1,12,4,18,9,7,11,3,101,5,6]; | |
var strings = ['this','is','a','collection','of','words']; | |
// array.reduce - find largest number | |
var largestValue = numbers.reduce(function(x,y){ return x > y ? x : y }); | |
console.log('largest number: ' + largestValue); | |
// array.reduce - find longest string |
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 utils = utils || {}; | |
// pipeline | |
utils.pipeline = function(){ | |
var handlers = []; | |
var register = function(handler){ | |
if(typeof handler !== 'function') | |
throw { name: 'InvalidTypeException', description: 'handler should be a function'} |
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.collection.mutable.ListBuffer | |
val msg1 = new Network1(1); | |
val msg2 = new Network1(2); | |
val msg3 = new Network1(3); | |
val pipeline = new PipeLine[Network1](); | |
pipeline.register((x: Network1) => new GetUndeliveredOrders(x)) | |
.register((x: Network1) => new GetDeliveryInfo(x)) | |
.register((x: Network1) => new GetPodImage(x)) |
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 ( | |
"fmt" | |
"sync" | |
"time" | |
) | |
func main() { | |
var w sync.WaitGroup |
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
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 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 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 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 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 | |
} |
OlderNewer