code
stringlengths
1
1.73M
language
stringclasses
1 value
require 'rake' require 'rake/testtask' require 'rake/rdoctask' desc 'Default: run unit tests.' task :default => :test desc 'Test the acts_as_gradable plugin.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc 'Generate documentation for the acts_as_grada...
Ruby
# desc "Explaining what the task does" # task :acts_as_gradable do # # Task goes here # end
Ruby
# Uninstall hook code here
Ruby
# Install hook code here
Ruby
module ActsAsGradable def acts_as_gradable #has_one :grade, :dependent => :destroy, :as => :gradable, :foreign_key => :gradable_id class_eval do def grade # end end # class eval do end # def acts_as_gradable end
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 'webrick' require 'webrick/httpproxy' require 'optparse' #puts req.request_line, req.raw_header module WEBrick class RLProxyServer < WEBrick::HTTPProxyServer def initialize(hash) p hash @orig_parent = hash[:Parent] p @orig_parent super(hash) end def proxy_service(req, re...
Ruby
#!/usr/bin/ruby srand(Time.now.to_i) # for simplicity, I assume that each proxy only has parents and ignores peers. # the state is represented as # (proxy_server, request.domain) # we map the URL space to just domain space under the assumption that if a # proxy is good enough for a domain, then it is good enough fo...
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
class RssEntry < ActiveRecord::Base acts_as_tsearch :fields => ["title","summary"] def self.reload_rss RssEntry.delete_all feed = FeedTools::Feed.open("http://feeds.feedburner.com/RidingRails") feed.items.each do |f| RssEntry.new(:title => f.title, :summary => f.summary, :link => f.link).sav...
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 # Pick a unique cookie name to distinguish our session data from others' session :session_key => '_tsearch_se...
Ruby
class RssController < ApplicationController #sudo gem install feed_tools require 'feed_tools' def index RssEntry.reload_rss if RssEntry.find(:first).nil? end def search if !params[:search].blank? @search = params[:search] if @search.size > 2 @results = RssEntry.find_by_tsea...
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 CreateRssEntries < ActiveRecord::Migration def self.up create_table :rss_entries do |t| t.column "title", :string t.column "summary", :text t.column "link", :string t.column "vectors", :tsvector end end def self.down drop_table :rss_entries e...
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/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/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/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/plugin'
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/about'
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/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/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/runner'
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/console'
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/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/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/benchmarker'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/profiler'
Ruby
#!/opt/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
#!/opt/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
#!/opt/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
#!/opt/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
#!/opt/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
#!/opt/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
# 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
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
# 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
# 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
# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) unless defined?(Rails::Initializer) if File.directory?("#{RAILS_ROOT}/vendor/rails") require "#{RAILS_ROOT}/vendor/rails/railties/lib/init...
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
source 'https://rubygems.org' gem 'jekyll', '~> 1.0' gem 'debugger'
Ruby
## # Create individual pages for each icon in the FontAwesome set require 'yaml' require 'debugger' module Jekyll class IconPage < Page ## # Take a single icon and render a page for it. def initialize(site, base, dir, icon) @site = site @base = base @dir = dir @name = "#{icon....
Ruby
## # Provide an icons attribute on the site object require 'yaml' require 'forwardable' module Jekyll class Icon attr_reader :name, :id, :unicode, :created, :categories def initialize(icon_object) @icon_object = icon_object # Class name used in CSS and HTML @icon_object['class'] = icon...
Ruby
source :gemcutter gem 'sinatra', :require => 'sinatra/base' gem 'thin', '~> 1.3' gem 'pg' gem 'data_mapper', '~> 1.2' gem 'dm-postgres-adapter' gem 'google-api-client', '>= 0.4.3' group :development do gem 'dm-sqlite-adapter', '~> 1.2' gem 'do_sqlite3', '~> 0.10' 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
# Install hook code here
Ruby
# desc "Explaining what the task does" # task :acts_as_syncable do # # Task goes here # end
Ruby
# Uninstall hook code here
Ruby
require 'rake' require 'rake/testtask' require 'rake/rdoctask' desc 'Default: run unit tests.' task :default => :test desc 'Test the acts_as_syncable plugin.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc 'Generate documentation for the acts_as_synca...
Ruby
require 'acts_as_syncable' require 'app/models/sync' ActiveRecord::Base.send(:include, ActiveRecord::Acts::Syncable)
Ruby
module ActiveRecord module Acts #:nodoc: module Syncable #:nodoc: def self.included(base) base.extend(ClassMethods) end module ClassMethods def sync_options=(d = {}) d.delete(:root) super(d) end def acts_as_syncable(o...
Ruby
require 'open-uri' class Sync < ActiveRecord::Base METHOD_CREATE = "create" METHOD_UPDATE = "update" METHOD_DESTROY = "destroy" belongs_to :method, :polymorphic => true cattr_accessor :stall_synching class << self def do(address, for_when, options = {}, url_header = {}) do_up(address,...
Ruby
class TreeNode attr_accessor :parentNode, :value def initialize (value) @value = value @index = 0 @childNodes = [] @parentNode = nil end def childNodes @childNodes end def addChild (node) node.parentNode = self @childNode...
Ruby
require 'test/unit' require 'treenode.rb' class TreeNode_Design < Test::Unit::TestCase def test_TreeNode_Initialized_Contract myNodeValue = 'I_Like_Cake' myTreeNode = TreeNode.new(myNodeValue) assert_equal(myTreeNode.value, myNodeValue) assert_equal...
Ruby
require 'treenode.rb' require 'singleton' class TreeService include Singleton def initialize @searchResult = [] @searchResultIndex = 0 @displayResult = '' end def cloneNode(originalNode) returnNode = TreeNode.new(originalNode.value) return...
Ruby
require 'treenode.rb' require 'treeservice.rb' class TreeApplication def initialize @myTree = TreeNode.new('root') @searchResults = '' end def buildTreeFromFile(filename) file = File.open(filename) file.read.split(/\n/).each do |line| buildTreeFromS...
Ruby
require 'test/unit' require 'treenode.rb' require 'treeservice.rb' class Test_TreeNode_And_Service < Test::Unit::TestCase def test_Search_Arbitrary myTree = TreeNode.new('root') myTree.addChild(TreeNode.new('parent')) myTree.childNodes[0].addChild(TreeNode.new('child1')) ...
Ruby
require 'test/unit/testsuite' require 'test_treenode.rb' require 'test_treeservice.rb'
Ruby
require 'RMagick' class NumberImageGenerator @@IMAGE_DIR = 'numbers-hdpi/' def generate(text, fs=18) #filename = "b" + sprintf("%03d", text) + ".png"; filename = "" + sprintf("%03d", text) + ".png"; font_size = fs; height = 35; width = 35; image = Magick::Image.new(width, height) {self.ba...
Ruby
#!/usr/bin/env ruby require 'net/http' require 'uri' LANGS_URI = 'http://ath.darshancomputing.com/bi/langs/' langs = Net::HTTP.get(URI.parse(LANGS_URI)).split() langs.each do |lang| if lang.length == 2 dir = 'res/values-' << lang else dir = 'res/values-' << lang[0,2] << '-r' << lang[2,2] end if ! D...
Ruby
namespace :blast do desc "Fire off all new blasts" task :off => :environment do p "running blast:off" blasts = Blast.find(:all, :conditions=>["sent_at = created_at",nil]) for b in blasts b.sent_at = Time.now() BlastMailer.deliver_blast(b) # update attributes here so we know th...
Ruby
# Install hook code here
Ruby
require 'rake' require 'rake/testtask' require 'rake/rdoctask' desc 'Default: run unit tests.' task :default => :test desc 'Test the acts_as_blaster plugin.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc 'Generate documentation for the acts_as_blaste...
Ruby
# Uninstall hook code here
Ruby
# Include hook code here require 'acts_as_blast' ActiveRecord::Base.send(:include, Setwave::Acts::Blast) ## we need to load the config (if present...) begin Config::CONFIG["blasts"] = YAML.load(File.read("#{RAILS_ROOT}/config/blasts.yml")) rescue => error # log here... end
Ruby
class BlastGenerator < Rails::Generator::Base def manifest record do |m| ### api => http://api.rubyonrails.org/classes/Rails/Generator/Commands/Create.html ### controllers m.directory('app/controllers') m.file("app/controllers/blasts_controller.rb", "app/controllers/blasts_controller.r...
Ruby
module BlastsHelper end
Ruby
class Blast < ActiveRecord::Base cattr_accessor :partials @@partials = nil acts_as_blast attr_accessor :_blasted, :recipients belongs_to :blasted, :polymorphic => true belongs_to :user validates_presence_of :user_id, :to, :from def validate_on_create if self.blasted_id.nil? and self.blasted_t...
Ruby
class BlastMailer < ActionMailer::Base def blast(blast, sent_at = Time.now()) @body[:blast] = blast @subject = blast.subject @recipients = blast.to @from = blast.from @content_type = "text/html" @sent_on = sent_at end end
Ruby
class BlastsController < ApplicationController # GET /blasts/new def new # @user = User.find(1) @blast = Blast.new @recipients = [] if params[:blast] @blast = Blast.new(params[:blast]) if @blast.blasted_type obj = @blast.blasted_type.camelize.constantize.new() obj.id = @...
Ruby
class CreateActsAsBlast < ActiveRecord::Migration def self.up create_table :blasts do |t| t.column :user_id, :integer t.column :blasted_id, :integer t.column :blasted_type, :string, :limit=> 20 t.column :partial, :string, :limit=> 20 t.column :to, :string, :limit=> 50 t....
Ruby
# ActsAsBlast module Setwave #:nodoc: module Acts #:nodoc: module Blast #:nodoc: def self.included(base) base.extend(ClassMethods) end module ClassMethods def acts_as_blast() attr_accessor :recipients, :failed_recipients, :blast include InstanceMetho...
Ruby
namespace :blast do desc "Fire off all new blasts" task :off => :environment do p "running blast:off" blasts = Blast.find(:all, :conditions=>["sent_at = created_at",nil]) for b in blasts b.sent_at = Time.now() BlastMailer.deliver_blast(b) # update attributes here so we know th...
Ruby
# Install hook code here
Ruby
require 'rake' require 'rake/testtask' require 'rake/rdoctask' desc 'Default: run unit tests.' task :default => :test desc 'Test the acts_as_blaster plugin.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc 'Generate documentation for the acts_as_blaste...
Ruby
# Uninstall hook code here
Ruby
# Include hook code here require 'acts_as_blast' ActiveRecord::Base.send(:include, Setwave::Acts::Blast) ## we need to load the config (if present...) begin Config::CONFIG["blasts"] = YAML.load(File.read("#{RAILS_ROOT}/config/blasts.yml")) rescue => error # log here... end
Ruby
class BlastGenerator < Rails::Generator::Base def manifest record do |m| ### api => http://api.rubyonrails.org/classes/Rails/Generator/Commands/Create.html ### controllers m.directory('app/controllers') m.file("app/controllers/blasts_controller.rb", "app/controllers/blasts_controller.r...
Ruby
module BlastsHelper end
Ruby
class Blast < ActiveRecord::Base cattr_accessor :partials @@partials = nil acts_as_blast attr_accessor :_blasted, :recipients belongs_to :blasted, :polymorphic => true belongs_to :user validates_presence_of :user_id, :to, :from def validate_on_create if self.blasted_id.nil? and self.blasted_t...
Ruby
class BlastMailer < ActionMailer::Base def blast(blast, sent_at = Time.now()) @body[:blast] = blast @subject = blast.subject @recipients = blast.to @from = blast.from @content_type = "text/html" @sent_on = sent_at end end
Ruby
class BlastsController < ApplicationController # GET /blasts/new def new # @user = User.find(1) @blast = Blast.new @recipients = [] if params[:blast] @blast = Blast.new(params[:blast]) if @blast.blasted_type obj = @blast.blasted_type.camelize.constantize.new() obj.id = @...
Ruby
class CreateActsAsBlast < ActiveRecord::Migration def self.up create_table :blasts do |t| t.column :user_id, :integer t.column :blasted_id, :integer t.column :blasted_type, :string, :limit=> 20 t.column :partial, :string, :limit=> 20 t.column :to, :string, :limit=> 50 t....
Ruby
# ActsAsBlast module Setwave #:nodoc: module Acts #:nodoc: module Blast #:nodoc: def self.included(base) base.extend(ClassMethods) end module ClassMethods def acts_as_blast() attr_accessor :recipients, :failed_recipients, :blast include InstanceMetho...
Ruby
#*********************************************************************** # Adanna Bot: web_services_bot.rb # # This bot tests the web services via HTTP requests that are stored in # the database. # # Created by: Nathan Lane # Last Updated: 05/09/2007 #************************************************************...
Ruby
#*********************************************************************** # Adanna Bot: http_spider_basic.rb # # This spider undertakes the task of going through all http-based links # on the site in order to find broken links, images, 404 errors, etc. # # Created by: Nathan Lane # Last Updated: 05/15/2007 #****...
Ruby
#*********************************************************************** # Adanna Bot: testspider.rb # # This is an attempt to creat a spider script for Adanna that integrates # into itself, so that Adanna has complete control over the script. # # Created by: Nathan Lane # Last Updated: 05/14/2007 #************...
Ruby