code
stringlengths
1
1.73M
language
stringclasses
1 value
# Copyright (c) 2006 The Pragmatic Programmers, LLC. # Reproduced from the book "Agile Web Development with Rails, 2nd Ed.", # published by The Pragmatic Bookshelf. # Available from www.pragmaticprogrammer.com/titles/rails2 # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this sour...
Ruby
# Copyright (c) 2006 The Pragmatic Programmers, LLC. # Reproduced from the book "Agile Web Development with Rails, 2nd Ed.", # published by The Pragmatic Bookshelf. # Available from www.pragmaticprogrammer.com/titles/rails2 # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this sour...
Ruby
# Copyright (c) 2006 The Pragmatic Programmers, LLC. # Reproduced from the book "Agile Web Development with Rails, 2nd Ed.", # published by The Pragmatic Bookshelf. # Available from www.pragmaticprogrammer.com/titles/rails2 # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this sour...
Ruby
# Copyright (c) 2006 The Pragmatic Programmers, LLC. # Reproduced from the book "Agile Web Development with Rails, 2nd Ed.", # published by The Pragmatic Bookshelf. # Available from www.pragmaticprogrammer.com/titles/rails2 # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this sour...
Ruby
#!/Users/dave/ruby1.8/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...
Ruby
#!/Users/dave/ruby1.8/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 ...
Ruby
#!/Users/dave/ruby1.8/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...
Ruby
#!/Users/dave/ruby1.8/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 ...
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/breakpointer'
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/breakpointer'
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' 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
# Copyright (c) 2006 The Pragmatic Programmers, LLC. # Reproduced from the book "Agile Web Development with Rails, 2nd Ed.", # published by The Pragmatic Bookshelf. # Available from www.pragmaticprogrammer.com/titles/rails2 # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this sour...
Ruby
# Copyright (c) 2006 The Pragmatic Programmers, LLC. # Reproduced from the book "Agile Web Development with Rails, 2nd Ed.", # published by The Pragmatic Bookshelf. # Available from www.pragmaticprogrammer.com/titles/rails2 # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this sour...
Ruby
# Copyright (c) 2006 The Pragmatic Programmers, LLC. # Reproduced from the book "Agile Web Development with Rails, 2nd Ed.", # published by The Pragmatic Bookshelf. # Available from www.pragmaticprogrammer.com/titles/rails2 # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this sour...
Ruby
module CustomersHelper end
Ruby
module OrdersHelper end
Ruby
# Copyright (c) 2006 The Pragmatic Programmers, LLC. # Reproduced from the book "Agile Web Development with Rails, 2nd Ed.", # published by The Pragmatic Bookshelf. # Available from www.pragmaticprogrammer.com/titles/rails2 # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this sour...
Ruby
module LinesHelper end
Ruby
# Copyright (c) 2006 The Pragmatic Programmers, LLC. # Reproduced from the book "Agile Web Development with Rails, 2nd Ed.", # published by The Pragmatic Bookshelf. # Available from www.pragmaticprogrammer.com/titles/rails2 # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this sour...
Ruby
# Copyright (c) 2006 The Pragmatic Programmers, LLC. # Reproduced from the book "Agile Web Development with Rails, 2nd Ed.", # published by The Pragmatic Bookshelf. # Available from www.pragmaticprogrammer.com/titles/rails2 # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this sour...
Ruby
# Copyright (c) 2006 The Pragmatic Programmers, LLC. # Reproduced from the book "Agile Web Development with Rails, 2nd Ed.", # published by The Pragmatic Bookshelf. # Available from www.pragmaticprogrammer.com/titles/rails2 # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this sour...
Ruby
class Customer < ActiveRecord::Base end
Ruby
class Line < ActiveRecord::Base belongs_to :order, :foreign_key => 'order_num', :class_name => 'Order' validates_presence_of :product, :qty, :price, :unitcost validates_numericality_of :qty, :price, :unitcost def before_save self.sum_sales = self.qty * self.price self.sum_cost = self.qty * self.un...
Ruby
require 'will_paginate' #START:validate #START:select #START:has_many class Order < ActiveRecord::Base #END:select #END:validate has_many :lines, :foreign_key => 'order_num', :class_name => 'Line' #END:has_many cattr_reader :per_page @@per_page = 10 #START:select STATUS_TYPES = [ # Displayed...
Ruby
class StoreController < ApplicationController before_filter :authorize #START:before_filter # before_filter :find_cart, :except => :empty_cart #END:before_filter def index redirect_to :controller=>'orders',:action => :index end # GET /orders/1/lines def order_lines if prepare_order and pa...
Ruby
#START:authorize #START:layout class LoginController < ApplicationController #END:layout #START:filter before_filter :authorize, :except => :login # before_filter :authorize_admin, :on => [:add_user, :delete_user] #END:filter # . . #END:authorize #START:layout #layout "admin" #END:layout #START:index ...
Ruby
class LinesController < ApplicationController # GET /lines # GET /lines.xml def index @lines = Line.find(:all) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @lines } end end # GET /lines/1 # GET /lines/1.xml def show @line = Line.find(params...
Ruby
class ApplicationController < ActionController::Base def cur_user User.find_by_name session[:user_name] end def cur_user_name session[:user_name] end protected def need_login end def need_admin if not admin? flash[:notice]...
Ruby
class OrdersController < ApplicationController before_filter :authorize # GET /orders # GET /orders.xml def index if admin? @orders = Order.paginate :order => 'created_at DESC', :page => params[:page] else @orders = Order.paginate_by_user cur_user.name,:order => 'created_at DESC', :page => ...
Ruby
#START:authorize class AdminController < ApplicationController before_filter :authorize # .... #END:authorize layout "application" def index list render :action => 'list' end def list # @product_pages, @products = paginate :products, :per_page => 10 @products = Product.search(:all, ...
Ruby
class CustomersController < ApplicationController before_filter :authorize # GET /customers # GET /customers.xml def index if admin? @customers = Customer.find :all else @customers = Customer.find :all, :conditions => ["user = ?", cur_user.name] end respond_to do |format| fo...
Ruby
# Copyright (c) 2006 The Pragmatic Programmers, LLC. # Reproduced from the book "Agile Web Development with Rails, 2nd Ed.", # published by The Pragmatic Bookshelf. # Available from www.pragmaticprogrammer.com/titles/rails2 # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this sour...
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
# Copyright (c) 2006 The Pragmatic Programmers, LLC. # Reproduced from the book "Agile Web Development with Rails, 2nd Ed.", # published by The Pragmatic Bookshelf. # Available from www.pragmaticprogrammer.com/titles/rails2 # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this sour...
Ruby
# Copyright (c) 2006 The Pragmatic Programmers, LLC. # Reproduced from the book "Agile Web Development with Rails, 2nd Ed.", # published by The Pragmatic Bookshelf. # Available from www.pragmaticprogrammer.com/titles/rails2 # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this sour...
Ruby
# Copyright (c) 2006 The Pragmatic Programmers, LLC. # Reproduced from the book "Agile Web Development with Rails, 2nd Ed.", # published by The Pragmatic Bookshelf. # Available from www.pragmaticprogrammer.com/titles/rails2 # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this sour...
Ruby
# Copyright (c) 2006 The Pragmatic Programmers, LLC. # Reproduced from the book "Agile Web Development with Rails, 2nd Ed.", # published by The Pragmatic Bookshelf. # Available from www.pragmaticprogrammer.com/titles/rails2 # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this sour...
Ruby
# Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/switchtower.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
namespace :db do desc "Prints the migration version" task :schema_version => :environment do puts ActiveRecord::Base.connection.select_value('select version from schema_info') end end
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
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "theme/css" sass_dir = "theme/scss" images_dir = "images" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): output_style = :co...
Ruby
#!/usr/bin/env ruby ## git-rank-contributors: a simple script to trace through the logs and ## rank contributors by the total size of the diffs they're responsible for. ## A change counts twice as much as a plain addition or deletion. ## ## Output may or may not be suitable for inclusion in a CREDITS file. ## Probably...
Ruby
#!/usr/bin/env ruby ## git-rank-contributors: a simple script to trace through the logs and ## rank contributors by the total size of the diffs they're responsible for. ## A change counts twice as much as a plain addition or deletion. ## ## Output may or may not be suitable for inclusion in a CREDITS file. ## Probably...
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
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
require 'sinatra.rb' # Sinatra defines #set at the top level as a way to set application configuration set :run, false set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development) require './main' run Sinatra::Application
Ruby
require 'sinatra/activerecord/rake' require './main'
Ruby
#!/usr/bin/env ruby ## git-rank-contributors: a simple script to trace through the logs and ## rank contributors by the total size of the diffs they're responsible for. ## A change counts twice as much as a plain addition or deletion. ## ## Output may or may not be suitable for inclusion in a CREDITS file. ## Probably...
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "theme/css" sass_dir = "theme/scss" images_dir = "images" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): output_style = :co...
Ruby
require 'mytest_ext' module Mytest def hello puts MytestInt::hello() end module_function :hello end
Ruby
puts 'hello world' #require 'hello2'
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
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
require 'sinatra.rb' # Sinatra defines #set at the top level as a way to set application configuration set :run, false set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development) require './main' run Sinatra::Application
Ruby
require 'sinatra/activerecord/rake' require './main'
Ruby
#!/usr/bin/env ruby ## git-rank-contributors: a simple script to trace through the logs and ## rank contributors by the total size of the diffs they're responsible for. ## A change counts twice as much as a plain addition or deletion. ## ## Output may or may not be suitable for inclusion in a CREDITS file. ## Probably...
Ruby
#!/usr/bin/env ruby ## git-rank-contributors: a simple script to trace through the logs and ## rank contributors by the total size of the diffs they're responsible for. ## A change counts twice as much as a plain addition or deletion. ## ## Output may or may not be suitable for inclusion in a CREDITS file. ## Probably...
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "theme/css" sass_dir = "theme/scss" images_dir = "images" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): output_style = :co...
Ruby
TBD: Russian uppercase alphabet [А-Я] A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0гг 1гг 2гг 3гг 4гг 5гг 6гг 7гг 8гг 9гг 0г 1г 2г 3г 4г 5г 6г 7г 8г 9г Xвв Vвв Iвв Lвв Mвв Cвв Xв Vв Iв Lв Mв Cв 0м 1м 2м 3м 4м 5м 6м 7м 8м 9м 0мм 1мм 2мм 3мм 4мм 5мм 6мм 7мм 8мм 9мм 0см 1см 2см 3см 4см 5см 6см 7см 8см 9см 0дм 1дм ...
Ruby
# Copyright (C) 2010 Tom Verbeure # # 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 wri...
Ruby
#! /usr/bin/env ruby # Copyright (C) 2010 Tom Verbeure # # 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 l...
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
require 'sinatra.rb' # Sinatra defines #set at the top level as a way to set application configuration set :run, false set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development) require './main' run Sinatra::Application
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "theme/css" sass_dir = "theme/scss" images_dir = "images" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): output_style = :co...
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