text stringlengths 10 2.61M |
|---|
Rails.application.routes.draw do
devise_for :users
resources :users, only: %i[index edit show update]
resources :courses
root 'home#index'
get 'privacy_policy', to: 'home#privacy_policy'
end
|
module RiakRest
# JiakDataFields provides a easy-to-create JiakData implementation.
#
# ===Usage
# <code>
# Dog = JiakDataFields.create(:name,:weight)
#
# addie = Dog.new(:name => "Adelaide", :weight => 45)
# addie.name # => "Adeliade"
# addie.weight ... |
class Vecmath < Formula
desc "Collection of vectorized based math utilities based on VecCore library"
homepage "https://github.com/root-project/vecmath"
url "https://github.com/root-project/vecmath/archive/v0.1.0.tar.gz"
version "0.1.0"
revision 1
depends_on "cmake" => :build
depends_on "vc"
depends_on... |
# typed: strict
class Comment < ApplicationRecord
searchkick
acts_as_tree
belongs_to :banal_brainstorm, class_name: 'Banal::Brainstorm', foreign_key: 'banal_brainstorm_id'
end
|
class LocationSerializer
include FastJsonapi::ObjectSerializer
attributes :city, :state, :country
has_many :concerts
end
|
require 'spec_helper'
require 'generators/forem/install_generator'
describe Forem::Generators::InstallGenerator do
before { cleanup! }
after { cleanup! }
# So we can know whether to backup or restore in cleanup!
# Wish RSpec had a setting for this already
before { flag_example! }
def flag_example!
exa... |
require 'spec_helper'
describe Message do
it { should have_many :team_messages}
it { should have_many(:teams).through(:team_messages) }
it { should have_and_belong_to_many :users }
end
|
require_relative './cfhighlander.compiler'
require 'aws-sdk-s3'
module Cfhighlander
module Publisher
class ComponentPublisher
def initialize(component, cleanup, template_format)
@component = component
@cleanup_destination = cleanup
@template_format = template_format
end
... |
# frozen_string_literal: true
require 'fileutils'
module AutomaticUpdate
class Run
OUTPUT_PATH = Rails.root.join('tmp/automatic_update/ReadyForImport.csv')
attr_reader :log_timestamp, :import_log_id
def initialize
@file_headers = []
@downloads = {}
end
def update(_download: true, ... |
class Follower
attr_accessor :name, :age, :life_motto
@@all = []
def initialize(name, age, life_motto)
@name = name
@age = age
@life_motto = life_motto
@@all << self
end
def self.all
@@all
end
def cults
oaths = BloodOath.all.select { |oath| ... |
class JsonWebToken
SECRET_KEY = Rails.application.secrets.secret_key_base.to_s ;
def self.encode(payload, exp= 24.hours.from_now)
payload[:exp]= exp.to_i
JWT.encode(payload,SECRET_KEY)
end
def self.decode token
decoded= JWT.decode(token,SECRET_KEY)[0]
HashWithIndifferen... |
class PackageOrderAttachment
# require 'RMagick'
include Mongoid::Document
include Mongoid::Timestamps
store_in database: 'sribulancer_development', collection: 'package_order_attachments'
MAXIMUM_IN_PACKAGE_ORDER_APPLICATION = 15
field :image
field :name
field :package_order_attachment_group_id
... |
class AddColorToCategory < ActiveRecord::Migration[5.0]
def change
add_column :categories, :color, :string, null: true
end
end
|
# frozen_string_literal: true
# Helper for accessing environmented S3 buckets and CloudFront links
module BPS
class S3
VALID_BUCKETS = %i[files photos bilge static seo floatplans automatic_updates].freeze
GLOBAL_BUCKETS = %i[seo automatic_updates].freeze
attr_reader :bucket
def initialize(bucket)
... |
class PhrasesController < ApplicationController
def index
if session[:phrase_ids]
@phrases = Phrase.find(session[:phrase_ids]) rescue [Phrase.random].compact
else
@phrases = [Phrase.random].compact
end
@dataexclude = @phrases.map(&:id).join(',')
@total_phrases = Phrase.remaini... |
class Channel < ActiveRecord::Base
belongs_to :user
before_destroy :remove_channel_from_nuntium
def remove_channel_from_nuntium
Nuntium.new_from_config.delete_channel name
end
end
|
require_relative '../helpers/palindromes'
class OEIS
A060875_SEQUENCE = IntrinsicKPalindromes.new(5, 1000).all
def self.a060875(n)
raise "A060875 is not defined for n = #{n} < 1" if n < 1
A060875_SEQUENCE[n - 1]
end
end
|
require "json"
require "yaml"
module Eshealth
class ClusterFS < Checkfactory
attr_accessor :url, :configbody, :type, :lastmsg, :percentage
attr_reader :requestfactory
def initialize(options={})
self.type = "ClusterFS"
self.url = options[:url] || "http://localhost:9200"
self.reques... |
#==============================================================================
# Relocated Pause Graphic
# by: Racheal
# Created: 11/11/2013
# Editted: 19/02/2015
#==============================================================================
# Replicates the pause graphic in Window_Message to allow for repositioning
... |
class Artist
attr_accessor :name
attr_reader :songs
@@song_count = 0
@@artists = []
def initialize(name)
@name = name
@songs = []
@@artists << self
end
def add_song(song)
@songs << song
song.artist = self
end
def add_song_by_name(song_name)
song = Song.new(song_name)
@songs << song
song.artist = sel... |
require 'test_helper'
class CreateCategoryTest < ActionDispatch::IntegrationTest
def setup
@category = categories(:one)
@user = users(:one)
@sample_keys = {user_id: @user.id, id: @category.id}
end
test '01: Create a new category' do
get new_user_category_path(@user.id)
... |
module CDI
module V1
class SurveyOpenQuestionSerializer < SimpleSurveyOpenQuestionSerializer
has_one :user, serializer: SimpleUserSerializer
has_many :questions, serializer: SurveyQuestionAnsweredSerializer
has_one :visibility, serializer: SimpleVisibilitySerializer
def visibility
... |
class CreateExercises < ActiveRecord::Migration
def change
create_table :exercises do |t|
t.integer :template_id
t.integer :work_group_id
t.integer :sentence_length
t.string :sentence_difficulty
t.string :sentence_source
t.timestamps
end
add_index :exercises, :templa... |
file = 'image_names.txt'
sanitized = 'sanitized_names.txt'
f = File.open(file, "r")
s = File.open(sanitized, 'w')
def sanitize(name)
name.gsub(/,jpg$/i, '')
name.gsub(/,png$/i, '')
name.gsub(/\(\d{1,3}\)/, '')
name.gsub(/[^0-9A-Z -]/i, '_')
name.strip
end
def get_token(name)
end_token = name.split.last.to... |
require 'spec_helper'
describe 'vault' do
context 'with defaults for all parameters' do
it { should compile.with_all_deps }
let(:facts) {
{
osfamily: 'Debian',
operatingsystem: 'Debian',
lsbdistcodename: 'wheezy',
manage_user: true,
}
}
... |
class AddLocationToEmployees < ActiveRecord::Migration
def change
add_column :employees, :street_address, :string
add_column :employees, :latitude, :float
add_column :employees, :longitude,:float
end
end
|
class RemoveCardidFromColors < ActiveRecord::Migration[5.1]
def change
remove_column :colors, :card_id
end
end
|
require 'rails_helper'
RSpec.describe Match, type: :model do
it 'is valid with required attributes' do
expect(build :match).to be_valid
end
it 'requires home team' do
expect(build :match, home_team: nil).not_to be_valid
end
it 'requires guest team' do
expect(build :match, guest_team: nil).not_t... |
class CreateFriendships < ActiveRecord::Migration
def change
create_table :friendships, id: false do |t|
t.integer :source_friend_id
t.integer :target_friend_id
t.boolean :accepted, default: false
t.timestamps null: false
end
add_index :friendships, :source_friend_id
add_index... |
require 'pry'
require 'time'
require 'date'
module Hotel
class Reservation
attr_reader :id, :room, :date_range
RATE_PER_NIGHT = 200
def initialize(input)
@id = input[:id]
@room = input[:room]
@date_range = DateRange.new(input[:start_date], input[:end_date])
end
def total_c... |
require 'spec_helper'
describe Fn::Salesforce::ObjectFactory do
describe ".new" do
subject { described_class.new(schema).schema }
context 'with a schema' do
let(:schema) { {} }
it "returns factory instance with the schema attached" do
expect(subject).to eql schema
end
end
... |
module FellowshipOneAPI # :nodoc:
module OAuth
# Implements the pure OAuth method of authentication. This allows the Fellowship One API to
# manage the authentication process.
module OAuthAuthentication
include OAuth
# The OAuth request object
attr_reader :oauth_request
# The OA... |
base = File.expand_path(File.dirname(__FILE__) + '/../lib')
require base + '/data_cleaner'
require 'test/unit'
TopSecret = Struct.new(:name, :email, :reference, :secret, :date)
class CleanerTest < Test::Unit::TestCase
def setup
@secret = TopSecret.new("Arthur Dent", "arthur@milliways.com", "H2G2", 42, Date.n... |
require 'sysflow/version'
require 'sysflow/system_connector'
module Sysflow
# Preparing the usage of Sysflow actions in Dynflow. If reloading
# is set to true and Dyntask (or other compatible module) is present
# in the system, it adds the actions path to the eager_load_paths (so that
# the actions are being ... |
module ApplicationHelper
# Public: Get a string that can be embedded in an html file to add the css
# styling used to show cropped pic images
#
# Examples
#
# <%= picCropCss %>
# <div class="faceWrapper">
# <img src="<%= @pic.url %>" class="faceImg">
# </div>
# <!-- Shows just the face... |
require 'rails_helper'
RSpec.describe API::EventsController, type: :controller do
let(:user){ create(:user) }
let(:registered_application){ create(:registered_application, url: "test.com", user: user)}
let!(:event){ registered_application.events.create(name: "test events")}
context "URL corresponds to a regi... |
RSpec.shared_context 'with dynamodb table' do |table_name, opts|
before(:all) do
create_table(table_name, opts)
end
after(:all) do
drop_table(table_name)
end
before(:each) do
truncate_table(table_name, opts)
end
end
|
module ManagementConsultancy
class Upload < ApplicationRecord
def self.upload!(suppliers)
error = all_or_none(Supplier) do
Supplier.delete_all_with_dependents
suppliers.map do |supplier_data|
create_supplier!(supplier_data)
end
create!
end
raise error i... |
class Student < ApplicationRecord
validates :first_name, :last_name, :grade, presence: true
before_validation :make_title_case
has_many :schedules
has_many :classrooms, through: :schedules
has_many :users, through: :classrooms
scope :elementary_school, -> { where(grade: [1,2,3,4,5]) }
scope :middle_school, -... |
class Album < ActiveRecord::Base
ALBUM_TYPES = ["Live", "Studio"]
validates :name, :album_type, :band, presence: true
validates :album_type, inclusion: {in: ALBUM_TYPES}
belongs_to :band
has_many :tracks,
dependent: :destroy
def self.album_types
ALBUM_TYPES
end
end
|
#
# Specifying rufus-tokyo
#
# Sun Feb 8 14:15:31 JST 2009
#
require File.dirname(__FILE__) + '/spec_base'
require 'rufus/tokyo/hmethods'
class MyHash
include Rufus::Tokyo::HashMethods
def initialize
super
@default_proc = nil
end
def get (k)
k.to_i % 2 == 0 ? k : nil
end
end
describe 'an ... |
class CleanUsernameValidator < ActiveModel::EachValidator
#https://gist.github.com/caseyohara/1453705
RESERVED_USERNAMES = [
'stacks', 'imulus', 'github', 'twitter', 'facebook', 'google', 'apple', 'about', 'account',
'activate', 'add', 'admin', 'administrator', 'api', 'app', 'apps', 'archive', 'archives'... |
# One night you go for a ride on your motorcycle. At 00:00 you start your engine, and the built-in timer automatically
# begins counting the length of your ride, in minutes.
# You don't have your watch on you and don't know what time it is. All you know thanks to the bike's timer is
# that n minutes have passed since 0... |
module Lolita
module Adapter
class ActiveRecord
include Lolita::Adapter::AbstractAdapter
attr_reader :dbi, :klass
def initialize(dbi)
@dbi=dbi
@klass=dbi.klass
end
# Association adapter
class Association
attr_reader :association, :adapter
def... |
class Unit < ActiveRecord::Base
validates :name, :presence => true, :uniqueness => {:scope => :user_id}
validates :user, :presence => true
belongs_to :user
has_many :resources
has_many :tools
end
|
Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
post "/auth/registration", to: "auth#registration"
post "/auth/login", to: "auth#login"
post "/auth/logout", to: "auth#logout"
get "/auth/auto_login", to: ... |
Rails.application.routes.draw do
scope 'api', defaults: { format: :json} do
resources :entries
end
root to: 'main#index'
get '*path', to: 'main#index'
end
|
class OrderStatus < ApplicationRecord
REGISTERED = 'CADASTRADO'
PREPARING = 'EM PREPARO'
READY = 'PRONTO'
DELIVERING = 'EM ENTREGA'
DELIVERED = 'ENTREGUE'
def self.all
options = []
options.push(REGISTERED)
options.push(PREPARING)
options.push(READY)
options.push(DELIVERING)
options... |
#create person class that is initialized
class Person
attr_accessor :bank_account, :happiness, :hygiene
attr_reader :name
#person should be able to remember their name
def initialize(name)
@name = name
@bank_account = 25
@happiness = 8
@hygiene = 8
end
def happiness=(new_happiness)
#happiness cannot exc... |
# Base framework
def addBundles(names)
names.each do |name|
addBundle(name)
end
end
def addBundle(name)
bundle = $bundles[name]
if bundle == nil
raise "Unknown bundle: " + name
end
$loader.addBundle(bundle)
end
require 'java'
addBundles(["org.eclipse.jface",
"org.eclipse.core.runt... |
#!/usr/bin/env ruby
require 'trollop'
require 'open3'
require 'set'
require 'fileutils'
$opts = Trollop::options do
opt :k, 'number of results to consider', default: 3
opt :diff, '% of difference between the k selected results', default: 0.05
opt :min, 'minimum number of executions... |
require 'singleton'
class Configuration
# Singletonモジュールのinclude
include Singleton
attr_accessor :base_url, :debug_mode
def initialize
# 設定の初期化
@base_url = ''
@debug_mode = false
end
end
# new不可
# config = Configuration.new # => Error
# インスタンスメソッドで参照
config = Configuration.instance
# 値の変更
co... |
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 _load_agency_from_url
if @agency
@agency_from_url = @agency
elsif params[:agency_id]
@agency_fr... |
require "rails_helper"
feature "contractor cannot have homes" do
let!(:contractor) { FactoryGirl.create(:contractor) }
scenario "contractor does not have 'Add a Home' link" do
visit root_path
click_link "Sign In"
fill_in "Email", with: contractor.email
fill_in "Password", with: contractor.password
... |
# coding: utf-8
namespace :sections do
desc "adds new section keys and defualt values."
task :addnewsections => :environment do
Section.create!([
{ key: 'research_page', content: '
<div class="program-box">
<div class="dropdown pull-right">
<button class="btn btn-defau... |
class Following < ActiveRecord::Base
attr_accessible :followed_user_id, :follower_user_id
belongs_to :followed_user
belongs_to :follower_user
end
|
# frozen_string_literal: true
require 'active_support/concern'
module Searchable
extend ActiveSupport::Concern
included do
class_attribute :searchable_columns
scope :search, ->(query) { where(search_query("%#{query}%")) }
end
class_methods do
def search_query(query)
columns = searchable_c... |
class User < ApplicationRecord
has_many :reports
has_many :votes
has_secure_password
end
|
task :default => :app
PATCH_DIR = File.join(File.dirname(__FILE__), "patches")
MAGLEV_HOME = ENV['MAGLEV_HOME']
desc "Do one-time install of gems and patch rails gems"
task :init => [:'bundler:gem', :'bundler:install', :'patch:activesupport']
desc "Run myapp, with maglev."
task :app do
cd('myapp') do
# MagLev ... |
#1
nil
#2
{:a=>"hi there"} #beacause << modifies the object informal_greetings is referring to.
#3
"two"
"three"
"one"
#4
def uuid
characters = []
(0..9).each { |digit| characters << digit.to_s }
('a'..'f').each { |digit| characters << digit }
uuid = ""
sections = [8, 4, 4, 4, 12]
sections.each do |s... |
require './producer.rb'
require './modules/validate.rb'
class Wagon
include Producer
include Validation
attr_reader :type
def self.set_validate
validate :producer_name, :presence
end
def initialize(producer_name, type)
self.producer_name = producer_name
self.type = type
validate!
end
... |
# frozen_string_literal: true
require "spec_helper"
describe GraphQL::Schema::AlwaysVisible do
class AlwaysVisibleSchema < GraphQL::Schema
class Query < GraphQL::Schema::Object
def self.visible?(ctx)
ctx[:visible_was_called] = true
false
end
field :one, Integer
def one; 1... |
# frozen_string_literal: true
module Main
module Actions
module Articles
class Drafts < Main::Action
include Deps[
repo: 'application.persistence.repositories.articles'
]
def handle(_req, res)
res.render view, articles: repo.drafts
end
end
end
... |
class Seat < ActiveRecord::Base
attr_accessible :seat_no, :category
belongs_to :auditorium
def price_for(show)
show.send(category)
end
def booked_for?(show)
# Booking.find_by_seat_id_and_show_id(id, show.id) ? true : false
Booking.exists?(:seat_id => id, :show_id => show.id)
end
def info
"... |
module Api
module V1
class LocationsController < ApplicationController
def index
lat = params[:lat]
long = params[:lng]
@client = GooglePlaces::Client.new(ENV['GOOGLE_SDK_API_KEY'])
type = 'gas_station'
results = @client.spots(lat,long, :types => [type])
@l... |
require "rails_helper"
feature "View list of the Words" do
given!(:user) { create :user_example_com }
background do
juice = create :word, user: user, content: "Saft"
water = create :word, user: user, content: "Wasser"
cheese = create :word, user: user, content: "Käse"
bread = create :word, conten... |
class Api::V1::NoteSerializer < Api::V1::BaseSerializer
attributes :id, :title, :content, :user, :created_at, :updated_at
def created_at
object.created_at.in_time_zone.iso8601 if object.created_at
end
def updated_at
object.updated_at.in_time_zone.iso8601 if object.created_at
end
end |
class Nettle < Package
desc "A low-level cryptographic library"
homepage "https://www.lysator.liu.se/~nisse/nettle/"
url "https://ftp.gnu.org/gnu/nettle/nettle-${version}.tar.gz"
release version: '3.4', crystax_version: 1
depends_on 'openssl'
depends_on 'gmp'
build_options use_cxx: true
build_copy '... |
require File.expand_path("../lib/friendly_id/version", __FILE__)
Gem::Specification.new do |s|
s.authors = ["Norman Clarke", "Adrian Mugnolo", "Emilio Tagua"]
s.description = <<-EOM
FriendlyId is the "Swiss Army bulldozer" of slugging and permalink plugins
for Ruby on Rails. It allows you t... |
array = []
100_000_000.times do |i|
array << i
end
ram = Integer(`ps -o rss= -p #{Process.pid}`) * 0.001
puts "Process: #{Process.pid}: #{ram} mb"
Process.fork do
ram = Integer(`ps -o rss= -p #{Process.pid}`) * 0.001
puts "Process: #{Process.pid}: #{ram} mb"
end
# Process: 99526: 788.584 mb
# Process: 99530: 1... |
class User < ApplicationRecord
validates :name, presence: true
validate :set_email
has_many :items
before_save :user_save
after_destroy :delete_item
def set_email
u = User.all
u.each do |i|
if i.email.any?
errors.add(:email, "El email no debe existir")
end
end
end
def user_save
a = s... |
class UsersController < ApplicationController
before_filter :authenticate, :except => [:show, :new, :create]
before_filter :authorize_user, :only => [:edit, :update]
before_filter :admin_user_only, :only => :destroy
def index
#show all users
@title = "All users"
# @all_users = User.all #w... |
class EpisodesController < ApplicationController
before_action :authenticate_user!
before_action :set_episode, only: [:show, :edit, :beats, :update, :destroy]
# GET /episodes
# GET /episodes.json
def index
@episodes = Episode.all
respond_to do |format|
format.html
format.json {
r... |
class AddPacketIdToReply < ActiveRecord::Migration
def change
add_column :replies, :packet_id, :integer
end
end
|
shared_examples_for 'Apache2' do |distro, version|
it 'includes apache2 required recipes' do
expect(chef_run).to include_recipe('apache2::default')
expect(chef_run).to include_recipe('apache2::mod_actions')
unless distro == 'ubuntu' && version == '14.04'
expect(chef_run).to include_recipe('apache2::... |
class MakeTagColorsJsons < ActiveRecord::Migration[5.2]
def change
remove_column :tags, :color, :string
remove_column :tags, :background_color, :string
add_column :tags, :color, :jsonb, default: {}
add_column :tags, :background_color, :jsonb, default: {}
end
end
|
# encoding: UTF-8
module Knapsack
class Platform
RE_X86 = /i\d86/
RE_X64 = /(x86_|amd)64/
RE_MINGW = /mingw32$/
RE_DARWIN = /darwin/
RE_LINUX = /linux(-gnu)?$/
attr_reader :target, :host
def initialize(target, host = nil)
@target = target
@host = host
end
de... |
Facter.add("rpm_version_httpd") do
setcode do
Facter::Util::Resolution.exec("/bin/rpm -q httpd")
end
end
|
class TemplatesController < ApplicationController
# after_action :verify_authorized, except: [:show]
before_action :set_template, only: [:show, :edit, :update, :destroy, :preview]
# before_update :upload_image
# GET /templates
# GET /templates.json
def index
@templates = Template.all
authorize... |
class User < ApplicationRecord
has_paper_trail
CAN_ORDER_DEVICES_LIMIT = 3
enum role: {
no: 'no',
third_line: 'third_line',
}, _suffix: true
has_many :extra_mobile_data_requests, foreign_key: :created_by_user_id, inverse_of: :created_by_user
has_many :api_tokens, dependent: :destroy
has_many :s... |
module SkeletorApi
class Client
def initialize(api_key: nil)
if api_key
SkeletorApi.config.api_key = api_key
end
end
def get_skeleton(slug)
self.get "/skeletons/#{slug}"
end
protected
def connection
@conn ||= Faraday.new(url: BASE_URL) do |conn|
conn.r... |
#require_relative '../DataEntry'
#require_relative '../SystemStrings'
require_relative 'SetCommand'
class AppendCommand < SetCommand
@command_name = 'append'
@class_name = 'AppendCommand'
@parameters = 4 #minimum parameters needed
def initialize(communicator, target_hash, value, key, flag, ttl, bytes)
@co... |
# frozen_string_literal: true
require 'jiji/configurations/mongoid_configuration'
require 'jiji/model/trading/back_test'
module Jiji::Messaging
class Device
include Mongoid::Document
include Jiji::Utils::ValueObject
include Jiji::Web::Transport::Transportable
store_in collection: 'devices'
fi... |
FactoryGirl.define do
factory :user do
first_name 'John'
last_name 'Smith'
email 'example@example.com'
password 'changeme'
role 'customer'
end
end
|
class AddressSearchController < ApplicationController
def index
search_results = ["No Results Found"]
if params["search_value"].present?
search_results = get_parsed_results
end
render json: search_results
end
private
def get_parsed_results
Geocoder.search(params["search_value"]).map ... |
module Company
class Profile
attr_accessor :first_name, :last_name, :handle, :title, :bio, :primary_email, :primary_phone
def initialize(first_name, last_name, handle, title, bio, primary_email, primary_phone)
@id = nil
@first_name, @last_name, @handle, @title, @bio, @primary_email, @primary_phon... |
class ModalboxHelperGenerator < Rails::Generators::Base #:nodoc:
source_root File.expand_path('../templates', __FILE__)
desc "Creates helper resources in relevant public destinations."
def create_resources
copy_file 'spinner.gif', 'public/images/spinner.gif'
create_file 'public/stylesheets/modalbox_helpe... |
class SeminarsController < ApplicationController
def index
@seminars = Seminar.page(params[:page])
end
end
|
class CheckPointsController < InheritedResources::Base
before_filter :authenticate_user!
before_filter :authenticate_owner, :only => [:edit, :update, :destroy]
# GET /check_points
# GET /check_points.json
def index
@title += " | #{t('activerecord.models.check_point')}"
if params[:check_point]
@... |
require 'rails_helper'
RSpec.feature "Stars index" do
attr_reader :current_user
before(:each) do
@current_user = User.create(uid: "17166293", username: "edilenedacruz", avatar: "https://avatars1.githubusercontent.com/u/17166293?v=3", token: ENV['TOKEN'])
allow_any_instance_of(ApplicationController).to rec... |
# encoding: UTF-8
# Add to rtesseract a image manipulation with MiniMagick
module MiniMagickProcessor
def self.setup
require 'mini_magick'
end
def self.a_name?(name)
%w(mini_magick MiniMagickProcessor).include?(name.to_s)
end
def self.image_to_tif(source, x = nil, y = nil, w = nil, h = nil)
tmp_... |
class AddRegionToShows < ActiveRecord::Migration
def change
add_column :shows, :region, :string, default: 'canada'
end
end
|
class DeleteRegisteredUserCountToTournamentMemberships < ActiveRecord::Migration[6.1]
def change
remove_column :tournaments, :registered_user_count
end
end
|
desc "Get IMDB info"
task :get_info => :environment do
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'json'
programs = Program.all
programs.each_with_index do |program, i|
title = program.title.to_s.gsub("\"", "")
url = "http://www.omdbapi.com/?t=#{URI::encode(title)}"
json = JSON.parse(... |
class RenameLongColumnPoints < ActiveRecord::Migration
def change
rename_column :points, :long, :lng
end
end
|
require './lib/deck'
describe Deck, type: :model do
let(:deck) { Deck.new }
context '#new' do
it 'should be a type of Deck' do
expect(deck).to be_a_kind_of(Deck)
end
end
context '#card_count' do
subject(:card_count) { deck.card_count }
it 'should start with 108 cards in the deck' do
... |
require 'pry'
def find_item_by_name_in_collection(name, collection)
collection.find{ |item| item[:item] == name }
end
def consolidate_cart(cart)
new_cart = []
cart.each do |item|
item_name = item[:item]
found_item = find_item_by_name_in_collection(item_name, new_cart)
if found_item
found_it... |
#
# This module holds utility methods used by vm_to_cluster.rb and Vagrantfile
# NOTE: Testing should be done with ChefDK and Vagrant rubys
#
# Most of the methods use VirtualBox or are run on the VirtualBox hypervisor
#
require 'json'
# pry is not required but nice to have
begin
require 'pry'
rescue LoadError
end
... |
class AddShowOnCv < ActiveRecord::Migration[5.1]
def change
add_column :projects, :cv_active, :boolean, default: false, null: false
end
end
|
class User < ActiveRecord::Base
mount_uploader :profile_picture, PictureUploader
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
ha... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.