Skip to content

Instantly share code, notes, and snippets.

View JohnMurray's full-sized avatar

John Murray JohnMurray

View GitHub Profile
@JohnMurray
JohnMurray / sshfs_connect.py
Created July 15, 2013 03:35
A simple utility script for mounting a bunch of remote hosts over sshfs. Useful if you develop on 1 or more remote machines on a regular basis.
#!/usr/bin/env python
from subprocess import call
import os
servers = [
{
'host': 'some.remote.host', # host to connect to
'dir' : '/usr/local/supersecret/' # remote dir to mount
},
{
@JohnMurray
JohnMurray / Greeter.scala
Last active December 22, 2015 02:08
Code files for my blog post at http://johnmurray.io
import akka.actor.Actor
object Greeter {
case object Greet
}
class Greeter extends Actor {
def receive = {
case Greeter.Greet => {
println("Hello, World")
}
package main
import (
"flag"
"log"
"net/http"
"net/url"
)
var (
<?php
class Node {
public $key;
public $next;
public function __construct($key, $next=null) {
$this->key = $key;
$this->next = $next;
}
}
@JohnMurray
JohnMurray / braces-repl.scala
Last active December 28, 2015 14:58
Blog post
val s1 = {"hello"} // s1: String = hello
val s = "hello" // s: String = hello
@JohnMurray
JohnMurray / timing.scala
Created January 22, 2014 17:04
Simple timing wrapper for synchronous operations
def timing[A](x: => A): Int = {
import com.github.nscala_time.time.Imports._
import org.joda.time.PeriodType
val then = LocalDateTime.now
x
new Period(then, LocalDateTime.now, PeriodType.millis).getValue(0)
}
Object Util {
def dangerousString(str: String) : Future[String] = {
liveDangerously()
Future.successful(str)
}
// now becomes
def dangerousString(str: String) : Future[String] = {
@JohnMurray
JohnMurray / linked-list.rs
Created January 29, 2014 12:39
Simple linked-list struct in Rust that doesn't work.
struct Node<T> {
value: T,
next: Option<~Node<T>>
}
struct LinkedList<T> {
head: ~Node<T>,
tail: ~Node<T>
}
@JohnMurray
JohnMurray / .travis.yml
Last active August 29, 2015 14:00
Code snippets for scala-project blog post on www.johnmurray.io
language: scala
scala:
- 2.10.3
script:
- sbt compile test:compile
- sbt scalastyle
- sbt test
jdk:
- oraclejdk7
- openjdk7
@JohnMurray
JohnMurray / set.scala
Created October 28, 2014 17:34
Extract from BuiltinCommands object in SBT
def set = Command(SetCommand, setBrief, setDetailed)(setParser) {
case (s, (all, arg)) =>
val extracted = Project extract s
import extracted._
val dslVals = extracted.currentUnit.unit.definitions.dslDefinitions
// TODO - This is possibly inefficient (or stupid). We should try to only attach the
// classloader + imports NEEDED to compile the set command, rather than
// just ALL of them.
val ims = (imports(extracted) ++ dslVals.imports.map(i => (i, -1)))
val cl = dslVals.classloader(currentLoader)