Skip to content

Instantly share code, notes, and snippets.

View derekbassett's full-sized avatar

Derek Bassett derekbassett

View GitHub Profile
@retronym
retronym / mvn2sbt.scala
Created May 3, 2010 17:17
mvn2sbt: quick hack to turn <dependencies> into SBT
object scala {
val version = "SCALA_VERSION$"
}
val xml = <dependencies>
<dependency>
<groupId>org.scalanlp</groupId>
<artifactId>scalala_${scala.version}</artifactId>
<version>0.3.1</version>
</dependency>
@nictuku
nictuku / gist:997386
Created May 29, 2011 01:47
golang union types.
// Objective: demonstrate that there are more use cases
// for union types than previously thought.
// http://groups.google.com/group/golang-nuts/browse_thread/thread/fbde059a7cfd2fa9
//
// Interface inference.
// We already have type inference, so this would be very Go-like:
type typeA int
func (x typeA) A() {}
func (x typeB) C() {}
@jimbojsb
jimbojsb / gist:1630790
Created January 18, 2012 03:52
Code highlighting for Keynote presentations

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

@guilleferrer
guilleferrer / Date Range Mongo Query
Created January 24, 2012 11:50
Query for a date range using Mongo Timestamps
db.Collection.find({
created_at : {
'$gte': new Timestamp(new Date(2012, 0, 21), 0),
'$lte': new Timestamp(new Date(2012, 0, 22), 0)
})
@jcaraballo
jcaraballo / git-branch-between-different-repositories.md
Created March 6, 2012 01:05
How to fork a github repository in bitbucket

#Create bitbucket branch

##Create local branch

$ git checkout -b sync
Switched to a new branch 'sync'
$ git branch
  master
* sync
@jboner
jboner / latency.txt
Last active May 3, 2024 15:17
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
@abesto
abesto / gist:3476594
Created August 26, 2012 09:27
Go: Newton's method for square root
/*
A Tour of Go: page 44
http://tour.golang.org/#44
Exercise: Loops and Functions
As a simple way to play with functions and loops, implement the square root function using Newton's method.
In this case, Newton's method is to approximate Sqrt(x) by picking a starting point z and then repeating: z - (z*z - x) / (2 * z)
@fjavieralba
fjavieralba / KafkaLocal.java
Last active March 23, 2021 09:57
Embedding Kafka+Zookeeper for testing purposes. Tested with Apache Kafka 0.8
import java.io.IOException;
import java.util.Properties;
import kafka.server.KafkaConfig;
import kafka.server.KafkaServerStartable;
public class KafkaLocal {
public KafkaServerStartable kafka;
public ZooKeeperLocal zookeeper;
@rosterloh
rosterloh / getopts.sh
Created June 2, 2014 16:07
An example of how to use bash getopts
#!/bin/bash
######################################################################
#This is an example of using getopts in Bash. It also contains some
#other bits of code I find useful.
#Author: Linerd
#Website: http://tuxtweaks.com/
#Copyright 2014
#License: Creative Commons Attribution-ShareAlike 4.0
#http://creativecommons.org/licenses/by-sa/4.0/legalcode
# A little Meteor CheatSheet about Iron-Router. (updated on a weekly basis)
# Check our Studio: https://gentlenode.com/
meteor add iron:router
meteor update iron:router
# Iron Router > Configuration