View reflection.go
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" | |
"reflect" | |
) | |
type Foo struct { | |
FirstName string `tag_name:"tag 1"` | |
LastName string `tag_name:"tag 2"` |
View chat.go
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" | |
"net" | |
) | |
type Client struct { | |
incoming chan string | |
outgoing chan string |
View gen_server.rb
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
require "ostruct" | |
require "securerandom" | |
module GenServer | |
class << self | |
def call(pid, method, *args) | |
entry = fetch_entry(pid) | |
value, state = entry.module.send(method, entry.state, *args) | |
entry.state = state | |
update_entry(pid, entry) |
View async_pmap.clj
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
(ns async-example.core | |
(:require [clojure.core.async :refer :all]) | |
(:gen-class)) | |
(defn my-pmap [f col] | |
(let [chans (repeatedly (count col) chan)] | |
(doseq [[c e] (map vector chans col)] | |
(go (>! c (f e)))) | |
(map <!! chans))) |
View chat_server.rb
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
require "socket" | |
require "rubygems" | |
require "bundler/setup" | |
require "celluloid" | |
module Chat | |
class ConnectionListener | |
include Celluloid |
View non_spooky.rb
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
foo = 1 | |
lambda do | |
if true | |
puts foo | |
else | |
foo = 2 | |
end | |
end.call |
View streams.js
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 Readable = require("stream").Readable; | |
function buildStream() { | |
var i = 0; | |
var stream = new Readable({objectMode: true}); | |
stream._read = function (n) { | |
if (i < 10) { | |
stream.push(i); | |
} else { |
View curry3.js
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
// The code below refers to examples found on page 120 of the PDF | |
// required functions | |
var _ = require("underscore")._; | |
var plays = [{artist: "Burial", track: "Archangel"}, | |
{artist: "Ben Frost", track: "Stomp"}, | |
{artist: "Ben Frost", track: "Stomp"}, | |
{artist: "Burial", track: "Archangel"}, |
View collect.go
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" | |
func collect(vals []int, f func(int) int) []int { | |
length := len(vals) | |
newVals := make([]int, length, length) | |
for i, val := range vals { | |
newVals[i] = f(val) |
View gist:1500444
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
socket = require "socket.io" | |
class Server | |
constructor: -> | |
@io = socket.listen 6788 | |
@io.configure => | |
@io.set "log level", -1 |
NewerOlder