Skip to content

Instantly share code, notes, and snippets.

View workmad3's full-sized avatar

David Workman workmad3

View GitHub Profile
Failures:
1) Micropost should not be valid when user_id is not present
Failure/Error: it { should_not be_valid }
expected #<Micropost id: 1, content: "lorem ipsum", user_id: 1, created_at: "2013-10-09 11:10:10", updated_at: "2013-10-09 11:10:10"> not to be valid
@workmad3
workmad3 / riak_wrapper.rb
Last active December 25, 2015 20:09 — forked from gerep/riak_wrapper.rb
class RiakWrapper
def initialize
walk_server = WalkServer.first
@client = Riak::Client.new(:protocol => "pbc", :host => walk_server.host, :pb_port => walk_server.pb_port)
end
def exists?(key, bucket_name)
bucket(bucket_name).exists?(key)
end
@workmad3
workmad3 / gist:7218203
Last active December 26, 2015 21:49 — forked from anonymous/gist:7218182
<%= link_to "passes/Tara-Evans-01-10-2013.jpg", class: "example-image-link", data: {lightbox: "gallery"}, title: "Well done Tara, first time with only one minor" do %>
<%= image_tag("passes/Tara-Evans-01-10-2013.jpg", alt: "Tara Evans", width: "220", height: "147")%>
<p>
Tara Evans <br />
Passed 1 October 2013
</p>
</a>
@workmad3
workmad3 / comment..rb
Last active December 27, 2015 12:49 — forked from andyh/comment..rb
def self.create_from_parent(parent_type, parent_id, comment_params, current_account)
parent = parent_type.constantize
raise ActiveRecord::RecordNotFound unless parent.reflect_on_association(:comments).klass == self
parent.find(parent_id).comments.create(comment_params.merge(account: current_account))
rescue NameError
raise ActiveRecord::RecordNotFound
end
@workmad3
workmad3 / after.vimrc
Last active December 28, 2015 16:39 — forked from anonymous/after.vimrc
" Extra packages {{{
Bundle "nono/vim-handlebars"
Bundle "leshill/vim-json"
Bundle "tpope/vim-bundler"
Bundle "fholgado/minibufexpl.vim"
Bundle "wavded/vim-stylus"
Bundle "altercation/vim-colors-solarized"
Bundle 'AutoTag'
Bundle "SuperTab"
" }}}
#temporary for testing
## move the response file into your recipe as either a template or cookbook file
##FileUtils.cp(node[:response_file], File.join("#{tmpDir}","client"))
cookbook_file "#{tmp_dir}/oracle_response_file"
execute "oracleInstall" do
command "#{tmpDir}/client/setup.exe -silent -responseFile \"#{tmpDir}/client/Oracle11gR2_rsp.rsp\" -logLevel finest -ignoreSysPrereqs -noconsole"
action :run
not_if { ::File.exists?("C:/oracle/product/11.2.0/client_1/bin") }
# add to Gemfile
gem 'decent_exposure' # https://github.com/voxdolo/decent_exposure
gem 'responders' # https://github.com/plataformatec/responders
@workmad3
workmad3 / sort.rb
Last active August 29, 2015 13:56 — forked from chief/gist:8944843
#!/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|