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
#!/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! | |
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
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| |
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 :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| |
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
source 'https://rubygems.org' | |
gem 'sinatra' | |
gem 'bundler' | |
gem 'pry' | |
gem 'pry-doc' | |
gem 'pry-byebug' |
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
= 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 |
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
module Export | |
module V1 | |
class GroupSerializer < ActiveModel::Serializers | |
attributes :items | |
def items_serializer | |
ItemsSerializer | |
end | |
def items |
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
<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> |
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
class Person | |
attr_reader :factory | |
attr_reader :name | |
def initialize(factory, name) | |
@factory = factory | |
@name = name | |
end | |
def coworkers |
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
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 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
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 |
OlderNewer