Skip to content

Instantly share code, notes, and snippets.

View tlockney's full-sized avatar

Thomas Lockney tlockney

View GitHub Profile
@tlockney
tlockney / gist:1a0dbe6f8bd437b07d5f
Created February 8, 2015 06:55
Get a new random port
lazy val port = new ServerSocket(0).getLocalPort()
@tlockney
tlockney / .tmux.conf
Created June 18, 2014 17:07
Tmux conf for remapping the prefix key
# set the command prefix to `
set -g prefix "`"
unbind C-b
bind "`" send-prefix
@tlockney
tlockney / Foo.java
Created June 13, 2014 01:10
A simple example where basic String concatenation in Java is really better than a StringBuilder.
public class Foo {
static final String aConstant = "a constant";
public void concatSimpleString() {
String aString = "one" + aConstant + "two";
}
public void concatWithStringBuilder() {
StringBuilder sb = new StringBuilder();
@tlockney
tlockney / Vagrantfile
Last active August 29, 2015 13:57
This setup allows for quick hacking with an sbt console on an EC2 instance -- very useful for trying out the AWS APIs when you need to try things out. As an example, I wanted to make sure I understood how to get the various bits of meta-data that are visible only on EC2. Create the following files and run setup.sh to run everything.
Vagrant.configure("2") do |config|
config.vm.box = "dummy"
config.vm.provider :aws do |aws, override|
aws.access_key_id = "..."
aws.secret_access_key = "..."
# you'll need to create the EC2 keypair used here -- I called it vagrant for easy tracking
aws.keypair_name = "vagrant"
# you'll want to use a group that has at least SSH open

Keybase proof

I hereby claim:

  • I am tlockney on github.
  • I am tlockney (https://keybase.io/tlockney) on keybase.
  • I have a public key whose fingerprint is 7598 1B8B E5C7 2B03 80D2 E966 D594 D4EC ED46 8B80

To claim this, I am signing this object:

@tlockney
tlockney / actor.scala
Created June 12, 2013 17:24
While immutable data structures are preferable in Scala, it's not always obvious how to utilize them inside of an Akka actor when you need the actor to be stateful. Thankfully, Akka provides some help here, by use of the become method, which is designed to update the behavior of an actor. Scala supports closures, so we can pass the new state in …
import akka.actor.Actor
// Following the common Akka pattern of defining the messaging
// protocol in the companion object
object SampleActor {
case object GetState
case class UpdateState(key: String, value: String)
}
class SampleActor extends Actor {
@tlockney
tlockney / akka-docs.sh
Last active January 8, 2017 12:26
Akka docs on your Kindle!
# This only works with the current master branch of Akka
# Setup the necessary deps
brew install python
# adjust this depending on the latest version of Python that brew installed
export PATH=`brew --prefix python`/bin:/usr/local/share/python:$PATH
pip install sphinx
val javaRuntimeOptions = Seq(
"-Xmx2048M",
"-XX:+UseConcMarkSweepGC",
"-XX:+CMSClassUnloadingEnabled",
"-XX:MaxPermSize=512M",
"-Xshare:off",
"-Dcom.sun.management.jmxremote.port=9998",
"-Dcom.sun.management.jmxremote.authenticate=false",
"-Dcom.sun.management.jmxremote.ssl=false",
"-Djava.rmi.server.hostname=%s".format(hostname),
@tlockney
tlockney / hack.sh
Created April 7, 2012 00:20 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@tlockney
tlockney / gist:1964541
Created March 3, 2012 05:21
Install htop via Homebrew
# I always forget you can install homebrew formulas using direct URLs
brew install https://raw.github.com/adamv/homebrew-alt/master/unmaintained/htop.rb