code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/spawner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/spawner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/inspector'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/reaper'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/reaper'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/inspector'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/request'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/request'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate'
| Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
end
| Ruby |
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
# See ActionController::RequestForgeryProtection for details... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# i... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
| Ruby |
ActionController::Routing::Routes.draw do |map|
# The priority is based upon order of creation: first created -> highest priority.
# Sample of regular route:
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
# Keep in mind you can assign values other than :controller and :action
# ... | Ruby |
# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
module Rails
class << self
def boot!
unless booted?
preinitialize
pick_boot.run
end
end
def booted?
... | Ruby |
# Be sure to restart your server when you modify this file
# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
# ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.0... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Use a different logger for distributed setups
# config.logger = SyslogLogger.new
# Full error repor... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.ca... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between... | Ruby |
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
| Ruby |
#!/usr/bin/env ruby
=begin
Test driver for recommendations.rb
=end
# recommendations.rb is in the sibling directory ../lib
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
require 'recommendations.rb'
require 'test/unit'
# Adds 'sum' method to Enumerable module as it's needed by
# recommendations.rb
#
modu... | Ruby |
#!/usr/bin/env ruby
=begin
Test driver for recommendations.rb
=end
# recommendations.rb is in the sibling directory ../lib
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
require 'recommendations.rb'
require 'test/unit'
# Adds 'sum' method to Enumerable module as it's needed by
# recommendations.rb
#
modu... | Ruby |
#!/usr/bin/env ruby -n
chomp
puts "#{$FILENAME}\t#{$_.length}"
| Ruby |
#!/usr/bin/env ruby
=begin
Demonstrates how to mixin a Module into a Class so that class
instances get the methods defined in the Module.
=end
module Fixie
def gears
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
end
end
class Bicycle
include Fixie
end
if __FILE__ == $0
# puts Bicycle.gears
puts Bicycle.new.gears
... | Ruby |
#!/usr/bin/env ruby
=begin
Demonstrates how to mixin a Module into a Class so that class
instances get the methods defined in the Module.
=end
module Fixie
def gears
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
end
end
class Bicycle
include Fixie
end
if __FILE__ == $0
# puts Bicycle.gears
puts Bicycle.new.gears
... | Ruby |
#!/usr/bin/env ruby -n
chomp
puts "#{$FILENAME}\t#{$_.length}"
| Ruby |
# Recommendation module to control namespace for Ruby equivalent of
# chapter 2 of "Programming Collective Intelligence".
require 'set'
unless defined? CRITICS
# A dictionary of movie critics and their ratings of a small set of
# movies
CRITICS = {
'Lisa Rose' => {'Lady in the Water' => 2.5, 'Snakes on a Pl... | Ruby |
#!/usr/bin/env ruby
require 'net/http'
require 'rexml/document'
require 'delicious'
# Create XML files corresponding to each item in an array of "popular"
# del.icio.us posts. These files are for offline use when there's no
# internet connection (i.e., airplane).
#
module CreatePosts
include Delicious
# Seriali... | Ruby |
#!/usr/bin/env ruby
require 'net/http'
require 'rexml/document'
require 'digest/md5'
module Delicious
# Returns an array of hashes corresponding to each popular del.icio.us post
#
def get_popular(tag='')
begin
parse_popular popular_url_stream(tag)
rescue SocketError
parse_popular popul... | Ruby |
#!/usr/bin/env ruby
require 'net/http'
require 'rexml/document'
require 'delicious'
# Create XML files corresponding to each item in an array of "popular"
# del.icio.us posts. These files are for offline use when there's no
# internet connection (i.e., airplane).
#
module CreatePosts
include Delicious
# Seriali... | Ruby |
# ----------------------------------------------------------------------
#
# Ruby adaptations of the Python code found in Toby Segaran's
# Programming Collective Intelligence book.
#
# steven.romej @ gmail (4 may 08)
# ----------------------------------------------------------------------
class Recommendations
# ... | Ruby |
#!/usr/bin/env ruby
require 'net/http'
require 'rexml/document'
require 'digest/md5'
module Delicious
# Returns an array of hashes corresponding to each popular del.icio.us post
#
def get_popular(tag='')
begin
parse_popular popular_url_stream(tag)
rescue SocketError
parse_popular popul... | Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
class Test::Unit::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
# in a transaction that's rolled back on completion. This ensures that the
# test datab... | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaire... | Ruby |
#!/usr/bin/env ruby
#
# You may specify the path to the FastCGI crash log (a log of unhandled
# exceptions which forced the FastCGI instance to exit, great for debugging)
# and the number of requests to process before running garbage collection.
#
# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
... | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaire... | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaire... | Ruby |
#!/usr/bin/env ruby
#
# You may specify the path to the FastCGI crash log (a log of unhandled
# exceptions which forced the FastCGI instance to exit, great for debugging)
# and the number of requests to process before running garbage collection.
#
# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
... | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaire... | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/destroy'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/about'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/destroy'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/about'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/spawner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/spawner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/inspector'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/reaper'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/reaper'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/inspector'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/request'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/request'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate'
| Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
end
| Ruby |
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
# See ActionController::RequestForgeryProtection for details... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# i... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
| Ruby |
ActionController::Routing::Routes.draw do |map|
# The priority is based upon order of creation: first created -> highest priority.
# Sample of regular route:
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
# Keep in mind you can assign values other than :controller and :action
# ... | Ruby |
# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
module Rails
class << self
def boot!
unless booted?
preinitialize
pick_boot.run
end
end
def booted?
... | Ruby |
# Be sure to restart your server when you modify this file
# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
# ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.0... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Use a different logger for distributed setups
# config.logger = SyslogLogger.new
# Full error repor... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.ca... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between... | Ruby |
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
| Ruby |
#!/usr/bin/env ruby
=begin
Test driver for recommendations.rb
=end
# recommendations.rb is in the sibling directory ../lib
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
require 'recommendations.rb'
require 'test/unit'
# Adds 'sum' method to Enumerable module as it's needed by
# recommendations.rb
#
modu... | Ruby |
#!/usr/bin/env ruby
=begin
Test driver for recommendations.rb
=end
# recommendations.rb is in the sibling directory ../lib
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
require 'recommendations.rb'
require 'test/unit'
# Adds 'sum' method to Enumerable module as it's needed by
# recommendations.rb
#
modu... | Ruby |
#!/usr/bin/env ruby -n
chomp
puts "#{$FILENAME}\t#{$_.length}"
| Ruby |
#!/usr/bin/env ruby
=begin
Demonstrates how to mixin a Module into a Class so that class
instances get the methods defined in the Module.
=end
module Fixie
def gears
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
end
end
class Bicycle
include Fixie
end
if __FILE__ == $0
# puts Bicycle.gears
puts Bicycle.new.gears
... | Ruby |
#!/usr/bin/env ruby
=begin
Demonstrates how to mixin a Module into a Class so that class
instances get the methods defined in the Module.
=end
module Fixie
def gears
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
end
end
class Bicycle
include Fixie
end
if __FILE__ == $0
# puts Bicycle.gears
puts Bicycle.new.gears
... | Ruby |
#!/usr/bin/env ruby -n
chomp
puts "#{$FILENAME}\t#{$_.length}"
| Ruby |
#!/usr/bin/env ruby
require 'net/http'
require 'rexml/document'
require 'delicious'
=begin
Build data files needed for offline work (when no internet
connectivity is available). Retrieves and stores data needed by
get_popular (popular.{tag}.xml) and get_urlposts
(urlposts.{md5digest}.xml).
=end
class OfflineDataB... | Ruby |
# Recommendation module to control namespace for Ruby equivalent of
# chapter 2 of "Programming Collective Intelligence".
require 'set'
unless defined? CRITICS
# A dictionary of movie critics and their ratings of a small set of
# movies
CRITICS = {
'Lisa Rose' => {'Lady in the Water' => 2.5, 'Snakes on a Pl... | Ruby |
#!/usr/bin/env ruby
require 'net/http'
require 'rexml/document'
require 'digest/md5'
class Delicious
# Directory where offline files are stored
OFFLINE_DIR = 'offline'
# Throw this exception when del.icio.us is throttling us
#
class ThrottlingException < RuntimeError
end
# Map Entry field names to... | Ruby |
#!/usr/bin/env ruby
require 'net/http'
require 'rexml/document'
require 'delicious'
=begin
Build data files needed for offline work (when no internet
connectivity is available). Retrieves and stores data needed by
get_popular (popular.{tag}.xml) and get_urlposts
(urlposts.{md5digest}.xml).
=end
class OfflineDataB... | Ruby |
require 'delicious'
class DeliciousRec
def initialize
@delish = Delicious.new
end
# Fill an initialized del.icio.us user dictionary with ratings
#
def fill_items(user_dict)
all_items = {}
# find links posted by all users
user_dict.each_key {|user|
# allow up to 2 more retries
... | Ruby |
# ----------------------------------------------------------------------
#
# Ruby adaptations of the Python code found in Toby Segaran's
# Programming Collective Intelligence book.
#
# steven.romej @ gmail (4 may 08)
# ----------------------------------------------------------------------
class Recommendations
# ... | Ruby |
#!/usr/bin/env ruby
require 'net/http'
require 'rexml/document'
require 'digest/md5'
class Delicious
# Directory where offline files are stored
OFFLINE_DIR = 'offline'
# Throw this exception when del.icio.us is throttling us
#
class ThrottlingException < RuntimeError
end
# Map Entry field names to... | Ruby |
require 'sinatra/activerecord/rake'
require './main' | Ruby |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'sinatra-activerecord'
gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client'
group :development do
gem 'rake'
gem 'sqlite3-ruby'
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.string :profile_id
t.string :email
t.string :refresh_token
end
add_index :users, :profile_id
end
def down
drop_table :users
end
end
| Ruby |
# Copyright (C) 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.