gem 'tire'
ENV['ELASTICSEARCH_URL'] = ENV['BONSAI_URL']
# Renders an ItemContainer as a <ul> element and its containing items as <li> elements. | |
# Prepared to use inside the topbar of Twitter Bootstrap http://twitter.github.com/bootstrap/#navigation | |
# | |
# Register the renderer and use following code in your view: | |
# render_navigation(level: 1..2, renderer: :bootstrap_topbar_list, expand_all: true) | |
class BootstrapTopbarList < SimpleNavigation::Renderer::Base | |
def render(item_container) | |
if options[:is_subnavigation] | |
ul_class = "dropdown-menu" |
if [ -f "$rvm_path/scripts/rvm" ]; then | |
source "$rvm_path/scripts/rvm" | |
if [ -f ".rvmrc" ]; then | |
source ".rvmrc" | |
fi | |
if [ -f ".ruby-version" ]; then | |
rvm use `cat .ruby-version` | |
fi |
#Model | |
@user.should have(1).error_on(:username) # Checks whether there is an error in username | |
@user.errors[:username].should include("can't be blank") # check for the error message | |
#Rendering | |
response.should render_template(:index) | |
#Redirecting | |
response.should redirect_to(movies_path) |
require 'net/http' | |
require 'xmlsimple' | |
url = "http://www.user-agents.org/allagents.xml" | |
xml_data = Net::HTTP.get_response(URI.parse(url)).body | |
data = XmlSimple.xml_in(xml_data) | |
agents = data['user-agent'].select{|agent| type = agent["Type"].first; type.include?("R") || type.include?("S")} | |
agent_names = agents.collect {|agent| agent["String"].first} |
Custom recipe to get OS X 10.9 Mavericks running from scratch, setup applications and developer environment. I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install.
The software selected is software that is "tried and true" --- software I need after any fresh install. I often install other software not listed here, but is handled in a case-by-case basis.
// Check swap | |
$ sudo swapon -s | |
Filename Type Size Used Priority --> empty | |
// Create and enable swap file | |
$ sudo dd if=/dev/zero of=/swapfile bs=1024 count=512k | |
$ sudo mkswap /swapfile | |
Setting up swapspace version 1, size = 262140 KiB | |
no label, UUID=103c4545-5fc5-47f3-a8b3-dfbdb64fd7eb |
function getAudioData (url, time) { | |
return new Promise(function (resolve, reject) { | |
var context = new AudioContext(); | |
var track = new Audio(url); | |
var bufferLength = time * context.sampleRate; | |
var buffer = new Float32Array(bufferLength); | |
var collector = context.createScriptProcessor(0, 1); | |
var audioSource = context.createMediaElementSource(track); | |
var samplesCollected = 0; |