Skip to content

Instantly share code, notes, and snippets.

@ejholmes
ejholmes / gist:1693208
Created January 28, 2012 07:26
Lighthouse post-receive hook
#!/usr/bin/env ruby
# Lighthouse + Git
# post-receive hook
LIGHTHOUSE_TOKEN = 'owner token here (the default one)'
LIGHTHOUSE_ACCOUNT = 'account (the subdomain)'
LIGHTHOUSE_PROJECT = 'project id (look in /projects/[id])'
# Store individual user tokens here.
# They are required so that changesets are mapped to the correct Lighthouse username
@ejholmes
ejholmes / post-receive.rb
Created January 31, 2012 07:41
Git post-receive hook for sending commit data to a github-services server.
#!/usr/bin/env ruby
require 'rubygems'
require 'grit'
require 'net/http'
require 'json'
rev_old, rev_new, ref = STDIN.read.split(" ")
repo = Grit::Repo.new File.expand_path(".")
payload = {
@ejholmes
ejholmes / template.rb
Created February 1, 2012 15:29
Rails template
# >---------------------------------------------------------------------------<
#
# _____ _ _ __ ___ _
# | __ \ (_) | \ \ / (_) | |
# | |__) |__ _ _| |___\ \ /\ / / _ ______ _ _ __ __| |
# | _ // _` | | / __|\ \/ \/ / | |_ / _` | '__/ _` |
# | | \ \ (_| | | \__ \ \ /\ / | |/ / (_| | | | (_| |
# |_| \_\__,_|_|_|___/ \/ \/ |_/___\__,_|_| \__,_|
#
# This template was generated by RailsWizard, the amazing and awesome Rails
@ejholmes
ejholmes / served.sh
Created February 8, 2012 07:14
Command for serving a local directory via HTTP
alias served="ruby -r webrick -e \"s = WEBrick::HTTPServer.new(:Port => 9090, :DocumentRoot => Dir.pwd); trap('INT') { s.shutdown }; s.start\""
@ejholmes
ejholmes / placeholder.js
Created February 29, 2012 20:52
Snippet of javascript for pseudo HTML5 placeholder.
$(function() {
$('.placeholder input[type=text]').each(function() {
var placeholder = $(this).val();
$(this).focus(function() {
if ($(this).val() == placeholder) {
$(this).val('');
}
});
ericholmes@eric-imac ~ » curl -I http://www.site.com
curl: (6) Couldn't resolve host 'www.site.com'
ericholmes@eric-imac ~ » curl -I http://site.com
HTTP/1.1 302 Found
Date: Tue, 06 Mar 2012 18:56:21 GMT
Server: UltraDNS Client Redirection Server
Last-Modified: Tue, 06 Mar 2012 18:56:21 GMT
Accept-Ranges: none
Connection: close
Content-type: text/html
# @order is created before each test runs
it "allows for the navision Id to be specified rather than the salesforce Id" do
@order.Status__c.should eq('Processing')
body = {
:order => {
:id => @order.Id,
:Status__c => "Processed",
:NavisionID__c => "testxxx_navision_id"
}
}
@HttpPost
global static void updateOrder(Order__c order) {
if (order.Id == null && order.NavisionID__c != null) {
upsert order Order__c.NavisionID__c;
} else {
upsert order;
}
}
@ejholmes
ejholmes / gist:2079814
Created March 18, 2012 18:58
Install ruby 1.9.3-p125 with rbenv on OS X lion
env CC=/usr/bin/gcc rbenv install 1.9.3-p125
@ejholmes
ejholmes / gist:2307320
Created April 5, 2012 01:42
Apex class for generating an HMAC cookie for tender
public class Tender {
public static String TENDER_SECRET = 'monkey';
public static String DOMAIN = 'help.yourapp.com';
public static String tenderize(String username) {
String expires = '1228117891';
String input = DOMAIN + '/' + username + '/' + expires;
Blob hmac = Crypto.generateMac('hmacSHA1', Blob.valueOf(input), Blob.valueOf(TENDER_SECRET));
return EncodingUtil.convertToHex(hmac);
}