code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
#!/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
def expiration_month
result = "<option>--</option>"
1.upto(12) do |month|
result << "<option>#{month}</option>"
end
result
end
def expiration_year
result = "<option>----</opt... | Ruby |
module CustomersHelper
end
| Ruby |
module SilentPostBacksHelper
end
| Ruby |
class AccountService
def initialize(map)
@map = map
end
def create
external_subscription_id = -1
begin
response = zgateway.recurring(charge_amount, credit_card, recurring_options)
if response.success?
external_subscription_id = response.authorization
else... | Ruby |
class OneClickService
def initialize(map)
@map = map
@profile = {
:payment_profiles => {
:bill_to => customer_billing_address,
:payment => customer_payment_options
},
:ship_to_list => customer_shipping_options
}
end
def create
external_cim_id = -1... | Ruby |
class Customer < ActiveRecord::Base
# TODO: Validations must be added here...
end
| Ruby |
class GatewayResponse < ActiveRecord::Base
end
| Ruby |
class SilentPostBacksController < ApplicationController
# http://www.mydomain.com/silent_post_back
def create
# Don't process postbacks that aren't for arb subscriptions
return render(:text => 'hi') if params[:x_subscription_id].nil?
case params[:x_response_code].to_i
when ActiveMerchant::Bil... | 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
helper :all # include all helpers, all the time
# See ActionController::RequestForgeryProtection for details... | Ruby |
class CustomersController < ApplicationController
# GET /customers/new
def new
@customer = Customer.new
end
# TODO: Validations must be added here for non AR objects
def create
account = AccountService.new(account_map)
external_subscription_id = account.create
one_click = OneClickServi... | 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 |
API_LOGIN_ID=""
TRANSACTION_KEY="" | Ruby |
ActionController::Routing::Routes.draw do |map|
map.resources :customers
map.resource :silent_post_back
end
| 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 |
RAILS_GEM_VERSION = '2.0.2' unless defined? RAILS_GEM_VERSION
require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
config.action_controller.session = {
:session_key => '_oac_session',
:secret => 'f04af54011d46e672a0e6505a87bc358662e54f790ce968ea82a67cc6c519497f39362f45... | 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 |
# 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 |
class ZephoLogFormatter
def call(severity, time, program_name, message)
datetime = time.strftime("%b %d %H:%M:%S")
process = "#{program_name} PID - #{$PID}"
hostname = Socket.gethostname.split('.')[0]
message = (String === message ? message : message.inspect).gsub(/\n/, '').strip
"#{datetime... | 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 |
#! /usr/bin/ruby
#author newdongyuwei@gmail.com
if GC.respond_to?(:copy_on_write_friendly=)
GC.copy_on_write_friendly = true
end
$KCODE = 'UTF-8'#解决中文乱码问题
%w(rubygems sinatra sinatra/base net/http net/https json erubis eventmachine em-websocket).each{|lib|require lib}
require 'ruby-growl'if RUBY_PLATFORM.downcas... | Ruby |
$:.unshift '.'
ENV['RACK_ENV'] = "production"
require 'rubygems'
require 'fetion_robot'
run Sinatra::Application
| Ruby |
#! /usr/bin/ruby
#author newdongyuwei@gmail.com
require 'rubygems'
require "sinatra"
require 'oauth'
require 'oauth/consumer'
require 'yaml'
require 'logger'
class SinaWeiboClient
def initialize()
@loger = Logger.new(STDOUT)
@loger.level = Logger::DEBUG
auth = YAML.load(File... | Ruby |
#! /usr/bin/ruby
#author newdongyuwei@gmail.com
if GC.respond_to?(:copy_on_write_friendly=)
GC.copy_on_write_friendly = true
end
$KCODE = 'UTF-8'#解决中文乱码问题
%w(rubygems fileutils sinatra sinatra/base net/http net/https json).each{|lib|require lib}
require 'ruby-growl'if RUBY_PLATFORM.downcase.include?("darwin")
class... | 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 |
#!/usr/bin/env ruby
bin = ARGV[0]
src = "#{bin}.cpp"
File.delete(bin)
system("g++ #{src} -o #{bin} -g")
while !File.exist?(bin)
sleep(1)
end
system("gdb #{bin}")
| Ruby |
#require 'ruby-debug'
def file_names(test_file)
if !(test_file =~ /\A(.+)_test/) #why /\A(.+)_test\Z/ doesn't work?
raise "Invalid file name!"
end
return [
$1, #bin_file
"#{$1}.cpp", #source_file
"#{$1}_input", #input_file
"#{$1}_output", #output_file
"#{$1}_output_r" #result_file
]
en... | Ruby |
#!/usr/bin/env ruby
test_file = "#{ARGV[0]}_test.rb"
test_file_fullpath = File.expand_path(test_file)
if File.exist?(test_file_fullpath)
system(test_file_fullpath)
else
require_relative 'test_helper'
test(test_file_fullpath)
end
| Ruby |
class Elements
attr_accessor :mass, :pos, :vel,
:axis, :eccentricity, :parameter, :square_constant, :inclination,
:true_anomaly, :argument_of_periapsis, :g,
:eccentric_anomaly, :mean_anomaly, :longitude_node,
:ecliptic_longitude, :ecliptic_latitude, :... | Ruby |
require 'integrators/ephemeris.rb'
require "integrators/nbody.rb"
require "integrators/vector.rb"
def integrate
@start_time = CONFIG['integration']['start_time']
@stop_time = CONFIG['integration']['stop_time']
@step = CONFIG['integration']['step'].to_f
@method = CONFIG['integration']['integrator... | Ruby |
#file1 = File.new("output/ms8_step0-1_100.dat", "r")
#file2 = File.new("output/yo8_step0-1_100.dat", "r")
#file1 = File.new("output/step-1.0/ms8.dat", "r")
#file2 = File.new("output/step-1.0/yo8.dat", "r")
#file1 = File.new("output/step-0.1/ms8.dat", "r")
#file2 = File.new("output/step-0.1/yo8.dat", "r")
file1 = Fil... | Ruby |
$min = 10;
class Body
attr_accessor :mass, :pos, :vel, :time
def initialize(mass = 0, pos = Vector[0,0,0], vel = Vector[0,0,0])
@mass, @pos, @vel = mass, pos, vel
end
def set_time(time)
@time = time
end
def calc(body_array, time_step, s)
ba = body_array
dt = time_step
eval(s)
... | Ruby |
require 'elements.rb'
class Body
attr_accessor :mass, :pos, :vel, :time, :elements
def initialize(mass = 0, pos = Vector[0,0,0], vel = Vector[0,0,0])
@mass, @pos, @vel = mass, pos, vel
@time = 0
@elements = Elements.new
end
def evolve(integration_method, dt, dt_start, dt_end)
@nsteps = 0
... | Ruby |
require 'yaml'
include Math
CONFIG = YAML.load_file('config/config.yml')
class Ephemeris
attr_accessor :eph_path, :datas_path, :eph_file
def initialize
@eph_path = CONFIG['ephemeris']['execute_path']
@datas_path = CONFIG['ephemeris']['datas_path']
@eph_file = CONFIG['ephemeris']['file']
en... | Ruby |
start = Time.now
require 'ephemeris/ephemeris.rb'
require 'elements.rb'
require "integrators/body.rb"
require "integrators/vector.rb"
# creating initial conditions
b = Body.new
b.simple_read
if (CONFIG['debug'])
b.pp
end
start_time = CONFIG['integration']['start_time']
stop_time = CONFIG['integration']['stop_time... | Ruby |
# Set this to the root of your project when deployed:
css_dir = "css"
sass_dir = "sass"
images_dir = "images"
# ルートパス
http_generated_images_path = "/shared/images"
javascripts_dir = "js"
# You can select your preferred output style here (can be overridden via the command line):
# output_style = :compressed
# chrome d... | Ruby |
require 'rubygems'
require 'sinatra'
require 'json'
require 'sqlite3'
require 'logger'
configure do
LOGGER = Logger.new('sinatra.log')
DB = SQLite3::Database.new("sankofa.db")
DB.results_as_hash = true
end
get '/' do
content_type :json
response['Access-Control-Allow-Origin'] = 'http://loca... | 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 |
# 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 |
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 |
# $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 |
# 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 |
# encoding: utf-8
# --------------------------------------------------------------------------------------------------
# Please note: If you're subclassing Formtastic::SemanticFormBuilder in a Rails 3 project,
# Formtastic uses class_attribute for these configuration attributes instead of the deprecated
# class_inhe... | 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 |
# Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attac... | Ruby |
# Be sure to restart your server when you modify this file.
MyRental::Application.config.session_store :cookie_store, :key => '_MyRental_session'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "ra... | Ruby |
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a probl... | Ruby |
require 'custom_logger'
MyRental::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disable... | Ruby |
require 'custom_logger'
MyRental::Application.configure do
# Settings specified here will take precedence over those in config/application.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... | Ruby |
MyRental::Application.configure do
# Settings specified here will take precedence over those in config/application.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... | Ruby |
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
MyRental::Application.initialize!
| Ruby |
require 'rubygems'
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
| Ruby |
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) if defined?(Bundler)
module MyRental
class Application < Rails::Application
... | Ruby |
MyRental::Application.routes.draw do
resources :agreements
resources :entries
resources :audits
resources :models
resources :branches
resources :authentications
resources :permissions
resources :groups
resources :occupations
resources :provinces
resources :marr_statuses
resources :nationali... | Ruby |
module ApplicationHelper
end
| Ruby |
module PermissionsHelper
end
| Ruby |
module CardsHelper
end
| Ruby |
module ReportHelper
end
| Ruby |
module UsersHelper
end
| Ruby |
module EntriesHelper
end
| Ruby |
module ProvincesHelper
end
| Ruby |
module MainHelper
end
| Ruby |
module UserSessionsHelper
end
| Ruby |
module ModelsHelper
end
| Ruby |
module AgreementsHelper
end
| Ruby |
module AuditsHelper
end
| Ruby |
module CustomersHelper
end
| Ruby |
module AuthenticationsHelper
end
| Ruby |
module SettingHelper
end
| Ruby |
module AdministratorHelper
end
| Ruby |
module HelpHelper
end
| Ruby |
module BranchesHelper
end
| Ruby |
module OccupationsHelper
end
| Ruby |
module TitlesHelper
end
| Ruby |
module NationalitiesHelper
end
| Ruby |
module GroupsHelper
end
| Ruby |
class Authentication < ActiveRecord::Base
belongs_to :group
belongs_to :permission
attr_accessor :user_log
def to_audit
return "ID:#{id}"+","+"Group:#{group.name}"+","+"Description:#{permission.name}"
end
end
| Ruby |
class Permission < ActiveRecord::Base
has_many :authentication
has_many :groups , :through => :authentication
belongs_to :model
attr_accessor :user_log
def to_audit
return "ID:#{id}"+","+"Name:#{name}"+","+"Description:#{description}"
end
end
| Ruby |
class Agreement < ActiveRecord::Base
after_create :generate_agreement_no
belongs_to :customer
belongs_to :user
validates_presence_of :customer_id
attr_accessor :user_log
def to_audit
return "ID:#{id}"+","+"Agreement NO.:#{agreement_no}"+","+"Customer Code:#{customer.code}"
end
private... | Ruby |
class Branch < ActiveRecord::Base
has_many :user
has_many :customer
validates_presence_of :code , :name
validates_numericality_of :code , :integer_only=>true
validates_length_of :code ,:is => 3
validates_uniqueness_of :code
attr_accessor :user_log
def to_audit
return "ID:#{id}"+","+":Code#{code}"+... | Ruby |
class Title < ActiveRecord::Base
has_many :customer
cattr_reader :per_page
validates_presence_of :name
validates_uniqueness_of :name
attr_accessor :user_log
def to_audit
return "ID:#{id}"+","+"Name:#{name}"
end
end
| Ruby |
class AuditObserver < ActiveRecord::Observer
observe :group,:branch,:model,:permission,:authentication,:customer,:title,:card,:nationality,:province,:occupation,:agreement
def after_create(record)
audit = Audit.new
audit.model=record.class.to_s
audit.action = 'Create'
audit.after = record.to_audi... | Ruby |
class Administrator
end
| Ruby |
class Audit < ActiveRecord::Base
end
| Ruby |
class User < ActiveRecord::Base
belongs_to :group
belongs_to :branch
has_many :agreements
validates_presence_of :group_id , :branch_id
acts_as_authentic do |c|
c.logged_in_timeout = 60.minutes
end
attr_accessor :user_log
def to_audit
return login
end
end
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.