Skip to content

Instantly share code, notes, and snippets.

View farmdawgnation's full-sized avatar
:shipit:

Matt Farmer farmdawgnation

:shipit:
View GitHub Profile
// ==UserScript==
// @name GitHub delete all notifications button
// @namespace http://www.github.com/micolous/delete-all-notifications
// @description Adds a button to allow you to delete all notifications on a page.
// @include http://github.com/inbox/notifications*
// @include https://github.com/inbox/notifications*
// ==/UserScript==
/*
@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._
@farmdawgnation
farmdawgnation / example1.rb
Created November 17, 2012 04:31
Examples for Blog Post on 11/16
class ParentThing < ActiveRecord::Base
include SecureThingBehavior
# Make the storage location of all our secure things accessible
# along with whatever else you need.
attr_accessible :secure
end
class ThingA < ParentThing
attr_secure :meeting_location, :meeting_passcode
def test1
[1,2,3,4,5].each do |item|
next if item == 3
puts item
end
end
def test2
[1,2,3,4,5].each do |item|
@farmdawgnation
farmdawgnation / Contact.scala
Last active December 10, 2015 02:58
The ContactSerializer for use with the Constant Contact API I'm developing.
case class ContactPhones( home_phone:Option[String] = None, work_phone:Option[String] = None,
cell_phone:Option[String] = None)
case class ContactName( first_name:Option[String] = None, middle_name:Option[String] = None,
last_name:Option[String] = None)
case class Contact(email_addresses:List[EmailAddress], action_by:String, id:Long = 0,
status:Option[Status.Value] = None, prefix_name:Option[String] = None,
name:Option[ContactName] = None, job_title:Option[String] = None,
department_name:Option[String] = None, company_name:Option[String] = None,
phone:Option[ContactPhones] = None, fax:Option[String] = None,
addresses:List[Address] = List(), notes:List[Note] = List(),
@farmdawgnation
farmdawgnation / gist:5074718
Last active December 14, 2015 10:49
A Lift response transformer and some CoffeeScript helpful for facilitating cross-domain AJAX requests in Lift.
// If we receive a jQuery JSONP call and we don't call the callback, add in a bogus
// call to the callback function.
LiftRules.responseTransformers.append { response =>
response.toResponse match {
case resp @ InMemoryResponse(data, headers, _, _) =>
{
for(callback <- S.param("callback")) yield {
val dataStr = new String(data)
if (! dataStr.contains(callback)) {