code
stringlengths
1
1.73M
language
stringclasses
1 value
class CreateRoles < ActiveRecord::Migration def self.up create_table "roles" do |t| t.string :name end # generate the join table create_table "roles_users", :id => false do |t| t.integer "role_id", "user_id" end add_index "roles_users", "role_id" add_index "roles_users", "...
Ruby
class AddParentIdToPost < ActiveRecord::Migration def self.up add_column :posts, :parent_id, :integer add_column :posts, :replies_count, :integer, :default => 0 end def self.down remove_column :posts, :parent_id remove_column :posts, :replies_count end end
Ruby
class AddIndexToTables < ActiveRecord::Migration def self.up # set limits for index key change_column :pages, :type, :string, :limit => 20 change_column :assets, :type, :string, :limit => 20 change_column :boards, :name, :string, :limit => 20 change_column :comments, :commentable_type, :string, :l...
Ruby
class ApplyActsAsViewedToPost < ActiveRecord::Migration def self.up ActiveRecord::Base.create_viewings_table add_column :posts, :views, :integer, :default => 0 end def self.down remove_column :posts, :views ActiveRecord::Base.drop_viewings_table end end
Ruby
class AddParentIdToComment < ActiveRecord::Migration def self.up add_column :comments, :parent_id, :integer add_column :comments, :lft, :integer add_column :comments, :rgt, :integer end def self.down remove_column :comments, :parent_id remove_column :comments, :lft remove_column :comments...
Ruby
class SimplyVersionedMigration < ActiveRecord::Migration def self.up create_table :versions do |t| t.integer :versionable_id t.string :versionable_type t.integer :number t.text :yaml t.datetime :created_at end add_index :versions, [:versionable_id, :versi...
Ruby
class CreateAssets < ActiveRecord::Migration def self.up create_table :assets do |t| # for attachment_fu t.column :size, :integer # file size in bytes t.column :content_type, :string # mime type, ex: application/mp3 t.column :filename, :string # sanitized filename t....
Ruby
class CreateTitles < ActiveRecord::Migration def self.up create_table :titles do |t| t.string :text t.timestamps end create_table :pages_titles, :id => false do |t| t.integer :page_id, :title_id end end def self.down drop_table :titles drop_table :pages_titles end end...
Ruby
class AddBoardIdToNote < ActiveRecord::Migration def self.up add_column :notes, :board_id, :integer end def self.down remove_column :notes, :board_id end end
Ruby
class AddOpenLevelToBoard < ActiveRecord::Migration def self.up add_column :boards, :open_level, :integer, :default => 999 end def self.down remove_column :boards, :open_level end end
Ruby
class CreatePosts < ActiveRecord::Migration def self.up create_table :posts do |t| t.string :title t.text :body t.integer :user_id t.timestamps end end def self.down drop_table :posts end end
Ruby
class AddUserIdToAlbum < ActiveRecord::Migration def self.up add_column :boards, :user_id, :integer end def self.down remove_column :boards, :user_id end end
Ruby
# Main module for authentication. # Include this in ApplicationController to activate RoleRequirement # # See RoleSecurityClassMethods for some methods it provides. module RoleRequirementSystem def self.included(klass) klass.send :class_inheritable_array, :role_requirements klass.send :include, RoleSecurity...
Ruby
module PolymorphicParent # # DRYing up for polymorphic controller (like commentable controller) # It produces some useful helper methods like these: # def parent_object # case # when params[:note_id] then Note.find_by_id(params[:note_id]) # when params[:photo_id] then Photo.find_by_id(params[:ph...
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 end # Accesses the current user from the session. # Future calls avoid the database because nil is not ...
Ruby
# Hijacker class # # This class is used by RoleRequirementTestHelper to temporarily hijack a controller action for testing # # Example usage: # hijacker = Hijacker.new(ListingsController) # hijacker.hijack_instance_method("index", "render :text => 'hello world!'" ) # get :index # will return "hello world" ...
Ruby
module AuthenticatedTestHelper # Sets the current user in the session from the user fixtures. def login_as(user) @request.session[:user_id] = user ? users(user).id : nil end def authorize_as(user) @request.env["HTTP_AUTHORIZATION"] = user ? ActionController::HttpAuthentication::Basic.encode_credentials...
Ruby
# Include this is test_helper.rb to enable test-case helper support for RoleRequirement via: # include RoleRequirementTestHelper # # RoleRequirementTestHelper uses the power of ruby to temporarily "hijack" your target action. (don't worry, it puts things back the way it was after it runs) # This means that the only ...
Ruby
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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/dispat...
Ruby
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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/dispat...
Ruby
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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 Fast...
Ruby
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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/dispat...
Ruby
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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/dispat...
Ruby
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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 Fast...
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' require 'redgreen' class Test::Unit::TestCase # RoleRequirementTestHelper must be included to test RoleRequirement include RoleRequirementTestHelper # Transactional fixtures accelerate your ...
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
# # << Haru Free PDF Library 2.0.2 >> -- line_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appear...
Ruby
# # << Haru Free PDF Library 2.0.6 >> -- ext_gstate_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice ...
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- text_demo2.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice...
Ruby
# # << Haru Free PDF Library 2.0.2 >> -- ttfont_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appe...
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- font_example.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright noti...
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- encryption.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice...
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- demo.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appea...
Ruby
# # << Haru Free PDF Library 2.0.6 >> -- slideshow_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice a...
Ruby
# # << Haru Free PDF Library 2.0.2 >> -- arc_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appear ...
Ruby
require 'mkmf' $CPPFLAGS = $CPPFLAGS + " -I../../include" $LDFLAGS = $LDFLAGS + " -L../../" $LIBS = $LIBS + " -lhpdf -lpng -lz" create_makefile 'hpdf'
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
require 'rubygems' require 'bundler/setup' require 'yaml' require 'yui/compressor' require 'json' require 'rufus/tokyo' require 'rake/testtask' require 'model/user' require 'model/form' require 'model/connection_manager' @db = ConnectionManager.rackless_connection namespace :deploy do desc 'Compile and bundle as...
Ruby
require 'lib/multipart' require 'model/user' require 'model/form' require 'model/connection_manager' class OdkBuild < Sinatra::Application disable :run set :views, File.dirname(__FILE__) + '/views' # required for dev env before do content_type :json end # For dev server purposes, load index via Sinatr...
Ruby
source :gemcutter gem 'ffi', '0.6.3' gem 'rufus-tokyo', '1.0.7', :require => 'rufus/tokyo' gem 'rack', '1.2.1' gem 'sinatra', '1.0' gem 'json', '1.4.6' gem 'pony', '1.0' gem 'warden', '0.10.7' gem 'oauth', '0.4.4' gem 'riot', '0.12.1' gem 'mocha', '0.9.12' gem 'rack-test', '0.5.7' gem 'yui-compressor', '0.9.3' grou...
Ruby
class AssetManager def self.javascripts return @@assets['javascripts'] || [] end def self.build_time return @@build_time end def self.load @@assets = YAML.load_file('assets.yml') || {} begin @@build_time = File.read '.build_time' rescue Errno::ENOENT @@build_time = Time.new.t...
Ruby
require 'model/user' Warden::Manager.before_failure do |env, opts| # Sinatra is very sensitive to the request method # since authentication could fail on any type of method, we need # to set it for the failure app so it is routed to the correct block env['REQUEST_METHOD'] = "GET" end use Warden::Manager do |m...
Ruby
class ConfigManager def self.[](config_key) return @@config[config_key] end def self.load @@config = (YAML.load_file('config.yml') || {})[ENV['RACK_ENV']] end end
Ruby
# Takes a hash of string and file parameters and returns a string of text # formatted to be sent as a multipart form post. # # Author:: Cody Brimhall <mailto:cbrimhall@ucdavis.edu> # Created:: 22 Feb 2008 # Modified by Clint Tseng on 2010/12/07 to take strings and pretend they're text/xml files. require 'cgi' modul...
Ruby
class ConnectionManager class << self attr_accessor :connection end def initialize(app) @app = app end def call(env) open_connection_if_necessary! @app.call(env) end protected def open_connection_if_necessary! self.class.connection ||= begin add_finalizer_hook! { ...
Ruby
require 'model/connection_manager' require 'digest/sha1' class String def self.random_chars( length ) chars = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a return (0...length).map{ chars[Kernel.rand(chars.length)] }.join end end class User def self.find(key) key = key.to_s.downcase data =...
Ruby
require 'model/connection_manager' class String def self.random_chars( length ) chars = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a return (0...length).map{ chars[Kernel.rand(chars.length)] }.join end end class Form def self.find(key, get_form_data = false) key = key.to_s data = Connect...
Ruby
require 'rubygems' require 'bundler/setup' Bundler.require require 'warden_odkbuild' require 'model/connection_manager' require 'config_manager' require 'asset_manager' require 'odkbuild_server' # load configuration files ConfigManager.load AssetManager.load # middleware use Rack::CommonLogger use Rack::Session::...
Ruby
require "rubygems" require "sinatra" require "rack/test" require "riot" require "mocha" require "json" require "rake" require "warden" require "warden_odkbuild" require 'model/connection_manager' require "model/user.rb" require "model/form.rb" require 'config_manager' require "odkbuild_server" ENV['RACK_ENV'] = "te...
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
require 'net/http' server = "msdl.microsoft.com" pdb = "ntkrnlmp" guid = "30092be745b24fe2a311a936e7b7486f2" uri = "/download/symbols/#{pdb}.pdb/#{guid}/#{pdb}.pd_" dest = "#{pdb}.pd_" puts uri Net::HTTP.start(server) { |http| headers = {"User-Agent" => "Microsoft-Symbol-Server/6.6.0007.5"} resp = http.get(u...
Ruby
# This file is part of Virtdbg # Copyright (C) 2010-2011 Damien AUMAITRE # # Licence is GPLv3, see LICENCE.txt in the top-level directory require 'metasm' require 'virtdbg' require 'optparse' $VERBOSE = false # parse arguments opts = { :device => 0 } OptionParser.new { |opt| opt.banner = 'Usage: virtdbg....
Ruby
# This file is part of Virtdbg # Copyright (C) 2010-2011 Damien AUMAITRE # # Licence is GPLv3, see LICENCE.txt in the top-level directory module VirtDbg VIRTDBGDIR = File.dirname(__FILE__) # add it to the ruby library path $: << VIRTDBGDIR end %w[forensic1394 virtdbg util main system].each { |f| require ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # this exemple illustrates the use of the cparser/preprocessor #factorize functionnality: # we write some code using standard headers, and t...
Ruby
# This file is part of Virtdbg # Copyright (C) 2010-2011 Damien AUMAITRE # # Licence is GPLv3, see LICENCE.txt in the top-level directory require 'metasm' require 'metasm/dynldr' include Metasm module VirtDbg class Forensic1394 < Metasm::DynLdr new_api_c File.read(File.join(VIRTDBGDIR, "inc", ...
Ruby
# This file is part of Virtdbg # Copyright (C) 2010-2011 Damien AUMAITRE # # Licence is GPLv3, see LICENCE.txt in the top-level directory require 'metasm' require 'metasm/dynldr' include Metasm module VirtDbg class VirtDbgMem < VirtualString def initialize(impl, addr=0, length=nil) ...
Ruby
# This file is part of Virtdbg # Copyright (C) 2010-2011 Damien AUMAITRE # # Licence is GPLv3, see LICENCE.txt in the top-level directory require 'metasm' require 'metasm/dynldr' require 'iconv' class String def utf16_to_iso converter = Iconv.new('ISO-8859-1//IGNORE//TRANSLIT', 'UTF-16') ...
Ruby
# This file is part of Virtdbg # Copyright (C) 2010-2011 Damien AUMAITRE # # Licence is GPLv3, see LICENCE.txt in the top-level directory require 'metasm' require 'metasm/dynldr' include Metasm def calc_checksum(data) data.unpack('C*').inject(0) { |sum, byte| sum+byte } end module VirtDbg class ...
Ruby
# ripped from metasm/misc class IO def hexdump(ctx={}) ctx[:noend] = true while buf = read(512) and not buf.empty? buf.hexdump(ctx) end ctx.delete :noend ''.hexdump(ctx) end end class String def hexdump(ctx={}) fmt = ctx[:fmt] ||= ['c', 'd', 'a'] ...
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
environment = :production project_type = :stand_alone http_path = "/" css_dir = "../styles" sass_dir = "." images_dir = "images" sass_options = { :line_numbers => false, :debug_info => false } # output_style = :compressed # output_style = :compact output_style = :expanded
Ruby
environment = :production project_type = :stand_alone http_path = "/" css_dir = "../styles" sass_dir = "." images_dir = "images" sass_options = { :line_numbers => false, :debug_info => false } # output_style = :compressed # output_style = :compact output_style = :expanded
Ruby
environment = :production project_type = :stand_alone http_path = "/" css_dir = "../styles" sass_dir = "." images_dir = "images" sass_options = { :line_numbers => false, :debug_info => false } # output_style = :compressed # output_style = :compact output_style = :expanded
Ruby
environment = :production project_type = :stand_alone http_path = "/" css_dir = "../styles" sass_dir = "." images_dir = "images" sass_options = { :line_numbers => false, :debug_info => false } # output_style = :compressed # output_style = :compact output_style = :expanded
Ruby
environment = :production project_type = :stand_alone http_path = "/" css_dir = "../styles" sass_dir = "." images_dir = "images" sass_options = { :line_numbers => false, :debug_info => false } # output_style = :compressed # output_style = :compact output_style = :expanded
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
require 'net/http' server = "msdl.microsoft.com" pdb = "ntkrnlmp" guid = "30092be745b24fe2a311a936e7b7486f2" uri = "/download/symbols/#{pdb}.pdb/#{guid}/#{pdb}.pd_" dest = "#{pdb}.pd_" puts uri Net::HTTP.start(server) { |http| headers = {"User-Agent" => "Microsoft-Symbol-Server/6.6.0007.5"} resp = http.get(u...
Ruby
# This file is part of Virtdbg # Copyright (C) 2010-2011 Damien AUMAITRE # # Licence is GPLv3, see LICENCE.txt in the top-level directory module VirtDbg VIRTDBGDIR = File.dirname(__FILE__) # add it to the ruby library path $: << VIRTDBGDIR end %w[forensic1394 virtdbg util main system].each { |f| require ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # # this exemple illustrates the use of the cparser/preprocessor #factorize functionnality: # we write some code using standard headers, and t...
Ruby
# This file is part of Virtdbg # Copyright (C) 2010-2011 Damien AUMAITRE # # Licence is GPLv3, see LICENCE.txt in the top-level directory require 'metasm' require 'metasm/dynldr' require 'iconv' class String def utf16_to_iso converter = Iconv.new('ISO-8859-1//IGNORE//TRANSLIT', 'UTF-16') ...
Ruby
# This file is part of Virtdbg # Copyright (C) 2010-2011 Damien AUMAITRE # # Licence is GPLv3, see LICENCE.txt in the top-level directory require 'metasm' require 'metasm/dynldr' include Metasm def calc_checksum(data) data.unpack('C*').inject(0) { |sum, byte| sum+byte } end module VirtDbg class ...
Ruby
# This file is part of Virtdbg # Copyright (C) 2010-2011 Damien AUMAITRE # # Licence is GPLv3, see LICENCE.txt in the top-level directory require 'metasm' require 'metasm/dynldr' include Metasm module VirtDbg class Forensic1394 < Metasm::DynLdr new_api_c File.read(File.join(VIRTDBGDIR, "inc", ...
Ruby
# ripped from metasm/misc class IO def hexdump(ctx={}) ctx[:noend] = true while buf = read(512) and not buf.empty? buf.hexdump(ctx) end ctx.delete :noend ''.hexdump(ctx) end end class String def hexdump(ctx={}) fmt = ctx[:fmt] ||= ['c', 'd', 'a'] ...
Ruby
# This file is part of Virtdbg # Copyright (C) 2010-2011 Damien AUMAITRE # # Licence is GPLv3, see LICENCE.txt in the top-level directory require 'metasm' require 'metasm/dynldr' include Metasm module VirtDbg class VirtDbgMem < VirtualString def initialize(impl, addr=0, length=nil) ...
Ruby
# This file is part of Virtdbg # Copyright (C) 2010-2011 Damien AUMAITRE # # Licence is GPLv3, see LICENCE.txt in the top-level directory require 'metasm' require 'virtdbg' require 'optparse' $VERBOSE = false # parse arguments opts = { :device => 0 } OptionParser.new { |opt| opt.banner = 'Usage: virtdbg....
Ruby
require 'rake' require 'yaml' module PhpThumbHelper ROOT_DIR = File.expand_path(File.dirname(__FILE__)) SRC_DIR = File.join(ROOT_DIR, 'src') DOCS_DIR = File.join(ROOT_DIR, 'apidocs') VERSION = YAML.load(IO.read(File.join(ROOT_DIR, 'config.yml')))['CURRENT_VERSION'].gsub(' ', '-').downcase...
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
# 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
# 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.3...
Ruby