Skip to content

Instantly share code, notes, and snippets.

View workmad3's full-sized avatar

David Workman workmad3

View GitHub Profile
@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|
@workmad3
workmad3 / Gemfile
Last active August 29, 2015 13:56 — forked from markfeedly/commit_msg.rb
source 'https://rubygems.org'
gem 'sinatra'
gem 'bundler'
gem 'pry'
gem 'pry-doc'
gem 'pry-byebug'
= 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
module Export
module V1
class GroupSerializer < ActiveModel::Serializers
attributes :items
def items_serializer
ItemsSerializer
end
def items
<tr>
<td><%= hours[:paylocity_id] %></td>
<td>E</td>
<td>REG</td>
<td><%= hours[:regular_hours] %></td>
</tr>
<tr>
<td><%= hours[:paylocity_id] %></td>
<td>E</td>
<td>OT</td>
class Person
attr_reader :factory
attr_reader :name
def initialize(factory, name)
@factory = factory
@name = name
end
def coworkers
@workmad3
workmad3 / routes
Created January 16, 2010 18:40 — forked from anonymous/routes
ActionController::Routing::Routes.draw do |map|
# twitter app stuff
map.connect '/accounts/callback', :controller => 'accounts', :action => 'callback'
map.resources :accounts, :collection => { :callback => :get}, :members => {:do_update => :post}
map.resources :feeds
map.resources :feed_entries
end
This example shows how to setup an environment running Rails 3 beta under 1.9.1 with a 'rails3' gem set.
∴ rvm update --head
# ((Open a new shell))
# If you do not already have the ruby interpreter installed, install it:
∴ rvm install 1.9.1
# Use the ruby + gem set
∴ rvm 1.9.1%rails3