Skip to content

Instantly share code, notes, and snippets.

docker-machine Notes
Download docker-machine binary from:
https://github.com/cloudnativeapps/machine/releases
(not: https://github.com/docker/machine/releases)
OR - build it yourself by cloning and following the build instructions at the bottom of the README.md:
https://github.com/docker/machine
Move the downloaded binary to:
/usr/local/bin/docker-machine
# test failed create due to validation
require 'awesome_print' # support 'ap'
sli = nil
Octopus.using(LassoDbSharding.key(ShoppingListItem, Retailer.find(767))) do
ap sli = ShoppingListItem.create()
ap sli.errors
end
cattle = ['hereford', 'angus', 'brahman', 'holstein']
dogs = ['terrier', 'akita', 'poodle', 'afghan']
breed = 'afghan'
animal_type = case breed
when *cattle
'cow'
when *dogs
'dog'
/**
* @returns {boolean} true if this is an iOS device running 'version' or greater
*/
function is_iOS_app_gte(version) {
return typeof window.device != "undefined" && window.device.platform == "iOS" && is_version_gte(window.device.version, version);
}
/**
* Is this an Apple iOS device and running version 7.0 or greater?
/**
* Takes two version numbers with multiple decimal points (e.g. '7.0.3') and
* returns true if the first one is greater than or equal to the second.
*
* @param v1 version that should be greater than or equal
* @param v2 version that should be less than or equal
* @returns {boolean} true if 'v1' >= 'v2'
*/
function is_version_gte(v1, v2) {
var v1_parts = (v1 || 0).toString().split('.').map(function(s) {return parseInt(s)});
@danlynn
danlynn / Ruby: Syntax for defining a hash with here-doc values.rb
Last active December 10, 2015 23:49
The following code provides an attractive and easy way to populate a hash with multi-line text values. These multi-line text literals are defined using ruby's here-doc syntax. In this case, the values are snippets of javascript code that were simply pasted in.
hash = {
:key1 => <<-END_VAL,
console.log('cow');
alert('moof!');
END_VAL
:key2 => <<-END_VAL
console.log('cow 2');
alert('moof! 2');
END_VAL
}
@danlynn
danlynn / api_v1_scratch.rb
Created November 28, 2012 16:20
Registration steps
# Register - Step 1 (login): Authenticate using fuzzy card number as 'login' and last name as 'password' (note auth will fail if Card.Reg == 1 already)
curl -i -H "Accept: application/json" -X POST -d "api_user_session[retailer_id]=767&api_user_session[type]=Card&api_user_session[login]=40000000197&api_user_session[password]=Vandalay" http://local.webstophq.com:3000/api/v1/login
# Register - Step 2 (get preferred store list): Gets list of {:id, :store_number, :address_1, :city, :store_name}
GET /api/v1/retailers/:retailer_id/stores(.:format)
curl -i -H "Accept: application/json" http://local.webstophq.com:3000/api/v1/retailers/767/stores?api_user_credentials=tozaqJaMRDKPjXPWhDh
# Register - Step 3 (update consumer): Mark Consumer (Card) as registered and set preferred store and password - then return the Consumer (Card) including new single_access_token and legacy_token
PUT /api/v1/retailers/:retailer_id/consumers/:id(.:format)
curl -i -H "Accept: application/json" -X PUT -d "consumer[registered]=1&co
require'socket'
server = TCPServer.new(8088);
loop do
connection = server.accept
puts 'Trapped a new connection'
end
1.9.2p320 :001 > s = "test: string with @ref and @ref2 in it"
=> "test: string with @ref and @ref2 in it"
1.9.2p320 :002 > s.scan(/(?<=@)\w+/)
=> ["ref", "ref2"]
1.9.2p320 :003 > s.scan(/@(\w+)/)
=> [["ref"], ["ref2"]]
erb_eval_mode = line =~ /^%ERB_START_EVAL/ if line =~ /^%ERB_START_EVAL|%ERB_STOP_EVAL/
if line =~ /^%ERB_START_EVAL/
erb_eval_mode = true
if line =~ /^%ERB_STOP_EVAL/
erb_eval_mode = false