code
stringlengths
1
1.73M
language
stringclasses
1 value
class UserNotifier < ActionMailer::Base def signup_notification(user) setup_email(user) @subject += '[Xurse] Please activate your new account' @body[:url] = "http://www.xurse.com/account/activate/#{user.activation_code}" end def activation(user) setup_email(user) @subject += '[Xurse]...
Ruby
class Building < ActiveRecord::Base has_many :plots end
Ruby
class WorldController < ApplicationController def show @world = World.find(params[:id], :include => [:zones]) end end
Ruby
class ZoneController < ApplicationController def show @zone = Zone.find(params[:id], :include => [:cities]) end end
Ruby
class CityController < ApplicationController def show @city = City.find(params[:id], :include => [:plots]) end end
Ruby
class AccountController < ApplicationController layout "main" before_filter :login_required, :only => [ :index, :update_password, :change_email, :change_password ] def index end def show @user = User.find_by_login(params[:id]) end def login if !params[:return_to].nil? session[:return_to] ...
Ruby
class Admin::UserController < ApplicationController layout "main" require_role "Administrator" active_scaffold :user do |config| config.columns = [:login, :email, :activated_at, :password, :password_confirmation, :roles] list.columns.exclude :password, :password_confirmation end end
Ruby
class Admin::RoleController < ApplicationController layout "main" require_role "Administrator" active_scaffold :role do |config| config.columns = [:name] end end
Ruby
class ApplicationController < ActionController::Base include ExceptionLoggable # AuthenticatedSystem must be included for RoleRequirement, and is provided by installing acts_as_authenticates and running 'script/generate authenticated account user'. include AuthenticatedSystem # You can move this into a differen...
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
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
set :application, "xurse" set :repository, "http://xurse.googlecode.com/svn/trunk/" # If you aren't deploying to /u/apps/#{application} on the target # servers (which is the default), you can specify the actual location # via the :deploy_to variable: # set :deploy_to, "/var/www/#{application}" # set :deploy_t...
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 # 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.0...
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
# 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
module AuthenticatedSystem protected # Returns true or false if the user is logged in. # Preloads @current_user with the user model if they're logged in. def logged_in? current_user != :false end # Accesses the current user from the session. def current_user @current_user ||= ...
Ruby
module AuthenticatedTestHelper # Sets the current user in the session from the user fixtures. def login_as(user) @request.session[:user] = user ? users(user).id : nil end def content_type(type) @request.env['Content-Type'] = type end def accept(accept) @request.env["HTTP_ACCEPT"] = accept en...
Ruby
name = XUL Remote type = generic
Ruby
require 'modshogun' require 'pp' require 'load' traindat = LoadMatrix.load_numbers('../data/fm_train_real.dat') testdat = LoadMatrix.load_numbers('../data/fm_test_real.dat') label_traindat = LoadMatrix.load_labels('../data/label_train_twoclass.dat') parameter_list= [[traindat,testdat,label_traindat],[traindat,testdat,...
Ruby
require 'load' require 'modshogun' require 'pp' traindat = LoadMatrix.load_numbers('../data/fm_train_real.dat') testdat = LoadMatrix.load_labels('../data/label_train_twoclass.dat') parameter_list = [[traindat,testdat,1.7], [traindat,testdat,1.6]] def kernel_auc_modular(fm_train_real=traindat,label_train_real=testdat...
Ruby
require 'modshogun' require 'pp' parameter_list=[['../data/train_sparsereal.light']] def features_read_svmlight_format_modular(fname) f=Modshogun::SparseRealFeatures.new lab=f.load_svmlight_file(fname) f.write_svmlight_file('testwrite.light', lab) end if __FILE__ == $0 puts 'Reading SVMLIGHT format' pp feature...
Ruby
require 'modshogun' require 'pp' require 'load' traindat = LoadMatrix.load_numbers('../data/fm_train_real.dat') testdat = LoadMatrix.load_numbers('../data/fm_test_real.dat') parameter_list=[[traindat,testdat, 1.0],[traindat,testdat, 10.0]] def kernel_cauchy_modular(fm_train_real=traindat,fm_test_real=testdat, sigma=...
Ruby
require 'modshogun' require 'load' require 'narray' require 'pp' parameter_list = [[1,7],[2,8]] def classifier_custom_kernel_modular(c=1,dim=7) Modshogun::Math.init_random(c) lab = (2*NArray.float(dim).random! - 1).sign data= NMatrix.float(dim, dim).random! symdata=data*data.transpose + NMatrix.float(dim,dim).u...
Ruby
require 'modshogun' require 'pp' require 'load' data = LoadMatrix.load_numbers('../data/fm_train_real.dat') parameter_list = [[data,10],[data,20]] def converter_hessianlocallylinearembedding_modular(data,k) features = Modshogun::RealFeatures.new features.set_feature_matrix(data) preprocessor = Modshogun::Hes...
Ruby
require 'modshogun' require 'pp' require 'load' ########################################################################### # anova kernel ########################################################################### traindat = LoadMatrix.load_numbers('../data/fm_train_real.dat') testdat = LoadMatrix.load_numbers('../da...
Ruby
require 'modshogun' require 'load' require 'narray' @num = 1000 @dist = 1 @width = 2.1 C = 1 puts "generating training data" traindata_real = gen_rand_ary @num testdata_real = gen_rand_ary @num puts "generating labels" trainlab = gen_ones_vec @num testlab = gen_ones_vec @num puts "doing feature stuff" feats_train =...
Ruby
require 'modshogun' require 'pp' require 'load' traindat = LoadMatrix.load_numbers('../data/fm_train_real.dat') testdat = LoadMatrix.load_numbers('../data/fm_test_real.dat') parameter_list = [[traindat,testdat],[traindat,testdat]] def distance_braycurtis_modular(fm_train_real=traindat, fm_test_real=testdat) feats_...
Ruby
require 'modshogun' require 'pp' require 'load' traindat = LoadMatrix.load_numbers('../data/fm_train_real.dat') testdat = LoadMatrix.load_numbers('../data/fm_test_real.dat') parameter_list=[[traindat,testdat, 1.0],[traindat,testdat, 5.0]] def kernel_circular_modular(fm_train_real=traindat,fm_test_real=testdat, sigma...
Ruby
require 'narray' require 'modshogun' require 'load' require 'pp' traindat = LoadMatrix.load_numbers('../data/fm_train_real.dat') testdat = LoadMatrix.load_numbers('../data/fm_test_real.dat') parameter_list=[[traindat,testdat, 1.3],[traindat,testdat, 1.4]] def kernel_gaussian_modular(fm_train_real=traindat,fm_test_re...
Ruby
require 'load' require 'modshogun' require 'pp' data=LoadMatrix.load_numbers('../data/fm_train_real.dat') label=LoadMatrix.load_numbers('../data/label_train_twoclass.dat') parameter_list=[[data,label]] def features_io_modular(fm_train_real, label_train_twoclass) feats=Modshogun::SparseRealFeatures.new feats.set_f...
Ruby
require 'modshogun' require 'pp' require 'load' traindat = LoadMatrix.load_numbers('../data/fm_train_real.dat') parameter_list = [[traindat,3],[traindat,4]] def clustering_hierarchical_modular(fm_train=traindat,merges=3) feats_train=Modshogun::RealFeatures.new feats_train.set_feature_matrix(fm_train) distance=Mo...
Ruby
require 'modshogun' require 'pp' require 'load' traindat = LoadMatrix.load_numbers('../data/fm_train_real.dat') testdat = LoadMatrix.load_numbers('../data/fm_test_real.dat') label_traindat = LoadMatrix.load_labels('../data/label_train_twoclass.dat') parameter_list = [[traindat,testdat,label_traindat,2.1,1,1e-5,1e-2]...
Ruby
require 'modshogun' require 'load' require 'pp' # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # Written (W) 2011 ...
Ruby
require 'narray' require 'modshogun' # for debugging purposes... #require 'rubygems' #require "pry" def LoadMatrix(filename, type = :numbers) case type when :numbers x = LoadMatrix.load_numbers(filename) pp x when :dna LoadMatrix.load_dna(filename) when :cubes LoadMatrix.load_cubes(filename) ...
Ruby
require 'modshogun' require 'pp' require 'load' traindna = LoadMatrix.load_dna('../data/fm_train_dna.dat') parameter_list = [[traindna, 3, 0, false], [traindna, 4, 0, false]] def distribution_histogram_modular(fm_dna=traindna, order=3, gap=0, reverse=false) charfeat=Modshogun::StringCharFeatures.new(Modshogun::DNA...
Ruby
require 'modshogun' require 'pp' require 'load' traindat = LoadMatrix.load_numbers('../data/fm_train_real.dat') testdat = LoadMatrix.load_numbers('../data/fm_test_real.dat') parameter_list = [[traindat,testdat],[traindat,testdat]] def distance_canberra_modular(fm_train_real=traindat,fm_test_real=testdat) feats_tra...
Ruby
require 'modshogun' require 'pp' require 'load' ########################################################################### # kernel ridge regression ########################################################################### traindat = LoadMatrix.load_numbers('../data/fm_train_real.dat') testdat = LoadMatrix.load_num...
Ruby
require 'modshogun' require 'pp' strings=['hey','guys','i','am','a','string'] parameter_list=[strings] def features_string_char_modular(strings) #create string features f=Modshogun::StringCharFeatures.new(strings, Modshogun::RAWBYTE) #and output several stats #puts "max string length", f.get_max_vector_length ...
Ruby
require 'modshogun' require 'pp' require 'load' ########################################################################### # chi2 kernel ########################################################################### traindat = LoadMatrix.load_numbers('../data/fm_train_real.dat') testdat = LoadMatrix.load_numbers('../dat...
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. # 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 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
VestalVersions.configure do |config| # Place any global options here. For example, in order to specify your own version model to use # throughout the application, simply specify: # # config.class_name = "MyCustomVersion" # # Any options passed to the "versioned" method in the model itself will override this...
Ruby
# Be sure to restart your server when you modify this file. Marketplace::Application.config.session_store :cookie_store, :key => '_Marketplace_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 wi...
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
Marketplace::Application.configure do # Settings specified here will take precedence over those in config/application.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 turne...
Ruby
Marketplace::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 w...
Ruby
Marketplace::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 t...
Ruby
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application Marketplace::Application.initialize!
Ruby
require 'rubygems' # Set up gems listed in the Gemfile. gemfile = File.expand_path('../../Gemfile', __FILE__) begin ENV['BUNDLE_GEMFILE'] = gemfile require 'bundler' Bundler.setup rescue Bundler::GemNotFound => e STDERR.puts e.message STDERR.puts "Try running `bundle install`." exit! end if File.exist?(gem...
Ruby
require File.expand_path('../boot', __FILE__) require 'rails/all' # If you have a Gemfile, require the gems listed there, including any gems # you've limited to :test, :development, or :production. Bundler.require(:default, Rails.env) if defined?(Bundler) module Marketplace class Application < Rails::Application ...
Ruby
Marketplace::Application.routes.draw do root :to => "apps#index" resources :apps do collection do post 'exists', 'ids' end resources :visuals do collection do post 'exists' end end end resources :app_targets do collection do post 'exists' end end ...
Ruby
module ApplicationHelper end
Ruby
module PermissionsHelper end
Ruby
module VisualsHelper end
Ruby
module AppTargetHelper end
Ruby
module AppPermissionHelper end
Ruby
module CommentsHelper end
Ruby
module AppsHelper end
Ruby
class AppTarget < ActiveRecord::Base belongs_to :app belongs_to :target end
Ruby
class App < ActiveRecord::Base validates_uniqueness_of :packageName has_one :rating, :dependent => :destroy has_many :visuals, :dependent => :destroy has_many :comments, :dependent => :destroy has_many :app_targets has_many :targets, :through => :app_targets has_many :app_permissions has_many :...
Ruby
class Permission < ActiveRecord::Base validates_uniqueness_of :name validates_presence_of :name has_many :app_permissions has_many :apps, :through => :app_permissions end
Ruby
class Target < ActiveRecord::Base has_many :app_targets has_many :apps, :through => :app_targets end
Ruby
class Comment < ActiveRecord::Base belongs_to :app end
Ruby
class Rating < ActiveRecord::Base versioned belongs_to :app end
Ruby
class Visual < ActiveRecord::Base belongs_to :app has_attached_file :image, :url => "/:attachment/:id/:style/:basename.:extension", :path => ":rails_root/public/:attachment/:id/:style/:basename.:extension" validates_attachment_presence :image validates_attachment_co...
Ruby
class AppPermission < ActiveRecord::Base belongs_to :app belongs_to :permission end
Ruby
class AppsController < ApplicationController # GET /apps # GET /apps.xml # GET /apps.json def index @apps = App.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @apps } format.json { render :json => @apps } end end # GET /apps/1 ...
Ruby
class Record attr_accessor :id, :exists end
Ruby
class PermissionsController < ApplicationController # POST /permission.xml # POST /permission.json def create @permission = Permission.new(:name => params[:permission]) respond_to do |format| if @permission.save format.xml { render :xml => @permission, :status => :created, :location => @...
Ruby
class CommentsController < ApplicationController # POST /comments.xml # POST /comments.json def create @app = App.find(params[:app_id]) @comment = @app.comments.new(params[:comment]) respond_to do |format| if @comment.save format.xml { render :xml => @comment, :status => :...
Ruby
class VisualsController < ApplicationController # POST /visuals def create @app = App.find(params[:app_id]) @visual = @app.visuals.new(:image => params[:image]) respond_to do |format| if @visual.save format.html { render :json => @visual, :status => :created} else ...
Ruby
class ApplicationController < ActionController::Base # protect_from_forgery end
Ruby
class AppTargetsController < ApplicationController # POST /app_targets.xml # POST /app_targets.json def create @app_target = AppTarget.new(params[:app_target]) respond_to do |format| if @app_target.save format.xml { render :xml => @app_target, :status => :created, :location => @app_targ...
Ruby
class AppPermissionsController < ApplicationController # POST /app_permissions/update_permissions.xml # POST /app_permissions/update_permissions.json def update_permissions app = App.find(params[:app_id]) app.permission_ids = params[:permissions] respond_to do |format| if app.save! ...
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.expand_path('../config/application', __FILE__) require 'rake' Marketplace::Application.load_tasks
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
source 'http://rubygems.org' gem 'rails', '3.0.3' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'mysql2' gem 'paperclip' gem 'will_paginate' gem 'vestal_versions', :git => 'git://github.com/adamcooper/vestal_versions' # Use unicorn as the web server # gem 'unicorn' # D...
Ruby
class CreateVestalVersions < ActiveRecord::Migration def self.up create_table :versions do |t| t.belongs_to :versioned, :polymorphic => true t.belongs_to :user, :polymorphic => true t.string :user_name t.text :modifications t.integer :number t.integer :reverted_from t...
Ruby
class CreateVisuals < ActiveRecord::Migration def self.up create_table :visuals do |t| t.references :app t.timestamps end add_index :visuals, :app_id end def self.down drop_table :visuals end end
Ruby
class CreateRatings < ActiveRecord::Migration def self.up create_table :ratings do |t| t.string :rating t.integer :ratingCount t.integer :downloadCount t.string :downloadCountText t.references :app t.timestamps end add_index :ratings, :app_id, :unique => true end ...
Ruby
class CreateAppPermissions < ActiveRecord::Migration def self.up create_table :app_permissions do |t| t.references :app t.references :permission t.timestamps end add_index :app_permissions, :app_id add_index :app_permissions, :permission_id end def self.down drop_table :ap...
Ruby
class CreateAppTargets < ActiveRecord::Migration def self.up create_table :app_targets do |t| t.references :app t.references :target t.timestamps end add_index :app_targets, :app_id add_index :app_targets, :target_id end def self.down drop_table :app_targets end end
Ruby
class CreateComments < ActiveRecord::Migration def self.up create_table :comments do |t| t.integer :rating t.string :creationTime t.string :authorName t.string :text t.string :authorId t.references :app t.timestamps end add_index :comments, :app_id add_index ...
Ruby
class CreateApps < ActiveRecord::Migration def self.up create_table :apps do |t| t.string :creator t.string :packageName t.string :title t.text :description t.string :appId t.string :category t.text :recentChanges t.string :email t.string :phone t.string...
Ruby
class CreateTargets < ActiveRecord::Migration def self.up create_table :targets do |t| t.string :name t.timestamps end add_index :targets, :name, :unique => true end def self.down drop_table :targets end end
Ruby
class CreatePermissions < ActiveRecord::Migration def self.up create_table :permissions do |t| t.string :name t.timestamps end add_index :permissions, :name, :unique => true end def self.down drop_table :permissions end end
Ruby
class AddAttachmentImageToVisual < ActiveRecord::Migration def self.up add_column :visuals, :image_file_name, :string add_column :visuals, :image_content_type, :string add_column :visuals, :image_file_size, :integer add_column :visuals, :image_updated_at, :datetime end def self.down remove_co...
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
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run Marketplace::Application
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 ruby # plot phi colormap and interface position require 'Tioga/FigureMaker' class CordPlots include Math include Tioga include FigureConstants def t @figure_maker end def initialize @figure_maker = FigureMaker.default t.def_eval_function { |str| eval(str) } @phi_range = [0.73, 0....
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/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/reaper'
Ruby