code
stringlengths
1
1.73M
language
stringclasses
1 value
class Produce < ActiveRecord::Base set_primary_key :pro_id end
Ruby
class ApplicationController < ActionController::Base protect_from_forgery end
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. Coffee2go::Application.config.session_store :cookie_store, key: '_coffee_2go_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 "ra...
Ruby
Coffee2go::Application.routes.draw do # The priority is based upon order of creation: # first created -> highest priority. # Sample of regular route: # match 'products/:id' => 'catalog#view' # Keep in mind you can assign values other than :controller and :action # Sample of named route: # match 'pro...
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 Coffee2go::Application.initialize!
Ruby
Coffee2go::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.acti...
Ruby
Coffee2go::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 ...
Ruby
Coffee2go::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 ...
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run Coffee2go::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__) Coffee2go::Application.load_tasks
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 CreateCarts < ActiveRecord::Migration def change create_table :carts do |t| t.references :user t.string "image", :limit => 60 t.string "name", :limit => 40 t.string "email", :limit => 30 t.date "time" t.column :available,'integer unsigned', :limit => 6 t.column :buy,'integer unsigned', ...
Ruby
class CreateProduces < ActiveRecord::Migration def change create_table :produces do |t| t.references :cart t.string "image", :limit => 60 t.string "name", :limit => 40 t.string "origin", :limit => 30 t.date "end_day" t.text "description" t.column :available,'integer unsigned', :limit => 6 ...
Ruby
class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.string "email", :limit => 30 t.string "password", :limit => 20 t.string "name", :limit => 30 t.string "phone", :limit => 15 t.string "address", :limit => 50 t.column :admin, :boolean, :default =...
Ruby
class CreateEnds < ActiveRecord::Migration def change create_table :ends do |t| t.references :cart t.string "name", :limit => 40 t.string "email", :limit => 30 t.date "time" t.column :price,'integer unsigned', :limit => 10 t.timestamps end end end
Ruby
class CreateNews < ActiveRecord::Migration def change create_table :news do |t| t.string "image", :limit => 60 t.string "name", :limit => 40 t.text "description" t.date "time" t.timestamps end end end
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__) Coffee2go::Application.load_tasks
Ruby
source 'https://rubygems.org' gem 'rails', '3.2.1' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'mysql2' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3....
Ruby
module ApplicationHelper end
Ruby
class End < ActiveRecord::Base belongs_to :cart end
Ruby
class Cart < ActiveRecord::Base has_many :produces has_many :ends belongs_to :user end
Ruby
class User < ActiveRecord::Base has_one :cart end
Ruby
class News < ActiveRecord::Base end
Ruby
class Produce < ActiveRecord::Base belongs_to :cart end
Ruby
class ApplicationController < ActionController::Base protect_from_forgery end
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. Coffee2go::Application.config.session_store :cookie_store, key: '_coffee_2go_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 "ra...
Ruby
Coffee2go::Application.routes.draw do # The priority is based upon order of creation: # first created -> highest priority. # Sample of regular route: # match 'products/:id' => 'catalog#view' # Keep in mind you can assign values other than :controller and :action # Sample of named route: # match 'pro...
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 Coffee2go::Application.initialize!
Ruby
Coffee2go::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.acti...
Ruby
Coffee2go::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 ...
Ruby
Coffee2go::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 ...
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run Coffee2go::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__) Coffee2go::Application.load_tasks
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "theme/css" sass_dir = "theme/scss" images_dir = "images" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): output_style = :co...
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 = 'Collaborati...
Ruby
# Raccolta di algoritmi per predirre il valore di un contesto require "similarity/similarity" class Predizione # Funzione per la selezione dell'algoritmo a partire da una stringa def predici(utenti, utente, soil, alg) case alg when "norm" return self.predict_norm(utenti, utente, soil) when "test...
Ruby
# To change this template, choose Tools | Templates # and open the template in the editor. require 'utility/vec_utils' class ExponentialRegression attr_accessor :exp, :amplitude, :error def initialize(train_matrix, train_vector_y) log_vect= VecUtils.logarizzatore(train_vector_y) @exp= self.expone...
Ruby
# To change this template, choose Tools | Templates # and open the template in the editor. class WeightedSum attr_accessor :weight, :soil def initialize (sim_vector, soil=0.5) @weight= sim_vector @soil=soil end def update(sim) (0..sim.size-1).each{|i| self.weight[i]= (self.weight[i]+sim[i])...
Ruby
# To change this template, choose Tools | Templates # and open the template in the editor. require 'matrix' class RidgeRegression attr_accessor :weight,:lambda def initialize(train_matrix, train_vector, lambda=0.5) @lambda= lambda @weight= self.weight_train(train_matrix, train_vector, lambda) end...
Ruby
# Classe per l'applicazione della regressione lineare require 'utility/vec_utils' class LinearRegression attr_accessor :beta1,:beta0, :epsilon def initialize(train_matrix,train_vector) @beta1= self.pendenza(train_vector, train_matrix) @beta0= self.intercetta(train_vector, train_matrix) @epsilon= 0 ...
Ruby
# To change this template, choose Tools | Templates # and open the template in the editor. require 'matrix' require 'utility/vec_utils' class QuadraticRegression attr_accessor :vector def initialize mx,y,degree=2 x= VecUtils.matrix_av_vector(mx) @vector= self.train(x,y,degree) end # Update delle var...
Ruby
# To change this template, choose Tools | Templates # and open the template in the editor. class DataStore attr_accessor :data, :users def initialize(data, users) @data= data @users= users end def data @data end def users @users end def to_print return {'Dati'=>self.data,'Utenti'=>s...
Ruby
# To change this template, choose Tools | Templates # and open the template in the editor. require 'utility/utility' require 'interfaces/data_store' require 'benchmarking/bench' require 'similarity/cosine_sim' require 'similarity/jaccard' require 'similarity/pearson' # Versione attuale class Interfaces attr_accessor...
Ruby
# To change this template, choose Tools | Templates # and open the template in the editor. require 'utility/utility' class Testing def Testing.comparate(indice_utente, soil,ows=1,owsc=1,owscn=1,orr=1,oer=1,orl=1,oqr=1) responso= Util.parser() utenti= responso[0] m1= Util.users_to_matrix(utenti,0) m2= Util....
Ruby
# To change this template, choose Tools | Templates # and open the template in the editor. class Bench #funzione logaritmica base 2 per il calcolo del Discounted Cumulative Gain def log2( x ) Math.log( x ) / Math.log( 2 ) end def sqr ( n ) n * n end def mda(width,height) a = Array.new(width) ...
Ruby
# To change this template, choose Tools | Templates # and open the template in the editor. require 'distance/distance' class DistanceUtils # Data una matrice di array, restituisce una matrice di distanza def DistanceUtils.ddmatrix(matrix) ddmatrix=[] (0..matrix.size-1).each{|i| dvec=[] (0..ma...
Ruby
# Librerie di utility require 'csv' require 'utente' # Trasforma una lista di utenti in una matrice di rating # senza contesto: 0 # contesto 1: 1 # contesto 2: 2 # contesto 3: 3 class Util def Util.users_to_matrix(utenti, contesto) matrix = [] case contesto when 0 utenti.each{|x| matrix.push(x.no_contex...
Ruby
# To change this template, choose Tools | Templates # and open the template in the editor. class VecUtils # Vector multiplier def VecUtils.mul_sum (vector_x,vector_y) mult= 0 (0..vector_x.size-1).each{|i| mult= mult+ vector_x[i]*vector_y[i] } return mult end def VecUtils.sum(vector) re...
Ruby
# To change this template, choose Tools | Templates # and open the template in the editor. class MatrixUtils end
Ruby
# Raccolta di algoritmi per il calcolo della similarità class Similarity end
Ruby
# To change this template, choose Tools | Templates # and open the template in the editor. require 'utente' class Jaccard attr_accessor :testo def initialize() @testo="--------------" end # Copia profonda di un vettore def copia_vet(vet) tmp = [] (0..vet.size-1).each{|i| tmp.push(vet[i])} return tmp...
Ruby
# To change this template, choose Tools | Templates # and open the template in the editor. class Pearson #def initialize end # Sommatoria def st(vet=[]) sum = 0 (0..vet.size-1).each{|i| sum = sum + vet[i] } return sum end # Sommatoria con argomento al quadrato def stq(vet=[]) s...
Ruby
# To change this template, choose Tools | Templates # and open the template in the editor. class CosineSim def initialize end # moltiplica tra loro le componenti di un vettore def vector_mult (vector_x, vector_y) vector_mult= 0 (0..vector_x.size-1).each{|x| vector_mult= vector_mul...
Ruby
# Main, scrivete qua il codice per i test require 'utente' require 'utility/utility' require 'similarity/cosine_sim' require 'similarity/jaccard' require 'similarity/similarity' require 'matrix' require 'predizione/weighted_sum' require 'predizione/linear_regression' require 'predizione/ridge_regression' re...
Ruby
# To change this template, choose Tools | Templates # and open the template in the editor. class Distance # Distanza euclidea def Distance.eclidean(x,y) eu= 0 (0..x.size-1).each{|i| eu=eu + ((x[i]-y[i])**2) } return Math.sqrt(eu) end # Distanza euclidea quadra def Distance.squared_ecl...
Ruby
# To change this template, choose Tools | Templates # and open the template in the editor. class Cluster attr_accessor :centroide,:elementi,:energia,:centroid_vector def initialize(centroide, centroid_vector) @centroide= centroide @elementi= [] @energia= 0.0 @centroid_vector= centroid_vector end ...
Ruby
# To change this template, choose Tools | Templates # and open the template in the editor. require 'utility/distance_utils' require 'utility/vec_utils' require 'clustering/cluster' class SimpleCluster # Il centroid è l'indice dell'utente nella matrice (id-1 in pratica) def SimpleCluster.cluster(centroide,matrix,di...
Ruby
# To change this template, choose Tools | Templates # and open the template in the editor. require 'utility/distance_utils' require 'utility/vec_utils' require 'clustering/cluster' class Hierarchical attr_accessor :clusters,:data,:ddmatrix, :max_dim, :k def initialize(matrix,k=5) @ddmatrix= DistanceUtils.ddmat...
Ruby
# To change this template, choose Tools | Templates # and open the template in the editor. class Centroide def initialize end end
Ruby
# To change this template, choose Tools | Templates # and open the template in the editor. require 'similarity/similarity' require 'predizione/prediction' class Utente attr_accessor :id, :no_context, :context_1, :context_2, :context_3, :predizione def initialize(id, a=[],b=[],c=[],d=[],e=[]) @id = id @...
Ruby
#!/usr/bin/env ruby # DESCRIPTION: parses configuration files compatable with Python's ConfigParser class ConfigParser < Hash def initialize(fname) section = nil key = nil File.open(fname,"r").each_line do |line| unless(line =~ /^#/) begin if line =~ /^(.+?)\s*[=:]\s*(.+)$/ # handle key=value lines ...
Ruby
#!/usr/bin/env ruby # DESCRIPTION: generates textual snort rules based on given parameters module Snort class Rule attr_accessor :action, :proto, :src, :sport, :dir, :dst, :dport, :opts def initialize(kwargs={}) @action = kwargs['action'] || 'alert' @proto = kwargs['proto'] || 'IP' @src = kwargs['src'...
Ruby
#!/usr/bin/env ruby # DESCRIPTION: extends ruby Structs to be outputted as yaml, xml, and json. This is meant to be used as a mixin require 'json' class Array def render_xml(element_name, element) str = "" if element.class == Date str = "<#{element_name}>#{element.strftime("%Y-%m-%d")}</#{element_name}>" els...
Ruby
#!/usr/bin/env ruby # DESCRIPTION: queries collective-intelligence-framework sources require 'json' require 'open-uri' require 'digest/sha1' require 'zlib' require 'base64' require 'configparser' require 'openssl' require 'pp' require 'snort_rule' OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE module CIF class...
Ruby
#!/usr/bin/env ruby # DESCRIPTION: extends ruby Structs to be outputted as yaml, xml, and json. This is meant to be used as a mixin require 'json' class Array def render_xml(element_name, element) str = "" if element.class == Date str = "<#{element_name}>#{element.strftime("%Y-%m-%d")}</#{element_name}>" els...
Ruby
#!/usr/bin/env ruby # DESCRIPTION: parses configuration files compatable with Python's ConfigParser class ConfigParser < Hash def initialize(fname) section = nil key = nil File.open(fname,"r").each_line do |line| unless(line =~ /^#/) begin if line =~ /^(.+?)\s*[=:]\s*(.+)$/ # handle key=value lines ...
Ruby
#!/usr/bin/env ruby # DESCRIPTION: generates textual snort rules based on given parameters module Snort class Rule attr_accessor :action, :proto, :src, :sport, :dir, :dst, :dport, :opts def initialize(kwargs={}) @action = kwargs['action'] || 'alert' @proto = kwargs['proto'] || 'IP' @src = kwargs['src'...
Ruby
#!/usr/bin/env ruby # DESCRIPTION: queries collective-intelligence-framework sources require 'json' require 'open-uri' require 'digest/sha1' require 'zlib' require 'base64' require 'configparser' require 'openssl' require 'pp' require 'snort_rule' OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE module CIF class...
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
#!/usr/bin/env 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 impaire...
Ruby
#!/usr/bin/env 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.log ...
Ruby
#!/usr/bin/env 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 impaire...
Ruby
#!/usr/bin/env 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 impaire...
Ruby
#!/usr/bin/env 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.log ...
Ruby
#!/usr/bin/env 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 impaire...
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