text stringlengths 10 2.61M |
|---|
class RemoveTypeFromAccounts < ActiveRecord::Migration[6.1]
def change
# WARNING: this will delete all records associated with checking accounts
Account.where(account_type: 0).each do |account|
account.balances.destroy_all
account.destroy
end
remove_column :accounts, :account_type, :integ... |
# frozen_string_literal: true
class Rogare::Commands::Motivate
extend Rogare::Command
command 'motivate'
usage '`!%`'
handle_help
match_command /(.+)/
match_empty :execute
def execute(m, _param)
m.reply [
'One day you will find the right words.', # Jack Kerouac
'Write. If it’s good, yo... |
module WebDevBookmarks
module Spec
module BookmarkUtils
def bookmark_created?(bookmark)
Bookmark.where(
domain: bookmark.domain,
path: bookmark.path,
query_string: bookmark.query_string
).any?
end
end
end
end
RSpec::Matchers.define(:show_bookmark)... |
# frozen_string_literal: true
module NCMB
class FetchError < StandardError
end
end |
class Photo < ActiveRecord::Base
has_attached_file :image,
:styles => {
:large => "500x",
:medium => "300x>",
:thumb => "100x>"
}
validates_attachment_content_type :image, :content_type => ["image/jpg", "image/jpeg", "image/png"]
validates_attachment_presence(:image)
end
|
class AccountsController < ApplicationController
def new
@account = Account.new
end
def create
@account = Account.new(account_params)
if @account.save
flash[:notice] = 'Account was successfully created.'
redirect_to :action => 'index'
else
render :action => 'new'
end
end
def edit
... |
# frozen_string_literal: true
class CustomerRequestsController < ApplicationController
def new
@customer_request = CustomerRequest.new
end
def create
@customer_request = CustomerRequest.new(customer_request_params)
@customer_request.submit
if @customer_request.api_errors.present?
render :... |
require 'rails_helper'
RSpec.describe "profiles/show", type: :view do
before(:each) do
@profile = assign(:profile, Profile.create!(
:id => "",
:company_name => "Company Name",
:country => "Country",
:address => "MyText",
:description => "MyText",
:category_id => "",
:pro... |
# -*- encoding : utf-8 -*-
class Notice < ActiveRecord::Base
attr_accessible :content, :published_at, :title
validates_presence_of :title, :content
end
|
module MomentumCms
module Tags
class CmsFile < CmsBaseTag
def render(context)
cms_site = context_get!(context, :cms_site)
id = params_get!('id')
file = MomentumCms::File.for_site(cms_site).where(identifier: id).first
raise CmsTagError.new('File not found') unless file
... |
class ContactUsMailer < ActionMailer::Base
default to: "charles.amoako.128@gmail.com"
def contact_us_email(contact_us_form)
@user_name = "#{contact_us_form[:first_name]} #{contact_us_form[:last_name]}"
@user_question = contact_us_form[:message]
mail(from: contact_us_form[:email], subject: "Growing Spr... |
require File.dirname(__FILE__) + "/test_case/rails_request_adapter"
require File.dirname(__FILE__) + "/test_case/mock_cookie_jar"
require File.dirname(__FILE__) + "/test_case/mock_controller"
require File.dirname(__FILE__) + "/test_case/mock_logger"
require File.dirname(__FILE__) + "/test_case/mock_request"
module Aut... |
# frozen_string_literal: true
require 'jiji/configurations/mongoid_configuration'
require 'jiji/model/trading/back_test'
require 'jiji/utils/bulk_write_operation_support'
module Jiji::Model::Graphing
class Graph
include Mongoid::Document
include Jiji::Utils::BulkWriteOperationSupport
include Jiji::Util... |
class ExpiringTags::TagNames
include Enumerable
def initialize(taggable)
@taggable = taggable
end
def to_a
taggable.tags.active.map(&:tag)
end
def <<(tag)
taggable.tags << ExpiringTags::Tag.find_or_create_by(tag: tag)
end
def self.new_with_names(taggable, names)
tag_names = new(tagg... |
module NginxConfigMaker
class Server
attr_reader :listen, :server_name, :location
def initialize(opts)
@listen = Array(opts[:listen])
@server_name = opts[:server_name]
@location = opts[:location]
end
def to_a
parts = []
parts << "server {"
listen.each do |l|
... |
class CreateLearnedSkills < ActiveRecord::Migration
def change
create_table :learned_skills do |t|
t.integer :character_id, presence: true
t.integer :skill_id, presence: true
t.integer :points, presence: true, :default => 0
t.timestamps null: false
end
add_index :learned_skills, :... |
class User < ApplicationRecord
# follower relationships
has_many :followers, through: :follower_follows, source: :follower
has_many :follower_follows, foreign_key: :followee_id, class_name: "Follow"
has_many :followees, through: :followee_follows, source: :followee
has_many :followee_follows, foreign_key: :... |
def total(array)
p array.inject{|sum,x| sum + x}.to_f
end
def sentence_maker(array)
p array.join(' ').capitalize << "."
end
# Add it up!
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented in the file.
# I ... |
module DoubleWeb
module DriverPatches
autoload :NetHTTP, 'double_web/driver_patches/net_http'
end
module Caches
autoload :Base, 'double_web/caches/base'
autoload :Memory, 'double_web/caches/memory'
autoload :Yaml, 'double_web/caches/yaml'
end
class UnexpectedRequestError < StandardError; en... |
#!/usr/bin/env ruby
require "thor"
require "fileutils"
require "net/http"
require "json"
TOKEN = ENV["GITHUB_API_TOKEN"]
class DocApp
def initialize(name)
@uri = URI("https://api.github.com/repos/afeiship/#{name}/pages")
@http = Net::HTTP.new(@uri.host, @uri.port)
@http.use_ssl = true
@header = {
... |
require 'rails_helper'
require 'user'
Rails.describe User, :type => :model do
xit { should have_secure_password }
context "shipper" do
shipper = FactoryGirl.build(:shipper)
subject { shipper }
it { should have_many(:shipments).
through(:user_shipments) }
it { should have_many(:user_shipments) }
it ... |
$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "devise_orm_couchrest_model/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "devise_orm_couchrest_model"
s.version = DeviseOrmCouchrestModel::VERSION
s.authors = [... |
require 'spec_helper'
require 'linked_list'
require 'pry'
describe 'singly linked list' do
before do
@list = LinkedList.new
(1..26).each { |e| @list.add(LinkedList::Node.new(e)) }
end
it 'keeps track of size' do
@list.size.must_equal 26
end
it 'searchs an element' do
@list.search(1).must_be... |
class FontTexGyreHeros < Formula
version "2.004"
sha256 "755954b7349b803fc1c3d82fe9d9c4f7cf66467af718eaaf4f78ae1a09bf265d"
url "http://www.gust.org.pl/projects/e-foundry/tex-gyre/heros/qhv#{version}otf.zip"
desc "TeX Gyre Heros"
homepage "http://www.gust.org.pl/projects/e-foundry/tex-gyre/heros"
def install... |
require 'i18n/backend/simple'
module Globalize
module Backend
class Pluralizing < I18n::Backend::Simple
def pluralize(locale, entry, count)
return entry unless entry.is_a?(Hash) and count
key = :zero if count == 0 && entry.has_key?(:zero)
key ||= pluralizer(locale).call(count, entry... |
# Require the bundler gem and then call Bundler.require to load in all gems
# listed in Gemfile.
require 'bundler'
Bundler.require
# Setup DataMapper with a database URL. On Heroku, ENV['DATABASE_URL'] will be
# set, when working locally this line will fall back to using SQLite in the
# current directory.
DataMapper.s... |
class EventsController < ApplicationController
before_action :require_login, except: [ :index, :show ]
before_action :check_event_changing_permission, except: [ :index, :show, :new, :create, :mine]
def index
query = params[:search]
if query
@events = Event.search(query)
else
@events = Eve... |
module InfobloxClient
class Client
module Zones
def zones
get('zone_auth')
end
def zone(ref)
get(ref)
end
def delete_zone(ref)
delete(ref)
end
def create_zone(attrs={})
body_json = JSON.dump(attrs)
post_request = -> { post('zone... |
require 'gandi'
module ProviderDSL
class MockProxyCall
def initialize(calls)
@calls = calls
@chained = []
self
end
undef_method :clone
def method_missing(method, *parameters)
@chained << method
method_name = @chained.join('.')
if ::Gandi::VALID_METHODS.include?(m... |
class FontTiejiliSc < Formula
version "1.100"
sha256 "28524e623b73ab4e8507ca689b1d166758a66b7eb73649c9996f8ba14626359f"
url "https://github.com/Buernia/Tiejili/releases/download/#{version}/Tiejili.zip"
desc "Tiejili SC"
desc "铁蒺藜体 简"
desc "Open-source font that extends Fontworks' Reggae One to Chinese"
ho... |
class FontImFellFrenchCanon < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/imfellfrenchcanon"
desc "IM Fell French Canon"
homepage "https://fonts.google.com/specimen/IM+Fell+French+Canon"
def install
(share/"fonts").install "IMFeFCi... |
require 'csv'
require 'time'
require "pry"
require_relative 'user'
require_relative 'trip'
require_relative 'driver'
DELAY_LIMIT = 15
module RideShare
class TripDispatcher
attr_reader :drivers, :passengers, :trips
def initialize(user_file = 'support/users.csv',
trip_file = 'support/trips.csv',
... |
class CreateAvailableTimes < ActiveRecord::Migration
def change
create_table :available_times do |t|
t.integer :debate_id
t.integer :proposed_by
t.integer :proposed_to
t.datetime :proposed_time
t.string :status
t.timestamps null: false
end
end
end
|
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
require 'spec_helper'
describe TwitterCldr::Transforms::TransformId do
describe '.find' do
it 'finds a transformer when given two locales' do
id = described_class.find('cs', 'ja')
expect(id.source).to eq('c... |
class AddIndexToColumns < ActiveRecord::Migration[5.0]
def change
add_index :samples, :user_id
add_index :samples, :sample_id
add_index :samples, :gps
add_index :samples, :sample_date
end
end
|
# Write a method that takes a string, and then returns a hash that contains 3 entries: one represents the percentage of characters in the string that are lowercase letters, one the percentage of characters that are uppercase letters, and one the percentage of characters that are neither.
# You may assume that the stri... |
require 'backpack_tf/special_item/interface'
require 'backpack_tf/special_item/response'
module BackpackTF
# Ruby representations of a JSON response to IGetSpecialItems
class SpecialItem
include Helpers
attr_reader :name
attr_reader :item_name
attr_reader :defindex
attr_reader :item_class
... |
class Comment < ActiveRecord::Base
belongs_to :book
belongs_to :staff
validates :name, :comment, presence: true
#chỉnh sửa
def self.search(search)
where("name LIKE ?", "%#{search}%")
end
#----
def self.search_book(id)
cat = self.all
if name.present?
... |
class MessageForm
include ActiveModel::Model
# attr_accessorメソッド
# クラス外部からインスタンス変数を参照、変更可能にする
attr_accessor :content, :user_id, :room_id, :photos
validates :content_or_photo, presence: true
private
def content_or_photo
self.content.present? || MessageImage.photos.present?
e... |
require 'colorize'
class Piece
attr_accessor :name, :pos, :symbol, :selected, :color, :board
def initialize(starting_pos, board)
@pos = starting_pos
@name = 'piece'
@symbol = ":p".colorize(color)
@selected = false
@color = :black
@board = board
end
def toggle_selected
if @selecte... |
class CreateDetectors < ActiveRecord::Migration[5.0]
def change
create_table :detectors do |t|
t.string :name
t.string :serial_number
t.string :detector_type
t.string :token
t.string :owner
t.decimal :latitude
t.decimal :longitude
t.timestamps
end
end
end
|
class MongoDBDropper
def drop(str)
@mongo_config = YAML.load(str)
database_name = @mongo_config["connector"]["database"]
db = Mongo::Connection.new.db(database_name)
connection = db.connection
connection.drop_database(database_name)
end
end
|
module KsCheckEnvironment
# Declare the Endpoints according to the environment
# Endpoints are required to make a post call through Rest Client
# the constant ks_production holds the endpoint for making API call with live credentials
# the constant ks_sandbox holds the endpoint for making API call with sandbox cre... |
module Mplay
using Rafini::String
help = <<-HELP
Usage:
gtk3app mplay [options] [url]
Options:
-v --version Show version and quit.
-h --help Show this help and quit.
--trim Trim the database.
--old=days Remove videos not seen in days.
--limit=number Keep only number of last seen... |
require 'nokogiri'
class TallyExportJob
def initialize(trans_id)
@trans_id = trans_id.to_i
@job_type = 1
end
def perform
trans = FinanceTransaction.find_by_id @trans_id
xml = fetch_xml(trans.id)
tally_url = TallyExportConfiguration.get_config_value('TallyUrl')
if tally_url[tally_url.lengt... |
class User < ApplicationRecord
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
mount_uploader :avatar, ImageUploader, dependent: :destroy
serialize :main_major, Array
after_update :create_feature
has_many :likes
has_many :documents, through: :likes
has_m... |
class RemoveColumsFromAtencion < ActiveRecord::Migration
def change
remove_column :atencions, :Idveterinario
remove_column :atencions, :cliente_id
remove_column :atencions, :mascota_nombre
end
end
|
class ApplicationController < ActionController::Base
protect_from_forgery
rescue_from CanCan::AccessDenied do |exception|
flash[:error] = "Access denied."
redirect_to "/admin"
end
def current_ability
@current_ability ||= Ability.new(current_employee)
end
def authenticate_admin_user!
if em... |
class Message < ApplicationRecord
validates_presence_of :content
end
|
# variables.rb
# Chapter 4 - Variables and Assignments
# starts on page 19
# Storing Variables aka "Assignments"
my_string = '...You can say that again...'
puts my_string
puts my_string
name = 'Anya Christina Emmanuella Jenkins Harris'
puts 'My name is ' + name + '.'
puts 'Wow! ' + name
puts 'is a really long name!'
... |
class Answer < ApplicationRecord
belongs_to :question
validates :content,length: {maximum: 255}
end
|
class ReworkRestaurantAddressesInUsers < ActiveRecord::Migration
def change
change_table :users do |t|
3.times do |i|
t.string :"restaurant_#{i+1}_street_address"
t.string :"restaurant_#{i+1}_city"
t.string :"restaurant_#{i+1}_state"
t.string :"restaurant_#{i+1}_zip_code"
... |
module Queries
class FoosQuery < Base
type [Types::FooType], null: true
description 'Returns a list of all Foos'
def resolve
Foo.all
end
end
end
|
#
# storage.rb : data storage on local FS
#
require 'json'
require 'uri'
require 'base64'
class Storage
def initialize(dir="./data/")
begin
File::ftype(dir)
rescue Errno::ENOENT
printf("Error: ENOENT: %s\n", dir)
printf("Create directory: %s\n", dir)
Dir.mkdir(dir)
rescue Errno::... |
module RegistrationsHelper
REGISTRATION_STATUSES = %w(confirmed cancelled)
def registration_submit_button
@registration.new_record? ? 'Register' : 'Save'
end
def registration_submit_button_class
@registration.new_record? ? 'btn' : 'btn btn-primary'
end
def cheque_details_visibility
visible = @... |
#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' }])
# .create(name: 'Emanuel', city... |
# This method takes an array of elements (these might be strings, integers, floats, or a
# combination of the above), and returns an array of the elements that appear once and only
# once.
def find_unique_elements(arr)
unique=[]
counts = Hash.new(0)
arr.each do |i|
counts[i] += 1
... |
module Driving
# Node class for points on the map. These have a world position
# (given by lattitude/longitude) and a set of other nodes to which
# this one is connected by a road of some kind.
class Node
@@nodes = {}
attr_accessor :pos, :neighbors
def initialize(pos, neighbors = Set.new)
... |
class CreateDocuments < ActiveRecord::Migration
def change
create_table :documents do |t|
t.string :name, null: false
t.integer :pages, null: false
t.timestamps
end
add_index :documents, :name, unique: true
end
end
|
class WelcomeController < ApplicationController
def index
unless session[:user_id].nil?
redirect_to dashboard_index_path
end
end
end
|
# encoding: utf-8
module Amazon
class NewAccount
include PageObject
link(:your_account, id: 'nav-link-yourAccount', text: /Your Account/)
link(:create_new_account, id: 'createAccountSubmit', text: /Create your Amazon account/)
text_field(:name, id: 'ap_customer_name')
text_field(:email, id: 'ap_... |
# frozen_string_literal: true
class LinkGenerator
def generate_link(item_hash)
format(Constant::ITEM_LINK_URL, class_id: item_hash[Constant::ITEM_HASH_CLASS_ID_KEY],
instance_id: item_hash[Constant::ITEM_HASH_INSTANCE_ID_KEY],
... |
class CreateRecommendations < ActiveRecord::Migration
def change
create_table :recommendations do |t|
t.integer :sender_id
t.integer :receiver_id
t.string :content
t.timestamps
end
add_index :recommendations, :receiver_id
end
end
|
ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
require 'rails/test_help'
require 'minitest/rails' # allows `describe` blocks
require 'mocha/minitest' # alows mocking
require 'active_support/testing/time_helpers'
class ActiveSupport::TestCase
# Run tests in parallel with specified workers
# pa... |
class CreateWeathers < ActiveRecord::Migration
def change
create_table :weathers do |t|
t.integer :travel_date
t.text :origin
t.text :destination
t.text :carrier
t.integer :departure_time
t.integer :arrival_time
t.timestamps null: false
end
end
end
|
class CreatePlaces < ActiveRecord::Migration
def change
create_table :places do |t|
t.string :nombre
t.string :direccion
t.references :district
t.string :url
t.string :telefono
t.timestamps
end
add_index :places, :district_id
end
end
|
class Desease < ApplicationRecord
has_many :symptoms_of_desease
has_many :symptoms, through: :symptoms_of_desease
end
|
require './graph'
require './linkedlist'
class Queue
def initialize()
@q = LinkedList.new()
end
def enq(val)
@q.add_node(val);
end
def deq()
rt = @q.rem_node
return rt
end
end |
class SessionsController < ApplicationController
before_action :check_for_no_login, except: [:destroy]
def new
end
def create
user = User.find_by :email => params[:email]
if user.present? && user.authenticate(params[:password])
# Create a new user session
session[:user_id] = user.id
... |
class AddRecoveryLvColumnToFacilityUse < ActiveRecord::Migration[5.2]
def change
add_column :facility_uses, :recovery_lv, :integer
add_column :facility_uses, :number, :integer
add_index :facility_uses, :recovery_lv
add_index :facility_uses, :number
end
end
|
require 'spec_helper'
describe EducationInfosController do
describe 'POST new' do
before :each do
@info_hash = {
from: '2013-1-2',
to: '2013-3-3',
school: 'Abc School',
remark: 'none'
}
@profile = FactoryGirl.create(:student_profile)
session[:user] = @profi... |
module Ruby
module HL7
class NTE < Segment
weight 4
add_field :set_id, :idx=>1
add_field :source, :idx=>2
add_field :comment, :idx=>3
add_field :comment_type, :idx=>4
end
end
end |
class CreateTrackEnrollReportMaterializedView < ActiveRecord::Migration
def up
execute 'DROP MATERIALIZED VIEW IF EXISTS track_enroll_reports_matview'
execute <<-SQL
CREATE MATERIALIZED VIEW track_enroll_reports_matview AS
SELECT
COUNT(*) as total_by_status,
elt.student_class... |
class User < ActiveRecord::Base
belongs_to :title
has_and_belongs_to_many :skills
has_many :allocations
# enum ties a numerical value in the database to named values that can be accessed in rails.
# http://edgeapi.rubyonrails.org/classes/ActiveRecord/Enum.html
# You can access these like this:
# user = U... |
class PurchaseController < ApplicationController
before_action :authenticate_user!
def index
@user = current_user
@sellitem = Sellitem.find(params[:sell_id])
card = Card2.find_by(user_id: current_user.id)
if card.present?
Payjp.api_key = ENV["PAYJP_PRIVATE_KEY"]
customer = Payjp::Custom... |
require './spec/spec_helper'
RSpec.describe Antlr4::Runtime do
it "can use bit_set correctly" do
s = Antlr4::Runtime::BitSet.new
t = Antlr4::Runtime::BitSet.new
s.set(3)
result = s.bits
expect(result).to eq(8)
result = s.next_set_bit(0)
expect(result).to eq(3)
t.set(4)
t.set(5)... |
FactoryBot.define do
factory :streaming_consolidated_chart_data_update, class: IGMarkets::Streaming::ConsolidatedChartDataUpdate do
bid_close 1.10883
bid_high 1.10886
bid_low 1.10877
bid_open 1.10878
cons_tick_count 58
day_high 1.10967
day_low 1.10703
day_net_chg_mid 0.00006
day_op... |
class Utility < ApplicationRecord
belongs_to :flat
belongs_to :category
belongs_to :tariff
has_many :payments, :dependent => :destroy
def quantity
return case category.name
when 'Квартплата'
self.flat.total_area
when 'Газ'
self.flat.residents_number
when 'ОТОПЛЕНИЕ'
... |
VAGRANTFILE_API_VERSION = "2"
base_dir = File.expand_path(File.dirname(__FILE__))
cluster = {
"mesos-master1" => { :ip => "100.0.10.11", :cpus => 1, :mem => 768 },
"mesos-master2" => { :ip => "100.0.10.12", :cpus => 1, :mem => 768 },
"mesos-master3" => { :ip => "100.0.10.13", :cpus => 1, :mem => 768 },
"mes... |
# -*- coding: utf-8 -*-
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
require 'ffi-locale/version'
date = "2011-09-25"
authors = ["Sean O'Halpin"]
email = "sean.ohalpin@gmail.com"
project = FFI::Locale
description = "An FFI wrapper for the C library setlocale and localeconv functio... |
namespace :settings do
desc <<-DESC
Changes a setting
USAGE: rake settings:set[foo,bar]
DESC
task :set , [:var, :value] => :environment do |t, args|
Setting.send "#{args[:var]}=", args[:value]
end
end
|
# Write your code here.
def line(deli)
result = "The line is currently"
if deli.size == 0
result += " empty."
else
result += ":"
deli.each_with_index do |name, index|
place = index + 1
result += " #{place}. #{name}"
end
end
puts result
end
def take_a_number(deli, name)
del... |
# frozen_string_literal: true
# WaterDrop library
module WaterDrop
# Current WaterDrop version
VERSION = '0.3.2.3'
end
|
class FontHindMadurai < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/hindmadurai"
desc "Hind Madurai"
homepage "https://fonts.google.com/specimen/Hind+Madurai"
def install
(share/"fonts").install "HindMadurai-Bold.ttf"
(share/"f... |
# frozen_string_literal: true
RSpec.describe(Jekyll::GitHubMetadata::Value) do
let(:simple_value) { described_class.new(proc { "a value" }) }
let(:number_value) { described_class.new(4) }
let(:string_value) { described_class.new("petunia my dear") }
let(:array_value) { described_class.new(%(oy you there))... |
module MarkdownHelper
# helper/shortcut for adding embedded image to slide in markdown syntax:
# 
#
# use it like:
# <%= image 'friendsbadge.png' %>
#
# note: alternate text (alt) and title are optional
def image( path, alt="", title="" )
%Q{
super
end
end |
module DiscountNetwork
class Destination
def self.list(term:)
DiscountNetwork.get_resource(
"destinations", term: term
)
end
end
end
|
module FogTracker
module Query
describe QueryProcessor do
QUERY['matching all Resources'] = '*::*::*::*'
QUERY['by account name'] = 'Fake Account \d+::*::*::*'
QUERY['by Fog Service'] = '*::FakeService::*::*'
QUERY['by Fog Provider'] = '*::*::FakeProvider::*'
... |
require 'spec_helper'
module Communications
describe UDPPacketBuffer do
let(:buffer) { UDPPacketBuffer.new(4) }
let(:packets) do
(1..7).to_a.collect { |i| FactoryGirl.build(:udp_packet, sequence_no: i) }
end
describe '#<<' do
context 'buffer is not full' do
it 'adds the packet to the... |
class AddInstagramToLodges < ActiveRecord::Migration[5.0]
def change
add_column :lodges, :instagram, :string
add_column :lodges, :facebook, :string
end
end
|
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '3.2.13'
gem 'thin'
# Use MongoDB
gem 'mongoid'
gem 'bson_ext'
gem 'mongo_ext'
# JQuery served via CDN
gem 'jquery-rails'
gem 'jquery-rails-cdn'
# Force newer slim version
gem 'slim', '>= 1.3.8'
gem 'slim-rails'
# Let's have some admin interface
gem 'activead... |
class User < ApplicationRecord
include PasswordHelper
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable, :registrable
devise :database_authenticatable, :recoverable, :rememberable, :trackable,
:validatable
before_validation(on: :create)... |
class ClassroomsController < ApplicationController
def index
@classrooms = Classroom.all
end
def new
@classroom = Classroom.new
end
def create
@classroom = Classroom.create classroom_params
respond_with @classroom, location: -> { classrooms_path }
end
def destroy
if Classroom.where... |
class Artist
attr_accessor :name, :songs
@@all = []
def initialize(name)
self.name = name
self.songs = []
end
def add_song(song)
self.songs << song
end
def save
@@all << self
end
def self.all
@@all
end
def self.create_by_name(artist)
new_artist = self.new(artist)
... |
# frozen_string_literal: true
module Files
class U2fSignRequest
attr_reader :options, :attributes
def initialize(attributes = {}, options = {})
@attributes = attributes || {}
@options = options || {}
end
# string - App ID for U2F
def app_id
@attributes[:app_id]
end
# ... |
# encoding: utf-8
# Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
module MobileCenterApi
module Models
#
# Model object.
#
#
class TestReportFeaturesItemTestsItemRunsItem
# @return [Float... |
module Nobbie
module Wx
module Command
class TypeIntoCommand < ComponentAwareCommand #:nodoc:
def initialize(path, value)
super(path)
@value = value
end
def execute
highlight {
if component.is_a?(TextCtrl) || component.i... |
module Wire
class Yellow
class << self
def out(it)
{
:total => it.total,
:results => it.map do |yellow_pages_result|
{:name => yellow_pages_result.name}
end.to_a
}
end
def in(it)
it ||= []
YellowPagesSearchResult.ne... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :donor do
logo ""
name "MyString"
level "MyString"
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.