code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
require "pp"
class RoutesController < ApplicationController
# GET /routes
# GET /routes.xml
def index
@sort = ["Name", "Geschraubt", "Grad", "Umlenker", "Farbe", "Bauarbeiter"]
if request.post?
case params[:sort]
when "Name"
@routes = Route.all :order => "name"
when "Gesc... | Ruby |
require "digest/sha2"
class WorkersController < ApplicationController
before_filter :isSchorsch, :except => [:index, :show, :edit, :update]
# GET /workers
# GET /workers.xml
def index
@workers = Worker.all :order => "name"
respond_to do |format|
format.html # index.html.erb
format.xml { r... | Ruby |
require 'pp'
class PrinterController < ApplicationController
def index
@routes = Route.find(:all)
end
def print
@routes = []
if params[:print_list] != nil && params[:print_list].keys != nil
params[:print_list].keys.each do |id|
@routes << Route.find(id.to_i)
end
end
rende... | Ruby |
class CommentsController < ApplicationController
before_filter :isSchorsch
# GET /comments
# GET /comments.xml
def index
@comments = Comment.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @comments }
end
end
# GET /comments/1
# GET /commen... | Ruby |
class EventsController < ApplicationController
before_filter :isSchorsch, :except => [:index]
# GET /events
# GET /events.xml
def index
@notes = Note.all.reverse
@events = Event.all.reverse
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @events }
e... | Ruby |
class NotesController < ApplicationController
# GET /notes
# GET /notes.xml
def index
check_hax0r
@notes = Note.all.reverse
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @notes }
end
end
# GET /notes/1
# GET /notes/1.xml
def show
check_h... | Ruby |
class BauarbeiterController < ApplicationController
def index
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @walls }
end
end
end
| Ruby |
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :authorize, :except => :login
before_filter :set_user
def set_user
if session[:worker_id]
@user = Worker.find(session[:worker_id])
else
@user = nil
en... | Ruby |
class ChainsController < ApplicationController
before_filter :isSchorsch, :except => [:index, :show, :get_all_walls]
# GET /chains
# GET /chains.xml
def index
@chains = Chain.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @chains }
end
end
# GE... | Ruby |
require 'pp'
require "digest/sha2"
class LoginController < ApplicationController
def login
if request.post?
worker = Worker.authenticate params[:email], params[:password]
if worker
session[:worker_id] = worker.id
redirect_to(:controller => :events, :action => "index")
else
... | Ruby |
class EventTypesController < ApplicationController
before_filter :isSchorsch
# GET /event_types
# GET /event_types.xml
def index
@event_types = EventType.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @event_types }
end
end
# GET /event_types/1... | 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'
Bauarbeiter::Application.load_tasks
| Ruby |
#!/usr/bin/ruby -w
require "pp"
require "digest/sha2"
begin
WORD = /\S+/
PASSWORD = /\S+/
NUMBER = /\d+/
EMAIL = /@/
data = {
:Username => [WORD, ""],
:Artistname => [WORD, ""],
:Phone => [NUMBER, ""],
:Email => [EMAIL, ""],
:Password => [PASSWORD, ""],
}
data.each_key d... | 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.4'
gem 'scrobbler'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# ge... | Ruby |
class AddExistentToRoutes < ActiveRecord::Migration
def self.up
add_column :routes, :existent, :boolean
end
def self.down
remove_column :routes, :existent
end
end
| Ruby |
class AddManyToManyEventEventtypes < ActiveRecord::Migration
def self.up
create_table :events_eventtypes, :id => false do |t|
t.integer :event_id
t.integer :eventtype_id
end
#add_index :routes_workers, :route_id
#add_index :routes_workers, :worker_id
end
def self.down
drop_table ... | Ruby |
class AddRelationToRoutes < ActiveRecord::Migration
def self.up
add_column :routes, :grade_id, :integer
add_column :routes, :chain_id, :integer
add_index :routes, :grade_id
add_index :routes, :chain_id
end
def self.down
remove_column :routes, :grade_id
remove_column :routes, :chain_id
... | Ruby |
class AddNameToEventtype < ActiveRecord::Migration
def self.up
add_column :eventtypes, :name, :string
end
def self.down
remove_column :eventtypes, :name
end
end
| Ruby |
class CreateGrades < ActiveRecord::Migration
def self.up
create_table :grades do |t|
t.string :grade
t.timestamps
end
end
def self.down
drop_table :grades
end
end
| Ruby |
class AddGrades < ActiveRecord::Migration
def self.up
Grade.create :grade => "1|1|5.0"
Grade.create :grade => "2|2|5.1"
Grade.create :grade => "3|3|5.2"
Grade.create :grade => "4|4|5.3"
Grade.create :grade => "4+|4/+|5.4"
Grade.create :grade => "4+/5-|4+|5.4/5.5"
Grade.create :grade... | Ruby |
class CreateWalls < ActiveRecord::Migration
def self.up
create_table :walls do |t|
t.integer :number
t.timestamps
end
end
def self.down
drop_table :walls
end
end
| Ruby |
class AddPictureToRoutes < ActiveRecord::Migration
def self.up
add_column :routes, :picture_id, :integer
add_index :routes, :picture_id
end
def self.down
remove_column :routes, :picture_id
end
end
| Ruby |
class CreateChains < ActiveRecord::Migration
def self.up
create_table :chains do |t|
t.integer :number
t.timestamps
end
end
def self.down
drop_table :chains
end
end
| Ruby |
class AddWallName < ActiveRecord::Migration
def self.up
add_column :walls, :name, :text
end
def self.down
remove_column :walls, :name
end
end
| Ruby |
class CreateEventTypes < ActiveRecord::Migration
def self.up
create_table :eventtypes do |t|
t.timestamps
end
end
def self.down
drop_table :eventtypes
end
end
| Ruby |
class AddReworkRoute < ActiveRecord::Migration
def self.up
add_column :routes, :rework, :boolean
end
def self.down
remove_column :routes, :rework
end
end
| Ruby |
class CreateEvents < ActiveRecord::Migration
def self.up
create_table :events do |t|
t.string :data
t.timestamps
end
end
def self.down
drop_table :events
end
end
| Ruby |
class AddColors < ActiveRecord::Migration
def self.up
Color.create :name => "Rot"
Color.create :name => "Gelb"
Color.create :name => "Gruen"
Color.create :name => "Blau"
Color.create :name => "Schwarz"
Color.create :name => "Weiss"
Color.create :name => "Lila"
Color.create :nam... | Ruby |
class CreateNotes < ActiveRecord::Migration
def self.up
create_table :notes do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :notes
end
end
| Ruby |
class CreatePictures < ActiveRecord::Migration
def self.up
create_table :pictures do |t|
t.string :name
t.string :sha
t.string :type
t.binary :data
end
end
def self.down
drop_table :pictures
end
end
| Ruby |
class AddRelationToChain < ActiveRecord::Migration
def self.up
add_column :chains, :wall_id, :integer
add_index :chains, :wall_id
end
def self.down
remove_column :chains, :wall_id
end
end
| Ruby |
class AddRelationToWalls < ActiveRecord::Migration
def self.up
end
def self.down
end
end
| Ruby |
class CreateComments < ActiveRecord::Migration
def self.up
create_table :comments do |t|
t.integer :worker_id
t.date :created
t.text :comment
t.timestamps
end
end
def self.down
drop_table :comments
end
end
| Ruby |
class AddEventtypes < ActiveRecord::Migration
def self.up
Eventtype.create :name => "comments" # wenn neuer kommentar erstellt wird
Eventtype.create :name => "new_route" # wenn neue route eingestellt wird
Eventtype.create :name => "set_request" # wenn route rausgeschraubt werden soll
Eventtype.c... | Ruby |
class AddCommentsRoutes < ActiveRecord::Migration
def self.up
create_table :comments_routes, :id => false do |t|
t.integer :comment_id
t.integer :route_id
end
end
def self.down
drop_table :comments_routes
end
end
| Ruby |
class AddRelationToWorker < ActiveRecord::Migration
def self.up
end
def self.down
end
end
| Ruby |
class AddManyToManyRoutesEvents < ActiveRecord::Migration
def self.up
create_table :events_routes, :id => false do |t|
t.integer :route_id
t.integer :event_id
end
#add_index :routes_workers, :route_id
#add_index :routes_workers, :worker_id
end
def self.down
drop_table :events_rou... | Ruby |
class AddAdmin < ActiveRecord::Migration
def self.up
Worker.create :name => "admin",
:artist_name => "admin",
:email => "admin@admin.admin",
:password => "085aed9fce8b179b691a18fb666f63bdabfc59e7b851d9d0f151ae26b6e9323b",
:salt => "477bbeff01461a566e0d4c5b79567a76888c449a47ce6c5f33516ba00354571c",
... | Ruby |
class CreateWorkers < ActiveRecord::Migration
def self.up
create_table :workers do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :workers
end
end
| Ruby |
class AddAccounts < ActiveRecord::Migration
def self.up
add_column :workers, :artist_name, :string
add_column :workers, :mobile, :string
add_column :workers, :email, :string
add_column :workers, :password, :string
add_column :workers, :salt, :string
add_column :workers, :admin, :integer, :def... | Ruby |
class AddManyToManyRouteWorkers < ActiveRecord::Migration
def self.up
create_table :routes_workers, :id => false do |t|
t.integer :route_id
t.integer :worker_id
end
#add_index :routes_workers, :route_id
#add_index :routes_workers, :worker_id
end
def self.down
drop_table :routes_w... | Ruby |
class CreateRoutes < ActiveRecord::Migration
def self.up
create_table :routes do |t|
t.string :name
t.date :build
t.string :grade
t.timestamps
end
end
def self.down
drop_table :routes
end
end
| Ruby |
class RemoveGradeStringFromRouteTable < ActiveRecord::Migration
def self.up
remove_column :routes, :grade
end
def self.down
add_column :routes, :grade, :string
end
end
| Ruby |
class AddColor < ActiveRecord::Migration
def self.up
create_table :colors do |t|
t.string :name
end
add_column :routes, :color_id, :integer
end
def self.down
drop_table :colors
remove_column :routes, :color_id
end
end
| 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 Bauarbeiter::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
require 'json'
RESET_PROB = 0.15;
class Handler
def gather_edges(json)
{:edges => :IN_EDGES}
end
def scatter_edges(json)
last_change = json['state'].to_f
return {:edges => :OUT_EDGES} if last_change > 1e-2
return {:edges => :NO_EDGES}
end
def gather(json)
edge = j... | Ruby |
#!/usr/bin/env ruby
require 'json'
INFINITY = 1e99
class String
alias :old_to_f :to_f
def to_f
return INFINITY if 0 >= self.length
self.old_to_f
end
end
class Handler
def gather_edges(json)
{:edges => :IN_EDGES}
end
def scatter_edges(json)
{:edges => :OUT_EDGES}
end
def gather(jso... | Ruby |
#!/usr/bin/env ruby
def colorize(text, color_code)
"\e[0;#{color_code}m#{text}\e[0m"
end
def red(text)
colorize(text, 31)
end
def green(text)
colorize(text, 32)
end
def cyan(text)
colorize(text, 36)
end
begin
# open new terminal
fd = IO.sysopen("/dev/tty", "r")
term = IO.new(fd,"r")
thread = T... | 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'
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about' | 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/dbconsole'
| 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/runner'
| 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/server'
| 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/plugin'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
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/performance/benchmarker'
| 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/performance/benchmarker'
| 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/process/inspector'
| 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/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/inspector'
| 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/console'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate'
| Ruby |
class GenreateCqPossibleAnswers < ActiveRecord::Migration
def self.up
closed_id=QuestionType.find_by_name("closed question").id
for question in ClosedQuestion.find(:all)
0.upto(rand(4)) do |x|
CQPossibleAnswer.create(:possible_answer=>"Jest ok?",:closed_question_id=>question.id)
end
e... | Ruby |
class Generator < ActiveRecord::Migration
def self.up
@role_ids= Hash.new
i=0
for role in SystemRole.find(:all)
@role_ids[i]=role.id
i+=1
end
@position_ids=Hash.new
i=0
for position in Position.find(:all) #wczesniej bylo losowane -- :role_id=>@role_ids[rand(@role_ids.length)]
@... | Ruby |
class AddSystemRoles < ActiveRecord::Migration
def self.up
SystemRole.delete_all
SystemRole.create(:description=>"uwa",:name => 'Admin')
SystemRole.create(:name => 'Surveyer')
SystemRole.create(:name => 'Surveyee')
SystemRole.create(:name => 'TempSurveyee')
end
def self.down
Position.delete_all
... | Ruby |
class AddQuestionTypes < ActiveRecord::Migration
def self.up
QuestionType.delete_all
QuestionType.create(:name => 'open question', :description => 'open question description...')
QuestionType.create(:name => 'closed question', :description => 'closed question description...')
# QuestionType.create(:name =... | Ruby |
class GenreateOpenQuestions < ActiveRecord::Migration
def self.up
open_id=QuestionType.find_by_name("open question").id
i=0
for survey in Survey.find(:all)
0.upto(rand(4)) do |x|
Question.create(:surveyID=>survey.id,:typeID=>open_id,:question=>"Wszystko ok?")
end
end
end... | Ruby |
class GenreateSurveys < ActiveRecord::Migration
def self.up
creationDate = ['2009-03-02', '2009-03-12','2009-03-22'", "'2009-04-02', '2009-05-02'];
startDate = ['2009-05-03','2009-06-03','2009-05-21','2009-06-13' ];
endDate = ['2009-06-23','2009-07-03','2009-07-21','2009-07-13' ];
editionperm_id=Su... | Ruby |
class AddSurveyPermissionTypes < ActiveRecord::Migration
def self.up
SurveyPermissionType.delete_all
SurveyPermissionType.create(:name => 'fill', :description => 'fill right description...')
SurveyPermissionType.create(:name => 'edition', :description => 'edition right description...')
SurveyPermissionTy... | Ruby |
#adds sample user with login ala and password 123
class AddUserAla123 < ActiveRecord::Migration
def self.up
@role=SystemRole.find(:first,:conditions=>"name='Admin'")
@position=Position.find(:first,:conditions=>"name='Academic'")
User.create!(:login => 'ala',:PASSWORD => '123',
:position_id=> @pos... | Ruby |
class GenreateRights < ActiveRecord::Migration
def self.up
fillperm_id=SurveyPermissionType.find_by_name('fill').id
editionperm_id=SurveyPermissionType.find_by_name('edition').id
statsperm_id=SurveyPermissionType.find_by_name('stats').id
for user in User.find(:all)
for survey in Survey.find(:all)
... | Ruby |
class AddPositionTypes < ActiveRecord::Migration
def self.up
Position.delete_all
#pos=Position.new # to dziala
#pos.positionid=3
#pos.NAME="uww"
#pos.save
Position.create(:name => 'Student')
Position.create(:name => 'Academic')
Position.create(:name => 'Secretary')
Position.create(:name => 'Unk... | Ruby |
class GenreateClosedQuestions < ActiveRecord::Migration
def self.up
closed_id=QuestionType.find_by_name("closed question").id
i=0
for survey in Survey.find(:all)
0.upto(rand(4)) do |x|
Question.create(:surveyID=>survey.id,:typeID=>closed_id,:question=>"Jest ok?")
end
end
... | Ruby |
class GenreateClosedQuestionDetails < ActiveRecord::Migration
def self.up
closed_id=QuestionType.find_by_name("closed question").id
for question in Question.find(:all,:conditions=>"TYPE_ID=#{closed_id}")
0.upto(rand(4)) do |x|
ClosedQuestion.create(:question_id=>question.id,
:min_answers=>... | 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 |
class Question < ActiveRecord::Base
include AliasingColumns
set_table_name "QUESTIONS"
AliasingColumns.add_aliases columns
belongs_to :survey,
:class_name => "Survey",
:foreign_key => "survey_id"
belongs_to :questiontype,
:class_name => "QuestionType",
:foreign_key => "type_id... | Ruby |
class SurveyPermissionType < ActiveRecord::Base
include AliasingColumns
set_table_name "SURVEY_PERMISSION_TYPES"
AliasingColumns.add_aliases columns
has_many :permissions,
:class_name => "UsersSurveysPermission",
:foreign_key => "permission_type_id",
:dependent => :destroy
... | Ruby |
class FilledSurvey < ActiveRecord::Base
include AliasingColumns
set_table_name "FILLED_SURVEYS"
AliasingColumns.add_aliases columns
has_many :oqanswers,
:class_name => "OQAnswer",
:foreign_key => "filled_survey_id",
:dependent => :destroy
has_many :cqanswers,
:class_name => "CQA... | Ruby |
class SystemRole < ActiveRecord::Base
include AliasingColumns
set_table_name "SYSTEM_ROLES"
AliasingColumns.add_aliases columns
has_many :users,
:class_name => "User",
:foreign_key => "role_id"
if AliasingColumns.get_adapter_name == "oracle"
# self.primary_key ="ID"
set_sequen... | Ruby |
class Position < ActiveRecord::Base
include AliasingColumns
set_table_name "POSITIONS"
AliasingColumns.add_aliases columns
has_many :users,
:class_name => "User",
:foreign_key => "position_id"
if AliasingColumns.get_adapter_name == "oracle"
# self.primary_key ="ID"
set_sequence_na... | Ruby |
class DQPossibleAnswer < ActiveRecord::Base
include AliasingColumns
set_table_name "DQ_POSSIBLE_ANSWERS"
AliasingColumns.add_aliases columns
belongs_to :distributingquestion,
:class_name => "DistributingQuestion",
:foreign_key => "distributing_question_id"
validates_presence_of :possible_... | Ruby |
module AliasingColumns
@adapter = Rails::Configuration.new.database_configuration[RAILS_ENV]["adapter"]
def self.add_aliases allcolumns
allcolumns.each do |arg|
if(arg.name.to_s!="PASSWORD" && arg.name.to_s!="password")
#from mixedCase to current name in db
method_name = translate_name(arg.... | Ruby |
class AQPossibleAnswer < ActiveRecord::Base
include AliasingColumns
set_table_name "AQ_POSSIBLE_ANSWERS"
AliasingColumns.add_aliases columns
belongs_to :arrangingquestion,
:class_name => "ArrangingQuestion",
:foreign_key => "arranging_question_id"
validates_presence_of :possible_answer
i... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.