text stringlengths 10 2.61M |
|---|
require "bundler"
begin
Bundler.setup
Bundler::GemHelper.install_tasks
rescue
raise "You need to install a bundle first. Try 'thor version:use 3.2.13'"
end
require 'yaml'
require 'rspec'
require 'rspec/core/rake_task'
require 'cucumber/rake/task'
desc "Run all examples"
RSpec::Core::RakeTask.new(:spec) do |t|
... |
# frozen_string_literal: true
require "rails_helper"
module ThinkFeelDoDashboard
module SocialNetworking
RSpec.describe ProfileQuestionsController, type: :controller do
routes { Engine.routes }
describe "GET edit" do
context "for authenticated users" do
let(:group) { instance_doubl... |
module StormFury
class Server
attr_reader :attributes, :options
attr_accessor :service
def self.create(attributes, options = {})
server = new(attributes, options)
server.create
end
def initialize(attributes, options = {})
@attributes = attributes
@options = options... |
class TracksController < ApplicationController
# GET /tracks
# GET /tracks.json
def index
@tracks = Track.joins(:ratings).includes(:ratings).order('tracks.updated_at desc')
@recent = Lastfm.recent
end
# GET /tracks/1
# GET /tracks/1.json
def show
if params[:artist].present?
@api = Lastf... |
module Kilomeasure
# Loads a measure definition and the formulas associated with it.
#
class MeasureLoader < ObjectBase
fattrs :data_path
attr_reader :data,
:measure
def initialize(*)
super
self.data_path ||= DATA_PATH
end
def each_measure_from_file
Dir["#{... |
class HomeController < ApplicationController
before_action :basic_http_auth
def index
@pictures = Picture.order(:created_at)
if params[:query]
@pictures = @pictures.where("title ilike ? OR description ilike ?",
"%#{params[:query]}%", "%#{params[:query]}%")
end
... |
class Review < ApplicationRecord
validates :body, :user_id, :restaurant_id, null: false
belongs_to :user
belongs_to :restaurant
end
|
require_relative '../support/helpers/helper'
RSpec.describe PagseguroRecorrencia do
before(:each) do
new_configuration
end
context 'when call get_card_brand() method' do
it 'when pass a correct bin' do
bin = '411111'
response = PagseguroRecorrencia.get_card_brand(bin)
expect(response.c... |
class IHGRewardsWebsite
include PageObject
include DataMagic
page_url FigNewton.ihg_rewards_website
a(:ihg_logo, :id => 'idHeaderLogo')
def wait_for_ihg_website
wait_until do
ihg_logo_element.visible?
end
end
end |
module GapIntelligence
# @see https://api.gapintelligence.com/api/doc/v1/advertisements.html
module Advertisements
# Requests a list of advertisements
#
# @param params [Hash] parameters of the http request
# @param options [Hash] the options to make the request with
# @yield [req] The Faraday r... |
class ChangeDataTypeForGcacheResult < ActiveRecord::Migration
def up
change_table :gcaches do |t|
t.change :result, :text
end
end
def down
change_table :gcaches do |t|
t.change :result, :string
end
end
end
|
require './models/book'
require './serializers/book_serializer'
get '/ ' do
'Welcome to BookList!'
end
namespace '/api/v1' do
efore do
content_type 'application/json'
end
helpers do
def base_url
@base_url ||= "#{request.env['rack.url_scheme']}://{request.env['HTTP_HOST']}"
end
def jso... |
FactoryGirl.define do
factory :guest do
email 'guest@forecast.com'
password 'password'
first_name 'Guest'
last_name 'Forecast'
image 'image-url'
sex 'Male'
birthday '2015-01-30'
username 'username'
end
end |
class RemoveCommunityFromParticipants < ActiveRecord::Migration
def up
remove_column :participants, :community
end
def down
add_column :participants, :community, :string
end
end
|
require 'rails_helper'
RSpec.describe Api::V1::UsersController, type: :controller do
let(:user) { create(:user) }
describe 'PATCH /user' do
context 'successful update' do
it "reponds with suceess" do
api_user user
patch :update, {}
expect(response).to be_success
end
... |
require 'open-uri'
require 'nokogiri'
module LeagueGrabber::GetTable
def get_league_table # Get me Premier League Table
url = 'http://www.bbc.co.uk/sport/football/tables'
doc = Nokogiri::HTML.parse(open url)
teams = doc.search('tbody tr.team')
keys = teams.first.search('td').map do |k|
k['class'].gsub('... |
require('minitest/autorun')
require('minitest/rg')
require_relative('../fish.rb')
require_relative('../river.rb')
require_relative('../bears.rb')
class BearsTest < MiniTest::Test
def setup()
@bears = Bears.new("Beatrice", "Grizzly")
@fish1 = Fish.new("salmon")
@fish2 = Fish.new("sturgeon")
@fish3 =... |
class CharactersCreateConversations < ActiveRecord::Migration
def change
create_table :conversations do |t|
t.string :code, null:false
t.boolean :initial, default:false
t.boolean :repeatable, default:false
t.text :results
end
add_index :conversations, :code, unique:true
end
end
|
require 'rails_helper'
RSpec.describe Note, type: :model do
it { should belong_to(:user) }
it { should have_many(:taggings) }
it { should have_many(:tags).through(:taggings) }
context "callback methods" do
before(:each) do
@user = User.create(
email: 'foobar@foobar.com',
password: 'f... |
class AddImageToRetails < ActiveRecord::Migration[5.2]
def change
add_column :retails, :retail_image, :string
end
end
|
RSpec.describe Kalculator::Formula do
describe "contains" do
context "with strings" do
it "returns true when there is a match" do
expect(Kalculator.evaluate("contains(\"ohai\", \"oh\")")).to eq(true)
end
it "returns false when there is no match" do
expect(Kalculator.evaluate("co... |
class CommentsController < ApplicationController
before_action :find_deck # before executing any action find the deck we are working with,
# no need to specify an 'only' since we want to get the deck on each operation
before_action :find_comment, only: [:edit, :update, :destroy] # same as abov... |
class Post < ActiveRecord::Base
# I am using active record to validate user input
#is invalid with no title
#is invalid when content is too short or too long
#is invalid if its not one of the predefined categories
#is invalid if not clickbait
validates :title, presence: true
validates :content, length: { minimum: 100... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Filterable do
it 'filters by params' do
create_list(:repository_index, 5)
result = Repository.all
expect(result.filter(language: 'ruby', deployable: 'true', dependency: 'existence', monitorable: 'true', tested: 'true', documented: 'fals... |
# frozen_string_literal: true
class GradeSerializerV2 < ActiveModel::Serializer
attribute :lesson_uid, key: :lesson_id
attributes :student_id, :deleted_at, :skill_id, :mark
belongs_to :student
belongs_to :lesson
belongs_to :grade_descriptor
end
|
# frozen_string_literal: true
class MoveAttendanceWebPushFromMemberToUser < ActiveRecord::Migration[7.0]
def change
add_reference :attendance_webpushes, :user
AttendanceWebpush.all.each do |awp|
awp.user_id = Member.find(awp.member_id).user_id
end
remove_column :attendance_webpushes, :member_id... |
require 'rails_helper'
RSpec.describe 'User', type: :model do
it 'is not valid without an email' do
user = User.new(password: '123456')
expect(user.save).to be(false)
end
it 'is not valid without an password' do
user = User.new(email: 'p@gmail.com')
expect(user.save).to be(false)
end
it 'is s... |
class Blog < ApplicationRecord
validates :first_name, :last_name, :phone, :email, :country, :presence => true
end |
# Longest String
# I worked on this challenge [by myself].
# longest_string is a method that takes an array of strings as its input
# and returns the longest string
#
# +list_of_words+ is an array of strings
# longest_string(list_of_words) should return the longest string in +list_of_words+
#
# If +list_of_words+ is ... |
require 'binary_heap'
class PriorityQueue
include BinaryHeap
def initialize max_heap=false
@elements = []
@is_min_heap = !max_heap
end
def pop
@elements.shift
end
# I need to be able to keep track of the elements
# While their positions change, we still need to be able to access the actual ... |
require File.expand_path(File.join(File.dirname(__FILE__), '../spec_helper'))
require File.expand_path(File.join(File.dirname(__FILE__), '../app'))
module InterestsViaForumSpecHelper
def setup_mocks
@forum = mock('Forum')
@forum_interests = mock('forum_interests assoc')
Forum.stub!(:find).and_return(@for... |
Given (/^my HTTP basic auth credentials are incorrect$/) do
@basic_auth_user = 'INCORRECT_USER_NAME'
@basic_auth_password = 'INCORRECT_USER_PASSWORD'
end
Given (/^I use a service broker with a bad Conjur URL$/) do
@service_broker_host = 'http://service-broker-bad-url:3001'
end
Given (/^I use a service broker wi... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
require "./lib/etiqueta.rb"
class Menu
def initialize(nombre, &block)
@nombre = nombre
@desayunos = []
@almuerzos = []
@cenas = []
if block_given?
if block.arity == 1
yield self
else
instance_eval(&block)
end
end
end
def titulo(name)
@titulo = nam... |
class NutritionalInfo < ApplicationRecord
belongs_to :ingredient
belongs_to :added_by, class_name: 'User'
has_many :derived_measurements
has_many :recipe_steps, as: :info_or_measurement, dependent: :destroy
has_many :report_cases, as: :reported, dependent: :destroy
end
|
require File.dirname(__FILE__) + "/../spec_helper"
describe Preflight::Rules::PageBoxWidth do
it "should pass files with a correctly sized MediaBox defined by Float points" do
filename = pdf_spec_file("pdfx-1a-subsetting")
rule = Preflight::Rules::PageBoxWidth.new(:MediaBox, 595.276, :pts)
PDF::Rea... |
# -*- coding: utf-8 -*-
require 'pukiwikiparser'
class PukiwikiFilter < TextFilter
description_file File.dirname(__FILE__) + "/../pukiwiki.html"
# このメソッドで入力値を変換します。
def filter(text)
pukiwiki = PukiWikiParser.new(Logger.new(STDOUT))
return pukiwiki.to_html(text, "dummypagename")
text
end
end
|
feature 'testing framework' do
scenario 'index page loads and capybara works' do
visit('/')
expect(page.status_code).to be(200)
end
end
|
class HadoopInstance < ActiveRecord::Base
attr_accessible :name, :host, :port, :description, :username, :group_list
belongs_to :owner, :class_name => 'User'
has_many :activities, :as => :entity
has_many :events, :through => :activities
has_many :hdfs_entries
validates_presence_of :name, :host, :port
afte... |
class WorkspacePresenter < Presenter
delegate :id, :name, :summary, :owner, :archiver, :archived_at, :public, :image, :sandbox, :permissions_for, :has_added_member,
:has_added_workfile, :has_added_sandbox, :has_changed_settings, to: :model
def to_hash
if rendering_activities?
{
:id =... |
require './helpers/persistence_handler'
class VagrantControl
FILENAME = 'Vagrantfile'
def initialize
@persistence_handler = PersistenceHandler.new
end
def log_path?
@persistence_handler.logfile?.value
end
def startup_command?
('vagrant up >> ' + log_path?)
end
def login_command?
('... |
module Extensions
module Authenticatable
def self.included(base)
base.class_eval do
############# CONFIGURATION #############
# Include default devise modules. Others available are:
# :token_authenticatable, :omniauthable
devise :database_authenticatable, :registe... |
class ConfirmationMailer < ActionMailer::Base
def confirm_email(target_email,activation_token)
@activation_token = activation_token
mail(to: target_email,
body:"http://localhost:3000/sessions/#{@activation_token}/edit",
content_type:"text/html",
subject: "text confirmation",
template_path: "confirmatio... |
require 'rails_helper'
RSpec.describe HomeController, :type => :controller do
let(:user) { FactoryGirl.create(:user) }
describe "get index page" do
describe "with no session" do
before { get :index }
it "should redirect to sign_in page" do
expect(response).to redirect_to new_user_session... |
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{vertica}
s.version = "0.8.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_r... |
class EndecaRecordChange < ActiveRecord::Base
####
# MODEL ANNOTATIONS
####
extend ValidationHelper
####
# VALIDATORS
####
validates_presence_of :review_id
validates_presence_of :product_id
enum_validator :change, [:replace, :delete]
enum_validator :status, [:new, :processing, :succ... |
class ChargesController < ApplicationController
before_action :authenticate_user!
def free
project = Project.find(params[:project_id])
current_user.subscriptions.create(project: project)
redirect_to project
end
def create
project = Project.find(params[:project_id])
# Create the customer ... |
require "application_system_test_case"
class ErrorsTest < ApplicationSystemTestCase
test "visit 404 page" do
visit '404'
assert_text '404'
end
test "visit 422 page" do
visit '422'
assert_text '422'
end
test "visit 500 page" do
visit '500'
assert_text '500'
end
end
|
Rails.application.routes.draw do
resources :places
devise_for :users, controllers: { registrations: 'registrations', passwords: 'passwords' },
path: '', path_names: { confirmation: 'verification', unlock: 'unlock', sign_in: 'login', sign_out: 'logout', sign_up: 'sign_up' }
resources :users
... |
class Post < ApplicationRecord
belongs_to :user
belongs_to :zemi
has_many :favorites
default_scope -> { order(created_at: :desc)}
validates :title, presence: true
validates :member, presence: true
validates :research_title, presence: true
validates :research_content, presence: true
validates :applicat... |
require 'rubygems'
require 'ruby-processing'
class Sketch<Processing::App
def setup
size 200,200
background 255
smooth
end
def draw
r, g, b, a = random(255), random(255), random(255), random(255)
diam = random(20)
x, y = random(width), random(height)
no_stroke
fill r, g, b, a
... |
class PokeLoc < ApplicationRecord
include Mongoid::Document
include Mongoid::Timestamps
include Location
include PokemonRef
field :tol, type: Time
field :pop2nd, type: Boolean
field :iv_a, type: Integer
field :iv_d, type: Integer
field :iv_s, type: Integer
field :weight, type: Float
field :height,... |
# Application controller
# Base for all controllers
class ApplicationController < ActionController::Base
include Pundit
protect_from_forgery with: :exception
before_action :require_login, :set_locale, :set_paper_trail_whodunnit
responders :flash
def self.default_url_options
{ locale: I18n.locale }
en... |
class CategoriesController < ApplicationController
before_filter :admin_required, :except => [:index, :show]
add_breadcrumb I18n.t('title.categories'), :categories_path
def index
@categories = Category.all
end
def new
add_breadcrumb I18n.t('title.add_category'), :new_category_path
@category ... |
require( 'minitest/autorun' )
require( 'minitest/rg')
require_relative( '../song.rb')
class TestSong < MiniTest::Test
def setup
@song = Song.new(1, "The Gambler", "Kenny Rogers")
end
def test_song_can_be_created
assert_equal(Song, @song.class)
end
def test_get_track_id
assert_equal(1, @song.... |
module QueryMethodsExtend
module OrExtend
@is_query_or = false
def set_is_query_or value
@is_query_or = value if self.where_values.size > 0
self
end
def where!(opts, *rest)
if Hash === opts
opts = sanitize_forbidden_attributes(opts)
references!(ActiveRecord::Predica... |
class Lost < ActiveRecord::Base
belongs_to :category
belongs_to :user
has_many :comments, :as => :commentable
validates_presence_of :title
validates_presence_of :location
mount_uploader :lost_img, StuffImageUploader
include PgSearch
pg_search_scope :search, :against => [:name, :location, :descri... |
require 'pathname'
module RhevmDescriptor
def d_init
# Make sure this is a descriptor.
desc, defs = parseDescriptor(dInfo.Descriptor)
# Make sure each disk is there.
defs.each do|diskDef|
filename = buildFilename(diskDef[:filename])
raise "No disk file: #{filename}" unless File.exist?(fi... |
require "application_system_test_case"
class MealPlansTest < ApplicationSystemTestCase
setup do
@meal_plan = meal_plans(:one)
end
test "visiting the index" do
visit meal_plans_url
assert_selector "h1", text: "Meal Plans"
end
test "creating a Meal plan" do
visit meal_plans_url
click_on "... |
require './lib/craft'
#
#
class Person
attr_reader :name, :interests, :supplies
def initialize(info)
@name = info[:name]
@interests = info[:interests]
@supplies = {}
end
def add_supply(material, quantity)
@supplies[material] ||= 0
@supplies[material] += quantity
end
def can_build?(cr... |
require 'logger'
require 'utilrb/logger'
module Orocos
def self.log_all
log_all_ports
log_all_configuration
end
# Setup logging on all output ports of the processes started with Orocos.run
#
# This method is designed to be called within an Orocos.run block
#
# @param [nil,#=... |
require 'spec_helper_acceptance'
case fact('osfamily')
when 'RedHat'
package_name = 'elasticsearch'
service_name = 'elasticsearch'
when 'Debian'
package_name = 'elasticsearch'
service_name = 'elasticsearch'
when 'Suse'
package_name = 'elasticsearch'
service_name = 'ela... |
class Food < ApplicationRecord
include FoodSearchable
has_many :categories_foods
has_many :categories, through: :categories_foods
has_one :food_information, inverse_of: :food
belongs_to :source
belongs_to :user
enum status: { pending: :pending, published: :published, unpublished: :unpublished }
end
|
require "aethyr/core/actions/commands/put"
require "aethyr/core/registry"
require "aethyr/core/input_handlers/command_handler"
module Aethyr
module Core
module Commands
module Put
class PutHandler < Aethyr::Extend::CommandHandler
def self.create_help_entries
help_entries = []... |
class Mailer < ActionMailer::Base
default from: "admin@globalnames.org"
def queue_email(upload)
@upload = upload
mail(:to => @upload.email, :subject => "Global Names PostBox upload") do |format|
format.html
format.text
end
end
def preview_email(upload)
@upload = upload
mail(:... |
require 'rails_helper'
describe 'maps' do
context 'categories with addresses' do
before do
bob = Admin.create(email: 'a@example.com', password: '12345678', password_confirmation: '12345678')
login_as bob
visit '/categories/new'
fill_in 'Title', with: 'Pic1'
fill_in 'Description', with: 'Lorem Ipsu... |
module CollectionsHelper
def disable_collection_button(collection = nil)
conditions = collection.disabled || collection.disabled == nil if collection
if conditions
text = ' Enable'
css_class = "btn-success fa fa-check-circle"
else
text = ' Disable'
css_class = "btn-danger fa fa-ban... |
require 'test_helper'
class JugadalotsControllerTest < ActionDispatch::IntegrationTest
setup do
@jugadalot = jugadalots(:one)
end
test "should get index" do
get jugadalots_url
assert_response :success
end
test "should get new" do
get new_jugadalot_url
assert_response :success
end
t... |
=begin
PEDAC
Data structure
Input: string
Output: Boolen
Create a hash with letters of the laphabet and corresponding blocks
Algorithm
iterate throught the letters of the word
Use the hash to find the corresponding block
Push the block into an array
Compare the array with the unique version of the array
=end
SPEL... |
class CreateFeedUpdates < ActiveRecord::Migration
def change
create_table :feed_updates do |t|
t.integer :user_id, null: false
t.integer :entry_id, null: false
t.string :entry_type
t.timestamps
end
add_index :feed_updates, :user_id
end
end
|
require 'spec_helper'
describe AvatarHelper do
before(:all) do
@me = Factory.build(:normal_person, :first_name => "My", :last_name => "Self")
@me.id = 1
@registered_user = Factory.build(:registered_user, :first_name => "Someone", :last_name => "Else", :id => 13)
@registered_user.id = 13
@invalid_... |
movies = {
matrix: 5,
avengers: 5,
captain_marvel: 5
}
puts "Enter a Choice, add, update, display, delete"
choice = gets.chomp
case choice
when "add"
puts "Enter a Movie Title"
title = gets.chomp
puts "Enter Rating for Movie"
rating = gets.chomp
if (movies[title.to_sym] == nil)
movies[titl... |
class EmployeesController < ApplicationController
before_action :set_employee, only: [:show, :destroy]
def index
@employee = Employee.new
@employees = Employee.all
end
def show
end
def create
@employee = Employee.new(employee_params)
if @employee.save
render json: @employee, status... |
class User < ApplicationRecord
has_secure_password
validates :first_name, :last_name, :username, :password_digest, presence: true
validates :username, uniqueness: true
end
|
require 'spec_helper'
require 'active_fedora/registered_attributes'
describe 'ActiveFedora::RegisteredAttributes' do
class MockDelegateAttribute < ActiveFedora::Base
include ActiveFedora::RegisteredAttributes
has_metadata :name => "properties", :type => ActiveFedora::SimpleDatastream do |m|
m.field "t... |
require 'spec_helper'
Run.tg(:read_only) do
use_pacer_graphml_data(:read_only)
describe Pacer::Filter::LoopFilter do
describe '#loop' do
it 'is a ClientError if no control block is specified' do
lambda do
graph.v.loop { |v| v.out }.in.to_a
end.should raise_error Pacer::ClientEr... |
# Public: Takes two numbers and returns the potency.
#
# base - The Integer that will be the base.
# exponent - The Integer that will be the exponent.
#
# Examples
#
# power(3, 2)
# # => 9
#
# Returns the potency of the given numbers.
def power(base, exponent)
if exponent == 0
return 1
end
... |
require "forwardable"
# This is a value object that represents a pair of engineers since there is no identity associated with
# the combination of two engineers, the pair of those engineers should be equal to the pair of the same
# engineers.
#
# See Pairing for how instances of pairs are stored.
class Pair
include ... |
get '/signup/?' do
erb :signup_form
end
post '/signup/?' do
if /.+@.+\..+/i.match(params[:user][:email]).nil?
flash[:danger] = 'The email address you entered seems to be invalid. Please try again.'
redirect '/signup'
elsif !User[email: params[:user][:email]].nil?
flash[:info] = "The email address #{params[:... |
class Gpsd < Formula
desc "Global Positioning System (GPS) daemon"
homepage "http://catb.org/gpsd/"
url "https://download.savannah.gnu.org/releases/gpsd/gpsd-3.17.tar.gz"
sha256 "68e0dbecfb5831997f8b3d6ba48aed812eb465d8c0089420ab68f9ce4d85e77a"
bottle do
cellar :any
sha256 "89237ff11349f301e4a41a9f1d... |
require "rails_helper"
RSpec.describe NewsLease, type: :model do
context "associations" do
it {is_expected.to belong_to(:user)}
it {is_expected.to belong_to(:category)}
it {is_expected.to belong_to(:place)}
it {is_expected.to belong_to(:image)}
end
end
|
module GroupDocs
class Signature
#
# Envelope and template entities share the same set of recipient methods.
#
# @see GroupDocs::Signature::Envelope
# @see GroupDocs::Signature::Template
#
module RecipientMethods
include Api::Helpers::SignaturePublic
#
# Returns recipie... |
class AddPriorityToSettings < ActiveRecord::Migration[5.2]
def change
add_column :settings, :priority, :integer
add_column :maintenance_histories, :priority, :integer
add_column :user_car_settings, :priority, :integer
end
end
|
class CreateGivs < ActiveRecord::Migration
def change
create_table :givs do |t|
t.string 'title'
t.string 'permalink'
t.text 'description'
t.string 'category'
t.string 'subcategory'
t.string 'tag'
t.integer 'quantity', default:1
t.float 'cost'
t.integer 'produ... |
# vim: ts=2 sts=2 et sw=2 ft=ruby fileencoding=utf-8
require "spec_helper"
describe DMM::Response do
before :all do
stub_get.to_return(xml_response("com.xml"))
@response = DMM::new.item_list
end
describe "Response" do
subject { @response }
it { should respond_to(:request) }
it { should respo... |
class Messenger
def self.send_message(number, message, from_number: ENV.fetch('PHONE_NUMBER'), logger: nil)
account_sid = ENV.fetch("TWILIO_ACCOUNT_SID")
auth_token = ENV.fetch("TWILIO_AUTH_TOKEN")
client = Twilio::REST::Client.new(account_sid, auth_token)
logger.info %("Sending message \"#{message}... |
module RollbarAPI
class Client
module Items
def get_item(item_id)
get("/item/#{item_id}")
end
def item_by_counter(counter)
get("/item_by_counter/#{counter}")
end
def all_items
get('/items/')
end
def update_item(item_id, options = {})
p... |
class CreateHaircontrols < ActiveRecord::Migration
def change
create_table :haircontrols do |t|
t.string "userid"
t.float "capFitTemperature"
t.float "coolDownTime"
t.datetime "timedate"
t.float "maxAlarmTemperature"
t.float "minAlarmTemperature"
t.float "postCoolTime"
t.float "railVolt... |
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
has_many :tetsukyojins
has_many :red_uruhuramaiters
... |
module BaseballPress
module Players
extend self
extend Download
def stats(game_date)
season = game_date.season
games = game_date.games
url = "http://www.baseballpress.com/lineups/%d-%02d-%02d" % [game_date.year, game_date.month, game_date.day]
doc = download_file(url)
css = ... |
class ID
attr_accessor :id, :content
def initialize(id,content)
@id = id
@content = content
end
#cette fonction nous renvoie un array d'objets comment avec tous les commentaires stockes dans le fichier csv
def self.all
id_array = [] #on initialise un array vide
CSV.read("./db/ids.csv").each do |line|
... |
#!/usr/bin/env ruby
require 'sinatra'
require 'fileutils'
require 'rmagick'
get '/:image' do |image|
requested_file = "/Users/C453/Desktop/#{image}"
if File.exists?(requested_file)
puts "Recieved GET for #{requested_file}"
content_type 'image/png'
img = Magick::Image.read(requested_... |
module Ricer::Plugins::Purple
class Icq < Violet
def protocol
'prpl-icq'
end
end
end
|
# Polisher Core Ruby Extensions
#
# Licensed under the MIT license
# Copyright (C) 2013 Red Hat, Inc.
require 'polisher/rpmspec'
class String
def gem?
File.extname(self) == ".gem"
end
def gemspec?
File.extname(self) == ".gemspec"
end
def gemfile?
File.basename(self) == "Gemfile"
end
def u... |
require 'minitest/autorun'
require_relative 'test_helper'
require_relative '../csv_parser'
require_relative '../naive_bayes_trainer'
require_relative '../naive_bayes_tester'
class NaiveBayesTesterTest < MiniTest::Unit::TestCase
def setup
parsed_data1 = CSVParser.new('./test/test_data/test_transcripts_class1.csv'... |
actions :install, :upgrade, :remove
default_action :install
attribute :version, :kind_of => String
attribute :source, :kind_of => String
attribute :options, :kind_of => [String, Hash]
|
class AppointmentDrop < Liquid::Drop
include ApplicationHelper
include PhoneNumberHelper
include AppointmentsHelper
include SubscriptionsHelper
include ActionView::Helpers::NumberHelper
include ActionView::Helpers::TextHelper
def initialize(appointment)
@appointment = appointment
end
def sta... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
ip_address = "10.1.1.20"
public_ip_address = ""
appname = "tavro"
hostname = appname + ".dev"
# ========================================================================
Vagrant.configure(2) do |config|
# For a complete reference, please see the online documentation at
# ... |
Rails.application.routes.draw do
namespace :api, defaults: {format: :json} do
resource :user, only: [:create]
resource :session, only: [:create, :destroy]
resources :businesses, only: [:index, :show, :create]
resources :reviews, only: [:create, :show, :destroy]
end
root to: 'static_pages#root... |
#this seriously needs rewrite
#later rails supports this already but our version does not
class Object
alias_method :try, :__send__
def tap
yield self
self
end
end
class NilClass
def try(*args)
nil
end
end
#our custom extensions
class Hash
def deep_delete_if_nil
delete_if{|k,v| v.nil? }... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.