code
stringlengths
1
1.73M
language
stringclasses
1 value
class AddConcursosCentroId < ActiveRecord::Migration def self.up add_column :concursos, :centro_id, :integer end def self.down remove_column :concursos, :centro_id end end
Ruby
class AddPresenciasTipoPresupuesto < ActiveRecord::Migration def self.up # especificar el origen de presupuesto add_column :concursos, :tipo_presupuesto_id, :integer add_column :presencias, :tipo_presupuesto_id, :integer add_column :promociones , :tipo_presupuesto_id, :integer add_column :salida_m...
Ruby
class CreatePuntajeCentroConsumos < ActiveRecord::Migration def self.up create_table :puntaje_centro_consumos do |t| t.column :centro_id, :integer t.column :evaluacion_id, :integer t.column :operacion, :integer t.column :puntos, :integer t.column :created_at, :datetime t.column...
Ruby
class CreateFamilias < ActiveRecord::Migration def self.up create_table :familias do |t| t.column :categoria_id, :integer t.column :empresa_id, :integer t.column :nombre, :string t.column :status_id, :integer t.column :created_at, :datetime t.column :updated_at, :datetime e...
Ruby
class CreatePuntajeMeseros < ActiveRecord::Migration def self.up create_table :puntaje_meseros do |t| t.column :operacion, :integer t.column :puntos, :integer t.column :evaluacion_id, :integer t.column :empleado_id, :integer end add_index :puntaje_meseros, :evaluacion_id a...
Ruby
class CreateConcursos < ActiveRecord::Migration def self.up create_table :concursos do |t| t.column :fecha_inicio, :date, :null => false t.column :fecha_termino, :date, :null => false t.column :status, :integer t.column :nombre, :string, :null => false t...
Ruby
class CreateSalidaMaterialDetalles < ActiveRecord::Migration def self.up create_table :salida_material_detalles do |t| t.column :salida_material_id, :integer t.column :clave, :string t.column :descripcion, :string t.column :cantidad, :integer t.column :precio, :decimal, :precision =>...
Ruby
class AddBonificacionesAplicableA < ActiveRecord::Migration def self.up add_column :bonificaciones, :aplicable_a, :integer, :default => 1 end def self.down remove_column :bonificaciones, :aplicable_a end end
Ruby
class AddExistenciasUnidadMedida < ActiveRecord::Migration def self.up add_column :existencias, :unidad_medida_id, :integer end def self.down remove_column :existencias, :unidad_medida_id end end
Ruby
class CreateRequisicionProductos < ActiveRecord::Migration def self.up create_table :requisicion_productos do |t| t.column :fecha_autorizacion, :datetime t.column :fecha_entrega, :datetime t.column :descripcion, :string t.column :solicitante_id, :integer t.column :autorizador_id, :in...
Ruby
class CreateFacturas < ActiveRecord::Migration def self.up create_table :facturas do |t| t.column :mayorista_id, :integer t.column :fecha_factura, :date t.column :referencia, :string t.column :created_at, :datetime t.column :updated_at, :datetime end end def...
Ruby
class CreateBusquedaConcursos < ActiveRecord::Migration def self.up sql="CREATE VIEW busqueda_concursos AS SELECT centros.concursos.[id], centros.concursos.tipo, centros.concursos.fecha_inicio, "+ "centros.concursos.fecha_termino, centros.concursos.ejecutivo_id,centros.concursos.nombre, centros.concurso...
Ruby
class AddBonificacionFamilia < ActiveRecord::Migration def self.up add_column :bonificaciones, :familia_id, :integer end def self.down remove_column :bonificaciones, :familia_id end end
Ruby
class CreateCompromisos < ActiveRecord::Migration def self.up create_table :compromisos do |t| t.column :descripcion, :text t.column :responsable, :integer, :null => false t.column :importe, :decimal, :null => true end end def self.down drop_table :compromisos end end
Ruby
class AddPresupuestoReservaEjecutivoId < ActiveRecord::Migration def self.up add_column :presupuesto_reservas, :ejecutivo_id, :integer, :default => 0 end def self.down remove_column :presupuesto_reservas, :ejecutivo_id end end
Ruby
class CreateMayoristas < ActiveRecord::Migration def self.up create_table :mayoristas do |t| t.column :nombre, :string end end def self.down drop_table :mayoristas end end
Ruby
class AddSolicitudMaterialesNombre < ActiveRecord::Migration def self.up add_column :solicitud_materiales, :nombre, :string remove_column :solicitud_materiales, :tipo_presupuesto_id end def self.down remove_column :solicitud_materiales, :nombre add_column :solicitud_materiales, :tipo_presupuesto_...
Ruby
class CreateBonificaciones < ActiveRecord::Migration def self.up create_table :bonificaciones do |t| t.column :convenio_id, :integer, :null => false t.column :marca_id, :integer, :null => false t.column :porcentaje, :integer, :null => false t.column :destino, :integer, ...
Ruby
#!/opt/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
#!/opt/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
#!/opt/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
#!/opt/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
#!/opt/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
#!/opt/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' 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
# 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.3...
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 end
Ruby
module Admin::CatalogsHelper end
Ruby
class CatalogValue < ActiveRecord::Base belongs_to :catalog validates_presence_of :name, :alternate_value_id validates_uniqueness_of :name, :alternate_value_id, :scope => [:catalog_id] validates_numericality_of :catalog_id, :parent_value_id, :allow_nil => true end
Ruby
class Catalog < ActiveRecord::Base has_many :catalog_values validates_presence_of :name validates_uniqueness_of :name validates_numericality_of :parent_id, :allow_nil => true # agrega un nuevo item en los valores del catálogo # validando si existe el mismo alternate_value_id o el mismo nombre # devu...
Ruby
class Admin::CatalogsController < ApplicationController def index list render :action => "list" end def show end def new @catalog = Catalog.new @catalogs = Catalog.find(:all, :order => 'name') end def list @catalogs = Catalog.paginate :page => params[:page] end def ...
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
# 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/dbconsole'
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/dbconsole'
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 CreateCatalogs < ActiveRecord::Migration def self.up create_table :catalogs do |t| t.string :name t.text :description t.integer :parent_id, :allow_nil => true t.timestamps end end def self.down drop_table :catalogs end end
Ruby
class CreateCatalogValues < ActiveRecord::Migration def self.up create_table :catalog_values do |t| t.string :name t.string :alternate_value_id t.references :catalog t.boolean :is_active, :default => true t.integer :parent_value_id t.timestamps end end def self.down ...
Ruby
#!/opt/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
#!/opt/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
#!/opt/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
#!/opt/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
#!/opt/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
#!/opt/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' 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
module PhysicalPoly def zero_vector() CP::Vec2.new(0,0) end def create_pyhsical_poly(x, y, mass, collision_tag) moment_of_inertia = CP.moment_for_circle(mass, 5,0, zero_vector) body = CP::Body.new(mass, moment_of_inertia) @shape = CP::Shape::Circle.new(body, 5,zero_vector) @shape.collision_t...
Ruby
require 'rubygems' require "enumerator" require 'physical_poly' include PhysicalPoly class Block MASS = 50 def initialize(window, space, x, y) @window = window @space = space @bounds = [CP::Vec2.new(5,2), CP::Vec2.new(3,-5), CP::Vec2.new(-3,-5), CP::Vec2.new(-5,2), CP::Vec2.new(0,5)] create_pyhsi...
Ruby
require 'rubygems' require "enumerator" require 'physical_barrier' include PhysicalBarrier class Floor def initialize(window, space, x, y, angle, length) @window = window @space = space @length = length create_pyhsical_barrier(x, y, angle, :floor) end def draw draw_barrier end def fr...
Ruby
module PhysicalBarrier def zero_vector() CP::Vec2.new(0,0) end def infinity return 1/0.0 end def create_pyhsical_barrier(x, y, a, collision_tag) moment_of_inertia, mass = infinity, infinity body = CP::Body.new(mass, moment_of_inertia) @shape = CP::Shape::Segment.new(body, start_vec, e...
Ruby
require 'rubygems' require 'gosu' require 'chipmunk' require 'block' require 'floor' include Gosu class Game < Window PHYSICS_RESOLUTION = 50 PHYSICS_TIME_DELTA = 1.0/350.0 VISCOUS_DAMPING = 0.7 GRAVITY = 30.0 X_RES = 640 Y_RES = 480 def initialize super(X_RES, Y_RES, false) setup_gosu_and_chipm...
Ruby
description "Generate a compass extension." file 'stylesheets/main.sass', :to => "stylesheets/_#{File.basename(options[:pattern_name]||options[:project_name]||'main')}.sass" file 'templates/project/manifest.rb' file 'templates/project/screen.sass' help %Q{ To generate a compass extension: compass create my_extens...
Ruby
# Make sure you list all the project template files here in the manifest. stylesheet 'screen.sass', :media => 'screen, projection'
Ruby
description "Plugin for cross-browser ellipsis truncated text." file 'xml/ellipsis.xml', :like => :css stylesheet 'ellipsis.sass' help %Q{ First, install the plugin to get the xml file that makes this work in firfox: compass init --using blueprint/link_icons Then mix +ellipsis into your selectors to enable ellips...
Ruby
description "The default project layout." stylesheet 'screen.sass', :media => 'screen, projection' stylesheet 'print.sass', :media => 'print' stylesheet 'ie.sass', :media => 'screen, projection', :condition => "IE"
Ruby
description "Button Plugin" stylesheet 'buttons.sass', :media => 'screen, projection' image 'buttons/cross.png' image 'buttons/key.png' image 'buttons/tick.png' help %Q{ To install the button plugin: compass init --using blueprint/buttons The buttons.sass file is just a recommendation to show you how to use the bu...
Ruby
description "Icons for common types of links" stylesheet "link_icons.sass", :media => 'screen, projection' image 'link_icons/doc.png' image 'link_icons/email.png' image 'link_icons/external.png' image 'link_icons/feed.png' image 'link_icons/im.png' image 'link_icons/pdf.png' image 'link_icons/visited.png' image 'link...
Ruby
description "A basic blueprint install that mimics the actual blueprint css." stylesheet 'screen.sass', :media => 'screen, projection' stylesheet 'partials/_base.sass' stylesheet 'print.sass', :media => 'print' stylesheet 'ie.sass', :media => 'screen, projection', :condition => "lt IE 8" image 'grid.png' help %...
Ruby
description "The blueprint framework for use with semantic markup." stylesheet 'screen.sass', :media => 'screen, projection' stylesheet 'partials/_base.sass' stylesheet 'partials/_form.sass' stylesheet 'partials/_page.sass' stylesheet 'partials/_two_col.sass' stylesheet 'print.sass', :media => 'print' stylesheet 'ie....
Ruby
description "The blueprint framework." stylesheet 'screen.sass', :media => 'screen, projection' stylesheet 'partials/_base.sass' stylesheet 'print.sass', :media => 'print' stylesheet 'ie.sass', :media => 'screen, projection', :condition => "lt IE 8" image 'grid.png' help %Q{ Please see the blueprint website for...
Ruby
module CP # Chipmunk Object # Makes it easier to manage complex objects that reference many primitive Chipmunk objects such as bodies shapes and constraints. # New composite objects simply need to include CP::Object and call #init_chipmunk_object(*objects) with the # composite and primitive Chipmunk objects that ma...
Ruby
module CP # Chipmunk Object # Makes it easier to manage complex objects that reference many primitive Chipmunk objects such as bodies shapes and constraints. # New composite objects simply need to include CP::Object and call #init_chipmunk_object(*objects) with the # composite and primitive Chipmunk objects that ma...
Ruby
# Chipmunk Game Dynamics. Provides fast, easy to use, robust physics. module CP # The bias coefficient used for resolving penetrations. Setting 0.0 effectively disables # penetration resolution. Setting 1.0 will try to resolve the penetration in a single step. # (not recommended) attr_accessor :bias_coef ...
Ruby
require 'rubygems' require_gem 'RedCloth' cdocs = 'chipmunk-docs' rc_cdocs = RedCloth.new(File.read(cdocs + '.textile')) html_cdocs = <<HTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="e...
Ruby
require 'mkmf' system 'cp ../src/* ./' $CFLAGS += ' -std=gnu99 -ffast-math' create_makefile('chipmunk')
Ruby
VERS = ARGV[0] raise("No version number!") unless VERS def system(command) puts command Kernel.system(command) end DIR = "/tmp/Chipmunk-#{VERS}" system("rsync Chipmunk-#{VERS}.tgz slembcke.net:files.slembcke.net/chipmunk/release/Chipmunk-5.x/") system("rsync -r --exclude='doc-src' #{DIR}/doc/ slembcke.net:files.sl...
Ruby
module CP # Chipmunk Object # Makes it easier to manage complex objects that reference many primitive Chipmunk objects such as bodies shapes and constraints. # New composite objects simply need to include CP::Object and call #init_chipmunk_object(*objects) with the # composite and primitive Chipmunk objects that ma...
Ruby
VERS = ARGV[0] raise("No version number!") unless VERS def system(command) puts command Kernel.system(command) end DIR = "/tmp/Chipmunk-#{VERS}" # Build Objective-Chipmunk system("cd ../Objective-Chipmunk; ruby BuildReleaseArchive.rb #{VERS}") # Export, clean, and prepare system("rm -rf #{DIR}") system("svn expor...
Ruby
require 'rubygems' require 'redcloth' html = <<HTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <t...
Ruby