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 / 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.
@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

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:

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) = {
@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" }
@farmdawgnation
farmdawgnation / modernizr-vml.js
Created May 8, 2012 15:08
Modernizr Test for VML
// Add a Modernizr check for VML
Modernizr.addTest('vml', function() {
// Adapted from http://stackoverflow.com/questions/654112/how-do-you-detect-support-for-vml-or-svg-in-a-browser
var a = document.body.appendChild(document.createElement('div'));
a.innerHTML = '<v:shape id="vml_flag1" adj="1" />';
var b = a.firstChild;
b.style.behavior = "url(#default#VML)";
var supportsVml = b ? typeof b.adj == "object": true;
a.parentNode.removeChild(a);
return supportsVml;
@farmdawgnation
farmdawgnation / brew-duplicityboto.sh
Created August 21, 2012 18:58
Install Duplicity and boto
#!/bin/sh
####
# Installer for Duplicity and boto backend to make backing
# up your OS X based system to wherever you want. Requires
# Homebrew (http://mxcl.github.com/homebrew/) to be installed
# first.
#
# To run:
# curl https://raw.github.com/gist/3418344/brew-duplicityboto.sh | bash
####
@farmdawgnation
farmdawgnation / ck-internalhttp.sh
Created August 22, 2012 04:27
Internal HTTP Monitor for CloudKick
#!/bin/bash
####
# Internal HTTP Monitor Script Plugin for Cloudkick.
#
# This script does a curl to a URL passed in on the command line and
# checks the return code provided by curl to determine whether or not
# the request was successuful or not. Useful for situations where you
# need to monitor the health of app servers behind a firewall/HAProxy
# setup.
#
@farmdawgnation
farmdawgnation / things.scala
Created October 6, 2012 02:04
Some things scala can do
// This is going to be a really quick summary of things, but it should give you an idea.
// (At least of some of the unique aspects of scala.)
// EXAMPLE 1: Flow control via pattern matching
trait HasUserIdentifier {
// Anything mixing this in must have a userId method
// that returns a string
def userId:String
}
@farmdawgnation
farmdawgnation / Bundles.scala
Created October 13, 2012 23:23 — forked from Shadowfiend/Bundles.scala
Lift snippet for bundle support in conjunction with Shadowfiend/sbt-resource-management.
package com.openstudy { package snippet {
import scala.xml._
import java.io.InputStreamReader
import net.liftweb.common._
import net.liftweb.http._
import LiftRules._
import net.liftweb.util._
import Helpers._