This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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%;} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn security-providers-type-algorithm-seq [] | |
(mapcat (fn [provider] | |
(map (fn [svc] | |
[(.getType svc) (.getAlgorithm svc)]) | |
(.getServices provider))) | |
(java.security.Security/getProviders))) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |