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
# From: https://nickcharlton.net/posts/ruby-subprocesses-with-stdout-stderr-streams.html | |
require 'open3' | |
module Utils | |
class Subprocess | |
def initialize(cmd, &block) | |
# see: http://stackoverflow.com/a/1162850/83386 | |
Open3.popen3(cmd) do |stdin, stdout, stderr, thread| | |
# read each stream from a new thread | |
{ :out => stdout, :err => stderr }.each do |key, stream| |
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
Signal.trap("INT") do | |
puts '' | |
system('say "Goodbye!"') | |
exit 1 | |
end | |
# A command line math flash cards | |
class Math < Thor | |
desc "times", "Practice your times tables - 2 to 12" |
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 'dry-container' | |
require 'dry-auto_inject' | |
# set up your container | |
my_container = Dry::Container.new | |
my_container.register(:data_store, -> { {users:[]} }) | |
my_container.register(:user_repository, -> { my_container[:data_store][:users] }) | |
my_container.register(:persist_user, -> { PersistUser.new }) |
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
UUID = Types::Strict::String.constrained( | |
format: /\A[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}\z/i) | |
describe UUID do | |
context 'UUID' do | |
include Voom::Types | |
let(:uuid){SecureRandom.uuid} | |
let(:bad_uuid){uuid+"&"} | |
it 'should constrain' do |
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
ruby 2.2.5 | |
os x 10.11.4 | |
I moved from rvm to rbenv. When I went to bundle I had build errors with libv8 (3.16.14.7) and eventmachine (1.0.8). | |
This is what up ended up working. | |
YMMV | |
``` | |
brew install gcc | |
brew link openssl --force | |
gem install libv8 -v '3.16.14.7' -- --with-system-v8 | |
bundle |
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
describe "Bad Validation Spec" do | |
subject { | |
Dry::Validation.Form do | |
key(:id).required | |
key(:foo).schema do | |
optional(:bar).maybe | |
optional(:goo).maybe | |
optional(:zurb).maybe # comment this line out and it works | |
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
/********************************************** | |
* Ink v1.0.5 - Copyright 2013 ZURB Inc * | |
**********************************************/ | |
/* Client-specific Styles & Reset */ | |
#outlook a { | |
padding: 0; | |
} |
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
<select id="<%= options.id %>" name="<%= options.name %>" | |
<% if((!options.blank && collection.size()==0) || | |
options.disabled ){ %> | |
disabled="disabled" | |
<% }; %> | |
> | |
<% if(options.blank){ %> | |
<option value=''><%= options.blank %></option> | |
<% }; %> | |
<% collection.each(function(item) { %> |
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
Handlebars.template = function(templateString) { | |
return function () { | |
if (arguments.length < 1) { | |
// With no arguments, return the raw template -- useful for rendering | |
// partials. | |
return templateString; | |
} else { | |
Handlebars.templates = Handlebars.templates || {} | |
Handlebars.templates[templateString] = Handlebars.templates[templateString] || Handlebars.compile(templateString); | |
return Handlebars.templates[templateString](arguments[0], arguments[1]); |
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
namespace :gem do | |
begin | |
require 'jeweler' | |
gem_name = 'voomify-jobs' | |
Jeweler::Tasks.new do |gem| | |
gem.name = gem_name | |
gem.summary = 'Voomify jobs engine for Rails 3.' | |
gem.files = Dir['{lib}/**/*', '{app}/**/*', '{config}/**/*'] | |
gem.author = 'Russell Edens' | |
gem.email = '[email protected]' |