code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
#!/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'
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin'
| Ruby |
#!/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/dispatcher" -- otherwise performance is severely impaired
re... | Ruby |
#!/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/dispatcher" -- otherwise performance is severely impaired
re... | Ruby |
#!/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 FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
# an... | Ruby |
#!/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/dispatcher" -- otherwise performance is severely impaired
re... | Ruby |
#!/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/dispatcher" -- otherwise performance is severely impaired
re... | Ruby |
#!/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 FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
# an... | 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 |
#author: arch.jslin (archilifelin@yahoo.com.tw) in June 2008
#This program is licensed under GNU GPL, for details please goto http://gnu.org
# This is a helper program, intend to provide htmls converted by bbs2html.rb
# a pre-generated style sheet, so that the space usage by <font> tags is reduced,
# and the time proc... | Ruby |
class LogReader
def initialize(f)
puts "new LogReader #{f}"
@file = File.new(f)
count = 0
@iplist = []
@scanlist = []
while (!@file.eof and count < 1000) do
count+=1
line = @file.gets
scan = execLine line
puts "#{count}\t#{scan.length}\n #{line}" if scan.length != 1
s = scan.length>0 ? s... | Ruby |
require "pingpong"
class GameManage
def initialize
@player_list = []
end
def join(p)
@player_list << p
end
def match_player
idleplayers = @player_list.select{|p| p.idle?}
if idleplayers.length >= 2 then
game = create_game
ma... | Ruby |
require "thread"
class Interval
def initialize(interval, limit = 0)
@interval = interval.to_f
@limit = limit.to_i
@thread = nil
end
def run(&block)
#puts "running #{@running} interval: #{@interval}"
stop
argv = {
:interval => @interval,
:limit => @limit,
:block => block
... | Ruby |
class Bar
attr_reader :top
def initialize
@top = 0
end
def top=(newtop)
@top = newtop.to_i
end
end | Ruby |
# Copyright: Hiroshi Ichikawa <http://gimite.net/en/>
# Lincense: New BSD Lincense
# Reference: http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol
require "socket"
require "uri"
require "digest/md5"
require "openssl"
class WebSocket
class << self
attr_accessor(:debug)
end
class Error... | Ruby |
$LOAD_PATH << "d:/ruby/mylib"
$LOAD_PATH << "."
require "web_socket"
require "thread"
require "gamemanage"
require "player"
Thread.abort_on_exception = true
server = WebSocketServer.new(
:accepted_domains => ["*"],
:port => 12010,
:host => "0.0.0.0")
puts("Server is running at port %d" % server... | Ruby |
# Copyright: Hiroshi Ichikawa <http://gimite.net/en/>
# Lincense: New BSD Lincense
$LOAD_PATH << File.dirname(__FILE__) + "/../lib"
require "web_socket"
require "thread"
Thread.abort_on_exception = true
if ARGV.size != 2
$stderr.puts("Usage: ruby sample/chat_server.rb ACCEPTED_DOMAIN PORT")
exit(1)
end
server =... | Ruby |
# Server serve the game
$LOAD_PATH << "D:/ruby/mylib"
require "web_socket"
require "thread"
Thread.abort_on_exception = true
if ARGV.size != 2
$stderr.puts("Usage: ruby sample/chat_server.rb ACCEPTED_DOMAIN PORT")
exit(1)
end
server = WebSocketServer.new(
:accepted_domains => [ARGV[0]],
:port => ARGV[1].to_... | Ruby |
# Copyright: Hiroshi Ichikawa <http://gimite.net/en/>
# Lincense: New BSD Lincense
$LOAD_PATH << File.dirname(__FILE__) + "/../lib"
require "web_socket"
require "thread"
Thread.abort_on_exception = true
if ARGV.size != 2
$stderr.puts("Usage: ruby sample/chat_server.rb ACCEPTED_DOMAIN PORT")
exit(1)
end
server =... | Ruby |
# Copyright: Hiroshi Ichikawa <http://gimite.net/en/>
# Lincense: New BSD Lincense
$LOAD_PATH << File.dirname(__FILE__) + "/../lib"
require "web_socket"
if ARGV.size != 1
$stderr.puts("Usage: ruby samples/stdio_client.rb ws://HOST:PORT/")
exit(1)
end
client = WebSocket.new(ARGV[0])
puts("Connected")
Thread.new()... | Ruby |
# Copyright: Hiroshi Ichikawa <http://gimite.net/en/>
# Lincense: New BSD Lincense
$LOAD_PATH << File.dirname(__FILE__) + "/../lib"
require "web_socket"
Thread.abort_on_exception = true
if ARGV.size != 2
$stderr.puts("Usage: ruby sample/echo_server.rb ACCEPTED_DOMAIN PORT")
exit(1)
end
server = WebSocketServer.... | 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 |
platform :ios, '6.0'
pod "AFNetworking", "~> 2.0"
pod "SDWebImage", "~>3.5.2"
pod "FMDB", "~>2.2"
pod "UI7Kit", "~>0.9.18"
pod "MBProgressHUD", "~>0.8"
pod 'libextobjc' | Ruby |
platform :ios, '6.0'
pod "AFNetworking", "~> 2.0"
pod "SDWebImage", "~>3.5.2"
pod "FMDB", "~>2.2"
pod "UI7Kit", "~>0.9.18"
pod "MBProgressHUD", "~>0.8"
pod 'libextobjc' | Ruby |
# Include hook code here | Ruby |
require 'rails_generator/generators/components/scaffold/scaffold_generator'
class BcmsScaffoldResourceSandbox
include ActionView::Helpers::ActiveRecordHelper
attr_accessor :form_action, :singular_name, :suffix, :model_instance
def sandbox_binding
binding
end
def default_input_block
Proc.new { |rec... | Ruby |
require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper'
describe <%= controller_class_name %>Helper do # Helper methods can be called directly in the examples (it blocks)
end
| Ruby |
class <%= controller_class_name %>Controller < ApplicationController
# GET /<%= table_name %>
# GET /<%= table_name %>.xml
def index
@<%= table_name %> = <%= class_name %>.find(:all)
respond_to do |format|
format.html # index.rhtml
format.xml { render :xml => @<%= table_name %>.to_xml }
... | Ruby |
require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper'
describe "/<%= table_name %>/show.<%= default_file_extension %>" do
include <%= controller_class_name %>Helper
before do
@<%= file_name %> = mock_model(<%= class_name %>)
<% for attribute in attributes -%>
@<%= file_... | Ruby |
module <%= controller_class_name %>Helper
end
| Ruby |
class <%= class_name %> < ActiveRecord::Base
end
| Ruby |
require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper'
describe "/<%= table_name %>/edit.<%= default_file_extension %>" do
include <%= controller_class_name %>Helper
before do
@<%= file_name %> = mock_model(<%= class_name %>)
<% for attribute in attributes -%>
@<%= file_... | Ruby |
require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper'
describe "/<%= table_name %>/index.<%= default_file_extension %>" do
include <%= controller_class_name %>Helper
before do
<% [98,99].each do |id| -%>
<%= file_name %>_<%= id %> = mock_model(<%= class_name %>)
<% for attr... | Ruby |
require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper'
describe "/<%= table_name %>/new.<%= default_file_extension %>" do
include <%= controller_class_name %>Helper
before do
@<%= file_name %> = mock_model(<%= class_name %>)
@<%= file_name %>.stub!(:new_record?).and_retu... | Ruby |
require File.dirname(__FILE__) + '/../spec_helper'
#Delete this context and add some real ones
context "Given a generated <%= table_name %>_spec.rb with fixtures loaded" do
fixtures :<%= table_name %>
specify "fixtures should load two <%= class_name %>s" do
<%= class_name %>.should have(2).records
end
en... | Ruby |
class <%= migration_name %> < ActiveRecord::Migration
def self.up
create_table :<%= table_name %> do |t|
<% for attribute in attributes -%>
t.column :<%= attribute.name %>, :<%= attribute.type %>
<% end -%>
end
end
def self.down
drop_table :<%= table_name %>
end
end
| Ruby |
require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper'
describe <%= controller_class_name %>Controller, "#route_for" do
it "should map { :controller => '<%= table_name %>', :action => 'index' } to /<%= table_name %>" do
route_for(:controller => "<%= table_name %>", :action => "inde... | Ruby |
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the bhed_rest_scaffold plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate documentation for the bhed_rest_s... | Ruby |
# desc "Explaining what the task does"
# task :custom_scaffold do
# # Task goes here
# end | Ruby |
# Uninstall hook code here
| Ruby |
# Install hook code here
| Ruby |
# CustomScaffold | 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 |
# $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... | 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... | Ruby |
# Compass configurations
sass_path = File.dirname(__FILE__)
css_path = File.join(sass_path, "..", "css")
# Require any additional compass plugins here.
images_dir = File.join(sass_path, "..", "img")
output_style = :expanded
environment = :production | Ruby |
css_dir = "css"
sass_dir = "sass" | 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 the Ext JS SDK relative to this file
$ext_path = "../../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 resources/sass folder
# <root>/resources/sass
sass_path = File.dirname(__FILE__)
# css_pat... | Ruby |
# Compass configurations
sass_path = File.dirname(__FILE__)
css_path = File.join(sass_path, "..", "css")
# Require any additional compass plugins here.
images_dir = File.join(sass_path, "..", "img")
output_style = :expanded
environment = :production | 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 |
# 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 |
# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb
unless defined?(RAILS_ROOT)
root_path = File.join(File.dirname(__FILE__), '..')
unless RUBY_PLATFORM =~ /mswin32/
require 'pathname'
root_path = Pathname.new(root_path).cleanpath(true).to_s
end
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 |
# 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 |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
#
# HTML editor box helper function
#
def fckeditor_text_area(object, method, options = {}, fckoptions = {})
# set defaults when no fckoptions set
if (! fckoptions[:width])
fckopti... | Ruby |
module ForwardHelper
end
| Ruby |
module ContentHelper
def base_url
# return the base url for this project
@project.domain + @project.directory_url + '/'
end
# Add the base url including domain for the requested file.
# Also checks to ensure the provided file is not already
# a complete url, in which case, nothing will be attached... | Ruby |
module Admin::ContentPagesHelper
end
| Ruby |
module Admin::FilesHelper
end
| Ruby |
module Admin::TagsHelper
end
| Ruby |
module Admin::ProjectGroupsHelper
end
| Ruby |
module StatsHelper
end
| Ruby |
module LibraryHelper
def self.check_magick
begin
return true if not Magick.nil?
rescue
# no magic here!
end
return false
end
end
| Ruby |
module BulletinTextHelper
include ActionView::Helpers::TextHelper
# convert all <br>s and </p>s into character returns
# then do some funky stuff with links strip all other html tags.
def html_to_text( text )
if text =~ /<\S/ # found a tag!
text = text.gsub(/[\n\r]/, '') # remove all newlines
... | Ruby |
module ProjectsHelper
end
| Ruby |
class BulkMailer < ActionMailer::Base
def bulletin(bulletin, subscription, subject = nil)
recipients subscription.recipient.email
from bulletin.project.sender
subject ( subject.nil? ? bulletin.subject : subject )
@content_type = "multipart/alternative"
bulletin.templet.templet_layouts.find(:... | Ruby |
#
# Extension of a Template for Pages used when preseting things to the user.
#
class Page < Templet
# prepare a special class used for useful funtions/variables
class PageParameters
attr_accessor :bulletin_name, :page_name
def initialize( options )
if (options)
self.bulletin_name = o... | Ruby |
class RecipientEmailReceipt < ActiveRecord::Base
belongs_to :email
belongs_to :recipient
end | Ruby |
class TempletLayout < ActiveRecord::Base
belongs_to :templet
# Provide access to some text helper functions.
# This is for ERB support only!
include BulletinTextHelper if ENABLE_ERB_LAYOUTS
attr_accessor :rendered
attr_protected :filter
@@valid_filters = ['liquid'] + (ENABLE_ERB_LAYOUTS ? ['ERB'] : [])... | Ruby |
class Section < ActiveRecord::Base
belongs_to :bulletin
has_many :entries, :order => 'position', :dependent => :destroy
# Create a new section and fill in all the required fields automatically.
# This is required if the section is going to be saved before the
# user has added any data.
#
# Requires th... | Ruby |
require 'erb'
class Bulletin < ActiveRecord::Base
belongs_to :project
belongs_to :templet
has_many :sections, :dependent => :destroy
has_many :recipient_receipts, :dependent => :delete_all, :extend => BulletinRecipientStatistics
has_many :bulletin_layouts, :dependent => :delete_all
has_many :content_pages... | Ruby |
class UserRole < ActiveRecord::Base
belongs_to :project
belongs_to :user
end
| Ruby |
#
# Extends the templet to provide the ability to generate email messages.
#
# Email messages allow the user to create a one-off email that does not require
# the complexity of a bulletin.
#
class Email < Templet
# generic accessor for links
attr_accessor :link
# prepare a special class used for useful funti... | Ruby |
class ContentPageTag < ActiveRecord::Base
end
| Ruby |
class RecipientReceipt < ActiveRecord::Base
belongs_to :bulletin
belongs_to :recipient
# status maybe:
# - F - Failed
# - R - Received
end
| Ruby |
class Project < ActiveRecord::Base
belongs_to :project_group
has_many :bulletins, :dependent => :destroy
has_many :user_roles, :dependent => :destroy
has_many :users, :through => :user_roles
has_many :subscriptions, :dependent => :delete_all
has_many :valid_subscriptions, :class_name => 'Subscription',... | Ruby |
class ContentPage < ActiveRecord::Base
belongs_to :templet
belongs_to :bulletin
# acts_as_taggable :join_table => 'content_page_tags'
validates_format_of :name, :with => /^[\d\w_\-]+$/
validates_uniqueness_of :name, :scope => 'bulletin_id'
def render( layout = nil )
self.templet.render( self.b... | Ruby |
require 'digest/sha1'
class User < ActiveRecord::Base
# empty project used for administrator!
# belongs_to :project
has_many :user_roles, :dependent => :destroy
has_many :projects, :through => :user_roles
attr_protected :id
attr_accessor :password, :password_confirmation
validates_length_of :na... | Ruby |
class Subscription < ActiveRecord::Base
belongs_to :recipient
belongs_to :project
# A list of valid states that the state field may become
# including a common name.
@@valid_states = {
'P' => _('Pending'),
'F' => _('Forced'),
'C' => _('Confirmed'),
'R' => _('Removed'),
}
def i... | Ruby |
class Tag < ActiveRecord::Base
end
| Ruby |
class Notifier < ActionMailer::Base
#
# Send an email to the user notifying them of what has changed.
# The correct message to be sent is automatically determined.
#
# Required options:
# * :recipient - the receiver of the message
# * :project - where to get the status from
# or
# * :subscript... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.