text stringlengths 10 2.61M |
|---|
class VehicleType < ApplicationRecord
has_one :vehicle, class_name: Vehicle, foreign_key: :vehicle_type_id
end
|
class RestructureMatchingApp < ActiveRecord::Migration
def change
rename_column :users, :age, :birth_year
rename_column :touch_data, :numTouches, :num_touches
remove_column :users, :techExp, :integer
change_column :data_files, :data, :text
add_column :touch_data, :app_version, :string
add_colu... |
require_relative '../spec_helper'
require 'faker'
describe Station do
describe "station validations" do
it "invalid without a name" do
station = Station.create(dock_count: 22, city_id: 3, installation_date: "01/01/2017")
expect(station).to_not be_valid
end
it "invalid without a dock count" ... |
class InventoriesController < ApplicationController
before_filter :get_store
respond_to :html, :json
def index
@inventories = @store.inventories.order('created_at desc').limit(params[:limit])
respond_with @inventories
end
def show
@inventory = @store.inventories.find(params[:id])
@line_items... |
class Array
def merge_sort(&prc)
return self if self.length <= 1
prc ||= Proc.new { |a, b| a <=> b }
half = self.count / 2
left = self.take half
right = self.drop half
Array.merge(left.merge_sort(&prc), right.merge_sort(&prc), &prc)
end
private
def self.merge(left, right, &prc)
... |
require 'clamp'
require 'rack'
require 'eventmachine'
require 'thread'
require 'fileutils'
require 'mongoid'
require 'daemons'
require 'tmpdir'
require File.join SesProxy::ROOT, 'app', 'web_panel'
module SesProxy
class StartCommand < Clamp::Command
option ["-s","--smtp-port"], "SMTP_PORT", "SMTP listen port (d... |
# frozen_string_literal: true
module TTY
class Tree
# Render nodes as files paths explorer
class DirectoryRenderer
MARKERS = {
unicode: {
branch: '├──',
leaf: '└──',
pipe: '│'
},
ansi: {
branch: '|--',
leaf: '`--',
pipe... |
require 'nokogiri'
require 'open-uri'
module Curates
module Fetchers
module Paypal
BASE_URI = 'https://www.paypal.com/uk/cgi-bin/webscr?cmd=_manage-currency-conversion&amount_in=1¤cy_in=%s¤cy_out=%s¤cy_conversion_type=%s'.freeze
def self.current_rate src, dest, type = 'BalanceConve... |
require 'cloudformation_mapper/resource'
class CloudformationMapper::Resource::AwsResourceOpsworksStack < CloudformationMapper::Resource
register_type 'AWS::OpsWorks::Stack'
type 'Template'
parameter do
type 'Template'
name :Properties
parameter do
type 'List<Key>'
name :Attributes
... |
class TweetsController < ApplicationController
get "/tweets" do
if Helpers.is_logged_in?(session)
erb :"tweets/index"
else
redirect "/login"
end
end
get "/tweets/new" do
if Helpers.is_logged_in?(session)
erb :"tweets/new"
else
redirect "/login"
... |
# -*- coding: utf-8 -*-
#
# Cookbook Name:: mysql
# Recipe:: default
#
# Copyright 2014, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
execute "mysql-server-install" do
command "yum -y install mysql-server --enablerepo=remi"
action :run
not_if "rpm -q mysql-server"
end
file "/var/log/mysql... |
class AddStartsEndsToCompetition < ActiveRecord::Migration
def change
add_column :competitions, :starts, :datetime
add_column :competitions, :ends, :datetime
end
end
|
require "rails_helper"
module UnsFeeder
RSpec.describe FeedsController, type: :routing do
routes { UnsFeeder::Engine.routes }
describe "routing" do
it "routes to #create" do
expect(:post => "/feeds").to route_to("uns_feeder/feeds#create")
end
it "routes to #destroy" do
exp... |
require_relative "options.rb"
require_relative "download.rb"
require_relative "parser.rb"
require_relative "report.rb"
class SitemapChecker
include Options
include Download
include Parser
include Report
def check_sitemaps
args = get_args
index = download(args[:index]).body
... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Development environment for a Python package with Jupyter.
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/focal64"
config.vm.hostname = "chthonic"
# Set up port forwarding to work with Jupyter.
config.vm.network "forwarded_port", guest: 8888, hos... |
#
# Cookbook Name:: elk-hardis
# Recipe:: logstash
#
# Copyright (c) 2016 The Authors, All Rights Reserved.
include_recipe 'elk-hardis::user'
include_recipe 'elk-hardis::java'
rpm_name = 'logstash-2.4.0.noarch.rpm'
rpm_url = 'https://download.elastic.co/logstash/logstash/packages/centos/logstash-2.4.0.noarch.rpm'
r... |
class RepoActivator
attr_reader :errors
def initialize(github_token:, repo:)
@github_token = github_token
@repo = repo
@errors = []
end
def activate
change_repository_state_quietly do
if repo.private?
add_hound_to_repo && create_webhook && repo.activate
else
create_... |
class CreateAuditProcessActivities < ActiveRecord::Migration
def change
create_table :audit_process_activities do |t|
t.references :audit, index: true, foreign_key: true
t.references :audit_process, index: true, foreign_key: true
t.references :activity, index: true, foreign_key: true
t.boo... |
# The news article that we want reactions for
class Article < ApplicationRecord
validates :title, presence: true
validates :url, presence: true
has_many :reactions
end
|
# This migration comes from refinery_products (originally 4)
class AddSlugToProductsCategories < ActiveRecord::Migration
def up
add_column :refinery_products_categories, :slug, :string
end
def down
remove_column :refinery_products_categories, :slug
end
end |
# Problem 305: Reflexive Position
# http://projecteuler.net/problem=305
#
# Let's call S the (infinite) string that is made by concatenating the consecutive positive integers (starting from 1) written down in base 10.
# Thus, S = 1234567891011121314151617181920212223242...
#
#
# It's easy to see that any number w... |
=begin
Personal project to play around with some fantasy football stuff
example output (in descending order of preference)
$ ruby fantasy_football.rb qb
Robert Griffin III
Mike Glennon
Ryan Fitzpatrick
Austin Davis
Michael Vick
Blake Bortles
Derek Carr
=end
require 'rubygems'
require 'nokogiri'
require 'open-uri'
... |
class Recipe
attr_accessor :name
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def recipe_card
RecipeCard.all.select do |list|
list.recipe == self
end
end
def recipe_ingredient
RecipeIngredient.all.select do |list|
list.r... |
# encoding: utf-8
# Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
module MobileCenterApi
module Models
#
# Model object.
#
#
class AppRequest
# @return [String] A short text describing th... |
class Node
attr_accessor :value, :parent, :children
def initialize(value)
@value=value
@parent=nil
@children=[]
end
end |
Pod::Spec.new do |s|
s.name = 'mob_sharesdk'
s.version = "4.4.13"
s.summary = 'ShareSDK is the most comprehensive Social SDK in the world,which share easily with 40+ platforms.'
s.license = 'MIT'
s.author = { "mob" => "mobproducts@163.com" }
s.homepage ... |
require "trick/function"
RSpec.describe Trick::Function do
def args
[:a, "b", 1, nil, [], {}]
end
describe "::to_proc" do
it "returns a Proc" do
expect(ABC.to_proc).to be_a Proc
end
it "returns callable with arguments" do
expect(ABC.to_proc.call(*args)).to eq ABC.call(*args)
end... |
class ChangeColumnToInstructionsForRecipe < ActiveRecord::Migration
def change
rename_column :recipes, :instruction, :instructions
end
end
|
class EvenFibonacci
attr_reader :fib_seq
def initialize(num)
@num = num
@fib_seq = [1, 2]
end
def sequencer
@num.times do
@fib_seq << @fib_seq[-1] + @fib_seq[-2]
end
end
def print_evens
print "#{@fib_seq.select{ |f| f if f % 2 == 0}} \n"
end
def execute
sequencer
... |
class DropMerchantSidekickGateways < ActiveRecord::Migration
def up
drop_table :gateways
end
def down
create_table :gateways do |t|
t.string "name", :null => false
t.string "mode"
t.string "type"
t.string "login_id"
t.string "transaction_key"
t.dat... |
module LoginHelper
def already_logged_in
return unless helpers.logged_in?
flash[:info] = 'You are already logged in.'
redirect_to root_path
end
end
|
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
module TwitterCldr
module Transforms
class NotInvertibleError < StandardError; end
# Base class for all transform rules
class Rule
STRING_TYPES = [
:escaped_char, :unicode_char, :escaped_backslas... |
RSpec.describe ERBB::Result do
describe '#initialize' do
it 'saves second argument as named_blocks' do
named_blocks = { foo: 'bar' }
result = ERBB::Result.new('', named_blocks)
expect(result.named_blocks).to eq(named_blocks)
end
it 'symbolizes the keys in named_blocks' do
named_b... |
module AchClient
class Helpers
class Utils
# Given a list of hashes where the hashes values are lists, merge the
# list of hashes by appending the two lists when there is a key
# collision
# @param hashlist [Array(Hash{String => Array})]
def self.hashlist_merge(hashlist)
... |
#
# Cookbook Name:: bcpc
# Recipe:: mysql
#
# Copyright 2013, Bloomberg Finance L.P.
#
# 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
#
# Unless ... |
# frozen_string_literal: true
class Api::V1::PostsSearchesController < SearchController
POST_STATUS = Post::DEFINED_STATES
# postsを検索する
def search
return if too_many_keywords?
posts = Post.find_posts(keywords, post_status, author, turn_pages, max_content)
results = generate_results(posts, keywords... |
if defined?(Merb::Plugins)
$:.unshift File.dirname(__FILE__)
dependency 'merb-slices', :immediate => true
Merb::Plugins.add_rakefiles "icomme/merbtasks", "icomme/slicetasks", "icomme/spectasks"
# Register the Slice for the current host application
Merb::Slices::register(__FILE__)
# Slice configuration... |
require 'spec_helper'
describe Maestrano::Connector::Rails::Entity do
describe 'class methods' do
subject { Maestrano::Connector::Rails::Entity }
describe 'id_from_external_entity_hash' do
it { expect(subject.id_from_external_entity_hash({'id' => '1234'})).to eql('1234') }
end
describe 'last... |
require 'phony'
require 'phone_classifier/mobile'
require 'phone_classifier/forbidden'
class PhoneClassifier
# authorative info: http://www.itu.int/oth/T0202.aspx?parent=T0202
# Numbering schemes for mobile numbers
#
def initialize number
@number = number
end
def kind
case
when self.mobi... |
# == Schema Information
#
# Table name: tasks
#
# id :integer not null, primary key
# name :string(255)
# fulltext :text
# image_url :string(255)
# game_id :integer
# location :string(255)
# hint1 :text
# hint2 :text
# comments :text
# created_at :datetime no... |
class Tag < ApplicationRecord
has_many :taggings
has_many :tags, through: :taggings
has_many :listings, through: :taggings
validates :name, uniqueness: true
end
|
# frozen_string_literal: true
require "rails_helper"
describe EtsPdf::Parser::ParsedLine do
subject(:parsed_line) { described_class.new("some line") }
its(:line) { is_expected.to eq("some line") }
described_class::LINE_TYPES.each do |type, klass|
describe "##{type}" do
let(:mock_line) { instance_dou... |
require './lib/plane'
require './lib/weather'
class Airport
include Weather
attr_accessor :planes
attr_reader :capacity
DEFAULT_CAPACITY = 10
def initialize (capacity = DEFAULT_CAPACITY)
@planes = []
@capacity = capacity
end
def land(plane)
@plane = plane
fail "plane is already landed and cannot la... |
# Predicate Methods
number = 7
p number.odd?
p number.even?
p 10.even?
|
require 'erb'
module MemesHelper
def url_convert(string)
encoded_string = ERB::Util.url_encode(string)
encoded_string.gsub('%2C','%252C')
end
def getty_request(search)
url = URI.parse("https://api.gettyimages.com")
search_url = "/v3/search/images?fields=id,title,comp,referral_destinations&sort_order=best&... |
module Relational
module Strategies
NotFound = Class.new(NoMethodError)
module Factory
def self.for(options = {})
available_strategies.each do |strategy|
if strategy.applicable_for?(options)
return strategy.new(options)
end
end
raise RelationalSt... |
#!/usr/bin/env ruby
require 'json'
require 'rest-client'
def calculate_upvotes(story)
story[:upvotes] = 1
if story[:title].downcase.include?('iphone')
story[:upvotes] *= 5
elsif story[:title].downcase.include?('taco')
story[:upvotes] *= 8
end
if story[:category].downcase == 'tech'
story[:upvotes]... |
class ChangeColumnToItems < ActiveRecord::Migration[6.0]
def change
change_column_null :items, :name, false
change_column_null :items, :detail, false
change_column_null :items, :price, false
change_column_null :items, :item_condition, false
change_column_null :items, :postage, false
change_col... |
require 'spec_helper'
describe "transfer_slips/index" do
before(:each) do
assign(:transfer_slips, [
stub_model(TransferSlip,
:report => nil,
:debit => "Debit",
:debit_amount => 1,
:credit => "Credit",
:credit_amount => 2
),
stub_model(TransferSlip,
... |
# == Schema Information
#
# Table name: priorities
#
# id :integer(4) not null, primary key
# priority_name :string(255)
# priority_type :string(255)
# created_at :datetime
# updated_at :datetime
#
class Priority < ActiveRecord::Base
has_many :tickets
end
|
class Document < ActiveRecord::Base
belongs_to :class_section
attr_accessible :file, :title, :class_section, :mime_type
def the_file=(incoming_file)
self.title = incoming_file.original_filename
self.file = incoming_file.read
self.mime_type = incoming_file.content_type
end
def is_text
return self.... |
class RemoveColumnsFromCategories < ActiveRecord::Migration
def up
remove_column :categories, :video_id
end
def down
add_column :categories, :video_id, :integer
end
end
|
FactoryGirl.define do
factory :link do
url 'http://youtube.com'
link_type 'video'
end
end |
module Api
class ContactsController < ApplicationController
before_action :set_contact_by_key, only: [:showbykey, :update, :addvisit]
def index
@contacts = Contact.all
end
def showbykey
if !@contact
render json: { message: 'Not found.' }, status: :not_found
end
end
... |
class FontCourierPrime < Formula
head "https://quoteunquoteapps.com/courierprime/downloads/courier-prime.zip"
desc "Courier Prime"
homepage "https://quoteunquoteapps.com/courierprime/"
def install
parent = File.dirname(Dir.pwd) != (ENV['HOMEBREW_TEMP'] || '/tmp') ? '../' : ''
(share/"fonts").install "#... |
require 'open-uri'
module CDI
module V1
module Users
class UpdateService < BaseUpdateService
include V1::ServiceConcerns::UserParams
record_type ::User
def record_params
user_params
end
def user_can_update?
if user_params[:profile_type].presen... |
# frozen_string_literal: true
require "thor"
module WasteExemptionsShared
module Seeds
class Address < Thor
desc "counties", "Setup UK Royal Mail Counties"
method_option :commit, aliases: "-c", type: :boolean, required: false, desc: "Commit changes permanently"
# rubocop:disable Metrics/M... |
class PostsController < ApplicationController
before_action :authenticate_user!, except: :index
def index
@current_user = current_user
if current_user.nil?
@posts = Post.find_public_posts
else
user_ids = current_user.following.pluck(:id)
user_ids.push current_user.id
@posts = Pos... |
require './modules'
require './tf_idf'
using ArrayEx
using HashEx
using StringEx
def compile_words(input_files, word_table, source_files)
input_files.each do |file_name|
File.open(file_name) do |file|
basename = File.basename(file)
ngram = file.read.remove_url.remove_symbols.ngram(N.to_i)
word... |
class Registration < ActiveRecord::Base
belongs_to :order
has_one :card
accepts_nested_attributes_for :card
validates :full_name, :company, :email, :telephone, :quantity, presence: true
serialize :notification_params, Hash
def paypal_url(return_path)
values = {
business: "merchant@gotealeaf.com... |
class LessonsController < BaseController
before_action :set_lesson, only: [:show, :edit, :update, :destroy]
def index
@lessons= Lesson.all.order('id DESC').paginate(page: params[:page], per_page: 50)
end
def new
@lessons= Lesson.new
end
def show
end
def create
@lessons = Lesson.new(lesso... |
# frozen_string_literal: true
module Shreds
module Auth
USER_TOKEN = '_shreds_user_token'
def current_user
@current_user ||= User.where(token: session[USER_TOKEN]).first
rescue ActiveRecord::RecordNotFound
nil
end
def authenticated?
!current_user.nil?
end
def sign_out... |
Rails.application.routes.draw do
resources :sequences, only: [:new, :create, :show]
root "sequences#index"
end
|
class OrdersController < ApplicationController
before_action :set_order, only: [:show, :edit, :update, :destroy]
# GET /orders
# GET /orders.json
def index
if params[:name]
@orders = Order.search_any_word(params[:name])
else
@orders = Order.all
end
end
def set_price
@product = ... |
require "application_system_test_case"
class SalaryTypesTest < ApplicationSystemTestCase
setup do
@salary_type = salary_types(:one)
end
test "visiting the index" do
visit salary_types_url
assert_selector "h1", text: "Salary Types"
end
test "creating a Salary type" do
visit salary_types_url
... |
class CreateMessages < ActiveRecord::Migration[6.0]
def change
create_table :messages do |t|
t.string :content #テキストの内容:「content」カラム
t.references :room, foreign_key: true #メッセージの投稿をしたチャットルームのid:「room_id」カラム
t.references :user, foreign_key: true #メッセージの投稿をしたユーザーのid:「user_id」カラム
#roomとuserに... |
class Emphasis
attr_reader :input_text
def initialize (input_text)
@input_text = input_text
end
def chunker
text = @input_text
text.split("\n\n").join
end
def text_converter
new_converter = chunker.sub("*","<em>")
new_converter.sub("*","</em>")
end
end
|
require 'spec_helper'
describe Bullhorn::Rest::Entities, :vcr do
def self.describe_entity(name, owner_methods=false, immutable=false, &block)
describe name do
plural = name.to_s.pluralize
it ".#{plural} returns #{plural}" do
res = client.send plural
expect(res.data).to_not be_nil... |
class AddColumnHashcodeForBorads < ActiveRecord::Migration[5.2]
def up
execute <<-DDL
ALTER TABLE backlogs ADD COLUMN hashcode varchar(255) NOT NULL DEFAULT ''
DDL
end
def down
execute <<-DDL
ALTER TABLE backlogs DROP COLUMN hashcode varchar(255) NOT NULL DEFAULT ''
DDL
end
end
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Actions::Response::Success do
describe 'success?' do
it 'returns true' do
expect(described_class.new.success?).to be_truthy
end
end
end
|
require 'rufus-scheduler'
require 'thread'
class Schedular
attr_accessor :id, :time
def initialize(id,time)
@id = id
@time = time
change_into_valid_time_format
end
def start_it!
threads=[]
threads<<Thread.new{
scheduler = Rufus::Scheduler.new
scheduler.at @time do
... |
class CreateFriends < ActiveRecord::Migration
def change
create_table :friends do |t|
t.string :name, :limit => 100, :null => false
t.decimal :lat, :long, :precision => 15, :scale => 2, :null => false, :default => 0.0
t.timestamps
end
add_index :friends, [:lat, :long], :unique => t... |
class FoodItemsController < ApplicationController
before_action :current_user_must_be_owner, :only => [:edit, :update, :destroy]
def current_user_must_be_owner
@food_item = FoodItem.find(params[:id])
if @food_item.user != current_user
redirect_to root_url, :alert => "Not authorized for that."
en... |
class User < ActiveRecord::Base
attr_accessor :password
validates_presence_of :email, :password, :first_name, :last_name
before_save :encrypt_password
has_attached_file :profile_pic, :styles => { :medium => "300x300>", :thumb => "100x100>", :small => "411x274>", :large => "1280x854>" }, :default_url => "missin... |
module GPIO
class TrafficLight
attr_reader :red, :yellow, :green, :state
def initialize(params)
@red = GPIO::Led.new(pin: params[:red_pin])
@yellow = GPIO::Led.new(pin: params[:yellow_pin])
@green = GPIO::Led.new(pin: params[:green_pin])
eval (params[:state] ? params[:state].to_s : 'power_outage')
en... |
class AddDiCountInReportToObservationGroups < ActiveRecord::Migration
def self.up
add_column :observation_groups, :di_count_in_report, :integer
end
def self.down
remove_column :observation_groups, :di_count_in_report
end
end
|
# rspec spec -t type:collection
RSpec::Matchers.define_negated_matcher :exclude, :include
describe Array.new([1, 2, 3]), 'Array', type: :collection do
it '#include' do
expect(subject).to include(2)
expect(subject).to include(2,1)
end
it { is_expected.to exclude 4 }
it { is_expected.not_to include 4 }... |
class BadWords
def self.bad_words_list
@bad_words_list ||= if ENV['PIN1YIN1_BAD_WORDS_FILE']
File.read(ENV['PIN1YIN1_BAD_WORDS_FILE']).split
else
[]
end
end
def self.match?(s)
bad_words_list.each do |word|... |
require File.expand_path('../../../spec_helper', __FILE__)
describe "Array#count" do
it 'returns count of elements' do
[1, :two, 'three'].count.should == 3
end
it 'returns count of elements that equals given object' do
[1, 'some text', 'other text', 2, 1].count(1).should == 2
end
it 'returns count ... |
class ProfilesController < ApplicationController
def show
@profile = authorize Profile.friendly.find(params[:id])
set_meta_tags title: "#{@profile.slug} | Profile",
description: "#{@profile.owner_type} profile page",
index: true,
follow: true
@members... |
require 'json'
require 'yaml'
class Config
# MQTT Config
class Mqtt
attr_reader :host, :password, :username
def initialize(config)
raise "'mqtt' config section is an array and not a hash" if config.kind_of?(Array)
@host = config['host']
@username = config['username']
@password ... |
# == Schema Information
#
# Table name: providers
#
# id :integer not null, primary key
# name :string(255)
# url_main :string(255)
# source :string(255) default("manual")
# name_for_link :string(255)
# ... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
# root to: 'recipes#index'
# resources :recipes, only: [:index]
# a suggestion by someone online (to generate an API namespace)
namespace :api do
# root to: 'recipes#index... |
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "prodder/version"
Gem::Specification.new do |s|
s.name = "prodder"
s.version = Prodder::VERSION
s.authors = ["Kyle Hargraves"]
s.email = ["pd@krh.me"]
s.homepage = "https://github.com/enova/prodder"
s.lic... |
require 'rails_helper'
RSpec.describe PurchasesController, type: :controller do
let!(:user) { create(:user) }
describe 'GET #index' do
context 'when logged' do
before { session[:user_id] = user.id }
let!(:purchases) { create_list(:purchase, 3) }
before { get :index }
it 'return all ... |
class GroceryListItemList < ActiveRecord::Base
has_many :grocery_lists
has_many :grocery_list_items
has_many :ingredients, through: :grocery_list_items
end
|
class NoClasificable < Llamada
validates_presence_of :concepto_de_la_llamada, :message => "no debe ser vacío"
end
|
class CreateSettings < ActiveRecord::Migration[6.0]
def change
create_table :settings do |t|
t.string :password
t.string :qiniu_base_url
t.string :qiniu_access_key
t.string :qiniu_secret_key
t.timestamps
end
end
end
|
# The Greek mathematician Nicomachus devised a classification scheme for natural numbers, identifying each as belonging
# uniquely to the categories of abundant, perfect, or deficient.
# A perfect number equals the sum of its positive divisors — the pairs of numbers whose product yields the target number,
# exclu... |
#This class is the parent for the actions for API Rest
class ApiController < ActionController::API
rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found
def record_not_found
render json: {
body: 'RecordNotFound'
}, status: 404
end
#Render JSON with response for a single object
... |
# Copyright 2019 The inspec-gcp-cis-benchmark Authors
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... |
Nucleotides = %w[A C G T]
def complement(nuc_idx)
3 - nuc_idx
end
SNVContext = Struct.new(:flank_5, :mid_before, :flank_3, :mid_after) do
def self.from_string(str)
flank_5, mid_before, mid_after, flank_3 = str.upcase.match(/^([ACGT])\[([ACGT])\/([ACGT])\]([ACGT])$/i).values_at(1,2,3,4).map{|nuc| Nucleotides.i... |
### Organizing Nested Data
# I have a collection of Programming Languages.
languages = {
:oo => {
:ruby => {
:type => "interpreted"
},
:javascript => {
:type => "interpreted"
},
:python => {
:type => "interpreted"
},
:java => {
:type => "compiled"
}
},
:f... |
ActiveAdmin.register Vehicle do
menu :parent => "Assets", :if => proc{ can?(:manage, Vehicle) }
controller.authorize_resource
index do
column :id
column "Vehicle", :sortable => :make do |v|
link_to v.make + ' ' + v.model, admin_vehicle_path(v)
end
column :year
column :checked_out
... |
require_relative '../spec_helper'
describe Talis::Bibliography::Work do
before do
Talis::Authentication::Token.base_uri(metatron_oauth_host)
Talis::Bibliography::Work.client_id = metatron_client_id
Talis::Bibliography::Work.client_secret = metatron_client_secret
Talis::Bibliography::Work.base_uri(met... |
class ChangeMerchantInitialStatus < ActiveRecord::Migration
def up
change_column_default :merchants, :status, "unconfirmed"
Merchant.where(:status => 'created').update_all(:status => 'unconfirmed')
end
def down
change_column_default :merchants, :status, "created"
Merchant.where(:status => 'unconf... |
class User < ApplicationRecord
has_secure_password
validates :email, presence: true, uniqueness: true
has_many :list_items
has_many :experiences, through: :list_items
end
|
Rails.application.routes.draw do
resources :users do
resources :trips
end
resources :trips do
resources :stops
resources :flights
resources :activities
resources :accommodations
end
resources :reviews
root 'home#index'
get '/login', to: 'sessions#new'
post '/login', to: 'sessi... |
ENV['RAILS_ENV'] ||= 'test'
require 'rails_helper.rb'
feature "Searching in Gwords" do
scenario "Searching for a word" do
When "I go to Translantions page" do
page.visit "/translations"
end
And "I search Haus" do
page.fill_in "search", with: 'Haus'
end
And "I click search" do
p... |
class AddBooleanToHighlights < ActiveRecord::Migration
def change
add_column :highlights, :highlighted, :boolean
add_column :highlights, :session_id, :string
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.