text stringlengths 10 2.61M |
|---|
class FileController < ApplicationController
def presigned_s3_url
s3 = Aws::S3::Resource.new
obj = s3.bucket("moryaka").object("#{SecureRandom.uuid}/#{params[:file_name]}")
url = URI.parse(obj.presigned_url(:put)).to_s
render json: { value: url }
end
end
|
# must be first file included
require_relative 'spec_helper.rb'
require_relative '../library/platform.rb'
describe "crew shasum" do
before(:all) do
environment_init
ndk_init
end
before(:each) do
clean_hold
clean_cache
repository_init
repository_clone
end
context 'with --check opti... |
# Write a function
# def solution(a)
# that, given an array A consisting of N integers, returns the number of distinct values in array A.
def solution(a)
# In production environment this will be my solution:
# a.uniq.size
#
# But since this is a coding challenge, my assumption
# is that you're looking fo... |
# frozen_string_literal: true
def to_hex(red, green, blue)
result = ['#']
[red, green, blue].each do |color|
color = color.to_s(16)
color = '0' + color if color.length == 1
result << color
end
result.join
end
def to_ints(color)
color.slice!('#')
result = color.scan(/../)
result.map! { |hex| ... |
require 'rspec'
require 'date'
require 'capybara/rspec'
require_relative '../spec_helper'
Capybara.app = PlantApplication
Capybara.javascript_driver = :selenium
Capybara.default_wait_time = 20
describe 'Plant Creation', :type => :feature do
before :each do
visit '/perfume'
end
context 'Successfully crea... |
require 'formula'
class OcamlFindlib < Formula
homepage 'http://projects.camlcity.org/projects/findlib.html'
url 'http://download.camlcity.org/download/findlib-1.5.3.tar.gz'
sha256 'd920816e48cb5bf3199fb57b78e30c2c1ea0e5eeeff654810118b14b76d482cf'
depends_on 'objective-caml'
def install
homebrew_prefix... |
# current code of mbta in ruby
# I used global variabale to make the hash of subway_line easier to access
# in reverse and use of global variable
$subway_lines =
{
red:['South Station','Park Street','Kendall','Central','Harvard','Porter','Davis','Alewife'],
green:['Government Cente', 'Park Street', 'Boylston',... |
#! /usr/bin/env ruby
###################################################################
require 'parallel'
require 'bio'
require 'Dir'
###################################################################
def getProt2Taxon(indirs, cpu, is_seqObj=false)
infiles = Array.new
prot2taxon = Hash.new
seqObjs = Hash.... |
require 'spec_helper'
describe "creating a new book" do
it "redirects to the books index page on success" do
visit "/books"
click_link "New Book"
expect(page).to have_content("New Book")
fill_in "Title", with: "Test Title"
fill_in "Author", with: "Test Author"
select "2010", from: "book[publication_date... |
# == Schema Information
#
# Table name: chief_doctors
#
# id :integer not null, primary key
# image :string(255)
# name :string(255)
# position :string(255)
# status :string(255)
# created_at :datetime
# updated_at :datetime
#
class ChiefDoctor < ActiveRecord::Base
validates ... |
FactoryGirl.define do
factory :exposure do
summary "MyString"
published "MyString"
title "MyString"
cvss_v2_base_score 1
access_vector "MyString"
access_complexity "MyString"
authentication "MyString"
integrity_impa... |
feature "User - Create" do
context 'Visitor' do
# Cenário para validar se usuários não autenticados são bloqueados de acessar a página
scenario "Access invalid", js: true do
visit new_user_path
expect(current_path).to eq new_session_path
end
end
context 'Adm... |
=begin
class Ticket
def initialize(venue, date)
@venue = venue
@date = date
end
def venue
@venue
end
def date
@date
end
end
th = Ticket.new("Town Hall", "11/12/13")
cc = Ticket.new("Convention Center", "12/13/14")
puts "We've created two tickets."
puts "The first is for a #{th.venue} event o... |
require 'json'
require 'date'
class InvalidPeriodError < StandardError
end
class Car
attr_reader :price_per_day, :price_per_km
def initialize(cid, price_per_day, price_per_km)
@cid = cid
@price_per_day = price_per_day
@price_per_km = price_per_km
end
end
class Rental
# Discount-priced intervals of days
F... |
require_relative '../spec_helper'
RSpec.describe FundamentalsFetcher do
let(:base_url) { 'https://www.finanzen.net/aktien/hugo_boss-aktie' }
let(:subject) { FundamentalsFetcher.new(base_url) }
let(:vcr_name ) { 'download_html_hugo_boss' }
around do |example|
VCR.use_cassette(vcr_name) { example.run }
en... |
module Relationships
extend ActiveSupport::Concern
def following?(leader)
leaders.include? leader
end
def follow!(leader)
leaders << leader if (leader != self) && (!following? leader)
end
end
|
# ----------------------------------------------------------------------------
# Frozen-string-literal: true
# Copyright: 2015-2016 Jordon Bedwell - MIT License
# Encoding: utf-8
# ----------------------------------------------------------------------------
$LOAD_PATH.unshift(File.expand_path("../lib", __FILE__))
requ... |
component 'rubygem-hiera' do |pkg, settings, platform|
pkg.version '3.4.5'
pkg.md5sum 'a248dbdd636a6a15cea5dd92b005af4c'
instance_eval File.read('configs/components/_base-rubygem.rb')
end
|
module Chat
module Msg
# Baseclass for all messages. Sets up some messages to make Message class
# definition nicer.
class Message
ALL = []
def self.inherited(klass)
ALL << klass
end
def self.fields
@fields ||= []
end
def self.def_fields(*fields)
... |
class Unxwb < Formula
desc "great tool for extracting the data contained in the Xbox files with the XWB, ZWB and WBA extensions and any other file which contains the XWB archives."
homepage "http://aluigi.altervista.org/papers.htm#xbox"
url "http://aluigi.altervista.org/papers/unxwb.zip"
version "0.3.6"
sha25... |
module LearnOpen
class FileBackupStarter
attr_reader :lesson, :location, :system_adapter
def self.call(lesson, location, options)
self.new(lesson, location, options).call
end
def initialize(lesson, location, options)
@lesson = lesson
@location = location
@system_adapter = opt... |
class PhotosController < ApplicationController
def show
user = User.find(params[:user_id])
@admin = params[:user_id].to_i == session[:login_id].to_i
@title = "#{user.first_name} #{user.last_name}"
@photos = user.photos
end
def new
@title = "Upload A Photo"
end
def create
uploaded_io = params[:photo]
... |
class Phones::FormDataSerializer < ApplicationSerializer
object_as :phone
attributes(
:number,
:extension,
:notes,
:contact_id,
:category_id,
:created_at,
:updated_at,
)
end
|
class RenameCallLimitInSipAccounts < ActiveRecord::Migration
def self.up
rename_column :sip_accounts, 'call-limit', :call_limit
end
def self.down
rename_column :sip_accounts, :call_limit, 'call-limit'
end
end |
require File.dirname(__FILE__) + '/spec_helper.rb'
describe Smsinabox, "configuration" do
it "should have a default base URI" do
Smsinabox.uri.to_s.should == "http://www.mymobileapi.com/api5/http5.aspx"
end
it "should accept a username" do
Smsinabox.username = 'test'
Smsinabox.username.should eql('... |
class AddLogoToBar < ActiveRecord::Migration
def change
add_column :bars, :logo_uid, :string
end
end
|
# 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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
module Palmade::CampingExt
module Mixins
module Benchmarking
module Base
def service_with_benchmarking(*a, &block)
rt = ret = nil
path_n_method = " [#{@request.request_method.to_s.upcase} #{@request.path rescue 'unknown'}]"
tm = Time.now.strftime("%Y-%m-%d %H:%M:%S")
... |
class ChangeTimestampForAdvertisements < ActiveRecord::Migration[6.1]
def change
change_column :advertisements, :timestamp, :string
end
end
|
class CheckoutService
def create_wirecard_payment(credit_card_data)
checkout_api = Checkout::Wirecard::Api.new
order_hash = checkout_api.create_order_with_hash(create_order_hash)
payment_hash = create_credit_card_hash(credit_card_data)
payment_response = checkout_api.create_payment_with_hash order_... |
require 'oauth'
require 'contacts/google'
# An extension to the standard OAuth library so we can nicely use Google APIs
module GoogleOAuth
class RequestToken < OAuth::RequestToken
def authorize_url(params={})
params.merge! :oauth_token => token
params = params.map { |k,v| "%s=%s" % [CGI.escape(k.to_s... |
class Reservation < ActiveRecord::Base
belongs_to :venue
belongs_to :game
belongs_to :user
has_many :posts
end
|
# frozen_string_literal: true
require 'rails_helper'
feature 'Staff can add new organization', %(
As an authenticated staff
I'd like to be able to add new organization
), js: true do
given(:staff) { create(:staff) }
describe 'Authenticated staff' do
background do
sign_in_as(staff)
visit staff... |
#
# Cookbook Name:: jenkins
# Attributes:: server
#
# Author:: Doug MacEachern <dougm@vmware.com>
# Author:: Fletcher Nichol <fnichol@nichol.ca>
# Author:: Seth Chisamore <schisamo@opscode.com>
#
# Copyright 2010, VMware, Inc.
# Copyright 2012, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "Lice... |
require 'rails_helper'
module Storage
describe AlbumStore do
describe '#all_albums' do
it 'returns all albums' do
dystopia = create(:album)
reminiscence = create(:album)
result = AlbumStore.new.all_albums
expect(result).to match_array([dystopia, reminiscence])
end
... |
#==============================================================================
# VXAce Star Passability Bug Fix
# by NeonBlack
# -- Level: Easy, Normal
# -- Requires: n/a
# -- This simply checks if the tile is a star before checking passability.
# If the tile is a star and it is passable, it then checks the tile U... |
# == Schema Information
#
# Table name: cats
#
# id :bigint not null, primary key
# birth_date :date not null
# color :string not null
# name :string not null
# sex :string(1) not null
# description :text not null
# creat... |
class ProjectsController < ApplicationController
before_filter :authenticate_user!
def index
respond_to do |f|
f.html {render :layout => false }
f.json {render :json => current_user.projects}
end
end
def show
respond_to do |f|
f.html {render :layout => false }
f.json {r... |
class UpdateItemGroupNameToEmptyString < ActiveRecord::Migration
def change
reversible do |dir|
dir.up do
ItemDetail.where("item_group_name is NULL").each {
|i|
i.update_attribute :item_group_name, ''
}
end
end
end
end
|
cask :v1 => 'dropbox-experimental' do
version '3.3.35'
sha256 '4d72e91bb525a8359cbe47ad8b39a8bb6632df95515c836b2891fd21d01b9b98'
url "https://dl.dropboxusercontent.com/u/17/Dropbox%20#{version}.dmg"
homepage 'https://www.dropboxforum.com/hc/communities/public/questions/202522965-Experimental-Build-3-3-34'
li... |
module Operations
module PostOperations
class PostEdit < Operations::OperationBase
attr_accessor :id
def doWork
origin_post = Post.find(id)
if origin_post.draft?
draft = origin_post
else
draft = Post.find_by(original_post: origin_post)
end
i... |
#! /usr/bin/env ruby
require 'influxdb'
require './conf.rb'
time_precision = 's'
bucket_tags = %w[past1 past5 past15]
influxdb = InfluxDB::Client.new host: HOST, database: DATABASE, username: USERNAME, password: PASSWORD
puts "Streaming some stats to database:#{DATABASE} every 5 seconds.."
loop do
stats = `w | he... |
class AddTipToColor < ActiveRecord::Migration
def self.up
add_column :colors, :tip, :text
end
def self.down
remove_column :colors, :tip
end
end
|
require "spec_helper"
module CloudCapacitor
module Executors
describe DefaultExecutor do
it_behaves_like "a Performance Test Executor"
subject(:executor) { described_class.new }
it "returns a Result object from Redis" do
redis_instance = MockRedis.new
Redis.stub(:new).an... |
class BraintreePayment
def initialize(gift, credit_card)
configure_environment
@gift = gift
@credit_card = credit_card
end
def configure_environment
Braintree::Configuration.environment = :sandbox
Braintree::Configuration.merchant_id = ENV["braintree_merchant_id"]
Braintree::Configuratio... |
class ProjectsController < ApplicationController
load_and_authorize_resource
before_action :reset_meta_tags, only: :show
def index
@projects = Project.all.page(params[:page])
end
def new
@project = Project.new
end
def create
@project.user = current_user
if @project.save
redirect_t... |
require 'test_helper'
class EntitiesListsExportsControllerTest < ActionDispatch::IntegrationTest
test 'CSV access' do
sign_in users(:show_on_agent_weather)
get export_user_agent_entities_list_path(
users(:admin), agents(:weather), entities_lists(:weather_conditions), format: :csv
)
assert_resp... |
class BidsController < ApplicationController
def show
@bid = Bid.find(params[:id])
end
def new
@project = Project.find(params[:project_id])
@bid = Bid.new
end
def create
@bid = Bid.new(bid_params)
@bid.project_id = params[:project_id]
@bid.user_id = current_user.id
@bid.f_name =... |
class AddPriceDataToProperties < ActiveRecord::Migration[5.1]
def change
add_column(:properties, :mortgage_value, :integer, null: false)
add_column(:properties, :mortgage_payoff, :integer, null: false)
add_column(:properties, :rent, :integer)
add_column(:properties, :rent_with_set, :integer)
add_c... |
# Timer
class Timer
attr_accessor :seconds
def initialize
@seconds = 0
end
def time_string
hours = @seconds / (60 * 60)
minutes = (@seconds % (60 * 60)) / 60
seconds = (@seconds % 60)
[Timer.time(hours), Timer.time(minutes), Timer.time(seconds)].join(":")
end
private
def Timer.time(str)
(str <... |
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
before_action :set_cache_buster
include Knock::Authenticable
#DEFAULT PARAMETERS
OFFSET = 0
LIMIT = 20
... |
require "test_helper"
class Kgallant90PalindromeTest < Minitest::Test
def test_non_palindrome
refute "apple".palindrome?
end
def test_literal_palindrome
assert "racecar".palindrome?
end
def test_mixed_case_palindrome
assert "RaceCar".palindrome?
end
def test_palindrome_with_punctuation
a... |
class Role < Sequel::Model
many_to_many :users, :left_key => :role_id, :right_key => :user_id, :join_table => :users_roles
end
|
class Api::V1::ApiController < ApplicationController
before_filter :require_authentication
def require_authentication
unless Rails.env == 'test'
authenticate_or_request_with_http_basic do |username, password|
username == "twothirdsclimbing" && password == "tookitooki"
end
end
end
end
|
# frozen_string_literal: true
class ContentComponentStories < ViewComponent::Storybook::Stories
story :default do
content do
"Hello World!"
end
end
story :with_helper_content do
content do
link_to 'Hello World!', '#'
end
end
story :with_constructor_content do
constructor do
... |
require_relative './application_service'
class RecipeFinder < ApplicationService
def initialize(tag)
@tag = tag
end
def call
fetch_search_results.map do |recipe|
{
id: recipe['id'],
name: recipe['title'],
summary: get_summary(recipe['id']),
img_url: recipe['image']... |
require_relative '../lib/doc_server'
# BAD – IO provides print, write and more methods which prints to console
# our test will break after refactoring which uses write, for example
RSpec.describe DocServer do
context 'display Ruby methods for Array/max' do
it 'printed with two IO#puts (use the implementation d... |
class AuthTokensController < ApplicationController
before_filter :authenticate_user!
def create
@user = User.find(params[:id])
@user.reset_authentication_token!
redirect_to user_path(@user)
end
def destroy
@user = User.find(params[:id])
@user.update_attribute(:authentication_token, nil)
... |
class Group < ActiveRecord::Base
attr_accessible :slug, :title
has_many :users
end
|
require 'nibble_endpoints'
require 'failsafe_store'
require 'movie_title'
module RottenTomatoesPrivate
extend NibbleEndpoints
# ${RT.PrivateApiV2FrontendHost}/api/private/v2.0/search/default-list
# https://www.rottentomatoes.com/api/private/v1.0/movies/12897/recommendations/
define_connection 'https://www.rot... |
module Dotpkgbuilder
class Payload < Stage
PAYLOAD_FILE = "Payload".freeze
delegate :working_dir, :source_dir, :pkg_dir, to: :context
def run
mkpayload
end
def mkpayload
log.info "creating #{pkg_dir}/#{PAYLOAD_FILE}"
inside(source_dir) do
sh "find . | cpio -o --format... |
module Mutations
class Users::CreateUser < BaseMutation
description 'Creates a User'
argument :name, String, required: true
argument :netid, String, required: true
type Types::UserType
def resolve(name: nil, netid: nil)
User.create!( name: name, netid: netid)
end
end
end
|
# == Schema Information
# Schema version: 20090906143900
#
# Table name: user_teams
#
# id :integer not null, primary key
# user_id :integer
# budget :integer
#
module TeamDriverExtension
def add(driver)
team = proxy_owner
# TODO rollback TeamUserDriver
_transaction do
if !team.dri... |
require 'spec_helper'
describe Graphlient::Adapters::HTTP::HTTPAdapter do
let(:app) { Object.new }
context 'with custom url and headers' do
let(:url) { 'http://example.com/graphql' }
let(:headers) { { 'Foo' => 'bar' } }
let(:client) do
Graphlient::Client.new(url, headers: headers, http: Graphlie... |
class Portafolio < ApplicationRecord
has_many :tecnologies
accepts_nested_attributes_for :tecnologies,
reject_if: lambda { |attrs| attrs['name'].blank? }
include Placeholder
validates_presence_of :title, :body, :main_image, :thumb_image
#Opcion
def self.angular
where... |
cask :v1 => 'homestream' do
version '1.1'
sha256 '193dd9fb3488dfb754057b9c216e09fe2f0528b20a95bbe9b7d5f4b0556a4e2b'
url "http://homestreamdownload.sony-europe.com/homestream-#{version}-osx.tar.gz"
homepage 'http://www.sony.co.uk/hub/1237485339460'
license :unknown # todo: change license and remove this co... |
Confy::App.helpers do
def conferences_grouped_by_year(conferences)
grouped_conferences = conferences.group_by(&:year)
Hash[grouped_conferences.sort_by { |k, _| k }.reverse]
end
def talks_counter(quantity)
if quantity > 1 then
"#{quantity} talks"
elsif quantity == 0
"No talks yet"
... |
class AddBillplzToOrders < ActiveRecord::Migration[5.0]
def change
add_column :orders, :status, :integer
add_column :orders, :paid_at, :datetime
add_column :orders, :bill_id, :string
add_column :orders, :bill_url, :string
end
end
|
class Menu < ActiveRecord::Base
acts_as_nested_set
include TheSortableTree::Scopes
validates :name, :menu_url, :menu_type, presence: true
validates :name, uniqueness: true
def title
name
end
class << self
def types
[:main, :rgt_side_bar, :lft_side_bar]
end
def view_templates
... |
# write a method that will return a substring based on the specific ndices.
# input: a string, with two indices as arguments
# 1. change the string into an array to select indices
# 2. create a range out of the two indices ( ex. 1..5)
# 3. select the letters out of array with array[a..b]
def substring(string, idx1, ... |
class CreateOptions < ActiveRecord::Migration
def change
create_table :options do |t|
t.string :name
t.integer :votos
t.integer :disponible
t.string :instancia
t.text :descripcion
t.timestamps null: false
end
end
end
|
# encoding: utf-8
class AccidentsController < ApplicationController
# authorize_resource
before_action :set_auto
def set_auto
@auto = Auto.find_by(id: params[:auto_id])
redirect_to autos_path and return unless @auto
end
def index
@accidents = @auto.accidents.includes(:customer).page(params[:pa... |
class AddSettings < ActiveRecord::Migration
def change
create_table :settings do |t|
t.string :name
t.integer :setting_key
t.string :value
end
add_index :settings, :name
end
end
|
class Faq < ActiveRecord::Base
acts_as_list
attr_accessible :answer, :position, :question
RailsAdmin.config do |config|
config.model Faq do
navigation_label 'CMS'
nestable_list true
list do
sort_by :position
field :id
field :question
... |
require("minitest/autorun")
require("minitest/rg")
require_relative("../player")
class PlayerTest < Minitest::Test
def setup
@name1 = Player.new("James", 6)
end
def test_get_name
assert_equal("James", @name1.name)
end
def test_get_number_of_lives
assert_equal(6, @name1.number_of_lives)
end
def test_wrong_gue... |
# create users
users_data = [
{ email: 'homer@sent.as', password: '12345678', password_confirmation: '12345678', bio: 'Homer Simpson', full_name: 'Homer' },
{ email: 'marge@sent.as', password: '12345678', password_confirmation: '12345678', bio: 'Marge Simpson', full_name: 'Marge' },
{ email: 'bart@sent.as', passw... |
class Category < ApplicationRecord
has_and_belongs_to_many :products
validates :name, presence: true, uniqueness: true
before_create :set_default_image
def set_default_image
unless banner_img.present?
self.banner_img = "http://lorempixel.com/1440/360/sports"
end
end
end |
# Model for finding pickup locations if given delivery codes.
class Location
# Gets the pickup code for a given delivery code.
def self.get_pickup_for(recap_delivery_code)
require 'net/http'
require 'uri'
begin
uri = URI.parse(ENV['LOCATIONS_URL'])
response = Net::HTTP.get_response(uri)
... |
class RecordsController < ApplicationController
before_action :require_admin, :only => [ :new, :edit, :destroy ]
def index
@records = Record.all.with_attached_cover.order(release_date: :desc)
end
def show
if Record.find_by_slug(params[:id])
@record = Record.find_by_slug(params[:id])
else Record... |
FactoryBot.define do
factory :memorial_notice do
first_name "Joe"
last_name "Smith"
date_of_death "24/04/2016"
after_nightfall false
spouse "Jenny Smith"
child1 "Max Smith"
child2 "Charlie Smith"
child3 nil
child4 nil
child5 nil
child6 nil
child7 nil
child8 nil
... |
# frozen_string_literal: true
# This class is responsible for generating the statement
class Statement
def display(transactions)
statement = prepare_headers(transactions[0])
transactions.reverse.each do |details|
statement += prepare_transaction_row(details)
end
statement
end
private
de... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Messageモデルに関するテスト', type: :model do
describe 'イベント情報の保存' do
let(:user) { create(:user) }
let(:room) { create(:room) }
it "メッセージが入力されている場合保存できるか" do
expect(FactoryBot.create(:message)).to be_valid
end
end
context 'バリデーションチ... |
# -*- encoding : utf-8 -*-
TelasiGe::Application.routes.draw do
scope controller: 'dashboard' do
match '/login', action: 'login', as: 'login', via: ['get', 'post']
get '/logout', action: 'logout', as: 'logout'
match '/register', action: 'register', as: 'register', via: ['get', 'post']
get '/register_c... |
class Compinfo < ActiveRecord::Base
belongs_to :user
validates_uniqueness_of :infotype
end
|
class Talk
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Slug
include Mongoid::Attributes::Dynamic
include Commentable
field :presentation_url, type: String
field :title, type: String
field :description, type: String
field :tags, type: String
field :thumbnail, type: String
... |
module GithubService
class TravisStatusParser < BaseParser
def able_to_parse?
@event == 'status' && contexts.include?(@params[:context])
end
private
def contexts
[
'continuous-integration/travis-ci/pr',
'continuous-integration/travis-ci/push'
]
end
def mess... |
class Task < ApplicationRecord
belongs_to :user
validates :title, presence: true, length: {minimum: 5, too_short: "%{count} characters is the minimum allowed"}
def complete!
self.completed = true
save
end
end
|
# frozen_string_literal: true
require 'client'
describe '証券会社の設定' do
before(:example) do
@client = Jiji::Client.instance
end
it 'GET /settings/securities/available-securities' \
+ 'で利用可能な証券会社が取得できる' do
r = @client.get('/settings/securities/available-securities')
expect(r.status).to eq 200
... |
class BillingPlansController < ApplicationController
before_action :set_billing_plan, only: [:show, :edit, :update, :destroy]
# GET /billing_plans
# GET /billing_plans.json
def index
@billing_plans = BillingPlan.all
end
# GET /billing_plans/1
# GET /billing_plans/1.json
def show
end
# GET /bi... |
class AddCompanyPhoneAndCompanyEmailToAppliedJobs < ActiveRecord::Migration[5.2]
def change
add_column :applied_jobs, :company_phone, :string
add_column :applied_jobs, :company_email, :string
end
end
|
class ApplicationController < ActionController::Base
include SessionsHelper
before_action :allow_staging_access
before_action :load_search_terms_list
protect_from_forgery
after_filter :set_csrf_cookie_for_ng
#http://stackoverflow.com/questions/128450/best-practices-for-reusing-code-between-controllers-in-rub... |
require 'logger'
require 'active_support/configurable'
require 'active_support/core_ext/module/attribute_accessors'
require 'active_support/core_ext/module/introspection'
require_relative './logging_support/filters/noop_filter'
require_relative './logging_support/filters/kv_filter'
require_relative './logging_support/... |
module Rhouse::Models
class DeviceCategory < ActiveRecord::Base
set_table_name 'DeviceCategory'
set_primary_key "PK_#{DeviceCategory.table_name}"
def DeviceCategory.lighting
find( :first, :conditions => ["Description = ?", "Lighting Device"] )
end
def DeviceCategory.ip_cam
f... |
def two_funny_facts_about(number)
begin
power_of_two = 2**number
integer_quotient = 100 / number
rescue ZeroDivisionError => e
puts "Du kan inte dividera med 0"
puts "Försök igen"
number = gets.chomp.to_i
retry
rescue TypeError => e
puts "Du måste skr... |
class CreateDealings < ActiveRecord::Migration[5.2]
def change
create_table :dealings do |t|
t.integer :phase, default: 0
t.datetime :buyer_datetime
t.datetime :seller_datetime
t.references :item, forign_key: true
t.references :buyer, foreign_key: { to_table: :users }
t.timesta... |
class PageItemDecorator < Draper::Decorator
delegate_all
decorates_association :binder
def link(title='', **options, &block)
binder.link(title.present? ? title : name, options, &block) if binder
end
end
|
class Variant < ActiveRecord::Base
belongs_to :product
belongs_to :buyer
has_many :coupons
validates :price, :quantity, presence: true
scope :active, -> { where(is_active: true) }
end
|
class CreateGroupConversationsUsersJoinTable < ActiveRecord::Migration[6.1]
def change
create_table :group_conversations_users, id: false do |t|
t.integer :conversation_id, null: false, index: true
t.integer :user_id, null: false, index: true
end
add_index :group_conversations_users, [:conve... |
class SparkcoreWorker
include Sidekiq::Worker
$redis = Redis.new
def perform(msg ="You forgot a message")
logger.info "Kicking off the SparkCore Worker!!"
$redis.lpush("get_sparkcore_data", store_data)
logger.info "SparkCore Worker is done"
end
private
def spark_vars
["temperature", "h... |
class CreateTodotasklists < ActiveRecord::Migration
def change
create_table :todotasklists do |t|
t.string :task_name
t.integer :created_by_user
t.integer :closed_by_user
t.integer :status
t.integer :remainder
t.integer :archive
t.timestamps null: false
end
en... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.