code
stringlengths
1
1.73M
language
stringclasses
1 value
#!/usr/bin/env ruby # scan C/C++ files for headers and create dependency rules require 'fileutils' require 'pathname' require 'pp' module Build def self.scan_file( src ) content = File.new( src ).read(1024) # read the first 1024 lines of the file if content != nil content.each_line{|line| inc = line.ma...
Ruby
#!/usr/bin/env ruby # Called by boot.sh, this script does a lot of the work of # setting up everything, and propogating settings like # brand, revision, stuff like that. require 'erb' require 'yaml' require 'rbconfig' require 'find' require 'fileutils' require 'optparse' require 'ostruct' require 'tools/pathname....
Ruby
#!/usr/bin/env ruby # -- # Features: # * Building dynamic libraries # * Building static libraries # * Building executables # ++ require 'find' require 'fileutils' require 'pathname' require 'rexml/document' require 'pp' include REXML module Build class Makefile attr_reader :path def initialize(root_path, mk_co...
Ruby
require 'rbconfig' require 'pathname' # XXX: these are fixes for win32 ruby 1.8.4 class Pathname def absolute? if Config::CONFIG['arch'] =~ %r{mswin32}i isabs = %r{\A[A-Za-z]:/} =~ @path ? true : false #puts "checking [#{@path}] is absolute #{isabs} for os #{Config::CONFIG['arch']}" else isabs = %r{\A/}...
Ruby
#!/usr/bin/env ruby # Called by boot.sh, this script does a lot of the work of # setting up everything, and propogating settings like # brand, revision, stuff like that. require 'erb' require 'yaml' require 'rbconfig' require 'find' require 'fileutils' require 'optparse' require 'ostruct' require 'tools/pathname....
Ruby
#!/usr/bin/env ruby # scan C/C++ files for headers and create dependency rules require 'fileutils' require 'pathname' require 'pp' module Build def self.scan_file( src ) content = File.new( src ).read(1024) # read the first 1024 lines of the file if content != nil content.each_line{|line| inc = line.ma...
Ruby
#creates a header file from a cpp file. It guesses (naively) at variable names. # # John Magnotti class MethodSignature @comments @return_type @class_name @name @parameters def initialize(comments, name) @comments = comments.size > 0 ? comments : "\n" @return_type = name.split(...
Ruby
class MethodSignature @comments @return_type @class_name @name @parameters def initialize(comments, name) @comments = comments.size > 0 ? comments : "\n" @return_type = name.split("::").first.split(" ") @class_name = @return_type.last @return_type.delete(@class_na...
Ruby
#puts 'Using Orientation'; puts 'Enter the class name: ' name = gets().gsub("\n",""); #"Orientation" header_file = name + ".h" cpp_file = name + ".cpp" #puts "try with: " + header_file _h = IO.readlines(header_file) _cpp = IO.readlines(cpp_file) _h_methods = [] _cpp_methods = [] _h.each do |line| if line.include...
Ruby
#creates a header file from a cpp file. It guesses (naively) at variable names. # # John Magnotti class MethodSignature @comments @return_type @class_name @name @parameters def initialize(comments, name) @comments = comments.size > 0 ? comments : "\n" @return_type = name.split(...
Ruby
class MethodSignature @comments @return_type @class_name @name @parameters def initialize(comments, name) @comments = comments.size > 0 ? comments : "\n" @return_type = name.split("::").first.split(" ") @class_name = @return_type.last @return_type.delete(@class_na...
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/ruby1.8 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 impaired...
Ruby
#!/usr/bin/ruby1.8 # # 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/boot' require 'commands/destroy'
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/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/dbconsole'
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/server'
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/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/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/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/performance/benchmarker'
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/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/performance/request'
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
# 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 helper :all # include all helpers, all the time # It's too easy to misuse sessions and end up with brittle s...
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
# These settings change the behavior of Rails 2 apps and will be defaults # for Rails 3. You can remove this initializer when Rails 3 is released. if defined?(ActiveRecord) # Include Active Record class name as root for JSON serialized output. ActiveRecord::Base.include_root_in_json = true # Store the full clas...
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
# 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.2...
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 # Enable threaded mode # config.threadsafe! # Use a different logger for distributed setups # config....
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
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
#!/usr/bin/ruby require 'kconv' $KCODE = 'u' $:.unshift(File.dirname($0)) require 'lib/corno' configfile = 'corno.conf' def usage end begin opt = OptionParser.new opt.on("-c", "--configfile CONFIGFILE") {|v| configfile = v } opt.parse! rescue Exception => e puts "version : #{Corno::VERSION}" usage end ...
Ruby
#!/usr/bin/ruby require 'kconv' $KCODE = 'u' $:.unshift(File.dirname($0)) require 'lib/corno' configfile = 'corno.conf' def usage end begin opt = OptionParser.new opt.on("-c", "--configfile CONFIGFILE") {|v| configfile = v } opt.parse! rescue Exception => e puts "version : #{Corno::VERSION}" usage end ...
Ruby
require 'cgi' module CornoStyle class Default attr_accessor :text, :tokens def initialize(text, plugin = nil) @text = text.gsub(/(\r\n)|(\r)/, "\n") @tokens = [] @plugin = plugin end def style 'CornoStyle' end BLOCK_STYLES = [ { :type => :pre, :regexp...
Ruby
#!/usr/bin/ruby $LOAD_PATH << "lib" require 'date' require 'stringio' require 'erb' require 'fileutils' require 'rss/maker' require 'digest/md5' module Corno VERSION = '0.0.2' class Item attr_accessor :item_id, :date, :title, :tags, :author, :contents def update(item) @item_id = item[:item_id] i...
Ruby
#!/usr/bin/ruby $LOAD_PATH << "lib" require 'date' require 'stringio' require 'erb' require 'fileutils' require 'rss/maker' require 'digest/md5' module Corno VERSION = '0.0.2' class Item attr_accessor :item_id, :date, :title, :tags, :author, :contents def update(item) @item_id = item[:item_id] i...
Ruby
#!/usr/bin/ruby require 'kconv' $KCODE = 'u' $:.unshift(File.dirname(__FILE__) + './lib') require 'lib/corno' require 'style/default/cornostyle' configfile = 'corno.conf' def usage end begin opt = OptionParser.new opt.on("-c", "--configfile CONFIGFILE") {|v| configfile = v } opt.parse! ...
Ruby
$:.unshift(File.dirname(__FILE__) + '/../') require 'test/unit' require 'style/default/cornostyle' require 'pp' class TC_CornoStyle < Test::Unit::TestCase def setup end def teardown end def test_convert_blockquote r = CornoStyle.to_html(<<-CONTENS) >> abcdefghij 0123456789 << ...
Ruby
#!/usr/bin/ruby require 'kconv' $KCODE = 'u' $:.unshift(File.dirname(__FILE__) + './lib') require 'lib/corno' require 'style/default/cornostyle' configfile = 'corno.conf' def usage end begin opt = OptionParser.new opt.on("-c", "--configfile CONFIGFILE") {|v| configfile = v } opt.parse! ...
Ruby
require 'pp' require 'cgi' class CornoStyle def self.to_html(text, plugin = nil) doc = CornoStyle.new(text, plugin) doc.parse_style doc.compile_blockquote doc.compile_super_pre doc.compile_title doc.compile_horizontal_rule doc.compile_plugin # pp doc.tokens do...
Ruby
$LOAD_PATH << "lib" require 'date' require 'stringio' require 'erb' require 'fileutils' require 'rss/maker' module Corno VERSION = '0.0.2' class Item attr_accessor :item_id, :date, :title, :tags, :author, :contents def update(item) @item_id = item[:item_id] if item.key?(:item_id)...
Ruby
#/usr/bin/ruby class TagCloud attr_accessor :words def initialize(words = []) @words = {} self.add(words) end def add(words) words.each do |word| w = word.strip if @words.key?(w) @words[w] = @words[w] + 1 else @words[w] = 1 end end end def calc(lev...
Ruby
#!/usr/bin/ruby require 'pp' require 'uri' require 'net/http' Net::HTTP.version_1_2 module Rire class Mapping def self.define(&block) m = new m.instance_eval(&block) unless block.nil? m.extend(Rire::Filter) m end attr_accessor :user_agent def initialize @entries = ...
Ruby
#!/usr/bin/ruby require 'pp' require 'uri' require 'net/http' Net::HTTP.version_1_2 module Rire class Mapping def self.define(&block) m = new m.instance_eval(&block) unless block.nil? m.extend(Rire::Filter) m end attr_accessor :user_agent def initialize @entries = ...
Ruby
#!/usr/bin/ruby require 'dl/import' require 'dl/struct' # you need `MECAB_BIN' value module Mecab module DL extend ::DL::Importable raise RuntimeError unless defined?(MECAB_BIN) dl_name = case RUBY_PLATFORM when /mswin/ "libmecab.dll" when /linux/ "libmecab.so" else ...
Ruby
#!/usr/bin/ruby require 'dl/import' require 'dl/struct' # you need `MECAB_BIN' value module Mecab module DL extend ::DL::Importable raise RuntimeError unless defined?(MECAB_BIN) dl_name = case RUBY_PLATFORM when /mswin/ "libmecab.dll" when /linux/ "libmecab.so" else ...
Ruby
class Bitmap attr_accessor :filename, :filesize, :height, :width, :type # format type BITMAPCOREHEADER = 0 # => 12 byte BITMAPINFOHEADER = 1 # => 40 byte BITMAPV4HEADER = 2 # => 108 byte BITMAPV5HEADER = 3 # => 124 byte class NoBitmapError < Exception; end class NoImplementedError < Exception; en...
Ruby
#!/usr/bin/ruby require 'time' class CCron @interval = 30 # => minutes def self.interval=(tm) @interval = tm end def self.interval @interval end def self.at(config, &block) params = config.split(/\s+/, 5) raise ArgumentError, "a few argument" if params.length < 5 prev_time = (Time...
Ruby
#!/usr/bin/ruby require 'time' class CCron @interval = 30 # => minutes def self.interval=(tm) @interval = tm end def self.interval @interval end def self.at(config, &block) params = config.split(/\s+/, 5) raise ArgumentError, "a few argument" if params.length < 5 prev_time = (Time...
Ruby
#!/usr/bin/ruby require 'net/http' require 'uri' require 'kconv' Net::HTTP.version_1_2 module WebService class Simple def initialize @params = {} @user_agent = "Ruby/#{RUBY_VERSION}" options = {} options = @@instance_values[self.class.to_s] if @@instance_values.key?(self.class.to_s) ...
Ruby
#!/usr/bin/ruby require 'net/http' require 'uri' require 'kconv' Net::HTTP.version_1_2 module WebService class Simple def initialize @params = {} @user_agent = "Ruby/#{RUBY_VERSION}" options = {} options = @@instance_values[self.class.to_s] if @@instance_values.key?(self.class.to_s) ...
Ruby
require 'rubygems' require 'mechanize' require 'hpricot' # TODO: クラスごとにファイルに分ける # TODO: timeline の取得処理にコードのダブりを調整 class Wassr class Message attr_accessor :username, :message, :permalink, :date, :favorite, :is_private def initialize @favorite = [] end end class Favorite attr_accessor :us...
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
# These settings change the behavior of Rails 2 apps and will be defaults # for Rails 3. You can remove this initializer when Rails 3 is released. # Include Active Record class name as root for JSON serialized output. ActiveRecord::Base.include_root_in_json = true # Store the full class name (including module namespa...
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
# 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
# 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.1...
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.resources :snippets # 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 :c...
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module PresetsHelper end
Ruby
module SnippetsHelper end
Ruby
module ExampleHelper end
Ruby
module HelpHelper end
Ruby
module RainbowHelper end
Ruby
module RootHelper end
Ruby
class Snippet < ActiveRecord::Base end
Ruby
class HelpController < ApplicationController caches_page :index layout 'main' def index #@top_partial = 'help' @side_partial = 'side' @page = 'help'; end def sites end end
Ruby
class PresetsController < ApplicationController layout 'rainbow', :except => ['css'] before_filter :header_css, :except => ['index'] def index @page = 'presets' @snippets = Snippet.find(:all) end def header_css response.headers['Content-type'] = 'text/css' end def css @snippets = Snippe...
Ruby
class RainbowController < ApplicationController layout 'rainbow' def index @side_partial = 'side' end def example @side_partial = 'side' end def handle_unknown_request redirect_to(:action => 'index') end end
Ruby