Skip to content

Instantly share code, notes, and snippets.

@mslinn
mslinn / sbtDeps
Created July 12, 2012 21:13
Shows all dependencies of an SBT project
#!/bin/bash
echo "Direct dependencies"
sbt 'show all-dependencies' | \
gawk 'match($0, /List\((.*)\)/, a) {print a[1]}' | \
tr -d ' ' | tr ',' '\n' | sort -t ':' | \
tr ':' '\t' | expand -t 30
echo -e "\nAll dependencies, including transitive dependencies"
sbt 'show managed-classpath' | tr -d ' ' | tr ',' '\n' | \
@nvkv
nvkv / .vimrc
Created July 10, 2012 11:18
.vimrc
set gfn=Menlo:h13
set tabstop=4
set shiftwidth=4
set expandtab
set linebreak
set wrap
set noswapfile
map ё `
@marktheunissen
marktheunissen / pedantically_commented_playbook.yml
Last active April 19, 2025 17:31 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
This playbook has been removed as it is now very outdated.
@erwink
erwink / swingactors.scala
Created June 16, 2012 14:58 — forked from viktorklang/swingactors.scala
Swing Actors using Akka
// ©2012 Viktor Klang
package akka.klang
import akka.dispatch.{ DispatcherPrerequisites, ExecutorServiceFactory, ExecutorServiceConfigurator }
import com.typesafe.config.Config
import java.util.concurrent.{ ExecutorService, AbstractExecutorService, ThreadFactory, TimeUnit }
import java.util.Collections
import javax.swing.SwingUtilities
@jboner
jboner / latency.txt
Last active April 28, 2025 17:59
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
@pedrofurla
pedrofurla / snippet.scala
Created May 12, 2012 03:51
Side-effect free handling of exceptions.The three first expressions can throw something
def exp[T](t: => T) =
(scala.util.control.Exception.allCatch either t).right
def readJson(dataField:Option[String],json:JsValue):Either[Throwable,JsValue] = {
for (
contents <- exp( json.asJsObject.getFields("rsp")(0) );
stat <- exp( contents.asJsObject.getFields("stat")(0).convertTo[String] );
jsonObject <- exp (
dataField match {
case Some(field) => contents.asJsObject.getFields(field)(0)
@stonegao
stonegao / gist:2657252
Created May 11, 2012 03:06 — forked from mardambey/gist:2654382
Reset Kafka offsets in ZooKeeper by deleting the corresponding nodes.
/**
* Notes: This code uses AsyncValue[T], a custom class that uses actors
* to allow concurrent operations on the provided type. It can be replaced
* by an Atomic object from the java.util.concurrent package or something
* that provides similar functionality.
*/
/**
* Resets the offsets for the given group / topic pair.
@kiritsuku
kiritsuku / Othello.scala
Last active October 3, 2015 14:48
Othello/Reversi implementation in Scala
import scala.util.parsing.combinator.JavaTokenParsers
import scala.util.Try
/*
* Compiles only with 2.10
*/
object Othello extends App with InputHandler {
private[this] var game = Game.empty
@viktorklang
viktorklang / swingactors.scala
Created April 19, 2012 17:25
Swing Actors using Akka
// ©2012 Viktor Klang
package akka.klang
import akka.dispatch.{ DispatcherPrerequisites, ExecutorServiceFactory, ExecutorServiceConfigurator }
import com.typesafe.config.Config
import java.util.concurrent.{ ExecutorService, AbstractExecutorService, ThreadFactory, TimeUnit }
import java.util.Collections
import javax.swing.SwingUtilities
@bhudgeons
bhudgeons / AggregationFrameworkTest.scala
Created February 21, 2012 16:24
MongoDB Aggregation Framework Via Casbah
import com.mongodb.casbah.Imports._
/*
* Simple test of the MongoDB Aggregation Framework via Casbah
*
* [Note: only works on MongoDB 2.1+]
*
* The "students" collection consists of student test score records that [simplified] look like this:
*
{