Skip to content

Instantly share code, notes, and snippets.

@ashewring
ashewring / pre-commit
Created June 2, 2016 04:35 — forked from leesmith/pre-commit
Git pre-commit hook to search for bad things in a commit
#!/bin/sh
if git-rev-parse --verify HEAD >/dev/null 2>&1; then
against=HEAD
else
# run against initial commit
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
for FILE in `git diff-index --check --name-status $against -- | cut -c3-` ; do
@ashewring
ashewring / upgrade.md
Created June 2, 2016 04:29 — forked from leesmith/upgrade.md
Upgrade Postgres via Homebrew
@ashewring
ashewring / simple-git-workflow.md
Created June 2, 2016 04:28 — forked from leesmith/simple-git-workflow.md
Simple Git Workflow For Continuous Delivery

Simple Git Workflow For Continuous Delivery

Workflow guidelines:

  • master branch is always production-ready, deployable, 100% green test suite
  • New development is done on feature branches, with frequent rebasing onto master
  • Clean commit history by preferring to rebase instead of merge (git pull is configured to automatically rebase)

rebase workflow

Workflow

(ns erdos-c.core
[:require [yokogiri.core :refer :all]])
(def client (make-client :javascript false))
(defn page [uri]
(get-page client (str "http://en.wikipedia.org" uri)))
(defn link-snippets [uri]
(xpath (page uri) "//a"))
@ashewring
ashewring / MySlf4jEventHandler.scala
Created January 6, 2012 21:13 — forked from momania/MySlf4jEventHandler.scala
Single line logging evenhandler
package com.acme.logging
import akka.actor.Actor
import akka.event.EventHandler
import akka.event.slf4j.{Logger, Logging}
class MySlf4jEventHandler extends Actor with Logging {
import EventHandler._
self.id = ID
import sbt._
import Keys._
import Defaults._
//adding the Artifacts.settings to you project settings will create and publish the artifact defined as 'theMainArtifact'
object Artifacts {
val allTheArtifacts = TaskKey[Seq[(sbt.Artifact, java.io.File)]]("all-artifacts")
val theMainArtifact = TaskKey[File]("zip-artifact", "Create zip with all library dependencies")
val artifactConf = config("Artifact") hide //use this to scope the create artifact to this config
@ashewring
ashewring / gist:1423540
Created December 2, 2011 15:01 — forked from momania/gist:1379932
CoffeePot Cake
object CoffeePot extends App {
ComponentRegistry.coffeeWarmer.trigger
}
trait OnOffDevice {
def on: Unit
def off: Unit
}
trait SensorDevice {
@ashewring
ashewring / cake_pattern_di.scala
Created December 2, 2011 15:01 — forked from HarryHuang/cake_pattern_di.scala
Scala Dependency Injection: an improved cake pattern
//harry huang [huanghui.huang@gmail.com]
//
//After reading the original post [http://jboner.github.com/2008/10/06/real-world-scala-dependency-injection-di.html, ]
//the original cake pattern seems quite verbose for me, and it is quite invasive, so I spent a bit time
//and come up with an improved version of cake pattern, which I call it "Auto Cake DI". It is working
//well with any POST(plain old scala trait)/POSO(plain old scala object) which means that anything can be
//injected without modification or introducing new traits.
/*---------inject trait---------*/
trait Inject[+T] { def inject: T }
import sbt._
import Keys._
import org.sbtidea._
import SbtIdeaPlugin._
import Scope.{GlobalScope, ThisScope}
object BuildSettings {
val buildOrganization = "com.mojolly.backchat"
val buildScalaVersion = "2.9.0-1"
val buildVersion = "0.8.1-SNAPSHOT"