text stringlengths 10 2.61M |
|---|
class MemeController < ApplicationController
before_action :authenticate_user!
def index
@memes = Meme.all
@meme = Meme.new
@search = Search.new(params[:search])
@memes = @search.search
if params[:search]
@category = search_params[:category]
@categories = Meme.where(category: @ca... |
Rails.application.routes.draw do
namespace :file_upload_cache do
resources :cached_files, :only => :show
end
end
|
class AddCreatedByUserToSignatures < ActiveRecord::Migration[5.0]
def change
add_column :agreements, :created_by_user_id, :uuid
end
end
|
namespace :set do
# Run with rake set:super_user["dlee"]
desc "Grants user super_user and administrator rights"
task :super_user, [:login] => :environment do |t,args|
user = User.find_by_login(args.login)
Permission.create(role: Role.find_by_name('super user'), user: user)
Permission.create(role: ... |
Rails.application.routes.draw do
devise_for :users
resource :users
root :to => 'visitors#index'
end
|
class AddCurrencyToBalances < ActiveRecord::Migration[6.0]
def change
add_column :balances, :currency, :text, null: false, default: "MXN"
remove_index :balances, [:date, :account_id]
add_index :balances, [:date, :account_id, :currency], unique: true, name: "one_currency_balance_per_day"
end
end
|
class MomentumCms::Template < ActiveRecord::Base
# == MomentumCms ==========================================================
include MomentumCms::BelongsToSite
include MomentumCms::ActAsPermanentRecord
self.table_name = 'momentum_cms_templates'
# == Constants =============================================... |
require 'nokogiri'
require 'open-uri'
namespace :carriers do
task :load => :environment do
desc "Carriers loading into DB"
Carrier.delete_all
doc = Nokogiri::HTML(open('http://avrefdesk.com/two_letter_airline_codes.htm'))
items = doc.xpath('//table/tr[@height=17]')
objects = []
items.each do |i... |
# frozen_string_literal: true
module GraphQL
class Schema
class Directive < GraphQL::Schema::Member
class Deprecated < GraphQL::Schema::Directive
description "Marks an element of a GraphQL schema as no longer supported."
locations(GraphQL::Schema::Directive::FIELD_DEFINITION, GraphQL::Schema... |
require 'test_helper'
class QuastionsControllerTest < ActionController::TestCase
setup do
@quastion = quastions(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:quastions)
end
test "should get new" do
get :new
assert_response :success
... |
# /Users/rasheqrahman/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
# load relevant gems
require 'rubygems'
require 'linkedin'
require 'markaby'
require 'pdfkit'
require 'yajl'
require 'eventbrite-client'
require 'yaml'
# load config variables from config.yml. Helps keep the code tidy!
APP_CONFIG = YAML.load_file("config.ym... |
module Refinery
module Testimonials
module Admin
class TestimonialsController < ::Refinery::AdminController
crudify :'refinery/testimonials/testimonial',
title_attribute: :flash_name,
:xhr_paging => false,
:paging => false,
:order => "... |
module Api
module V2
class RatesController < ApplicationController
skip_before_action :verify_authenticity_token, raise: false # TODO: Replace with verify_API_key
def create
if Rate.valid_params?(api_params)
ratable = api_params[:ratable_type] == 'Chain' ? Chain.find_by(id: api_p... |
module ApplicationHelper
def error_notices(error_resource)
error_resource.errors.each do |error|
"<li>#{error}</li>"
end
end
def current_user_is_authorized_to_delete(resource)
logged_in? && current_user.id == resource.user_id
end
def current_user? (user)
logged_in? && current_user == ... |
class Card
include Comparable
attr_reader :suit, :value
def initialize(value, suit)
@value = value
@suit = suit
end
def <=>(other)
value_comp = self.value <=> other.value
value_comp == 0 ? self.suit <=> other.suit : value_comp
end
def to_s
"#{Value.to_s(@value)} of #{Suit.to_s(@sui... |
class AddCourtDateToClient < ActiveRecord::Migration[5.1]
def change
add_column :clients, :next_court_date_at, :date, null: true
end
end
|
Given(/^I am a guest$/) do
end
When(/^I visit application homepage$/) do
visit home_path
end
Then(/^I should see the homepage layout$/) do
expect(page).to have_title("Happy New Year!")
expect(page).to have_selector("nav")
expect(page).to have_selector("header")
end
|
require 'redis'
require 'ohm'
module ConnectionHelpers
module Redis
extend self
def build_connection
@conncetion ||= ::Redis.new ConnectionHelpers.config_of('redis')
end
def build_ohm_connection
if @ohm_connection.nil?
::Ohm.connect :url => url
@ohm_connection = ::Ohm.re... |
=begin
Insights Service Approval APIs
APIs to query approval service
OpenAPI spec version: 1.0.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
=end
class Template < ApplicationRecord
acts_as_tenant(:tenant, :has_global_records => true)
has_many :workflows
validates :title, :presence => ... |
class RemoveWinPercentageFromUsers < ActiveRecord::Migration
def change
remove_column :users, :win_percentage
end
end
|
FactoryGirl.define do
factory :group, class: "Group" do
name "Thaiband 🇹🇭"
project "Create a catchy music video"
submission "https://www.youtube.com/watch?v=y6120QOlsfU"
score "100"
end
factory :group2, class: "Group" do
name "ภาพยนตร์ที่ฉันรู้"
project "Se... |
class AddSchoolIdToFeeInvoice < ActiveRecord::Migration
# adding school id to add db uniquess
def self.up
add_column :fee_invoices, :school_id, :integer
end
def self.down
remove_column :fee_invoices, :school_id
end
end
|
#
# Cookbook Name:: devpi
# Provider:: devpi_nginx_site
#
# Copyright 2013-2015, Dave Shawley
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.... |
require 'rails_helper'
RSpec.describe Store, type: :model do
let(:populated_store) { described_class.new(uuid: '32db7ef9-1144-464e-b561-9c8880b41d28', hash_store: { hash_key: :key_value }) }
it "stores a SecureRandom.uuid" do
store = described_class.new(uuid: '8002e436-dc3a-452e-a4fd-9ba466c737b1')
expe... |
class Image < ActiveRecord::Base
has_many :image_comments
has_many :comments, dependent: :destroy
has_many :favorites, dependent: :destroy
has_many :users, through: :favorites
validates :url, uniqueness: true
def self.search term
images = Image.where("keywords LIKE ?", "%#{term}%")
where(content_... |
require 'rspec'
require 'numbers_to_words'
describe 'translate_number' do
it 'returns the word form of an integer below 9' do
translate_number(7).should eq 'seven'
end
it 'returns the word form of an integer below 19' do
translate_number(13).should eq 'thirteen'
end
it 'returns the word form of any... |
# Write a program that will take a number from 0 to 999,999,999,999 and spell out that number in British English.
# In other words, if the input to the program is 12345 then the output should be twelve thousand three hundred forty-five.
class Say
ONES = %w{NO one two three four five six seven eight nine ten eleven... |
module PUBG
class Telemetry
require "pubg/telemetry/log_player_login"
require "pubg/telemetry/log_player_create"
require "pubg/telemetry/log_player_position"
require "pubg/telemetry/log_player_attack"
require "pubg/telemetry/log_item_equip"
require "pubg/telemetry/log_item_pickup"
require ... |
input = File.read("/Users/hhh/JungleGym/advent_of_code/2021/inputs/day04.in").split "\n\n"
# input = File.read("/Users/hhh/JungleGym/advent_of_code/2021/inputs/day04test.in").split "\n\n"
nums = input.shift
nums = nums.split ","
p nums
class Board
attr_reader :board
attr_accessor :marks, :last_num, :won
def ini... |
class Circle < ActiveRecord::Base
attr_accessible :title, :user_id
validates_presence_of :title
belongs_to :master, :class_name => 'User', :foreign_key => "user_id"
belongs_to :friend, :class_name => 'User', :foreign_key => "friend_id"
end
|
class Snake < ExObj
@@STATE_WAITING = 0
@@STATE_HISSING = 1
@@STATE_BITING = 2
@@STATE_BITTEN = 3
def initialize()
super("snake")
@state = @@STATE_WAITING
end
def getDescription()
return "A poisonous snake."
end
def resetState()
@state = @@STATE_WAITING
end
def timerTick()
if(@state < @@STATE... |
# What output does this code print? Fix this class so that there are no surprises waiting in store for the unsuspecting developer.
class Pet
attr_reader :name
def initialize(name)
@name = name.to_s
end
def to_s
# @name.upcase!
"My name is #{@name.upcase}."
end
end
name = 'Fluffy'
fluffy = Pet.... |
# # -*- mode: ruby -*-
# # vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
VAGRANT_BOX = 'ubuntu/bionic64'# Memorable name for your
VM_NAME = 'al-yw-vm'# VM User — 'vagrant' by default
VM_USER = 'vagrant'# Username
# VM_PORT = 8080
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
#config.vm.provider "docker"... |
require 'account'
describe 'Withdrawal feature tests' do
let(:account) { Account.new }
it 'allows user to deposit funds' do
account.deposit(1000)
expect(account.balance).to eq(1000)
end
it 'throws error if user tries to deposit invalid amount' do
expect { account.deposit(-5) }
.to raise_erro... |
require 'rails_helper'
describe PlayerVsPlayer do
let(:primary) { FactoryBot.create :player }
let(:secondary) { FactoryBot.create :player }
let(:day) { DateTime.now.beginning_of_month.strftime('%m/%d/%y') }
subject { PlayerVsPlayer.new(primary, secondary) }
context '#games_won' do
let(:expected_games_wo... |
module Concerns::EngineMaster::Validation
extend ActiveSupport::Concern
included do
validates :name, uniqueness: true, presence: true
end
end
|
require "spec_helper"
require "stanford_corenlp_xml_adapter"
RSpec.describe StanfordCorenlpXmlAdapter do
it "has a version number" do
expect(StanfordCorenlpXmlAdapter::VERSION).not_to be nil
end
describe ".doc" do
it "returns a Nokogiri object" do
expect(StanfordCorenlpXmlAdapter.doc(valid_xml).cl... |
require './lib/terms'
require 'oj'
describe "Terms" do
before :all do
terms_stub = Oj.load( '{
"@mroth":"Matthew Rothenberg",
"@kellan":"Kellan Elliott-McCrea",
"@curlyjazz":"Jasmine Trabelsi"
}' )
@... |
module DJ
class Worker
attr_accessor :worker_class_name
class << self
def enqueue(*args)
self.new(*args).enqueue!
end
end
def dj_object=(dj)
@dj_object = dj.id
end
def dj_object
DJ.find(@dj_object)
end
def worker_class_name
i... |
# XSD4R - XMLScan XML parser library.
# Copyright (C) 2002, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
# redistribute it and/or modify it under the same terms of Ruby's license;
# either the dual license version in 2003, or any later v... |
FactoryBot.define do
factory :lessonplan do
name "MyString"
attachment "MyString"
teacher nil
end
end
|
require 'test_helper'
describe Flyer do
it 'has 2 object from fixtures' do
Flyer.count.must_equal 3
end
it 'title should be more then 5 symbols' do
Flyer.new(title: 'abcde').must_be :valid?
end
end
|
describe Exporter::Overtimes do
include_context "exporter"
let!(:overtime_kirk) { create(:overtime_kirk) }
it "exports" do
export
expect(record["employee_id"]).to eql("1701")
expect(record["name"]).to eql("Kirk,James")
expect(record["rank"]).to eql("SgtDet")
expect(record["assigned"]).to eql(... |
require 'digest/sha1'
class User < ActiveRecord::Base
RESERVED_LOGINS = %w(home unknown_user user_has_no_url login signup activate_account logout admin forgotten_password fyp unfyp login_express fyp_express unfyp_express legal_info)
attr_accessor :password
attr_accessor :terms_of_use_acceptance
attr_accessor... |
require_relative '../helpers/palindrome_counter'
class OEIS
# Number of strings of length n over a 7 letter alphabet that begin with a
# nontrivial palindrome.
def self.a249640(n)
palindrome_count(n, 7)
end
end
|
module GithubService
class DeleteParser < BaseParser
def able_to_parse?
@event == 'delete'
end
private
def username
@params[:sender][:login]
end
def type
@params[:ref_type]
end
def name
@params[:ref]
end
def message
%(#{username} deleted #{typ... |
#encoding: utf-8
class Fila < ActiveRecord::Base
# attr_accessible :title, :body
validates_presence_of :nome, :message => "preenchimento obrigatório"
validates_presence_of :cpf, :message => "preenchimento obrigatório"
validates_presence_of :rg, :message => "preenchimento obrigatório"
validates_presence_of... |
#!/usr/bin/ruby
require 'uri'
require 'net/http'
require 'json'
require 'openssl'
require 'base64'
if ENV['BITRISE_GIT_BRANCH'] != 'master'
puts 'Not on main branch, skipping notification'
exit 0
end
env_sdk_failure_notif_endpoint = ENV['SDK_FAILURE_NOTIFICATION_ENDPOINT']
env_sdk_failure_notif_endpoint_hmac_key... |
require 'bigdecimal/util'
namespace :alerts do
desc "User can receive alert based on MAX_NEW value"
task min: :environment do
@alerts = Alert.all
@alerts.each do |alert|
unless alert.expired?
present_value = alert.get_value('price_usd').to_d
new_percent_delta = alert.percent_changed
... |
class Sebastian::Item::FlowBox < Sebastian::Item
@@defaults = {
flowbox_orientation: Clutter::FlowOrientation::VERTICAL
}.merge(@@defaults)
def initialize(options = {})
super()
@state[:children] = []
@state[:options] = {
orientation: @@defaults[:flowbox_orientation]
}.merge(options)
... |
class NewsfeedsController < ApplicationController
# GET /newsfeeds
# GET /newsfeeds.xml
def index
@newsfeeds = Newsfeed.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @newsfeeds }
end
end
# GET /newsfeeds/1
# GET /newsfeeds/1.xml
def show
... |
class MakeLawsPublic < ActiveRecord::Migration
def up
Agenda.transaction do
# make all new laws public
puts "making #{Agenda.where(:parliament_id => 2).count} laws public"
start = Time.now
index = 0
Agenda.where(:parliament_id => 2).find_each(:batch_size => 100) do |agenda|
p... |
RSpec.describe Hanami::Controller do
describe ".configuration" do
before do
Hanami::Controller.unload!
module ConfigurationAction
include Hanami::Action
end
end
after do
Object.send(:remove_const, :ConfigurationAction)
end
it "exposes class configuration" do
... |
require 'rails_helper'
describe "editing" do
before(:each) do
@user = create(:user_with_recipes)
sign_in
visit edit_user_recipe_path @user, @user.recipes.first
end
it "allows you to delete recipes" do
expect(@user.recipes.count).to eq(5)
click_link 'Delete Recipe'
Capybara.current_dri... |
require 'builder'
require 'saml_idp/algorithmable'
require 'saml_idp/signable'
module SamlIdp
class AssertionBuilder
include Algorithmable
include Signable
attr_accessor :reference_id
attr_accessor :issuer_uri
attr_accessor :principal
attr_accessor :audience_uri
attr_accessor :saml_request... |
class FavoriteArticlesController < ApplicationController
before_action :signed_in?
def create
@favorite_article = FavoriteArticle.new(user_id: current_user.id, article_id: params[:article_id])
if @favorite_article.save
redirect_to user_path(current_user)
else
render 'article/show'
end
... |
require 'htph';
# Produces lists of gd_ids where those ids can be joined by one or more
# of oclc, sudoc, lccn, and/or issn.
def main
@log = HTPH::Hathilog::Log.new();
@log.d("Started");
db = HTPH::Hathidb::Db.new();
conn = db.get_conn();
# Get each distinct value of a given attribute (oclc, sudoc, ...)... |
class AddIndexesOnTimeTableClassTiming < ActiveRecord::Migration
def self.up
add_index :time_table_class_timings, [:timetable_id,:batch_id], :name => :timetable_id_and_batch_id_index
add_index :time_table_class_timing_sets, :time_table_class_timing_id
end
def self.down
remove_index :time_table_class_... |
module GuidConverter
def self.to_oracle_raw16(string, strip_dashes: true, dashify_result: false)
oracle_format_indices = [3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15]
string = string.gsub("-"){ |_match| "" } if strip_dashes
parts = split_into_chunks(string)
result = oracle_format_indices.map ... |
require 'rails_helper'
require 'shoulda-matchers'
RSpec.describe User, type: :model do
before(:each) do
@user = User.create(email: "email@test.com", password_digest: "ppppp")
end
context "Valid User" do
it "should not allow to be created without an email" do
@user.email = nil
expect(@user).to_not be_val... |
class TravelerSerializer < ActiveModel::Serializer
attributes :id, :name, :age, :liked_sights, :reviewed_sights
# has_many :sightseeings, through: :likes
has_many :likes
has_many :reviews
end
|
class ItemsController < ApplicationController
#<-------All GET methods
#GET /items?id=:id
def get
@id = params[:id] #collect input
@item = nil
#check to make sure the id isn't null
if !@id.nil?
@item = Item.find_by(id: @id)
end
... |
class Duck < ApplicationRecord
belongs_to :student
validates :student_id, :description, :name, presence: :true
end
|
class CreatePlanets < ActiveRecord::Migration[6.0]
def change
create_table :planets do |t|
t.string :planet_name
t.integer :rotation_period
t.integer :orbital_period
t.integer :diameter
t.string :gravity
t.integer :surface_water
t.integer :population
t.references :h... |
# frozen_string_literal: true
json.results do
json.total @count
json.notifications do
json.array! @notifications do |notification|
json.id notification.id
json.unread !notification.read?
json.template render partial: "notifications/#{notification.notifiable_type.underscore.pluralize}/#{notifi... |
class RailwayStationsRoute < ActiveRecord::Base
belongs_to :railway_station
belongs_to :route
validates :railway_station_id, uniqueness: {scope: :route_id}
end |
Rails.application.routes.draw do
mount Chato::Engine => "/chato"
end
|
class Cart < ApplicationRecord
belongs_to :cd
belongs_to :user
validates :cd_id, presence: true
validates :user_id, presence: true
validates :quantity, presence: true
def self.search_all(search)
Cart.where(['cd_id LIKE ?', "#{search}"])
end
end
|
class UserNotifier < ActionMailer::Base
default from: "cudalign@gmail.com"
def send_done_processing_alignment_email(alignment)
@alignment = alignment
mail(to: @alignment.callback_email, subject: 'We just finished processing your alignment request!')
end
end
|
# ENVIRONMENT HELPER
# Primarily to allow different domains and static domains for local and remote sites
# When Jekyll builds, you can use the Liquid filter to output the correct paths
# 1. Create a file named `_env` and put in it the name of your environment
# 2. Configure your paths in _config.yml
# 3. Use the Liqu... |
# frozen_string_literal: true
class MovieApiService
SERVICE_DOMAIN = "https://pairguru-api.herokuapp.com"
SERVICE_ENDPOINT = "/api/v1/movies/"
API_URL = "#{SERVICE_DOMAIN}#{SERVICE_ENDPOINT}"
DEFAULTS = { poster: "", plot: "", rating: 0.0 }.freeze
NO_MOVIE_MSG = "Couldn't find Movie"
def initialize(title)... |
class CreateEmployeeTasks < ActiveRecord::Migration[5.2]
def change
create_table :employee_tasks do |t|
t.decimal :hours_done
t.integer :task_id
t.integer :employee_id
t.timestamps
end
end
end
|
# rspec spec -t type:collection
describe [1, 7, 9], 'All', type: :collection do
it { is_expected.to all(be_odd.and(be_an(Integer))) }
it { expect(%w[ruby rails]).to all(be_a(String).and(include('r'))) }
end
|
class SleepsController < ApplicationController
before_action :authenticate_user!
def index
sleep_date = Date.today
# Sleep grouped by month in hash
@sleep_months = @sleeps.group_by { |s| s.sleep_date.beginning_of_month }.sort { |a,b| a[0] <=> b[0] }
# Sleep grouped for use in calendar helper
# ... |
class CreateBooks < ActiveRecord::Migration[6.0]
def change
create_table :books do |t|
t.string :book_name, null: false, limit: 30
t.text :description, null: false, limit: 300
t.integer :category_id, null: false
t.integer :age, n... |
class Expand < ActiveRecord::Migration[5.0]
def change
change_column :line_items, :id, :integer, limit: 8
end
end
|
# This migration comes from inyx_catalogue_rails (originally 20140912135705)
class CreateInyxCatalogueRailsCategoryCatalogues < ActiveRecord::Migration
def change
create_table :inyx_catalogue_rails_category_catalogues do |t|
t.string :title
t.string :description
t.timestamps
end
end
end
|
#t.string "name", null: false
class State < ActiveRecord::Base
has_many :cities
belongs_to :country
validates_presence_of :name
end
|
require "fog/core/model"
module Fog
module Compute
class Brkt
class Volume < Fog::Model
module State
READY = "READY"
end
# @!group Attributes
identity :id
attribute :name
attribute :description
attribute :computing_cell, :alia... |
# 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... |
class CreateLeads < ActiveRecord::Migration
def change
create_table :leads do |t|
t.string :first_name
t.string :last_name
t.string :email
t.string :phone
t.string :company
t.integer :interested
t.integer :status
t.integer :source
t.text :company
t.text ... |
class CreateBooks < ActiveRecord::Migration
def self.up
create_table :books do |t|
t.string :name, default: nil, null: false, unique: true
t.text :description
t.string :cover_image
t.timestamp :create_at
end
end
def self.down
drop_table :books
end
end
|
module ActualResults
class CalculatedRating
attr_reader :sorted_teams
attr_reader :teams
def self.cache_key(contest)
"c#{contest.respond_to?(:id) ? contest.id : contest}-rating"
end
def self.preload_classes
ActualResults::TeamState
ActualResults::TestState
Ac... |
class ChangeColumnNameTuenti < ActiveRecord::Migration
def up
rename_column :tuenti_data, :actions_text, :actions
end
def down
rename_column :tuenti_data, :actions, :actions_text
end
end
|
#a. Erstellen Sie eine Klasse Game mit einem Konstruktor, der eine Instanzvariable title anlegt.
#Zugleich soll ein leeres Array mit dem Namen players erstellt werden.
#b. die Klasse Game bekommt eine Methode add_player der ein Spieler hinzugefuegt wird
#c. eine Methode play erzeugt folgenden Ausdruck:
# There are 3 p... |
class MessangersController < ApplicationController
def create
@user = User.friendly.find(params[:user_id])
@message = Messanger.new(message_params)
@message.receiver_id = @user.id
@message.sender_id = current_user.id
@message.save
redirect_to @user
end
def index
@user = User.friendly.find(params[:use... |
module Chanko
module UpdatingLoad
module Loadable
def self.included(obj)
obj.class_eval do
def require_or_updating_load(path)
ActiveSupport::Dependencies.require_or_updating_load(path)
end
end
end
end
module Dependencies
def self.included(... |
class LibView::LibraryCatsController < ApplicationController
before_action :set_locale_info
# GET /libraries
def index
@library_cats = LibraryCat.
joins("INNER JOIN library_#{@current_locale}s USING(library_id) INNER JOIN library_cat_#{@current_locale}s ON library_cat_id=library_vcats.id").
activ... |
#MICHELLE: any time a comment is put above a line of code it is explaining what it is there for (not below)
# Homepage (Root path)
get '/' do
erb :index
end
get '/messages' do
#our server needs to load the messages from the database, render them as HTML, and send that HTML back as a response to their browser. @me... |
require 'rake'
desc "Home-baked spec task"
task :spec do
# this obviously need some cleaning - it's currently getting the job done though
if RUBY_PLATFORM == 'i386-mswin32'
system("ir spec/mspec/bin/mspec-run --format spec spec/*_spec.rb")
else
unless ENV["RUBY_EXE"]
# MSpec needs RUBY_EXE env var ... |
# Copyright 2007-2014 Greg Hurrell. All rights reserved.
# Licensed under the terms of the BSD 2-clause license.
require 'walrat'
module Walrat
class ParsletOmission < ParsletCombination
attr_reader :hash
# Raises an ArgumentError if parseable is nil.
def initialize parseable
raise ArgumentError,... |
require_relative 'questions_database'
require_relative 'user'
require 'byebug'
class QuestionFollow
def self.find_by_id(id)
data = QuestionsDatabase.instance.execute(<<-SQL, id)
SELECT
*
FROM
question_follows
WHERE
id = ?
SQL
question_follow = QuestionFollow.n... |
def Donation
@@all = []
attr_reader :artist, :donor
def initialize(artist, donor)
@artist = artist
@donor = donor
@@all << self
end
def self.all
@@all
end
end |
class ReviewsController < ApplicationController
before_action :logged_in_user, only: [:create, :destroy]
before_action :correct_user, only: :destroy
def create
@user = User.find(current_user)
@review = Review.new(review_params)
property = Property.find(@review.property_id)
if @review.save!
... |
module ApplicationHelper
# shorten a string to a set number of characters to the word number (closing tags if needed)
# this method counts tags or formatting symbols as characters for shortening
def truncate_words(string, count = 30, end_str=' ...')
trunc = string
if string.length >= count
shortene... |
class RedirectController < ApplicationController
def index
url = params[:next_url] || root_url
redirect_to url
end
end
|
class EncryptedFile
COORDS = [1000, 2000, 3000]
Number = Struct.new(:value, :position)
def initialize(values)
@numbers = values.map.with_index { |v, i| Number.new(v, i) }
@order = @numbers.dup
end
def mix!(times = 1)
times.times do
@order.each do |number|
@numbers.rotate!(@numbers... |
class SearchController < ApplicationController
def index
service = FuelStationService.new(params[:q])
@stations = service.stations
end
end
|
class CreatePomodoros < ActiveRecord::Migration
def self.up
create_table :pomodoros do |t|
t.integer :id
t.integer :activity_id
t.timestamp :start_time
t.timestamp :end_time
t.integer :interruption_type
t.timestamps
end
end
def self.down
drop_table :pomodoros
en... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
def create_esb_server (config, hostname, ip1, ip2)
config.vm.define hostname do |esb|
esb.vm.provider "virtualbox" do |provider|
provider.customize ["modifyvm", :id, "--memory", 2048]
end
esb.vm.network "private_network", ip: ip1
esb.vm.host_name = host... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.