code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
class Incident < ActiveRecord::Base
end
| Ruby |
require 'digest/sha1'
class User < ActiveRecord::Base
validates_presence_of :lastname, :firstname, :login
validates_uniqueness_of :login
validates_confirmation_of :password
attr_reader :password
attr_accessor :password_confirmation
def password=(value)
@password = value
... | Ruby |
module IncidentsHelper
end
| Ruby |
module UsersHelper
end
| Ruby |
module BoxesHelper
end
| Ruby |
module RoomsHelper
end
| 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 => '_bliss_sess... | 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 |
# 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 |
ActionController::Routing::Routes.draw do |map|
map.resources :incidents
map.resources :users
map.resources :boxes
map.resources :rooms
map.login 'login' , :controller => 'users', :action => 'login'
map.logout 'logout' , :controller => 'users', :action => 'logout'
# The priority is based upon orde... | 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
unless defined?(RAILS_ROOT)
root_path = File.join(File.dirname(__FILE__), '..')
unless RUBY_PLATFORM =~ /(:?mswin|mingw)/
require 'pathname'
root_path = Pathname.new(root_path).cleanpath(true).to_s
end
... | Ruby |
#!/usr/bin/ruby1.8
#
# 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 |
#!/usr/bin/ruby1.8
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 |
# 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 |
# 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.
#
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters ... | Ruby |
# Be sure to restart your server when you modify this file.
Blog::Application.config.session_store :cookie_store, key: '_blog_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 "rails generat... | 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 |
Blog::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_co... | Ruby |
Blog::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 have to restart the web serve... | Ruby |
Blog::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 suite... | Ruby |
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Blog::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 defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.requi... | Ruby |
Blog::Application.routes.draw do
resources :comments
resources :posts
# The priority is based upon order of creation:
# first created -> highest priority.
# Sample of regular route:
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action
#... | Ruby |
module ApplicationHelper
end
| Ruby |
module PostsHelper
end
| Ruby |
module CommentsHelper
end
| Ruby |
class Comment < ActiveRecord::Base
attr_accessible :body, :post_id
end
| Ruby |
class Post < ActiveRecord::Base
attr_accessible :body, :title
end
| Ruby |
class PostsController < ApplicationController
# GET /posts
# GET /posts.json
def index
@posts = Post.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @posts }
end
end
# GET /posts/1
# GET /posts/1.json
def show
@post = Post.find(params[:id])
... | Ruby |
class CommentsController < ApplicationController
# GET /comments
# GET /comments.json
def index
@comments = Comment.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @comments }
end
end
# GET /comments/1
# GET /comments/1.json
def show
@commen... | Ruby |
class ApplicationController < ActionController::Base
protect_from_forgery
end
| Ruby |
#!/usr/bin/env rake
# 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.expand_path('../config/application', __FILE__)
Blog::Application.load_tasks
| Ruby |
source 'https://rubygems.org'
gem 'rails', '3.2.13'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> ... | Ruby |
class CreatePosts < ActiveRecord::Migration
def change
create_table :posts do |t|
t.string :title
t.text :body
t.timestamps
end
end
end
| Ruby |
class CreateComments < ActiveRecord::Migration
def change
create_table :comments do |t|
t.integer :post_id
t.text :body
t.timestamps
end
end
end
| Ruby |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | Ruby |
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Blog::Application
| Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integrati... | Ruby |
module Utils
require 'fileutils'
include FileUtils
def wash_to_html(dest = "book.html")
dest_path = absolute_path(dest)
rm_rf dest_path
builder = Builder::XmlMarkup.new
xml = builder.html do |html|
html.head do |head|
head.meta "HTTP-EQUIV" => "CONTENT-TYPE", "CONTENT" => "text/html... | Ruby |
require 'builder'
require 'hpricot'
require 'iconv'
class BlogEntry
attr_reader :id
def initialize(file_path)
@file_path = file_path
@id = @file_path.split("/").last.split(".").first.to_i
p "creating blog entry : #{file_path}"
content = File.new(file_path).read
@doc = Hpricot.parse(content)
... | Ruby |
require 'builder'
class BlogEntries
require 'fileutils'
include FileUtils
attr_reader :entries
def initialize(src_dir_path)
src_dir = Dir.new(absolute_path(src_dir_path))
file_names = src_dir.entries.reject{|entry|entry.index(".")==0}
blog_file_names = file_names.reject{|entry|entry.include?("ind... | Ruby |
#!/usr/bin/env ruby
require 'rubygems'
require File.dirname(__FILE__) + "/" + "blog_entries.rb"
require File.dirname(__FILE__) + "/" + "blog_entry.rb"
class IndexEntry
def self.from_csv_file(path, delimeter = "\t")
File.new(path).read.split("\n").map{|line| IndexEntry.new(line)}
end
def initialize(line)
... | Ruby |
#!/usr/bin/env ruby
require 'rubygems'
require File.dirname(__FILE__) + "/" + "blog_entries.rb"
require File.dirname(__FILE__) + "/" + "blog_entry.rb"
src_dir = "TransparentThoughts"
#src_dir = "test-src"
BlogEntries.new(src_dir).to_calc | Ruby |
#!/usr/bin/env ruby
require 'rubygems'
require File.dirname(__FILE__) + "/" + "blog_entries.rb"
require File.dirname(__FILE__) + "/" + "blog_entry.rb"
src_dir = "TransparentThoughts"
#src_dir = "test-src"
BlogEntries.new(src_dir).to_calc | Ruby |
#!/usr/bin/env ruby
require 'rubygems'
require File.dirname(__FILE__) + "/" + "blog_entries.rb"
require File.dirname(__FILE__) + "/" + "blog_entry.rb"
class IndexEntry
def self.from_csv_file(path, delimeter = "\t")
File.new(path).read.split("\n").map{|line| IndexEntry.new(line)}
end
def initialize(line)
... | 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 |
environment = :production
project_type = :stand_alone
http_path = "/"
css_dir = "../styles"
sass_dir = "."
images_dir = "images"
sass_options = {
:line_numbers => false,
:debug_info => false
}
# output_style = :compressed
# output_style = :compact
output_style = :expanded
| Ruby |
require 'webrick'
include WEBrick
s = HTTPServer.new(
:Port => 2010,
:DocumentRoot => Dir::pwd
)
s.mount('/sh/scripts', WEBrick::HTTPServlet::FileHandler, '../scripts')
s.mount('/sh/styles', WEBrick::HTTPServlet::FileHandler, '../styles')
trap('INT') { s.stop }
s.start
| Ruby |
class Db < ActiveRecord::Migration
def self.up
create_table :blogs do |blog|
blog.column :name, :string
blog.column :url, :string, :null => false
blog.column :click, :integer, :default => "0"
blog.column :rank, :integer, :default => "9999999"
blog.column :user_id, :integ... | 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/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 |
#!/usr/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 |
#!/usr/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 |
#!/usr/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 |
#!/usr/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 |
#!/usr/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 |
#!/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/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
Dir[File.dirname(__FILE__) + "/../lib/daemons/*_ctl"].each {|f| `#{f} #{ARGV.first}`} | Ruby |
#!/usr/bin/env ruby
# Ferret DRb server launcher script
#
# Place doc/ferret_server.yml into RAILS_ROOT/config and fit to taste.
#
# Start this script with script/runner and RAILS_ENV set.
#
# to run the unit tests against the drb server, start it with
# RAILS_ENV=test script/runner script/ferret_server
# and run your... | Ruby |
#!/usr/bin/env ruby
# Ferret DRb server launcher script
#
# Place doc/ferret_server.yml into RAILS_ROOT/config and fit to taste. Start
# it with RAILS_ENV set to the desired environment.
#
#
# To run the demo project's unit tests against the drb server, start it with
#
# RAILS_ENV=test script/ferret_start
#
# and run... | 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 script/runner
config = ActsAsFerret::Remote::Config.load
def send_signal(signal, pid_file)
pid = open(pid_file).read.to_i
print "Sending #{signal} to ferret_server with PID #{pid}..."
begin
Process.kill(signal, pid)
rescue Errno::ESRCH
puts "Process does not exist. Not running. Removing... | 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/breakpointer' | Ruby |
#!/usr/bin/env ruby
Dir[File.dirname(__FILE__) + "/../lib/daemons/*_ctl"].each {|f| `#{f} #{ARGV.first}`} | 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/about' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server' | Ruby |
#!/usr/bin/env script/runner
config = ActsAsFerret::Remote::Config.load
def send_signal(signal, pid_file)
pid = open(pid_file).read.to_i
print "Sending #{signal} to ferret_server with PID #{pid}..."
begin
Process.kill(signal, pid)
rescue Errno::ESRCH
puts "Process does not exist. Not running. Removing... | 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
# Ferret DRb server launcher script
#
# Place doc/ferret_server.yml into RAILS_ROOT/config and fit to taste. Start
# it with RAILS_ENV set to the desired environment.
#
#
# To run the demo project's unit tests against the drb server, start it with
#
# RAILS_ENV=test script/ferret_start
#
# and run... | Ruby |
#!/usr/bin/env ruby
# Ferret DRb server launcher script
#
# Place doc/ferret_server.yml into RAILS_ROOT/config and fit to taste.
#
# Start this script with script/runner and RAILS_ENV set.
#
# to run the unit tests against the drb server, start it with
# RAILS_ENV=test script/runner script/ferret_server
# and run your... | 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/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/generate' | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.