code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
# 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
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 |
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
end
| Ruby |
module VoiceCallsHelper
end
| Ruby |
class VoiceCall < ActiveRecord::Base
def self.recent
@recent_calls = VoiceCall.find(:all)
end
end
| Ruby |
class VoiceCallsController < 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 }
... | 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 => '_dataservic... | 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/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 AddVoiceCalls < ActiveRecord::Migration
def self.up
create_table :voice_calls do |t|
t.column :source_country, :string
t.column :destination_country, :string
end
end
def self.down
drop_table :voice_calls
end
end
| Ruby |
class AddDateColumn < ActiveRecord::Migration
def self.up
add_column :voice_calls, :call_time, :timestamp
end
def self.down
remove_column :voice_calls, :call_time
end
end
| Ruby |
#!E:/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 |
#!E:/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 |
#!E:/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 |
#!E:/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 |
#!E:/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 |
#!E:/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 |
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/bin/env ruby
require 'test/unit'
module DependencyInjection
IGNORED_SETTERS = ['==', '===']
# inject dependencies by matching getters on container with setters
# on object to recieve injection
def autowire_dependencies(instance)
container = self
instance.methods.each { |setter|
if sett... | Ruby |
require 'rubygems'
require 'postgres'
require 'erb'
class DatabaseSchemaProvider
def initialize(connection_string)
@conn_str = connection_string
end
def get_table_columns()
resultset = execute_sql(get_column_metadata_sql)
get_columns_from_dataset(resultset)
end
p... | Ruby |
#!/usr/bin/env ruby
require 'mysql'
require 'date'
class CustomerFinder
def initialize(connection)
@connection = connection;
end
def find(date)
sql = "select name, email, number, keyword, provision_date, expiration_date from customers
where expiration_date < '#{date}' and enab... | Ruby |
#!/usr/bin/env ruby
class String
def starts_with? aString
rindex(aString, 0) == 0
end
def ends_with? aString
index(aString) == self.length - aString.length
end
end
str = "Just another string"
puts str.starts_with?("Ju") # should be true
puts str.starts_with?("str") # should be false
puts str.ends_... | Ruby |
#!/usr/bin/env ruby
# line_num.rb
def get_lines(file_name)
return File.open(file_name, 'r').readlines
end
def get_format(lines)
return "%0#{lines.size.to_s.size}d"
end
def get_output(lines)
format = get_format(lines)
output = ''
lines.each_with_index do |line, i|
output += "#{sprintf(form... | Ruby |
require 'rake'
require 'rake/gempackagetask'
require 'fileutils'
include FileUtils
spec = Gem::Specification.new do |s|
s.name = "binarysignal-logger"
s.version = "1.1"
s.author = "Nauman Leghari"
s.email = "laghari78@yahoo.com"
s.homepage = "http://www.binarysignals.com"
s.platform = Gem::Platform::RUBY
s.summ... | Ruby |
#!/usr/bin/env ruby
module BinarySignals
class BSLogger
def initialize(name)
@name = name
end
def customlog(message)
print 'hello world'
end
end
end
| Ruby |
#!/usr/bin/env ruby
module BinarySignals
class BSLogger
def initialize(name)
@name = name
end
def customlog(message)
print 'hello world'
end
end
end
| Ruby |
#!/usr/bin/env ruby
str = "35 C"
temp, scale = str.split(" ")
if temp !~ /-?[0-9]+/
print temp, " is not valid.\n"
exit 1
end
temp = temp.to_f
case scale
when "C", "c"
f = 1.8*temp + 32
when "F", "f"
c = (5.0/9.0)*(temp-32)
else
print "Must specify C or F.\n"
... | Ruby |
#!/usr/bin/env ruby
require 'socket'
class SimpleIrcBot
def initialize(server, port, channel)
@channel = channel
@socket = TCPSocket.open(server, port)
say "NICK Domian1978"
say "USER Domian1978 0 * Domian1978"
say "JOIN ##{@channel}"
puts "#{1.chr}"
say_to_chan "#{1.chr}ACTION is here ... | Ruby |
#!/usr/bin/env ruby
require 'socket'
class SimpleIrcBot
def initialize(server, port, channel)
@channel = channel
@socket = TCPSocket.open(server, port)
say "NICK Domian1978"
say "USER Domian1978 0 * Domian1978"
say "JOIN ##{@channel}"
puts "#{1.chr}"
say_to_chan "#{1.chr}ACTION is here ... | Ruby |
#!/usr/bin/ruby
# TODO:
# 1. call event handler to save the data into the database
# 1.(option 2) create a pipeline of processes
require 'pp'
require 'yaml'
def skip_line(filters, line)
skip = false
filters.each do |f|
if line =~ /#{f}/
skip = true
bre... | Ruby |
#!/usr/bin/ruby
# TODO:
# 1. call event handler to save the data into the database
# 1.(option 2) create a pipeline of processes
require 'pp'
require 'yaml'
def skip_line(filters, line)
skip = false
filters.each do |f|
if line =~ /#{f}/
skip = true
bre... | Ruby |
#!/usr/bin/env ruby
class Customer < Struct.new(:name, :company)
end
c = Customer.new("John Doe", "MSFT")
puts %Q(#{c.name} - #{c.company})
house_data = Struct.new("Data", :houseno, :city, :country)
dt = house_data.new(32, "London", "UK")
print dt.inspect
| Ruby |
#!/usr/bin/env ruby
require 'dbi'
require 'database'
Database.instance.connect('DBI:Mysql:smsclient', 'ag3nt', 'password')
email = 'abc@hotmail.com'
sql = "select name, email, number, keyword, provision_date, expiration_date from customers where email = '#{email}' and enabled=true"
Database.instance.connection.selec... | Ruby |
# $ext_path: This should be the path of where the ExtJS SDK is installed
# Generally this will be in a lib/extjs folder in your applications root
# <root>/lib/extjs
$ext_path = "../../"
# sass_path: the directory your Sass files are in. THIS file should also be in the Sass folder
# Generally this will be in a resource... | Ruby |
# include the utils rb file which has extra functionality for the ext theme
dir = File.dirname(__FILE__)
require File.join(dir, 'lib', 'utils.rb')
# register ext4 as a compass framework
Compass::Frameworks.register 'ext4', dir | Ruby |
# $ext_path: This should be the path of where the ExtJS SDK is installed
# Generally this will be in a lib/extjs folder in your applications root
# <root>/lib/extjs
$ext_path = "../../lib/extjs"
# sass_path: the directory your Sass files are in. THIS file should also be in the Sass folder
# Generally this will be in a... | Ruby |
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 |
require 'acts_as_attention_destiny_lib'
require 'acts_as_attention_source_lib'
ActiveRecord::Base.class_eval do
include Bitnik::Acts::AttentionDestinyLib
include Bitnik::Acts::AttentionSourceLib
end
| Ruby |
class BitnikApmFooConsumer < ActiveRecord::Base
acts_as_attention_source
end
| Ruby |
class BitnikApmFooObject < ActiveRecord::Base
acts_as_attention_destiny :key_mapping => 'key'
end
| Ruby |
class BitnikApmGenerator < Rails::Generator::NamedBase
def manifest
#Generate some names for classes, etc. This will inflect on
#the third parameter given to script/generate if given, or use
#an array of predefined names.
#camel_name, under_name, plural_name = args[0] ? inflect_names(args[0]) : ['M... | Ruby |
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the bitnik_apm plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate documentation for the bitnik_apm plugin.'... | Ruby |
# desc "Explaining what the task does"
# task :bitnik_apm do
# # Task goes here
# end
| Ruby |
# Uninstall hook code here
| Ruby |
# Install hook code here
| Ruby |
# BitnikApm
| Ruby |
class AttentionReferencePoint < ActiveRecord::Base
belongs_to :attention_destiny_reference
belongs_to :attention_profile
end
| Ruby |
class AttentionProfile < ActiveRecord::Base
has_many :attention_points
has_many :attention_reference_points
belongs_to :attention_source, :polymorphic => true
end
| Ruby |
class AttentionPoint < ActiveRecord::Base
belongs_to :attention_destiny
belongs_to :attention_profile
end
| Ruby |
require 'active_record'
module Bitnik
module Acts
module AttentionDestinyLib
def self.included(mod)
mod.extend(ClassMethods)
end
module ClassMethods
mattr_accessor :bitnik_apm_key_mapping
mattr_accessor :bitnik_apm_from_value
#Defines this model to be an atten... | Ruby |
class AttentionReferenceAuthor
attr_accessor :key
attr_accessor :value
attr_accessor :from
attr_accessor :updated_at
attr_accessor :attention_destiny_reference
end
class AttentionDestinyReference < ActiveRecord::Base
belongs_to :attention_profile
def author
author = AttentionReferenceAuthor.new
... | Ruby |
class AttentionDestiny < ActiveRecord::Base
belongs_to :attention_generator, :polymorphic => true
end
| Ruby |
require 'active_record'
require 'apm_builder'
module Bitnik
module Acts
module AttentionSourceLib
def self.included(mod)
mod.extend(ClassMethods)
end
module ClassMethods
mattr_accessor :bitnik_apm_key_mapping
mattr_accessor :bitnik_apm_from_value
#Defines this... | Ruby |
module Bitnik
module Apm
#Class that implements an algorithm to build an APML file from an AttentionSource object.
class Builder
attr_reader :version
attr_accessor :title
attr_accessor :generator
attr_accessor :user_email
attr_accessor :default_profile
attr_accessor :from
... | Ruby |
require 'rexml/streamlistener'
require 'rexml/document'
module AutomataParser
class ParserNode
attr_accessor :parent
attr_accessor :son
attr_accessor :name
attr_accessor :values
attr_accessor :text
def initialize
@values = Hash.new
end
def link node
@son = node
no... | Ruby |
module AutomataParser
class Stack
def initialize
@data = Array.new
end
def push elem
@data.push elem
end
def pop
@data.delete(@data.last)
end
def top
@data.last
end
def empty?
@data.empty?
end
end
end
| Ruby |
module AutomataParser
module Constants
ANYTHING = '_AutomataParser_*_'
end
class GraphVertexWrapper
include AutomataParser::Constants
attr_accessor :name
def initialize(name,arcs)
@arcs = arcs
end
def with(label)
@arcs.each do |arc|
if(arc[label]!=nil)
r... | Ruby |
require 'automata_parser/stack'
require 'automata_parser/graph'
require 'automata_parser/parser'
module Bitnik
module Apm
include AutomataParser
#Author APML proxy class.
class Author
attr_accessor :key
attr_accessor :from
attr_accessor :updated
end
#Concept APML proxy class.... | Ruby |
$:.unshift(File.dirname(__FILE__) + '/../lib')
require 'test/unit'
RAILS_ENV= "test"
require File.expand_path(File.join(File.dirname(__FILE__),'../../../../config/environment.rb'))
=begin
ActiveRecord::Base.class_eval do
alias_method :save, :valid?
def self.columns() @columns ||= []; end
def self.column(name,... | Ruby |
#!/usr/bin/ruby
# class Tukang Ucap
class Mengucap
def initialize(nama)
@nama = nama.capitalize
end
def ucapkan
puts "Hello #{@nama}!"
end
end
# Create a new object
g = Mengucap.new("world")
# Output "Hello World!"
g.ucapkan
| Ruby |
#!/usr/bin/ruby
# class Tukang Ucap
class Mengucap
def initialize(nama)
@nama = nama.capitalize
end
def ucapkan
puts "Hello #{@nama}!"
end
end
# Create a new object
g = Mengucap.new("world")
# Output "Hello World!"
g.ucapkan
| Ruby |
#!/usr/bin/env ruby
=begin
helloworld.rb - Ruby/GTK first sample script.
Copyright (c) 2002,2003 Ruby-GNOME2 Project Team
This program is licenced under the same licence as Ruby-GNOME2.
$Id: helloworld.rb,v 1.4 2003/02/01 16:46:22 mutoh Exp $
=end
require 'gtk2'
button = Gtk::Button.new("Hello World")
butto... | Ruby |
#!/usr/bin/env ruby
=begin
helloworld.rb - Ruby/GTK first sample script.
Copyright (c) 2002,2003 Ruby-GNOME2 Project Team
This program is licenced under the same licence as Ruby-GNOME2.
$Id: helloworld.rb,v 1.4 2003/02/01 16:46:22 mutoh Exp $
=end
require 'gtk2'
button = Gtk::Button.new("Hello World")
butto... | Ruby |
#!/usr/bin/ruby
# class Tukang Ucap
class Mengucap
def initialize(nama)
@nama = nama.capitalize
end
def ucapkan
puts "Hello #{@nama}!"
end
end
# Create a new object
g = Mengucap.new("world")
# Output "Hello World!"
g.ucapkan
| Ruby |
#!/usr/bin/ruby
# class Tukang Ucap
class Mengucap
def initialize(nama)
@nama = nama.capitalize
end
def ucapkan
puts "Hello #{@nama}!"
end
end
# Create a new object
g = Mengucap.new("world")
# Output "Hello World!"
g.ucapkan
| Ruby |
#!/usr/bin/env ruby
=begin
helloworld.rb - Ruby/GTK first sample script.
Copyright (c) 2002,2003 Ruby-GNOME2 Project Team
This program is licenced under the same licence as Ruby-GNOME2.
$Id: helloworld.rb,v 1.4 2003/02/01 16:46:22 mutoh Exp $
=end
require 'gtk2'
button = Gtk::Button.new("Hello World")
butto... | Ruby |
#!/usr/bin/env ruby
=begin
helloworld.rb - Ruby/GTK first sample script.
Copyright (c) 2002,2003 Ruby-GNOME2 Project Team
This program is licenced under the same licence as Ruby-GNOME2.
$Id: helloworld.rb,v 1.4 2003/02/01 16:46:22 mutoh Exp $
=end
require 'gtk2'
button = Gtk::Button.new("Hello World")
butto... | Ruby |
#!/usr/bin/ruby
# class Tukang Ucap
class Mengucap
def initialize(nama)
@nama = nama.capitalize
end
def ucapkan
puts "Hello #{@nama}!"
end
end
# Create a new object
g = Mengucap.new("world")
# Output "Hello World!"
g.ucapkan
| Ruby |
#!/usr/bin/ruby
# class Tukang Ucap
class Mengucap
def initialize(nama)
@nama = nama.capitalize
end
def ucapkan
puts "Hello #{@nama}!"
end
end
# Create a new object
g = Mengucap.new("world")
# Output "Hello World!"
g.ucapkan
| Ruby |
#!/usr/bin/env ruby
=begin
helloworld.rb - Ruby/GTK first sample script.
Copyright (c) 2002,2003 Ruby-GNOME2 Project Team
This program is licenced under the same licence as Ruby-GNOME2.
$Id: helloworld.rb,v 1.4 2003/02/01 16:46:22 mutoh Exp $
=end
require 'gtk2'
button = Gtk::Button.new("Hello World")
butto... | Ruby |
#!/usr/bin/env ruby
=begin
helloworld.rb - Ruby/GTK first sample script.
Copyright (c) 2002,2003 Ruby-GNOME2 Project Team
This program is licenced under the same licence as Ruby-GNOME2.
$Id: helloworld.rb,v 1.4 2003/02/01 16:46:22 mutoh Exp $
=end
require 'gtk2'
button = Gtk::Button.new("Hello World")
butto... | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.