Skip to content

Instantly share code, notes, and snippets.

View farmdawgnation's full-sized avatar
:shipit:

Matt Farmer farmdawgnation

:shipit:
View GitHub Profile
@farmdawgnation
farmdawgnation / server.sh
Created January 18, 2016 22:13
A little lightweight server management script I wrote
#!/bin/bash
command -v aws >/dev/null 2>&1 || { echo >&2 "I require the AWS cli, but it is not installed."; exit 1; }
command -v jq >/dev/null 2>&1 || { echo >&2 "I require jq, but it is not installed."; exit 1; }
#export AWS_ACCESS_KEY_ID=ACCESS_KEY_HERE_IF_NOT_ALREADY_IN_ENVIRONMENT
#export AWS_SECRET_ACCESS_KEY=SECRET_KEY_HERE_IF_NOT_ALREADY_IN_ENVIRONMENT
#export AWS_DEFAULT_REGION=REGION_HERE_IF_NOT_ALREADY_IN_ENVIRONMENT
INSTANCE_ID=INSTANCE_ID_HERE
@farmdawgnation
farmdawgnation / example1.scala
Created March 7, 2015 16:02
Examples for skipping a scala version
(skip in compile) <<= scalaVersion { sv => () => sv == "2.9.3" }
abstract class SingletonSerializer[T](implicit mf: Manifest[T]) extends Serializer[T] {
val SingletonClass: Class[T] = mf.runtimeClass.asInstanceOf[Class[T]]
def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), T] = {
case (TypeInfo(SingletonClass, _), json) if json.extractOpt[String].map(_ endsWith "$").getOrElse(false) =>
val className = json.extract[String]
Class.forName(className).getField("MODULE$").get().asInstanceOf[T]
}
def serialize(implicit format: Formats) = {

Keybase proof

I hereby claim:

  • I am farmdawgnation on github.
  • I am farmdawgnation (https://keybase.io/farmdawgnation) on keybase.
  • I have a public key whose fingerprint is CD57 2E26 F60C 0A61 E6D8 FC72 4493 8917 D667 4D07

To claim this, I am signing this object:

@echo off
set SBT_LAUNCHER_PATH="project\sbt-launch-0.13.1.jar"
set SBT_LAUNCHER_SOURCE="http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.13.1/sbt-launch.jar"
if not exist %SBT_LAUNCHER_PATH% powershell -Command "(New-Object Net.WebClient).DownloadFile('%SBT_LAUNCHER_SOURCE%', '%SBT_LAUNCHER_PATH%')"
@REM Internal options, always specified
set INTERNAL_OPTS=-Dfile.encoding=UTF-8 -Xmx768m -noverify -XX:ReservedCodeCacheSize=256m -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:MaxPermSize=512m
@farmdawgnation
farmdawgnation / date-dot-parse.js
Last active August 29, 2015 13:56
A Date.parse implementation from Stackoverflow stuffs.
// This is a slightly modified version of two patches. The first suggested at
// http://stackoverflow.com/questions/5802461/javascript-which-browsers-support-parsing-of-iso-8601-date-string-with-date-par
// and the second, for Date.js suggested at
// http://stackoverflow.com/questions/12145437/date-js-parsing-an-iso-8601-utc-date-incorrectly
//
// Here we override the implementation of Date.parse provided by Date.js. In this implementation we
// first check to see if we can construct the date using the Date constructor. If we can, we move
// along. If we cannot, we attempt to start the Date.js grammar parser. If that, too, fails us, we
// then assume we're running in IE 8, and someone passed in an ISO8601 string, which IE8's date
// constructor won't recognize. So we try to manually parse it out, returning a Date instance.
@farmdawgnation
farmdawgnation / BinarySearch.cpp
Last active January 1, 2016 16:39
Hilariously primitive implementations of Binary Search Tree and Linked List I found on an old CD-ROM from High School. Written in Visual-C++. Circa 2005.
#include "StdAfx.h"
#include ".\binarysearch.h"
#include <stdlib.h>
#include <stdio.h>
BSNode::BSNode() {
this->lessThan = NULL;
this->greaterThan = NULL;
}
@farmdawgnation
farmdawgnation / iptablesload
Created December 22, 2013 04:57
IP Tables Load.
#!/bin/sh
iptables-restore < /etc/iptables.rules
ip6tables-restore < /etc/ip6tables.rules
exit 0
@farmdawgnation
farmdawgnation / gist:5666802
Created May 28, 2013 23:01
Some of the specs for the Anchor Tab API.
describe("GET /api/v1/embed/*") {
it("should return 200 and a jscmd for a valid tab id") {
runApiRequest("/api/v1/embed/" + validTab._id.toString, None, _.parameters = List("callback" -> "123")) { response =>
response match {
case Full(JavaScriptResponse(jscmd, _, _, code)) =>
code should equal (200)
case somethingUnexpected => fail(somethingUnexpected.toString)
}
}
@farmdawgnation
farmdawgnation / animals-2.scala
Last active December 16, 2015 18:20
Examples for Lift and Mongo Post
import net.liftweb.mongodb._
import BsonDSL._
trait Animal {
def makeNoise(): String
}
case class Dog(name: String, breed: String) extends Animal {
def makeNoise() = {
"Woof"