code
stringlengths
1
1.73M
language
stringclasses
1 value
require 'optparse' module AhpTools module CLI class NewProject def self.execute(stdout, arguments=[]) options = { :quiet => false, :repository => "Dummy filesystem repo", :life_cycle_model => "Example Life-Cycle Model", :stamp_style => "teamCity", ...
Ruby
require 'optparse' module AhpTools module CLI class SetSecurity attr_reader :options def initialize() @options = { :resource_type => nil, :resource_name => nil, :role => nil, :action => nil, :remove => false, :no_exec => false, ...
Ruby
require 'optparse' module AhpTools module CLI class NewEnvironments def self.execute(stdout, arguments=[]) options = { :verbose => true, :environments => [] } mandatory_options = %w( environments group ) parser = OptionParser.new do |opts| o...
Ruby
require 'optparse' module AhpTools module CLI class AddStatusSteps def self.execute(stdout, arguments=[]) options = { :job => "blah", } mandatory_options = %w( job ) parser = OptionParser.new do |opts| opts.banner = <<-BANNER.gsub(/^ /,'') ...
Ruby
require 'optparse' module AhpTools module CLI class AddAgents def self.execute(stdout, arguments=[]) options = { :agents => "", :env => "" } parser = OptionParser.new do |opts| opts.banner = <<-BANNER.gsub(/^ /,'') Add one or mor...
Ruby
#!/usr/bin/ruby # jsmin.rb 2007-07-20 # Author: Uladzislau Latynski # This work is a translation from C to Ruby of jsmin.c published by # Douglas Crockford. Permission is hereby granted to use the Ruby # version under the same conditions as the jsmin.c on which it is # based. # # /* jsmin.c # 2003-04-21 # # Copyrig...
Ruby
#!/usr/bin/ruby # jsmin.rb 2007-07-20 # Author: Uladzislau Latynski # This work is a translation from C to Ruby of jsmin.c published by # Douglas Crockford. Permission is hereby granted to use the Ruby # version under the same conditions as the jsmin.c on which it is # based. # # /* jsmin.c # 2003-04-21 # # Copyrig...
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
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
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 'sinatra/activerecord/rake' require './main'
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
$: << 'lib' unless $:.include?('lib')
Ruby
#!/usr/local/bin/ruby $: << ".." require "fann" include Fann puts "-> create new neural network." nn = Ann.new([2, 4, 1], 1.0, 0.7) puts "-> setup neural network parameter." nn.training_algorithm = TRAIN_QUICKPROP nn.activation_function_hidden = SIGMOID_SYMMETRIC_STEPWISE nn.activation_function_output = SIGMOID_SYM...
Ruby
#!/usr/local/bin/ruby $: << ".." require "fann" include Fann puts "-> create new neural network." nn = Ann.new([2, 4, 1], 1.0, 0.7) puts "-> setup neural network parameter." nn.training_algorithm = TRAIN_QUICKPROP nn.activation_function_hidden = SIGMOID_SYMMETRIC_STEPWISE nn.activation_function_output = SIGMOID_SYM...
Ruby
$: << File.join(File.dirname(__FILE__), '..', 'lib') require 'ann' puts "-> create new neural network." nn = Ann::Network.new(2, 4, 1) puts "-> training data load." td = [[[-1,-1],[-1]],[[-1,1],[1]],[[1,-1],[1]],[[1,1],[-1]]] puts "-> training neural network." nn.train(td, 30000, 10, 0.00001){|epoch, error| puts "...
Ruby
require 'rake/testtask' task :default => [:test] Rake::TestTask.new do |t| t.libs << 'test' t.pattern = 'test/**/*_test.rb' t.verbose = true end
Ruby
require 'yaml' YAML.add_domain_type( "stadig.name,2006", "Ann::Neuron" ) do |type, val| n = YAML.object_maker(Ann::Neuron, val) n.instance_variable_set('@activation', Ann::Sigmoid) n.instance_variable_set('@actder', Ann::SigDer) n end module Ann Sigmoid = Proc.new {|i| 1 / (1 + Math.exp(-i))} SigDer = Pro...
Ruby
require 'yaml' module Ann # An input neuron is used in the first layer of a neural network to feed the # input values into the network. It should return its most current value as # a float from the output method. class InputNeuron def self.new_layer(values) values.collect {|i| InputNeuron.ne...
Ruby
require 'ann/neuron' require 'ann/input_neuron' module Ann class Network attr_reader :layers def initialize(*desc) work = desc.clone prev_layer = [] work.shift.times do prev_layer << InputNeuron.new end @layers = [prev_layer] # Create the layers ...
Ruby
require 'ann/network' require 'ann/neuron' require 'ann/input_neuron'
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: 'Emanuel...
Ruby
class CreateFaqs < ActiveRecord::Migration def change create_table :faqs do |t| t.string :question t.string :answer t.timestamps end end end
Ruby
class CreatePrograms < ActiveRecord::Migration def change create_table :programs do |t| t.string :name t.text :description t.string :image_link t.string :colour_id t.timestamps end end end
Ruby
class AddAttachmentPhotoToPrograms < ActiveRecord::Migration def self.up change_table :programs do |t| t.has_attached_file :photo end end def self.down drop_attached_file :programs, :photo end end
Ruby
class CreatePrograms < ActiveRecord::Migration def change create_table :programs do |t| t.string :name t.text :description t.string :image_link t.timestamps end end end
Ruby
class CreateEvents < ActiveRecord::Migration def change create_table :events do |t| t.string :title t.text :description t.date :start_date t.date :end_date t.date :deadline t.string :registration_link t.string :location t.integer :type t.string :image_path ...
Ruby
class CreateProjects < ActiveRecord::Migration def change create_table :projects do |t| t.integer :program t.string :name t.text :description t.text :summary t.string :registration_link t.string :image_link t.integer :exchange t.timestamps end end end
Ruby
class AddAttachmentPhotoToEvents < ActiveRecord::Migration def self.up change_table :events do |t| t.attachment :photo end end def self.down drop_attached_file :events, :photo end end
Ruby
class AddAttachmentPhotoToProjects < ActiveRecord::Migration def self.up change_table :projects do |t| t.has_attached_file :photo end end def self.down drop_attached_file :projects, :photo end end
Ruby
class CreatePartners < ActiveRecord::Migration def change create_table :partners do |t| t.string :name t.string :image_link t.string :page_link t.timestamps end end end
Ruby
class CreateTestimonials < ActiveRecord::Migration def change create_table :testimonials do |t| t.string :image_link t.string :country t.integer :program t.timestamps end end end
Ruby
class CreateCountries < ActiveRecord::Migration def change create_table :countries do |t| t.string :name t.integer :project_id t.timestamps end end end
Ruby
class CreateProjects < ActiveRecord::Migration def change create_table :projects do |t| t.integer :program t.string :countries t.string :name t.text :description t.string :registration_link t.string :image_link t.integer :type t.timestamps end end end
Ruby
class AddAttachmentPhotoToPartners < ActiveRecord::Migration def self.up change_table :partners do |t| t.attachment :photo end end def self.down drop_attached_file :partners, :photo end end
Ruby
class AddAttachmentPhotoToTestimonials < ActiveRecord::Migration def self.up change_table :testimonials do |t| t.has_attached_file :photo end end def self.down drop_attached_file :testimonials, :photo end end
Ruby
class CreateAdmins < ActiveRecord::Migration def change create_table :admins do |t| t.string :login t.string :crypted_password t.string :password_salt t.integer :access_level t.integer :access_type t.string :persistence_token t.string :perishable_token t.timestamps...
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. # # Note: You'll currently still have to declare fixtures explicitly in integrati...
Ruby
#!/usr/bin/env rake # 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.expand_path('../config/application', __FILE__) Website::Application.load_tasks
Ruby
source 'https://rubygems.org' gem 'rails', '3.2.8' gem 'authlogic' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'sqlite3' gem 'paperclip', '~> 3.0' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails'...
Ruby
#!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands'
Ruby
#!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands'
Ruby
module ApplicationHelper end
Ruby
module AdminSessionsHelper end
Ruby
module EventsHelper end
Ruby
module TestimonialsHelper end
Ruby
module ProjectsHelper end
Ruby
module FaqsHelper end
Ruby
module ProgramsHelper end
Ruby
class Partner < ActiveRecord::Base attr_accessible :image_link, :name, :page_link, :photo has_attached_file :photo, :url => "/assets/partners/:id/:style/:basename.:extension", :path => ":rails_root/public/assets/partners/:id/:style/:basename.:extension" end
Ruby
class Admin < ActiveRecord::Base acts_as_authentic do |c| c.merge_validates_length_of_password_field_options :minimum => 6 end attr_accessible :access_level, :access_type, :login, :password, :password_confirmation end
Ruby
class AdminSession < Authlogic::Session::Base end
Ruby
class Event < ActiveRecord::Base attr_accessible :deadline, :description, :end_date, :image_path, :location, :registration_link, :start_date, :title, :type, :photo has_attached_file :photo, :url => "/assets/events/:id/:style/:basename.:extension", :path => ":rails_root/publi...
Ruby
class Program < ActiveRecord::Base attr_accessible :description, :image_link, :name ,:photo has_attached_file :photo, :url => "/assets/events/:id/:style/:basename.:extension", :path => ":rails_root/public/assets/events/:id/:style/:basename.:extension" validates_attachm...
Ruby
class Project < ActiveRecord::Base attr_accessible :countries, :description, :image_link, :name, :program, :registration_link, :exchange, :summary, :photo has_attached_file :photo, :url => "/assets/events/:id/:style/:basename.:extension", :path => ":rails_root/public/ass...
Ruby
class Testimonial < ActiveRecord::Base attr_accessible :country, :image_link, :program, :photo has_attached_file :photo, :url => "/assets/testimonials/:id/:style/:basename.:extension", :path => ":rails_root/public/assets/testimonials/:id/:style/:basename.:extension" valid...
Ruby
class Faq < ActiveRecord::Base attr_accessible :answer, :question end
Ruby
class Country < ActiveRecord::Base attr_accessible :name, :project_id end
Ruby
class PartnersController < ApplicationController def new @partner = Partner.new end def create @partner = Partner.create(params[:partner]) if @partner.save redirect_to :action => "index" flash[:notice] = "Partner Created $blue" end end def index @partners = Partner.all end def destroy @p...
Ruby
class EventsController < ApplicationController def test @events = Event.order("events.start_date DESC") @event = Event.find(params[:id]) end def show @events = Event.order("events.start_date DESC") @event_show = Event.find(params[:id]) @event = Event.new $errors = false end def new @events = Event...
Ruby
class ApplicationController < ActionController::Base protect_from_forgery helper_method :current_admin_session, :current_admin , :admin_authenticated? before_filter :getProjects ,:getPrograms private def current_admin_session return @current_admin_session if defined?(@current_admin_session) @curren...
Ruby
class ProjectsController < ApplicationController def index @projects = Project.all @program = Program.find(3) end def show @projects = Project.all @project= Project.find(params[:id]) @allTestimonials = Testimonial.all end def new @project = Project.new end def create @project = Project.new(p...
Ruby
class TestimonialsController < ApplicationController def index @testimonials = Testimonial.all end def new @testimonial = Testimonial.new end def create @testimonial = Testimonial.new(params[:testimonial]) if @testimonial.save flash[:notice] = "Testimonial Created $green" redirect_to :action => "i...
Ruby
class AdminSessionsController < ApplicationController def new render layout: "admin_layout" @admin_session = AdminSession.new end def create @admin_session = AdminSession.new(params[:admin_session]) if @admin_session.save flash[:notice] = "Logged in successfuly $green" redirect_to :contr...
Ruby
class FaqsController < ApplicationController def index @faqs = Faq.all end def new @faq = Faq.new end def create @faq = Faq.new(params[:faq]) if @faq.save redirect_to(:action => 'index') else render('new') end end def edit @faq = Faq.find(params[:id]) end def update @faq = Faq....
Ruby
class CountriesController < ApplicationController end
Ruby
class ProgramsController < ApplicationController def index @programs = Program.all end def show @program= Program.find(params[:id]) @allTestimonials = Testimonial.all @allProjects = Project.all end def new @program = Program.new end def create @program = Program.new(params[:program]) if @p...
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 to debug a probl...
Ruby
# Be sure to restart your server when you modify this file. # # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do wrap_parameters ...
Ruby
# Be sure to restart your server when you modify this file. # Your secret key for verifying the integrity of signed cookies. # If you change this key, all old signed cookies 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 attac...
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. Website::Application.config.session_store :cookie_store, key: '_website_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the session table with "rails g...
Ruby
Website::Application.routes.draw do resources :events resources :programs resources :projects match 'logout', :controller => 'admin_sessions', :action => 'destroy' resources :admin_sessions resources :faqs resources :testimonials resources :partners end
Ruby
require 'rubygems' # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
Ruby
require File.expand_path('../boot', __FILE__) require 'rails/all' if defined?(Bundler) # If you precompile assets before deploying to production, use this line Bundler.require(*Rails.groups(:assets => %w(development test))) # If you want your assets lazily compiled in production, use this line # Bundler.requi...
Ruby
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application Website::Application.initialize!
Ruby
Website::Application.configure do # Settings specified here will take precedence over those in config/application.rb # Code is not reloaded between requests config.cache_classes = true # Full error reports are disabled and caching is turned on config.consider_all_requests_local = false config.action...
Ruby
Website::Application.configure do # Settings specified here will take precedence over those in config/application.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 web se...
Ruby
Website::Application.configure do # Settings specified here will take precedence over those in config/application.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 su...
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run Website::Application
Ruby
#!/usr/bin/env rake # 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.expand_path('../config/application', __FILE__) Website::Application.load_tasks
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
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
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 'sinatra/activerecord/rake' require './main'
Ruby
class CreateEstadosCuenta < ActiveRecord::Migration def self.up create_table :estados_cuenta do |t| t.string :descripcion t.timestamps end end def self.down drop_table :estados_cuenta end end
Ruby
class CreateCuentas < ActiveRecord::Migration def self.up create_table :cuentas do |t| t.string :razon_social t.date :fecha_apertura t.date :fecha_cierre t.integer :estado_cuenta_id t.integer :contacto_id t.string :rubro t.timestamps end end def self.down drop_table :cuenta...
Ruby
class CreateVentas < ActiveRecord::Migration def self.up create_table :ventas do |t| t.integer :producto_id t.date :fecha_facturacion t.timestamps end end def self.down drop_table :ventas end end
Ruby
class CreatePrecios < ActiveRecord::Migration def self.up create_table :precios do |t| t.float :tarifa_trainee t.date :fecha_creacion t.timestamps end end def self.down drop_table :precios end end
Ruby
class CreateNoticias < ActiveRecord::Migration def self.up create_table :noticias do |t| t.string :titulo t.date :fecha t.integer :user_id t.text :contenido t.timestamps end end def self.down drop_table :noticias end end
Ruby
class CreateEstadosTrainee < ActiveRecord::Migration def self.up create_table :estados_trainee do |t| t.string :descripcion t.timestamps end end def self.down drop_table :estados_trainee end end
Ruby
class CreateCuentasTrainee < ActiveRecord::Migration def self.up create_table :cuentas_trainee do |t| t.integer :cuenta_id t.integer :trainee_id t.date :fecha_ingreso t.date :fecha_egreso t.text :observaciones t.timestamps end end def self.down drop_table :cuentas_train...
Ruby
class CreateReportes < ActiveRecord::Migration def self.up create_table :reportes do |t| t.integer :user_id t.integer :equipo_id t.date :fecha_desde t.date :fecha_hasta t.string :titulo t.text :observaciones t.timestamps end end def self.down drop_table :reportes end end
Ruby