code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
#!/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/plugin' | Ruby |
require File.dirname(__FILE__) + '/../config/environment.rb'
FLICKR = Flickr.new(FLICKR_CACHE, FLICKR_KEY, FLICKR_SECRET)
unless FLICKR.auth.token
frob = FLICKR.auth.getFrob
link = FLICKR.auth.login_link
puts
puts link
puts
puts "copy and paste the above url into your browser then hit enter after viewing ... | Ruby |
class CreateForums < ActiveRecord::Migration
def self.up
create_table :forums do |t|
t.string :name
t.text :description
t.integer :position
t.timestamps
end
create_table :forum_topics do |t|
t.string :title
t.integer :forum_id
t.integer :owner_id
t.ti... | Ruby |
class MoveTimezoneToProfiles < ActiveRecord::Migration
def self.up
add_column :profiles, :time_zone, :string, :default => "UTC"
remove_column :users, :time_zone
execute "update profiles set time_zone='UTC'"
end
def self.down
remove_column :profiles, :time_zone
add_column :users, :time_zone, :... | Ruby |
class AddProfileLastActivityAt < ActiveRecord::Migration
def self.up
add_column :profiles, :last_activity_at, :datetime
end
def self.down
remove_column :profiles, :last_activity_at
end
end
| Ruby |
class CreateLovdByLess < ActiveRecord::Migration
def self.up
create_table "blogs", :force => true do |t|
t.string "title"
t.text "body"
t.integer "profile_id"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "blogs", "profile_id"
create... | Ruby |
##
# ForumsTestHelper
# Author: Les Freeman (lesliefreeman3@gmail.com)
# Created on: 5/16/08
# Updated on: 5/16/08
# Provides useful methods for testing the models and controllers associented with forums.
#
module ForumsTestHelper
def valid_forum_attributes
forums(:one).attributes
end
def unvalid_forum_att... | Ruby |
namespace :gems do
namespace :dependent do
desc "Install gems required for lovd-by-less"
task :install do
windoz = /win32/ =~ RUBY_PLATFORM
gems = %w[
rflickr
rmagick
RedCloth
]
gems << 'win32console' if windoz
sudo = windoz ? '' : 'sudo '
ge... | Ruby |
debug = true
def build_params segs, others = ''
s = []
segs.each do |seg|
if seg.is_a?(ActionController::Routing::DynamicSegment)
s << seg.key.to_s.gsub(':', '')
end
end
s <<( others) unless others.blank?
s.join(', ')
end
def build_path segs
s = ""
segs.each do |seg|
if seg.is_a?(Acti... | Ruby |
task :mig do
puts 'rake db:migrate RAILS_ENV="development"'
system "rake db:migrate RAILS_ENV='development'"
puts "rake db:test:clone"
system "rake db:test:clone"
if !ENV['a'].nil? && ENV['a'].size > 0
puts "NOT RUNNING: rake annotate_models"
else
system "rake annotate_models"
end
end
| Ruby |
class LessFormBuilder < ActionView::Helpers::FormBuilder
include ActionView::Helpers::ActiveRecordHelper
def method_missing *args
options = args.extract_options!
label = get_label '', options
front(label) + super(*args) + back(label)
end
def wrap method, options = {}
s = front(method, o... | Ruby |
require 'avatar/source/gravatar_source'
class SizedGravatarSource < Avatar::Source::GravatarSource
alias_method :parse_options_without_size, :parse_options
def self.sizes
{ :small => 50, :medium => 100, :large => 150, :big => 150 }
end
def parse_options(profile, options)
#pass :gravatar_size t... | 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
#
# 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
#
# 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 |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
require 'ostruct'
require 'mocha'
# for testing uploaded files
# place any "already uploaded" files in a subdirectory within /test/ instead of overwriting production files.
FileColumn::ClassMethods... | 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 |
require 'FileUtils'
FileUtils.cp_r("../sources/indigo/", "C:/Program Files/Blender Foundation/Blender/2.67/scripts/addons", :verbose => true)
| 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' }])
# Major.create(:name... | Ruby |
class CreateEvents < ActiveRecord::Migration
def self.up
create_table :events do |t|
t.string :information
t.boolean :state
t.timestamps
end
end
def self.down
drop_table :events
end
end
| Ruby |
class CreateRooms < ActiveRecord::Migration
def self.up
create_table :rooms do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :rooms
end
end
| Ruby |
class AddComputerRoom < ActiveRecord::Migration
def self.up
add_column :computers, :room_id, :int
end
def self.down
remove_column :computers, room_id
end
end
| Ruby |
class AddEventComputerType < ActiveRecord::Migration
def self.up
add_column :events, :computer_id, :int
add_column :events, :type_event_id, :int
end
def self.down
remove_column :events, computer_id
remove_column :events, type_event_id
end
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :login
t.string :password
t.timestamps
end
end
def self.down
drop_table :users
end
end
| Ruby |
class CreateComputers < ActiveRecord::Migration
def self.up
create_table :computers do |t|
t.string :mac_adress
t.string :ip_computer
t.int :ram
t.int :cpu
t.int :hard_drive
t.boolean :state_computer
t.boolean :state_agent
t.timestamps
end
end
def self.dow... | Ruby |
class CreateTypeEvents < ActiveRecord::Migration
def self.up
create_table :type_events do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :type_events
end
end
| Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
class ActiveSupport::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 da... | Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/destroy'
| 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
require File.expand_path('../../config/boot', __FILE__)
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/generate'
| Ruby |
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/destroy'
| 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/console'
| 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__)
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about'
| Ruby |
#!/usr/bin/env ruby
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 EventsHelper
end
| Ruby |
module RoomsHelper
end
| Ruby |
module UsersHelper
end
| Ruby |
module ComputersHelper
end
| Ruby |
module TypeEventsHelper
end
| Ruby |
class Room < ActiveRecord::Base
end
| Ruby |
class Event < ActiveRecord::Base
belongs_to :type_event
belongs_to :computer
end
| Ruby |
class TypeEvent < ActiveRecord::Base
end
| Ruby |
class User < ActiveRecord::Base
end
| Ruby |
class Computer < ActiveRecord::Base
belongs_to :room
end
| Ruby |
class EventsController < ApplicationController
# GET /events
# GET /events.xml
def index
@events = Event.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @events }
end
end
# GET /events/1
# GET /events/1.xml
def show
@event = Event.find(par... | 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 UsersController < ApplicationController
# GET /users
# GET /users.xml
def index
@users = User.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @users }
end
end
# GET /users/1
# GET /users/1.xml
def show
@user = User.find(params[:id])
... | Ruby |
class RoomsController < ApplicationController
# GET /rooms
# GET /rooms.xml
def index
@rooms = Room.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @rooms }
end
end
# GET /rooms/1
# GET /rooms/1.xml
def show
@room = Room.find(params[:id])
... | Ruby |
class TypeEventsController < ApplicationController
# GET /type_events
# GET /type_events.xml
def index
@type_events = TypeEvent.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @type_events }
end
end
# GET /type_events/1
# GET /type_events/1.xml
... | Ruby |
class ComputersController < ApplicationController
# GET /computers
# GET /computers.xml
def index
@computers = Computer.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @computers }
end
end
# GET /computers/1
# GET /computers/1.xml
def show
... | 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 |
# 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 :events
map.resources :type_events
map.resources :rooms
map.resources :computers
map.resources :users
# The priority is based upon order of creation: first created -> highest priority.
# Sample of regular route:
# map.connect 'product... | 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 |
# 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' }])
# Major.create(:name... | Ruby |
class AddColumnComputer < ActiveRecord::Migration
def self.up
add_column :computers, :ram_used, :integer, :default => 0
add_column :computers, :cpu_used, :integer, :default => 0
add_column :computers, :hard_drive_used, :integer, :default => 0
end
def self.down
remove_column :computers, ram_us... | Ruby |
class CreateVirusDatabases < ActiveRecord::Migration
def self.up
create_table :virus_databases do |t|
t.integer :software_id
t.integer :computer_id
t.timestamps
end
end
def self.down
drop_table :virus_databases
end
end
| Ruby |
class CreateEvents < ActiveRecord::Migration
def self.up
create_table :events do |t|
t.string :information
t.boolean :state
t.timestamps
end
end
def self.down
drop_table :events
end
end
| Ruby |
class CreateRooms < ActiveRecord::Migration
def self.up
create_table :rooms do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :rooms
end
end
| Ruby |
class CreateViri < ActiveRecord::Migration
def self.up
create_table :viri do |t|
t.string :name
t.integer :virus_types_id
t.timestamps
end
end
def self.down
drop_table :viri
end
end
| Ruby |
class AddComputerRoom < ActiveRecord::Migration
def self.up
add_column :computers, :room_id, :int
end
def self.down
remove_column :computers, room_id
end
end
| Ruby |
class CreateSoftwares < ActiveRecord::Migration
def self.up
create_table :softwares do |t|
t.string :name
t.datetime :end_licence
t.timestamps
end
end
def self.down
drop_table :softwares
end
end
| Ruby |
class CreateBaseVirale < ActiveRecord::Migration
def self.up
create_table :base_virales do |t|
t.integer :antivirus_id
t.integer :computer_id
t.datetime :last_update
t.timestamps
end
end
def self.down
drop_table :base_virales
end
end | Ruby |
class AddEventComputerType < ActiveRecord::Migration
def self.up
add_column :events, :computer_id, :int
add_column :events, :type_event_id, :int
end
def self.down
remove_column :events, computer_id
remove_column :events, type_event_id
end
end
| Ruby |
class CreateVirusTypes < ActiveRecord::Migration
def self.up
create_table :virus_types do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :virus_types
end
end
| Ruby |
class AddOsComputer < ActiveRecord::Migration
def self.up
add_column :computers, :os, :string, :default => "windows XP"
add_column :computers, :software_id, :integer
end
def self.down
remove_column :computers, :os
remove_column :computers, :antivirus_id
end
end | Ruby |
class CreateComputers < ActiveRecord::Migration
def self.up
create_table :computers do |t|
t.string :mac_adress
t.string :ip_computer
t.int :ram
t.int :cpu
t.int :hard_drive
t.boolean :state_computer
t.boolean :state_agent
t.timestamps
end
end
def self.dow... | Ruby |
class AddColunmComputer < ActiveRecord::Migration
def self.up
add_column :computers, :ram, :integer
add_column :computers, :cpu, :integer
add_column :computers, :hard_drive, :integer
end
def self.down
remove_column :computers, ram
remove_column :computers, cpu
remove_column :computers... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.