Skip to content

Instantly share code, notes, and snippets.

View michaelahlers's full-sized avatar

Michael Ahlers michaelahlers

View GitHub Profile
@wrwills
wrwills / LensTest.scala
Created November 30, 2010 13:47
playing with some of the ideas from the Haskell fclabels library using the new Lens functionality in scalaz
import scalaz._
/**
* playing with some of the ideas from the Haskell fclabels library
* using the new Lens functionality in scalaz
*
* http://hackage.haskell.org/package/fclabels
*/
object LensTest {
@oxbowlakes
oxbowlakes / 3nightclubs.scala
Created May 13, 2011 15:14
A Tale of 3 Nightclubs
/**
* Part Zero : 10:15 Saturday Night
*
* (In which we will see how to let the type system help you handle failure)...
*
* First let's define a domain. (All the following requires scala 2.9.x and scalaz 6.0)
*/
import scalaz._
import Scalaz._
@johan
johan / laughing-man.svg
Created July 6, 2011 04:56
The Laughing Man (Ghost in the Shell), 1000 byte SVG :-)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ashwoods
ashwoods / pre-commit
Created October 11, 2011 17:19
pre-commit hook for VERSION file
#!/bin/sh
# Tag revisions like this:
# $ git tag -a -m "Version 0.2" v0.2 HEAD
VF=VERSION
DEFAULT_VERSION=UNKNOWN
LF='
'
@milessabin
milessabin / gist:1705644
Created January 30, 2012 17:47
Access to companion object of Foo via implicit resolution
trait Companion[T] {
type C
def apply() : C
}
object Companion {
implicit def companion[T](implicit comp : Companion[T]) = comp()
}
object TestCompanion {
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active July 7, 2024 13:22
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
anonymous
anonymous / gist:4026158
Created November 6, 2012 17:24
class ActorRefSerializer(val system: ExtendedActorSystem) extends kryo.Serializer[ActorRef] {
override def read(kryo: Kryo, input: Input, typ: Class[ActorRef]): ActorRef = {
val path = input.readString()
system.actorFor(path)
}
override def write(kryo: Kryo, output: Output, obj: ActorRef) = {
Serialization.currentTransportAddress.value match {
case null => output.writeString(obj.path.toString)
import scala.reflect.runtime.universe._
import scala.reflect.runtime.{currentMirror => cm}
trait Base {
def companion: MetaBase = {
val classSymbol = cm.classSymbol(getClass)
val moduleSymbol = classSymbol.companionSymbol.asModule
val moduleMirror = cm.reflectModule(moduleSymbol)
moduleMirror.instance.asInstanceOf[MetaBase]
}
@jbenet
jbenet / simple-git-branching-model.md
Last active June 17, 2024 14:53
a simple git branching model

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote