code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/runner' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/destroy' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/about' | Ruby |
#!/usr/bin/env ruby
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../vendor/plugins/rspec/lib"))
require 'spec'
::Spec::Runner::CommandLine.run(ARGV, STDERR, STDOUT, true, true)
| Ruby |
#!/usr/bin/env ruby
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../rspec/lib' # For svn
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/plugins/rspec/lib' # For rspec installed as plugin
require 'rubygems'
require 'drb/drb'
require 'rbconfig'
require 'spec'
require 'optparse'
specmate = ENV['HOME'] + "/Lib... | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/runner' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console' | Ruby |
#!/usr/bin/env ruby
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../rspec/lib' # For svn
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/plugins/rspec/lib' # For rspec installed as plugin
require 'rubygems'
require 'drb/drb'
require 'rbconfig'
require 'spec'
require 'optparse'
specmate = ENV['HOME'] + "/Lib... | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/reaper'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/inspector'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/inspector'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/spawner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/reaper'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/spawner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/destroy' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/about' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin' | Ruby |
#!/usr/bin/env ruby
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../vendor/plugins/rspec/lib"))
require 'spec'
::Spec::Runner::CommandLine.run(ARGV, STDERR, STDOUT, true, true)
| Ruby |
class AddInterestPosition < ActiveRecord::Migration
def self.up
add_column :interests, :position, :integer
end
def self.down
remove_column :interests, :position
end
end
| Ruby |
class CreateInterests < ActiveRecord::Migration
def self.up
create_table :interests do |t|
t.integer :conference_id
t.integer :user_id
t.timestamps
end
end
def self.down
drop_table :interests
end
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table "users", :force => true do |t|
t.column :login, :string
t.column :email, :string
t.column :crypted_password, :string, :limit => 40
t.column :salt, :str... | Ruby |
class CreateConferences < ActiveRecord::Migration
def self.up
create_table :conferences do |t|
t.string :name
t.text :description
t.string :venue
t.string :city
t.string :country
t.string :price
t.string :url
t.datetime :proposals_at
t.datetime :signup_at
... | Ruby |
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'spec/rails'
module AuthenticatedSystem
def login
self.current_user = User.create! :login => '... | 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. Set it to :false if login fails
# so tha... | Ruby |
#!/usr/local/bin/ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impai... | Ruby |
#!/usr/local/bin/ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impai... | Ruby |
#!/usr/local/bin/ruby
#
# You may specify the path to the FastCGI crash log (a log of unhandled
# exceptions which forced the FastCGI instance to exit, great for debugging)
# and the number of requests to process before running garbage collection.
#
# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.lo... | Ruby |
#!/usr/local/bin/ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impai... | Ruby |
#!/usr/local/bin/ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impai... | Ruby |
#!/usr/local/bin/ruby
#
# You may specify the path to the FastCGI crash log (a log of unhandled
# exceptions which forced the FastCGI instance to exit, great for debugging)
# and the number of requests to process before running garbage collection.
#
# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.lo... | Ruby |
# 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 |
require 'rubygems'
require 'sparklines'
require 'jcode'
$KCODE = 'u'
# Be sure to restart your web 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 vers... | Ruby |
# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
module Rails
class << self
def boot!
unless booted?
preinitialize
pick_boot.run
end
end
def booted?
... | Ruby |
ActionController::Routing::Routes.draw do |map|
map.connect '', :controller => 'travel', :action => 'index'
map.connect 'komandiruotes', :controller => 'travel', :action => 'index'
map.connect 'xml', :controller => 'data_service'
map.connect 'xml/seimo_nariai', :controller => 'data_service', :action=>'lrs_mps'
... | Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def stat_percent( x, y )
sprintf("%2.2f%", x.to_f / y.to_f * 100 )
end
def link_to_with_current(
name,
options = {},
html_options = {},
*parameters_for_method_reference)
... | Ruby |
# Provides a tag for embedding sparklines graphs into your Rails app.
#
# To use, load it in your controller with
#
# helper :sparklines
#
# AUTHOR
#
# Geoffrey Grosenbach[mailto:boss@topfunky.com]
#
# http://topfunky.com
#
# License
#
# This code is licensed under the MIT license.
#
module SparklinesHelper
# Cal... | Ruby |
module TravelHelper
#wrap argumentas reikalingas kai kviecia is union_trips2html
#nes union kitaip auksti pasiskaiciuoja
def trips2html(state, wrap = true)
trips = state.trips
height = trips.size > 14 ? 330 : (trips.size * 20 + 80)
cache = StateInfowindowHtmlCache.find_by_state_id(state.id)
html =... | Ruby |
module DataServiceHelper
def state_to_xml(xml, state)
xml.salis do
state_info(xml, state)
end
end
# mp != nil kai iskvieciamas trip_by_mp
def trip_to_xml(xml, state, mp=nil)
xml.salis do
xml.sn_id @mp.id_in_lrs if mp
state_info(xml, state)
for trip in state.trips
xml... | Ruby |
module PoliticiansHelper
end
| Ruby |
module QuestionsHelper
end
| Ruby |
module KpiHelper
end
| Ruby |
class StateLabel < ActiveRecord::Base
belongs_to :state
end
| Ruby |
class DebateReference < ActiveRecord::Base
#http://railsforum.com/viewtopic.php?id=16760
belongs_to :politician
belongs_to :name_reference, :class_name => 'Politician', :foreign_key => 'name_reference_id'
end
| Ruby |
class Position < ActiveRecord::Base
belongs_to :politician
end
| Ruby |
class State < ActiveRecord::Base
has_many :state_labels
has_many :trips
belongs_to :state_union
def to_a
["lng" => lng,
"lat" => lat,
"label" => trips.size,
"info" => trips2html(self)]
end
private
def trips2html(state, wrap = true)
trips = state.trips
height = trips.size > 1... | Ruby |
class Attendance < ActiveRecord::Base
belongs_to :sitting
belongs_to :politician
end
| Ruby |
class Trip < ActiveRecord::Base
belongs_to :state
belongs_to :politician
end | Ruby |
class MpCache < ActiveRecord::Base
belongs_to :politician
end
| Ruby |
class Politician < ActiveRecord::Base
has_many :name_references, :through => :debate_references
has_many :debate_references, :dependent => :destroy
has_many :positions, :dependent => :destroy
has_many :speeches
has_many :attendances
has_many :votes
has_many :trips
has_one :mp_cache #TODO sita keisti
... | Ruby |
class Session < ActiveRecord::Base
has_many :sittings
end
| Ruby |
class Vote < ActiveRecord::Base
include PoliticiansHelper
belongs_to :question
belongs_to :political_group
belongs_to :politician
validates_presence_of :political_group
ABSENT = 1
NOVOTE = 2
ABSTAIN = 3
NO = 4
YES = 5
end | Ruby |
class Speech < ActiveRecord::Base
belongs_to :question
belongs_to :politician
end | Ruby |
class StateUnion < ActiveRecord::Base
has_many :states
def trips
trips = []
states.each{|st| trips << st.trips }
return trips.flatten
end
end
| Ruby |
class Question < ActiveRecord::Base
#TODO stage: dabar 'Svarstymas' 'Priėmimas' bet buna ir 'grazinta ....' http://www3.lrs.lt/pls/inter/w5_sale.klaus_stadija?p_svarst_kl_stad_id=-2675
belongs_to :sitting
has_many :votes
has_many :political_group_votes
has_many :speeches
def self.find_questions_with_r... | Ruby |
class PoliticalGroupVote < ActiveRecord::Base
belongs_to :question
belongs_to :political_group
end
| Ruby |
class PoliticalGroup < ActiveRecord::Base
has_many :politicians
has_many :political_group_votes
end
| Ruby |
class Sitting < ActiveRecord::Base
has_many :questions
has_many :votes, :through => :questions
has_many :attendances
belongs_to :session
def approved_questions
aq = Array.new
questions.find(:all,:conditions=>{:stage=>'Priėmimas'}).each { |q|
a = q.votes.count(:conditions => {:action => Vote::AB... | Ruby |
# Handles requests for sparkline graphs.
#
# You shouldn't need to edit or extend this, but you can read
# the documentation for SparklinesHelper to see how to call it from
# another view.
#
# AUTHOR
#
# Geoffrey Grosenbach[mailto:boss@topfunky.com]
#
# http://topfunky.com
#
class SparklinesController < ApplicationCo... | Ruby |
class KpiController < ApplicationController
helper :sparklines
def index
doc = REXML::Document.new( File.new(File.join(RAILS_ROOT,'lab', 'pranesimai_spaudai.xml')).read )
@feed = Array.new
doc.elements.each("//item[position() < 20]") {|item|
@feed << {:title=>item.elements['title'].text, :link... | Ruby |
class DataServiceController < ApplicationController
def index
end
def lrs_mps
@mps = Politician.find(:all)
render :layout => false
end
def trips_by_mp
@mp = Politician.find_by_id_in_lrs( params[:sn] )
@states = State.find(:all, :include => [:trips], :conditions => ['trips.politician_id = ?', ... | Ruby |
class QuestionsController < ApplicationController
helper :sparklines
def index
@questions = Question.find :all
end
def filter
vote_questions = Question.find_questions_with_votes(params[:vote].to_f)
speech_questions = Question.find_questions_with_speeches(params[:speech].to_f)
attendance_ques... | Ruby |
class PoliticiansController < ApplicationController
helper :sparklines
def index
politicians = Politician.find :all
@politicians_active = politicians.reject{|mp| mp.current_positions_by_type('seimas').size == 0 }
@politicians_inactive = politicians.reject{|mp| mp.current_positions_by_type('seimas').s... | Ruby |
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
# Pick a unique cookie name to distinguish our session data from others'
session :session_key => '_gmaps_sess... | Ruby |
class TravelController < ApplicationController
def lrsmap
@travelers = Politician.find(:all, :include => [:trips], :order =>'last_name')
end
def lrslist
@states = State.find(:all, :include => [:trips, :state_labels]).sort{|x,y| y.trips.size <=> x.trips.size}
@travelers = Politician.find(:all, :incl... | Ruby |
require 'rubygems'
require 'log4r'
module Log
@@lg = Log4r::Logger.new 'atviras-seimas'
@@lg.outputters = Log4r::Outputter.stdout
def log
@@lg
end
end | Ruby |
require 'rubygems'
require 'active_record'
require 'app/models/question'
require 'app/models/political_group'
require 'lrs/log'
#
# Klausimo duomenu klases konstravimas. Cia jau nebeatliekama html parsinimas, bet gali
# buti atliekama tolesne duomenu analize su RegExp
#
# http://www3.lrs.lt/pls/inter/w5_sale.kl... | Ruby |
require 'rubygems'
require 'hpricot'
require 'open-uri'
require 'lrs/utils'
require 'lrs/balsavimas/sitting_builder'
require 'lrs/balsavimas/question_builder'
require 'lrs/balsavimas/debate_analyser'
require 'lrs/balsavimas/statistician'
require 'app/models/sitting'
require 'app/models/vote'
require 'lrs/log'
#
# Visa... | Ruby |
RAILS_ENV = 'development'
require File.dirname(__FILE__) + "/../../config/environment"
require 'jcode'
$KCODE = 'u'
require 'lrs/utils'
class DebateAnalyser
include Utils
def initialize(sit)
@sitting = sit
end
def analyse(url)
doc = utf_page url
(doc/"p.Roman").each do |el|
line = el.i... | Ruby |
#!/usr/bin/env ruby
RAILS_ENV = 'development'
require File.dirname(__FILE__) + "/../../config/environment"
require 'app/models/sitting'
require 'app/models/question'
require 'app/models/vote'
require 'app/models/speech'
require 'app/models/political_group_vote'
require 'lrs/balsavimas/lrs_extractor'
Session.delete_al... | Ruby |
require 'app/models/political_group_vote'
require 'app/models/political_group'
require 'app/models/vote'
class Statistician
def political_group_votes(sitting)
sitting.questions.each do |question|
sql_time = "select distinct time from votes where question_id = #{question.id}"
r = ActiveRecord::Base.co... | Ruby |
require 'rubygems'
require 'active_record'
require 'app/models/sitting'
#
# Klase konstruoja Posedzio model
#
class SittingBuilder
attr_reader :sitting
attr_reader :session
# suskuriam sesija, kuriai posedis priklauso
# => 8 eilinė Seimo sesija (2008-03-10 - ...)
def create_session(text)
md = text.mat... | Ruby |
#!/usr/bin/env ruby
RAILS_ENV = 'development'
require File.dirname(__FILE__) + "/../../config/environment"
require 'app/models/sitting'
require 'app/models/question'
require 'app/models/vote'
require 'app/models/speech'
require 'app/models/political_group_vote'
require 'lrs/balsavimas/lrs_extractor'
Session.delete_al... | Ruby |
require 'rubygems'
require 'hpricot'
require 'lrs/log'
require 'open-uri'
module Utils
include Log
@@ARCHYVE = "../www_lrs/"
def denormalize( text )
t = text.gsub("&", "&").gsub(' ', ' ') #niekur nerandu kaip Hpricot'e ismesti spec simboliu pakeitimus
t.gsub("\245", " ") #kazkokie keisti simb... | Ruby |
#!/usr/bin/env ruby
RAILS_ENV = 'development'
require File.dirname(__FILE__) + "/../../config/environment"
require 'rubygems'
require 'active_record'
require 'hpricot'
require 'open-uri'
require 'json'
require 'uri'
require 'lrs/utils'
include Utils
LRS_URL = "http://www3.lrs.lt/pls/inter/"
#pareigybiu tipai
KOMITE... | Ruby |
#!/usr/bin/env ruby
RAILS_ENV = 'development'
require File.dirname(__FILE__) + "/../../config/environment"
require 'rubygems'
require 'active_record'
require 'hpricot'
require 'open-uri'
require 'json'
require 'uri'
require 'lrs/utils'
include Utils
LRS_URL = "http://www3.lrs.lt/pls/inter/"
#pareigybiu tipai
KOMITE... | Ruby |
#valstybiu kodu mapas
#viskas surasyta valstybes.txt faile
class CountryDescription
def initialize
@state_codes = Hash.new
File.new('scraping/valstybes.txt', 'r').each_line{|line|
state, code, iso_code, full_name = line.split(',')
@state_codes[full_name.chomp] = iso_code
}
end
def stat... | Ruby |
require 'rubygems'
require 'active_record'
class State < ActiveRecord::Base
end
ActiveRecord::Base.establish_connection({
:adapter => "mysql",
:database => "poldek",
:socket => "/opt/local/var/run/mysqld/mysqld.sock",
:username => "",
:password => ""
})
File.new('valstybes-add-win.... | Ruby |
require 'rubygems'
require 'active_record'
class State < ActiveRecord::Base
has_one :coordinate
end
class Coordinate < ActiveRecord::Base
belongs_to :state
end
ActiveRecord::Base.establish_connection({
:adapter => "mysql",
:database => "poldek",
:socket => "/opt/local/var/run/mysqld/mysqld.... | Ruby |
RAILS_ENV = 'development'
require File.dirname(__FILE__) + "/../../config/environment"
Mp.find(:all).each do |st|
l = st.name_in_reports
st.name_in_reports = Iconv.new('utf-8', 'windows-1257').iconv(l)
st.save
end
| Ruby |
RAILS_ENV = 'development'
require File.dirname(__FILE__) + "/../../config/environment"
require 'rubygems'
require 'active_record'
require 'hpricot'
require 'open-uri'
require 'uri'
require 'lrs/utils'
require 'lrs/keliones/cache_generator'
require 'app/models/trip'
require 'app/models/state_label'
require 'app/models... | Ruby |
# sugeneruoti ivairius HTML gabalus tam kad greiciau krautu puslapi
require 'active_record'
require 'app/models/trip'
require 'app/models/politician'
require 'app/models/mp_cache'
#suskaiciuojam bendra laika kiek seimo narys praleido komandiruotese
def mp_trip_duration
Politician.find(:all).each do |mp|
c = Mp... | Ruby |
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/breakpointer' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/runner' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/profiler'
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.