Skip to content

Instantly share code, notes, and snippets.

View bwmcadams's full-sized avatar

Brendan McAdams bwmcadams

View GitHub Profile
@mpilquist
mpilquist / document.scala
Created March 3, 2016 18:48
Example of using scodec to decode a document of fields
package foo
import scodec.bits._
import scodec._
import scodec.codecs._
case class Document(fields: Vector[(String, Field)])
sealed trait Field
case class IntField(value: Int) extends Field
@chriseidhof
chriseidhof / pechakucha.sh
Last active January 19, 2017 11:56
Advance Deckset slides every 20 seconds
#/bin/bash
# Works from Deckset 1.2 upwards. Make sure you have a document opened.
#
# If you're using the Trial version change "Deckset" to "Deckset Trial"
osascript -e 'repeat' -e 'tell application "Deckset" to tell document 1 to set slideIndex to slideIndex + 1' -e 'delay 20' -e 'end repeat'
@RWJMurphy
RWJMurphy / v0.34.11.ini
Created February 10, 2013 09:09
Dwarf Therapist memory layout for DF 0.34.11 on OSX
[info]
checksum=0x8f421f9c
version_name=v0.34.11
complete=true
[addresses]
translation_vector=0x01636a88
language_vector=0x01636a70
creature_vector=0x015f56ec
dwarf_race_index=0x015dcf80
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@jboner
jboner / latency.txt
Last active May 10, 2024 14:27
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
package com.mongodb.casbah
package commons
object Syntax extends Syntax
trait Syntax {
implicit def name(name: String) = Name(name)
}
case class Name(name: String) {
@bwmcadams
bwmcadams / org.mongodb.mongod.plist
Created March 2, 2011 23:59
Suggested Plist for Mac MongoDB 1.8+, enables durability and clean shutdown
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.mongodb.mongod</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/mongodb/bin/mongod</string>
<string>run</string>
@bwmcadams
bwmcadams / CallableMap.scala
Created January 26, 2011 21:34
Quick and dirty version of Map in Scala that can be 'called' like Python dicts where unknown methods are pulled out as Map keys. Uses the 2.9 dynamic trait.
class CallableMap extends scala.collection.mutable.HashMap[String, Any] with Dynamic {
def invokeDynamic(name: String)(args: Any*) = {
println("Invoke Dynamic: (name = %s)(args: %s)".format(name, args))
get(name)
}
def typed[T]: T = {
asInstanceOf[T]
}