Skip to content

Instantly share code, notes, and snippets.

View woods's full-sized avatar

Scott Woods woods

View GitHub Profile
@woods
woods / working_hours.rb
Created July 20, 2011 17:32
Calculating elapsed working days / hours
>> d1 = Date.new( 2006, 12, 1 )
=> #<Date: 4908141/2,0,2299161>
>> d2 = Date.new( 2007, 1, 15 )
=> #<Date: 4908231/2,0,2299161>
>> (d1..d2)
=> #<Date: 4908141/2,0,2299161>..#<Date: 4908231/2,0,2299161>
>> weekends = [0, 6]
=> [0, 6]
>> (d1..d2).each { |i| puts i }
<snip>
#!/bin/sh
# A short script to bring the production database up to date. You need to
# run this from the application root, e.g.:
#
# ./script/update_production_database
# Display commands as we execute them.
set -x
$ cd a_rails_project/
$ ruby vendor/gems/skylinecms/test/unit/page_test.rb
vendor/gems/skylinecms/test/unit/page_test.rb:1:in `require': no such file to load -- test_helper (LoadError)
from vendor/gems/skylinecms/test/unit/page_test.rb:1
$ ruby -r vendor/gems/skylinecms/test/test_helper vendor/gems/skylinecms/test/unit/page_test.rb
config.gem: Unpacked gem skylinecms in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem skylinecms in vendor/gems not in a versioned directory. Giving up.
/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010. Use #requirement
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:440:in `load_missing_constant': uninitialized constant Skyline::Sections::Interface (NameError)
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependenc
$ rake -T
(in /Users/woods/src/git/vendor/skyline)
rake doc:generate # Generate YARD Documentation
rake gem:build # Build gem
rake gem:check_dependencies # Check that runtime and development dependencies are installed
rake gem:check_dependencies:development # Check that development dependencies are installed
rake gem:check_dependencies:runtime # Check that runtime dependencies are installed
rake gem:gemspec # Generate and validates gemspec
rake gem:gemspec:debug # Display the gemspec for debugging purposes
rake gem:gemspec:generate # Generates the gemspec, using version from VERSION
class Chapter < ActiveRecord::Base
validates :subdomain,
:presence => true,
:uniqueness => true,
:length => { :maximum => 63 }
validates_format_of :subdomain, :with => /^[a-z0-9-]+$/i, :message => 'can only contain letters, numbers, and dashes'
validates_format_of :subdomain, :without => /^-/, :message => 'can not start with a dash'
validates_format_of :subdomain, :without => /-$/, :message => 'can not end with a dash'
validates_format_of :subdomain, :without => /--/, :message => 'can not contain two consecutive dashes'
end
# For best results, run this file with the command:
# spec -c -f n karma_proxy.rb
require 'rubygems'
require 'active_support'
# This module provides all the client-side functionality that the web app
# will need to integrate with a Karma server.
module Karma
# Create or update a particular user.
#
# PUT /users/:permalink.html
# PUT /users/:permalink.json
# PUT /users/:permalink.xml
#
# If the user does not already exist, it will be created at the given URI.
# If the user already exists, it will be updated. If the permalink is
# updated, the URI of the resource will have changed, and a Location: header
# will be returned with the location of the new resource.
# Set up a global git ignore file in ~/.gitignore . Copy and paste these commands into a terminal.
echo '.DS_Store' >> ~/.gitignore
git config --global core.excludesfile ~/.gitignore
# Rack configuration file. Used to run this app under apache/passenger.
require 'app'
run Sinatra::Application
#!/usr/bin/env ruby
# Query twitter for all recent tweets by West Arete Computing and write them
# to a JSON file.
require 'rubygems'
require 'twitter'
require 'active_support'
# The users from whom we should fetch tweets tagged with #westarete