code
stringlengths
1
1.73M
language
stringclasses
1 value
#!/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/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/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/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/inspector'
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/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 Person < ActiveRecord::Migration def self.up create_table :people do |t| t.string :name t.string :surname t.string :photo t.timestamps end end def self.down drop_table :people end end
Ruby
class AddColToPerson < ActiveRecord::Migration def self.up add_column :people, :announcement_id, :integer end def self.down remove_column :people, :announcement_id end end
Ruby
class Announcement < ActiveRecord::Migration def self.up create_table :announcements do |t| t.string :type t.string :title t.date :start t.date :end t.string :place t.string :description t.string :mail t.timestamps end end def self.down drop_table :ann...
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.string :email t.string :name t.string :password t.integer :privilege t.timestamps end end def self.down drop_table :users end end
Ruby
class Drop < ActiveRecord::Migration def self.up drop_table :announcements end def self.down end end
Ruby
class ChangeAnnType < ActiveRecord::Migration def self.up change_column :announcements, :start, :datetime change_column :announcements, :end, :datetime end def self.down raise ActiveRecord::IrreversibleMigration end end
Ruby
class CreateAnnouncements < ActiveRecord::Migration def self.up create_table :announcements do |t| t.string :announcement_type t.string :title t.datetime :start t.datetime :end t.string :place t.string :description t.string :mail t.timestamps end end def s...
Ruby
class ChangeColNameType < ActiveRecord::Migration def self.up rename_column :announcements, :type, :announcement_type end def self.down raise ActiveRecord::IrreversibleMigration end end
Ruby
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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/dispat...
Ruby
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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/dispat...
Ruby
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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 Fast...
Ruby
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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/dispat...
Ruby
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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/dispat...
Ruby
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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 Fast...
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
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
require 'mytest_ext' module Mytest def hello puts MytestInt::hello() end module_function :hello end
Ruby
puts 'hello world' #require 'hello2'
Ruby
require "pathname" require 'rake/clean' # 请自行定义下面两行 NAME = "windump" # 可执行文件名 SRC = "./src" # D 源程序在 ./src 目录下(包括子目录) IMPORT_DIR = "./src" LIBS = ["advapi32.lib", "uuid.lib", "ole32.lib", "oleaut32.lib"] # 程序用到的附加 .lib # DCFLAGS_DEBUG = "-debug -g -version=WD_Console...
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 Wine def initialize() @log = Logger.new(STDOUT) @producer = "" @source = "n/a" @country = "" @region = "" @area = "" @year = 0 @ean = "" @category = "" @type = "" @alcohol = "" @name = "Unknown wine" end # Who made the wine attr_accessor :producer # Where was t...
Ruby
require_relative "parsers/wein.cc.rb" require "csv" require "logger" $log = Logger.new(STDOUT) $log.level = Logger::DEBUG # ARGs handling newWines = Array.new(0) # read CSV and iterate over all eans # Note: CSV is UTF-8 encoded! CSV.foreach("test.csv", :headers => true, :col_sep => ";", :encoding => "UTF...
Ruby
require 'rubygems' require 'open-uri' require 'hpricot' require 'logger' require_relative '../wine.class.rb' class WineCc def self.getWines(ean) result = Array.new(0) baseUrl = "http://www.wein.cc" doc = Hpricot(open(baseUrl + "/wein/weinsuche.php?q=" + URI::encode(ean))) # Suche alle Links a...
Ruby
class Wine def initialize() @log = Logger.new(STDOUT) @producer = "" @source = "n/a" @country = "" @region = "" @area = "" @year = 0 @ean = "" @category = "" @type = "" @alcohol = "" @name = "Unknown wine" end # Who made the wine attr_accessor :producer # Where was t...
Ruby
require_relative "parsers/wein.cc.rb" require "csv" require "logger" $log = Logger.new(STDOUT) $log.level = Logger::DEBUG # ARGs handling newWines = Array.new(0) # read CSV and iterate over all eans # Note: CSV is UTF-8 encoded! CSV.foreach("test.csv", :headers => true, :col_sep => ";", :encoding => "UTF...
Ruby
require 'rubygems' require 'open-uri' require 'hpricot' require 'logger' require_relative '../wine.class.rb' class WineCc def self.getWines(ean) result = Array.new(0) baseUrl = "http://www.wein.cc" doc = Hpricot(open(baseUrl + "/wein/weinsuche.php?q=" + URI::encode(ean))) # Suche alle Links a...
Ruby
require_relative "wine.class.rb" class Tools end
Ruby
class Wine def initialize() @log = Logger.new(STDOUT) @producer = "" @source = "n/a" @country = "" @region = "" @area = "" @year = 0 @ean = "" @category = "" @type = "" @alcohol = "" @name = "Unknown wine" end # Who made the wine attr_accessor :producer # Where was t...
Ruby
 class CsvHandler def initialize(fileName) @file = fileName end def getWines() result = Array.new(0) CSV.foreach(@file, :headers => true, :col_sep => ";", :encoding => "UTF-8") do |csv_wine| result << csvToWine(csv_wine) end (result) end def saveWines(wines) line=0 CSV.open(...
Ruby
require_relative "parsers/wein.cc.rb" require_relative "parsers/avin.cc.rb" require_relative "tools.rb" require_relative "wine.class.rb" require_relative "io-handlers/csv.rb" require "csv" require "choice" require "logger" $log = Logger.new(STDOUT) $log.level = Logger::DEBUG AVIN_STORAGE = "AVIN" #####...
Ruby
require 'rubygems' require 'open-uri' require 'hpricot' require 'logger' require_relative '../wine.class.rb' # Uses the Avin API # Details can be found here: http://www.avin.cc/api-documentation/ class AvinCc def self.getWines(ean) result = Array.new(0) $log.warn("NOT YET IMPLEMENTED as we currently mi...
Ruby
require 'rubygems' require 'open-uri' require 'hpricot' require 'logger' require_relative '../wine.class.rb' class WineCc def self.getWines(ean) result = Array.new(0) baseUrl = "http://www.wein.cc" doc = Hpricot(open(baseUrl + "/wein/weinsuche.php?q=" + URI::encode(ean))) # Suche alle Links a...
Ruby
require 'rubygems' require 'selenium-webdriver' begin driver = Selenium::WebDriver.for :remote, :url => "http://localhost:4444/wd/hub", :desired_capabilities => :firefox driver.get "http://www.google.com" driver.save_screenshot "/Screenshots/google.png" ensure driver.quit end
Ruby
require 'rubygems' # not required for ruby 1.9 or if you installed without gem require 'selenium-webdriver' driver = Selenium::WebDriver.for :firefox driver.manage.timeouts.implicit_wait = 10 # seconds driver.get "http://somedomain/url_that_delays_loading" element = driver.find_element(:id => "some-dynamic-element")
Ruby
require 'rubygems' # not required for ruby 1.9 or if you installed without gem require 'selenium-webdriver' driver = Selenium::WebDriver.for :firefox driver.get "http://somedomain/url_that_delays_loading" wait = Selenium::WebDriver::Wait.new(:timeout => 10) # seconds begin element = wait.until { driver.find_element...
Ruby
require 'rubygems' require 'selenium-webdriver' PROXY = "localhost:8080" proxy = Selenium::WebDriver::Proxy.new( :http => PROXY, :ftp => PROXY, :ssl => PROXY ) caps = Selenium::WebDriver::Remote::Capabilities.ie(:proxy => proxy) # you have to use remote, otherwise you'll have to code it yoursel...
Ruby
require 'rubygems' require 'selenium-webdriver' PROXY = 'localhost:8087' profile = Selenium::WebDriver::Firefox::Profile.new profile.proxy = Selenium::WebDriver::Proxy.new( :http => PROXY, :ftp => PROXY, :ssl => PROXY ) driver = Selenium::WebDriver.for :firefox, :profile => profile
Ruby
driver = Selenium::WebDriver.for :chrome
Ruby
driver = Selenium::WebDriver.for :ie
Ruby
driver = Selenium::WebDriver.for :firefox
Ruby
driver = Selenium::WebDriver.for :remote, :url => "http://localhost:4444/wd/hub", :desired_capabilities => :htmlunit
Ruby
require 'rubygems' require 'selenium-webdriver' driver = Selenium::WebDriver.for :firefox driver.get "http://google.com" element = driver.find_element :name => "q" element.send_keys "Cheese!" element.submit puts "Page title is #{driver.title}" wait = Selenium::WebDriver::Wait.new(:timeout => 10) wait.u...
Ruby
require 'rubygems' require 'eventmachine' require 'mail' module Handler @last = '' @content = '' def file_modified puts "#{path} modified" @content = File.read(path) if @content != @last puts 'content changed:', @content ## EM.next_tick do ...
Ruby
require 'rubygems' require 'mail' #require 'mustache' hostname = 'localhost'#`hostname`.strip Mail.defaults do delivery_method :smtp, { :address => hostname, :port => 25, :domain => hostname } end mail = Mail.new do from 'from@localhost' to 'to@localhost' subject 'test email subj...
Ruby
# Copyright (c) 2006 "Gardiner" # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, di...
Ruby
# Copyright (c) 2006 "Gardiner" # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, di...
Ruby
# Copyright (c) 2006 "Gardiner" # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, di...
Ruby
# Copyright (c) 2006 "Gardiner" # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, di...
Ruby
# Copyright (c) 2006 "Gardiner" # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, di...
Ruby
# Copyright (c) 2006 "Gardiner" # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, di...
Ruby
# Copyright (c) 2006 "Gardiner" # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, di...
Ruby
# Copyright (c) 2006 "Gardiner" # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, di...
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
# 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
# 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 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
# 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
ActionController::Routing::Routes.draw do |map| map.resources :spaces map.resources :spaces map.resources :spaces # The priority is based upon order of creation: first created -> highest priority. # Sample of regular route: # map.connect 'products/:id', :controller => 'catalog', :action => 'view' # K...
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
# CalendarHelper allows you to draw a databound calendar with fine-grained CSS formatting # # Screw the license. class Date def week return self.next.cweek end end module CalendarHelper # Returns an HTML calendar. In its simplest form, this method generates a plain # calendar (which can then be ...
Ruby
module SpacesHelper def can_have_action true end def date_title( blog, prev_date) return "" if prev_date == blog.log_date return "<div class=\"DateTitle\"> #{blog.log_date.to_s}</div>" end def SpacesHelper::get_date_period params @today = Date.today date_from = date_to = @today if p...
Ruby
class Page < ActiveRecord::Base end
Ruby
class Weblog < Page end
Ruby
class Space < ActiveRecord::Base has_many :pages has_many :weblogs def existing_page_titles connection.select_all("SELECT title FROM pages WHERE space_id = #{self.id.to_i}").map { |row| row['title'] } end end
Ruby
class AnonymousUser acts_as_anonymous_user end
Ruby
class User < ActiveRecord::Base acts_as_user acts_as_encrypts_password validates_length_of :password, :minimum => 8 class << self # Searches for the user record with the given email and password and # returns a User instance for it. Returns nil if no user with the given # credentials could ...
Ruby