text stringlengths 10 2.61M |
|---|
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def previous_control(page)
link_to('Previous', {:action => :show, :id => page.higher_item.id}) unless page.first?
end
def next_control(page)
page.last? ? "<span class=\"last_page\">(This is ... |
# Programming Languages Lab
# Laura Nadolski
# May 26 2018
def reformat_languages(languages)
new_hash = {}
style_array = []
type_string = ""
languages.each do |oo_or_funct, names|
names.each do |name, type_hash|
if type_hash.has_value?("interpreted")
type_string = "interpreted"
else
... |
class AddRaceIdToRaceRanking < ActiveRecord::Migration
def change
add_column :race_rankings, :race_id, :integer
end
end
|
Vagrant.require_version ">= 1.7.0"
Vagrant.configure("2") do |config|
config.vm.define "storage"
config.vm.provider "virtualbox"
config.vm.box = "bento/ubuntu-16.04"
config.ssh.insert_key = true
config.vm.define "storage" do |n|
n.vm.hostname = "storage"
n.vm.network :private_netw... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
def current_user_can?(action, object)
false
end
def current_admin_can?(action, object)
true
end
end
|
class NewAnswerNoticeService
def send_notice(answer)
answer.question.subscribers.find_each do |user|
if user.is_author?(answer.question)
unless user.is_author?(answer)
NewAnswerNoticeMailer.notice_for_owner(user, answer).try(:deliver_later)
end
else
unless user.is_aut... |
class HomeScreen < PM::GroupedTableScreen
title "About"
def table_data
[{
title: 'LeanMotion',
cells: [
{ title: '网站', action: :website },
{ title: '版本:0.1'}
]
},
{
title: '联系',
cells: [
{ title: '作者:张泽涛'},
{ title: '公司:恰恰网络', action: :chac... |
class My::StatusesController < ApplicationController
before_filter :login_required
@@per_page = APP_CONFIG[:statuses]['per_page']
def index
@statuses = current_user.statuses.paginate(
:page => params[:page],
:per_page => @@per_page,
:order => 'crea... |
ActiveAdmin.register Profile do
hstore_editor
permit_params :avatar, :user_id, :sites, :biography
filter :user
filter :created_at
index do
selectable_column
id_column
column :user
column :created_at
actions
end
form(:html => { :multipart => true }) do |f|
f.inputs "Associati... |
class EventoYaExistenteError < StandardError
def initialize(msg="El id de este evento ya existe")
super
end
end |
require 'rails_helper'
RSpec.describe ContractModel, type: :model do
it 'has a valid factory' do
expect(create :contract_model).to be_valid
end
end
|
module KTorrent
class BEncoding
BadBEncoding = Class.new(StandardError)
def initialize(data)
@data = data
@index = 0
end
def decode
parse_data_stream
end
def self.decode(data)
self.new(data).decode
end
def self.encode(object)
case object
when Has... |
class TaskList < ApplicationRecord
belongs_to :user
has_many :tasks, dependent: :destroy, inverse_of: :task_list
has_and_belongs_to_many :favorites_users, class_name: "User"
validates :name, :user, presence: true
accepts_nested_attributes_for :tasks, reject_if: :all_blank, allow_destroy: true
scope :pu... |
class Bowl < ActiveRecord::Base
has_and_belongs_to_many :fruits
end
|
module BrowserTimezoneRails
module TimezoneControllerSetup
private
def time_zone_to_use
if @current_user && @current_user.timezone.present?
@current_user.timezone
else
browser_timezone.presence || Time.zone
end
end
def set_time_zone(&action)
Time.use_zone(time... |
require 'spec_helper'
require 'base64'
describe Api::Response do
before :each do
@response = Api::Response.new(
double response_code: 200,
status_message: "OK",
response_headers: "Foo: 123\r\nBar: baz\r\nQuux-Zuul: fedcba",
response_body: '{"a":1,"b":2}',
... |
class Review < Sequel::Model
plugin :timestamps, update_on_create: true
plugin :auto_validations, not_null: :presence
many_to_one :transaction
many_to_one :user
many_to_one :reviewer, class: :User, key: :reviewer_id
def after_create
super
Notification.create({
user: self.user,
triggeri... |
require 'spec_helper'
describe StaticPagesController do
describe "GET 'home' action from 'StaticPagesController'" do
it "should be successful" do
get 'home'
response.should be_success
end
end
describe "GET 'contact' action from 'StaticPagesController'" do
it "should be successful" do
... |
class PlayerStatsController < ApplicationController
before_action :player_must_exist
def index
@stat = PlayerVsPlayer.new(primary, secondary)
@games = @stat.games.page(params[:page]).per(10)
render :index
end
def player_vs_player
render json: PlayerVsPlayer.new(primary, secondary).games_won
... |
require_relative '../helpers/console'
class SelectionMenu
def initialize(hash)
@title = hash[:title]
@disable_selection = hash[:disable_selection] == true
@input_message = hash[:input_message] || '> '
@autoclear = hash[:autoclear] != false
@index_template = hash[:index_template] || ->(index) { "#... |
class UserUpdateOperation < Operation
attr_reader :pipe
def initialize
@pipe = Pipe.new
@user = Main::Users.new @pipe
end
def load
super() do
@user.load_from_params attribute_group: :for_update
end
end
def accomplish
super do
@user.update
end
end
end
|
# Build a class called FizzBuzz that takes two numbers as parameters and
# then have a method called run that returns a fizzbuzz array
# (numbers from 1 to 100, numbers divisible by the first number replaced
# by 'fizz' and numbers replaced by the second number replaced by 'buzz' and
# numbers divisible by both replace... |
class ServiceItemsController < ApplicationController
before_action :set_service_item, only: [:show, :edit, :update, :destroy]
# GET /service_items
# GET /service_items.json
def index
@service_items = ServiceItem.all
end
def update_auto_models
@auto_models = AutoModel.where(auto_brand_id: params[:a... |
class Order < ApplicationRecord
belongs_to :credit_card
belongs_to :plan
enum status: {
draft: 0,
paid: 1
}
end
|
class Like < ApplicationRecord
belongs_to :user
belongs_to :review
scope :like_review, ->(id){where review_id: id}
end
|
require 'json'
require 'tempfile'
require 'version_sorter'
require 'rocco'
require 'docurium/layout'
require 'pp'
class Docurium
Version = VERSION = '0.0.5'
attr_accessor :branch, :output_dir, :data
def initialize(config_file)
raise "You need to specify a config file" if !config_file
raise "You need to... |
class Notifier < ActionMailer::Base
layout 'email'
default :from => 'GamePlayDate.com <no-reply@gameplaydate.com>'
def registration_confirmation(user_id)
user = User.find(user_id)
@user = user
mail(:to => @user.email, :subject => "Welcome to GamePlayDate!")
end
def password_reset(user_id)
... |
module RunLengthEncoding
def self.encode(string)
string
.each_char
.each_with_object(EncodeTracker.new) do |character, tracker|
tracker.process_character(character)
end.result
end
def self.decode(string)
string
.scan(/\d*[^0-9]/)
.map { |group| EncodedGroup.new(group... |
class ApplicationController < ActionController::Base
def callback
logins = current_user.present? ? current_user.logins : {}
case omniauth[:provider]
when 'facebook'
logins['graph.facebook.com'] = omniauth[:credentials][:token]
else
raise 'Unknown Provider'
... |
Routrip::Application.routes.draw do
#get 'blog' => 'blog#index'
#get 'blog/:title' => 'blog#post'
get '/blog(:id)', to: 'blog#index', :id => /.+/
scope "(:locale)", locale: /en|es/ do
get 'trips/new', :to => "trips#new"
get 'trips/trip_sent', :to => "trips#trip_sent"
get 'trips/show_admin/:id'... |
# Initializes all page objects
class Pages
attr_accessor :navigation_bar, :landing_page, :test_automation_page,
:contact_us_page
def initialize
@navigation_bar = NavigationBar.new
@landing_page = LandingPage.new
@test_automation_page = TestAutomationPage.new
@contact_us_page = Cont... |
require 'spec_helper'
describe RssProgramImporter do
describe '::sync' do
before :each do
stub_request(:get, %r{californiareport}).to_return({
:content_type => 'text/xml',
:body => load_fixture('rss/rss_feed.xml')
})
end
it "imports episodes and enclosures as audi... |
class AddUvWhiteAndBatchToMpis < ActiveRecord::Migration
def change
add_column :mpis, :uv_light, :string
add_column :mpis, :white_light, :string
add_column :mpis, :batch_number, :string
end
end
|
class Bookmark < ApplicationModel
belongs_to :user, :class_name => "User", :foreign_key => "user_id", :counter_cache => :store_count
belongs_to :store, :class_name => "Store", :foreign_key => "foreign_key", :counter_cache => :bookmark_count
belongs_to :region, :class_name => "Region", :foreign_key => "foreign_key... |
class Service < ApplicationRecord
has_many :projects, dependent: :destroy
validates :name, presence: true
def self.circle
find_by name: 'Circle CI'
end
def self.github
find_by name: 'GitHub'
end
def self.heroku
find_by name: 'Heroku'
end
def self.honeybadger
find_by name: 'Honeybad... |
# prompt
Pry.config.color = true
Pry.config.prompt_name = ''
Pry.config.prompt = proc do |obj, nest_level, _pry_|
version = ''
version << "\001\e[0;31m\002"
version << "#{RUBY_VERSION}"
version << "\001\e[0m\002"
if defined?(Rails)
version << ':'
version << "\001\e[0;91m\002"
version << "#{Rails.... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
resources :categories, :products
root to: "categories#index"
#get "/allcategories", to: "categories#index"
get "/allcategories", to: redirect("/")
get "/products/:id/toggle... |
authorization do
role :tokens do
has_permission_on :oauth_user_tokens, :to=>[:index,:revoke]
end
role :oauth2_manage do
has_permission_on :oauth_clients, :to=>[:index,:new,:create,:show,:edit,:update,:destroy]
end
role :admin do
includes :oauth2_manage
includes :tokens
includes :basic
... |
RSpec.describe Mission::ChaosMonkey do
let(:no_of_stages) { 4 }
let(:mission_distance) { 160 }
let(:auto_abort_rate) { 3 }
let(:auto_explode_rate) { 5 }
let(:random) { double('random') }
describe 'chaos_for_mission' do
it 'generates abort_at at "auto_abort_rate"' do
expect(random).to receive(:ran... |
require 'spec_helper'
describe Disqussion::Client do
context ".new" do
before do
@client = Disqussion::Client.new
end
it "connect using the endpoint configuration" do
connection = @client.send(:connection).build_url(nil).to_s
connection.should == @client.api_endpoint.gsub(/\/$/, '')
... |
# encoding: utf-8
Entonces(/^(?:veo un mensaje|veo el mensaje|veo un mensaje que dice)? "(.*?)"$/) do |mensaje|
#Capybara Quering, sin RSpec. Usa MiniTest.
#save_and_open_page
assert page.has_content?(mensaje)
end
Dado(/^(?:estoy en la pantalla|me encuentro en la pantalla|estoy en la pantalla donde veo|que estoy... |
# Write an efficient algorithm for the following assumptions:
# N is an integer within the range [2..100,000];
# each element of array A is an integer within the range [−1,000..1,000].
def solution(a)
head = a.first
tail = a.drop(1).inject(:+)
min_diff = (head - tail).abs
(1...a.size - 1).each do |i|
... |
# Read about factories at http://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :folder do
sequence(:name) {|n| "Folder#{n}"}
todouser_id 1
association :todouser
end
end
|
class CallbacksController < ApplicationController
def google_oauth2
@user = User.from_omniauth(request.env['omniauth.auth'])
sign_in_and_redirect @user
end
def failure
flash[:error] = 'There was a problem signing you in. Please register or try signing in later.'
redirect_to new_user_registrat... |
require 'rails_helper'
RSpec.describe Bicycle, type: :model do
context "Validations" do
# NOTE: these matchers are provided by the `shoulda-matchers` gem
# They're not provided automatically by RSpec itself.
it { is_expected.to validate_presence_of(:brand) }
it { is_expected.to validate_presence_of(... |
class AddModifiedHoursToTimeTables < ActiveRecord::Migration
def change
add_column :time_tables, :modified_hours, :integer
end
end
|
module Refinery
module Auditions
class AuditionsController < ::ApplicationController
before_filter :find_all_auditions
before_filter :find_page
def index
# you can use meta fields from your model instead (e.g. browser_title)
# by swapping @page for @audition in the line below:
... |
require_relative 'questionsdatabase'
require_relative 'modelbase'
class Reply < ModelBase
attr_accessor :id, :parent_id, :user_id, :question_id, :body
def initialize(options)
@id = options['id']
@question_id = options['question_id']
@parent_id = options['parent_id']
@user_id = options['user_id']
... |
class Api::V1::BaseApiController < ApplicationController
private
# Swagger
class << self
Swagger::Docs::Generator::set_real_methods
def inherited(subclass)
super
subclass.class_eval do
setup_basic_api_documentation(subclass)
end
end
private
def setup_basic_api_do... |
#!/usr/bin/env ruby
require 'script_notifier'
notice_queue_uri = ARGV[0]
result_queue_uri = ARGV[1]
config_path = ARGV[2]
if ARGV[2] == '--pid'
unless ARGV.length > 3
raise "Please provide a pid file when specifying --pid"
else
pid_file_name = ARGV[3]
puts pid_file_name
if ... |
require 'spec_helper'
module Naf
describe MachineAffinitySlot do
let(:machine) { mock_model(Machine, server_address: '0.0.0.1', server_name: 'Machine1') }
let!(:slot) { FactoryGirl.create(:normal_machine_affinity_slot) }
# Mass-assignment
[:machine_id,
:affinity_id,
:required,
:affini... |
# frozen_string_literal: true
require 'ffi-rzmq'
# ZmqSocket is for abstraction of zeromq socket
class ZmqSocket
attr_reader :client_public_key, :ip, :port, :zmq, :name
@@client_public_key = ''
@@client_private_key = ''
def initialize(hsh = {})
set_connection(hsh.fetch('ip4'), hsh.fetch('zmq_port'))
... |
class Alumno < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
CURP_regex = /^[A-Z]{1}[AEIOU]{1}[A-Z]{2}[0-9]{2}(0... |
=begin
The goal here is to take a hash like this:
pigeon_data = {
:color => {
:purple => ["Theo", "Peter Jr.", "Lucky"],
:grey => ["Theo", "Peter Jr.", "Ms. K"],
:white => ["Queenie", "Andrew", "Ms. K", "Alex"],
:brown => ["Queenie", "Alex"]
},
... |
class Tagging < ActiveRecord::Base
belongs_to :taggable, :polymorphic => true
belongs_to :tag
validates_uniqueness_of :taggable_id, :scope => [:tag_id]
#method to set the correct class type for taggings polymorphic table
def taggable_type=(sType)
super(sType.to_s.classify.constantize.to_s)
end
e... |
require 'test_helper'
class PlayerPromisesControllerTest < ActionController::TestCase
setup do
@player_promise = player_promises(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:player_promises)
end
test "should get new" do
get :new
as... |
FactoryBot.define do
factory :notification do
subject "MyString"
message "MyString"
end
end
|
# coding: utf-8
require 'rails_helper'
describe "audiograms/index" do
before(:each) do
@patient = FactoryGirl.create(:patient)
@examdate = Time.now
@audiogram_stub = stub_model(Audiogram,
:examdate => @examdate,
:comment => "Comment",
:image_location => "graphs_some_directory",
:ac_rt_5... |
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require '/Users/kyle/Code/sp-event-api/lib/tech_omaha_scraper.rb'
require 'mechanize'
require 'nokogiri'
require 'open-uri'
require 'geocoder'
require 'chronic'
require 'pry'
describe TechOmahaScraper do
describe 'TechOmahaScraper general methods' ... |
class CreateReceivables < ActiveRecord::Migration[5.0]
def change
create_table :receivables do |t|
t.integer :company_id
t.decimal :receiveable_amount, precision: 20, scale: 2
t.date :check_date
t.date :transaction_date
t.text :remarks
t.timestamps
end
end
end
|
module Roglew
module GL
ALREADY_SIGNALED ||= 0x911A
CONDITION_SATISFIED ||= 0x911C
MAX_SERVER_WAIT_TIMEOUT ||= 0x9111
OBJECT_TYPE ||= 0x9112
SIGNALED ||= 0x9119
SYNC_CONDITION ||= 0x9113
SYNC_FENCE ||= 0x9116
... |
describe AttachmentPolicy do
subject { described_class }
let(:proposal) { create(:proposal, :with_parallel_approvers, :with_observers) }
let(:attachment) { create(:attachment, proposal: proposal) }
permissions :can_destroy? do
it "allows the original uploader to delete" do
expect(subject).to permit(... |
class ChangeDefaultStatusofApp < ActiveRecord::Migration
def change
change_column_default :apps, :status, 5
end
end
|
#!/usr/bin/env ruby
# frozen_string_literal: true
begin
require 'denshi_paper'
rescue LoadError
$: << File.expand_path('../lib', __dir__)
require 'denshi_paper'
end
require 'optparse'
require 'openssl'
if $0 == __FILE__
opt = OptionParser.new
opt.version = DenshiPaper::VERSION
workspace = nil
client_i... |
class VideosController < ApplicationController
before_filter :authenticate_user!
before_filter :get_page
before_filter :page_administrator!
def index
redirect_to new_page_video_url(@page)
end
def show
@video = @page.videos.find(params[:id])
respond_to do |format|
format.html # show.ht... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-16.04"
config.ssh.forward_agent = true
config.ssh.forward_x11 = true
config.vm.network "private_network", ip: "192.168.23.33"
config.vm.hostname = "dotfiles"
config.vm.provider :virtualbox do |v|
... |
class FontCoiny < Formula
head "https://github.com/google/fonts/raw/main/ofl/coiny/Coiny-Regular.ttf", verified: "github.com/google/fonts/"
desc "Coiny"
homepage "https://fonts.google.com/specimen/Coiny"
def install
(share/"fonts").install "Coiny-Regular.ttf"
end
test do
end
end
|
class FontHanamina < Formula
version "2017.09.04,68253"
sha256 "571cd4a09ae7da0c642d640fc2442c050aa450ebb0587a95cdd097d41a9c9572"
url "https://osdn.dl.osdn.jp/hanazono-font/#{version.to_s.sub(/.*,/, "")}/hanazono-#{version.to_s.sub(/,.*/, "").gsub(".", "")}.zip", verified: "osdn.dl.osdn.jp/hanazono-font/"
desc ... |
# frozen_string_literal: true
module Suggestions
class ApplyService < ::BaseService
def initialize(current_user)
@current_user = current_user
end
def execute(suggestion)
unless suggestion.appliable?
return error('Suggestion is not appliable')
end
params = file_update_par... |
require 'time'
module DJI
module Fedex
class Package
attr_accessor :tracking_number, :pretty_tracking_number
attr_accessor :tracking_qualifier, :tracking_carrier_code, :tracking_carrier_description
attr_accessor :shipper_company_name, :shipper_name, :shipper_address, :shipper_address_line_2,
... |
module Crawler
module RobotsTxt
# Parsing and matching for path in robots.txt
class PathMatcher
# @param [String] path
def initialize(path)
path = path.to_s.strip
path = "/#{path}" unless path.start_with?('/')
endmark_index = path.index('$') || -1
@valid = endmark_... |
class AddPendenciasAlunos < ActiveRecord::Migration
def self.up
add_column :alunos, :pend_financeira, :boolean
add_column :alunos, :pend_biblioteca, :boolean
end
def self.down
remove_column :alunos, :pend_financeira
remove_column :alunos, :pend_biblioteca
end
end
|
class AddEditedToPhysicalFile < ActiveRecord::Migration
def change
add_column :physical_files, :edited, :boolean, default: false
end
end
|
# This class initializes the array of the face up cards.
# Includes methods for drawing 3 more cards, getting the size
# of the cards shown array, getting and deleting cards at a given
# position.
class CardsShown
# initialize: Creates a new instance of CardsShown
#
# deck - The deck that the cards are being d... |
require 'rails_helper'
RSpec.describe ' application/:id page ' do
it 'shows vet info' do
shelter_1 = Shelter.create!(name: "shelter_1", city: "greenvil", rank: "1", foster_program: "b")
shelter_2 = Shelter.create!(name: "shelter_2", city: "burgerburg", rank: "2", foster_program: "a")
pet_1 = shelter_... |
class Product < ActiveRecord::Base
include PgSearch
has_one :variant
has_one :metadatum
searchable do
text :name
autosuggest :name
end
pg_search_scope :autocomplete,
against: :name,
using: {tsearch: {prefix: true} }
pg_search_scope :autocomplete_with_ass... |
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
include AuthenticatedSystem
require 'rubygems'
require 'aasm'
#include ExceptionNotifiable
#custom erro... |
Given(/^the following links have been saved:$/) do |links|
links.hashes.each do |link|
# puts "links : #{links}"
# puts "hashes : #{links.hashes}"
Link.create(link)
end
end
Given(/^I am using the bookmark manager$/) do
visit '/'
end
When(/^I add a link with a description$/) do
@description = 'A scr... |
#!/usr/bin/env ruby
require 'optparse'
require 'csv'
class Item
attr_accessor :name, :weight, :value
def initialize(name, weight, value)
@name = name
@weight = weight
@value = value
end
end
class Chromosome
include Comparable
attr_accessor :bits, :fitness
def initialize(bits, fitness=0)
... |
class School < ApplicationRecord
has_many :trips
validates :name, :responsible_name, presence: true
validates(
:responsible_contact,
presence: true,
length: { minimum: 9 },
)
def to_s
name
end
end
|
require './lib/wizards/wizard'
require './lib/wizards/room'
describe Wizard do
let(:rooms) { Rooms.new }
subject do
Wizard.new(rooms.layout)
end
describe "#position_x" do
it "the wizard starts off at postion 4" do
subject.position_x.should eq 4
end
end
describe "#position_y" do
it ... |
$LOAD_PATH.unshift(File.dirname(__FILE__))
require "spec_helper"
describe "ServicesMgmt" do
include Rack::Test::Methods
context "authentication" do
def app
ServicesMgmt
end
it "should be redirected without token" do
get "/"
last_response.should be_redirect
end
it "should be... |
# array.rb creates an array, reads values, and prints it back out
#
# Input: array size, an int, values, ints,
# Output: values stores in the array
#
# Begun by: Prof. Adams, for CS 214 at Calvin College.
# Completed by: David Choi
# Date: 3-11-2019
#################################################################
d... |
class PrincessPeach < Fighter
def initialize
@name = "Princess Peach"
@opening_line = "Hi-cha"
@moves = [
Move.new('heal', EFFECT_TYPES::HEAL, 50),
Move.new('booty bump', EFFECT_TYPES::STUN, 50)
]
@special_move = SpecialMove.new '*music*', EFFECT_TYPES::HEAL, 20
super 35 # pi... |
class AccountBill < Bill
before_validation :update_offset
accepts_nested_attributes_for :bill_account_entry
validates_associated :bill_account_entry
validates_presence_of :payee
validates_length_of :payee, :maximum => 50
private
def update_offset
build_bill_account_entry if bill_acco... |
# Objects on the employee page
class EmployeeSummaryPage
include PageObject
# Objects on the page
h4(:general_info_header, class: 'panel-title', text: 'General Info')
h4(:project_info_header, class: 'panel-title', text: 'Project Info')
h4(:time_off_info_header, class: 'panel-title', text: 'Time Off Info')
... |
# frozen_string_literal: true
class CreateTasks < ActiveRecord::Migration[6.1]
def change
create_table :tasks do |t|
t.integer :claimed_by
t.string :task_name
t.text :task_description
t.datetime :due_date
t.integer :child_task_id
t.string :tag
t.timestamps
end
end... |
module Auth
class OauthsController < BaseController
skip_before_action :verify_authenticity_token if respond_to? :verify_authenticity_token
def create
type = (oauth_params[:provider].to_s + '_user').classify
@oauth_user = OauthUser.find_or_initialize_by(type: type, uid: oauth_params[:uid])
... |
class TopicVotesController < ApplicationController
before_action :set_topic_vote, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!
def upvote
topic = Topic.find(params[:id])
topic_vote = TopicVote.new
topic_vote.value = 1
topic_vote.voter_id = current_user.id
topic_v... |
class Profile < ActiveRecord::Base
belongs_to :user, dependent: :destroy
has_many :images
end
|
class AddCompactNameToDepartments < ActiveRecord::Migration
def change
add_column :departments, :compact_name, :string
add_index :departments, :compact_name
end
end
|
# == Schema Information
#
# Table name: withdrawal_requests
#
# id :integer not null, primary key
# wallet_id :integer
# status :integer default(0)
# amount :decimal(8, 2)
# data :text
# created_at :datetime not null
# updated_at :datetime not null
# paym... |
class Invite < ActiveRecord::Base
attr_accessible :email
validates_format_of :email, :with => RFC822::EMAIL
has_many :referrals
end
|
#!/usr/bin/env ruby
require 'sinatra'
require 'sinatra/formkeeper'
require 'pony'
require './helpers.rb'
configure :development, :test do
require 'pry'
# Config for [MailCatcher](http://mailcatcher.me/)
set :email_options, {
via: :smtp,
via_options: {
address: "localhost",
port: 1025
}
... |
module OrganizationChargeHelper
#为机构员工的社保和公积金服务提供工作流相关的公共功能集
extend ActiveSupport::Concern
include PagerHelper
included do
scope :of_organization, ->(organization_ids) {where(organization_id: organization_ids).order(:start_date)}
scope :managed_by_users, ->(user_ids) { joins(:organization).where("organi... |
require 'rails_helper'
RSpec.describe Movie, type: :model do
describe "scopes" do
describe ":current_week" do
it 'return the movie with a screening this week' do
movie = create(:movie)
create(:screening, movie: movie, date: Time.now)
expect(Movie.current_week.count).to eq 1
e... |
describe "Moria::ViewConstraint" do
before do
@superview = UIView.new
@view1 = UIView.new
@view2 = UIView.new
@superview.addSubview(@view1)
@superview.addSubview(@view2)
@attribute1 = Moria::ViewAttribute.new(@view1, NSLayoutAttributeHeight)
@attribute2 = Moria::ViewAttribute.new(@view2, N... |
class NvsEnvsController < ApplicationController
before_filter :find_project, :get_types
before_filter :authorize
# GET /nvs_envs
# GET /nvs_envs.json
def index
@nvs_envs = NvsEnv.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @nvs_envs }
end
end
... |
name 'zabbix-agent'
maintainer 'Sous Chefs'
maintainer_email 'help@sous-chefs.org'
license 'Apache-2.0'
description 'Installs/Configures Zabbix Agent'
source_url 'https://github.com/sous-chefs/zabbix-agent'
issues_url 'https://github.com/sous-chefs/zabbix-agent/issues'... |
## Worked with Luke Woodruff
class HelloWorldClass
def initialize(name)
@name = name.capitalize
end
def sayHi
puts "Hello #{@name}!"
end
end
hello = HelloWorldClass.new("Alix")
hello.sayHi
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.