Skip to content

Instantly share code, notes, and snippets.

View samstarling's full-sized avatar

Sam Starling samstarling

View GitHub Profile
require 'rubygems'
require 'rest-assured'
RestAssured::Double.create(fullpath: '/products', content: 'this is content')
---
gives me...
---
/Users/starls01/.rvm/gems/ruby-1.9.3-p125/gems/activeresource-3.2.3/lib/active_resource/base.rb:588:in `prefix': undefined method `path' for nil:NilClass (NoMethodError)
bbcpasswd () {
smbpasswd -U <name> -r `host -t srv _ldap._tcp.pdc._msdcs.national.core.bbc.co.uk | cut -d" " -f8 | head -c -2`
}
<?php
// Generate a random number.
$random = rand(0, 2);
// Set up messages, and fetch a random one.
$messages = array(
array("heading" => "foo", "body" => "123"),
array("heading" => "bar", "body" => "456"),
array("heading" => "bad", "body" => "789")
@samstarling
samstarling / gist:3749581
Created September 19, 2012 13:11
Expand/Shrink Form Input
$(document).ready(function(){
$("#search").bind({
focus: function() {
$(this).animate({ width:200 }, 300);
},
blur: function() {
$(this).animate({ width:90 }, 300);
}
});
});
@samstarling
samstarling / safe_json.rb
Last active December 18, 2015 21:09
Safe access of a nested hash from JSON in Ruby.
require 'json'
class Hash
def dig(*path)
path.inject(self) do |location, key|
location.respond_to?(:keys) ? location[key] : nil
end
end
end
package com.distributed
object Helpers {
def maybe(chance: Double)(success: => Any)(failure: => Any) = {
if(scala.util.Random.nextFloat() < chance) {
success
} else {
failure
}
}
package com.samstarling.futures
import com.twitter.util.Future
object SequentialComposition extends App {
case class User(name: String)
def authenticate(credentials: String) = Future { Some(User("sam")) }
package com.samstarling.futures
import com.twitter.util.{Future, Await}
import com.samstarling.util.time
object ConcurrentComposition extends App {
def slowTask(time: Int): Future[String] = Future {
Thread.sleep(time)
"Hello"

Keybase proof

I hereby claim:

  • I am samstarling on github.
  • I am samstarling (https://keybase.io/samstarling) on keybase.
  • I have a public key whose fingerprint is A72B 8BEA CE58 9EC2 0C73 B8B0 C39D 1F80 D7AD 8B1B

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am samstarling on github.
  • I am samstarling (https://keybase.io/samstarling) on keybase.
  • I have a public key ASAbCz8NP9AUlQvj5wngqAgkVDCt75RvHXctk8X6nvjbgAo

To claim this, I am signing this object: