Skip to content

Instantly share code, notes, and snippets.

View kyleburton's full-sized avatar

Kyle Burton kyleburton

View GitHub Profile
// http://www.hackerrank.com/
// open JS console in Chrome, paste into JS console
// run:
// Foo.playGames( 7, 99 )
// to play 99 games starting with the opening value of 7
Foo = (function () {
var self = {autoContinue: true};
self.startGame = function (numCandies) {
$.ajax({
@kyleburton
kyleburton / multi-dyn-dispatch.clj
Created November 16, 2011 03:29
clojure multi-method dyn dispatch example
(defmulti my-multi (fn [arg]
(if (.startsWith arg "a")
:a
:b)))
(defmethod my-multi :a [arg]
(format "this is :a gonka-donk: %s" arg))
(defmethod my-multi :b [arg]
(format "b is the b is the b damn it: %s" arg))
@kyleburton
kyleburton / sample-Rakefile.rb
Created September 8, 2011 16:29
Rakefile for Chris B. B.
require 'rubygems'
require 'fileutils'
require 'net/http'
require 'net/https'
require 'json'
require 'pp'
def http_get url
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
@kyleburton
kyleburton / wooo.d3.js
Created August 17, 2011 02:31
On any website, open the js-console and paste this... => wooo.stop() will halt the effect.
wooo = function () {
var self = {};
self.interval = 1000;
self.iLikeIt = true;
self.init = function () {
var script = document.createElement("script");
script.setAttribute("src", "http://mbostock.github.com/d3/d3.js?1.29.1")
document.getElementsByTagName("head")[0].appendChild(script);
@kyleburton
kyleburton / cuke-step-multi-line.rb
Created June 2, 2011 21:03
Cucumber Step For Multiline Strings
Then /^the IVR says "([^\"]*)"$/ do |phrase|
@ivr_client.last_response['twml'].should include(phrase)
end
Then /^the IVR says$/ do |multiline|
multiline.split(/\n/).each do |phrase|
phrase.strip!
@ivr_client.last_response['twml'].should include(phrase)
end
end
@kyleburton
kyleburton / ccard.feature
Created June 2, 2011 20:58
Cucumber for testing my Twilio "La Cosa Nostra" IVR
Feature: La Cosa Nostra IVR Workflow
In order to register a credit card I want to call the La Cosa Nostra IVR
and simulate a phone call.
Background: As part of each Scenario I want to set my defaults.
Given my telephone number is "(100) 000-0001"
And I am testing the "CCard" workflow.
And I call the IVR.
Scenario: I register my card in one step and sign up for all services.
@kyleburton
kyleburton / oocssgrid-gen.rb
Created May 25, 2011 15:47
OOCSS Grids, generate additional sizings (eg: size1of10)
# ruby oocssgrid-gen.rb 10
# prints:
# .size1of10{width:10.0%;}
# .size2of10{width:20.0%;}
# .size3of10{width:30.0%;}
# .size4of10{width:40.0%;}
# .size5of10{width:50.0%;}
# .size6of10{width:60.0%;}
# .size7of10{width:70.0%;}
# .size8of10{width:80.0%;}
@kyleburton
kyleburton / java-sec-providers.clj
Created May 24, 2011 19:42
Clojure Java Security - enumerate providers, types and algorithms
(defn security-providers-type-algorithm-seq []
(mapcat (fn [provider]
(map (fn [svc]
[(.getType svc) (.getAlgorithm svc)])
(.getServices provider)))
(java.security.Security/getProviders)))
@kyleburton
kyleburton / twilio-ivr.rb
Created March 28, 2011 18:44
Example Twilio IVR State Machine
require 'ivrflow'
class CCard < Ivrflow
attr_accessor :asked_for_card_times
desc <<-END
This workflow represents a caller registering a Credit Card.
During the registration, after they've entered their credit
card number, we attempt to upsel them on
END
@kyleburton
kyleburton / slime-connect.rb
Created March 11, 2011 18:28
Emacs, Slime Helper to augment 'swank' bash function and trigger emacs to connect to the fresh swank server.
#!/usr/bin/env ruby
require 'socket' # Sockets are in standard library
$hostname = 'localhost'
$port = (ARGV[0] || "4005").to_i
attempts = 100
$s = nil
$retry = true
while $retry && (attempts > 0)