code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
#!/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 ItemsHelper
end
| Ruby |
class Owner < ActiveRecord::Base
has_many :items
def inhaber=(text)
base = Base64.b64encode(Digest::SHA1.digest("z5_#{text}v!?"))
cont = Base64.b64encode(Digest::SHA1.digest("ihihwer_#{Time.now.utc}%&/(!?"))
self.checker=base
write_attribute(:inhaber, "#{base[1..20].gsub(/\+/, '_')}#{cont[1.... | Ruby |
require 'digest/sha1'
class Item < ActiveRecord::Base
belongs_to :owner
def description=(description)
description = "Double-Click me!" if description.nil? or description == ""
write_attribute(:description,description)
end
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
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForg... | Ruby |
class ItemsController < ApplicationController
# GET /items
# GET /items.xml
before_filter :checkPermission, :except=>[:index,:new,:copy]
in_place_edit_for :owner, :titel
def index
@rolle = getRolle(params[:r])
@items = @owner.items.find(:all, :order => "number ASC")
#remo... | 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 :items, :collection => {:copy => :get}
# 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 ca... | 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.3' 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 |
# 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 |
# 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 |
# 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.1... | 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 |
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 |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
include TagsHelper
end
| Ruby |
module StylesheetsHelper
# Internet Exploder hacks.
# <% ie6 do %>
# css for ie6 here
# <% end %>
def ie6(&block)
wrap '* html', &block
end
# <% ie7 do %>
# css for ie7 here
# <% end %>
def ie7(&block)
wrap '* + html', &block
end
# <% ie do %>
# css for ie here
# <% end %>
... | Ruby |
module ChecklistHelper
end
| Ruby |
class Checklist < ActiveRecord::Base
has_many :items
validates_presence_of :name
validates_uniqueness_of :name
acts_as_sphinx
acts_as_taggable
end | Ruby |
class Item < ActiveRecord::Base
belongs_to :checklist
validates_presence_of :description
end
| Ruby |
class ChecklistController < ApplicationController
def index
@tags = Checklist.tag_counts
end
# def tag_cloud
# @tags = Checklist.tag_counts
# end
def new
@checklist = Checklist.new(params[:checklist])
@checklist.items.build(params[:items])
@items = @checklist.items
end
def edit
@ch... | 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 StylesheetsController < ApplicationController
before_filter :set_headers
after_filter { |controller| controller.cache_page }
session :off
layout nil
private
def set_headers
headers['Content-Type'] = 'text/css; charset=utf-8'
end
end
| 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 |
#!/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/runner'
| 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/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/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/plugin'
| 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/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/console'
| 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/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'
require 'commands/about'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin'
| Ruby |
class ActsAsTaggableMigration < ActiveRecord::Migration
def self.up
create_table :tags do |t|
t.column :name, :string
end
create_table :taggings do |t|
t.column :tag_id, :integer
t.column :taggable_id, :integer
# You should make sure that the column created is... | Ruby |
class CreateChecklists < ActiveRecord::Migration
def self.up
create_table :checklists do |t|
t.column :name, :string
t.timestamps
end
end
def self.down
drop_table :checklists
end
end
| Ruby |
class CreateItems < ActiveRecord::Migration
def self.up
create_table :items do |t|
t.column :description, :string
t.timestamps
end
end
def self.down
drop_table :items
end
end
| Ruby |
class AssociateItemsToChecklist < ActiveRecord::Migration
def self.up
add_column :items, :checklist_id, :integer
end
def self.down
remove_column :items, :checklist_id
end
end | 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 |
require File.dirname(__FILE__) + "/../test_helper"
require "unit_record"
ActiveRecord::Base.disconnect! | 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 |
# $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 |
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 |
# -- ChelloTraffic Widget --
# data retriever script
# by Gábor Sebestyén <segabor@chello.hu>, 2006
# http://chellotraffic.uw.hu
require 'net/http'
require 'net/https'
require 'uri'
# parse traffic of current month
#
def process_current_month
out = ""
r = yield
case r.body
when /<strong>Hiba<\/strong... | Ruby |
VERREGEX = /<key>CFBundleVersion<\/key>\s+<string>([0-9.]+)<\/string>/
File.open("Info.plist") do |f|
plist = f.read
if plist =~ VERREGEX
print $1
else
print "0.0.0"
end
end
| Ruby |
#!/usr/bin/env ruby
# encoding: utf-8
project = 'battery-indicator'
user = `cat ~/.netrc | awk '{print $4;}'`.strip
pass = `cat ~/.netrc | awk '{print $6;}'`.strip
version = `grep "android:versionName=" AndroidManifest.xml`.split('"')[1]
apk_location = "BatteryIndicatorPro-#{version}.apk"
system("cp bin/*-release.ap... | Ruby |
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
LANGS_URI = 'http://ath.darshancomputing.com/bi/langs/'
langs = Net::HTTP.get(URI.parse(LANGS_URI)).split()
langs.each do |lang|
if lang.length == 2
dir = 'res/values-' << lang
else
dir = 'res/values-' << lang[0,2] << '-r' << lang[2,2]
end
if ! D... | Ruby |
#!/usr/bin/env ruby
require 'nokogiri'
string_to_remove = ['pref_cat_themes',
'theme_settings',
'theme_settings_summary',
'theme_settings_help']
string_files = []
Dir.glob('res/values*').each do |d|
file = d << "/strings.xml"
string_files << file if Fil... | Ruby |
#!/usr/bin/env ruby
# encoding: utf-8
require 'nokogiri'
# read in convert.xml to see which how to convert the string-arrays
# for each strings.xml in res/values res/values-?? res/values-??-*
# find the string-arrays that match the ones in convert.xml and for each
# remove opening and closing string-array tag
#... | Ruby |
require 'RMagick'
class NumberImageGenerator
@@IMAGE_DIR = 'numbers-hdpi/'
def generate(text, fs=18)
#filename = "b" + sprintf("%03d", text) + ".png";
filename = "" + sprintf("%03d", text) + ".png";
font_size = fs;
height = 35;
width = 35;
image = Magick::Image.new(width, height) {self.ba... | Ruby |
#
# To change this template, choose Tools | Templates
# and open the template in the editor.
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/testtask'
require 'spec/rake/spectask'
spec = Gem::Specification.new do |s|
s.name = 'RubyDSL'
... | 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 =>... | Ruby |
class DefaultTrialsAndTravails < ActiveRecord::Migration
def self.up
TrialsAndTravails.delete_all
TrialsAndTravails.create(:name => 'The Hand of War')
TrialsAndTravails.create(:name => 'Press-Ganged')
TrialsAndTravails.create(:name => 'Calamity')
TrialsAndTravails.create(:name => 'Ship-Lorn')... | Ruby |
class DefaultRoles < ActiveRecord::Migration
def self.up
Role.delete_all
Role.create(:name => 'Admin')
Role.create(:name => 'Registered')
Role.create(:name => 'Guest')
end
def self.down
Role.delete_all
end
end
| Ruby |
class AddGenderToCharacters < ActiveRecord::Migration
def self.up
add_column :characters, :gender, :string
end
def self.down
remove_column :characters, :gender
end
end
| Ruby |
class AddRoleIdToUsers < ActiveRecord::Migration
def self.up
add_column :users, :role_id, :integer, :default => Role.find_by_name("Registered").id
end
def self.down
remove_column :users, :role_id
end
end
| Ruby |
class AddUsernameToUsers < ActiveRecord::Migration
def self.up
add_column :users, :username, :string
end
def self.down
remove_column :users, :username
end
end
| Ruby |
class DefaultCareers < ActiveRecord::Migration
def self.up
Career.delete_all
Career.create(:name => 'Astropath Transcendent')
Career.create(:name => 'Arch-Militant')
Career.create(:name => 'Void-Master')
Career.create(:name => 'Explorator')
Career.create(:name => 'Missionary')
Career.... | Ruby |
class AddStatsToCharacters < ActiveRecord::Migration
def self.up
add_column :characters, :weapon_skill, :integer, :null => false
add_column :characters, :ballistic_skill, :integer, :null => false
add_column :characters, :strength, :integer, :null => false
add_column :characters, :toughness, :integer, ... | Ruby |
class AddHomeWorldToCharacters < ActiveRecord::Migration
def self.up
add_column :characters, :home_world_id, :integer
end
def self.down
remove_column :characters, :home_world_id
end
end
| Ruby |
class CreateLureOfTheVoids < ActiveRecord::Migration
def self.up
create_table :lure_of_the_voids do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :lure_of_the_voids
end
end
| Ruby |
class CreateTrialsAndTravails < ActiveRecord::Migration
def self.up
create_table :trials_and_travails do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :trials_and_travails
end
end
| Ruby |
class DeviseCreateUsers < ActiveRecord::Migration
def self.up
create_table(:users) do |t|
t.database_authenticatable :null => false
t.recoverable
t.rememberable
t.trackable
# t.confirmable
# t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
# t.tok... | Ruby |
class CreateBirthrights < ActiveRecord::Migration
def self.up
create_table :birthrights do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :birthrights
end
end
| Ruby |
class AddSessionsTable < ActiveRecord::Migration
def self.up
create_table :sessions do |t|
t.string :session_id, :null => false
t.text :data
t.timestamps
end
add_index :sessions, :session_id
add_index :sessions, :updated_at
end
def self.down
drop_table :sessions
end
end
| Ruby |
class DefaultHomeWorlds < ActiveRecord::Migration
def self.up
HomeWorld.delete_all
HomeWorld.create(:name => 'Death World')
HomeWorld.create(:name => 'Void Born')
HomeWorld.create(:name => 'Forge World')
HomeWorld.create(:name => 'Hive World')
HomeWorld.create(:name => 'Imperial World')
... | Ruby |
class AddTrialsAndTravailsToCharacters < ActiveRecord::Migration
def self.up
add_column :characters, :trials_and_travails_id, :integer
end
def self.down
remove_column :characters, :trials_and_travails_id
end
end
| Ruby |
class CreateHomeWorlds < ActiveRecord::Migration
def self.up
create_table :home_worlds do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :home_worlds
end
end
| Ruby |
class DefaultMotivations < ActiveRecord::Migration
def self.up
Motivation.delete_all
Motivation.create(:name => 'Endurance')
Motivation.create(:name => 'Fortune')
Motivation.create(:name => 'Vengeance')
Motivation.create(:name => 'Renown')
Motivation.create(:name => 'Pride')
Motivatio... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.