Skip to content

Instantly share code, notes, and snippets.

View jamesthompson's full-sized avatar

James Thompson jamesthompson

View GitHub Profile
@jamesthompson
jamesthompson / sublimecheatsheet.md
Created November 4, 2013 18:22
Sublime Text 3 Command Sheet

Sublime Text 3 Cheat Sheet

Files and Tokens

  • Command palette ⌘⇧P
  • Search files ⌘P
  • Search file symbols ⌘R
  • Search project symbols ⌘⇧R
  • Goto definition ⌘⌥↓
@jamesthompson
jamesthompson / sublime prefs
Created November 7, 2013 20:49
My sublime prefs
{
"color_scheme": "Packages/Color Scheme - Default/Monokai Bright.tmTheme",
"dictionary": "Packages/Language - English/en_GB.dic",
"font_face": "Monaco",
"font_size": 10,
"ignored_packages":
[
"Vintage",
"Theme - Refined"
],
@jamesthompson
jamesthompson / sbt.sublime-build
Last active January 3, 2016 05:08
sbt build file for sublime if sbt script is present in project path
{
"cmd": ["sbt"],
"file_regex": "^\\[error\\] ([.a-zA-Z0-9/-]+[.]scala):([0-9]+):",
"selector": "source.scala",
"working_dir": "${project_path:${folder}}",
"variants": [
{
"name": "sbt_compile",
"cmd": ["${project_path:${folder}}/sbt compile"],
@jamesthompson
jamesthompson / GetRedis.scala
Created March 18, 2014 16:17
Get all keys and values from Redis
using: "net.debasishg" %% "redisclient" % "2.11"
// GetRedis.apply will print out all the keys and values in a csv list
object GetRedis {
import com.redis.{RedisClient, RedisClientPool}
def apply = {
val rcp = new RedisClientPool(
sys.env.getOrElse("REDIS_HOST", "localhost"),
6379
)
@jamesthompson
jamesthompson / RedisFreeAlgebra
Created January 19, 2015 22:00
An example toy algebra for Redis actions
// This should work with Scala 2.10.4 & scalaz 7.1, core, effect and concurrent packages
import scalaz.{ concurrent, Free, Functor, Monad, syntax }
import concurrent.Task
import Free.{freeMonad => _, _}
import syntax.monad._
// Describe the set of actions - which are functors
sealed trait RedisF[+A] {
def map[B](fn: A => B): RedisF[B]
@jamesthompson
jamesthompson / EncodingCheck.scala
Created March 24, 2015 16:56
Testing JSON encoding using Lenses and Arbitrary Generators
import argonaut._, Argonaut._
import org.scalacheck._, Prop._
import scalaz._, Scalaz._
object EncodingTestExample extends Properties("Encoding Json Test Example") {
case class Vehicle(
wheelsCount: Option[Int],
engineParts: List[String]
)
let
region = "us-west-2";
accessKeyId = "CORRECTAWSKEY";
defaults =
{ config, pkgs, resources, ... }:
{ deployment.targetEnv = "ec2";
deployment.ec2.accessKeyId = accessKeyId;
deployment.ec2.region = region;
@jamesthompson
jamesthompson / machines.nix
Created May 1, 2015 19:06
machine network def
{ numZookeeperNodes ? 1 }:
with import <nixpkgs/lib>;
let
makeMachine = n: nameValuePair "zk-${toString n}"
({ config, pkgs, nodes, ... }:
{
defaults =
{ config, pkgs, ... }:
{ deployment.targetEnv = "virtualbox";
deployment.virtualbox.memorySize = 2048; # Mb
deployment.virtualbox.headless = true;
};
}
@jamesthompson
jamesthompson / TrentTree.hs
Created September 6, 2015 16:19
Dir Tree Prog
module TrentTree where
import Control.Monad.Trans.Class -- from the `transformers` package
import Control.Monad.Trans.Except -- from the `errors` package
import Data.Monoid ((<>))
import Data.Tree
import System.Directory (doesDirectoryExist,
getDirectoryContents)
import System.FilePath (combine, takeFileName)