code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
#!/usr/bin/env ruby
last_key, max_val = nil, 0
STDIN.each_line do |line|
key, val = line.split("\t")
if last_key && last_key != key
puts "#{last_key}\t#{max_val}"
last_key, max_val = key, val.to_i
else
last_key, max_val = key, [max_val, val.to_i].max
end
end
puts "#{last_key}\t#{max_val}" if last_k... | Ruby |
#!/usr/bin/env ruby
last_key, max_val = nil, 0
STDIN.each_line do |line|
key, val = line.split("\t")
if last_key && last_key != key
puts "#{last_key}\t#{max_val}"
last_key, max_val = key, val.to_i
else
last_key, max_val = key, [max_val, val.to_i].max
end
end
puts "#{last_key}\t#{max_val}" if last_k... | Ruby |
#!/usr/bin/env ruby
STDIN.each_line do |line|
val = line
year, temp, q = val[15,4], val[87,5], val[92,1]
puts "#{year}\t#{temp}" if (temp != "+9999" && q =~ /[01459]/)
end | Ruby |
#!/usr/bin/env ruby
STDIN.each_line do |line|
val = line
year, temp, q = val[15,4], val[87,5], val[92,1]
puts "#{year}\t#{temp}" if (temp != "+9999" && q =~ /[01459]/)
end | Ruby |
class CreateDepreciations < ActiveRecord::Migration
def self.up
create_table :depreciations do |t|
t.column :description, :string
t.column :live_years, :integer
t.column :code, :string
t.column :compensation,:string
end
execute "INSERT INTO depreciations(id,description,live_... | Ruby |
class CreateGeneralBalaceSheets < ActiveRecord::Migration
def self.up
create_table :general_balace_sheets do |t|
t.column :account_id, :integer
t.column :period, :integer
t.column :total_amount,:float
end
end
def self.down
drop_table :general_balace_sheets
end
end
| Ruby |
class CreateTransaction1s < ActiveRecord::Migration
def self.up
create_table :transaction1s do |t|
t.column :account_id, :string
t.column :period_id, :string
t.column :date, :datetime
t.column :amount, :float
t.column :subject, :text
# :text, :integer,... | Ruby |
class CreateConfigurations < ActiveRecord::Migration
def self.up
create_table :configurations do |t|
t.column :business_title, :string
t.column :foundation_date, :date
t.column :months_accounting_cycle, :string
end
execute "INSERT INTO configurations(id,business_title,foundatio... | Ruby |
class CreatePeriods < ActiveRecord::Migration
def self.up
create_table :periods do |t|
t.column :number, :integer
t.column :state, :string
t.column :valid, :string,:default=> "NOT EVALUATED"
end
end
def self.down
drop_table :periods
end
end
| 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 |
#!C:/InstantRails/ruby/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 seve... | Ruby |
#!C:/InstantRails/ruby/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/fastcg... | Ruby |
#!C:/InstantRails/ruby/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 seve... | Ruby |
#!C:/InstantRails/ruby/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 seve... | Ruby |
#!C:/InstantRails/ruby/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/fastcg... | Ruby |
#!C:/InstantRails/ruby/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 seve... | 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/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/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/about' | 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/console' | 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/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 |
#!/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/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/generate' | Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
end
| Ruby |
module AccountsHelper
end
| Ruby |
module DepreciationsHelper
end
| Ruby |
module ConfigurationsHelper
end
| Ruby |
module PeriodsHelper
end
| Ruby |
module Transaction1sHelper
end
| Ruby |
class Account < ActiveRecord::Base
belongs_to :depreciation
has_many :transaction1
has_one :depreciation
end
| Ruby |
class Transaction1 < ActiveRecord::Base
belongs_to :period
belongs_to :account
end
| Ruby |
class Configuration < ActiveRecord::Base
end
| Ruby |
class GeneralBalaceSheet < ActiveRecord::Base
end
| Ruby |
class Depreciation < ActiveRecord::Base
has_one :account
has_many :transaction1
end
| Ruby |
class Period < ActiveRecord::Base
has_many :transaction1
end
| Ruby |
class ConfigurationsController < ApplicationController
def index
list
render :action => 'list'
end
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
verify :method => :post, :only => [ :destroy, :create, :update ],
:redirect_to => { :action => :list }
def list
... | Ruby |
class Transaction1sController < ApplicationController
auto_complete_for :account, :name
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
verify :method => :post, :only => [ :destroy, :create, :update ],
:redirect_to => { :action => :list }
def index
list
... | Ruby |
class DepreciationsController < ApplicationController
def index
list
render :action => 'list'
end
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
verify :method => :post, :only => [ :destroy, :create, :update ],
:redirect_to => { :action => :list }
def list
... | Ruby |
# Filters added to this controller will be run for all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
config = Configuration.find 1
@business_title=config.business_title
@foundation_date= co... | Ruby |
class AccountsController < ApplicationController
def index
list
render :action => 'list'
end
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
verify :method => :post, :only => [ :destroy, :create, :update ],
:redirect_to => { :action => :list }
def list
@acco... | 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 |
# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb
unless defined?(RAILS_ROOT)
root_path = File.join(File.dirname(__FILE__), '..')
unless RUBY_PLATFORM =~ /mswin32/
require 'pathname'
root_path = Pathname.new(root_path).cleanpath(true).to_s
end
RAILS... | Ruby |
# 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 version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION ... | 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 |
#!/usr/bin/env ruby
# encoding: utf-8
project = 'battery-indicator'
user = `cat ~/.netrc | awk '{print $4;}'`.strip
pass = `cat ~/.netrc | awk '{print $6;}'`.strip
version = `grep "android:versionName=" AndroidManifest.xml`.split('"')[1]
apk_location = "BatteryIndicatorPro-#{version}.apk"
system("cp bin/*-release.ap... | Ruby |
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
LANGS_URI = 'http://ath.darshancomputing.com/bi/langs/'
langs = Net::HTTP.get(URI.parse(LANGS_URI)).split()
langs.each do |lang|
if lang.length == 2
dir = 'res/values-' << lang
else
dir = 'res/values-' << lang[0,2] << '-r' << lang[2,2]
end
if ! D... | Ruby |
require 'RMagick'
class NumberImageGenerator
@@IMAGE_DIR = 'numbers-hdpi/'
def generate(text, fs=18)
#filename = "b" + sprintf("%03d", text) + ".png";
filename = "" + sprintf("%03d", text) + ".png";
font_size = fs;
height = 35;
width = 35;
image = Magick::Image.new(width, height) {self.ba... | Ruby |
require 'redcarpet'
module Jekyll
class UserGuideFor < Liquid::For
def render(context)
sort_by = @attributes['sort_by']
category = @attributes['category']
sorted_collection = context[@collection_name].dup
sorted_collection = sorted_collection.sort_by { |i| (i && i.to_liquid[@att... | Ruby |
require 'sinatra/activerecord/rake'
require './main' | Ruby |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'sinatra-activerecord'
gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client'
group :development do
gem 'rake'
gem 'sqlite3-ruby'
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.string :profile_id
t.string :email
t.string :refresh_token
end
add_index :users, :profile_id
end
def down
drop_table :users
end
end
| Ruby |
# Copyright (C) 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Ruby |
require 'sinatra.rb'
# Sinatra defines #set at the top level as a way to set application configuration
set :run, false
set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development)
require './main'
run Sinatra::Application | Ruby |
source "http://rubygems.org"
gem 'rake', '0.8.7'
gem 'json'
group :development do
gem 'test-unit'
gem 'thoughtbot-shoulda'
gem 'ruby-debug'
end | Ruby |
begin
require 'main/init'
rescue LoadError
require 'src/main/ruby/main/init'
end
require 'pathname'
require 'test/unit'
require 'shoulda/integrations/test_unit'
require 'lib/configuration'
require 'lib/crawling'
java_import [de.recipeminer.environments.ExecutionContextProvider,
de.recipeminer.environ... | Ruby |
require 'test/unit'
require 'shoulda/integrations/test_unit'
require 'src/main/ruby/main/init'
class TestJava < Test::Unit::TestCase
context "The java integrations" do
should "be able to provide 'magic' access to de.* and eu.* Java-packages" do
assert_nothing_raised do
assert_instance_of(java.lang... | Ruby |
begin
require 'main/init'
rescue LoadError
require 'src/main/ruby/main/init'
end
require 'test/unit'
require 'shoulda/integrations/test_unit'
require 'lib/configuration'
class TestConfig < Test::Unit::TestCase
context "#{Configuration::ConfigContainer}" do
context "in the test enviroment" do
setu... | Ruby |
begin
require 'main/init'
rescue LoadError
require 'src/main/ruby/main/init'
end
require 'net/http'
require 'json'
require 'lib/configuration'
require 'lib/crawling'
module Testing
def self.print_info
puts "The Ruby VM is: #{RUBY_DESCRIPTION}"
puts 'My Loadpath is:'
puts $:
puts 'My classpath is:'... | Ruby |
require 'java'
require 'pathname'
module Init
EXPECTED_HOME_ENTRIES = ['pom.xml', 'src', 'Gemfile']
RELATIVE_INIT_PATH = 'src/main/ruby/main/init.rb'
class << self
def add_package_shortcuts
[:de, :eu].each do |meth|
Kernel.module_eval <<-EOM
def #{meth}
JavaUt... | Ruby |
require 'src/main/ruby/main/init'
require 'pathname'
require 'singleton'
java_import(de.recipeminer.environments.ExecutionContextProvider)
module Configuration
class << self
def project_home_path
Init::project_home_path
end
alias_method :project_path, :project_home_path
def maven_r... | Ruby |
#encoding: UTF-8
java_import [de.recipeminer.persistence.Db4oHelpers,
de.recipeminer.crawling.chefkoch.ChefkochJsonRecipe,
de.recipeminer.tools.Tools]
java_import(java.lang.String) {'JString'}
module Workflow
module Workflow
def run
begin
execute
rescue Exce... | Ruby |
#encoding: utf-8
require 'lib/configuration'
require 'net/http'
require 'json'
require 'set'
require 'pp'
require 'yaml'
require 'singleton'
java_import [de.recipeminer.environments.ExecutionContextProvider,
de.recipeminer.environments.ExecutionContext,
de.recipeminer.crawling.chefkoch.Chefko... | Ruby |
puts "probing for #{JAR_PROBING_STRING}"
path_template = $:.select { |p| p.end_with? JAR_PROBING_STRING }
unless path_template.empty?
entry = path_template[0].sub(JAR_PROBING_STRING, JAR_LOCATION_RUBY)
$: << entry
entry
else
nil
end
| Ruby |
#encoding: UTF-8
require 'rake'
require 'rake/clean'
require 'rubygems/package_task'
require 'rdoc/task'
require 'rake/testtask'
require 'fileutils'
require 'set'
spec = Gem::Specification.new do |s|
s.name = 'recipeminer'
s.version = '0.0.1'
s.has_rdoc = true
s.extra_rdoc_files = ['README', 'LI... | Ruby |
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.string :profile_id
t.string :email
t.string :refresh_token
end
add_index :users, :profile_id
end
def down
drop_table :users
end
end
| Ruby |
# Copyright (C) 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Ruby |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'sinatra-activerecord'
gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client'
group :development do
gem 'rake'
gem 'sqlite3-ruby'
end
| Ruby |
require 'sinatra.rb'
# Sinatra defines #set at the top level as a way to set application configuration
set :run, false
set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development)
require './main'
run Sinatra::Application | Ruby |
require 'sinatra/activerecord/rake'
require './main' | Ruby |
class RubyLibraryExample
def get_server_language
'ruby'
end
# Basic communication
def passing
end
def failing(message)
raise message
end
def logging(message, level='INFO')
puts "*#{level}* #{message}"
end
def returning
'returned string'
end
# Logging
def one_message_w... | Ruby |
# Copyright 2008-2009 Nokia Siemens Networks Oyj
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | Ruby |
#!/usr/bin/env ruby
class ExampleRemoteLibrary
def count_items_in_directory(path)
Dir.entries(path).find_all{|i| not i.match('^\.')}.length
end
def strings_should_be_equal(str1, str2)
puts "Comparing '#{str1}' to '#{str2}'"
if str1 != str2
raise RuntimeError, "Given strings are not equal"
... | 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 |
# 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 |
# 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.
Rottenpotatoes::Application.config.session_store :cookie_store, key: '_rottenpotatoes_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... | 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 |
Rottenpotatoes::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... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.