code
stringlengths
1
1.73M
language
stringclasses
1 value
#!/usr/bin/ruby require 'rubygems' require 'google/api_client' require 'logger' require 'oauth/oauth_util' require 'sqlite3' require 'thread' require 'trollop' YOUTUBE_API_READONLY_SCOPE = 'https://www.googleapis.com/auth/youtube.readonly' YOUTUBE_ANALYTICS_API_SCOPE = 'https://www.googleapis.com/auth/yt-analytics.re...
Ruby
require 'google/api_client' require 'google/api_client/client_secrets' require 'json' require 'launchy' require 'thin' RESPONSE_HTML = <<stop <html> <head> <title>OAuth 2 Flow Complete</title> </head> <body> You have successfully completed the OAuth 2 flow. Please close this browser window and return to ...
Ruby
#!/usr/bin/ruby require 'rubygems' require 'google/api_client' # oauth/oauth_util is not part of the official Ruby client library. # Get it at http://samples.google-api-ruby-client.googlecode.com/git/oauth/oauth_util.rb require 'oauth/oauth_util' require 'trollop' # This code assumes that there's a client_secrets.j...
Ruby
NOT READY YET #!/usr/bin/ruby require 'rubygems' require 'google/api_client' require 'oauth/oauth_util' client = Google::APIClient.new youtube = client.discovered_api('youtube', 'v3alpha') auth_util = CommandLineOAuthHelper.new('https://www.googleapis.com/auth/youtube') client.authorization = auth_util.authorize() ...
Ruby
#!/usr/bin/ruby require 'rubygems' require 'google/api_client' # oauth/oauth_util is not part of the official Ruby client library. # Get it at http://samples.google-api-ruby-client.googlecode.com/git/oauth/oauth_util.rb require 'oauth/oauth_util' require 'trollop' # An OAuth 2 access scope that allows for full read...
Ruby
require 'google/api_client' require 'google/api_client/client_secrets' require 'json' require 'launchy' require 'thin' RESPONSE_HTML = <<stop <html> <head> <title>OAuth 2 Flow Complete</title> </head> <body> You have successfully completed the OAuth 2 flow. Please close this browser window and return to ...
Ruby
#!/usr/bin/ruby require 'rubygems' require 'google/api_client' # oauth/oauth_util is not part of the official Ruby client library. # Get it at http://samples.google-api-ruby-client.googlecode.com/git/oauth/oauth_util.rb require 'oauth/oauth_util' # An OAuth 2 access scope that allows for full read/write access. YOU...
Ruby
#!/usr/bin/ruby require 'rubygems' require 'google/api_client' require 'trollop' # Set DEVELOPER_KEY to the "API key" value from the "Access" tab of the # Google APIs Console <http://code.google.com/apis/console#access> # Please ensure that you have enabled the YouTube Data API for your project. DEVELOPER_KEY = "REP...
Ruby
#!/usr/bin/ruby require 'rubygems' require 'google/api_client' # oauth/oauth_util is not part of the official Ruby client library. # Get it at http://samples.google-api-ruby-client.googlecode.com/git/oauth/oauth_util.rb require 'oauth/oauth_util' # A limited OAuth 2 access scope that allows for read-only access. YO...
Ruby
#/usr/bin/env ruby require 'minigems' require 'cloudservers' require 'terminal-table' require 'colorize' class Interface def initialize(username, apikey) @username = username @apikey = apikey end def connect #Assume use connection @conn = CloudServers::Connection.new(:us...
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
# default rake file used for deployment task :default do puts "hello world" end
Ruby
#-- # Interface to tool configuration # # Author:: Lachlan Donald (mailto:lachlan@ljd.cc) # Copyright:: Copyright (c) 2007-2008 Lachlan Donald # License:: MIT #++ require 'yaml' require 'ostruct' module Cloudwire class YamlConfiguration def initialize(file) @yaml = YAML.load_file(file) end def method_missi...
Ruby
#------------------------------------------------------------ # top-level cloudwire module require 'logger' module Cloudwire CLOUDWIRE_VERSION = '0.1' # gets the version of cloudwire def self.version return CLOUDWIRE_VERSION end def self.logger unless defined? @logger @logger = Logger.new(STDOUT) @l...
Ruby
#!/usr/bin/env ruby require 'rubygems' require 'ramaze' # require all controllers and models acquire __DIR__/:controller/'*' acquire __DIR__/:model/'*' Ramaze.start :adapter => :mongrel, :port => 80
Ruby
#!/usr/bin/env ruby require 'rubygems' require 'ramaze' # require all controllers and models acquire __DIR__/:controller/'*' acquire __DIR__/:model/'*' Ramaze.start :adapter => :mongrel, :port => 80
Ruby
# Default url mappings are: # a controller called Main is mapped on the root of the site: / # a controller called Something is mapped on: /something # If you want to override this, add a line like this inside the class # map '/otherurl' # this will force the controller to be mounted on: /otherurl class MainControll...
Ruby
require 'ramaze' require 'ramaze/spec/helper' require __DIR__/'..'/'start' describe MainController do behaves_like 'http', 'xpath' ramaze :view_root => __DIR__/'../view', :public_root => __DIR__/'../public' it 'should show start page' do got = get('/') got.status.should == 200 got.at('//ti...
Ruby
#!/usr/bin/env rackup # start.ru for ramaze apps # use thin>=0.6.3 # thin start -r start.ru # # rackup is a useful tool for running Rack applications, which uses the # Rack::Builder DSL to configure middleware and build up applications easily. # # rackup automatically figures out the environment it is run in, and runs ...
Ruby
require 'rubygems' require 'sequel' # require 'memcache' DB = Sequel.mysql('jitter_db', :user => 'jitter', :password => 'Jitter', :host => 'localhost') # CACHE = MemCache.new 'localhost:11211', :namespace => 'jitter' class Users < Sequel::Model(:users) set_schema do # You can't define a column and name...
Ruby
#!/usr/bin/env ruby require 'rubygems' require 'ramaze' # FCGI doesn't like you writing to stdout Ramaze::Log.loggers = [ Ramaze::Informer.new( File.join(__DIR__, '..', 'ramaze.fcgi.log') ) ] Ramaze::Global.adapter = :fcgi $0 = File.join(__DIR__, '..', 'start.rb') require $0
Ruby
#!/usr/bin/env ruby require 'rubygems' require 'ramaze' # FCGI doesn't like you writing to stdout Ramaze::Log.loggers = [ Ramaze::Informer.new( File.join(__DIR__, '..', 'ramaze.fcgi.log') ) ] Ramaze::Global.adapter = :fcgi $0 = File.join(__DIR__, '..', 'start.rb') require $0
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...
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 :users # 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 :cont...
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module UsersHelper end
Ruby
module SessionHelper end
Ruby
class Friendship < ActiveRecord::Base belongs_to :user, :class_name => 'User', :foreign_key => 'user_id' belongs_to :user, :class_name => 'User', :foreign_key => 'friend_id' end
Ruby
class User < ActiveRecord::Base has_many :friendships def add_friend friend_name friend = User.find_by_name friend_name return if friend.nil? || friend.id == id return if !(friendships.find_by_friend_id(friend.id)).nil? friendship = Friendship.new friendship.user_id = ...
Ruby
class SessionController < ApplicationController 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 # See ActionController::RequestForgeryProtection for details...
Ruby
class UsersController < ApplicationController # GET /users # GET /users.xml def index @users = User.find(:all) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @users } end end # GET /users/1 # GET /users/1.xml def show @user = User.find(...
Ruby
# Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require(File.join(File.dirname(__FILE__), 'config', 'boot')) require 'rake' require 'rake/testtask' require 'rake/rdoctask' require 'tasks/rails'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/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/runner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/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/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/plugin'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/dbconsole'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/reaper'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/inspector'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/inspector'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/spawner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/reaper'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/spawner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/plugin'
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.string :name t.string :password t.timestamps end create_table :friendships do |t| t.integer :user_id t.integer :friend_id t.timestamps end end def self.down drop_table :use...
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
#!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
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
require 'google/api_client' require 'google/api_client/client_secrets' require 'json' require 'launchy' require 'thin' RESPONSE_HTML = <<stop <html> <head> <title>OAuth 2 Flow Complete</title> </head> <body> You have successfully completed the OAuth 2 flow. Please close this browser window and return to ...
Ruby
#!/usr/bin/ruby require 'rubygems' require 'google/api_client' require 'logger' require 'oauth/oauth_util' require 'sqlite3' require 'thread' require 'trollop' YOUTUBE_API_READONLY_SCOPE = 'https://www.googleapis.com/auth/youtube.readonly' YOUTUBE_ANALYTICS_API_SCOPE = 'https://www.googleapis.com/auth/yt-analytics.re...
Ruby
#!/usr/bin/ruby require 'rubygems' require 'google/api_client' # oauth/oauth_util is not part of the official Ruby client library. # Get it at http://samples.google-api-ruby-client.googlecode.com/git/oauth/oauth_util.rb require 'oauth/oauth_util' require 'trollop' # This code assumes that there's a client_secrets.j...
Ruby
#!/usr/bin/ruby require 'rubygems' require 'google/api_client' # oauth/oauth_util is not part of the official Ruby client library. # Get it at http://samples.google-api-ruby-client.googlecode.com/git/oauth/oauth_util.rb require 'oauth/oauth_util' # A limited OAuth 2 access scope that allows for read-only access. YO...
Ruby
#!/usr/bin/ruby require 'rubygems' require 'google/api_client' # oauth/oauth_util is not part of the official Ruby client library. # Get it at http://samples.google-api-ruby-client.googlecode.com/git/oauth/oauth_util.rb require 'oauth/oauth_util' require 'trollop' # An OAuth 2 access scope that allows for full read...
Ruby
#!/usr/bin/ruby require 'rubygems' require 'google/api_client' require 'trollop' # Set DEVELOPER_KEY to the "API key" value from the "Access" tab of the # Google APIs Console <http://code.google.com/apis/console#access> # Please ensure that you have enabled the YouTube Data API for your project. DEVELOPER_KEY = "REP...
Ruby
require 'google/api_client' require 'google/api_client/client_secrets' require 'json' require 'launchy' require 'thin' RESPONSE_HTML = <<stop <html> <head> <title>OAuth 2 Flow Complete</title> </head> <body> You have successfully completed the OAuth 2 flow. Please close this browser window and return to ...
Ruby
NOT READY YET #!/usr/bin/ruby require 'rubygems' require 'google/api_client' require 'oauth/oauth_util' client = Google::APIClient.new youtube = client.discovered_api('youtube', 'v3alpha') auth_util = CommandLineOAuthHelper.new('https://www.googleapis.com/auth/youtube') client.authorization = auth_util.authorize() ...
Ruby
#!/usr/bin/ruby require 'rubygems' require 'google/api_client' # oauth/oauth_util is not part of the official Ruby client library. # Get it at http://samples.google-api-ruby-client.googlecode.com/git/oauth/oauth_util.rb require 'oauth/oauth_util' # An OAuth 2 access scope that allows for full read/write access. YOU...
Ruby
# -*- ruby -*- require 'rubygems' require 'rake' require 'rake/gempackagetask' require 'lib/cloudsponge' PKG_FILES = FileList["**/*"].exclude(/CVS|pkg|tmp|coverage|Makefile|\.nfs\./) spec = Gem::Specification.new do |s| s.name = 'cloudsponge' s.version = Cloudsponge::VERSION s.author = "Graeme Rouse" s.email...
Ruby
# -*- ruby -*- require 'rubygems' require 'rake' require 'rake/gempackagetask' require 'lib/cloudsponge' PKG_FILES = FileList["**/*"].exclude(/CVS|pkg|tmp|coverage|Makefile|\.nfs\./) spec = Gem::Specification.new do |s| s.name = 'cloudsponge' s.version = Cloudsponge::VERSION s.author = "Graeme Rouse" s.email...
Ruby
require File.expand_path(File.dirname(__FILE__) + '/cloudsponge/contact_importer') require File.expand_path(File.dirname(__FILE__) + '/cloudsponge/contact') require File.expand_path(File.dirname(__FILE__) + '/cloudsponge/event') require File.expand_path(File.dirname(__FILE__) + '/cloudsponge/cs_exception') require File...
Ruby
module Cloudsponge EVENT_TYPES = %w{ INITIALIZING GATHERING SUBMITTING COMPLETE ERROR} EVENT_STATUSES = %w{ PENDING INPROGRESS COMPLETED ERROR } class Event attr_accessor :event_type, :status, :value, :description def self.from_array(list) list.map { |event_data| Event.new(event_data) }.compact ...
Ruby
module Cloudsponge class Contact attr_accessor :first_name, :last_name, :emails, :phones def self.from_array(list) list.map { |contact_data| Contact.new(contact_data) }.compact end def initialize(contact_data) # get the basic data self.first_name = contact_data['first_name'] ...
Ruby
module Cloudsponge require "net/http" require "net/https" require "uri" begin require 'json' rescue end class Utility def self.object_to_query(object) return object unless object.is_a? Hash object.map{ |k,v| "#{URI.encode(k.to_s)}=#{URI.encode(v.to_s)}" }.join('&') end ...
Ruby
# CloudSponge.com Ruby Library # http://www.cloudsponge.com # Copyright (c) 2010 Cloud Copy, Inc. # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php # # Written by Graeme Rouse # graeme@cloudsponge.com module Cloudsponge # Constants URL_BASE = "https://api.cloudsponge.com/" ...
Ruby
module Cloudsponge class CsException < StandardError attr :code def initialize(message, code) super(message) @code = code end end end
Ruby
require "test/unit" require "../lib/cloudsponge" class TestUtility < Test::Unit::TestCase def test_decode_response require "json" object = {'key1' => 'value1', 'key2' => 'value2', 'integer_key' => 5} assert_equal object, Cloudsponge::Utility.decode_response(JSON.generate(object)) end end
Ruby
require "test/unit" require "cloudsponge" class TestContact < Test::Unit::TestCase def test_new_from_data data = {'first_name' => 'John', 'last_name' => 'Smith', 'email' => nil, 'phone' => nil} assert contact = Cloudsponge::Contact.new(data) assert_equal data['first_name'], contact.first_name assert_...
Ruby
require "test/unit" require File.dirname(__FILE__) + "/../lib/cloudsponge" class TestContactImporter < Test::Unit::TestCase def test_version_exists assert Cloudsponge::VERSION end DOMAIN_KEY = "Your Domain Key" DOMAIN_PASSWORD = "Your Domain Password" def test_u_p_import contacts = nil impo...
Ruby