code
stringlengths
1
1.73M
language
stringclasses
1 value
module ExtJS4 module SassExtensions module Functions module Utils def parsebox(list, n) assert_type n, :Number if !n.int? raise ArgumentError.new("List index #{n} must be an integer") elsif n.to_i < 1 raise ArgumentError.new("List index #{n} must...
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
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
# 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
# Be sure to restart your web 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 ...
Ruby
# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb unless defined?(RAILS_ROOT) root_path = File.join(File.dirname(__FILE__), '..') unless RUBY_PLATFORM =~ /mswin32/ require 'pathname' root_path = Pathname.new(root_path).cleanpath(true).to_s end RAILS...
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
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper def translate(str,lang=:ru) case str when 'First name': return 'Имя' when 'Name': return 'ИО' when 'Last name': return 'Фамилия' when 'Rank': return 'Разряд' when 'Cre...
Ruby
module NewsHelper end
Ruby
module PlayersHelper end
Ruby
class Pair < ActiveRecord::Base set_primary_key "pair_id" has_many :teams, :through => :teampair has_many :players, :through => :pairplayer end
Ruby
class MenuItem < ActiveRecord::Base attr_accessor :controller_action, :content_page validates_presence_of :name validates_uniqueness_of :name def above if self.parent_id conditions = ["parent_id = ? and seq = ?", self.parent_id, self.seq - 1] else conditions = ["parent_i...
Ruby
class Name attr_reader :first, :last def initialize(first, last) @first = first @last = last end def to_s [@first, @last].compact.join(" ") # compact - Returns a new array based on the arr with all nil elements removed end end class Player < ActiveRecord::Ba...
Ruby
class Login attr_accessor :errors attr_accessor :name, :password def initialize @errors = Array.new end end
Ruby
class Event < ActiveRecord::Base set_primary_key "event_id" end
Ruby
class SiteController < ActiveRecord::Base validates_presence_of :name validates_uniqueness_of :name attr_accessor :permission def permission @permission ||= Permission.find_by_id(self.permission_id) return @permission end def actions @actions ||= ControllerAction.find(:all, ...
Ruby
class Permission < ActiveRecord::Base validates_presence_of :name validates_uniqueness_of :name # Find Permissions for a Role ID or an array of Role IDs. def Permission.find_for_role(role_ids) return find_by_sql( ["select permissions.* from permissions inner join roles_permissions on permissions.id = rol...
Ruby
class Credentials attr_accessor :role_id, :updated_at, :role_ids attr_accessor :permission_ids attr_accessor :controllers, :actions, :pages # Create a new credentials object for the given role def initialize(role_id) @role_id = role_id role = Role.find(@role_id) @updated_at = role.updated_at ...
Ruby
class MarkupStyle < ActiveRecord::Base validates_presence_of :name validates_uniqueness_of :name end
Ruby
class TeamPair < ActiveRecord::Base set_primary_key "team_pair_id" belongs_to :pair, :foreign_key=>"pair_id" belongs_to :team, :foreign_key=>"team_id" end
Ruby
class Team < ActiveRecord::Base set_primary_key "team_id" has_many :pairs, :through => :teampair end
Ruby
require 'redcloth' class ContentPage < ActiveRecord::Base validates_presence_of :name validates_uniqueness_of :name attr_accessor :content_html def self.find_for_permission(p_ids) if p_ids and p_ids.length > 0 return find(:all, :conditions => ['permission_id in (?)', p_ids], ...
Ruby
require 'digest/sha1' class User < ActiveRecord::Base validates_presence_of :name validates_uniqueness_of :name attr_accessor :clear_password attr_accessor :confirm_password def role if self.role_id @role ||= Role.find(self.role_id) end return @role end def before_save if sel...
Ruby
class ControllerAction < ActiveRecord::Base validates_presence_of :name validates_uniqueness_of :name, :scope => 'site_controller_id' attr_accessor :controller, :permission, :url, :allowed, :specific_name def controller @controller ||= SiteController.find(self.site_controller_id) end def permission ...
Ruby
class SystemSettings < ActiveRecord::Base set_table_name 'system_settings' attr_accessor :public_role, :default_markup_style attr_accessor :site_default_page, :not_found_page, :permission_denied_page, :session_expired_page def public_role @public_role ||= Role.find(self.public_role_id) end def defa...
Ruby
class RolesPermission < ActiveRecord::Base def RolesPermission.find_for_role(role_ids) return find_by_sql [%q{ select roles_permissions.*, permissions.name from roles_permissions inner join permissions on roles_permissions.permission_id = permissions.id where role_id in (?) order by permissions.name }, role...
Ruby
class PairPlayer < ActiveRecord::Base set_primary_key "pair_player_id" belongs_to :pair, :foreign_key=>"pair_id" belongs_to :player, :foreign_key=>"player_id" end
Ruby
require "credentials" require "menu" class Role < ActiveRecord::Base serialize :cache validates_presence_of :name validates_uniqueness_of :name def Role.rebuild_cache roles = Role.find(:all) for role in roles do role.cache = nil ; role.save # we have to do this to clear it role.cache...
Ruby
class Rank < ActiveRecord::Base def human_rank return self.rank end end
Ruby
class Menu class Node attr_accessor :parent, :parent_id, :children attr_accessor :site_controller_id, :controller_action_id, :content_page_id attr_accessor :id, :name, :label, :url def initialize() @parent = nil end def setup(item) @parent_id = item.parent_id @name = item....
Ruby
class EventType < ActiveRecord::Base set_primary_key "event_type_id" end
Ruby
class SystemSettingsController < ApplicationController def index list render :action => 'list' end # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def list ...
Ruby
class ClubController < ApplicationController layout "base" def index end def about end def contacts end end
Ruby
class RolesController < ApplicationController # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def index list render :action => 'list' end def list @roles ...
Ruby
class ControllerActionsController < ApplicationController # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def index list render :action => 'list' end def li...
Ruby
class AuthController < ApplicationController # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :login, :logout ], :redirect_to => { :action => :list } def login if request.get? AuthController.clear_session(session) else ...
Ruby
class NewsController < ApplicationController end
Ruby
class MarkupStylesController < ApplicationController # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def index list render :action => 'list' end def list ...
Ruby
class PermissionsController < ApplicationController # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def index list render :action => 'list' end def list @...
Ruby
class EventsController < ApplicationController layout 'base' def list end end
Ruby
class SiteControllersController < ApplicationController # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def index list render :action => 'list' end def list ...
Ruby
class RolesPermissionsController < ApplicationController # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def index list render :action => 'list' end def list ...
Ruby
class PlayersController < ApplicationController layout "application" def index list render :action => 'list' end # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action =>...
Ruby
require 'menu' class MenuItemsController < ApplicationController # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update, :move_up, :move_down ], :redirect_to => { :action => :list } d...
Ruby
# Filters added to this controller will be run for all controllers in the application. # Likewise, all the methods added will be available for all controllers. class ApplicationController < ActionController::Base @lang = :ru end class Array def to_ru self.collect! do |elem| if elem.instance_of? Strin...
Ruby
class UsersController < ApplicationController # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def index list render :action => 'list' end def list @user_p...
Ruby
class ContentPagesController < ApplicationController # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def index list render :action => 'list' end def list ...
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 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/runner'
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/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/profiler'
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/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/breakpointer'
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/console'
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/spawner'
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/spawner'
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/generate'
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/about'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/plugin'
Ruby
class FakeEntries < ActiveRecord::Migration def self.up puts "Creating fake Player" p = Player.new p.id = 1 p.name = Name.new("[!]Fake","Player[!]") p.created_at = Time.now p.save! puts "Creating fake Pair" p = Pair.new p.id = 1 p.lock = false p.created_at = Time.now ...
Ruby
class CreateRanks < ActiveRecord::Migration def self.up create_table :ranks do |t| t.column 'rank', :float t.column 'desc', :string end end def self.down drop_table :ranks end end
Ruby
class CreateTeams < ActiveRecord::Migration def self.up create_table :teams, :primary_key => "team_id" do |table| table.column :team_name, :string, :null => "false" table.column :lock, :boolean, :null => false table.column :created_at, :date, :null => false end end def self.down dro...
Ruby
class CreatePlayers < ActiveRecord::Migration def self.up create_table :players, :primary_key => "player_id" do |table| table.column :first_name, :string, :null => false table.column :last_name, :string, :null => false table.column :rank_id, :integer, :null => false table.column :...
Ruby
class CreateDeals < ActiveRecord::Migration def self.up create_table :deals, :primary_key => "deal_id" do |table| table.column :num, :integer, :null => false table.column :event_id, :integer, :null => false table.column :res, :integer, :null => false table.column :ns_id, :integer, :null =...
Ruby
class InitialSetup < ActiveRecord::Migration def self.up create_table 'markup_styles', :force => false do |t| t.column 'name', :string, :default => '', :null => false end create_table 'permissions', :force => false do |t| t.column 'name', :string, :default => '', :null => false end ...
Ruby
class CreatePairs < ActiveRecord::Migration def self.up create_table :pairs, :primary_key => "pair_id" do |table| table.column :lock, :boolean, :null => false table.column :created_at, :date, :null => false end end def self.down drop_table :pairs end end
Ruby
class CreatePairsPlayers < ActiveRecord::Migration def self.up create_table :pairs_players, :primary_key=>"pair_player_id" do |t| t.column :pair_id, :integer t.column :player_id, :integer end # execute " # ALTER TABLE pairs_players ADD FOREIGN KEY (pair_id) REFERENCES pairs (pair_id); # ...
Ruby
class CreateDealDetails < ActiveRecord::Migration def self.up create_table :deal_details, :primary_key => "deal_detail" do |table|\ table.column :deal_id, :integer, :null => false table.column :room, :boolean # true: open table.column :deal_data, :string table.column :auction, :string ...
Ruby
class CreateEvents < ActiveRecord::Migration def self.up create_table :events, :primary_key=>"event_id" do |table| table.column :event_title, :string, :null => false table.column :event_type_id, :integer, :null => false # FK eventtypes table.column :parent_event_id, :integer # FK events ta...
Ruby
class CreateParticipants < ActiveRecord::Migration def self.up create_table :participants, :primary_key => "participant_id" do |table| table.column :event_id, :integer, :null => false # FK events table.column :team_id, :integer, :null => false table.column :pair_id, :integer, :null => false ...
Ruby
class MenuRestItemsUsersCachedContentPages < ActiveRecord::Migration def self.up # Add URL to use for Actions, to better support REST add_column 'controller_actions', 'url_to_use', :string # Enhancements for Users add_column 'users', 'password_salt', :string add_column 'users', 'fullname', :strin...
Ruby
class CreateEventTypes < ActiveRecord::Migration def self.up create_table :event_types, :primary_key => "event_type_id" do |table| table.column :event_type_desc, :string table.column :created_at, :date, :null => false end end def self.down drop_table :event_types end end
Ruby
class CreateTeamsPairs < ActiveRecord::Migration def self.up create_table :teams_pairs, :primary_key=>"team_player_id" do |t| t.column :pair_id, :integer t.column :team_id, :integer end # execute " # ALTER TABLE teams_pairs ADD FOREIGN KEY (pair_id) REFERENCES pairs (pair_id); # ALTER...
Ruby
class AddLocationToPlayers < ActiveRecord::Migration def self.up add_column 'players', 'location', :string end def self.down remove_column 'players', 'location' end end
Ruby
namespace :goldberg do desc "Dump standard Goldberg tables to files in db/" task :dump_starter => :environment do goldberg_classes.each do |klass| dump_for_class klass, "db" end end desc "Load standard Goldberg tables from files in db/" task :load_starter => 'db:migrate' do goldberg_class...
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