text stringlengths 10 2.61M |
|---|
module Api::V1
class ApiController < ApplicationController
protect_from_forgery with: :null_session
before_filter :allow_cors
rescue_from Exception do |e|
render json: {error: e.message}, status: :unprocessable_entity
end
rescue_from Mongoid::Errors::DocumentNo... |
module Players
class TournamentsController < ApplicationController
def index
@player = Player.find(params[:player_id])
@tournaments = @player.tournaments.page(params[:tournaments_page]).per(10)
end
end
end
|
module EnvVars
def self.[](key)
ENV[full_key(key)]
end
def self.full_key(key)
"#{app_name}_#{Rails.env}_#{key}".upcase
end
def self.app_name
Rails.application.class.parent_name
end
end
|
class User
include ActiveAttr::Model
attribute :id
attribute :email
attribute :password
attribute :crypted_password
class << self
def authenticate(*credentials)
require 'json'
require 'net/http'
require 'uri'
require 'openssl'
require 'jwt'
uri = URI.parse('http://... |
require 'spec_helper'
include Devise::TestHelpers
describe 'Security permissions' do
before :all do
User.destroy_all
DataFile.destroy_all
@author_user = FactoryGirl.create(:user)
@censor_user = FactoryGirl.create(:censor_user)
@users = [@author_user, @censor_user]
@admin_user = FactoryGirl.cr... |
require 'spec_helper'
describe Storage do
context 'uid' do
it 'generates new uids' do
u1 = Storage.next_uid
u2 = Storage.next_uid
expect(u1).not_to eql(u2)
end
it 'generates string uids' do
expect(Storage.next_uid).to be_a(String)
end
end
context 'save & retrieve' do
... |
require "rspec"
require File.dirname(__FILE__) + '/roman_calculator'
describe RomanCalculator, "Add to Roman Numerals to produce a sum" do
it "I plus I should equal II" do
sut = RomanCalculator.new
sut.Add("I","I").should == "II"
end
it "II plus II should equal IV" do
sut = RomanCa... |
require 'rails_helper'
RSpec.describe "/shelters/:id", type: :feature do
it "has a link to the home page" do
visit "/shelters"
click_link "Home"
expect(current_path).to eq("/")
end
end
RSpec.describe "/shelters/:id", type: :feature do
it "allows user to see a shelters info for given id" do
shel... |
module Public::ErrorsHelper
def render_404
render 'public/errors/file_not_found'
end
def redirect_404
redirect_to 'public/errors/file_not_found'
end
end
|
require 'classes/structs'
require 'exceptions'
class Effect
# probability constants
VALID_PROBABILITY = 0.01..1 #valid range
# duration constants
INSTANT = -2
FOREVER = Float::INFINITY
VALID_DURATION = 1..Float::INFINITY
VALID_VALUE_CLASSES = [Numeric, Range, NilClass]
def self.load_definition... |
module MatchFiles
# Returns a processor that mimicks Git ignore behavior
def self.git(root, patterns = nil)
return MatchFiles::GitignoreMatcher.new(root, patterns)
end
end
require_relative('match_files/matcher.rb')
require_relative('match_files/gitignore_matcher')
|
# frozen_string_literal: true
Rails.application.routes.draw do
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
concern :commentable do
resources :comments
end
resources :items, concerns: :commentable
# , :image_attachable]
get 'welcome/index'
# For details on the DSL a... |
require 'securerandom'
require 'forwardable'
require 'hutch/logging'
require 'hutch/exceptions'
module Hutch
class Publisher
include Logging
extend Forwardable
attr_reader :connection, :broker, :config
def_delegators :broker,
:channel,
:exchange,
... |
class LeaderboardController < ApplicationController
def index
@players = User.board
end
end
|
class User < ActiveRecord::Base
validates_presence_of :email, :password
validates_uniqueness_of :email
def login_attempt_counter
self.increment_counter(:logins, 0)
end
def check_user_logins
if self.logins >= 4
self.wait_1_minute
else
self.login_attempt_counter
en... |
class Api::V1::ItemsController < ApplicationController
def index
render json: Item.all, status: 200
end
def show
render json: Item.find(params[:id]), status: 200
end
def destroy
item = Item.find(params[:id])
if item.delete
render json: Item.all, status: 204
end
end
def create
item = Item.new(c... |
class AddActiveToTechnologies < ActiveRecord::Migration
def change
add_column :technologies, :active, :boolean
end
end
|
class ChangeDefaultCategory < ActiveRecord::Migration
def change
change_column :categories, :name, :string, :default => "Misc.", :null => false
end
end
|
module FacilityWizardForm
class BasicInfoForm
include ActiveModel::Model
include Mapper
ATTRS = [:id,
:name,
:code,
:square_foot,
:canopy_square_foot,
:site_license,
:timezone,
:is_complete,
:is_enable... |
require("minitest/autorun")
require('minitest/reporters')
require_relative('../bar')
require_relative('../rooms')
require_relative('../guests')
require_relative('../songs')
require_relative('../drinks')
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
class BarTest < MiniTest::Test
def setup
@dr... |
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "mpex/version"
Gem::Specification.new do |s|
s.name = "mpex"
s.version = Mpex::VERSION
s.authors = ["Fa Wuxi"]
s.email = [""]
s.homepage = "https://github.com/fawuxi/mpex"
s.summary = %q{MPEx.rb: a co... |
require 'rails_helper'
RSpec.describe 'test root page', type: :feature do
before(:each) do
@user = create(:user)
login(@user)
end
scenario 'expect to be on dashboard page when loged in' do
expect(current_path).to eq root_path
expect_page_content(['Dashboard', 'Jobline', 'Job', 'Online cv', 'Ind... |
module CdnTags
class Error < StandardError
attr_reader :object
def initialize(object)
@object = object
end
end
end
|
#!/usr/local/bin/ruby -w
$key = "key"
$target = "coliwicojqkwbjplvwffjvapvjuikicomitxrxnemtbefickmpeitfoohesnojwxcgrddvkhitesnnafxjhhfhxxvxbmxvgpvjuikgcemifgsbapagoqympzgvmhggzzclgksdjqgthbytkgubbshlcnnspxufwxnrfbytkgusjtrbbhjxorqijqdxfexstmwtbsoxjjbmvhfjvyvmssnhvtdqrrithnhgjtacnvfhcsxrnrhirwcgroxxjbbhvstxoimmumwolxnrw... |
class CreateSkis < ActiveRecord::Migration
def change
create_table :skis do |t|
t.references :store, :null => false
t.attachment :image
t.string :gender, :null => false
t.string :level, :null => false
t.string :brand, :null => false
... |
require 'rails_helper'
RSpec.describe "announcements/edit", type: :view do
before(:each) do
@announcement = assign(:announcement, Announcement.create!(
:name => "MyString",
:kind => "MyString",
:title => "MyString",
:subtitle => "MyString",
:column => 1,
:lines => 1,
:pa... |
module Montrose
class Schedule
attr_accessor :rules
def self.build
schedule = new
yield schedule if block_given?
schedule
end
def initialize
@rules = []
end
def <<(rule)
@rules << Montrose::Recurrence.new(rule)
self
end
alias add <<
def incl... |
# frozen_string_literal: true
module TidyJson
class JtidyInfo # :nodoc:
NOTICE = [
'#',
'# jtidy is in no way affiliated with, nor based on, ',
'# the HTML parser and pretty printer of the same name.',
'#',
'# More information is available here:',
'# https://github.com/rdipard... |
class Admin::PuppetmastersController < Admin::AdminController
load_and_authorize_resource
include Admin::UtilsHelper
# GET /puppetmasters
# GET /puppetmasters.json
def index
@puppetmasters = Puppetmaster.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @... |
class Ad < ActiveRecord::Base
include SecureAttachable
belongs_to :screen
belongs_to :user
has_attached_file :ad_image,
styles: { large: '900x300#', card: '300x300>', thumb: '100x100>' },
default_url: ''
has_destroyable_file :ad_image
validates_image_attachment :a... |
z = %w(my name is seif d)
#this will give us an array of the above sentence
#what if we want to loop over this array and do something?
z.each do |word|
print word + " "
end
#loops through each element of the array
#and prints a sentence
#can also be written like this:
z.each {|word| print word.capitalize + " "... |
require 'rails_helper'
describe Idv::ProfileMaker do
describe '#save_profile' do
it 'creates Profile with encrypted PII' do
applicant = Proofer::Applicant.new first_name: 'Some', last_name: 'One'
normalized_applicant = Proofer::Applicant.new first_name: 'Somebody', last_name: 'Oneatatime'
user ... |
# == Schema Information
#
# Table name: users
#
# id :bigint(8) not null, primary key
# username :string(255) not null
# password :string(255) not null
# email :string(255)
# admin :boolean default(FALSE)
#
FactoryBot.define do
factory :user do
sequence :username do |... |
class ClientStatus < ApplicationRecord
belongs_to :department
validates :name, :icon_color, :department, presence: true
end
|
# frozen_string_literal: true
# Dealer
class Dealer < User
def initialize(name = 'Dealer')
super
end
def make_choice(deck)
take_card(deck) if hand.cards_count_score < 17 && hand.cards.size != 3
end
end
|
# Write a function:
# def solution(s)
# that, given a string S consisting of N characters, returns 1 if string S is properly nested and 0 otherwise.
# For example, given S = "(()(())())", the function should return 1 and given S = "())", the function should return 0, as explained above.
def solution(s)
chars ... |
# frozen_string_literal: true
module Vedeu
module Editor
# Used by {Vedeu::Editor::Lines} and {Vedeu::Editor::Line} to
# fetch an item from the respective collection.
#
# @api private
#
module Collection
include Vedeu::Repositories::Assemblage
# Fetches an item from a collecti... |
# Sections
# --------
When(/^the user goes to the (.*?) section$/) do |section_name|
section_name = section_name.downcase
page_header_text = on(Sidebar).goto_section(section_name)
expect(page_header_text).to eq(section_name)
end
|
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
#config.vm.box = "ubuntu/xenial64"
config.vm.box = "bento/ubuntu-16.04"
config.vm.define "#{ENV['QTRPI_VM_NAME']}"
config.vm.provider "virtualbox" do |v|
v.memory = 4096
v.cpus = 8
end
config.vm.provision :ansible do |ansi... |
# == Schema Information
#
# Table name: reservations
#
# id :bigint(8) not null, primary key
# user_id :integer not null
# restaurant_id :integer not null
# start_datetime :datetime not null
# table_size :integer not null
# end_datetime :datetime... |
class RoadtripFacade
class << self
def route(data)
route = MapquestService.route(data)
# require 'pry'; binding.pry
if route[:info][:statuscode] == 402
coordinates = LocationFacade.coordinates(data[:destination])
forecast = {}
start_city = data[:origin]
end_city ... |
require 'test_helper'
class ReviewsControllerTest < ActionController::TestCase
setup do
@review = reviews(:one)
@user = users(:one)
@admin = users(:admin)
@tb = users(:tb)
end
test "should get index" do
sign_in(@admin)
get :index
assert_response :success
assert_not_nil assigns(:r... |
Rails.application.routes.draw do
root 'time_cards#show'
get '/signup', to: 'users#new'
post '/signup', to: 'users#create'
get '/login', to: 'sessions#new'
post '/login', to: 'sessions#create'
delete '/logout', to: 'sessions#destroy'
get '/timecard', to: 'time_cards#show'
post '/timecard', ... |
require File.dirname(__FILE__) + '/../../test/test_helper'
require File.dirname(__FILE__) + '/../spec_helper'
require 'redirect_controller'
# Re-raise errors caught by the controller.
class RedirectController; def rescue_action(e) raise e end; end
describe RedirectController do
before do
request.relative_url_ro... |
class CreateVerdicts < ActiveRecord::Migration
def change
create_table :verdicts do |t|
t.string :status
t.string :opinion_left
t.string :opinion_right
t.integer :winner_id
t.string :confirmed_judges
t.string :confirmed_public
t.belongs_to :debate, index: true
t.ti... |
# 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 "set"
n = 28123
class Integer
def factors()
1.upto(Math.sqrt(self)).select {|i| (self % i).zero?}.inject([]) do |f, i|
f << i
f << self/i unless i == self/i
f
end.sort - [self]
end
end
# build a set of abundant numbers less than n
@abundant_set = (2..n).sel... |
class RenameIsPositionToIsJobForCubicleLabels < ActiveRecord::Migration
def self.up
rename_column :cubicle_labels, :is_position, :is_job
end
def self.down
rename_column :cubicle_labels, :is_job, :is_position
end
end
|
class TradeArticleQuery < Query
attr_reader :evergreen, :pub_date_start, :pub_date_end, :update_date_start, :update_date_end, :q
def initialize(options = {})
super
[:pub_date_start, :pub_date_end, :update_date_start, :update_date_end, :q].each do |sym|
instance_variable_set("@#{sym}", options[sym])
... |
class MessagesController < ApplicationController
before_action :populate_friends
def index
@messages = current_user.received_messages
end
def create
@message = Message.new(create_message_params)
@message.sender_id = current_user.id
if @message.save
flash.now[:success] = "Message sent"
... |
require 'meal_serving'
require 'initializations'
RSpec.configure do |config|
config.include(Recipes)
end
describe MealServing do
let(:soup_serving){described_class.new(soup, 5)}
let(:ingredient_quantities){soup_serving.total_ingredient_quantities}
describe '#total_ingredient_quantities' do
context 'retur... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
resource :bullet, only: :show
resource :in_fine, only: :show
resource :standard, only: :show
resource :linear, only: :show
root to: redirect('/standard')
mount LoanCreato... |
class AddForeignKeyForImageCreator < ActiveRecord::Migration[5.0]
def change
add_foreign_key :images, :users, column: :creator_id, name: :index_images_on_creator_id
end
end
|
Pod::Spec.new do |s|
s.name = 'BitlyShortener-Fork'
s.version = '0.0.1'
s.platform = :ios
s.author = 'stefan@arentz.ca'
s.summary = 'Bit.ly shortener'
s.source = { :git => 'https://github.com/111minutes/iphone-bitly.git', :commit => '1e075e9d9078f364b55bfc9740e061b4fd41f48b' }
s.source_f... |
class DeleteUserId < ActiveRecord::Migration[6.0]
def change
remove_column :flight_attendances, :user_id
add_column :flight_attendances, :traveler_id, :integer
end
end
|
class AlertsViewHandler
attr_reader :result
class << self
def call(result)
new(result).perform
end
end
def initialize(result)
@result = result
end
def perform
setup_alerts!
end
def setup_alerts!
result['contract.default'].errors.full_messages.inject('') do |acc, elem|
... |
class Status < ActiveRecord::Base
attr_accessible :message,
:is_clock_out
belongs_to :user
def ended_at
if self.next_status.present?
self.next_status.created_at
else
Time.zone.now
end
end
def duration_in_seconds
self.ended_at - self.created_at
end
def dur... |
require 'pry'
require 'json'
require 'rack/cache'
require 'sinatra'
require 'digest/sha1'
require 'redis'
use Rack::Static, urls: ["/assets", "/components", "/lib"]
use Rack::Cache
set :static_cache_control, :public
enable :sessions
REDIS = Redis.new
def validate_registration(email, password)
errors = {}
unless ... |
require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require(*Rails.groups)
platform = RUBY_PLATFORM.match(/(linux|darwin)/)[0].to_sym
Bundler.require(platform)
module EventsInsider
class Application < Rails::Application
# Use the responders controller from the responders gem
config.a... |
class RenameTypoInInsurance < ActiveRecord::Migration
def change
rename_column :insurances, :paid_preriod_length, :paid_period_length
end
end
|
feature 'Visitor signs in' do
scenario 'with valid email and password' do
sign_in_as_admin
expect_user_to_be_signed_in
end
scenario 'tries with wrong password' do
create :user,
name: 'name',
email: 'user@example.com',
password: 'password'
sign_in_with 'use... |
# Acts as a proxy to buildables with regexp names. Used for caching purposes. Remembers name used and always uses it later.
# Allows building and demolishing it's buildable.
class Blueprints::BlueprintNameProxy
# Initializes new instance of proxy.
# @param [Symbol] name Name of buildable that this proxy uses.
# @... |
class CalendarController < ApplicationController
before_action :authenticate_employee!
def index
set_variables(Date.today.month, Date.today.year)
end
def month
date = Date.parse(params[:date])
set_variables(date.month, date.year)
render :index
end
# Sets the variables for the calendar, u... |
def translate(string)
words = string.split(" ")
vowels = ["a", "e", "i", "o", "u"]
phrase = []
words.each do |word|
if vowels.include?(word[0])
phrase << word + "ay"
elsif
phrase << until_vowel(word)
end
end
return phrase.join(' ')
end
privat... |
require 'rubygems'
require 'sinatra'
require 'sqlite3'
require 'net/http'
require 'json/pure'
helpers do
def dbquery(query, params=nil)
retries = 5
result = []
db = SQLite3::Database.new "reorgjs.sqlite"
begin
if params
db.execute(query, params) do |row|
result << row
end
else
db.execut... |
require "thor"
require "erb"
require "fileutils"
class Configure < Thor
# ...
def self.exit_on_failure?
true
end
class << self
def options(options={})
options.each do |option_name, option_settings|
option option_name, option_settings
end
end
end
module E... |
class Organization < ActiveRecord::Base
has_many :challenges, class_name: "Challenge"
end
|
require_relative 'db_connection'
require_relative '01_sql_object'
module Searchable
def where(params)
where_line = params.keys.map { |key| "#{key} = ?" }.join(' AND ')
results = DBConnection.execute(<<-SQL, *params.values)
SELECT
*
FROM
#{table_name}
WHERE
#{whe... |
RSpec::Matchers.define :perform_queries do |expected|
match do |block|
query_count(&block) == expected
end
failure_message do |actual|
"Expected to run #{expected} queries, got #{@counter.query_count}"
end
def query_count(&block)
@counter = ActiveRecord::QueryCounter.new
ActiveSupport::Notif... |
class Manufacturer < ActiveRecord::Base
has_many :categories
has_many :products, through: :categories
validates_presence_of :title
end
|
require 'spec_helper'
describe Space::App::Handler do
let(:project) { stub('project') }
let(:handler) { Space::App::Handler.new(project) }
def command_for(command)
handler.send(:command_for, nil, command)
end
describe 'command_for' do
it 'returns a Command::Refresh instance for an empty command st... |
# frozen_string_literal: true
require 'jiji/test/test_configuration'
require 'jiji/test/data_builder'
describe Jiji::Model::Trading::Intervals do
let(:intervals) { Jiji::Model::Trading::Intervals.instance }
describe '#get' do
it 'idに対応するIntervalを取得できる' do
interval = intervals.get(:one_minute)
exp... |
require 'rails_helper'
RSpec.describe Company, :type => :model do
describe 'associations' do
it { is_expected.to have_many(:products) }
it { is_expected.to have_many(:people) }
end
describe 'validations' do
it { is_expected.to validate_presence_of(:name) }
end
describe 'callbacks' do
subjec... |
module CategoriesHelper
def show_nested_category_name(categories, category, show_links)
show_nested_category_name(categories, category, show_links, '>')
end
def show_nested_category_name(categories, category, show_links=false, separator)
#walk the categories recursively, finding the parent
n... |
class RenameScorecardHolesToTurns < ActiveRecord::Migration[4.2]
def change
rename_table :turns, :turns
end
end
|
class CreateProjectCategories < ActiveRecord::Migration
def up
create_table ::Refinery::ProjectCategory.table_name do |t|
t.string :title
t.integer :position
t.timestamps
end
add_index ::Refinery::ProjectCategory.table_name, :id
load(Rails.root.join('db', 'seeds', 'project_cat... |
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user (not logged in)
cannot :manage, :all
can :manage, Destination, user_id: user.id
can :manage, Source, user_id: user.id
can :manage, Article, user_id: user.id
can :manage, AffiliateLink, user_id: user.id... |
class Status < ActiveRecord::Base
validates :body, :user_id, presence: true
has_many :comments, as: :commentable, dependent: :destroy
has_many :likes, as: :likeable, dependent: :destroy
belongs_to :user
default_scope { order('created_at DESC') }
def liked_by?(user)
self.likes.exists?(user_id: user.i... |
class FontGupter < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/gupter"
desc "Gupter"
homepage "https://fonts.google.com/specimen/Gupter"
def install
(share/"fonts").install "Gupter-Bold.ttf"
(share/"fonts").install "Gupter-Medi... |
require 'fileutils'
require 'test/unit'
require 'pp'
require 'rubygems'
require 'bundler/setup'
require 'rspec'
require 'json'
require 'vocabularise/model'
require 'vocabularise/config'
require 'vocabularise/crawler'
require 'vocabularise/request_handler'
require 'vocabularise/mendeley_handler'
require 'vocabularise... |
namespace :parking_spots do
# rails geocode:all CLASS=ParkingSpot SLEEP=1.25 REVERSE=true
task dump: :environment do
parking_spots = ParkingSpot.all.map do |parking_spot|
parking_spot.attributes.slice('friendly_name', 'latitude', 'longitude', 'address', 'polygon')
end
File.open(Rails.root.join('... |
# frozen_string_literal: true
class Course
attr_accessor :subject
def initialize(subject)
@subject = subject
end
end
|
class CreateCompras < ActiveRecord::Migration[5.0]
def change
create_table :compras do |t|
t.string :nome_comprador, limit: 50
t.string :descricao, limit: 50
t.decimal :preco_unitario
t.integer :quantidade
t.string :endereco, limit: 50
t.string :nome_fornecedor, limit: 50
... |
# 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... |
require 'rails_helper'
RSpec.describe ItemPurchase, type: :model do
describe '商品購入情報の保存' do
before do
@user = FactoryBot.create(:user)
@item = FactoryBot.create(:item)
@purchase = FactoryBot.build(:item_purchase)
sleep 0.02 # インスタンス生成時にエラーが発生するため待機処理を実行
@purchase.user_id = @user.id
... |
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
validates :name, uniqueness: true, presence: true
va... |
class SessionsController < ApplicationController
before_action :authenticate_user!
skip_after_action :verify_authorized
skip_after_action :verify_policy_scoped
def create
unless current_user.present?
head :unprocessable_entity
end
end
end |
# frozen_string_literal: true
require 'gosu'
require_relative 'snake'
require_relative 'food'
class Game < Gosu::Window
def initialize
super 640, 480
self.caption = 'GOSU SNAKE'
reset_snake
@food = Food.new
@font = Gosu::Font.new(20)
end
def update
snake_move
reset_food if @snake.fe... |
require 'airport'
describe Airport do
it { is_expected.to respond_to(:land).with(1).argument}
it { is_expected.to respond_to(:take_off).with(1).argument}
describe '#land' do
it 'can see a landed plane' do
plane1 = (double :plane)
subject.land(plane1)
expect(subject.planes).to include plane1
en... |
VALID_CHOICES = { r: 'rock', p: 'paper', sc: 'scissors', l: 'lizard', sp: 'spock' }
def prompt(message)
puts "=> #{message}"
end
def win?(first, second)
(first == 'rock' && %w(scissors lizard).include?(second)) ||
(first == 'paper' && %w(rock spock).include?(second)) ||
(first == 'scissors' && %w(paper li... |
# Source: https://launchschool.com/exercises/41e03303
# Create a hash with the letter block pairs
BLOCK_PAIRS = {
'B' => 'O', 'X' => 'K', 'D' => 'Q', 'C' => 'P', 'N' => 'A', 'G' => 'T',
'R' => 'E', 'F' => 'S', 'J' => 'W', 'H' => 'U', 'V' => 'I', 'L' => 'Y',
'Z' => 'M'
}.freeze
# Take a given word
# Unless str.c... |
# frozen_string_literal: true
RSpec.describe Customerio::TrackService, :customerio do
let(:service) { described_class.new }
describe '#call' do
subject(:call) do
service.call(user_id: user.id, event: event, **attributes)
end
let(:user) { create(:user) }
let(:event) { 'event_name' }
let(... |
# Processes have resource limits, which are imposed by the kernel.
# Ruby maximum allowed file descriptors
p Process.getrlimit(:NOFILE) # [soft limit, hard limit]
# Bumping the soft limit
Process.setrlimit(:NOFILE, 4096)
p Process.getrlimit(:NOFILE)
# Exceeding the limit will raise an exception
Process.setrlimit(:NO... |
require_relative "digit"
require_relative "dictionary"
require_relative "words_from_letters"
module TollFree
class FindWords
def initialize phonenumber,
dictionary = "/Users/tim/code/toll_free/conf/words"
@digits = phonenumber.chars.map { |char| TollFree::Digit.new(char.to_i) }
@di... |
# frozen_string_literal: true
class ContactSerializer
include FastJsonapi::ObjectSerializer
set_key_transform :camel_lower
set_type :contacts
set_id :uid
attributes :given_name,
:family_name,
:name,
:email,
:role_name,
:created,
:... |
# frozen_string_literal: true
Gem::Specification.new do |s|
s.name = 'gauss'
s.version = '0.0.1'
s.authors = ['Hasstrup Ezekiel']
s.email = ['hasstrup.ezekiel@gmail.com']
s.date = '2020-09-07'
s.summary = 'Vending machine'
s.files = Dir[
'{lib}/**/*',
'Gemfile',
'Rakefile'
]
s.require_pat... |
require File.expand_path('../boot', __FILE__)
require "action_controller/railtie"
require "action_mailer/railtie"
require "sprockets/railtie"
Bundler.require(:default, LOLITA_ORM, Rails.env) if defined?(Bundler)
module RailsApp
class Application < Rails::Application
# Add additional load paths for your own custom ... |
class DropDropboxInfoFromUsers < ActiveRecord::Migration
def up
remove_column :users, :dropbox_token_key
remove_column :users, :dropbox_token_secret
end
def down
add_column :users, :dropbox_token_key, :string, :null => false, :default => '', :after => :assets_size
add_column :users, :dropbox_toke... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Hyrax::EtdPresenter, type: :presenter do
subject(:presenter) { described_class.new(document, ability, request) }
let(:ability) { nil }
let(:document) { SolrDocument.new(etd.to_solr) }
let(:etd) { FactoryGirl.create(:moomin... |
class Forecasts::CashFlowStatementController < ApplicationController
load_and_authorize_resource
def index
@forecast = Forecast.find(params[:forecast_id])
@cash_flow_statement = CashFlowStatement.new(@forecast)
end
private
# Never trust parameters from the scary internet, only allow the white... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.