text stringlengths 10 2.61M |
|---|
namespace :camaleon_cms do
desc 'Generate thumbnails for uploaded files'
task generate_thumbnails: :environment do
include CamaleonCms::CamaleonHelper
include CamaleonCms::HooksHelper
include CamaleonCms::SiteHelper
include CamaleonCms::PluginsHelper
include CamaleonCms::ThemeHelper
include ... |
class Api::ImageResource < Api::BaseResource
attribute :file_name
attribute :url
attribute :description
has_one :imagable, polymorphic: true
has_one :uploader, class_name: "Person"
end
|
class Series
def initialize(str)
@str = str
@size = str.size
end
def slices(num)
raise ArgumentError if @size < num
result = []
0.upto(@size - num) do |idx|
result << [@str[idx..idx + num - 1].to_i]
end
result
end
end
|
class Role < ActiveRecord::Base
private
validates :name, :definition, presence: true
end
|
module Qiita
# Qiita API から取得したデータを保持
class Item
attr_accessor :title, :username, :updated_at, :body, :stocks, :profile_image, :profile_image_url, :url
def initialize(data)
@title = data['title']
@username = data['user']['url_name']
@updated_at = data['updated_at_in_words']
@body =... |
class AddGenericDateToEvents < ActiveRecord::Migration
def change
add_column :events, :generic_date, :string
end
end
|
Given(/^Eu esteja na tela de listagem das classes$/) do
visit classes_path
end
|
class RemembranceToken < ActiveRecord::Base
unloadable
belongs_to :authenticatable, :polymorphic => true
validates_presence_of :series_token
validates_presence_of :remembrance_token
validates_presence_of :authenticatable
def value
"#{authenticatable_type}|#{authenticatable_id}|#{series_token}|#{remem... |
class Argument < ActiveRecord::Base
belongs_to :user
belongs_to :relationship
has_many :comments, :as => :commentable
scope :today, -> { where(created_at: (Time.now.beginning_of_day..Time.now.end_of_day)) }
end
|
class Appointment < ApplicationRecord
belongs_to :artist
validates_presence_of :date,
:description
# :paid,
# :client_name,
# :client_email,
# :user_id
end
|
require 'spec_helper'
describe Cortex::Request do
let(:client) { Cortex::Client.new(access_token: '123') }
context 'Request Methods' do
let(:response) { OpenStruct.new({body: "Body", headers: {}, status: 200} ) }
let(:model) { { title: 'Test' } }
before(:each) do
@connection = stub
Cortex... |
#
# Cookbook:: cms_sap_sybbackup
# Recipe:: syb_config.rb
#
# Author:: bharati_patidar (SAP Auto & Orch Squad)
# Copyright:: 2018, The Authors, All Rights Reserved.
# Find Sybase Servername. Servername need not be only 3 chars for non-sap.
sname_cmd = Mixlib::ShellOut.new("ls -ld /sybase/*/sapdata1 | awk '{print $3,$4... |
# -*- coding: utf-8 -*-
#
# Author:: lnznt
# Copyright:: (C) 2011 lnznt.
# License:: Ruby's
#
require 'test/unit'
require 'gmrw/extension/proc'
class TestFields < Test::Unit::TestCase
def try_assert_equal(tests)
tests.each_with_index do |test, i|
actual, expected = test.first
assert_equal(expected, ... |
namespace :fedena_app_frame do
desc "Install Fedena App Frame Module"
task :install do
system "rsync --exclude=.svn -ruv vendor/plugins/fedena_app_frame/public ."
end
end
|
=begin
Glassomium - web-based TUIO-enabled window manager
http://www.glassomium.org
Copyright 2012 The Glassomium 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
h... |
module UserSignedIn
extend ActiveSupport::Concern
private
def user_signed_in
unless user_signed_in?
flash[:alert] = "サインインしてください"
redirect_to new_user_path
end
end
end |
class Javacpp < Formula
desc "The missing bridge between Java and native C++"
homepage "https://github.com/bytedeco/javacpp"
url "http://search.maven.org/remotecontent?filepath=org/bytedeco/javacpp/1.2.3/javacpp-1.2.3-bin.zip"
sha256 "b57e8add9d2ae67cf93e87b4964e54969daa810d0abb224bc80c7d38e8f4f6a6"
depends_... |
class DeleteInvalidFeaturings < ActiveRecord::Migration
def up
Featuring.all.each do |featuring|
featuring.destroy if featuring.invalid?
end
end
def down
raise ActiveRecord::IrreversibleMigration
end
end
|
# frozen_string_literal: true
require 'goauth/version'
require 'goauth/account'
require 'goauth/result_list'
require 'goauth/client'
module Goauth
AuthError = Class.new(RuntimeError)
end
|
class Skill < ActiveRecord::Base
IMG_PATH = "skills/"
IMAGES = Dir.glob("app/assets/images/skills/*.jpg").map{|img| "assets/" + img.split('images/')[1]}
belongs_to :hero
def img_path
return "assets/" + IMG_PATH + self.img_url
end
def methods_json
return {
:img_path => self.img_path
}
... |
Loudmouth.setup do |config|
# Optionally specify a layout to use for the loudmouth controller
config.use_layout = ''
# Default comment text for the new comment form
config.new_comment_content = "Enter new Comment..."
# How many minutes before a user can post a subsequent comment (rate limiting)
confi... |
class PostsController < ApplicationController
load_and_authorize_resource
def show
@post = Post.find(params[:id])
end
def create
@post = Post.new()
@post.user_id = current_user.id
body_markdown = params[:post][:body_markdown]
clean_input = sanitize_and_strip_input(body_markdown)
@pos... |
class UpdateEloRatings < ActiveRecord::Migration
def up
Tournament.all.each do |tournament|
tournament.users.each do |user|
tournament.elo_ratings.with_defaults.create(:user => user)
end
tournament.games.order(:created_at).select(&:confirmed?).each do |game|
game.process_elo
... |
require 'json'
require 'csv'
require 'set'
require 'yaml'
require 'experiment_extensions/experiment_extender'
require 'experiment_extensions/data_farming_experiment_progress_bar'
require 'experiment_extensions/data_farming_simulation'
require 'experiment_extensions/simulation_scheduler'
class DataFarmingExperiment < M... |
# encoding: utf-8
require 'spec_helper'
module Manipulacao
describe Crop do
describe ".margens(top, right, bottom, left)" do
it 'factory method: instancia um Crop' do
img = Imagem.new(ler_fixture("upload/500x369_30kb.png"))
crop = Crop.margens(10, 30, 20, 40)
crop_normal = Crop.new... |
require 'spec_helper'
describe Relationship do
before(:each) do
@pairee = Factory(:thought_worker, :name => "Vinay")
@pairer = Factory(:thought_worker, :name => "ash")
@relationship = @pairer.relationships.build(:pairee_id => @pairee.id, :pairings => 1)
@reverse_relationship = @pairee.reverse_relat... |
class AddCustomImageToEvents < ActiveRecord::Migration
def change
add_column :events, :custom_image, :string
end
end
|
class QuestionsController < ApplicationController
before_filter :authenticate_user!
before_filter :load_problem, :only => [ :create ]
before_filter :load_question, :except => [ :create ]
def create
@question = @problem.questions.build(params[:question])
if @question.save
redirect_to problem_quest... |
# Book Model
class Book < ApplicationRecord
has_many :requests
has_many :comments
belongs_to :author
mount_uploader :image, BookImageUploader
ratyrate_rateable 'general'
validates :title, :description, :image, :author, presence: true
validates :year, presence: true, numericality: true
validate :year_mar... |
class Dota::Hero
include Mongoid::Document
include ActiveModel::Validations
include ActiveModel::Serialization
validates_presence_of :name, :url
embeds_many :stats, class_name: 'Dota::Versus', inverse_of: :hero, cascade_callbacks: true
accepts_nested_attributes_for :stats
field :name, type: String
... |
#
# Tests de la class PISite::Tdm
#
# @noter que la sous-classe Tdm n'est pas un sous-classe de PISite::Livre mais
# de PISite. Pourquoi ? Pour pouvoir être dissociée des livres.
#
require 'spec_helper'
require_model 'pisite'
PISite::set_folder 'test'
describe PISite::Tdm do
before(:all) do
PISite::set_folder 't... |
require "application_system_test_case"
class SupplyFoodConfigurationsTest < ApplicationSystemTestCase
setup do
@supply_food_configuration = supply_food_configurations(:one)
end
test "visiting the index" do
visit supply_food_configurations_url
assert_selector "h1", text: "Supply Food Configurations"
... |
Maybe = Algebrick.type do
variants None = atom,
Some = type { fields Object }
end # => Maybe(None | Some)
# Types can be extended with usual syntax for modules and using Ruby supports module reopening.
module Maybe
def maybe(&block)
case self
when N... |
class TflsController < ApplicationController
before_filter :authorize_company
before_action :set_tfl, only: [:show, :edit, :update, :destroy]
# GET /tfls
# GET /tfls.json
def index
@tfls = current_company.tfls
end
# GET /tfls/1
# GET /tfls/1.json
def show
end
# GET /tfls/new
def new
@... |
names = ["motivation", "funny", "sports", "love"]
names.each { |name| Category.create(name: name) }
quotes = [
["Our greatest glory is not in never falling, but in rising every time we fall.", "Confucius", 1],
["All our dreams can come true, if we have the courage to pursue them.", "Walt Disney", 1],
["It does n... |
class Task < ActiveRecord::Base
attr_accessible :name
validates :name, :presence => true
belongs_to :owner, :inverse_of => :tasks, :validate => true
validates :owner, :presence => true
end
|
Rails.application.routes.draw do
root 'static_pages#top'
get '/signup', to: 'users#new'
# ログイン
get '/login', to: 'sessions#new'
post '/login', to: 'sessions#create'
delete '/logout', to: 'sessions#destroy'
resources :users do
member do
patch 'editor_switch' # 編集権限切替
end
collection do
... |
#==============================================================================
# ■ HSP ヘルプファイルを作る
#------------------------------------------------------------------------------
# 注意…
# ・[対応済]"@param[in] x, y, z" は正常に検出できないので "x,y,z" のようにスペースを消す。
# ・上記のような "x,y,z" にデフォルト引数の指定はできない
# ・関数宣言は複数行にしない
#============... |
# frozen_string_literal: true
require 'test_helper'
module Vedeu
describe XCoordinate do
let(:described) { Vedeu::XCoordinate }
let(:instance) { described.new(geometry) }
let(:geometry) {}
describe '#initialize' do
it { instance.must_be_instance_of(described) }
it { instance.instanc... |
# frozen_string_literal: true
module Mappable
# Defines what fields to map
module Mapping
def self.included(base)
base.extend InheritanceHelper::Methods
base.extend ClassMethods
end
def self.default_mapping_options(src, dest)
{
src: src.to_sym,
getter: src.to_s.freeze... |
class MoodUpdate < ActiveRecord::Base
belongs_to :mood
validates :mood, :intensity, presence: true
validates :intensity, numericality: {only_integer:true, greater_than: 0, less_than_or_equal_to: 10}
end
|
require 'json'
class BFileCache
PATH = File.dirname(__FILE__) + "/b_file_lookup_table.json"
def self.new_term(file_compare)
official_range = file_compare.official_range
local_range = file_compare.local_range
if official_range != local_range
raise "OEIS does not match local! #{official_range} !=... |
class ActivitySector < ActiveRecord::Base
has_and_belongs_to_many :entities
default_scope :order => 'activity_sectors.position asc'
validates_presence_of :name
end
|
# Problem 395: Pythagorean tree
# http://projecteuler.net/problem=395
#
# The Pythagorean tree is a fractal generated by the following procedure:
#
#
#
# Start with a unit square. Then, calling one of the sides its base (in the animation, the bottom side is the base):
# Attach a right triangle to the side opposit... |
class Drone < ApplicationRecord
has_one :order
has_one :current_address, class_name: "Address", as: :addressable, dependent: :destroy
# has_one :target_address, class_name: "Address", as: :addressable, dependent: :destroy
# reverse_geocoded_by :latitude, :longitude, address: :full_address
# after_validat... |
module Troles
class Operations < Troles::Common::Operations
autoload :Read, 'troles/operations/read'
autoload :Write, 'troles/operations/write'
# constructor
# @param [Object] the role subject, fx a User or UserAccount
def initialize role_subject
super
end
end
end |
require "spec_helper"
describe "routes to Sessions" do
it "routes login_path to sessions#new" do
get(login_path).should route_to("sessions#new")
end
it "routes sessions_path to sessions#create" do
post(sessions_path).should route_to("sessions#create")
end
it "routes logout_path to sessions#destroy"... |
require 'sinatra'
require 'sinatra/reloader'
$SECRET_NUMBER = rand(100)
$correct = false
$bg_color = "white"
$available_guesses = 5
def reinitialize
$old_number = $SECRET_NUMBER
$SECRET_NUMBER = rand(100)
$bg_color = ($correct == true ? "lime" : "white")
$correct = false
$available_guesses = 5
end
def check_gue... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
BOX = "bionic-canonical-64"
BOX_URL = "https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64-vagrant.box"
Vagrant.configure("2") do |config|
config.vm.box = BOX
config.vm.box_url = BOX_URL
config.disksize.size = '20GB'
config.vm.network "forward... |
# -*- mode: ruby -*-
# # vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.provision "shell", path: "provision.sh"
config.vm.synced_folder ".", "/vagrant"
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
config.ssh.username = "ubuntu"
# Fix docker not being able to resolve privat... |
class DropTableStoryPlaceCategory < ActiveRecord::Migration
def change
drop_table :story_place_categories
end
end
|
class Like < ApplicationRecord
belongs_to :traveler
belongs_to :sightseeing
end
|
require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module SvEcommerce
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rai... |
require 'pry'
#using each and not using reverse method
def reverse_each_word(string)
reverse = []
string.split(" ").each do |word|
reverse << reverse_word(word)
end
reverse.join(" ")
end
def reverse_word(word)
new_word = ""
i = 0
while i < word.length
new_word = word[i] ... |
class CategoriesController < ApplicationController
def new
@category = Category.new(params[:id])
authorize! :create, Category, message: "You need to be a moderator to create a new category."
end
def edit
@category = Category.find(params[:id])
authorize! :edit, @category, message: "You need to be ... |
#! /usr/bin/ruby
#
# SeqTools
# ver.1.0.1
# This class is used to various operation for sequence data
#
# Copyright (c) 2016 - Ryo Kanno
#
# This software is released under the MIT License.
# http://opensource.org/licenses/mit-license.php
#
class SeqTools
def self.invert(seq)
r=""
seq.each_char do |i|
... |
class ContractsController < ApplicationController
def index
@contracts = Contract.all
end
def new
@contract = Contract.new
end
def create
@contract = Contract.new(user_params)
if @contract.save
redirect_to contracts_path
end
end
private
def user_params
params.require(:c... |
class CreateRecipeIngredients < ActiveRecord::Migration[5.2]
def change
create_table :recipe_ingredients do |t|
t.belongs_to :recipe
t.belongs_to :ingredient
t.decimal :quantity, precision: 10, scale: 2
t.string :display_quantity
t.string :unit
t.decimal :metric_quantity, prec... |
require 'yaml'
require_relative '../classes/order.rb'
module OopLibrary
def self.generateOrdersData
orders = [
Order.new("The Odyssey", "Mikhail Mikhaylov"),
Order.new("Crime and Punishment", "Mikhail Mikhaylov"),
Order.new("The Sound and the Fury", "Ivan Ivanov"),
Order.new("Nineteen Eighty Four", "Pet... |
class User < ApplicationRecord
has_many :messages
has_many :chats, through: :messages
@time_until_deletion = 0
def set_time_until_deletion
@time_until_deletion = 60
while @time_until_deletion > 0
@time_until_deletion -= 1
sleep 60
if @time_until_deletion == 0
self.destroy
... |
class ReportsController < ApplicationController
def show
@report = current_user.report
end
end
|
class VehicleModelsController < ApplicationController
before_filter :authenticate
# GET /vehicle_models
# GET /vehicle_models.xml
def index
@vehicle_models = VehicleModel.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @vehicle_models }
end
end
... |
class Infrastructure < ActiveRecord::Base
has_many :installations, dependent: :destroy
has_many :fittings, through: :installations
validates :area, presence: { message: 'Please provide a area' }
end
|
Rails.application.routes.draw do
devise_for :users, controllers: { sessions: 'user/sessions',
passwords: 'user/passwords',
confirmations: 'user/confirmations',
unlocks: 'user/unlocks',
... |
class CreatePurchaseOrders < ActiveRecord::Migration[5.0]
def change
create_table :purchase_orders do |t|
t.string :cc_first_name
t.string :cc_last_name
t.string :cc_month
t.string :cc_year
t.string :cc_brand
t.string :user_ip
t.string :billing_first_name
t.string :... |
class AddOtherCnNameToWineries < ActiveRecord::Migration
def change
add_column :wineries, :other_cn_name, :string
end
end
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the 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... |
# frozen_string_literal: true
module AsciiPngfy
module Settings
# Reponsibilities
# - Pipes setter and getter calls to a specific Setting instance
# - Associates supported settings with the respective Setting name
# - Generates a SettingsSnapshot object for the purpose of describing
# a... |
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# email :string(255)
# name :string(255)
# password_digest :string(255)
# lat :float
# long :float
# address :text
# is_admin :boolean def... |
class Game
attr_accessor :player1, :player2, :board, :show
def initialize(player1, player2)
@player1 = player1
@player2 = player2
@board = Board.new
@show = Show.new(@board)
end
def play
count = 1
while(true )
player_turn(player1)
... |
class Ingredient < ActiveRecord::Base
belongs_to :recipe
scope :with, -> (name) {where name: name}
end
|
require 'minicomic-backend/filter'
class InputFilter < Filter
attr_accessor :output_filename
def initialize
super
@output_filename = "tmp.png"
end
end
|
module Campaigns
module CreateCsvExport
class Specification
def mapping
{
campaign: {
"[DO NOT TOUCH] Campaign DB ID" => :id,
"[DO NOT TOUCH] Campaign Kickstarter url" => :kickstarter_url,
"Start date" => :start_dat... |
require 'double_linked_list'
class Que < DoubleLinkedList
class QueueEmptyError < RuntimeError
end
def enqueue(value)
add(Node.new(value))
end
def dequeue
raise QueueEmptyError if @size == 0
remove(@tail)
end
end
|
#!/usr/bin/env ruby
require 'pp'
# Today, we'll learn to use this special command trick, the alias method.
# With that, we can change name of the methods in diferent classes, calling the exact same method
class Alias
def hello
puts "Hello from original =========> Aqui o método original"
end
alias :new_hell... |
Rails.application.routes.draw do
resources :incidents, except: %w(edit update destroy) do
resources :incident_details, except: %w(edit update destroy)
end
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root to: "incidents#index"
end
|
class GameObjectController < FayeRails::Controller
channel '/game_object/lock' do
subscribe do
begin
data = message.symbolize_keys
user = User.find_by(access_token: data[:access_token])
game_object = GameObject.find(data[:id])
game_channel = user.room.game_channel
if ... |
class DocumentsController < ApplicationController
def share
@document = Document.find(params[:id])
@document.assign_attributes(params[:document])
@document.author = User.find_or_initialize_by_email(@document.author.email)
@document.users = @document.users.map do |user|
User.find_or_initialize_... |
class User < ApplicationRecord
has_many :user_answers
has_many :question_answers, through: :user_answers
end
|
require 'test_helper'
class CameraRollsControllerTest < ActionController::TestCase
setup do
@camera_roll = camera_rolls(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:camera_rolls)
end
test "should get new" do
get :new
assert_respons... |
# Imports ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
require 'fileutils'
require_relative "../../generator.rb"
require_relative "../../primitives.rb"
require_relative "../generatorUtils.rb"
# Module Globals +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def is_number
Proc.... |
class Build < ApplicationRecord
belongs_to :user
serialize :item_ids, Array
def items
Item.where(id: item_ids)
end
end
|
############################################# Windows #############################################
# From here is window region. Enter with caution! #
# Trade back of transforming from OOP to structural is a really high and bad cohesion... #
# Some functions hav... |
class Api::BusinessController < Api::BaseController
require_relative 'errors/business_exception'
before_filter :set_business, only: [:add_participant]
BUSINESS_TYPES = %w(findgoods)
def create
if BUSINESS_TYPES.include?(params[:action_name])
analytics_question
search_matchers
create_busi... |
require 'rails_helper'
require 'helper_methods'
describe User do
before :each do
User.delete_all
@jason = User.new(username: 'jason', password: 'password', email: 'jason@xylophonexyz.com')
@jason.skip_confirmation!
@jason.save!
@unsaved = User.new
end
def random_details(user, options={name_length:8})
... |
class Stack
def initialize
@store = LinkedList.new
end
def push(item)
@store.add_first(item)
end
def pop()
return nil if @store.empty?
item = @store.remove_first
return item
end
def empty?()
return @store.empty?
end
def to_s
return @store.to_s
end
end
|
module Vote
module Condorcet
module Schulze
class Basic
attr_reader :candidates, :vote_matrix, :play_matrix, :result_matrix, :ranking, :vote_count
attr_reader :winners_array, :potential_winners, :beat_couples, :ties
def initialize
@beat_couples = []
@ties = []
... |
class CreateReadingSessionParticipants < ActiveRecord::Migration
def change
create_table :reading_session_participants do |t|
t.integer :user_id, null: false
t.integer :reading_session_id, null: false
t.timestamps null: false
end
add_index :reading_session_participants, :user... |
require 'pry'
require 'pry-byebug'
#TEDDIT: Strings - Student's File
# Teddit is a Ruby text based news aggregator. Think Reddit in your terminal.
# This exercise will be used throughout the ruby portion of this course.
# We will incrementally build a news aggregator (next week using API's)
# We will create a more dy... |
class Character < ActiveRecord::Base
validates :first_name, :last_name, :workplace, presence: true
end
|
require_relative 'test_helper'
require './lib/sales_engine'
class TransactionTest < Minitest::Test
def setup
item_file_path = './test/fixtures/items_truncated.csv'
merchant_file_path = './test/fixtures/merchants_truncated.csv'
invoice_file_path = './test/fixtures/invoices_truncated.csv'
invoice_item... |
class ArtistsController < ApplicationController
before_action :authenticate_user!
def index
if params[:genre] == nil && params[:search] == nil
@artists= Artist.all
elsif params[:genre]=="" && params[:or]=="" && params[:search] == ''
@artists= Artist.all
elsif params[:genre].p... |
class AddPositionToShowplacepicture < ActiveRecord::Migration
def change
add_column :showplacepictures, :position, :integer, default: 0
end
end
|
class ServicesRelation < ROM::Relation[:sql]
schema(:services, infer: true) do
associations do
belongs_to :car
end
end
dataset { order { id.desc } }
end
|
class AddActivatedToSubscriptions < ActiveRecord::Migration
def self.up
if ::Subscription.table_exists?
add_column :subscriptions, :activated, :boolean, :default=>false
end
end
def self.down
if ::Subscription.table_exists?
remove_column :subscriptions, :activated
end
end
end
|
FactoryGirl.define do
factory :album_publisher, :class => Publisher do
name { "#{Faker::Name.name}#{rand(100)}" }
end
factory :album_artist, :class => Artist do
name { Faker::Name.name }
end
factory :album_artist_1, :class => Artist do
name { Faker::Name.first_name }
end
factory :album_tra... |
ENV["RACK_ENV"] = "test"
require "minitest/autorun"
require "rack/test"
require_relative "../app"
class AppTest < Minitest::Test
include Rack::Test::Methods
def app
Sinatra::Application
end
def setup
@root = File.expand_path("../..", __FILE__)
@datafiles = Dir.glob("#{@root}/data/*").map { |fil... |
require_relative 'analytics/event'
module Talis
# Use this as a mixin within your classes to be able to send analytics events.
module Analytics
# Create a single analytics event.
# In order to send events, the client must be configured with a
# valid OAuth client that is allowed to search for users:
... |
module SimpleMath
extend ActiveSupport::Concern
def avg(arr)
arr.inject{ |sum, el| sum + el }.to_f / arr.size
end
# incremental avg formula: https://ubuntuincident.wordpress.com/2012/04/25/calculating-the-average-incrementally/
def incremental_avg(avg, arr, n)
m = arr.size
avg + ((arr.sum - (m ... |
require 'spec_helper'
#rubs
#ruby
#ruby's
#rubying
#rucksack
describe Bise do
before(:all) do
@dict = File.join(File.dirname(__FILE__), 'dict')
end
it 'should find first line for "small" term' do
File.open(@dict){|f| f.bin_find('a')}.should == 'rubs'
File.open(@dict){|f| f.bin_find('A'){... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.