code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
class CreateArticles < ActiveRecord::Migration
def self.up
create_table :articles do |t|
t.column :user_id, :integer
t.column :title, :string
t.column :synopsis, :text, :limit => 1000
t.column :body, :text, :limit => 20000
t.column :published, :boolean, :default => false
t... | Ruby |
class AddOpenIdAuthenticationTables < ActiveRecord::Migration
def self.up
create_table :open_id_authentication_associations, :force => true do |t|
t.column :lifetime, :integer
t.column :assoc_type, :string
t.column :handle, :string
t.column :issued, :integer
t.column :ser... | Ruby |
class CreatePages < ActiveRecord::Migration
def self.up
create_table :pages do |t|
t.column :title, :string
t.column :permalink, :string
t.column :body, :text
t.column :created_at, :datetime
t.column :updated_at, :datetime
end
end
def self.down
drop_table :pages
en... | Ruby |
class CreateSubtasksdescs < ActiveRecord::Migration
def self.up
create_table :subtasksdescs do |t|
t.column :tasksdesc_id, :integer, :default => 0, :null => false
t.column :conturl1, :string, :limit => 100, :default => "", :null => false
t.column :uname1, ... | Ruby |
class CreateCategories < ActiveRecord::Migration
def self.up
create_table :categories do |t|
t.column :name, :string
end
end
def self.down
drop_table :categories
end
end
| Ruby |
require 'net/http'
# Original credits: http://blog.inquirylabs.com/2006/04/13/simple-uri-validation/
# HTTP Codes: http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net/HTTPResponse.html
class ActiveRecord::Base
def self.validates_uri_existence_of(*attr_names)
configuration = { :message => "is not v... | Ruby |
require_dependency "user"
module OpenidLoginSystem
protected
# overwrite this if you want to restrict access to only a few actions
# or if you want to check if the user has the correct rights
# example:
#
# # only allow nonbobs
# def authorize?(user)
# user.login != "bob"
# end
def a... | Ruby |
module LoginSystem
protected
def is_logged_in?
username, password = get_http_auth_data
@logged_in_user = User.find(session[:user_id]) if session[:user_id]
@logged_in_user = User.authenticate(username, password) if username && password
@logged_in_user ? @logged_in_user : false
end
def logg... | Ruby |
#!E:/InstantRails/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 seve... | Ruby |
#!E:/InstantRails/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 seve... | Ruby |
#!E:/InstantRails/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/fastcg... | Ruby |
#!E:/InstantRails/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 seve... | Ruby |
#!E:/InstantRails/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 seve... | Ruby |
#!E:/InstantRails/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/fastcg... | 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 |
class CreateHotfileClicks < ActiveRecord::Migration
def self.up
create_table :hotfile_clicks do |t|
t.timestamps
end
end
def self.down
drop_table :hotfile_clicks
end
end
| Ruby |
class CreateInvitations < ActiveRecord::Migration
def self.up
create_table :invitations do |t|
t.timestamps
end
end
def self.down
drop_table :invitations
end
end
| Ruby |
class CreateUserConnections < ActiveRecord::Migration
def self.up
create_table :user_connections do |t|
t.timestamps
end
end
def self.down
drop_table :user_connections
end
end
| Ruby |
class CreateHotfiles < ActiveRecord::Migration
def self.up
create_table :hotfiles do |t|
t.timestamps
end
end
def self.down
drop_table :hotfiles
end
end
| Ruby |
class CreateViewUserCounts < ActiveRecord::Migration
def self.up
create_table :view_user_counts do |t|
t.timestamps
end
end
def self.down
drop_table :view_user_counts
end
end
| Ruby |
class CreateFriends < ActiveRecord::Migration
def self.up
create_table :friends do |t|
t.timestamps
end
end
def self.down
drop_table :friends
end
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.timestamps
end
end
def self.down
drop_table :users
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 |
#!C:/temp/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:/temp/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.... | Ruby |
#!C:/temp/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:/temp/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 severel... | Ruby |
#!C:/temp/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.... | Ruby |
#!C:/temp/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 severel... | 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
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/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/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 IndexHelper
end
| Ruby |
module FriendHelper
end | Ruby |
module AdminHelper
end
| Ruby |
module HotfilesHelper
end
| Ruby |
class Hotfile < ActiveRecord::Base
belongs_to :user_connection, :class_name => "ViewUserCount", :foreign_key => "user_id"
end
| Ruby |
class KerjoMailer < ActionMailer::Base
def invite(from,to,url)
subject="An invitation"
@body["friend"] = to
@body["user"] = from
@body["url"]=url
setup_email(from,to,subject)
end
def notify(from,to,myname,hisname,url)
subject="I'v added you as my friend"
@body["friend"] = hisname+'('+to+')'
... | Ruby |
class Invitation < ActiveRecord::Base
end
| Ruby |
class User < ActiveRecord::Base
#has_many :friends, :class_name => "Friend", :foreign_key => "user_id"
#has_many :his_friends, :class_name => "Friend", :foreign_key => "friend_id"
has_many :connections,
:foreign_key => "user_id",
:class_name => "UserConnection",
:conditions=>["thetime > :thetime",{:thetime=>6.m... | Ruby |
class ViewUserCount < ActiveRecord::Base
end
| Ruby |
class Friend < ActiveRecord::Base
belongs_to :user, :class_name => "User", :foreign_key => "user_id"
belongs_to :friend, :class_name => "User", :foreign_key => "friend_id"
end
| Ruby |
class HotfileClick < ActiveRecord::Base
end
| Ruby |
class UserConnection < ActiveRecord::Base
belongs_to :user, :foreign_key => "user_id" , :class_name => "User"
belongs_to :friend, :foreign_key => "friend_id", :class_name => "User"
end
| Ruby |
class SearchController < ApplicationController
before_filter :auth
def index
params[:server]="" if (params[:server].blank?)
end
end | Ruby |
class JnlpController < ApplicationController
def make
sfilename=Time.now.to_f.to_s+rand(0xFFFFFFFF).to_s+".jnlp"
if(params[:port].blank?)
params[:port]="443"
end
if($cache.nil?)then
@content=File.open("public/kerjodando.jnlp"){|f|f.read}
logger.warn("the message sho... | Ruby |
class FriendController < ApplicationController
before_filter :auth
def index
@me=User.find(session[:user_id])
end
def usermod
@me=User.find(session[:user_id])
@func=-101
user=User.find_by_email(params[:email].strip)
if (user.nil? || user.id==@me.id)
if(request.post? && @me.password==params[:old... | Ruby |
class TrustedfileController < ApplicationController
def make
require 'set'
ids=params[:identifier]
ver=params[:ver].to_i
port_ips=params[:port].split(':',2)
cm=ConnectionManager.new
cm.refresh_mynet(ids,request.remote_ip,port_ips[0],port_ips[1],nil)
UserConnection.update_all(['routeri... | 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 HotfilesController < ApplicationController
before_filter :auth,:except => [:index]
def submit
begin
if params[:filesizelong].to_i<=0
@result='paramwrong'
else
if (Hotfile.find_by_filehash(params[:filehash]).nil?)
mF=Hotfile.new
mF.filehash=params[:filehash]
mF.description=param... | Ruby |
class AdminController < ApplicationController
def index
if(request.post? && params[:pwd]=='hicasper')
session[:admin]=true
end
if session[:admin]
redirect_to :controller=>'hotfiles'
else
render :layout => false
end
end
def logout
session[:admin] = nil
redirect_to :controller=>'index'
end
end... | Ruby |
class IndexController < ApplicationController
def index
if request.get? && !params[:inviteid].nil?
invite = Invitation.find(:first,:conditions=>"hashkey='#{params[:inviteid]}' ")
unless invite.nil? || invite.friend_id>0
params[:email]=invite.email
params[:inviteid]=invite.id
else
... | 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 |
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!
# 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
# 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 = '2.0... | 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 ConnectionManager
def joinnet(user_id,friend_id,routerip,port,ips,sid)
uc=UserConnection.find(:first,:conditions=>["user_id=:user_id and friend_id=:user_id",{:user_id=>user_id}])
if(uc.nil?)
uc=UserConnection.new()
uc.user_id = user_id
uc.friend_id=friend_id
end
refreshconnec... | Ruby |
class NetManager
def initialize(id)
@id=id.to_s
end
def is_friend(friend_id)
if @friends_ids.nil?
require 'set'
friends=Friend.find(:all,:conditions=>"user_id="+@id)
friends=[] if friends.nil?
@friends_ids=Set.new
friends.each{|n| @friends_ids<<n.friend_id}
end
@friends_ids.i... | Ruby |
dir = File.dirname(__FILE__)
Dir[File.expand_path("#{dir}/**/*.rb")].uniq.each do |file|
require file
end | Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'spec/rails/story_adapter' | Ruby |
class CreateForums < ActiveRecord::Migration
class Forum < ActiveRecord::Base
end
def self.up
create_table :forums do |t|
t.string :name
t.text :description
t.integer :topics_count, :null => false, :default => 0
t.timestamps
end
Forum.create!(:name => "Discussion forum",... | Ruby |
class AddEmailUniqueness < ActiveRecord::Migration
def self.up
remove_index :people, :email
add_index :people, :email, :unique => true
end
def self.down
remove_index :people, :email
add_index :people, :email
end
end
| Ruby |
class CreateLocalKeys < ActiveRecord::Migration
include Crypto
def self.up
# Identifier for the tracker
File.open("identifier", "w") do |f|
f.write UUID.new
end unless File.exist?("identifier")
# RSA keys for user authentication
Crypto.create_keys
end
def self.down
end
end
| Ruby |
class CreateTopics < ActiveRecord::Migration
def self.up
create_table :topics do |t|
t.integer :forum_id
t.integer :person_id
t.string :name
t.integer :forum_posts_count, :null => false, :default => 0
t.timestamps
end
add_index :topics, :forum_id
end
def self.down
... | Ruby |
class CreateBlogs < ActiveRecord::Migration
def self.up
create_table :blogs do |t|
t.integer :person_id
t.timestamps
end
end
def self.down
drop_table :blogs
end
end
| Ruby |
class AddAdmin < ActiveRecord::Migration
class Person < ActiveRecord::Base
end
class Blog < ActiveRecord::Base
end
def self.up
add_column :people, :admin, :boolean, :default => false, :null => false
add_column :people, :deactivated, :boolean,
:default => false, :null =>... | Ruby |
class AddEmailNotificationPreferences < ActiveRecord::Migration
def self.up
add_column :people, :connection_notifications, :boolean, :default => true
add_column :people, :message_notifications, :boolean, :default => true
add_column :people, :wall_comment_notifications, :boolean, :default => true
add_c... | Ruby |
class CreatePosts < ActiveRecord::Migration
def self.up
create_table :posts do |t|
t.integer :blog_id
t.integer :topic_id
t.integer :person_id
t.string :title
t.text :body
t.integer :blog_post_comments_count, :null => false, :default => 0
t.string :type
t.time... | Ruby |
class AddServerNameAndApp < ActiveRecord::Migration
def self.up
add_column :preferences, :server_name, :string
add_column :preferences, :app_name, :string
end
def self.down
remove_column :preferences, :app_name
remove_column :preferences, :server_name
end
end
| Ruby |
class ChangeArticleCommentCountToArticleCommentCount < ActiveRecord::Migration
def self.up
rename_column(:articles, :comments_count, :article_comments_count)
end
def self.down
rename_column(:articles, :article_comments_count, :comments_count)
end
end
| Ruby |
class CreateFriends < ActiveRecord::Migration
def self.up
create_table :friends do |t|
t.integer :person_id
t.integer :friend_id
t.timestamps
end
end
def self.down
drop_table :friends
end
end
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.