Skip to content

Instantly share code, notes, and snippets.

View searls's full-sized avatar
💚

Justin Searls searls

💚
View GitHub Profile
@searls
searls / campfire-jenkins.rb
Created April 13, 2011 11:45
Tells campfire that a Jenkins build failed. Configure the post-build-task plugin ( https://wiki.jenkins-ci.org/display/JENKINS/Post+build+task ) to listen to the console output for failures and point it at a script like this one.
#!/usr/bin/ruby
require 'rubygems'
require 'tinder' #https://github.com/collectiveidea/tinder
campfire = Tinder::Campfire.new('your-subdomain',
:token => 'your token',
:ssl => true,
:proxy => 'http://your-proxy:1234')
room = campfire.rooms.first
@searls
searls / ConvertsQueryResultsToJson.java
Created April 21, 2011 18:32
Mapping Java to JSON in a jdk1.4 compatible way
public String convert(List<Map<String, Object>> queryResults) {
//json-simple - WINNAR!
return JSONValue.toJSONString(queryResults);
//flexjson - fail - requires java.lang.Enum
// return new JSONSerializer().serialize(queryResults);
//Jackson - fail - requires java.io.Closeable
// try {
// return new ObjectMapper().writeValueAsString(queryResults);
@searls
searls / jasmine-ajax-example-spec.coffee
Created April 28, 2011 16:32
A simple Jasmine Ajax spying example
window.context = window.describe
describe ".googlePandaStatus", ->
Given -> @ajaxCaptor = jasmine.captor()
Given -> spyOn($, "get")
When -> googlePandaStatus("Happy")
And -> expect($.get).toHaveBeenCalledWith("http://google.com", @ajaxCaptor.capture())
describe "~ the AJAX success handler", ->
Given -> spyOn(window, "printMessage")
class Bunny
attr_accessor :carrots, :lettuce_heads, :garden, :mate
def eat
@carrots.nom
@lettuce_heads.nom
end
def find_carrots
@garden.visit do |soil|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
@searls
searls / jenkins.jstack
Created May 13, 2011 19:32
Jenkins jstack dump following "Please wait while Jenkins is getting ready to work" - note that Jenkins is a fully updated ubuntu/debian distribution, operating behind an HTTP Proxy
2011-05-13 15:29:27
Full thread dump OpenJDK Client VM (19.0-b09 mixed mode, sharing):
"Attach Listener" daemon prio=10 tid=0x09381400 nid=0x465 waiting on condition [0x00000000]
java.lang.Thread.State: RUNNABLE
"RequestHandlerThread[#5]" daemon prio=10 tid=0x092c1c00 nid=0x3a9 in Object.wait() [0xb442f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x7b4a73a0> (a winstone.RequestHandlerThread)
@searls
searls / netflix.js
Created May 14, 2011 22:15
Types in an alphabetic sort of your Netflix Instant queue
//Save this as a bookmarklet in your browser's bookmark bar & click it while viewing your netflix instant queue. If it looks right, click "Update Queue" to save the changes.
javascript:void((function($){$.each($('#qbody tr a.mdpLink').contents().toArray().sort(function(a,b){ return a.nodeValue > b.nodeValue ? 1 : -1; }),function(i,e){ $(e).closest('tr').find('input.o').val(i) });})(jQuery))
@searls
searls / some-source.js
Created May 19, 2011 11:49
Add a little spy on creator that defaults to return this to support jQuery-like chaining.
buttonifyAndHide = function($obj) {
$obj.button().hide();
};
@searls
searls / game_spec_gimme.rb
Created May 24, 2011 03:05
Dearest friend, Mike Busch -- example taken from the RSpec Book: http://media.pragprog.com/titles/achbd/code/cb/42/spec/codebreaker/game_spec.rb
#compare to RSpec Book: http://media.pragprog.com/titles/achbd/code/cb/42/spec/codebreaker/game_spec.rb
require 'spec_helper'
module Codebreaker
describe Codebreaker::Game do
let(:output) { gimme(IO) }
let(:game) { Game.new(output) }
describe '#start' do
before do
@searls
searls / quirks-mode-doctype-hack.js
Created June 9, 2011 20:23
What to do when you can't edit the markup, but the markup doesn't have a doctype defined, and you don't want IE7/8 to enable quirks mode.
if($.browser.msie && document.compatMode === 'BackCompat') {
document.write('<!DOCTYPE html>'+document.documentElement.outerHTML);
history.go(0);
}