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
struct foo { | |
float *stuff; | |
int offset; | |
float operator[](size_t i) const | |
{ | |
return stuff[i + offset]; | |
} | |
float &operator[](size_t i) |
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
def MPQ path | |
path | |
end | |
class ReplayFile | |
def initailize path | |
@archive = MPQ(path) | |
end | |
end |
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
// Scala's for comprehensions can be used like Haskell's do notation for monadic code, ie. its a compact way to string together computations sequentially. | |
val f = for { | |
a <- Future(10 / 2) // 10 / 2 = 5 | |
b <- Future(a + 1) // 5 + 1 = 6 | |
c <- Future(a - 1) // 5 - 1 = 4 | |
} yield b * c // 6 * 4 = 24 | |
val result = f.get() |
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
class EventBus | |
def self.publish event args | |
@subscribers[event].each do |sub| | |
# whatever meta stuff sends event to method on object (handler) :p | |
end | |
end | |
def self.subscribe event, handler, method | |
@subscribers[event] = { :handler => handler, :method => method } |
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
module MessageBus | |
class MessageBus | |
@handlers = {} | |
def self.subscribe message, handler, method | |
@handlers[message] ||= [] | |
@handlers[message] << { :handler => handler, :method => method } | |
end | |
def self.send message, args |
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.Actor | |
// defining messages -- Object = singleton, case class = DTO (sorta, generally) | |
object Born | |
case class Evolve(numberOfNeighbors: Int) | |
object Status | |
// receive is the method that handles incoming messages. | |
// alive: Receive and dead: Receive are defining alternative ways to respond to messages | |
// these will be switched on during runtime |
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
// controller | |
[CanViewProfile] | |
public ActionResult Show(int id) | |
{ | |
var view = new ShowProfileQuery(id).Execute(); | |
return View(view); | |
} | |
// before filter |
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
// possibly tail recursive :p | |
open System.IO | |
// Seq.toList because I don't know how to pattern match an empty sequence :) | |
let folderWithDepth' path depth = | |
try | |
System.IO.Directory.EnumerateDirectories(path) |> Seq.toList |> List.map (fun d -> (d, depth)) | |
with | |
| _ -> [] |
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
EXPR="$(cat | sed 's/\\/\\\\/g' | sed 's/\"/\\\"/g')" | |
export SHELL_NAME=${SHELL_NAME:="FSharp Interactive"} | |
export SHELL_INTERPRETER=${SHELL_INTERPRETER:="fsi"} | |
osascript << END | |
tell application "Terminal" | |
activate | |
set _foundTab to false |
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
type Greeting = () => String | |
def greet(g: Greeting) = { | |
println(g()) | |
} | |
def hello() = { "hello from Huey" } | |
greet(hello) // >> "hello from Huey" |
OlderNewer