text stringlengths 10 2.61M |
|---|
class VendingMachine
attr_reader :money_total
AVAILABLE_MONEY = [10, 50, 100, 500, 1000].freeze
def initialize
@money_total = 0
end
def insert_money(money)
if AVAILABLE_MONEY.include?(money)
@money_total += money
end
end
def refund
@money_total.tap{ @money_total = 0 }
end
end
... |
require 'scrabbler'
describe Scrabbler do
it 'returns all possible anagrams of a string' do
expect(subject.anagramize("ab", 2)).to eq ["ab", "ba"]
end
it 'returns as many anagrams as there are permutations' do
expect(subject.anagramize("abcd", 4).count).to eq 24
end
it 'finds anagrams of length 3 ... |
class AddCoins < ActiveRecord::Migration
def self.up
add_column :users, :points, :integer, :default => 100
end
def self.down
remove_column :users, :points
end
end
|
class Sulfuras
attr_reader :name, :sell_in, :quality
def initialize(name, sell_in, quality)
@name = name
@sell_in = sell_in
@quality = quality
end
def update
quality
end
end
|
require 'support/connection_helpers'
require 'support/database_creator'
require 'support/active_record/schema_setup'
module MySQL2Helper
ADAPTER = 'mysql2'
puts "Active Record #{ActiveRecord::VERSION::STRING}, #{ADAPTER}"
def active_record_mysql2_setup
::DatabaseCreator.create_database_for ADAPTER
::Co... |
module Shomen
module Model
#
class Module < Abstract
#
def self.type; 'module'; end
# Method's name.
attr_accessor :name
# Namespace of module is the path of the class or module
# containing this module.
attr_accessor :namespace
# Comment associated with m... |
# frozen_string_literal: true
FactoryBot.define do
factory :service_record, class: Preneeds::ServiceRecord do
service_branch 'AF' # Air Force
discharge_type '1'
highest_rank 'GEN'
national_guard_state 'NY'
date_range { attributes_for :date_range }
end
end
|
require 'spec_helper'
describe NachrichtensController do
describe "routing" do
it "routes to #index" do
get("/nachrichtens").should route_to("nachrichtens#index")
end
it "routes to #new" do
get("/nachrichtens/new").should route_to("nachrichtens#new")
end
it "routes to #show" do
... |
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
# after_create :create_applicant, if: :candidate?
has_one :applicant
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackabl... |
class Admin::SignupsController < Admin::BaseController
helper_method :sort_column, :sort_direction
def index
@signups = Signup.order(sort_column + " " + sort_direction).
paginate(:page => pagination_page, :per_page => pagination_rows)
end
def show
@signup = Signup.find(param... |
class Opinion < ApplicationRecord
validates :body, presence: true, length: { maximum: 140,
too_long: '140 characters in comment is the maximum allowed.' }
belongs_to :user
has_many :likes, dependent: :destroy
scope :ordered_by_most_recent, -> { order(created_at: :d... |
class ChangeTemporaryEffectsToSpecialEffects < ActiveRecord::Migration[5.1]
def change
rename_table :temporary_effects, :special_effects
change_table :special_effects do |t|
t.remove :attr
t.remove :modifier
t.string :description
end
end
end
|
class User
include Dynamoid::Document
table name: :users, key: :user_id, read_capacity: 5, write_capacity: 5
field :name
field :email
end
|
class Api::V1::DepartamentosController < ApplicationController
respond_to :json
# GET /departamentos
def index
@departamentos = Departamento.all
render json: @departamentos
end
# GET /departamentos/:id
def show
@departamento = Departamento.find(params[:id])
render json: @departamento
end
# POST /depar... |
require 'spec_helper'
feature 'User watches entry' do
scenario 'in the challenge page' do
member = new_member
organization = new_organization
challenge = create :challenge, title: 'Reto 1', organization: organization
collaboration = create :collaboration, challenge: challenge, member: member
cre... |
module Summary
extend ActiveSupport::Concern
included do
self.class::SUMMARY_PERIOD = 1.day if ENV['TEST_EMAILS']
end
def set_summary_period!
if self.class::SUMMARY_PERIOD >= 1.month
@start_of_period = self.class::SUMMARY_PERIOD.ago.beginning_of_month
@end_of_period = self.class::SUMMARY_... |
class YellowCardsController < ApplicationController
before_action :set_card, only: [:show, :edit, :update, :destroy]
# GET /cards
# GET /cards.json
def index
@yellow_cards = YellowCard.all
end
# GET /cards/1
# GET /cards/1.json
def show
end
# GET /cards/new
def new
@yellow_card = Yellow... |
class Auth::TopicsController < ApplicationController
before_action :set_auth_topic, only: [:show, :edit, :update, :destroy]
# GET /auth/topics
# GET /auth/topics.json
def index
@auth_topics = Auth::Topic.all
end
# GET /auth/topics/1
# GET /auth/topics/1.json
def show
@topic = Auth::Topic.find(... |
class Admin::OrderItemsController < ApplicationController
before_action :authenticate_admin!
def update
order_item = OrderItem.find(params[:id])
order = order_item.order
if order.status != "入金待ち"
order_item.update(order_item_params)
order_item.order_status_auto_update
order_item.produ... |
# "is-a"
# "has-a"
# Animal is-a object
class Animal
end
# Dog is-a Animal
class Dog < Animal
def initialize(name)
# Dog has-a name
@name = name
end
end
# Cat is-a Animal
class Cat < Animal
def initialize(name)
# Cat has-a name
@name = name
end
end
# Person is-a object
class Person
def in... |
# frozen_string_literal: true
class User < ApplicationRecord
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
has_many :posts, dependent: :destroy
has_many :comments, dependent: :destroy
has_many :active_relationships, class_name: 'Relationship', foreign_key... |
# MDB::Model implements a very simple and un-production-worthy
# persistence model. A class that includes the Maglev::Model module, will
# automatically persist all new instances in a hash table for the class.
# If the module is re-included (or the file that defines the class is
# re-run), then all previous saved inst... |
# frozen_string_literal: true
require "spec_helper"
RSpec.describe DefraRuby::Alert do
describe "VERSION" do
it { expect(DefraRuby::Alert::VERSION).to be_a(String) }
it { expect(DefraRuby::Alert::VERSION).to match(/\d+\.\d+\.\d+/) }
end
describe ".configuration" do
context "when the host app has no... |
# frozen_string_literal: true
require './init'
desc 'Default task: run all tests'
task default: [:test]
task :test do
exec 'thor monk:test'
end
desc 'Creates the 300 width images for existing assets'
task :make_asset_300s do
assets = Asset.all(deleted: false)
assets.each do |asset|
orig = MiniMagick::Imag... |
class Artist < ApplicationRecord
has_many :festivals, through: :festival_artists
has_many :festival_artists
default_scope -> { order(headliner: :desc, name: :asc) }
validates :name, presence: true
end
|
class ReviewFormInstance < ActiveRecord::Base
belongs_to :cubicle_label, :foreign_key => :cubicle_id
belongs_to :user, :foreign_key => :user_id
belongs_to :account
belongs_to :review_form
belongs_to :campaign
has_many :review_answers
has_many :review_form_instances_review_question_instances, :dependent =>... |
class EmailAddress < ActiveRecord::Base
attr_accessible :contact_id, :email, :main, :provider, :status, :user_id
has_one :contact
belongs_to :user
validates_presence_of :email
end
|
namespace :import do
desc "Import students from csv"
task students: :environment do
counter = 0
filename = File.join Rails.root, "students.csv"
CSV.foreach(filename, headers: true) do |row|
student = Student.assign_from_row(row)
if student.save
counter += 1
else
puts ... |
=begin
Given the MM-DD-YYYY formatted date
"10-02-2001"
We will call this a "palindrome date,"
since without the separators this is 10022001
(1) Write a function that,
given a specific date,
finds the closest valid date before the given date that is a palindrome date.
you may ignore leap years!
(2) Now w... |
# == Schema Information
#
# Table name: apoyo_institucionals
#
# id :integer not null, primary key
# tipo :integer
# porc_cumplimiento :float
# comentario :text
# created_at :datetime
# updated_at :datetime
#
# Clase que representa el apoyo institucional
... |
require 'spec_helper'
describe ::WineBouncer::AuthMethods do
let(:tested_class) do
Class.new do
include ::WineBouncer::AuthMethods
end.new
end
let(:user) { FactoryGirl.create(:user) }
let(:token) { FactoryGirl.create :clientless_access_token, resource_owner_id: user.id, scopes: 'public' }
con... |
class QuestionsController < ApplicationController
# index
# def index
# @questions = Question.all
# end
# new
def new
@form = Form.find(params[:form_id])
@question = Question.new
end
# create
def create
@form = Form.find(params[:form_id])
@question = Question.create!(question_para... |
# ------------ Minitest_test_helper.txt ----------------------------------- #
# --- 09.000-Test_Helper.rb --- #
# ---------------------------------------------------------------------------------- #
# --- ... |
class Integer
##
# Calculate a random chance using easy notation: 1 =~ 50 :: 1 in 50 chance
def =~ n #
rand(n) <= (self - 1)
end
end
class Numeric
##
# Is M close to N within a certain delta?
def close_to? n, delta = 0.01
(self - n).abs < delta
end
##
# Normalize a number to be within 0.... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def basic_auth
user = User.find_by_email(request.headers['X-User-Email'])
unless user && user.api_token == re... |
class User < ActiveRecord::Base
has_many :billing_informations
has_many :credit_cards
has_many :searches, inverse_of: :user
has_many :carts
has_many :responsibilities
has_many :responsible_shops, through: :responsibilities, source: :shop
has_many :responsible_carts, through: :responsible_shops, source: :car... |
require 'rails_helper'
RSpec.describe Tweet, type: :model do
describe 'test avatar' do
let!(:tweet) { create(:tweet) }
it 'should generate url && image' do
expect(tweet.image).not_to be_nil
end
describe 'testing validations' do
it 'should be valid without message but with image' do
... |
class ChangedHoldersAddedUgroupsCountAndDeletedGroupsCount < ActiveRecord::Migration
def self.up
add_column :holders, :ugroups_count, :integer
remove_column :holders, :groups_count
end
def self.down
add_column :holders, :groups_count, :integer, :limit=>nil, :default=>nil
remove_column :holders,... |
RSpec.describe Mutant::Reporter::Trace do
let(:object) { described_class.new }
describe '#delay' do
subject { object.delay }
it { should eql(0.0) }
end
let(:reportable) { double('Reportable') }
%i[report start progress].each do |name|
describe "##{name}" do
subject { object.public_send(n... |
cask :v1 => 'sococo' do
version '3.2.7'
sha256 '6772f2c2ef5c7b046612de408b79a71ed0936041fb9286785af69d862f653d1f'
url "http://download.sococo.com/10069/Sococo_#{version.gsub('.','_')}_10069.dmg"
homepage 'http://www.sococo.com'
license :unknown # todo: change license and remove this comment; ':unknown' is... |
require 'test_helper'
class CassandraObject::TimestampsTest < CassandraObject::TestCase
test 'timestamps set on create' do
issue = Issue.create
assert_in_delta Time.now.to_i, issue.created_at.to_i, 10
assert_in_delta Time.now.to_i, issue.updated_at.to_i, 10
end
test 'updated_at set on change' do
... |
shared_examples_for 'a legacy node url' do
it "should have a legacy_node" do
model.should respond_to :legacy_node
model.should respond_to :legacy_node=
end
it "should have a legacy_url" do
model.should respond_to :legacy_url
model.should respond_to :legacy_url=
end
describe "#legacy_... |
# QUESTION 1: Let's do some "ASCII Art" (a stone-age form of nerd artwork from back in the days before computers had video screens).
# For this practice problem, write a one-line program that creates the following
# output 10 times, with the subsequent line indented 1 space to the right:
string = "The Flintstones Ro... |
require 'rails_helper'
describe 'GET /v1/users', subdomain: 'api' do
context 'without a token' do
it 'returns an empty 404 response' do
hook = FactoryBot.create :hook
params = { latest_hook_id: hook.id }
patch '/v1/users', params: params, as: :json
expect(response.code).to eq '404'
... |
class TeamsController < ApplicationController
before_action :set_only_admin
before_action :set_team, only: [:edit, :update, :delete_team, :show]
layout "account"
def new
@team = Team.new
@teams = Team.all.order('created_at desc')
end
def edit
@teams = Team.all.order('created_at desc')
end
... |
class AddDataToBirthdayParties < ActiveRecord::Migration
def change
add_column :birthday_parties, :data, :jsonb
end
end
|
# Encoding: UTF-8
require_relative '../spec_helper'
describe 'plex-home-theater::app' do
describe file('/Applications/Plex Home Theater.app'),
if: os[:family] == 'darwin' do
it 'exists' do
expect(subject).to be_directory
end
end
describe package('Plex Home Theater'), if: os[:family] ==... |
class FixMyTags::MusicFinder
attr_reader :path
def initialize path = "~/Music"
@path = path
end
def list
found = `find #{@path} -type f`
files = found.force_encoding('UTF-8').split(/\n/)
files = files.select{|x| !x.match(/\/\./) }
files.map{ |file| FixMyTags::MusicFactory.build file }
e... |
require 'test_helper'
class DvrsControllerTest < ActionController::TestCase
setup do
@dvr = dvrs(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:dvrs)
end
test "should get new" do
get :new
assert_response :success
end
test "shoul... |
FactoryGirl.define do
factory :contractor do
name "Toolman"
contact "Tim Taylor"
email "tim@email.com"
phone "555-555-5555"
states_serviced ["MN", "WI", "ND"]
end
end
|
# frozen_string_literal: true
# == Schema Information
#
# Table name: users
#
# id :bigint(8) not null, primary key
# email :string(255) not null
# email_publish :boolean default(FALSE), not null
# family_name :string(255) not null
# given_name ... |
# All credits of this script goes to @arkham
# https://github.com/Arkham/dotfiles/blob/master/Rakefile
task :default => [:backup_dir, :backup, :link]
WHOAMI = ENV['USER']
DOTFILES_DIR = "/Users/#{WHOAMI}/.dotfiles"
BACKUP_DIR = "/Users/#{WHOAMI}/.dotfiles-backup"
DOTFILES = %w(
Brewfile
curlrc
dockerignore
ge... |
class CreateNippos < ActiveRecord::Migration[5.0]
def change
create_table :nippos do |t|
t.belongs_to :user, foreign_key: true, null: false
t.date :reported_for, null: false
t.text :subject_yaml
t.text :body
t.datetime :sent_at
t.timestamps
end
add_index :nippos, %i(... |
class RemoveImageInfoFromImages < ActiveRecord::Migration
def change
remove_column :images, :image_info, :string
end
end
|
class Recipe < ActiveRecord::Base
belongs_to :user, dependent: :destroy
has_one :categories
belongs_to :category
has_many :recipe_img
belongs_to :rating
has_many :notifications, as: :notifiable
has_attached_file :recipe_img, styles: { recipe_index: "250x350>", recipe_show: "325x475>" }, default_url: "/i... |
#!/usr/bin/env ruby
require 'skeleton'
class WIFIDump < Skeleton
attr_reader :ducky
self.title = 'WIFI Dump TCP'
self.description = 'Dump WIFI profiles, and send it over TCP'
def setup
@host = @server_setup.host
@port = @server_setup.port
@ssl = @server_setup.use_ssl?
end
def run
return un... |
require "airport"
require "plane"
# Imstructions for the Grand Finale:
# Given 6 planes, each plane must land at the airport.
# When the airport is full (capacity: 6 planes), every plane
# must take off again (this must take into consideration that
# the weather may be stormy).
# After all the planes have landed, c... |
# creates states abbreviations
regions = {
'Ile de France' => 'ilf',
'Brittany' => 'Bt',
'Normandy' => 'Nd',
'Pays de la Loire' => 'PL',
'Bourgogne' => 'Bg'
}
# some cities in those states
cities = {
'ilf' => 'Paris',
'PL' => 'Nantes',
'Bg' => 'Dijon'
}
# add some more cities
cities['Nd'] = 'Rouen'
cit... |
class Dialog < Formula
desc "Display user-friendly dialog boxes from shell scripts"
homepage "http://invisible-island.net/dialog/"
url "ftp://invisible-island.net/dialog/dialog-1.2-20150920.tgz"
mirror "https://fossies.org/linux/misc/dialog-1.2-20150920.tgz"
sha256 "c4e61ec5768701683dd4b5b2ebd8a31e6289fa6a1f5... |
class CreateFollows < ActiveRecord::Migration
def change
create_table :follows , id: false do |t|
t.references :from_user , null: false
t.references :to_user , null: false
end
end
end
|
require 'spec_helper'
require 'money-rails/test_helpers'
RSpec.describe ManageIQ::Consumption::ShowbackPricePlan, :type => :model do
let(:plan) { FactoryGirl.build(:showback_price_plan) }
it 'has a valid factory' do
plan.valid?
expect(plan).to be_valid
end
it 'is not valid without a name' do
plan... |
class MyArray
attr_accessor :array
def initialize(arr = [])
@array = arr
end
def size
@array.size
end
def reverse
@array.reverse
end
def max
@array.max
end
def min
@array.min
end
def desc
@array.sort.reverse
end
def asc
@array.sort
end
def odd
@arr... |
class User < ActiveRecord::Base
attr_accessor :remeber_token
before_save {self.email = email.downcase}
validates :name,presence:true, length:{ maximum:50 }
validates :email,presence:true,length:{maximum:50},format:{with:/\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i},uniqueness: { case_sensitive: false }
validates :passwor... |
class AddPrivateToGardens < ActiveRecord::Migration[5.2]
def change
add_column :gardens, :private, :boolean
end
end
|
class Score < ActiveRecord::Base
belongs_to :student
belongs_to :assignment
delegate :course_section, to: :assignment
validates_uniqueness_of :assignment, scope: :student
validates :points_earned, presence: true
validate :points_not_more_than_possible
def color_class
if destroyed?
""
elsif... |
class AlterPublishedUnreadIdx < ActiveRecord::Migration[5.0]
def change
remove_index :entries, :name => 'index_entries_on_unread'
remove_index :articles, :name => 'index_articles_on_published'
add_index :entries, [:unread, :subscription_id], order: { unread: :desc }
add_index :entries, [:unread, :arti... |
class ShortenedUrl < ApplicationRecord
belongs_to :user
has_many :shortened_url_access, -> { order(created_at: :desc) }
validates :short_uri, :presence => true
validates_uniqueness_of :short_uri, :case_sensitive => false
validates :destination_url, :presence => true
validates_format_of :short_uri, :with =>... |
class Product < ActiveRecord::Base
belongs_to :category
has_many :order_lists
mount_uploader :attachment, AttachmentUploader
end
|
require 'spec_helper'
describe "Users" do
describe "signup" do
describe "failure" do
it "should not make a new user" do
lambda do
visit signup_path
fill_in "Name", :with => ""
fill_in "Email", :with => ""
fill_in "Password", :with => ""
fill_in "Confirmation", :with => ""
click_button
response.should render_template('u... |
require 'test_helper'
require 'model_test_helper'
class EntityTest < ActiveSupport::TestCase
test 'Basic entity creation & entities_list association' do
assert_equal 2, entities_lists(:weather_conditions).entities.count
entity = Entity.new(
solution: "{gender: 'male'}",
auto_solution_enabled: fa... |
module Tephue
module Entity
module Comparable
attr_reader :id
def eql?(other)
self.class == other.class && id == other.id
end
alias_method :==, :eql?
def exactly_equal?(other)
eql?(other) && attributes.eql?(other.attributes)
end
def attributes
... |
class RemoveOrderIdFromDialogues < ActiveRecord::Migration
def change
remove_column :dialogues, :order_id
end
end
|
class WelcomeController < ApplicationController #:nodoc:
def router
render 'stoics/home'
end
end
|
# frozen_string_literal: true
module Api::V1::Videos
IndexSchema = ::Api::V1::Admin::Videos::IndexSchema
end
|
class CreateOffers < ActiveRecord::Migration[5.2]
def change
create_table :offers do |t|
t.references :equipment, foreign_key: true
t.date :date_from
t.date :date_end
t.integer :ofer_price
t.float :ofer_percent
t.string :tite1
t.text :body
t.timestamps
end
en... |
require 'spec_helper'
feature 'recording statuses' do
scenario 'User adds a new status' do
post_status 'I am busy'
expect(page.find('.statuses tbody tr:first-child')).to have_text('I am busy')
end
scenario 'The last added status should have a current decal' do
post_status 'I am busy'
expect(pag... |
# Problem 317: Firecracker
# http://projecteuler.net/problem=317
#
# A firecracker explodes at a height of 100 m above level ground. It breaks into a large number of very small fragments, which move in every direction; all of them have the same initial velocity of 20 m/s.
#
#
# We assume that the fragments move wit... |
class RemoveOldNumbersAndNewNumbers < ActiveRecord::Migration
def change
remove_column :courses, :old_number
remove_column :courses, :new_number
remove_column :course_numberings, :old_number
remove_column :course_numberings, :new_number
end
end
|
require 'spec_helper'
describe "shows an individual facility" do
it "shows the facility"do
facility = Facility.create!(facility_attributes(phone: 1111111111))
visit facility_path(facility)
# save_and_open_page
expect(page).to have_text(facility.name)
expect(page).to have_text(facility.iTriage_... |
class AdminMailer < ApplicationMailer
default from: "hello@adventryapp.com"
default to: "grebublin@gmail.com, zefed1@gmail.com"
def user_request(params)
@params = params
mail subject: "Adventry: New user request received"
end
end
|
# -*- mode: ruby -*- vi:ft=ruby:sw=4:ts=4:expandtab:
#
# Generate a single new ssh key to use for all VMs
# By default, vagrant generates a key for each VM, but put is in a
# provider-dependent location. Here, we want to support both vbox and
# libvirt, and there is no way to tell ansible to look for the key in two
# ... |
namespace :wirecard do
task :create_webhook => :environment do
@wirecard = Checkout::Wirecard::Api.new
events = ['PAYMENT.*']
wirecard_webhook = @wirecard.setup_webhook_base events
puts "Webhook token: #{wirecard_webhook["token"]}"
end
task :list_webhook => :environment do
@wirecard = Check... |
module SequelSpec
module Matchers
module Validation
class ValidateLengthMatcher < ValidateMatcher
attr_reader :validation_type
def description
desc = "validate that length of #{@attribute.inspect} "
desc << case validation_type
when :validates_exact_length then... |
class TestServer
attr_accessor :host, :port, :connect_count, :commands
def initialize(options={})
default_options = {
:listen => true,
:authenticate => true,
:response => true,
}
@options = default_options.merge(options)
@connect_count = 0
@connections = []
@commands = []... |
class CreateProjectTodos < ActiveRecord::Migration
def change
create_table :project_todos do |t|
t.text :content
t.date :due_at
t.integer :comments_count
t.datetime :created_at
t.datetime :updated_at
t.string :assignee
t.integer :position
t.string :url
t.integ... |
class Prime
def self.nth(n)
fail ArgumentError unless n > 0
p = PrimeCheker.new
a = natural_numbers()
.lazy()
.select {|x| p.prime?(x)}
.take(n)
.to_a()
.last()
end
private
def self.natural_numbers()
Enumerator.new ... |
class ChangeDataTypeForColumnsInEvents < ActiveRecord::Migration
def change
remove_column :events, :songs_to_learn
remove_column :events, :songs_to_review
end
end
|
module Lxcos
module Runner
class Files < TaskRunner
def initialize(params)
super(params)
@source_env_name, @destination_env_name = params.fetch(:source_env_name), params.fetch(:destination_env_name)
@project_name = params.fetch(:project_name)
end
def sync
cmd_p... |
require_relative '../lib/month'
RSpec.describe Month do
context "#header" do
it "matches cal for December 2012" do
month = Month.new(12, 2012)
month.header.should == " December 2012"
end
it "matches cal for July 1901" do
month = Month.new(07, 1901)
month.header.should == " ... |
cask :v1 => 'kodi' do
version '14.0'
sha256 'bf0f5b836a517edeb78b75424b929c9d42067463232e6f62a2df327a947d9d35'
url "http://mirrors.xbmc.org/releases/osx/x86_64/kodi-#{version}-Helix-x86_64.dmg"
name 'Kodi'
name 'XBMC' # former
homepage 'http://kodi.tv/'
license :gpl
app 'Kodi.app'
end
|
class Deckfile < ActiveRecord::Base
belongs_to :dataset
audited associated_with: :dataset
before_destroy :delete_file
def delete_file
if File.exists?(self.path)
File.delete(self.path)
end
#remove directory if empty
end
end
|
require 'rails_helper'
RSpec.describe ContractsController, :type => :controller do
example do
expect(described_class).to equal(ContractsController)
end
end
|
class GEXF
attr_accessor :file
def initialize(file)
@file = file
end
def write(content)
content = content.gsub("&", "&")
@file.write(content)
end
def write_all(opts={})
header_declaration
graph_declare = opts[:graph_declaration] || {}
graph_declaration(graph_declare)
at... |
RSpec.describe "Framework freeze" do
describe "Hanami::Controller" do
before do
Hanami::Controller.load!
end
after do
Hanami::Controller.unload!
end
it "freezes framework configuration" do
expect(Hanami::Controller.configuration).to be_frozen
end
xit "freezes action co... |
require 'aws-sdk-kinesis'
require 'faker'
require 'json'
# Create a client
kinesis = Aws::Kinesis::Client.new(
region: 'us-east-1',
endpoint: 'http://localhost:4568'
)
# Create the stream
begin
kinesis.create_stream(stream_name: 'usersSignedUp', shard_count: 1)
rescue Aws::Kinesis::Errors::ResourceInUseExceptio... |
# 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... |
module Hutch
module Tracers
class NullTracer
def initialize(klass)
@klass = klass
end
def handle(message)
@klass.process(message)
end
end
end
end
|
module OpenAssets
module Cache
# An object that can be used for caching serialized transaction in a Sqlite database.
class TransactionCache < SQLiteBase
def setup
db.execute <<-SQL
CREATE TABLE IF NOT EXISTS Tx(
TransactionHash BLOB,
SerializedTx B... |
namespace :db do
namespace :pc do
desc 'Updates gravatar users'
task update_gravatar_users: :environment do
batch_size = ENV.fetch('BATCH_SIZE', 50)
users = User.all
users_count = users.count
users.batch_size(batch_size).each_with_index do |user, index|
puts "Updating gravatar... |
class CreateMissions < ActiveRecord::Migration
def change
create_table :missions do |t|
t.integer :num_dossier
t.date :date_reperage
t.time :heure_reperage
t.time :duree_reperage
t.boolean :top_amiante
t.text :perimetre_reperage
t.datetime :dateheure_visite
t.date :... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.