text stringlengths 10 2.61M |
|---|
class WinLayer < Joybox::Core::Layer
scene
def on_enter
title = Label.new text: "You Win!", font_size: 48,
position: [Screen.half_width, Screen.half_height + 50]
self << title
audio_effect = AudioEffect.new
audio_effect[:win] = 'hooray.wav'
audio_effect.play :win
end
end |
#!/usr/bin/env ruby
## M4ngl3r ##
#
# String is passed as argument, program finds all combinations of upper/lower-case, and "leet" transforms.
require 'optparse'
@list = []
@l33t_list = {
"a" => ["4", "@"],
"b" => ["8"],
"c" => ["("],
"e" => ["3"],
"f" => ["ph"],
"g" =... |
# frozen_string_literal: true
# Set of helper methods for composing email messages
module UserMailerHelper
FOLLOW_CALL_TO_ACTION = I18n.t 'notifier.follow_cases'
SUBSCRIBER_MESSAGE = I18n.t 'notifier.subscribe_message'
subscriber_link_copy = 'Subscribe to our newsletter as well'
subscriber_link = ActionContr... |
class Role < ActiveRecord::Base
has_many :company_roles
has_many :companies, :through => :company_roles
validates_uniqueness_of :title
def self.seed
roles = ["Software Engineer", "Frontend Engineer", "Fullstack Engineer",
"Ruby Engineer", "Web Developer", "Javascript Engineer"]
roles.each do |rol... |
# frozen_string_literal: true
module ToWords
VERSION = "1.1.1"
end
|
require 'rails_helper'
RSpec.feature 'Transfers' do
scenario 'transfer my animal' do
user = sign_in
animal = FactoryGirl.create(:animal, owner: user)
other_user = FactoryGirl.create(:user)
visit animal_path(animal)
select other_user.name, from: 'Buyer'
click_button 'Transfer'
expect(page)... |
class FontNotoSansGujaratiUi < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/notosansgujaratiui"
desc "Noto Sans Gujarati UI"
homepage "https://fonts.google.com/specimen/Noto+Sans+Gujarati"
def install
(share/"fonts").install "NotoSa... |
class AddIndexToSuitsEmail < ActiveRecord::Migration
def change
add_index :suits, :email, unique: true
end
end
|
# Advent of Code 2019 Day 14 Part Two https://adventofcode.com/2019/day/14#part2
# Space Stoichiometry
# Equations for producing fuel from ore and intermediate chemicals
# How much fuel can you make from one trillion (1000000000000) ore?
class Ingredient
attr_accessor :num
attr_accessor :chem
def initialize(str)... |
json.tasks do
json.partial! 'api/tasks/task', task: @task
end |
# Screen shot config info:
# https://github.com/mattheworiordan/capybara-screenshot/blob/master/lib/capybara-screenshot.rb
require "selenium-webdriver"
require 'capybara'
require 'capybara/cucumber'
require 'capybara/poltergeist' # for headless
require 'capybara-screenshot/cucumber' # screenshots
r... |
# == Schema Information
#
# Table name: users
#
# id :bigint(8) not null, primary key
# username :string not null
# discriminator :string not null
# image_url :string
# email :string not null
# password_digest :string not null
# ... |
class User < ActiveRecord::Base
ROLES = [:student, :teacher, :admin]
devise :database_authenticatable,
# :confirmable,
# :lockable,
:registerable,
# :recoverable,
:rememberable,
:trackable,
# :validatable,
authentication_keys: [:login]
has... |
require File.expand_path('../../test_helper', File.dirname(__FILE__))
class CmsSiteAliasTest < ActiveSupport::TestCase
def test_fixtures_validity
Cms::SiteAlias.all.each do |site_alias|
assert site_alias.valid?, site_alias.errors.full_messages.to_s
end
end
def test_validation
site_alias = cms... |
# encoding: utf-8
#
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
#... |
Pod::Spec.new do |s|
s.name = 'BHTNestedSelectionPicker'
s.version = '0.0.1'
s.summary = 'A library for interacting with the TicketingHub Developer API from an iOS device.'
s.homepage = 'https://github.com/bartekhugo/BHTNestedSelectionPicker'
s.aut... |
require_relative 'room.rb'
require_relative 'song.rb'
require_relative 'guest.rb'
require_relative 'welcome_viewer.rb'
require_relative 'room_viewer.rb'
class KaraokeBar
def initialize()
# Initialize rooms
@rooms = []
@rooms[0] = Room.new(1, 10, 6)
@rooms[1] = Room.new(2, 11, 7)
@rooms[2] = R... |
require 'rails_helper'
RSpec.feature "User can add an item to their cart" do
scenario "user adds items to their carts" do
item = FactoryGirl.create(:item)
item2 = FactoryGirl.create(:item)
total_price = item.price + item2.price
total_weight = item.weight + item2.weight
visit item_path(item)
... |
When(/^I go to the homepage$/) do
visit'/'
end
Then(/^I should see the welcome message$/) do
expect(page).to have_content("Home")
end
|
=begin
Write a function that accepts an array of 10 integers (between 0 and 9),
that returns a string of those numbers in the form of a phone number.
Example
createPhoneNumber([1, 2, 3, 4, 5, 6, 7, 8, 9, 0])
# => returns "(123) 456-7890"
The returned format must be correct in order to complete this challenge.
Don't ... |
require 'menu'
describe Menu do
let(:lunch_menu) { Menu.new }
let(:salad) { double :dish, name: "salad", price: 6 }
let(:burger) { double :dish, name: "burger", price: 8 }
let(:restaurant) {double :takeaway, list_of_dishes: [salad,burger] }
it "can create a indexed menu out of the list of dishes" do
expect(l... |
require 'spec_helper'
describe GameOwnership do
let(:game_owner) { FactoryGirl.create(:user) }
let(:game) { FactoryGirl.create(:game) }
let(:game_ownership) { game_owner.gameownerships.build(game_id: game.id) }
subject { game_ownership }
it { should be_valid }
describe "ownership methods" do
... |
class RoutesController < ApplicationController
before_action :set_action, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!, except: [:index, :search]
before_action :move_to_index, only: [:edit, :update, :destroy]
def index
@routes = Route.includes(:user).order("created_at DESC")
... |
class Audit < ActiveRecord::Base
def get_name_type
case self.auditable_type
when "User"
return "Usuário"
when "Product"
return "Produto"
when "Organ"
return "Orgão"
when "Sector"
return "Setor"
when "Client"
return "Cliente"
when "ClientSegment"
return "Segmen... |
RSpec::Matchers.define :be_unique do
def duplicates(ary)
ary.group_by{ |e| e }.select{ |e, dups| dups.length > 1 }.keys
end
match do |array|
duplicates(array).empty?
end
failure_message_for_should do |array|
"array has duplicated elements: #{duplicates(array)}"
end
end
|
class ShopifyController < ApplicationController
require 'nokogiri'
require 'open-uri'
require 'csv'
#starts the whole process then redirects to download page
def create_csv
@url_base = "https://apps.shopify.com"
get_app_links
get_app_details
create_csv_file
redirect_to "/shopify_apps.csv"
end
# empty... |
module LocalizeExt::LanguageRules::Extensions
class UK_UA
def self.plural_key(count, key)
key_string = key.to_s
case count
when 0 then key_string
when 1 then key_string += '_1'
when 2..4 then key_string += '_2'
when 5..20 then key_string
else key_string = plu... |
module GeekparkApi
class User
def self.update token, params = {}
res = Faraday.patch GeekparkApi.config.user_api_base_uri do |req|
req.headers['Authorization'] = "Bearer #{token}"
req.body = params
end
{status: res.status, body: JSON.parse(res.body)}
end
def self.event... |
# == Schema Information
#
# Table name: beta_comments
#
# id :integer not null, primary key
# comment :text
# page_url :string(255)
# user_id :integer
# created_at :datetime
# updated_at :datetime
# name :string(255)
# email :string(255)
# mailing_list :boole... |
#
# Cookbook Name:: directories
# Recipe:: default
#
# Copyright 2014, Virender Khatri
#
# 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.0
#
# U... |
# encoding: utf-8
require_relative "helper"
setup do
obj = Object.new
obj.extend Cuba::TextHelpers
end
test "truncate" do |helper|
assert_equal "the q...", helper.truncate("the quick brown", 5)
assert_equal "same string", helper.truncate("same string", 11)
end
test "markdown" do |helper|
assert_equal "<h... |
require 'rake'
require 'rake/clean'
namespace(:dependencies) do
namespace(:sqlite3) do
package = RubyInstaller::Sqlite3
standard_download_and_extract package
mingw_root = File.join RubyInstaller::ROOT, RubyInstaller::MinGW.target
task :prepare => [package.target] do
cp(
File.join(p... |
# This was to explain super to myself with inherited classes
# in order to understand how methods are overwrittn
class OldGuy
def initialize(name, age)
@name = name
@age = age
end
def show_age
puts "His age is #{@age}"
end
def show_name
puts "His name is #{@name}"
end
def show_all
puts "Hello"
en... |
# frozen_string_literal: true
module GraphQL
module Tracing
class PrometheusTracing < PlatformTracing
class GraphQLCollector < ::PrometheusExporter::Server::TypeCollector
def initialize
@graphql_gauge = PrometheusExporter::Metric::Base.default_aggregation.new(
'graphql_duratio... |
class JobFeed < ActiveRecord::Base
attr_accessible :feed_id, :guid, :job_id, :published_at, :url
validates_presence_of :feed_id, :guid, :job_id, :published_at, :url
before_save do |job_feed|
job_feed.guid = UnicodeUtils.downcase(guid)
job_feed.url = UnicodeUtils.downcase(url)
end
validates :guid... |
# encoding: UTF-8
module CDI
module V1
module GameQuestions
class UpdateService < BaseUpdateService
include V1::ServiceConcerns::GameQuestionParams
record_type ::GameQuestion
# for serializers
alias :game_quiz :game
alias :game_poll :game
alias :game_open_... |
require_relative 'helper'
class TestDendenMarkdown < Test::Unit::TestCase
data {
data_set = {}
Pathname.glob(File.join(__dir__, 'fixtures/markdown/**/*.md')).each do |md_path|
label = md_path.sub_ext('').to_s.sub(File.join(__dir__, 'fixtures/markdown/'), '')
html_path = md_path.sub_ext('.html')
... |
class CreateFormulaAndConditions < ActiveRecord::Migration
def self.up
create_table :formula_and_conditions do |t|
t.string :expression1
t.string :expression2
t.integer :operation
t.string :value
t.references :hr_formula
t.timestamps
end
end
def self.down
dr... |
class ExerciseMusclesController < ApplicationController
# GET /exercise_muscles
# GET /exercise_muscles.xml
def index
@exercise_muscles = ExerciseMuscle.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @exercise_muscles }
end
end
# GET /exercise_mu... |
require "yaml"
require "typescript-node"
module Fy
class App < Padrino::Application
# register ScssInitializer
register Padrino::Rendering
register Padrino::Helpers
register Padrino::Mailer
register Padrino::Admin::AccessControl
error 404 do
render 'errors/404'
end
... |
# frozen_string_literal: true
class Elements::ButtonComponent < ViewComponent::Base
def initialize(button_type:)
@button_type = button_type
end
def button_type
@button_type.submit
end
end
|
#!/usr/bin/env ruby
ENV['RAILS_ENV'] ||= 'development'
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require File.expand_path('../../config/environment', __FILE__)
require 'daemon_spawn'
require 'resque'
if ENV['RAILS_ENV'] == "development... |
# encoding: UTF-8
module CDI
module V1
module GameOpenQuestions
class UpdateService < Games::BaseUpdateService
include V1::ServiceConcerns::GameOpenQuestionsParams
record_type ::GameOpenQuestion
private
def whitelist_attributes_to_clear
[:video_link, :image]
... |
require 'sinatra/base'
require 'sinatra/flash'
require './lib/player'
require './lib/game'
class Battle < Sinatra::Base
enable :sessions
register Sinatra::Flash
get "/" do
erb :index
end
post '/names' do
player_1 = Player.new(params[:player_1_name])
player_2 = Player.new(params[:player_2_name])
@game = Game... |
class AddExpirationToNode < ActiveRecord::Migration
def self.up
# add a column to node so it can have a hardware profile
add_column "nodes", "expiration", :datetime
end
def self.down
remove_column "nodes", "expiration"
end
end
|
require 'sepshortener_client/version'
require 'net/http'
require 'digest'
require 'uri'
module SepshortenerClient
INBOUNDSMS_TOKEN = "INBOUNDSMS".freeze
SEPRESEARCH_TOKEN = "SEPRESEARCH".freeze
SEPCONTENT_TOKEN = "SEPCONTENT".freeze
CONTENT_TYPE = 'application/json'.freeze
def short_url(link)
return ... |
class AddBoolsToDialogues < ActiveRecord::Migration
def change
add_column :dialogues, :further_negotiation, :boolean
add_column :dialogues, :won, :boolean
end
end
|
class ChangeIntegerLimitInCryptocurrencies < ActiveRecord::Migration[6.1]
def change
change_column :cryptocurrencies, :market_cap, :integer, limit: 8
change_column :cryptocurrencies, :total_volume, :integer, limit: 8
end
end
|
require 'rails_helper'
describe 'admin/dashboard/index' do
it 'renders the page header' do
render
expect(rendered).to match(%r{<h1>Dashboard<\/h1>})
end
end
|
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: :null_session
helper_method :current_employee
helper_method :random_pic
def current_employee
token = request.headers['a... |
require 'minitest/autorun'
require 'docopt'
class TestTokenStream < MiniTest::Unit::TestCase
def test_create_with_array
array = %w(a b c)
tokens = Docopt::TokenStream.new(array, nil)
array.each_with_index do |v, i|
assert_equal tokens[i], v
end
end
def test_create_with_string
array = ... |
class Category < ActiveRecord::Base
self.primary_key = :id_categoria
has_many :cursos, :class_name => 'Curso', :foreign_key => :id_categoria
end
|
# -*- mode: ruby -*-
# vi: set ft=ruby :
$script_ansible = <<-EOF
sudo apt update
sudo apt install -y software-properties-common
sudo add-apt-repository --yes --update ppa:ansible/ansible
sudo apt install -y ansible
EOF
$script_update = <<-EOF
sudo apt update
sudo apt upgrade -y
EOF
$hosts... |
FactoryGirl.define do
factory :text do
app { "app_#{rand(10000)}" }
context { "context_#{rand(10000)}" }
locale "sv-SE"
name { "name_#{rand(10000)}" }
mime_type "text/plain"
lock_version 0
usage ""
result "Moxie"
created_by "https://api.acme.com/v1/api_users/... |
# Used by mdb_server.rb
Maglev.persistent do
class AppModel
attr_reader :a, :b
def self.view_42(docs)
42
end
def self.view_67(docs, count, ary)
67 + count.to_i + ary.size
end
def self.view_53(documents)
53
end
def self.view_66(documents, count)
66 + count.to_i
... |
require 'thumbnail_setter'
class Video < ActiveRecord::Base
attr_accessible :video_url, :title, :skill_list, :thumbnail_url, :video_host, :video_id
validates :video_url, :presence => true
belongs_to :user
default_scope :order => 'created_at DESC'
acts_as_taggable
acts_as_taggable_on :skills
@@regex... |
class ChangeIntegersToStrings < ActiveRecord::Migration
def change
change_column :movies, :budget, :string
change_column :movies, :box_office_performance, :string
change_column :movies, :total_box_office, :string
end
end
|
class Search < ActiveRecord::Base
hobo_model # Don't put anything above this
before_save :clear_unneeded_comparison_attrs
DateComparison = HoboFields::EnumString.for :is, :before, :after, :is_not
KeywordComparison = HoboFields::EnumString.for :is, :above, :below, :is_not
fields do
name :string
tex... |
require 'rails_helper'
RSpec.describe Quarter, type: :model do
describe '.current_quarter' do
subject(:current_quarter) { described_class.current_quarter }
it '今日が含まれるクォーターが返されること' do
expect(current_quarter.start_date..current_quarter.end_date).to cover(Date.current)
end
end
describe '.find_o... |
module StrokeDB
module Util
# Usage: OptionsHash!(options); options.require("required_option")
# 1. Lets access string and symbol keys interchangebly.
# 2. Lets specify required keys.
def OptionsHash(hash, defaults = nil)
OptionsHash!(hash.dup, defaults)
end
def OptionsHash!(hash, d... |
SimpleSupport::Application.routes.draw do
mount RailsAdmin::Engine => '/admin', :as => 'rails_admin'
devise_for :users, controllers: {
sessions: 'users/sessions',
registrations: 'users/registrations'
}
root 'tickets#index'
resources :tickets, only: [:index, :show, :new, :create]
resources :supp... |
class ClientContact < ActiveRecord::Base
audited
belongs_to :client
belongs_to :state
belongs_to :city
belongs_to :client_contact_type
belongs_to :client_class
has_many :phone_users, :validate => false, dependent: :destroy
accepts_nested_attributes_for :phone_users, allow_destroy: true, :reject_if => proc { |... |
require 'pp'
input = File.readlines("../day21.in").map { |x| x.chomp.tr("/", "\n") }
# input = <<TEST
# ../.# => ##./#../...
# .#./..#/### => #..#/..../..../#..#
# TEST
# input = input.split("\n").map { |x| x.chomp.tr("/", "\n") }
$rules = {}
input.each do |line|
k, v = line.split " => "
$rules[k] = v
end
def ... |
# frozen_string_literal: true
class AccessTokenSerializer
include JSONAPI::Serializer
attributes :id, :token
end
|
class Store < ActiveRecord::Base
has_many :stations, :foreign_key => "major",
:primary_key => "major"
end
|
module Fakes
class CombinedArgMatcher
attr_reader :all_matchers
def initialize(options = {})
@all_matchers = options.fetch(:matchers, [])
end
def matches?(args)
matches = true
all_matchers.each_with_index do |matcher, index|
value = args[index]
matches &= matcher.m... |
# frozen_string_literal: true
module MondialRelay
module Labels
# An interface for *label* creation.
# Requests the {https://api.mondialrelay.com/Web_Services.asmx?op=WSI2_CreationEtiquette
# WSI2_CreationEtiquette} endpoint.
#
# Available creation params (*M* — mandatory, *O* — optional):
#
... |
require('rspec')
require('contact')
describe(Contact) do
before() do
Contact.clear()
end
describe('#name') do
it('returns the first name of the person') do
test_contact = Contact.new("Bob")
expect(test_contact.first_name()).to(ex("Bob Dylan"))
end
end
describe('#save') do
it('sa... |
Rails.application.routes.draw do
devise_for :users, controllers: {
sessions: 'users/sessions',
registrations: 'users/registrations'
}
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
root to: "recipes#index"
resources :recipes
resourc... |
# coding: utf-8
require 'spec_helper'
RSpec.describe Apress::Images::Imageable do
let(:image) { build :subject_image }
let(:dummy_filepath) { Rails.root.join('../fixtures/images/sample_image.jpg') }
before { allow(Apress::Images::ProcessJob).to receive(:enqueue) }
it { expect(image).to have_attached_file(:i... |
#!/usr/bin/env ruby
require_relative 'Element'
class Node < Element
attr_accessor :activatable
attr_accessor :input_arcs
attr_accessor :output_arcs
# e.g. of node_type = :transition
attr_accessor :node_type
# active_state = :activation or :deactivation
attr_accessor :active_state
... |
require_dependency "usermanagement/application_controller"
module Usermanagement
class AccountsController < ApplicationController
before_action :authenticate_user!
before_action :set_account, only: [:edit, :update, :destroy]
before_action :set_person, only: [:index, :new, :create]
skip_around_action... |
require 'rails_helper'
describe 'the Media', js: true do
init_site
it 'list media' do
admin_sign_in
visit "#{cama_root_relative_path}/admin/media"
within '#cama_media_gallery' do
execute_script('$(\'#cama_search_form .dropdown-toggle.btn\').click()')
find('.add_folder').click
end
... |
# frozen_string_literal: true
module Api
class WarsController < ApiController
include(WarHelper)
before_action :set_war, except: %i[index create]
before_action :war_editable?, only: %i[update create_times destroy_times]
after_action :verify_authorized, except: %i[index show index_times]
UserRedu... |
class PlantsAction < ApplicationRecord
belongs_to :plant, optional: true
belongs_to :action, optional: true
accepts_nested_attributes_for :action, :allow_destroy => true
validates_presence_of :action, :scope => :action_id, :message => "must have a checkbox checked first, before selecting a date"
validates_pre... |
require 'spec_helper'
describe Scheme do
describe "looking up schemes" do
before :each do
@sector = 'health'
@stage = 'start-up'
@size = 'under-10'
@support_types = %w(finance loan)
@location = 'wales'
GdsApi::ContentApi.any_instance.stub(:business_support_schemes).and_return... |
require 'rails_helper'
describe "a user logs in logs out", type: :feature do
fixtures :users
describe "the user who has an account logs in" do
before(:each) do
visit "/"
click_link("Create Account")
fill_in("user[email]", with: "J@gmail.com")
fill_in("user[user_name]", with: "Jeffy")
... |
require 'spec_helper'
require 'route_map'
describe RouteMap do
before do
@route_map = RouteMap.new(5,6)
end
it "should create a grid from size in constructor" do
expect(@route_map.valid_coords?(0,0)).to be_true
expect(@route_map.valid_coords?(5,6)).to be_true
expect(@route_map.valid_coords?(6 ,... |
class BansController < ApplicationController
# GET /bans
# GET /bans.xml
def index
@bans = Ban.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @bans }
end
end
# GET /bans/1
# GET /bans/1.xml
def show
@ban = Ban.find(params[:id])
... |
# frozen_string_literal: true
require 'pry'
require_relative 'board'
require_relative 'player'
require_relative 'displayable'
#
class Game
include Displayable
attr_accessor :player1, :player2, :current_player, :board
def initialize
@board = Board.new
@player1 = Player.new('Player 1', 'black')
@pla... |
class SentMail < ActiveRecord::Base
belongs_to :article
belongs_to :subscriber
attr_accessible :sent
after_commit :send_emails
private
# TODO: test this
def send_emails
# TODO: this might be problematically slow. Does a db query for every single committed sentmail.
unless sent
sent = Save... |
class EmailsController < ApplicationController
before_filter :instantiate_client
def index
@has_mails = $server.has_new_mail?(current_user)
new_mails = $server.new_mails(current_user) if @has_mails
@new_mails_length = new_mails.length if @has_mails
@emails = @client.downloaded_emails
end
def n... |
require_relative '../lib/csv_reader'
require_relative '../lib/exception'
puts "Enter file path name:"
file_path = gets.chomp
reader = CsvReader.new(file_path)
begin
reader.process
p reader.items
rescue InvalidExtensionError => e
puts e.message
rescue ClassAlreadyExistsError => e
puts e.message
rescue SpaceIns... |
# A comment, this is so you can read your program later.
# Anything after the # is ignoredby ruby.
puts "I could have code like this" # This will be ignored
#puts "This is not going to be printed"
puts "this will be printed"
|
class ApplicationController < ActionController::API
# Graphiti is a tool I'm using to help build a nice, conventional API
include Graphiti::Rails::Responders
# This is copy/pasted; it says that every controller supports both json and jsonAPI; jsonAPI is the particular format Graphiti's UI tool (vandal) uses. I u... |
#!/usr/bin/env ruby
def random_string
Array.new(36).map.with_index do|c,i|
case i
when 8, 13, 18, 23
'-'
else
(('a'..'z').to_a + ('0'..'9').to_a).sample(1)
end
end.join
end
while true
seconds = rand(1..10)
requests = rand(1..100)
STDERR.puts "#{requests} requests/s for #{seconds... |
class SceneTemplatesController < ApplicationController
before_action :set_scene_template, only: [:show, :edit, :update, :destroy]
# GET /scene_templates
# GET /scene_templates.json
def index
@scene_templates = SceneTemplate.all
end
# GET /scene_templates/1
# GET /scene_templates/1.json
def show
... |
require 'cgi'
# This class controls the active processors, and the window used to edit them.
class ProcessorsController < OSX::NSArrayController
# This is run once the NIB is loaded - i.e. when the application has
# completed starting.
def awakeFromNib
registerUriHook
end
# This registers the +getUri_w... |
class AddZoneToMicroposts < ActiveRecord::Migration
def self.up
add_column :microposts, :zone_id, :interger
execute(%q{
UPDATE microposts SET zone_id = 1
})
add_index "microposts", ["zone_id"], :name => "fk_index_microposts_zone_id"
end
def self.down
remove_column :microposts, :zone_id... |
describe 'adds slug when creating a profile' do
let!(:user) { Profile.create!(FactoryGirl.attributes_for(:published, firstname: 'Ada', lastname: 'Lovelace')) }
describe 'slug' do
it 'uses the user id' do
visit "/profiles/#{user.id}"
expect(page.status_code).to be(200)
end
it 'uses the user... |
class SupplyCondition < ActiveRecord::Base
OUT_OF_LENGTH = '資料長度超過限制'
NOT_EMPTY = '不能空白'
MUST_BE_INTEGER = '必須是整數'
validates :restaurant_id, :presence => { :message => "餐廳編號," + NOT_EMPTY } ,
:length => { :maximum => 11, :message => "餐廳編號," + OUT_OF_LENGTH } ,
... |
require 'rails_helper'
RSpec.describe "Routing to products", type: :routing do
it 'routes get /products to products#index' do
expect(get: "/products").to route_to("products#index")
end
it 'routes get /products/1 to products#show' do
expect(get: "/products/1").to route_to("products#show", id: "1")
end
... |
class ImagePost < Post
validates :url, presence: true
end
|
require 'socketry'
module ViolentRuby
# This Banner Grabber class is meant to provide a simple
# interface to, well... grab banners from services running
# on a target to determine the potential attack vectors
# avaialable to you.
# @author Kent 'picat' Gruber
#
# @example Basic Usage
# BannerGrabber... |
require 'spec_helper'
describe 'jchkmail::cdb' do
let :title do
'mycdb'
end
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts
end
context "with source parameter" do
let :params do
{
:source => '/location/mycdb'
... |
RSpec.describe 'Item show page' do
before(:each) do
@merchant = Merchant.create(name: 'Beer World')
@item = @merchant.items.create(name: "Turing Ale", description: "Beer", unit_price: 12, image: '../../images/capy-photo.jpg')
end
it 'should show item name' do
visit "/items/#{@item.id}"
expect(pag... |
Rails.application.routes.draw do
resources :folders
root to: "folders#index"
end
|
require_relative "../lib/game.rb"
require "pry"
RSpec.describe Pawn do
describe "#team" do
it "gives the corresponding color" do
pawn = WhitePawn.new("e4")
expect(pawn.team).to eql("white")
pawn = BlackPawn.new("e4")
expect(pawn.team).to eql("black")
end
end
describe "#show" do
... |
# Write a method that takes an Array of numbers and then returns the sum of the sums of each leading subsequence for that Array. You may assume that the Array always contains at least one number.
def sum_of_sums(arr)
sum_arr = []
index = 0
while index < arr.length
if index == 0
sum_arr[index] = arr[i... |
class CreateTextStyles < ActiveRecord::Migration[5.0]
def change
create_table :text_styles do |t|
t.string :korean_name
t.string :english
t.string :category #heaind, float, body
t.string :font_family
t.string :font
t.float :font_size
t.string :text_color
t.string... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.