code
stringlengths
1
1.73M
language
stringclasses
1 value
# Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. Rails.application.config.filter_parameters += [:password]
Ruby
Costumecode::Application.routes.draw do devise_for :admins mount RailsAdmin::Engine => '/cp', :as => 'rails_admin' devise_for :users devise_scope :user do get "/logout" => "devise/sessions#destroy" get "/login" => "devise/sessions#new" end # devise_for :admins # devise_scope :admin do # get "...
Ruby
require 'rubygems' # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
Ruby
require File.expand_path('../boot', __FILE__) require 'rails/all' if defined?(Bundler) # If you precompile assets before deploying to production, use this line Bundler.require(*Rails.groups(:assets => %w(development test))) # If you want your assets lazily compiled in production, use this line # Bundler.requi...
Ruby
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application Costumecode::Application.initialize!
Ruby
Costumecode::Application.configure do # Settings specified here will take precedence over those in config/application.rb # Code is not reloaded between requests #config.cache_classes = true # Full error reports are disabled and caching is turned on #config.consider_all_requests_local = false #config...
Ruby
Costumecode::Application.configure do # Settings specified here will take precedence over those in config/application.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 we...
Ruby
Costumecode::Application.configure do # Settings specified here will take precedence over those in config/application.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 tes...
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run Costumecode::Application
Ruby
#!/usr/bin/env rake # 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.expand_path('../config/application', __FILE__) Costumecode::Application.load_tasks
Ruby
class CreateCourses < ActiveRecord::Migration def self.up create_table :courses do |t| t.string :id t.string :name t.string :teacher t.string :facilitator t.text :description t.string :category t.timestamps end end def self.down drop_table :courses end end
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
#!C:/Ruby/bin/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 impaired...
Ruby
#!C:/Ruby/bin/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
#!C:/Ruby/bin/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 impaired...
Ruby
#!C:/Ruby/bin/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 impaired...
Ruby
#!C:/Ruby/bin/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
#!C:/Ruby/bin/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 impaired...
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' $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" 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/dbconsole'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" 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/dbconsole'
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
module CoursesHelper end
Ruby
class Course < ActiveRecord::Base 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
class CoursesController < ApplicationController def index @courses = Course.find(:all) @pages = @courses.paginate :page => params[:page], :per_page => 12, :order => 'created_at DESC' respond_to do |format| format.html # index.html.erb format.xml { render :xml => @pages } end end ...
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): # ActiveSupport::Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person',...
Ruby
# These settings change the behavior of Rails 2 apps and will be defaults # for Rails 3. You can remove this initializer when Rails 3 is released. if defined?(ActiveRecord) # Include Active Record class name as root for JSON serialized output. ActiveRecord::Base.include_root_in_json = true # Store the full clas...
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| map.resources :courses # 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 :co...
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.2...
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 # Enable threaded mode # config.threadsafe! # Use a different logger for distributed setups # config....
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
# Copyright 2008-2009 Nokia Siemens Networks Oyj # # 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...
Ruby
#!/usr/bin/env ruby class ExampleRemoteLibrary def count_items_in_directory(path) Dir.entries(path).find_all{|i| not i.match('^\.')}.length end def strings_should_be_equal(str1, str2) puts "Comparing '#{str1}' to '#{str2}'" if str1 != str2 raise RuntimeError, "Given strings are not equal" ...
Ruby
class RubyLibraryExample def get_server_language 'ruby' end # Basic communication def passing end def failing(message) raise message end def logging(message, level='INFO') puts "*#{level}* #{message}" end def returning 'returned string' end # Logging def one_message_w...
Ruby
class RubyLibraryExample def get_server_language 'ruby' end # Basic communication def passing end def failing(message) raise message end def logging(message, level='INFO') puts "*#{level}* #{message}" end def returning 'returned string' end # Logging def one_message_w...
Ruby
# Copyright 2008-2009 Nokia Siemens Networks Oyj # # 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...
Ruby
#!/usr/bin/env ruby class ExampleRemoteLibrary def count_items_in_directory(path) Dir.entries(path).find_all{|i| not i.match('^\.')}.length end def strings_should_be_equal(str1, str2) puts "Comparing '#{str1}' to '#{str2}'" if str1 != str2 raise RuntimeError, "Given strings are not equal" ...
Ruby
#!/usr/bin/env ruby require 'blueprint/blueprint' # **Basic # # Calling this file by itself will pull files from blueprint/src and concatenate them into three files; ie.css, print.css, and screen.css. # # ruby compress.rb # # However, argument variables can be set to change how this works. # # Calling # ...
Ruby
#!/usr/bin/env ruby require 'blueprint/blueprint' require 'blueprint/validator' # This script will validate the core Blueprint files. # # The files are not completely valid. This has to do # with a small number of CSS hacks needed to ensure # consistent rendering across browsers. # # To add your own CSS files for...
Ruby
class SemanticClassNames < Blueprint # attributes attr_accessor :class_assignments attr_reader :namespace, :source_file # constructor def initialize(options = {}) @namespace = options[:namespace] || "" @source_file = options[:source_file] || File.join(Blueprint::BLUEPRINT_ROOT_PATH, 'screen.css')...
Ruby
class String # quick method to see if string has any content def blank?; self.length.zero?; end # strip space after :, remove newlines, replace multiple spaces with only one space, remove comments def strip_space! replace self.gsub(/:\s*/, ':').gsub(/\n/, '').gsub(/\s+/, ' ').gsub(/(\/\*).*?(\*\/)/, '') ...
Ruby
require 'yaml' require 'optparse' class Compressor < Blueprint # class constants TEST_FILES = [ 'index.html', 'parts/elements.html', 'parts/forms.html', 'parts/grid.html', 'parts/sample.html' ] unless const_defined?("TEST_FILES") # properties attr_accessor :namespace, :custom_css, ...
Ruby
begin require 'rubygems' gem 'rmagick' require 'rvg/rvg' rescue Exception => e end class GridBuilder < Blueprint # included modules begin include Magick rescue end # properties attr_reader :column_width, :gutter_width, :output_path, :able_to_generate # constructor def initialize(options=...
Ruby
class CSSParser < Blueprint # attributes attr_accessor :namespace attr_reader :css_output, :raw_data # constructor def initialize(options = {}) @raw_data = options[:file_path] ? File.path_to_string(options[:file_path]) : options[:css_string] || "" @namespace = options[:namespace] || "" ...
Ruby
# # HTML classes namespace adder # This class is used to add namespaces to the test files, # so that the tests will work even if you set your own namespace. # class Namespace < Blueprint # Read html to string, remove namespace if any, # set the new namespace, and update the test file. def initialize(path, nam...
Ruby
require 'fileutils' class Blueprint ROOT_PATH = File.join(File.expand_path(File.dirname(__FILE__)), "../../") BLUEPRINT_ROOT_PATH = File.join(Blueprint::ROOT_PATH, 'blueprint') SOURCE_PATH = File.join(Blueprint::BLUEPRINT_ROOT_PATH, 'src') TEST_PATH = File.join(Blueprint::RO...
Ruby
class Validator < Blueprint # instance variables attr_reader :error_count # constructor def initialize(options = {}) @error_count = 0 end # instance methods def validate java_path = `which java`.rstrip raise "You do not have a Java installed, but it is required." if java_path.blank? ...
Ruby
require 'erb' class CustomLayout < Blueprint # class constants CSS_ERB_FILE = File.join(Blueprint::LIB_PATH, 'grid.css.erb') unless const_defined?("CSS_ERB_FILE") # properties # widths/column count default to core BP settings attr_writer :column_count, :column_width, :gutter_width def column_count ...
Ruby
#!/usr/bin/env ruby require 'blueprint/blueprint' require 'blueprint/validator' # This script will validate the core Blueprint files. # # The files are not completely valid. This has to do # with a small number of CSS hacks needed to ensure # consistent rendering across browsers. # # To add your own CSS files for...
Ruby
#!/usr/bin/env ruby require 'blueprint/blueprint' # **Basic # # Calling this file by itself will pull files from blueprint/src and concatenate them into three files; ie.css, print.css, and screen.css. # # ruby compress.rb # # However, argument variables can be set to change how this works. # # Calling # ...
Ruby
# Populates the places table with .csv data class PopulatePlaces < ActiveRecord::Migration def self.up FasterCSV.foreach("#{RAILS_ROOT}/lib/dev/csv_flatfiles/COWORKINATION_Places_02.csv") do |row| Place.create( :org => row[0], :street_address => row[1], :locality =>...
Ruby
class CreatePlaces < ActiveRecord::Migration def self.up create_table :places do |t| t.column :org, :string # organization's name t.column :street_address, :string # street address t.column :locality, :string # locality (city) t.column :region, :string ...
Ruby
class AddOpenIdAuthenticationTables < ActiveRecord::Migration def self.up create_table "open_id_authentication_associations", :force => true do |t| t.column "server_url", :binary t.column "handle", :string t.column "secret", :binary t.column "issued", :integer t.column "lifetime", :i...
Ruby
class CreatePeople < ActiveRecord::Migration def self.up create_table :people do |t| t.column :login, :string # login (username) t.column :given_name, :string # given name (first name) t.column :family_name, :string # family name (last name) t.column :org, :st...
Ruby
class AlterPlacesAddLatLon < ActiveRecord::Migration def self.up add_column :places, :lat, :string add_column :places, :lng, :string end def self.down remove_column :places, :lat remove_column :places, :lng end end
Ruby
class AlterUsersAddRestfulAuthenticationCols < ActiveRecord::Migration def self.up add_column :people, :crypted_password, :string, :limit => 40 add_column :people, :salt, :string, :limit => 40 add_column :people, :remember_token, :string add_column :peopl...
Ruby
class AlterPeopleTableAddOpenIdColumn < ActiveRecord::Migration def self.up add_column :people, :openid_url, :string end def self.down remove_column :people, :openid_url end end
Ruby
class AlterPeopleTableAddNicknameColumn < ActiveRecord::Migration def self.up add_column :people, :nickname, :string end def self.down remove_column :people, :nickname end end
Ruby
class CreateEvents < ActiveRecord::Migration def self.up create_table :events do |t| end end def self.down drop_table :events end end
Ruby
class CreateMembershipsTable < ActiveRecord::Migration def self.up create_table :memberships do |t| t.column :person_id, :integer t.column :place_id, :integer t.column :role, :string t.column :home, :boolean t.column :created_at, :datetime # created at (auto) t.column :up...
Ruby
# Add lat/lng info to each Place in the places table class GeocodePlaces < ActiveRecord::Migration def self.up places = Place.find(:all) for place in places geo = GeoKit::Geocoders::MultiGeocoder.geocode("#{place.locality}, #{place.region}, #{place.postal_code}, #{place.country_name}") place.updat...
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/local/bin/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 impai...
Ruby
#!/usr/local/bin/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.lo...
Ruby
#!/usr/local/bin/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 impai...
Ruby
#!/usr/local/bin/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 impai...
Ruby
#!/usr/local/bin/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.lo...
Ruby
#!/usr/local/bin/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 impai...
Ruby
load 'deploy' if respond_to?(:namespace) # cap2 differentiator load 'config/deploy'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/breakpointer'
Ruby