code
stringlengths
1
1.73M
language
stringclasses
1 value
=begin = File webcapture.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in the ...
Ruby
=begin = File metadata.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public Licens...
Ruby
=begin = File signature.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in the h...
Ruby
=begin = File export.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume DelugrÈ <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License ...
Ruby
=begin = File array.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume DelugrÈ <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License a...
Ruby
=begin = File filters/jpx.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public Lic...
Ruby
=begin = File filters/lzw.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public Lic...
Ruby
=begin = File filters/dct.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public Lic...
Ruby
=begin = File filters/crypt.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public L...
Ruby
=begin = File filters/runlength.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Publ...
Ruby
=begin = File filters/predictors.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Pub...
Ruby
=begin = File filters/flate.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public L...
Ruby
=begin = File filters/jbig2.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public L...
Ruby
=begin = File filters/ascii.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public L...
Ruby
=begin = File filters/ccitt.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public L...
Ruby
=begin = File file.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as...
Ruby
=begin = File boolean.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume DelugrÈ <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License...
Ruby
=begin = File stream.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in the hope...
Ruby
=begin = File parsers/pdf.rb = Info This file is part of Origami, PDF manipulation framework for Ruby Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org> All right reserved. Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public Lic...
Ruby
=begin = File parsers/linear.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in ...
Ruby
=begin = File parsers/ppklite.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in...
Ruby
=begin = File parsers/fdf.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in the...
Ruby
=begin = File page.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in the hope t...
Ruby
=begin = File xreftable.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in the h...
Ruby
=begin = File object.rb = Info Origami is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Origami is distributed in the hope...
Ruby
source :gemcutter gem 'sinatra', :require => 'sinatra/base' gem 'thin', '~> 1.3' gem 'pg' gem 'data_mapper', '~> 1.2' gem 'dm-postgres-adapter' gem 'google-api-client', '>= 0.4.3' group :development do gem 'dm-sqlite-adapter', '~> 1.2' gem 'do_sqlite3', '~> 0.10' 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 'data_mapper', '~> 1.2' gem 'dm-postgres-adapter' gem 'google-api-client', '>= 0.4.3' group :development do gem 'dm-sqlite-adapter', '~> 1.2' gem 'do_sqlite3', '~> 0.10' 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
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) # Mayor.create(:name =>...
Ruby
class CreateChannels < ActiveRecord::Migration def self.up create_table :channels do |t| t.string :name t.timestamps end end def self.down drop_table :channels end end
Ruby
class AddGuids < ActiveRecord::Migration def self.up change_column :channels, :id, :string change_column :messages, :id, :string end def self.down change_column :messages, :id, :string change_column :channels, :id, :string end end
Ruby
class CreateMessages < ActiveRecord::Migration def self.up create_table :messages, :force => true do |t| t.text :body t.string :channel_id t.string :name t.timestamps end end def self.down drop_table :messages end end
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. # # Note: You'll currently still have to declare fixtures explicitly in integrati...
Ruby
source "http://rubygems.org" gem "rails", "3.0.5" gem "less", :git => "git://github.com/maccman/less.git" gem "rack-less" gem "rack-sprockets" gem "yui-compressor" gem "supermodel" gem "sqlite3" gem "juggernaut" gem "thin" gem "omniauth" gem "carrierwave" group :development do gem "ruby-debug19", :require => "ru...
Ruby
#!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands'
Ruby
#!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands'
Ruby
module ApplicationHelper end
Ruby
module AuthorizeHelper end
Ruby
module AssetsHelper end
Ruby
module AppHelper def script_template(name, id = nil) id ||= name id += "_template" id = id.camelize(:lower) content_tag(:script, :type => "text/template", :id => id) do render :partial => name end end def meta_tag(name, value) %(<meta name="#{name}" content="#{Rack::Utils.escape_h...
Ruby
module ChannelsHelper end
Ruby
class JuggernautObserver < ActiveRecord::Observer observe :message, :channel def after_create(rec) publish(:create, rec) end def after_update(rec) publish(:update, rec) end def after_destroy(rec) publish(:destroy, rec) end protected def publish(type, rec) Juggernaut.p...
Ruby
class Channel < ActiveRecord::Base has_many :messages, :dependent => :destroy # include ActiveRecord::GUID attr_accessible :id, :name end
Ruby
class Asset < CarrierWave::Uploader::Base storage :file class << self def find(id) self.new.tap do |rec| rec.retrieve_from_store!(id) end end def create(file) file = CarrierWave::SanitizedFile.new(file) self.new.tap do |rec| rec.store!({ :tempfil...
Ruby
class Message < ActiveRecord::Base belongs_to :channel validates_presence_of :body, :channel_id attr_accessible :id, :body, :name, :channel_id # include ActiveRecord::GUID end
Ruby
class MessagesController < ApplicationController before_filter :require_user def index @messages = Message.all render :json => @messages end def create message = Message.new(params) message.name = current_user message.save! head :ok end def update message = Message.find(...
Ruby
class ApplicationController < ActionController::Base protect_from_forgery protected def current_user cookies.signed[:handle] end def require_user unless current_user respond_to do |format| format.html { flash[:error] = "You must be logged in to...
Ruby
class AuthorizeController < ApplicationController def create cookies.permanent.signed[:handle] = request.env["omniauth.auth"]["user_info"]["nickname"] redirect_to "/" end def failure raise "OAuth failure - #{params[:message]}" end def destroy cookies.delete(:handle) end end
Ruby
class AssetsController < ApplicationController def show @asset = Asset.find(params[:id]) send_file @asset.path end def create @asset = Asset.create(params[:file]) render :json => {:url => asset_url(@asset)} end end
Ruby
class ChannelsController < ApplicationController before_filter :require_user before_filter :find_channel, :only => [:update, :destroy] def index @channels = Channel.all render :json => @channels end def create Channel.create!(params) head :ok end def update @channel.update_att...
Ruby
class AppController < ApplicationController before_filter :require_user layout false end
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. # 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
ActionView::Helpers::AssetTagHelper.register_javascript_expansion :juggernaut => ["http://localhost:8080/application.js"]
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. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf # Mime::Type.register_alias "text/html", :iphone
Ruby
Rails.application.config.middleware.use OmniAuth::Builder do provider :twitter, 'imkhJ6VxilZIA7AO36XpHg', 'FsFr1yuVI7RMp9O7v97j8dHkwSfFKeLMcgK74hyys', :sign_in => true end
Ruby
# Be sure to restart your server when you modify this file. Holla2::Application.config.session_store :cookie_store, :key => '_holla4_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 with "rails ...
Ruby
require "active_record/guid"
Ruby
Holla2::Application.routes.draw do # The priority is based upon order of creation: # first created -> highest priority. # Sample of regular route: # match 'products/:id' => 'catalog#view' # Keep in mind you can assign values other than :controller and :action # Sample of named route: # match 'produc...
Ruby
require 'rubygems' # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
Ruby
require File.expand_path('../boot', __FILE__) require 'rails/all' # If you have a Gemfile, require the gems listed there, including any gems # you've limited to :test, :development, or :production. Bundler.require(:default, Rails.env) if defined?(Bundler) module Holla2 class Application < Rails::Application # ...
Ruby
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application Holla2::Application.initialize!
Ruby
Holla2::Application.configure do # Settings specified here will take precedence over those in config/application.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Full error reports are disabled and caching is turned on ...
Ruby
Holla2::Application.configure do # Settings specified here will take precedence over those in config/application.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 webser...
Ruby
Holla2::Application.configure do # Settings specified here will take precedence over those in config/application.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 s...
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run Holla2::Application
Ruby
# Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path('../config/application', __FILE__) require 'rake' Holla2::Application.load_tasks
Ruby
module ActiveRecord module GUID def self.included(base) base.class_eval do before_create :set_default_id if column_names.include?("created_at") default_scope :order => "created_at ASC" end end base.extend ClassMethods end private def set_default_i...
Ruby
# If the sql has some returned rows (e.g. it was a SELECT) db.query( sql ) do |rows| # Go through every returned row rows.each do |row| # Create a temporary hash tmp = {} # Force the array columns into Hash Key/Value pairs for i in 0 .. rows.columns.length-1 tmp[row...
Ruby
#!/usr/bin/env ruby # Import all the external libraries require 'cgi' require 'rubygems' require_gem 'sqlite3-ruby' require 'json/objects' # Display the Javascript header print "Content-type: text/javascript\n\n" # Initalize the application variables err = "" r = [] cgi = CGI.new # Capture parameters passed in by t...
Ruby
# Import the CGI library require 'cgi' # Create a new CGI object, which will parse # the incoming CGI parameters cgi = CGI.new # Capture the SQL query parameter sql = cgi['sql'] # Get the database name from the user and make # sure that no malicious characters were used d = cgi['db'].gsub(/[^a-zA-Z0-9_-]/, "")
Ruby
#!/usr/bin/env ruby # Import all the external libraries require 'cgi' require 'rubygems' require_gem 'sqlite3-ruby' require 'json/objects' # Display the Javascript header print "Content-type: text/javascript\n\n" # Initalize the application variables err = "" r = [] cgi = CGI.new # Capture parameters passed in by t...
Ruby
# Import the external SQLite library require 'rubygems' require_gem 'sqlite3-ruby' # Later on in the program… # Connect to the SQLite database, which is just a file # 'd' contains the name of our database, which is 'wiki' db = SQLite3::Database.new('../../data/' + d + '.db')
Ruby
rows.columns = ["title","author","content","date"] rows = [ ["HomePage","John","Welcome to my wonderful wiki!","20060324122514"], ["Test","Anonymous","Lorem ipsum dolem…","20060321101345"], … ]
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 '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
#!/usr/bin/env ruby require 'nokogiri' string_to_remove = ['first_run_message', 'first_run_message_free', 'first_run_title'] string_files = [] Dir.glob('res/values*').each do |d| file = d << "/strings.xml" string_files << file if File.exists?(file) end string_files.sort! ...
Ruby
#!/usr/bin/env ruby # encoding: utf-8 require 'nokogiri' # read in convert.xml to see which how to convert the string-arrays # for each strings.xml in res/values res/values-?? res/values-??-* # find the string-arrays that match the ones in convert.xml and for each # remove opening and closing string-array tag #...
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
#!/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
# 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 '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 '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 'albacore' require 'version_bumper' bumper_file "version.txt" # Read any atypical version bump type from environment/command-line. # e.g., rake bumpType=minor # bumpType=major -> 2.3.251.0 becomes 3.0.0.0 # bumpType=minor -> 2.3.251.0 becomes 2.4.0.0 # no bumpType specified -> 2.3.251.0 becomes 2.3.252...
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper def form_submit if controller.action_name == 'new' or controller.action_name == 'create' 'Создать' elsif controller.action_name == 'edit' or controller.action_name == 'update' 'Обновить' ...
Ruby
module BusinessProcessClassesHelper end
Ruby