code
stringlengths
1
1.73M
language
stringclasses
1 value
class ChangeColumnConfigGranularityIdToDimenSrcLocations < ActiveRecord::Migration def self.up end def self.down end end
Ruby
class CreateFactSrcPhoneNumbers < ActiveRecord::Migration def self.up create_table :fact_src_phone_numbers do |t| t.integer :dimen_src_location_id t.integer :timestamp t.integer :calls t.timestamps end end def self.down drop_table :fact_src_phone_numbers end end
Ruby
class CreateFactCountByDestNumbers < ActiveRecord::Migration def self.up create_table :fact_count_by_dest_numbers, :id=>false do |t| t.string :indentifying_phone_number t.integer :timestamp t.integer :calls t.timestamps end end def self.down drop_table :fact_co...
Ruby
class DimenSrcLocation < ActiveRecord::Migration def self.up create_table :dimen_src_locations do |t| t.string :identifying_phone_number t.string :iso_country_code t.string :city t.integer :config_granularity_id t.timestamps end end def self.down end end
Ruby
class CreateConfigGranularities < ActiveRecord::Migration def self.up create_table :config_granularities do |t| t.string :mask t.string :description t.timestamps end end def self.down drop_table :config_granularities end end
Ruby
class CreateFactCountBySrcIps < ActiveRecord::Migration def self.up create_table :fact_count_by_src_ips do |t| t.string :src_ip t.integer :timestamp t.integer :calls t.timestamps end end def self.down drop_table :fact_count_by_src_ips end end
Ruby
class AddColumnMaskToDimenTrunkGroupCarrier < ActiveRecord::Migration def self.up add_column :dimen_trunk_group_carriers, :mask, :string end def self.down remove_column :dimen_trunk_group_carriers, :mask end end
Ruby
class AddColumnSecondToCdrRaws < ActiveRecord::Migration def self.up add_column :cdr_raws, :c1_start_time, :string add_column :cdr_raws, :c2_start_time, :string add_column :cdr_raws, :c3_call_duration, :string add_column :cdr_raws, :c4_call_source, :string add_column :cdr_raws, :c5_call_source_q93...
Ruby
class AddColumnsToDimenTrunkGroupCarrier < ActiveRecord::Migration def self.up add_column :dimen_trunk_group_carriers, :src_carrier, :string add_column :dimen_trunk_group_carriers, :src_ip, :string add_column :dimen_trunk_group_carriers, :dimen_dest_vcb_id, :integer add_column :dimen_trunk_group_carri...
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
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run CdrV1::Application
Ruby
#require './app/models/dimen_dest_vcb.rb' require 'active_record' class TestActiveRecord < Test::Unit::TestCase def test_xxx r = DimenDestVcb.new.find(:all) assert(false) end # TODO uninitialized constant DimenTrunkGroupCarrier def test_find_trunk_group_carrier ''' parameters: src...
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
require 'offset' module City_Gen module Bldg_Gen # Convenience Menus for debugging menu = City_Gen.menu.add_submenu("Buildings") menu.add_item("clf_highrise") { model = Sketchup.active_model sel = model.selection building_faces = [] sel.each { |e| building_faces <<...
Ruby
# street_gen.rb #--------------------------------------------------------------------------------------------------- # Version: 0.5.1a # Compatible: SketchUp 7 (PC) # (other versions untested) #--------------------------------------------------------------------------------------------------- # # CHA...
Ruby
# city_gen.rb #--------------------------------------------------------------------------------------------------- # Version: 0.1.2a # Compatible: SketchUp 7 (PC) # (other versions untested) #--------------------------------------------------------------------------------------------------- # # CHANG...
Ruby
=begin rdoc = CityGen CityGen is the Open Source City Generator for Sketchup. Please visit the blog at: citygen.blogger.com and our project website at: code.google.com/p/citygen/ == Disclaimer THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE ...
Ruby
#!/usr/bin/ruby1.9 BYTEPERLINE = 16 def dumpHexLine addr,line,count str = "%04X " % addr if count > BYTEPERLINE count = BYTEPERLINE end i = 0 line.each_byte do |c| if i < count str += "%02X " % c end i += 1 end while i < BYTEPERLINE str += " " i += 1 end str += " |" i = 0 line.each...
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 'mytest_ext' module Mytest def hello puts MytestInt::hello() end module_function :hello end
Ruby
puts 'hello world' #require 'hello2'
Ruby
require "rubygems" require "bundler/setup" require "stringex" ## -- Rsync Deploy config -- ## # Be sure your public key is listed in your server's ~/.ssh/authorized_keys file ssh_user = "user@domain.com" ssh_port = "22" document_root = "~/website.com/" rsync_delete = false rsync_args = "" # Any ext...
Ruby
require 'sass-globbing' # Require any additional compass plugins here. project_type = :stand_alone # Publishing paths http_path = "/" http_images_path = "/images" http_generated_images_path = "/images" http_fonts_path = "/fonts" css_dir = "public/stylesheets" # Local development paths sass_dir = "sass" images_dir = ...
Ruby
source "https://rubygems.org" group :development do gem 'rake', '~> 0.9' gem 'jekyll', '~> 0.12' gem 'rdiscount', '~> 2.0.7' gem 'pygments.rb', '~> 0.3.4' gem 'RedCloth', '~> 4.2.9' gem 'haml', '~> 3.1.7' gem 'compass', '~> 0.12.2' gem 'sass', '~> 3.2' gem 'sass-globbing', '~> 1.0.0' gem 'rubypants...
Ruby
# encoding: utf-8 # # Jekyll category page generator. # http://recursive-design.com/projects/jekyll-plugins/ # # Version: 0.1.4 (201101061053) # # Copyright (c) 2010 Dave Perrett, http://recursive-design.com/ # Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php) # # A generator that crea...
Ruby
# Title: Simple Image tag for Jekyll # Authors: Brandon Mathis http://brandonmathis.com # Felix Schäfer, Frederic Hemberger # Description: Easily output images with optional class names, width, height, title and alt attributes # # Syntax {% img [class name(s)] [http[s]:/]/path/to/image [width [height]] [title ...
Ruby
# Title: jsFiddle tag for Jekyll # Author: Brian Arnold (@brianarn) # Description: # Given a jsFiddle shortcode, outputs the jsFiddle iframe code. # Using 'default' will preserve defaults as specified by jsFiddle. # # Syntax: {% jsfiddle shorttag [tabs] [skin] [height] [width] %} # # Examples: # # Input: {% jsfiddl...
Ruby
# Sitemap.xml Generator is a Jekyll plugin that generates a sitemap.xml file by # traversing all of the available posts and pages. # # How To Use: # 1) Copy source file into your _plugins folder within your Jekyll project. # 2) Change modify the url variable in _config.yml to reflect your domain name. # 3) Run Je...
Ruby
# Title: Include Array Tag for Jekyll # Author: Jason Woodward http://www.woodwardjd.com # Description: Import files on your filesystem as specified in a configuration variable in _config.yml. Mostly cribbed from Jekyll's include tag. # Syntax: {% include_array variable_name_from_config.yml %} # # Example 1: # {% incl...
Ruby
module Jekyll class Pagination < Generator # This generator is safe from arbitrary code execution. safe true # Generate paginated pages if necessary. # # site - The Site. # # Returns nothing. def generate(site) site.pages.dup.each do |page| paginate(site, page) if Pager...
Ruby
require 'pygments' require 'fileutils' require 'digest/md5' PYGMENTS_CACHE_DIR = File.expand_path('../../.pygments-cache', __FILE__) FileUtils.mkdir_p(PYGMENTS_CACHE_DIR) module HighlightCode def highlight(str, lang) lang = 'ruby' if lang == 'ru' lang = 'objc' if lang == 'm' lang = 'perl' if lang == 'pl...
Ruby
module Jekyll # Extended plugin type that allows the plugin # to be called on varous callback methods. # # Examples: # https://github.com/tedkulp/octopress/blob/master/plugins/post_metaweblog.rb # https://github.com/tedkulp/octopress/blob/master/plugins/post_twitter.rb class PostFilter < Plugin #Cal...
Ruby
# Title: Render Partial Tag for Jekyll # Author: Brandon Mathis http://brandonmathis.com # Description: Import files on your filesystem into any blog post and render them inline. # Note: Paths are relative to the source directory, if you import a file with yaml front matter, the yaml will be stripped out. # # Syntax {%...
Ruby
#custom filters for Octopress require './plugins/backtick_code_block' require './plugins/post_filters' require './plugins/raw' require './plugins/date' require 'rubypants' module OctopressFilters include BacktickCodeBlock include TemplateWrapper def pre_filter(input) input = render_code_block(input) inpu...
Ruby
class String def titlecase small_words = %w(a an and as at but by en for if in of on or the to v v. via vs vs.) x = split(" ").map do |word| # note: word could contain non-word characters! # downcase all small_words, capitalize the rest small_words.include?(word.gsub(/\W/, "").downcase) ? w...
Ruby
# Title: Simple Code Blocks for Jekyll # Author: Brandon Mathis http://brandonmathis.com # Description: Write codeblocks with semantic HTML5 <figure> and <figcaption> elements and optional syntax highlighting — all with a simple, intuitive interface. # # Syntax: # {% codeblock [title] [url] [link text] %} # code snippe...
Ruby
# # Author: Brandon Mathis # Based on the semantic pullquote technique by Maykel Loomans at http://miekd.com/articles/pull-quotes-with-html5-and-css/ # # Outputs a span with a data-pullquote attribute set from the marked pullquote. Example: # # {% pullquote %} # When writing longform posts, I find it helpful to i...
Ruby
require 'json' class ConfigTag < Liquid::Tag def initialize(tag_name, options, tokens) super options = options.split(' ').map {|i| i.strip } @key = options.slice!(0) @tag = nil @classname = nil options.each do |option| @tag = $1 if option =~ /tag:(\S+)/ @classname = $1 if option ...
Ruby
# # = RubyPants -- SmartyPants ported to Ruby # # Ported by Christian Neukirchen <mailto:chneukirchen@gmail.com> # Copyright (C) 2004 Christian Neukirchen # # Incooporates ideas, comments and documentation by Chad Miller # Copyright (C) 2004 Chad Miller # # Original SmartyPants by John Gruber # Copyright (C) 2003...
Ruby
module Jekyll require 'haml' class HamlConverter < Converter safe true priority :low def matches(ext) ext =~ /haml/i end def output_ext(ext) ".html" end def convert(content) begin engine = Haml::Engine.new(content) engine.render rescue StandardE...
Ruby
# A Liquid tag for Jekyll sites that allows embedding Gists and showing code for non-JavaScript enabled browsers and readers. # by: Brandon Tilly # Source URL: https://gist.github.com/1027674 # Post http://brandontilley.com/2011/01/31/gist-tag-for-jekyll.html # # Example usage: {% gist 1027674 gist_tag.rb %} //embeds a...
Ruby
module Octopress module Date # Returns a datetime if the input is a string def datetime(date) if date.class == String date = Time.parse(date) end date end # Returns an ordidinal date eg July 22 2007 -> July 22nd 2007 def ordinalize(date) date = datetime(date) ...
Ruby
# # Author: Brandon Mathis # A full rewrite based on the work of: Josediaz Gonzalez - https://github.com/josegonzalez/josediazgonzalez.com/blob/master/_plugins/blockquote.rb # # Outputs a string with a given attribution as a quote # # {% blockquote Bobby Willis http://google.com/search?q=pants the search for bobby's ...
Ruby
# Author: Brandon Mathis # Description: Provides plugins with a method for wrapping and unwrapping input to prevent Markdown and Textile from parsing it. # Purpose: This is useful for preventing Markdown and Textile from being too aggressive and incorrectly parsing in-line HTML. module TemplateWrapper # Wrap input wi...
Ruby
# Title: Simple Video tag for Jekyll # Author: Brandon Mathis http://brandonmathis.com # Description: Easily output MPEG4 HTML5 video with a flash backup. # # Syntax {% video url/to/video [width height] [url/to/poster] %} # # Example: # {% video http://site.com/video.mp4 720 480 http://site.com/poster-frame.jpg %} # # ...
Ruby
# Monkeypatch for Jekyll # Introduce distinction between preview/productive site generation # so posts with YAML attribute `published: false` can be previewed # on localhost without being published to the productive environment. module Jekyll class Site # Read all the files in <source>/<dir>/_posts and create a...
Ruby
require './plugins/pygments_code' module BacktickCodeBlock include HighlightCode AllOptions = /([^\s]+)\s+(.+?)\s+(https?:\/\/\S+|\/\S+)\s*(.+)?/i LangCaption = /([^\s]+)\s*(.+)?/i def render_code_block(input) @options = nil @caption = nil @lang = nil @url = nil @title = nil input.gsub(...
Ruby
# Title: Include Code Tag for Jekyll # Author: Brandon Mathis http://brandonmathis.com # Description: Import files on your filesystem into any blog post as embedded code snippets with syntax highlighting and a download link. # Configuration: You can set default import path in _config.yml (defaults to code_dir: download...
Ruby
require 'bundler/setup' require 'sinatra/base' # The project root directory $root = ::File.dirname(__FILE__) class SinatraStaticServer < Sinatra::Base get(/.+/) do send_sinatra_file(request.path) {404} end not_found do send_file(File.join(File.dirname(__FILE__), 'public', '404.html'), {:status => 404}...
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' }]) # Major.create(:name...
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.string :name t.integer :age t.timestamps end end def self.down drop_table :users end end
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' class ActiveSupport::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 da...
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/dbconsole'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/dbconsole'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/generate'
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module UsersHelper end
Ruby
class User < ActiveRecord::Base 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 protect_from_forgery # See ActionController::RequestForgeryPr...
Ruby
class UsersController < ApplicationController # GET /users # GET /users.xml def index @users = User.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(params[:id]) ...
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 do debug a probl...
Ruby
# Be sure to restart your server when you modify this file. # 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. ActiveReco...
Ruby
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf # Mime::Type.register_alias "text/html", :iphone
Ruby
# Be sure to restart your server when you modify this file. # Your secret key for verifying cookie session data integrity. # If you change this key, all old sessions 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 attacks. Act...
Ruby
ActionController::Routing::Routes.draw do |map| map.resources :users map.root :controller => 'users' end
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 # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') ...
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 # Full error reports are disabled and caching is turned on config.action_controller.consider_all_reque...
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
# $ext_path: This should be the path of where the ExtJS SDK is installed # Generally this will be in a lib/extjs folder in your applications root # <root>/lib/extjs $ext_path = "../../" # sass_path: the directory your Sass files are in. THIS file should also be in the Sass folder # Generally this will be in a resource...
Ruby
# include the utils rb file which has extra functionality for the ext theme dir = File.dirname(__FILE__) require File.join(dir, 'lib', 'utils.rb') # register ext4 as a compass framework Compass::Frameworks.register 'ext4', dir
Ruby
# $ext_path: This should be the path of the Ext JS SDK relative to this file $ext_path = "../../extjs" # sass_path: the directory your Sass files are in. THIS file should also be in the Sass folder # Generally this will be in a resources/sass folder # <root>/resources/sass sass_path = File.dirname(__FILE__) # css_pat...
Ruby
# Compass configurations sass_path = File.dirname(__FILE__) css_path = File.join(sass_path, "..", "css") # Require any additional compass plugins here. images_dir = File.join(sass_path, "..", "img") output_style = :expanded environment = :production
Ruby
module ExtJS4 module SassExtensions module Functions module Utils def parsebox(list, n) assert_type n, :Number if !n.int? raise ArgumentError.new("List index #{n} must be an integer") elsif n.to_i < 1 raise ArgumentError.new("List index #{n} must...
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
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