text stringlengths 10 2.61M |
|---|
# encoding: ascii-8bit
dir = File.expand_path "~/.ruby_inline"
if File.directory? dir then
require "fileutils"
puts "nuking #{dir}"
# force removal, Windoze is bitching at me, something to hunt later...
FileUtils.rm_r dir, :force => true
end
require "minitest/autorun"
require "rubygems"
require "png"
require ... |
require 'spec_helper'
feature 'user can follow others' do
scenario 'user follows and unfollows another user' do
comedy = Fabricate(:category)
sarah = Fabricate(:user)
bob = Fabricate(:user)
futurama = Fabricate(:video, title: 'Futurama', category: comedy)
review = Fabricate(:review, user: bob, vi... |
# 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 rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
#!/usr/bin/env ruby
require 'wunderbar/script'
require 'ruby2js/filter/functions'
require 'whimsy/asf'
ldaplist = ASF::Person.list
ldap = ldaplist.map(&:id)
errors = 0
_html do
_style %{
table {border-collapse: collapse}
table, th, td {border: 1px solid black}
td {padding: 3px 6px}
tr:hover td {back... |
require "indocker/version"
require 'logger'
$LOAD_PATH << File.join(__dir__, 'indocker')
require_relative 'indocker/colored_string'
module Indocker
module Repositories
autoload :Abstract, 'repositories/abstract'
autoload :Git, 'repositories/git'
autoload :Local, 'repositories/local'
autoload :NoSync... |
class AdvanceSearchesController < ApplicationController
before_action :set_advance_search, only: [:show, :edit, :update, :destroy]
# GET /advance_searches
# GET /advance_searches.json
def index
@advance_searches = AdvanceSearch.all
end
# GET /advance_searches/1
# GET /advance_searches/1.json
def s... |
class PartOfEquipmentDetail < ActiveRecord::Base
belongs_to :part_of_equipment, :touch => true
belongs_to :working_group
belongs_to :phase
belongs_to :sector
end
|
class Photo < ApplicationRecord
belongs_to :user
belongs_to :place
validates :caption, :picture, presence: true
mount_uploader :picture, PictureUploader
end
|
require 'minitest'
require 'minitest/autorun'
require 'minitest/pride'
require './test/test_helper'
require './lib/notifications/email/signup_confirmation'
class SignupConfirmationTest < Minitest::Test
def data
{
"name" => "Alice Smith",
"email" => "alice@example.com",
}
end
attr_reader :ema... |
class ProduceOrderItemsController < ApplicationController
before_action :set_produce_order_item, only: [:show, :edit, :update, :destroy]
# GET /produce_order_items
# GET /produce_order_items.json
def index
@produce_order_items = ProduceOrderItem.all
end
# GET /produce_order_items/1
# GET /produce_or... |
require 'rails_helper'
describe TeamRequest do
describe 'validation' do
before :each do
@user = FactoryGirl.create(:user)
end
it "should pass with valid parameters" do
request = FactoryGirl.build(:team_request)
expect(request).to be_valid
end
it "should fail for having no sour... |
class UsersController < ApplicationController
before_action :authenticate_user!, except: [:new, :create]
attr_accessor :avatar, :avatar_cache
def new
@user = User.new
end
def create
# uploader = AvatarUploader.new
# uploader.store!(params[:user][:avatar])
# uploader.thumb.url
@user = User.new(user_par... |
class Micropost < ApplicationRecord
belongs_to :user
validates :content,length:{maximum:20}
presence: ture
end
|
class Tip < ActiveRecord::Base
include Uuid
include FuzzyFind
default_scope -> { order "created_at DESC" }
belongs_to :user
belongs_to :noun, polymorphic: true
has_many :purchases
has_many :purchasers, through: :purchases, source: :user, inverse_of: :purchased_tips
validates_presence_of :subject
va... |
class ChangePhonetoStringClientsModel < ActiveRecord::Migration
def change
change_column :clients, :phone, :string
end
end
|
require 'rspec'
require_relative '../avl_tree';
RSpec.describe AVLTree do
context 'initialize' do
it 'initializes an AVL tree with root nil' do
tree = AVLTree.new
expect(tree.root).to be(nil);
end
end
context 'insert' do
left_heavy_tree = AVLTree.new
it 'makes the first node insert... |
module Matchers
class MatchSnapshot < RSpec::Matchers::BuiltIn::Eq
def initialize(snapshot, formatter)
@snapshot = snapshot
@formatter = formatter
super(@snapshot.read)
end
def matches?(actual)
actual = @formatter.normalize(actual)
if @snapshot.read && !ENV['UPDATE_SNAPSHOT... |
module PostsHelper
def post_owner?
@post.user == current_user
end
end
|
module Cirrocumulus
class Message
def self.stop_md(disk_number)
msg = self.new(nil, 'request', [:stop, [:disk, [:disk_number, disk_number]]])
msg.ontology = 'cirrocumulus-xen'
msg
end
def self.query_export(reply_with, disk_number)
msg = Cirrocumulus::Message.new(nil, 'query-if', ... |
require 'test_helper'
class ControlqnyttsControllerTest < ActionDispatch::IntegrationTest
setup do
@controlqnytt = controlqnytts(:one)
end
test "should get index" do
get controlqnytts_url
assert_response :success
end
test "should get new" do
get new_controlqnytt_url
assert_response :suc... |
class CreateJoinTableSitePhasesTypochronologicalUnits < ActiveRecord::Migration[5.2]
def change
create_join_table :site_phases, :typochronological_units do |t|
t.index [:site_phase_id, :typochronological_unit_id], name: :index_sptu
end
end
end
|
class AddSchoolToSavingsItem < ActiveRecord::Migration
def change
add_column :savings_items, :school_name, :string
end
end
|
LoLStats::Application.routes.draw do
root to: "games#index"
resources :games
devise_for :users
end
|
require 'rails_helper'
RSpec.describe InstructorProfile, :type => :model do
it "has a valid factory" do
expect(FactoryGirl.build(:instructor_profile)).to be_valid
end
describe "validations" do
subject { FactoryGirl.build :instructor_profile }
context "profile_path" do
it { should validate_pre... |
module Ticketing
module Invoice
class BasicEntityRepresentation < BaseRepresentation
def amount(entity)
entity.amount
end
def id(entity)
entity.id.to_s
end
private
def representation
{
id: :id,
amount: :amount
}
end
... |
class ContactsController < ApplicationController
def create
@message = ActionController::Base.helpers.sanitize(params[:details])
@person = current_tenant || current_landlord
respond_to :js
begin
TurnkiiMailer.contact(@person,@message).deliver
rescue Net::SMTPAuthenticationError, Net::SMTP... |
# @author Mathias Bayon
require 'crypt/rijndael'
require 'securerandom'
require 'benchmark'
require 'YAML'
# Properties singleton class
class Messages
# Returns properties.yaml messages
def self.get()
@@messages ||= YAML.load_file("properties.yaml")
end
end
# MBA_crypt class
class MBA_crypt
... |
#!/usr/bin/ruby -w
Inf = 1.0/0
def prompt(*args)
input_arg=false
until input_arg do
print(*args)
value=Float(gets) rescue false
input_arg=value rescue false
if (0..Inf) === value
input_arg=true
else
input_arg=false
end
end
return value
end
def create_monthly_bills_array(mo... |
class CreateIndexPostMsg < ActiveRecord::Migration[5.1]
def change
create_table :index_post_msgs do |t|
t.string :msg
t.integer :state, default: 0
t.references :receiver, index: false
t.references :sender, index: false
t.references :resource, polymorphic: true, index: false
t.s... |
class AddCityRegionPostalCodeToUser < ActiveRecord::Migration[5.2]
def change
add_column :users, :city, :string, null: false, default: ''
add_index :users, :city
add_column :users, :region, :string, null: false, default: ''
add_index :users, :region
add_column :users, :postal_code, :string, null: ... |
#!/usr/bin/env ruby
# Fetch from the expedition database and create an XML document to fit with the
# OAIPMH server
#
# Author: srldl
#
########################################
require './server'
require './config'
require 'net/http'
require 'net/ssh'
require 'net/scp'
require 'time'
require 'date'
require 'json'
requ... |
require 'spec_helper'
RSpec.describe Fluent::Plugin::WorkatoFilter do
let(:config) {
'<label @ERROR>
<match **>
@type stdout
</match>
</label>'
}
let(:driver) { Fluent::Test::Driver::Filter.new(described_class).configure(config) }
let(:result) { driver.filtered_records.first }
... |
class RemoveCodeTranslations < ActiveRecord::Migration
def up
drop_table :code_translations
end
def down
raise ActiveRecord::IrreversibleMigration, "Can't recover the deleted table"
end
end
|
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = "rtree"
s.version = "0.3.5"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Alessandro Berardi,,,"]
s.date = "2011-11-28"
s.email = "berardialessandro@gmail.com"
s.extra... |
class MessageCenter::InstallGenerator < Rails::Generators::Base
source_root File.expand_path('../templates', __FILE__)
def create_initializer_file
template 'initializer.rb', 'config/initializers/message_center.rb'
end
def copy_migrations
Rails.application.load_tasks
Rake::Task['message_center:inst... |
require "sinatra"
require "sinatra/reloader" if development?
require "tilt/erubis"
before do
@toc = File.readlines('data/toc.txt')
end
helpers do
def in_paragraphs(text)
paragraphs = text.split("\n\n")
paragraphs.map.with_index { |para, idx| "<p id='#{idx}'>#{para}</p>" }.join('')
end
def highlight(t... |
module NotesHelper
def format_date(note)
note.note_date.strftime("#{note.note_date.day.ordinalize} %b %Y")
end
def short_format_date(note)
note.note_date.strftime("%a #{note.note_date.day.ordinalize} %b")
end
def table_header
url = request.path_info
if url.include? 'tags'
request[:tag]... |
require 'net/http'
require 'uri'
require 'json'
require_relative 'hyperoslo_extensions'
module CvBot
module Replies
def show_welcome_message
reply_with_text(I18n.t('show_welcome_message.hello_user', name: user['first_name']))
simulate_typing 1
reply_with_text(I18n.t('show_welcome_message.happ... |
class Sable::DSL::Converter
def initialize(service_accounts)
@service_accounts = service_accounts
end
def convert
@service_accounts.map do |email, service_account|
output_service_account(service_account)
end.join("\n")
end
private
def output_service_account(service_account)
<<-EOS
s... |
class AddForienKeysForGoalAndActionGoal < ActiveRecord::Migration
def change
add_reference :statuses, :goal, index: true
add_foreign_key :statuses, :goals
add_reference :statuses, :action_goal, index: true
add_foreign_key :statuses, :action_goals
end
end
|
class Timer
def seconds
@seconds = 0
end
def seconds= seconds
@seconds = seconds
end
def time_string
@time_string = padded @seconds
end
def padded seconds
puts "#{seconds}"
hours = seconds / (60 * 60)
minutes = (seconds / 60) - (hours * 60)
seconds = seconds - (hours * (60 * 60)) - (minutes * 60... |
Rails.application.routes.draw do
devise_for :users
# root is the channels show
root to: 'channels#show'
resources :channels, only: [ :show ]
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
# we need this route within the api so that we can FETCH from t... |
require 'test_helper'
class CommentTest < ActiveSupport::TestCase
setup do
@comment = FactoryGirl.create :comment
end
test "it shouldn't be blank" do
@comment.note = ""
assert !@comment.save
end
test "it should have a flower" do
f = FactoryGirl.create :flower
c = f.comments.build note: "awes... |
Then(/^I should see customer name displayed for canadian user$/) do
data = data_for(:canada_account_summary_page)
on(AccountSummaryPage).customername.should == "Welcome #{data['customer_name']}"
end
And(/^first letter in name is uppercase for canadian user$/) do
customer_name= on(AccountSummaryPage).customerna... |
class AddCategoryFkToMicroposts < ActiveRecord::Migration
def change
add_reference :microposts, :category, index: true
end
end
|
class Project < ActiveRecord::Base
#id,name,status,description,start_date,created_at,updated_at
#readers/writers
has_many :tasks
has_many :project_categories
has_many :categories, through: :project_categories
belongs_to :client
belongs_to :user
#validates_presence_of :name, :status, :start_date, :client_id
#va... |
# spec/models/past_event_spec.rb
require 'spec_helper'
require 'rails_helper'
describe PastEvent do
it "has a valid factory" do
FactoryGirl.create(:past_event).should be_valid
end
it "is invalid without a title" do
FactoryGirl.build(:past_event, title: nil).should_not be_valid
end
it "is invalid wit... |
require 'rails_helper'
RSpec.describe King, type: :model do
let(:king) { FactoryGirl.build :king }
it 'is a Piece type' do
expect(king).to be_a_kind_of(Piece)
end
# it 'should move up, down, diagonal 1 squares' do
# end
#
# it 'should captures units vertically, horizontally, and diagonally' do
# e... |
module API
module V1
class Cars < Grape::API
include API::V1::Defaults
resource :cars do
desc "list all cars"
get "", root: :cars do
Car.all
end
end
end
end
end
|
require File.expand_path('../boot', __FILE__)
require 'rails/all'
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.requi... |
module Jekyll
class LinkTag < Liquid::Tag
def self.sites
{
:play_store => 'https://play.google.com/store/apps/details?id=#{@name}',
:xposed_module => 'http://repo.xposed.info/module/#{@name}',
:xda_thread => 'http://forum.xda-developers.com/showthread.php?t=#{@name}',
:f_dr... |
class AddColumnToPayrollCalculation < ActiveRecord::Migration
def change
add_column :payroll_calculations, :manual_class_rate, :float
end
end
|
json.array!(@customers) do |customer|
json.extract! customer, :id, :title, :content
json.url customer_url(customer, format: :json)
end
|
require 'test_helper'
class SiteLayoutTest < ActionDispatch::IntegrationTest
def setup
@user = users(:kenneth)
end
test "layout links" do
get root_path
assert_template 'static_pages/home'
# Nav link for non-logged-in user
assert_select "a[href=?]", root_path, count: 2
assert_select "a[href=?]", he... |
require 'everyday_natsort_kernel'
require 'yaml'
require_relative 'command'
require_relative 'abstract_list'
module Rbe::Data
class CommandList < Rbe::Data::AbstractList
def on_init
migrate
end
def local_list
@local_commands
end
def local_list=(local_list)
@local_commands = lo... |
require 'rails/generators'
require 'rails/generators/migration'
module EtCms
module Generators
class InstallGenerator < Rails::Generators::Base
include Rails::Generators::Migration
desc "Generates migrations, seed data and adds mount"
def self.source_root
File.expand_path(File.join(Fi... |
class AddDistanceToLocations < ActiveRecord::Migration
def change
change_column :locations, :latitude, 'float USING CAST(latitude AS float)'
change_column :locations, :longitude, 'float USING CAST(longitude AS float)'
add_column :locations, :travel, :float
add_index :locations, [:latitude, :longitude]... |
require 'spec_helper'
RSpec.feature "user_pages_spec.rb" do
scenario "should have the h1 'Sign up'" do
visit signup_path
expect(page).to have_content('Sign up')
end
scenario "should not have a custom page title Sign up" do
visit signup_path
expect(page).to have_title("Sign up")
end
end
|
module Fog
module Compute
class Google
class Disks < Fog::Collection
model Fog::Compute::Google::Disk
def all(zone: nil, filter: nil, max_results: nil, order_by: nil,
page_token: nil)
opts = {
:filter => filter,
:max_results => max_results,
... |
##
# The designer model used as our main user type management
# * *Attribute* :
# - +email+ -> string
# - +password+ -> encrypted string
# - +fullname+ -> string
# - +facebook_email+ -> string
# - +phone_number+ -> string
# - +country+ -> string
# - +day_dob+ -> integer day of date of birth
# - +month_dob+ -> integer m... |
require 'spec_helper'
describe Bootsy::FormHelper do
let :form do
s = double(text_area: '<textarea field>',
hidden_field: '<hidden field>').extend Bootsy::FormHelper
s.stub(:render) {|template, variables| template+variables[:container].to_s }
s
end
let(:container){ double(content: 'a... |
require_relative 'spec_helper'
require_relative '../lib/hello_world/greeter'
RSpec.describe Greeter do
describe '#say_hello' do
subject { described_class.new('hola') }
it 'says hello' do
name = 'Lili'
expect(subject.say_hello(name)).to eq('hola Lili')
end
end
end
|
# Author:: Derek Wang (mailto:derek.yuanzhi.wang@gmail.com)
# Copyright:: Copyright (c) 2011 StACC, University of St Andrews
# License::
# Description:
class CreateSsDataTransfers < ActiveRecord::Migration
def change
create_table :ss_data_transfers do |t|
t.string :name
t.text :description
t.int... |
class AddAttributesColumnToHerbs < ActiveRecord::Migration
def change
add_column :herbs, :chinese_name, :string
add_column :herbs, :medicinal_description, :text
add_column :herbs, :rendered_medicinal_description, :text
add_column :herbs, :precautions, :text
add_column :herbs, :rendered_precautions... |
class Project
attr_reader :title
def initialize(title)
@title = title
end
def add_backer(backer)
ProjectBacker.new(self, backer)
end
def backers
ProjectBacker.all.select{|pb_instance| pb_instance.project == self}.map{|pb_instances| pb_instances.backer}
end
end |
require 'net/http'
require 'json'
require 'uri'
require 'digest'
module Baison
class Connection
attr_accessor :params
attr_accessor :site
# @param [Baison::Params] params
def initialize(params)
@params = params
@site = URI(@params.site)
end
# body 其实一直是空的,虽然接口要求POST,但是GET也不是不可... |
class Bucket
include Mongoid::Document
include Mongoid::Timestamps
field :bucket_name, type: String
has_many :items
belongs_to :user
end
|
require_relative '../test_config'
require_relative "#{SOURCE_ROOT}/component/experience_component"
require_relative "#{SOURCE_ROOT}/system/event_system"
require_relative "#{SOURCE_ROOT}/model/entity"
class ExperienceComponentTest < Test::Unit::TestCase
def test_next_level_at_uses_lambda_from_constructor
e = Exper... |
class AddCoversToMovies < ActiveRecord::Migration
def change
change_table :movies do |t|
t.attachment :original_cover
t.attachment :remake_cover
end
end
end
|
class User < ApplicationRecord
mount_uploader :icon, ImageUploader
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
validates :nickname, presence: true
has_many :products
has_many :comments
end
|
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.provider "virtualbox" do |vb|
vb.memory = 1024
vb.cpus = 1
vb.name = "target2"
end
config.vm.network "private_network", ip: "192.168.33.102"
config.vm.hostname = "target2"
end |
class AdditionalCostsController < ApplicationController
before_filter :authenticate_user!
before_filter :load_additional_cost, :only => [:update, :destroy, :clone]
def index
load_additional_costs
@additional_cost = current_user.additional_costs.new
end
def show
redirect_to additional_costs_url
... |
#!/usr/bin/env ruby
require 'NotificationServiceDriver.rb'
module AdCenterWrapper
endpoint_url = ARGV.shift
obj = INotificationService.new(endpoint_url)
# run ruby with -d to see SOAP wiredumps.
obj.wiredump_dev = STDERR if $DEBUG
# SYNOPSIS
# GetNotifications(parameters)
#
# ARGS
# parameters GetNotifica... |
class ApplicationController < ActionController::Base
include ExceptionHandler
def set_default_request_format
request.format = :json unless params[:format]
end
end
|
module EventsHelper
def format_price(event)
if event.free?
content_tag(:strong, "Free!") # or "<strong>Free</strong>".html_safe # .html_safe tells rails to not escape strong tags in html
else
number_to_currency(event.price)
end
end
end
|
=begin
Write a method that takes two strings as arguments,
determines the longest of the two strings,
and then
returns the result of
concatenating the shorter string, the longer string,
and the shorter string once again.
You may assume that the strings are of different lengths.
Understand the problem:
input:
2 string... |
class UpdateRecipesFoodsTable < ActiveRecord::Migration
def change
rename_column(:recipe_foods, :food_item_id, :food_id)
end
end
|
# frozen_string_literal: true
module Eq
module Companies
# Eq::Companies::CompanyEntityFactory
class CompanyEntityFactory
def initialize; end
def build(hash)
CompanyEntity.new(
id: hash[:id],
name: hash[:name],
logo: hash[:logo],
created_at: hash[:... |
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
AGE_RANGE = %w[18-29 30-39 40-49 50-59 60-69 70+].freez... |
FactoryGirl.define do
factory :mail do
sequence :message_id do |n|
"message#{n}@test.com"
end
end
factory :email_address do
sequence :email do |n|
"email#{n}@test.com"
end
sequence :unique do |n|
"unique#{n}"
end
end
factory :email_history do
sequence :message_id ... |
class PurchaseOrdersController < ApplicationController
before_action :redirect_sign_in
before_action :set_item
def index
redirect_to root_path if (current_user.id == @item.user.id) || PurchaseOrder.exists?(item_id: @item.id)
@order = OrderAddress.new
end
def create
@order = OrderAddress.new(orde... |
class Book < Sequel::Model(WoodEgg::DB)
one_to_many :essays, :order => :id
many_to_many :writers, :order => :id
many_to_many :researchers, :order => :id
many_to_many :editors, :order => :id
many_to_many :customers, :order => :id
class << self
def available
Book.exclude(asin: nil).order(:id).all.s... |
require 'json'
require 'vanagon/engine/base'
require 'vanagon/logger'
require 'yaml'
class Vanagon
class Engine
# This engine allows build resources to be managed by the ["Always be
# Scheduling" (ABS) scheduler](https://github.com/puppetlabs/always-be-scheduling)
#
# ABS expects to ask `build_host_i... |
class User < ActiveRecord::Base
EMAIL_REGEX = %r"(?:[a-z0-9!#$\%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$\%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0... |
class Project < ActiveRecord::Base
validates :name, :presence => true
include RedmineAware
has_many :scenarios, -> {where(deleted: false).order(:scenario_no)}
def masked_redmine_api_key
if redmine_api_key.present?
'*' * 32
else
nil
end
end
def build_dir
File.join(STORE_BASE_D... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or pr... |
Rails.application.routes.draw do
devise_for :users
root 'reviews#index'
get 'favorites/index'
resources :users do
get '/favorites' => 'users#favorites',as: 'favorites'
get '/admin_index/:id' => 'users#admin_index',as:'admin_index'
get '/histories' => 'users#histories', as:'histories'
end
get '/user... |
class Store < ActiveRecord::Base
resourcify
has_many :substores, class_name: "Store", foreign_key: "parent_id"
belongs_to :parent, class_name: "Store"
belongs_to :store_type
has_many :batches
#has_many :vendors
#has_many :supplies
belongs_to :store_operation
default_scope{order(name: :asc)}
... |
require 'fastlane_core/ui/ui'
module Fastlane
UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
module Helper
require_relative 'info_plist'
#
# 文件
#
class FileInfo
FileInfoUnknownFile = :FileInfoUnknownFile
FileInfoUnknownDir = :FileInfoUnknownDir
FileInfoUnknown ... |
class SyntaxHighlighter < Redcarpet::Render::HTML
def block_code(code, language)
CodeRay.scan(code, language).html(:wrap => :div)
end
end |
#!/usr/bin/env ruby
# coding: utf-8
require 'optparse'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: foo.tb [options]"
opts.on("-f PATTERN", "--file-pattern=PATTERN", String, "globbing pattern for input files") do |f|
options[:input] = f
end
opts.on("-i FPS_IN", "--fps-in=FPS_IN", Integ... |
class UVID
PREFIX="UV-"
class << self
def uvid
unless NSUserDefaults['UVID'] and NSUserDefaults['UVID'].length >= 36
NSUserDefaults['UVID'] = "%s%s" % [PREFIX, CFUUIDCreateString(nil, CFUUIDCreate(nil))]
end
return NSUserDefaults['UVID']
end
end
end
|
require_relative 'acceptance_helper'
feature 'Make new import', %q{
As some user I want to be able to make import form } do
before { visit root_path}
scenario 'User is trying to browse import form' do
expect(current_path).to eq root_path
expect(page).to have_content 'Deer'
within '.border-form-div' d... |
class User < ApplicationRecord
has_many :videos
has_and_belongs_to_many :categories
end
|
class NotificationMailer < ApplicationMailer
def order_confirmation(order)
@order = order
mail to: "#{order.user.email}", subject: "Your order has been confirmed - #{order.order_number}"
end
def welcome_message
@greeting = "Hi"
mail to: "to@example.org"
end
end
|
class AddingNewFieldsForDamperrepairPdfReport < ActiveRecord::Migration
def change
add_column :lsspdfassets, :u_dr_passed_post_repair, :string
add_column :lsspdfassets, :u_dr_description, :string
add_column :lsspdfassets, :u_dr_damper_model, :string
add_column :lsspdfassets, :u_dr_installed_damper_type... |
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "name_remaker/version"
Gem::Specification.new do |spec|
spec.name = "name_remaker"
spec.version = NameRemaker::VERSION
spec.authors = ["Frank Pimenta"]
spec.email = ["frank.p... |
class User < ApplicationRecord
# Include default devise modules Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable,
:recoverable, :rememberable, :trackable, :validatable
has_many :leave_applications
before_save :forward_to_zero
before_s... |
require 'rails_helper'
describe KpiPresenter do
before :each do
@g = FactoryGirl.create(:graph, variables: {})
@q = FactoryGirl.create(:query, command: "SELECT id FROM customers LIMIT 10")
@g_dates = FactoryGirl.create(:graph)
@g_results = FactoryGirl.create(:graph, query_id: @q.id, variables: {})
... |
module TableSwizzler
def with_table_swizzling(table_name, options = {}, &block)
# Tip o' the hat to bmo!
conn = ActiveRecord::Base.connection
conn.transaction do
conn.execute "CREATE TABLE #{quote_table_name(table_name + '_new')} LIKE #{quote_table_name(table_name)}"
yield... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.