code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
module AuthenticatedSystem
protected
# Returns true or false if the user is logged in.
# Preloads @current_user with the user model if they're logged in.
def logged_in?
!!current_user
end
# Accesses the current user from the session.
# Future calls avoid the database because nil is not... | Ruby |
class String
def no_html
str = self.dup
str.gsub!(/<\/?[^>]*>/, '')
str.strip!
str.gsub!(' ', '')
str
end
end
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
%(<span style="font-size:12px;color:red;">#{instance.error_message.kind_of?(Array) ? instance.error_message.first : instan... | Ruby |
require 'ostruct'
class CreditCalc
#Валюта кредиту
attr_accessor :currency
#Сумма кредиту СК
attr_accessor :summa
#Відсоткова ставка %
attr_accessor :interest_rate
#Строк кредитування, місяці t
attr_accessor :months
#Схема погашення
# - Стандарт
# - Ануїтет
attr_acc... | Ruby |
require 'ostruct'
class Settings
cattr_accessor :filepath, :config_, :contact_
@@filepath = "#{RAILS_ROOT}/config/settings.yml"
@@available_settings = YAML::load(File.open(@@filepath))
def self.[](name)
@@available_settings[name]
end
def self.config
@@config_ ||= OpenStruct.new(@@avail... | Ruby |
module AuthenticatedTestHelper
# Sets the current user in the session from the user fixtures.
def login_as(user)
@request.session[:user_id] = user ? users(user).id : nil
end
def authorize_as(user)
@request.env["HTTP_AUTHORIZATION"] = user ? ActionController::HttpAuthentication::Basic.encode_credentials... | Ruby |
namespace :db do
namespace :fixtures do
#desc 'Create YAML test fixtures from data in an existing database.
# Defaults to development database. Set RAILS_ENV to override.'
task :dump_all => :environment do
sql = "SELECT * FROM %s"
skip_tables = ["schema_info"]
ActiveRe... | Ruby |
namespace :data do
task :create_super_user => :environment do
puts "login: admin; pass: ghjtrn21"
User.delete_all("login = 'admin'")
user = User.new(
:login=>"admin",
:name=>"Administrator",
:password=>"ghjtrn21",
:password_confirmation=>"ghjtrn21",
:email=>"igor.com.ua@gmail.co... | Ruby |
#############################################################################
# Module: BulkInsertable
# Author: Peter Philips
#
# The idea is that in a high performing application you may want to
# insert lots and lots of rows. Doing this as individual inserts is
# a very slow process. If you group the inserts into... | Ruby |
Option().default_package='buildpy'
def package_buildpy():
Option().actual='build.py'
Option().binname='build.py'
def buildpy_build():
os.system('cd src; ./connect; mv build.py ../')
def buildpy_install():
init_install()
copy_bin()
process_install()
| Ruby |
require "test/unit"
require "bulletio"
class TestBulletio < Test::Unit::TestCase
def setup
@async_socket = AsyncSocket.new
end
def test_new_asyncsocket
assert AsyncSocket.new
end
end
| Ruby |
require 'mkmf-rice'
create_makefile('bulletio')
| Ruby |
require 'rubygems'
require 'hoe'
Hoe.spec 'bulletio' do
developer('Matt Holmes', 'teganthegnome@gmail.com')
self.readme_file = 'README.rdoc'
self.history_file = 'CHANGELOG.rdoc'
self.extra_rdoc_files = FileList['*.rdoc']
self.extra_dev_deps << [ 'rake-compiler', '>= 0' ]
self.spec_extras = { :exte... | Ruby |
require 'bulletio/bulletio'
class AsyncSocket
VERSION = '1.0.0'
end
| Ruby |
require 'rubygems'
SPEC = Gem::Specification.new() do |s|
s.name = "Bumbrella"
s.version = "0.0.0"
s.author = "Peter Schuller"
s.email = "peter.schuller@infidyne.com"
s.homepage = "http://bumbrella.code.google.com/"
s.platform = Gem::Platform::RUBY
s.summary = "Back... | Ruby |
require 'bumbrella/exceptions'
require 'bumbrella/util'
| Ruby |
module Bumbrella
# A backup. Represents a description of WHAT to backup, WHERE to
# place the backup, WHEN to perform backups and HOW to perform them.
#
# Note that the word 'backup' here refers to the abstract sense of a
# backup, rather than the actual data on disk at the backup
# destination.
#
# Thi... | Ruby |
module Bumbrella
# Common base class for all bumbrella defined errors.
class BumbrellaError < StandardError
end
# Raised to indicate that an operation failed due to an unexpected
# environmental condition. "Environmental" here refers to the
# operating system environment.
class EnvironmentError < Bumbrel... | Ruby |
require 'bumbrella/exceptions'
module Bumbrella
module Util
# Raised to indicate that the home directory of the current user
# could not be ascertained.
class NoUserHomeError < EnvironmentError
end
def Util.user_home()
homedir = ENV['HOME']
if not homedir then
raise NoUserHo... | Ruby |
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
require 'test/unit'
require 'bumbrella'
include Bumbrella
class UtilTester < Test::Unit::TestCase
def test_basic()
assert_not_nil(Util::user_home(), "user_home() should never return nil")
end
end
| Ruby |
require 'tc_util'
| Ruby |
#!/usr/local/bin/ruby
# Queries an LDAP server for all email addresses (tested against Exchange 5.5),
# and makes nice bugzilla user entries out of them. Also disables Bugzilla users
# that are not found in LDAP.
require 'ldap'
require 'dbi'
require 'getoptlong'
opts = GetoptLong.new(
['--dbname', '-d', G... | Ruby |
module Mongoboard
module Spec
module Testdata
def initialize
@releases = {}
end
def configureMongoDb
Mongoid.load!('../etc/mongoid.yml', :development)
end
def initEmptyDefaults
Mongoid.purge!
saveTemplatesFor 'sample-1'
saveTemplatesFor 'sample-2'
saveNewRelease 'sample-1... | Ruby |
require 'mongoboard/domain'
require 'mongoboard/webapp'
| Ruby |
require 'sz/hash_utils'
require 'rest-client'
require 'json'
require 'decorator'
require 'base64'
require 'nokogiri' # xml parser
module Webtest
module RestClientFascade
class RestClientResponseDecorator
include Decorator
def body_json(dropRootKey = true)
jsonHash = JSON.parse(@decorated.body)
... | Ruby |
module SZ
class Lockfile
attr_reader :fileName
def initialize(lockFileName)
@fileName = lockFileName
@lockDone = false
end
def lock
if File.exists?(@fileName)
raise "lockfile already exists, pid is " + dump
end
file = File.open(@fileName, "w")
file.write Process.pid ... | Ruby |
module SZ
class IncludeLocator
def includedFileName(string)
string =~ /\$\(include:(.+)\)/
return $1
end
def includeFile?(string)
if(string =~ /^\$\(include:(.+)/)
return true
else
... | Ruby |
require 'yaml'
require 'sz/include_locator'
module SZ
class VariableSubstitution
def initialize(configuration)
@configuration = configuration
end
def evaluate(resultWithVariables)
result = resultWithVariables
if resultWith... | Ruby |
require 'ostruct'
module SZ
class HashDecorator
def initialize(hash, dropRootKey = false)
@hash = transformHash(hash, dropRootKey)
end
def method_missing(name)
result = nil
if @hash.key? name
result = @hash[name]
else
@hash.each do |k,v|
if k.to_s.to_sym == name
... | Ruby |
require 'wtac'
require 'singleton'
module SZ
class TranslatorFactory
def self.build(prefix)
config = WTAC.instance.config
return Translator.new(prefix, config)
end
end
class Translator
def initialize(prefix, messageSource)
@prefix = prefix.to_s
@messageSource = messageSource
end
def... | Ruby |
require 'erb'
require 'singleton'
module SZ
class BindingContainer
def initialize(data)
@data = data
end
def exposeBinding
binding
end
end
class YamlToTemplateRenderService
include Singleton
def renderAsFile(bindingData, templateFile, destinationFile)
templateAsString = File.read(templat... | Ruby |
require 'singleton'
module SZ
class IssueDefinition
attr_accessor :name
#
# :bug, :enhancement, ...
#
attr_accessor :type
def initialize
@type = :unknown
@name = 'unknown'
@detected = nil
end
def detected?
return @detected == nil ? false : @detected
end
... | Ruby |
require 'singleton'
module SZ
class NumericPrefixGenerateService
include Singleton
#
# prepend before nextFile result
#
attr_writer :directoryPrefix
attr_reader :lastString
def initialize
@counter = 0
@directoryPrefix = ''
@lastString = ''
end
def nextString(suffix = nil)
... | Ruby |
module Decorator
def initialize(decorated)
@decorated = decorated
end
def method_missing(method, *args, &block)
args.empty? ? @decorated.send(method) : @decorated.send(method, *args, &block)
end
end | Ruby |
require 'moped'
require 'sinatra/base'
require 'sinatra/respond_with'
require 'sinatra/contrib'
require 'sinatra/json'
module Mongoboard
class Webapp < Sinatra::Base
configure :production, :development do
enable :logging
end
set :static, true
set :public_dir, File.dirname(__FILE__) + '/static'
get '/... | Ruby |
require 'mongoid'
require 'singleton'
module Mongoboard
module Errors
class WrongResultCount < StandardError
def initialize(actualCount)
@actualCount = actualCount
end
def message
message = super
r = "got " + @actualCount.to_s + " results"
r = r + ", " + message unless message.nil?
r... | Ruby |
class CreateOsas < ActiveRecord::Migration
def self.up
create_table :osas do |t|
t.integer :account_id
t.string :coordinator
t.boolean :isopen, :default => false
t.timestamps
end
end
def self.down
drop_table :osas
end
end
| Ruby |
class CreateAnnouncements < ActiveRecord::Migration
def self.up
create_table :announcements do |t|
t.integer :osa_id
t.text :message
t.timestamps
end
end
def self.down
drop_table :announcements
end
end
| Ruby |
class CreateMembers < ActiveRecord::Migration
def self.up
create_table :members do |t|
t.integer :student_id
t.integer :organization_id
t.string :position
t.integer :semester
t.integer :year
t.boolean :confirm
t.string :confirmation_key
t.boolean :sentcnfrm #flag fo... | Ruby |
class CreateEventReports < ActiveRecord::Migration
def self.up
create_table :event_reports do |t|
t.integer :organization_id
t.string :name
t.string :category
t.string :description
t.date :date
t.string :venue
t.string :head
t.string :file_path1, :file_path2, :file_... | Ruby |
class CreateOrganizations < ActiveRecord::Migration
def self.up
create_table :organizations do |t|
t.integer :account_id
t.string :name, :acronym, :nature, :category, :status, :approved_by, :default => ""
t.string :mailing_address, :email_org, :email_head, :default => ""
t.date :date_estab... | Ruby |
class CreateAwards < ActiveRecord::Migration
def self.up
create_table :awards do |t|
t.integer :organization_id
t.string :name
t.string :file_path
t.string :classification
t.string :description
t.string :award_giving_body
t.timestamps
end
end
def self.down
d... | Ruby |
class CreateEvents < ActiveRecord::Migration
def self.up
create_table :events do |t|
t.integer :organization_id
t.string :name
t.string :category
t.string :description
t.date :date
t.string :venue
t.string :head
t.timestamps
end
end
def self.down
drop_... | Ruby |
class CreateAccounts < ActiveRecord::Migration
def self.up
create_table :accounts do |t|
t.string :username, :password, :group
t.timestamps
end
end
def self.down
drop_table :accounts
end
end
| Ruby |
class CreateStudents < ActiveRecord::Migration
def self.up
create_table :students do |t|
t.integer :student_no
t.integer :year_level
t.string :name #full name
t.string :nickname
t.string :degree_program #BS BA MS MA PHD PGA
t.string :course
t.string :college
t.strin... | 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 |
#!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
#
# 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 |
#!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 imp... | Ruby |
#!C:/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 |
#!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 imp... | 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'
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
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/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'
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
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 |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
end
| Ruby |
module OrganizationsHelper
end
| Ruby |
module AccountsHelper
end
| Ruby |
module EventsHelper
end
| Ruby |
module OsasHelper
end
| Ruby |
module StudentsHelper
end
| Ruby |
module AnnouncementsHelper
end
| Ruby |
module MembersHelper
end
| Ruby |
module AwardsHelper
end
| Ruby |
module NotifierHelper
end
| Ruby |
module EventReportsHelper
end
| Ruby |
module MainHelper
end
| Ruby |
class Account < ActiveRecord::Base
validates_presence_of :username, :password
validates_uniqueness_of :username
validates_length_of :password, :minimum => 5, :too_short => 'must be at least 5 characters long'
end
| Ruby |
class Osa < ActiveRecord::Base
belongs_to :account
has_many :announcements
end
| Ruby |
class EventReport < ActiveRecord::Base
belongs_to :organization
end
| Ruby |
class Student < ActiveRecord::Base
has_many :members
#set_primary_key "student_id"
#validates_uniqueness_of :student_no
end
| Ruby |
class Event < ActiveRecord::Base
belongs_to :organization
validates_presence_of :name, :message => "of activity can't be blank"
end
| Ruby |
class Notifier < ActionMailer::Base
def welcome_email(email,subj,password,username)
recipients email
from "Office of Student Activities <up.bukluran@gmail.com>"
subject subj
sent_on Time.now
body :password => password, :username => username
end
def confirm_member(member, org)
... | Ruby |
class DataFile < ActiveRecord::Base
def self.open(filename, directory_path)
f = File.open(directory_path+filename, 'r')
return f
end
def self.save(upload, directory_path)
name = upload['datafile'].original_filename
directory = directory_path
path = File.join(directory, name)
... | Ruby |
class Member < ActiveRecord::Base
belongs_to :student #, :foreign_key => "student_no"
belongs_to :organization
end
| Ruby |
class Organization < ActiveRecord::Base
belongs_to :account
has_many :events
has_many :event_reports
has_many :awards
has_many :members
validates_presence_of :name
end
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.