text stringlengths 10 2.61M |
|---|
class NewSudoku
def initialize(numbers)
@numbers = numbers.split('')
@candidates = %w[1 2 3 4 5 6 7 8 9]
solve
end
def solve
until solved?
@numbers.each_with_index do |number, index|
if number == '0'
@index = index
@numbers[index] = uniqueness if uniqueness != n... |
# frozen_string_literal: true
# Script Model
class Script < ApplicationRecord
include ActivityHistory
include CloneRecord
include Uploadable
include Downloadable
include Sortable
acts_as_list
validates_presence_of :name, :script, :url
def self.get_script(request)
find_by_url(request.url)
end
... |
class RemoveClientFronInvoices < ActiveRecord::Migration
def change
remove_column :invoices, :client, :string
end
end
|
# = Clase madre Matriz.
# Contiene los métodos comunes entres las clase matrizDen y matrizDis, que son:
# - att_reader para ancho y elementos de matriz.
# - to_s.
# - [](i), para poder acceder directamente a los elementos.
# - []=(i,other), que permite indexar elementos de matriz.
# La jerarquía de herencias es la sig... |
class SessionsController < ApplicationController
def new
applicant = Applicant.find_by(email: params[:email])
if applicant
session[:email] = applicant.email
render json: applicant
else
render json: {message: "No applicant with this email exist"}
end
end
def create
end
def ... |
FactoryGirl.define do
factory :snap_invite_ad do
name 'Features'
media_url 'http://example.com/features.png'
text_overlay 'Check out our cool features'
end
end
|
Rails.application.routes.draw do
devise_for :tutors
resources :appointments
resources :tutors, except: [:new, :create, :edit, :update] do
resources :appointments, only: [:index, :new]
end
resources :students do
resources :tutors, only: [:index]
resources :appointments, only: [:index, :new]
end
... |
# frozen_string_literal: true
module Relax
module SVG
# Structural objects under this module, as defined
# https://www.w3.org/TR/SVG2/struct.html#TermStructuralElement
module Structural
# This is a prototype class for a structural element
class StructuralPrototype
include Relax::SVG::... |
class GithubIssuesController < ApplicationController
before_action :set_github_issue, only: [:show, :edit, :update, :destroy]
# GET /github_issues
# GET /github_issues.json
def index
@github_issues = GithubIssue.all
end
# GET /github_issues/1
# GET /github_issues/1.json
def show
end
# GET /gi... |
require 'spec_helper'
require_relative '../lib/game'
describe Game do
before :each do
# TODO: use real objects
space_list = [GoSpace.new]
39.times do
space_list << NormalSpace.new
end
@board = Board.new(space_list)
end
it "creates a game with two players named Horse and Car." do
ho... |
Refinery::Pages::SectionPresenter.class_eval do
attr_accessor :view_context
#def wrap_content_in_tag(content)
#template = ERB.new content.to_s.gsub(">",'>').gsub("<",'<')
#def view_context.get_binding
#binding()
#end
#content = template.result(view_context.get_binding).html_safe
#con... |
class AeventoDispositivosController < ApplicationController
before_action :set_aevento_dispositivo, only: [:show, :edit, :update, :destroy]
# GET /aevento_dispositivos
# GET /aevento_dispositivos.json
def index
@aevento_dispositivos = AeventoDispositivo.all
end
# GET /aevento_dispositivos/1
# GET /a... |
# Write your code here.
katz_deli = []
def line(katz_deli)
if katz_deli.length == 0
puts "The line is currently empty."
else
other_deli = []
message = "The line is currently:"
katz_deli.each_with_index do |name, i|
other_deli.push(" #{i + 1}. #{name}")
end
katz_deli_line = other_deli.u... |
#this is some code
#class code: Class, Game
#The class will have four methods
#Guess, Check, mark, create
#Guess will take a user input
#Check will see if that has been guessed before, and then if its in the word
#mark will add that guess to previously guessed, and if applicable add it to the word
#each round it will c... |
require "test/unit"
require File.dirname(__FILE__) + "/../lib/ordered_json"
require "json"
class OrderedJSONTest < Test::Unit::TestCase
def test_parse_nothing
assert_equal OrderedHash.new, OrderedJSON.parse("{}")
end
def test_simple_dump
assert_equal "{ }", OrderedJSON.dump({})
end
def test_... |
class BashhubServer < Formula
desc "privately hosted open source server for bashhub-client https://github.com/rcaloras/bashhub-client"
homepage ""
version "0.2.4"
if OS.mac?
url "https://github.com/nicksherron/bashhub-server/releases/download/v0.2.4/bashhub-server_v0.2.4_darwin_amd64.tar.gz"
sha256 "2c... |
require "spec_helper"
RSpec.describe SemanticNavigation::Core::Leaf do
let(:leaf_class) { SemanticNavigation::Core::Leaf }
describe "#name" do
context :returns do
it "saved name" do
leaf = leaf_class.new({ id: :first, name: "first" }, 1)
expect(leaf.name).to eq "first"
end
i... |
require 'rails_helper'
RSpec.describe FeedConsumer do
describe '#perform' do
let(:source_urls){[
#"http://www.cttransit.com/uploads_GTFS/googleha_transit.zip",
#"http://www.cttransit.com/uploads_GTFS/googletest_transit.zip",
#"http://www.cttransit.com/uploads_GTFS/googlenh_transit.zip",
#... |
class SessionsController < ApplicationController
def destroy
logout
redirect_to :sign_in, notice: 'Successfully signed out.'
end
end
|
# frozen_string_literal: true
require 'csv'
require 'open-uri'
CSV_URL='http://sdw-wsrest.ecb.europa.eu/service/data/EXR/D.USD.EUR.SP00.A?format=csvdata'
class ParseRates
def self.perform(file: open(CSV_URL), date_column: 'TIME_PERIOD', value_column: 'OBS_VALUE')
last_rate_date = EurUsdRate.order(:date).last&.d... |
require File.expand_path(File.dirname(__FILE__) + "/my_kmart_test_base")
describe "ProductReviewsPageTest" do
include MyKmartTestBase
valid_user_info = nil
valid_product_info = nil
before :each do
setup_pages
valid_user_info = create_new_user
valid_product_info = create_new_produ... |
names = ["Sopha", "Joãozinho", "Joanazinha"]
version = {'Versão 1' => 'Liberada', 'Versão 2' => 'Liberada', 'Versão 3' => 'Liberada', 'Versão 4' => 'Atual', 'Versão 5' => 'Em desenvlvimento'}
creator = 'Pedro "Dpezin" Valentinuci'
def nation
puts "1- Nacional"
puts "2- Gringa"
end
print "Digite o seu nome: "
... |
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
#protect_from_forgery with: :null_session
before_filter :configure_permitted_parameters, if: :devise_controller?... |
module ThreeScale
module Request
def build_params parameters
parameters.reject! {|k,v| v.nil? || v.empty?}
query = parameters.inject([]) do |query, key_value|
key_value[1] = key_value[1].strip
query << key_value.join("=")
end
query.join("&")
end
def get path, para... |
module OpenNebula
class TestUtils
# ids used in tests
VMID = 4900
CTID = 5590
# resources
TEST_DISK = File.expand_path(File.dirname("test/resources/unused")) + "/disk.0"
TEST_CTX = File.expand_path(File.dirname("test/resources/unused")) + "/disk.2"
# absolute paths describing openvz env... |
require 'cases/sqlserver_helper'
require 'models/developer'
require 'models/topic'
class AttributeMethodsTestSqlserver < ActiveRecord::TestCase
end
class AttributeMethodsTest < ActiveRecord::TestCase
COERCED_TESTS = [
:test_read_attributes_before_type_cast_on_datetime,
:test_typecast_attribute_from_selec... |
require 'test_helper'
class Kagishi::ConfigurationTest < Minitest::Test
def test_default_configuration
assert_equal "HS256", Kagishi.config.algorithm
assert_equal 15 * 60, Kagishi.config.ttl
assert_equal "", Kagishi.config.secret
end
class RewriteConfigurationTest < Minitest::Test
def setup
... |
require 'spec_helper'
describe 'when searching' do
context 'for quick notes' do
let(:matching_key) { 'matchingkey' }
let(:matching_value) { 'matchingvalue' }
let(:matching_tags) { %w[matchingtag] }
let(:nonmatching_key) { 'badkey' }
let(:nonmatching_value) ... |
require 'prawn_charts/layers/layer'
module PrawnCharts
module Layers
# Vertical line graph.
class VerticalLine < Layer
def draw(pdf, coords, options={})
# Include options provided when the object was created
options.merge!(@options)
pdf.reset_text_marks
stroke_width ... |
class AddSchoolFundrasierToEvents < ActiveRecord::Migration
def change
add_column :events, :school_fundraiser, :boolean, default: false
end
end
|
class AmzUpdatesChannel < ApplicationCable::Channel
def subscribed
stream_from "amz_updates_channel"
end
def change(data)
deliveries = DataStorage[:amazon_deliveries].with_indifferent_access || {}
if data["remove"]
deliveries.delete(data["id"])
elsif data["rename"]
order = deliveries[... |
require 'active_record'
module Chawk
# Models used in Chawk. ActiveRecord classes.
module Models
class NodeInvalidator
extend Forwardable
def_delegators :sweeps, :size, :map
def initialize(node)
@node = node
@sweeps = []
@selections = []
end
def <<(time)
... |
require 'spec_helper'
describe GadgetsController do
describe "GET 'index'" do
before :each do
get :index
end
it "returns http success" do
expect(response).to be_success
end
it "renders the index template" do
expect(response).to render_template :index
end
it "populat... |
class VotesController < ApplicationController
before_action :authenticate_user!
def create
review = Review.find params[:review_id]
vote = Vote.new is_up: params[:is_up],
user: current_user,
review: review
if vote.save
redirect_to product_path(review.product... |
class Event < ActiveRecord::Base
attr_protected
has_many :guests
has_many :items
belongs_to :host
validates_presence_of :name, :address
after_validation :geocode
geocoded_by :address
end |
class CreateConversationContexts < ActiveRecord::Migration[5.0]
def change
create_table :conversation_contexts do |t|
t.string :key
t.text :dialog_stack, array: true, default: ['root']
t.integer :turn_counter, default: 1
t.integer :request_counter, default: 1
t.string :convo_id
... |
require 'faraday'
module Zotero
Base_URL = 'https://api.zotero.org'
API_Version = {query_param: 'v', query_string: 3}
API_Key = {userID: 1248965,key: 'L4KkWh4aGygSjJUz98vXWUIX'}
end
# https://www.zotero.org/support/dev/web_api/v3/basics
conn = Faraday.new(:url => Zotero::Base_URL) do |faraday|
# faraday.request... |
require 'spec_helper'
describe "employees/new" do
before(:each) do
assign(:employee, stub_model(Employee).as_new_record)
end
it "renders new employee form" do
render
assert_select "form[action=?][method=?]", employees_path, "post" do
end
end
end
|
require 'test_helper'
class RegistrationsControllerTest < ActionController::TestCase
include Devise::TestHelpers
test "should create registration" do
assert_difference('Registration.count') do
post :create, registration: {email: 'test@test.com'}
end
assert_redirected_to root_path
end
... |
require "rubygems"
require "bundler"
Bundler.setup
require 's3_uploader'
def s3_upload(bucket_name, directory)
Fog.credentials = { path_style: true }
S3Uploader.upload_directory(directory, bucket_name, {
:s3_key => ENV['MZS_AWS_ACCESS_KEY'],
:s3_secret => ENV['MZS_AWS_SECRET'],
:public => true... |
module Piano
module Helpers
def current_user
!session[:user].nil?
end
end
end
|
version = `cat ./version`.strip
Pod::Spec.new do |s|
s.name = 'CZiti-macOS'
s.version = version
s.summary = 'Ziti SDK for Swift (macOS)'
s.homepage = 'https://github.com/openziti/ziti-sdk-swift'
s.author = { 'ziti-ci' => 'ziti-ci@netfoundry.io' }
s.license = { :type => 'Apache... |
class ChannelNameUnique < ActiveRecord::Migration[5.2]
def change
change_column :channels, :name, :string, null: false
add_index :channels, :name, unique: true
end
end
|
two_number = ARGV[0]
arr2 = []
arr3 = []
result = 0
p "============="
puts "Преобразование числа Двоичной Системы Исчисления (2-СИ) в Десятиричную (10-СИ) методом удвоения"
p "============="
# валидация двоичного числа и "плавающей точки"
valid = two_number.to_s.count "23456789" # проверяем наше число на содержание чис... |
module Raven
class Processor::RequestMethodData < Processor
attr_accessor :request_methods
def initialize(client)
super
self.request_methods = client.configuration.sanitize_data_for_request_methods
end
def process(data)
sanitize_if_string_keys(data) if data["request"]
sanitiz... |
require_relative 'gitlab_init'
require_relative 'gitlab_net'
require 'json'
require 'base64'
class GitlabPostReceive
attr_reader :config, :repo_path, :changes
def initialize(repo_path, actor, changes)
@config = GitlabConfig.new
@repo_path, @actor = repo_path.strip, actor
@changes = changes
end
de... |
class User < ApplicationRecord
# Direct associations
has_many :restaurants,
:foreign_key => "contributor_id",
:dependent => :nullify
has_many :activities,
:foreign_key => "contributor_id",
:dependent => :nullify
has_many :recipes,
:foreig... |
class TodoItemsController < ApplicationController
before_action :set_todo_list
def create
@todo_item = @todo_list.todo_items.create(todo_item_params)
redirect_to @todo_list
end
def destroy
@todo_item = @todo_list.todo_items.find(params[:id]).destroy
redirect_to @todo_list
end
private
def set_todo_list
@t... |
class Booking < ApplicationRecord
belongs_to :boat
belongs_to :user
has_one :review, dependent: :destroy
validates :date_start, :date_end, presence: true
# validate :end_must_be_after_start
# validate :start_must_not_be_before_today
# def end_must_be_after_start
# errors.add(:date_end, "must be after... |
class AddBuildingToListing < ActiveRecord::Migration
def change
add_column :listings, :unit, :string
add_column :listings, :building_id, :integer
add_column :listings, :listings_type_id, :integer
add_column :listings, :room_config_id, :integer
add_column :listings, :fee_type_id, :integer... |
class ApplicationController < ActionController::Base
before_action :authenticate_user!
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
helper_method :dt
def dt(key, options = {})
options.merge!(:default => t(... |
# frozen_string_literal: true
require "lib/middleman-git_matter"
activate :git_matter
require "lib/middleman-categories"
activate :categories
# https://github.com/Aupajo/middleman-search_engine_sitemap
# You can override the priority or change frequency for a particular page by using frontmatter:
# ---
# title: Blo... |
OpenGithubIssue::Engine.routes.draw do
post :report, to: 'reports#report', as: :report
end
|
class Account::JobsController < ApplicationController
before_action :authenticate_user!
def index
@jobs = current_user.applied_jobs
end
end
|
require 'rails_helper'
RSpec.describe DashboardsController, :type => :controller do
describe 'GET show' do
context 'not logged in' do
it 'redirects to login page' do
get :show
expect(response).to redirect_to(login_path)
end
end
context 'user logged in' do
let(:user) { b... |
# frozen_string_literal: true
ActiveAdmin.register PrinterModel do
permit_params :name, :x_mm, :y_mm, :z_mm, :petg, :abs
end
|
class UserGroup < ActiveRecord::Base
validates :user_group, uniqueness: true, presence: true, length: { in: 2..20 }
validates :group_name, presence: true, length: { maximum: 40 }
has_many :users
has_many :scripts
has_many :filters
end
|
class AddIsOpenToShopHours < ActiveRecord::Migration
def change
add_column :shop_hours, :is_open, :boolean
end
end
|
class ExplanatoryVariableDSL
attr_accessor :variable, :current_sample
def initialize(main_block, variable)
@variable = variable
@dependencies = []
instance_eval(&main_block)
end
def type(type)
@variable.type = type
end
def input(input)
@variable.input = input
end
def description(... |
class NotificationScope < ActiveRecord::Base
belongs_to :notification_listener
belongs_to :notifier, :polymorphic => true
validates_uniqueness_of :notification_listener_id, :scope => [:notifier_id, :notifier_type], :message => "This NotificationListener is already associated with that object!"
end
|
class CreateNonSiteUsers < ActiveRecord::Migration
def self.up
create_table :non_site_users do |t|
t.string :email, :null => false, :limit => 100
t.integer :invitable_id, :null => false
t.string :invitable_type
t.timestamps
end
end
def self.down
drop_table :non_site_users
e... |
class Payrolls::AfpsController < ApplicationController
before_filter :authenticate_user!, :only => [:index, :new, :create, :edit, :update ]
protect_from_forgery with: :null_session, :only => [:destroy, :delete]
def index
@afp = Afp.where("status = 1")
render layout: false
end
def show
@afp = Afp.... |
class PublicKeysController < ApplicationController
def index
render plain: current_application.current_jwk.private_key.public_key.to_pem
end
end
|
require 'active_record'
module AppConfig
extend AppConfig::Processor
FORMATS = ['string', 'array', 'hash', 'boolean'].freeze
RESTRICTED_KEYS = [
'id',
'to_s',
'configure',
'load',
'flush',
'reload',
'keys',
'empty?',
'method_missing',
'exist?',
'source_model',
'co... |
require 'minitest/autorun'
require 'minitest/pride'
require "rack/test"
require_relative 'app'
class TestThing < Minitest::Test
include Rack::Test::Methods
def app
App
end
def test_show_picksum
get "/picksum"
p last_response
assert last_response.ok?
assert_equal "Do you feel lucky, punk?... |
require_relative 'movie'
describe Movie do
before do
@initial_rank = 10
@movie = Movie.new("goonies", @initial_rank)
end
it "has a capitalized title" do
@movie.title.should == "Goonies"
end
it "has the correct rank" do
@movie.rank.should == 10
end
it "has a string representation" do
@movie.to_s.shou... |
class OrderSerializer
include JSONAPI::Serializer
attributes :reference, :purchase_channel, :client_name, :address,
:delivery_service, :line_items, :total_value_cents, :status
belongs_to :batch
end
|
#TODO: Get umode command to actually work
class UmodeCommand
def initialize(unit, options = {})
@unit = unit
end
def help
"/#{command_and_aliases} <modes> - Not functioning correctly"
end
def command_and_aliases
c = "/#{command}"
a = aliases.collect {|a| "/#{a}" }
[c, a].join(' |... |
class Cart < ActiveRecord::Base
has_many :cart_items
has_many :items, through: :cart_items
end
|
class DropColumns < ActiveRecord::Migration
def change
remove_column :notes, :image_file_name
remove_column :notes, :image_content_type
remove_column :notes, :image_file_size
remove_column :notes, :image_updated_at
remove_column :users, :avatar_file_name
remove_column :users, :avatar_content_t... |
# Read about factories at http://github.com/thoughtbot/factory_girl
Factory.define :received_message do |f|
f.association(:private_message)
f.recipient { |p| p.association(:user) }
f.read_at nil
end
|
class Requests::StoreBalance < ActiveRecord::Base
validates :actual_credit_amount, presence: true, numericality: true
validates :hold_credit_amount, presence: true, numericality: true
validates :credit_amount, presence: true, numericality: true
validate :reject_new_store_balance
validate :actual_credit_plus_hold_... |
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby "2.7.1"
gem "bootsnap", ">= 1.4.2", require: false
gem "devise"
gem "jbuilder", "~> 2.5"
gem "pg", ">= 0.18", "< 2.0"
gem "puma", "~> 3.11"
gem "rails", "~> 6.0.0"
gem "sass-rails", "~> 5"... |
require_relative 'lib/mlp'
require 'woof'
require 'pry'
require 'csv'
def make_to_input_and_output_arrays(arff_file)
output_length = arff_file.get_class_values.length
arff_file.data.map do |data_instance|
# class_attribute = data_instance.fetch("class")
class_attribute = data_instance.fetch(arff_file.class... |
class TaskAmazonMapping < ActiveRecord::Base
belongs_to :task
belongs_to :amazon
belongs_to :deployment_task_mapping
end
|
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
require_relative '../lib/kmeans-clusterer'
require_relative './utils/mnist_loader'
require 'narray'
require 'optparse'
require 'pca'
k = 10
train_size = 5000
test_size = 200
runs = 1 # not much seems to be gained by multiple runs for this example
skip_plo... |
class Plane < ApplicationRecord
has_many :intineraries, class_name: "FlightItinerary"
has_many :flights, through: :intineraries
belongs_to :airline, class_name: "Airline", foreign_key: "airline_id"
end
|
module Boxzooka
class InventoryListResponseItem < BaseElement
# Total product quantity currently in warehouse.
scalar :quantity,
type: :integer
# Product quantity that is immediately ready to ship.
scalar :quantity_ready,
type: :integer
# Product quantity allocated to existing, unshi... |
# Final Project: A Text Adventure Game
# Date: 05-May-2016
# Authors: A01020319 Fernando Gomez Herrera
# A01371743 Luis Eduardo Ballinas Aguilar
#The ExploringState class, allows to the user: fight with a monster
#see your currents status, use magic, consume food, valid movements
#pick up treasures and so on
... |
class BaseWorker
include Sidekiq::Worker
extend StatsD::Instrument
sidekiq_options queue: Rails.configuration.app['sidekiq']['queues'].first, retry: true, backtrace: 10
# The child class' perform method should return false or nil (or raise an exception)
# if the job failed, and anything else if it passed
... |
class AttachmentsController < ApplicationController
def create
@attachment = Attachment.new attachment_params
@attachment.user_id = current_user.id
if @attachment.save
flash[:notice] = "Success"
else
flash[:error] = "Failed: PDFS only"
end
redirect_to :back
end
private
def a... |
module SurveyBuilder
class SurveyResponse < ActiveRecord::Base
belongs_to :survey_form
belongs_to :user
has_many :answers
accepts_nested_attributes_for :answers
end
end
|
require_relative "commands/base"
require_relative "commands/match"
require_relative "commands/group"
require_relative "commands/sort"
require_relative "commands/project"
require_relative "commands/limit"
require_relative "commands/or"
require_relative "commands/unwind"
module Mongoid
module Contextual
module Agg... |
class Admin::BroFulfillmentsController < Admin::AdminController
before_action :set_bro_order
before_action :set_fulfillment, only: [:transition_workflow, :invoice, :edit, :update]
def transition_workflow
@fulfillment.send("#{params[:event]}!") if params[:event]
end
def invoice
@bro_order = @f... |
FactoryGirl.define do
factory :user do
email {Faker::Internet.email}
first_name {Faker::Name.first_name}
last_name {Faker::Name.last_name}
phone {Faker::PhoneNumber.phone_number}
password '1'*8
password_confirmation '1'*8
organization
end
end
|
=begin
Ruby Case Statement
SYNTAX:
case exp0 #exp0 is variable name (constant name)
when exp1, exp2 #when exp0 is equal to exp1 OR exp2 then execute statement1
statement1
when exp3, exp4 #when exp0 is equal to exp3 OR exp4 then execute statement2
statement2
else
statement3
end
=e... |
# frozen_string_literal: true
# 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:... |
class DecksController < ApplicationController
before_action :find_deck, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user! # protects new deck route from unauthenticated
# access.
def index
@decks = Deck.all.order(... |
# U2.W5: Build a simple guessing game SOLO CHALLENGE
# I worked on this challenge by myself.
# 2. Pseudocode
=begin
# Input: An initialized class, GuessingGame, taking a positive integer as an argument
# Output: A guess method which outputs a symbol (:high, :low, or :correct)
A solved method which outputs a ... |
class Family < ActiveRecord::Base
belongs_to :church
belongs_to :eligibility_status
has_many :members, foreign_key: 'mem_iFamilyID', dependent: :destroy
self.table_name = "family"
self.primary_key = "fam_iFamilyID"
end |
# frozen_string_literal: true
module ActionController
class ActionControllerError < StandardError #:nodoc:
end
class BadRequest < ActionControllerError #:nodoc:
def initialize(msg = nil)
super(msg)
set_backtrace $!.backtrace if $!
end
end
class RenderError < ActionControllerError #:nodo... |
class ChangeColumnToUrls < ActiveRecord::Migration[5.2]
def up
change_column :urls, :content_name, :string, null: false, limit: 128
change_column :urls, :alias, :string, null: false, limit: 16
change_column :urls, :url, :text, null: false, limit: 1000
end
def down
change_column :urls, :content_na... |
module Gemojione
class Index
attr_reader :all
def initialize(emoji_list=nil)
emoji_list ||= begin
emoji_json = File.read(File.absolute_path(File.dirname(__FILE__) + '/../../config/index.json'))
JSON.parse(emoji_json)
end
@emoji_by_name = {}
@emoji_by_moji = {}
@... |
require "csv"
class LDAP
HEADERS = [:cn, :sn, :mail, :uid, :homeDirectory, :uidNumber, :gidNumber]
attr_accessor :root, :options, :results
def initialize(root, options)
@root = root
@options = options
@results = []
end
def self.search(root, options)
ldap = new(root, options)
ldap.handl... |
Rails.application.routes.draw do
# user dashboard
get '/' => 'users#home'
get '/users' => 'users#index'
get '/users/:id/' => 'users#show'
get '/authorize' => 'users#authorize'
# quest routes
get '/inbox/pending' => 'quests#in_pending'
get '/inbox/active' => 'quests#in_active'
get '/inbox/complete' =... |
class CoachesController < UsersController
before_action :authenticate_user!
after_action :verify_authorized
def index
end
def show
end
def create
authorize Coach
@coach = Coach.new(secure_params)
@coach.update_attribute(:user_id, params[:coach][:user_id])
@coach.save
... |
require 'spec_helper'
describe 'infiniband::calc_log_num_mtt' do
it 'returns 23' do
is_expected.to run.with_params(135_303_601_848.32).and_return(23)
end
it 'returns 22' do
is_expected.to run.with_params(67_528_032_256.00).and_return(22)
end
it 'returns 25' do
is_expected.to run.with_params(135... |
# frozen_string_literal: true
require 'stannum/constraints/properties/match_property'
require 'support/examples/constraint_examples'
RSpec.describe Stannum::Constraints::Properties::MatchProperty do
include Spec::Support::Examples::ConstraintExamples
subject(:constraint) do
described_class.new(reference_nam... |
class ConditionIsFoil < ConditionSimple
def match?(card)
["foilonly", "both"].include?(card.foiling)
end
def to_s
"is:foil"
end
end
|
class Connection < ActiveRecord::Base
belongs_to :receiver, class_name: "User", foreign_key: :receiver_id
belongs_to :sender, class_name: "User", foreign_key: :sender_id
# Returns the receiver in case +user+ is the sender
# returns the sender if +user+ is the receiver
# nil otherwise
def not_this_guy(user... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.