code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/dbconsole'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about'
| Ruby |
#!/usr/bin/env ruby
unless ARGV.include?("-p")
ARGV << "-p"
ARGV << "3000"
end
unless ARGV.include?("-b")
ARGV << "-b"
ARGV << "0.0.0.0"
end
require File.expand_path('../../config/boot', __FILE__)
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/dbconsole'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/console'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/plugin'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../../config/boot', __FILE__)
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../../config/boot', __FILE__)
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../../config/boot', __FILE__)
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../../config/boot', __FILE__)
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/generate'
| Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
end
| Ruby |
module SessionHelper
end
| Ruby |
module FbConnectHelper
end
| Ruby |
module UsersHelper
end
| Ruby |
module WebappHelper
#
# Generate a list of keywords to insert into the template. Each controller can override it
def keywords
"Add Logic here to generate the keywords for all app. Override in each controller"
end
def template_name
"simple"
end
def statics_url
#Assumes the same host and s... | Ruby |
module HomeHelper
end
| Ruby |
class UserSession
attr_writer :user_id, :name, :facebook_user
attr_reader :user_id, :name, :facebook_user
def initialize(user, facebook_user=nil)
@user_id = user.id
@name = user.full_name
@facebook_user = facebook_user
end
def profile_picture_url
if @facebook_user
... | Ruby |
class UserMailer < ActionMailer::Base
def signup_confirmation(user)
setup_email(user.email)
@subject = I18n.t(:activate_account_email_subject)
@body = {:user=>user, :url => "#{WEBAPP_CONFIG["webapp_site"]}/user/activate/#{user.id}/#{user.activation_key}"}
end
def recover_password_instructions(us... | Ruby |
class UserObserver < ActiveRecord::Observer
def after_create(user)
UserMailer.deliver_signup_confirmation(user) unless user.facebook_user?
end
end | Ruby |
class PasswordRecovery < ActiveRecord::Base
def self.clear_password_recover(user_id)
PasswordRecovery.delete(self.find_by_user_id(user_id).id) if self.find_by_user_id(user_id)
end
def self.create_password_recovery(user_id)
#Check if exists any password recovery for the user
password_recovery = s... | Ruby |
class User < ActiveRecord::Base
before_create :before_create_user
#accept_terms
attr_accessible(:terms)
validates_acceptance_of(:terms, :message=>:accept_terms,:on=>:create)
#handle
attr_accessible(:handle)
validates_uniqueness_of(:handle, :case_sensitive=>false)
validates_length_of(:handle,:minimum=>4,... | Ruby |
class PersistentSession < ActiveRecord::Base
def self.clear_session(user_id)
PersistentSession.delete(PersistentSession.find_by_user_id(user_id).id) if !PersistentSession.find_by_user_id(user_id).nil?
end
def self.create_session(user_id)
#check if exists
persistent_session = PersistentSession.fi... | Ruby |
require 'webapp_exceptions'
class WebappController < ApplicationController
helper :all # include all helpers, all the time
include ApplicationHelper
include WebappHelper
before_filter :detect_auto_login_cookie
#Define the base layout. For not hard coded
layout :determine_layout
protected
... | Ruby |
class FbConnectController < WebappController
def authenticate
@facebook_session = Facebooker::Session.create(Facebooker.api_key, Facebooker.secret_key)
logger.debug "facebook session in authenticate: #{facebook_session.inspect}"
redirect_to @facebook_session.login_url
end
def facebook_session=(s... | 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
protect_from_forgery # See ActionController::RequestForgeryPr... | Ruby |
class HomeController < WebappController
def index
end
end
| Ruby |
class UsersController < WebappController
before_filter :requires_authentication, :except=>[:new,:create,:reset_password, :recover_password, :activate]
#List users
# GET /users
# GET /users.xml
def index
@users = User.all
respond_to do |format|
format.html # index.html.erb
format.xml ... | Ruby |
class SessionsController < WebappController
def new
#Try to auto login the user
#do_auto_login if session[:user_session].nil? && cookies[WebappConstants::AUTO_LOGIN_COOKIE_NAME]
#I need to ask for email/username, password and the keeplogged in
#Initialize the instance vars
@handle_or_email =... | 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.
# 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 do debug a probl... | Ruby |
#Load the WEB APP configuration for the current environment
WEBAPP_CONFIG = YAML.load_file("#{RAILS_ROOT}/config/webapp_config.yml")[Rails.env]
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.default_charset = "utf-8"
ActionMailer::Base.smtp_setti... | Ruby |
# Be sure to restart your server when you modify this file.
# These settings change the behavior of Rails 2 apps and will be defaults
# for Rails 3. You can remove this initializer when Rails 3 is released.
if defined?(ActiveRecord)
# Include Active Record class name as root for JSON serialized output.
ActiveReco... | 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 cookie session data integrity.
# If you change this key, all old sessions 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 attacks.
Act... | Ruby |
ActionController::Routing::Routes.draw do |map|
map.resources :users
#User Activation Route
map.activate 'user/activate/:id/:activation_key', :controller => "users", :action => "activate"
map.reset_password 'user/reset_password/:id/:key', :controller=>"users", :action=>"reset_password"
map.recover_passwo... | 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 |
# Be sure to restart your server when you modify this file
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
... | 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
# Full error reports are disabled and caching is turned on
config.action_controller.consider_all_reque... | 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 StringUtils
def self.generate_random_words(max=100)
Array.new(max) {(rand(122-97) + 97).chr }.join
end
end | Ruby |
module Webapp
##Exceptions for the web App.
## TODO: Check what is the best base Exception
class NotAllowedError < StandardError
end
class FBUserNotAuthenticableError < StandardError
end
class FBUserNotRegisteredError < StandardError
end
class NoFBSessionError < St... | Ruby |
module WebappConstants
AUTO_LOGIN_COOKIE_NAME = "alcn"
MAX_AUTO_LOGIN_COOKIE_AGE = 15 #days
# class Constants
# def self.auto_login_cookie_name
#
# end
# end
end | 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/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 |
#!/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/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
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
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../rspec/lib' # For svn
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/plugins/rspec/lib' # For rspec installed as plugin
require 'rubygems'
require 'drb/drb'
require 'rbconfig'
require 'spec'
require 'optparse'
specmate = ENV['HOME'] + "/Lib... | 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
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console' | Ruby |
#!/usr/bin/env ruby
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../vendor/plugins/rspec/lib"))
require 'spec'
::Spec::Runner::CommandLine.run(ARGV, STDERR, STDOUT, true, true)
| 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 ruby
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../vendor/plugins/rspec/lib"))
require 'spec'
::Spec::Runner::CommandLine.run(ARGV, STDERR, STDOUT, true, true)
| 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
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../rspec/lib' # For svn
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/plugins/rspec/lib' # For rspec installed as plugin
require 'rubygems'
require 'drb/drb'
require 'rbconfig'
require 'spec'
require 'optparse'
specmate = ENV['HOME'] + "/Lib... | 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 |
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'spec/rails'
Spec::Runner.configure do |config|
config.use_transactional_fixtures = true
config.... | Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
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 => '_BaseCart_s... | 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 |
# 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 |
# 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 |
# 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 |
require 'rubygems'
require 'sinatra'
require 'haml'
require './lib/render_partial'
# ------------------------------------------------------------
# Sinatra variables
# ------------------------------------------------------------
set :app_file, __FILE__
set :root, File.dirname(__FILE__)
set :views, 'views'
set :public,... | Ruby |
require 'rubygems'
require 'bundler'
require 'rake'
Bundler.setup
Dir["tasks/*.rake"].sort.each { |ext| load ext }
| Ruby |
namespace :styles do
desc "Run compass stats"
task :stats => ["stats:default"]
namespace :stats do
task :default do
puts "*** Running compass stats ***"
system "compass stats"
end
desc "Create a log of compass stats"
task :log do
t = DateTime.now
filename = "compass-s... | Ruby |
desc 'Start the application'
task :start do
system "bundle exec shotgun config.ru"
end | Ruby |
require './app'
# Compass Configuration
require 'grid-coordinates'
require 'meyer-reset'
# Configuration to use when running within Sinatra
project_path = Sinatra::Application.root
# HTTP paths
http_path = '/'
http_stylesheets_path = '/stylesheets'
http_images_path = '/images'
http_javascr... | Ruby |
source "http://rubygems.org"
gem "sinatra", "~> 1.2.3"
gem "shotgun", "~> 0.9"
gem "haml", "~> 3.1.1"
gem "sass", "~> 3.1.1"
gem "compass", "~> 0.11.1"
gem "grid-coordinates", "~> 1.1.4" | Ruby |
# Borrowed from Tanner Burson: http://github.com/tannerburson
# http://github.com/adamstac/sinatra-plugins/blob/master/render_partial.rb
module Sinatra
module RenderPartial
def partial(page, options={})
haml page, options.merge!(:layout => false)
end
end
helpers RenderPartial
end | Ruby |
require 'rubygems'
require 'sinatra'
require './app'
run Sinatra::Application | Ruby |
Dir[File.dirname(__FILE__) + '/lib/**/*.rb'].each { |lib| require lib }
ActiveRecord::ConnectionAdapters::MysqlAdapter.send :include, BatchedSqlFu
ActiveRecord::Base.send :include, BatchedSqlFu::ActiveRecord
| Ruby |
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the batched_sql_fu plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate documentation for the batched_sql_fu ... | Ruby |
# desc "Explaining what the task does"
# task :batched_sql_fu do
# # Task goes here
# end
| Ruby |
# Uninstall hook code here
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.