This file contains 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
1) Docker::Container#changes returns the changes as an array | |
Failure/Error: ] | |
expected: [{"Path"=>"/dev", "Kind"=>0}, {"Path"=>"/dev/kmsg", "Kind"=>0}, {"Path"=>"/root", "Kind"=>2}] | |
got: [{"Kind"=>2, "Path"=>"/root"}] (using ==) | |
Diff: | |
@@ -1,4 +1,2 @@ | |
-[{"Path"=>"/dev", "Kind"=>0}, | |
- {"Path"=>"/dev/kmsg", "Kind"=>0}, | |
- {"Path"=>"/root", "Kind"=>2}] | |
+[{"Kind"=>2, "Path"=>"/root"}] |
This file contains 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 'celluloid' | |
# It wasn't until I commented out this line that I realised what was actually going on below | |
# Celluloid.logger = nil | |
class Foo | |
include Celluloid | |
def do | |
bar | |
end |
This file contains 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
desc 'Add, remove and list config for an app' | |
command :config do |c| | |
c.desc 'Delete config by keys' | |
c.command :rm do |sc| | |
sc.action do |global_options, options, args| | |
@api.request :delete, "/app/#{Git.first_sha}/config", { | |
keys: args.to_json | |
} | |
end | |
end |
This file contains 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
<?php | |
$chocolates = ['maltesers', 'minstrels', 'green & blacks', 'montezuma']; | |
$we_ate = array_slice($chocolates, 0, 2); | |
// Outputs: ['maltesers', 'minstrels'] | |
?> |
This file contains 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
chocolates = ['maltesers', 'minstrels', 'green & blacks', 'montezuma'] | |
we_ate = chocolates[0..1] | |
# Outputs: ['maltesers', 'minstrels'] |
This file contains 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
task calculate_per_location_costs: :environment do | |
year = ENV['YEAR'].to_i | |
month = ENV['MONTH'].to_i | |
# Method 1: By server usage | |
# Get all servers that were created in the given month | |
servers_by_location = Server.with_deleted | |
.where('extract(year from created_at) = ?', year) | |
.where('extract(month from created_at) = ?', month) | |
.group_by(&:location) |
This file contains 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
# config.ru for Rackup + Wordpress, based on http://stuff-things.net/2011/05/16/legacy-development-with-pow/ | |
# added hackery to work around wordpress issues - Patrick Anderson (patrick@trinity-ai.com) | |
# clearly this could be cleaner, but it does work | |
# And more hackery by @twombh to work in Linux environment | |
require 'rack' | |
require 'rack-legacy' | |
require 'rack-rewrite' | |
# patch Php from rack-legacy to substitute the original request so |
This file contains 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
# This whole thing is horrible. | |
# Firstly Yahoo's website, docs and UI are terrible. | |
# Second, OAuth!? For a simple search API, WTF!? | |
# Thirdly, this code is bodged together, undocumented and didn't work with queries that needed URI escaping (but does now) | |
# GRRRRRRRRRRRRRRRRRRRRR! | |
require 'net/http' | |
# A utility for signing an url using OAuth in a way that's convenient for debugging |
This file contains 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
# Place this file in the same directory as `Vagrantfile' | |
# then simply require "vagrant-snapshot.rb" at the top of Vagrantfile. | |
require 'optparse' | |
Vagrant.commands.register(:snap) { Snap::Commands } | |
# Provide rake-like desc() 'inflected' documentation | |
# See http://stackoverflow.com/questions/2948328/access-attributes-methods-comments-programmatically-in-ruby | |
class Module |
This file contains 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
class Hash | |
def quiet_fetch query | |
current = self | |
query.split('/').each do |key| | |
if current.fetch(key, false) | |
current = current.fetch(key) | |
else | |
return nil | |
end | |
end |
OlderNewer