Skip to content

Instantly share code, notes, and snippets.

@andreacampi
andreacampi / consume_json.rb
Created September 28, 2012 21:31
cookbooks/consume_json/libraries/consume_json.rb
class Chef
module Mixin
module ConsumeJson
def consume_json(url)
Chef::Log.debug "consume_json: requesting url: #{url}"
info = nil
fetch(url) do |data|
info = JSON.parse(data)
Chef::Log.debug "consume_json: parsed: #{info.inspect}"
@hedgehog
hedgehog / features|focus_test.feature
Created January 3, 2012 01:22 — forked from mattheworiordan/features|focus_test.feature
Capybara-Webkit focus on an element test that fails
Feature: Capybara Webkit focus test
In order to show that Capybara Webkit does not allow an element to maintain focus
I created this feature
Which anyone can try
@javascript
Scenario: Run demo page
When I am on the capybara demo page
Then I should see a successful result
@hedgehog
hedgehog / chat.rb
Created January 2, 2012 20:26 — forked from rkh/chat.rb
Simple Chat Application using the Sinatra Streaming API
# coding: utf-8
require 'sinatra'
set server: 'thin', connections: []
get '/' do
halt erb(:login) unless params[:user]
erb :chat, locals: { user: params[:user].gsub(/\W/, '') }
end
get '/stream', provides: 'text/event-stream' do
@hedgehog
hedgehog / reference.mkdn
Created January 2, 2012 07:55 — forked from mirisuzanne/reference.mkdn
Susy Documentation / Reference

Susy Reference

Terms

  • Susy Grid: A grid that you build with Susy. You can have multiple on one page if you need.
  • Grid Element: Any HTML element that is aligned to a Susy Grid.
  • Container: The root element in a Susy Grid. Anything inside it is a potential Grid Element.
  • Context: Either root (default) or the number of columns spanned by the parent Grid Element.
@hedgehog
hedgehog / gist:1506046
Created December 21, 2011 13:28 — forked from mitchellh/gist:1277049
Configure Vagrant VM to use Host DNS for VPN
Vagrant::Config.run do |config|
# ...
config.vm.customize do |vm|
# Use the host resolver for DNS so that VPN continues
# to work within the VM
vm.network_adapters.each do |na|
if na.enabled? && na.nat_driver
na.nat_driver.dns_use_host_resolver = true
end
@hedgehog
hedgehog / sortable.rb
Created December 7, 2011 21:35 — forked from jarib/sortable.rb
jquery ui sortable w/ webdriver
require 'selenium-webdriver'
pr = Selenium::WebDriver::Firefox::Profile.new
pr.native_events = true
d = Selenium::WebDriver.for :firefox, :profile => pr
d.get "http://jqueryui.com/demos/sortable/"
list = d.find_element(:id, 'sortable').find_elements(:tag_name, 'li')
d.action.drag_and_drop_by(list[0], 0, 200).perform
#!/bin/bash
cat .gitignore | egrep -v "^#|^$" | while read line; do
if [ -n "$line" ]; then
OLD_IFS=$IFS; IFS=""
for ignored_file in $( git ls-files "$line" ); do
git rm --cached "$ignored_file"
done
IFS=$OLD_IFS
fi
@hedgehog
hedgehog / LICENSE.txt
Created December 2, 2011 13:46 — forked from jed/LICENSE.txt
generate random UUIDs
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@hedgehog
hedgehog / api_wrapper_spec.rb
Created November 29, 2011 20:30 — forked from mrchrisadams/api_wrapper_spec.rb
Using webmock and VCR together
describe ApiWrapper::Connection, "with retry enabled" do
before(:each) do
# connect to api
# the @api_wrapper object persists, across all the responses, and we set the number of retries
# on the ApiWrapper::Connection#get method here too, for when we call it further down in the spec.
@api_wrapper = ApiWrapper::Connection.new('stage.api_wrapper.com', APIWRAPPER_V2_API_KEY, APIWRAPPER_V2_PASSWORD, :retries => 2)
VCR.use_cassette("ApiWrapper_Connection/v2/raising unhandled errors") do
@hedgehog
hedgehog / em-http-vcr.rb
Created November 25, 2011 21:35 — forked from igrigorik/em-http-vcr.rb
Mocking with WebMock and VCR
require 'rubygems'
require 'test/unit'
require 'em-http'
require 'vcr'
VCR.config do |c|
c.cassette_library_dir = 'fixtures/vcr_cassettes'
c.http_stubbing_library = :webmock
end