I hereby claim:
- I am workmad3 on github.
- I am workmad3 (https://keybase.io/workmad3) on keybase.
- I have a public key whose fingerprint is A828 9E82 5DF9 242F A7C5 7310 0504 58CC 0BB0 5509
To claim this, I am signing this object:
# Generate your password in your preferred manner, such as SecureRandom.base64(30) | |
node[:my_super_secret_password] ||= NodeEncryption.encrypt_value("super_secret!") | |
# Later on, recover the password | |
my_super_secret_password = NodeEncryption.decrypt_value(node[:my_super_secret_password]) |
def foo(options={}) | |
default_options = { | |
foo: "bar" | |
} | |
options = options.dup | |
options.default_proc = proc{|h,k| default_options[k] || (raise ArgumentError.new("No value for required option #{k}"))} | |
# Now access options as 'normal' | |
#!/usr/bin/env ruby | |
require "benchmark" | |
Benchmark.bmbm(7) do |x| | |
iterations = 10_000 | |
a = 4000.times.map { |i| rand(i * 100).to_i } | |
a.sort! | |
common_packages = %w(python-setuptools python-dev) | |
case node['platform'] | |
when "centos", "redhat", "amazon" | |
platform_packages = common_packages + ['gcc'] | |
when "debian", "ubuntu" | |
platform_packages = common_packages + ['build-essential'] | |
end | |
platform_packages.each do |pkg| |
namespace :scrape do | |
desc "Take a screenshot of a url using Phantomjs" | |
task :screenshots => :environment do | |
require 'capybara' | |
require 'poltergeist/capybara' | |
include Capybara::DSL | |
Capybara.default_driver = :poltergeist | |
articles = Article.order('zscore DESC').limit(3) | |
articles.each_with_index do |article, i| |
source 'https://rubygems.org' | |
gem 'sinatra' | |
gem 'bundler' | |
gem 'pry' | |
gem 'pry-doc' | |
gem 'pry-byebug' |
I hereby claim:
To claim this, I am signing this object:
class ClassToAddMethodsTo | |
def self.special_attr_accessor(attr, set: ->(val){val}, get: ->(val){val}) | |
define_method attr do | |
get.(instance_variable_get "@#{attr}") | |
end | |
define_method "#{attr}=" do |rhs| | |
instance_variable_set "@#{attr}", set.(rhs) | |
end | |
end | |
config.json goes in <chef-repo>/.berkshelf/api-server | |
berkshelf-api.sh script goes in <chef-repo> | |
If you use bundler in your chef-repo, add berkshelf-api to the Gemfile, otherwise 'gem install berkshelf-api' |
= form_for([@forum, @topic]) do |f| | |
- if @topic.errors.any? | |
%div{id: 'error_explanation'} | |
%h2 | |
= pluralize(@topic.errors.count, "error") | |
prohibited this topic from being saved: | |
- for message in @topic.errors.full_messages | |
%li | |
= message |