text
stringlengths
10
2.61M
class Article attr_accessor :id, :title, :author, :type def initialize(id: id, title: title, author: author, type: type) @id = id @title = title @author = author @type = type end end
##----------------------------------------------------------------------------## ## Common Event Pop-ups ## Created by Neon Black ## ## For both commercial and non-commercial use as long as credit is given to ## Neon Black and any additional authors. Licensed under Creative Commons ## CC BY 3.0 - http://creativecommon...
# frozen_string_literal: true require 'active_record_json_explain/version' module ActiveRecordJsonExplain class Error < StandardError; end # Your code goes here... end # rubocop:disable all # Usage # ``` ruby # # NOTE: # # if use postgresql adapter, Rails run `require 'activerecord/lib/active_record/connection_a...
class AddIndexToArtShares < ActiveRecord::Migration[5.2] def change add_index :art_shares, :artist_id add_index :art_shares, :viewer_id end end
require_relative('../db/sql_runner.rb') require_relative('house.rb') class Student attr_reader :id, :first_name, :last_name, :house_id, :age def initialize(options) @id = options['id'].to_i if options['id'] @first_name = options['first_name'] @last_name = options['last_name'] @house_id = options[...
class AddGlobalStatusToDocuments < ActiveRecord::Migration def change add_column :documents, :global_status, :string, :after => :status, :default => '', :null => false rename_column :documents, :status, :local_status end end
require 'nil/serialise' require_relative 'Player' require_relative 'HeroStatistics' players = Nil.deserialise('players.db') players.reject! do |player| player.difference < 30 end heroes = {} players.each do |player| player.statistics.each do |hero| if heroes[hero.name] == nil heroes[hero.name] = hero ...
require 'spec_helper' require 'rails_helper' describe User do it { should validate_presence_of(:email) } it { should validate_presence_of(:password_digest) } it { should validate_presence_of(:full_name) } it { should have_many(:items).order('purchase_date DESC') } end
module Guard # A group of Guards. There are two reasons why you want to group your guards: # # - You can start only certain Groups from the command line by passing the `--group` option. # - Abort task execution chain on failure within a group. # # @example Group that aborts on failure # # group :fron...
class CreateNvsMigs < ActiveRecord::Migration def change create_table :nvs_migs do |t| t.string :name t.datetime :end_date t.datetime :init_date t.integer :nvs_mig_status_id t.integer :source_env_id t.integer :target_env_id t.string :nvs_process_sequence t.st...
module Rubinius module AST class Node attr_accessor :line def initialize(line) @line = line end def pos(g) g.set_line @line, @file end # TODO: transform nodes that use this def kernel? false end def children [] end ...
class Brewery < ActiveRecord::Base include RatingAverage has_many :beers, :dependent => :destroy has_many :ratings, :through => :beers validates :name, :presence => true validates :year, :numericality => { greater_than_or_equal_to: 1042, only_integer: true} validate :...
class LocationFacade class << self def coordinates(location) data = MapquestService.coordinates(location) data[:results].map do |location| Coordinate.new(location) end end end end
namespace :import do desc "Import Pipe Delimted IRS 5013c Data " task :irs_data => :environment do require 'csv' txt_file_path = 'db/irs_5013cs.txt' results = File.open(txt_file_path).readlines do |line| line = line.split('|').each_slice(7) end # Order Field Notes # 1 EIN Req...
class RecipesController < ApplicationController def index @recipes = Recipe.all @recipes = policy_scope(Recipe) @recipes = Recipe.tagged_with(params[:tag]) if params[:tag].present? @tag = params[:tag] end def show @recipe = Recipe.find(params[:id]) authorize @recipe ingredients = @re...
=begin Given an array, find the duplicates in that array, and return a new array of those duplicates. The elements of the returned array should appear in the order when they first appeared as duplicates. Note: numbers and their corresponding string representations should not be treated as duplicates (i.e., "1" != 1)....
class WebServer < Sinatra::Base set :traps, false set :show_exceptions, false not_found do halt 404 end error do halt 500 end get '/ping' do halt 200, 'OK' end get '/metrics' do content_type 'text/plain' self.class.exporter.request! self.class.exporter.export end end
module TestBench class CLI class ParseArguments Error = Class.new(RuntimeError) attr_reader :argv def run @run ||= Run.build(test_run: TestBench::Run.build) end attr_writer :run def test_run run.test_run end def output test_run.output ...
class ApplicationTimeSlice include Mongoid::Document belongs_to :user_application WINDOW = 1.hour field :app_env, :type => String, :default => "production" field :actions, :type => Hash, :default => {} field :method_types, :type => Hash, :default => {} # DOCUMENT # # # method_types.al...
# Create hash which maps state to abbreviation. states = { 'Oregon' => 'OR', 'Florida' => 'FL', 'California' => 'CA', 'New York' => 'NY', 'Michigan' => 'MI' } cities = { 'CA' => 'San Francisco', 'MI' => 'Detroit', 'FL' => 'Jacksonville' } # add some more cities cities['NY'] = 'New York' cities['OR'] =...
class Root6Bk < Formula homepage "https://root.cern.ch" url "https://root.cern.ch/download/root_v6.06.08.macosx64-10.11-clang73.tar.gz" #url "https://root.cern.ch/download/root_v6.10.02.macosx64-10.11-clang80.tar.gz" ##sha256 "0186dc465ab5f7f2390fbf67b36c891a7aca9c6d8929e30155857f8bbcd5a2c3" sha256 "b8702b5945...
class Ability include CanCan::Ability def initialize(user) can :read, :all # permissions for every user, even if not logged in return unless user can :create, TodoList can :create, Comment do |c| c.campaign.exists? end return unless user && user.type == 'Expert' can :manage, Campa...
class Flag < ActiveRecord::Base belongs_to :polygon has_one :usersession, :foreign_key => :session_id, :primary_key => :session_id attr_accessible :flag_value, :is_primary, :polygon_id, :session_id, :flag_type, :latitude, :longitude validates :flag_value, presence: true validates :polygon_id, presence: true valid...
class MainsController < ApplicationController before_action :main_new, only: [:index, :new, :search] def index #paramsがnilなら1を代入、早い話が最初のブラウジング時の対応 params[:page] = 1 if params[:page].blank? #早い話がこれのタイトルにリンクつけてループで回せばいい #全部表示は却下#@mains = Main.all #kaminariを使ったページング #なんか決まり事のオンパレードなので割愛 @mains = Main...
require "rails_helper" feature "user can create a post inside a topic" do scenario "with valid input" do prepare_board_topic fill_form(:post, { post_title: "My title", post_description: "This is my post" }) click_on "Create Post" expect(page).to have_content("Post created!") end scenario "with...
class User def self.find_by_id(id) result = QuestionsDatabase.instance.execute( <<-SQL, id ) SELECT * FROM users WHERE id = ? SQL User.new(result.first) unless result.empty? end def self.find_by_name(fname, lname) result = QuestionsDatabase.instance.execute( <<-SQL,...
# coding: utf-8 class MembershipsController < ApplicationController before_filter :find_artist def create @membership = @artist.memberships.build(member_id: params[:member_id]) if @membership.save redirect_to artist_url(@artist), notice: 'Эмси добавлен в группу.' else redirect_to artist_u...
module MarkovsImporter def increment_markov_from_score(markov, score) score[:frequency] = 1 score.each_pair do |tone, points| score[tone] = points + markov.read_attribute(tone) end return score end # increment_markov_from_score def calculate_score_from_tones(tones) defaults = Hash.new(...
module Fluent class Mongo2Output < BufferedOutput Plugin.register_output('mongo2', self) require 'fluent/plugin/mongo_auth' include MongoAuthParams include MongoAuth require 'fluent/plugin/logger_support' include LoggerSupport include SetTagKeyMixin config_set_default :include_tag_ke...
feature 'user sign out' do before do User.create(name: 'Bob', email: 'bob@gmail.com', password: 'password', password_confirmation: 'password') sign_in end scenario 'a user can sign out of their account' do click_button "Sign Out" expect(page).to have_content "Good...
# Most of this agent was taken, verbatim, from the Packages agent. # Rather than muddy the waters by forking that agent I created a # separate agent that is ONLY concerned with Yum...(I live in an Ivory Tower # where I only need to worry about RHEL) # This also needs to be a bit more transparent to what's going on an...
module Capybara::Poltergeist class Driver < Capybara::Driver::Base # allows Capybara to have different behaviors depending on whether # the current driver includes Kanye's algorithm def kanye_invited? true end private def imma_let_you_finish wait_for_in_progress_ajax_to_finish ...
# frozen_string_literal: true # rubocop:disable Layout/EmptyLinesAroundArguments # https://github.com/bbatsov/rubocop/issues/5224 RSpec.describe Utilities::Markdown, type: :service do context 'happy path' do it 'works (non-code example)' do sample_markdown = { text: <<~SENTINEL ## Hello ...
class DeleteFaqLanguage < ActiveRecord::Migration[5.2] def change remove_column :faqs, :language_id end end
require 'goodreads/version' require 'goodreads/errors' require 'goodreads/request' require 'goodreads/client' module Goodreads @@options = {} # Create a new Goodreads::Client instance # def self.new(options={}) Goodreads::Client.new(options) end # Define a global configuration # # options[:ap...
class Admin::AdminsController < Admin::BaseAdminController load_and_authorize_resource except: %i[dashboard edit update toggle_state] skip_authorization_check only: %i[dashboard edit update toggle_state] before_action :set_timelines, only: :dashboard before_action :set_comments, only: :dashboard before_action...
class Sandwich < ActiveRecord::Base has_many :sandwich_ingredients has_many :ingredients, through: :sandwich_ingredients, after_add: :add_calories before_create :capitalize_name def capitalize self.name = name.upcase end def add_calories(ingredient) self.total_calories += ingredient.calories self.save en...
class ChangeLikesInImages < ActiveRecord::Migration def up change_column :images, :likes, :string end def down change_column :images, :likes, :integer end end
class Review < ApplicationRecord include Hashable belongs_to :job belongs_to :owner, polymorphic: true belongs_to :reviewee, polymorphic: true after_create :complete_job after_create :send_counterpart_email validates_presence_of :comment, :qualification, :job validate :can_create private def can_c...
require 'test_helper' # declare a new controller for testing purposes class AuthorizationTestController < ApplicationController include Authorization::ControllerMixin before_filter permission_required(:eat_cake), :only => :delicious_cake def delicious_cake @cake = :chocolate render :nothing => true en...
class Ability include CanCan::Ability def initialize(user) user ||= User.new can :update, user can :manage, :all if user.is_role? User::SUPERADMIN if user.is_role? User::ADMIN can :manage, News can :manage, Message end cannot :destroy, user end end
class AddSecurityLocationAndSecurityCodeToKey < ActiveRecord::Migration def change add_column :keys, :security_location, :string add_column :keys, :security_code, :string end end
def display_board(board) puts " #{board[0]} | #{board[1]} | #{board[2]} " puts "-----------" puts " #{board[3]} | #{board[4]} | #{board[5]} " puts "-----------" puts " #{board[6]} | #{board[7]} | #{board[8]} " end WIN_COMBINATIONS = [ [0, 1, 2], [3, 4, 5], [6, 7 ,8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0,...
module Api class WarPlayersController < ::ApplicationController def create war_player = WarPlayer.new(create_params) if war_player.save render json: WarPlayerSerializer.new(war_player).to_json, status: 201 else render json: { errors: true }, status: 422 end end pri...
# class de version 1.0 class Player attr_accessor :name, :life_points # initialiser la class def initialize(name) @name = name @life_points = 10 end def show_state puts "#{@name} a encore ses #{@life_points}pts" end def gets_damage(damages) @life_points -= damages if ...
class ItemScreen include Furter DEFAULT_DATA ={ 'item' => '3000', 'color' => 'Black' } def search_for_item(data = {}) data = DEFAULT_DATA.merge(data) touch("view:'UITextFieldLabel' marked:'E.g. tote >20 or purse 20..40'") sleep(2) type_into_keyboard(data['item']) sleep(2) ...
require 'toml-rb' # 言語設定のconfigファイルから要素を抜き出すライブラリ class Config attr_reader :config_file ABTROOT = ENV['ABT'] # 設定ファイルを読み込む def initialize @config_file = TomlRB.load_file(ABTROOT + '/config.toml') end # user名を取得 def get_username @config_file['user']['username'] end # パスワー...
require 'test_helper' module Cornell class SemesterTranslatorTest < ActiveSupport::TestCase test "should raise an error if input parameter is anything but a hash or a string" do assert_raise ArgumentError do sem = SemesterTranslator.new(["I am not", "a valid parameter"]) end end ...
require "spec_helper" describe Users::SystemUser do it "should create SystemUser" do system_user = Users::SystemUser.create_system_user!("test", "testreal", "pass", "pass", "sales") system_user.should be_true end it "should not create SystemUser since the password and confirmation is not equal" do ...
class Users::WorkoutsController < ApplicationController def index if logged_in? @user = current_user filter_workouts_view else redirect_to '/' end end def new @workout = Workout.new end def create @workout = Workout.new(workout_params) @workout.user_id = current_us...
# Marks all TextBlocks "content" which are between the headline and the part that has # already been marked content, if they are marked MIGHT_BE_CONTENT. # This filter is quite specific to the news domain. # used downstream of KeepLargetBlockFilter since that's what sets MIGHT_BE_CONTENT module Boilerpipe::Filters c...
require 'thread' array = [] mutex = Mutex.new 5.times.map do Thread.new do mutex.synchronize do 1000.times do array << nil end end end end.each(&:join) puts array.size # 5000 # 无论何时你有多个线程共享一个对象引用时,并对其做了修改,你就要有麻烦了,除非有锁来阻止修改中的上下文切换。 # 使用了一个共享的互斥或者说锁。一旦一个线程进入mutex.synchronize内的代码块时,所有其他线...
class VipLbPoolAssignment < ActiveRecord::Base acts_as_audited acts_as_authorizable acts_as_reportable acts_as_commentable named_scope :def_scope belongs_to :vip belongs_to :lb_pool validates_uniqueness_of :vip_id, :scope => :lb_pool_id def self.default_search_attribute 'assigned_at' end ...
=begin In the previous exercise, you developed a method that converts non-negative numbers to strings. In this exercise, you're going to extend that method by adding the ability to represent negative numbers as well. Write a method that takes an integer, and converts it to a string representation. You may not u...
require 'cinch' require './models/CasinoPlayer' class Bomb include Cinch::Plugin set :prefix, /^!/ match /bomb help$/, method: :help match /bomb stat$/, method: :stat match /bomb play$/, method: :play match /bomb cut (.+)?/, method: :cut match /bomb leaderboard/, method: :leaderboard match /bomb reset$/, met...
require 'sinatra/base' require 'pry' require 'date' class Airtime < Sinatra::Base get "/airtime" do stat end def stat logfile = '/var/log/messages' result = "" macnames = Hash.new macnames['00:11:24:c5:b9:8a'] = 'Emmanuel Macbook' macnames['00:22:4c:03:a1:9e'] = 'Emmanuel Wii' m...
class Vehicle < ActiveRecord::Base belongs_to :vehicle_type belongs_to :vehicle_service belongs_to :provider end
# frozen_string_literal: true require "rails" require "large_text_field/engine" require "large_text_field/named_text_value" require "large_text_field/owner" require "large_text_field/version" module LargeTextField MAX_LENGTH = 5_000_000 end
# common utilities for CentOS servers # require 'rspec/core/shared_context' # we need a module to have a default shared_context, we can't use include_contest from RSpec.configure module PathDefender module CentOS extend RSpec::Core::SharedContext def self.centos_facts { :ipaddress ...
require 'rubygems' Gem::Specification.new do |spec| spec.name = 'bm3-core' spec.version = '0.1.2' spec.author = 'Ben Nagy' spec.license = 'MIT' spec.email = 'ben@iagu.net' #spec.homepage = '<INTERNAL ONLY>' spec.summary = 'Core components shared by BM3 projects' spec.tes...
require "rails_helper" RSpec.describe CollegeMailer, :type => :mailer do describe "activation" do it "renders the content properly" do college = create(:college) mail = CollegeMailer.activation(college) expect(mail.subject).to eq("Welcome to adaptive admission") expect(mail.to).to eq(...
require 'rails_helper' RSpec.describe CategoriesController, :type => :controller do it "should returns the success js response" do get :index, :format => 'js' response.status.should eq 200 expect(response).to be_success end it "should return the list of all history" do get :history...
class IdeaListCommentSerializer include FastJsonapi::ObjectSerializer attributes :id, :name, :active has_many :comments end
class Item < ApplicationRecord extend ActiveHash::Associations::ActiveRecordExtensions belongs_to_active_hash :prefecture belongs_to_active_hash :category belongs_to_active_hash :status belongs_to_active_hash :shipping_fee belongs_to_active_hash :shipping_date has_one_attached :image belongs_to :user ...
# -*- encoding : utf-8 -*- Dado /^que se tiene al menos una palabras con multiples significados$/ do @palabra = FactoryGirl.create(:palabra_con_traducciones) end Dado /^que se encuentra en el listado de palabras$/ do visit palabras_path end Cuando /^se le de click en el botón para agregar variante$/ do click_li...
class Anagram attr_accessor :word def initialize(word) @word = word end def match(array) match_array = [] #array_of_words = array.sort array.each do |words| if @word.split("").sort == words.split("").sort match_array << words end end match_array end end
=begin Insights Service Approval APIs APIs to query approval service OpenAPI spec version: 1.0.0 Generated by: https://github.com/swagger-api/swagger-codegen.git =end class Workflowgroup < ApplicationRecord belongs_to :workflow belongs_to :group end
class AppointmentsController < ApplicationController def index @appointments = Appointment.all #@dockies = Doctor.find(current_doctor) #@dockies = Doctor.first end def new @appointment = Appointment.new end def create @appointment = Appointment.new(appointment_params) ...
#!/bin/ruby #-- # Copyright (C) 2014 Harald Sitter <sitter@kde.org> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License or (at your option) version 3 or any later...
class Yogurt < ActiveRecord::Base validates_presence_of :name, :calories validates_numericality_of :calories end
class User < ActiveRecord::Base before_destroy :confirm_no_candidates include FriendlyId friendly_id :login has_many :candidates validates :name, presence: true validates :login, presence: true, uniqueness: true attr_accessible :login, :name default_scope order: 'name ASC' private def confi...
module Admin class BeliefsController < Admin::BaseController before_action only: [:show, :edit, :update, :destroy] def new @belief = Belief.new end def create @belief = Belief.new(belief_params) if @belief.save flash[:notice] = 'About Page has been created' redirect...
require 'spec_helper' describe 'DDTC ITAR Debarred Parties API V1', type: :request do include_context 'ScreeningList::Dtc data' describe 'GET /v1/consolidated_screening_list/dtc/search' do let(:params) { {} } before { get '/v1/consolidated_screening_list/dtc/search', params } context 'when search par...
class AddRatingToPhotos < ActiveRecord::Migration def change add_column :photos, :rating, 'int unsigned', :default => 0, :null => false, :after => :size end end
#sets of information that could possibly be displayed on an order class OrderColumn def self.all list = { past_experience: { header: "Confidence rating", code: "d.past_experience", css_class: "center" }, bid_status: { header: "Bid status", code: "bid...
class UserNoteController < ApplicationController def create @note = UserNote.new(user_note_params) if @note.save flash[:notice] = 'User note successfully added' else flash[:alert] = "Errors on user note #{@note.errors.messages}" end redirect_to edit_profile_path(@note.user_id) end ...
require 'test_helper' class NotificationsControllerTest < ActionController::TestCase setup do setup_json_api setup_default_profiles @profile = @dragon @user = @profile.user end test "index should succeed" do login_user set_profile get :index, profile_id: @profile assert_response...
RSpec.configure do |config| config.include InstanceFactory config.after(:each) do instance_factory_clear! end end FactoryGirl::SyntaxRunner.send(:include, InstanceFactory)
require "spec_helper" require 'cancan/matchers' require 'report_queries' describe Product do describe "report information" do describe "counting fabrics" do describe "Jimmyz scarf" do before do role = Role.create({name: 'admin', description: 'blah'}) @user = User.create({ ...
require('spec_helper') describe(ShoeBrand) do it { should have_many(:shoe_stores) } it("ensures the length of title is at most 40 characters") do shoe_brand = ShoeBrand.new({:title => "a".*(41)}) expect(shoe_brand.save()).to(eq(false)) end it("ensures that title doesn't already exist") do ShoeBrand...
Rails.application.routes.draw do resources :posts # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html get 'about_me', to: 'pages#about_me' get 'contact', to: 'pages#contact' get 'portfolio', to: 'pages#portfolio' get 'free_printables', to: 'pages#free_pri...
# 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 Version # @return [String] version attr_accessor :...
RSpec.describe DiaperPartnerClient, type: :service do before do stub_env('PARTNER_FORM_URL', 'https://partner-form.com') stub_env('PARTNER_KEY', 'partner-key') end describe '::post' do it 'performs a POST request' do attributes = { 'id' => 123, 'partner_form_fields' => %w(section1 section2) } ...
class CartsController < ApplicationController before_action :set_cart, only: [:show, :edit, :update, :destroy] rescue_from ActiveRecord: :RecordNotFound, with: :invalid_cart private def invalid_cart logger.error "Attempts to access invalid cart #{params[:id]}" redirect_to store_url, notice: 'Invalid ca...
class Employee attr_reader :name, :title, :salary attr_accessor :boss def initialize(name, title, salary, boss = nil) @name = name @title = title @salary = salary @boss = boss add_self_to_boss_employees if boss end def add_self_to_boss_employees @boss.employees << self end def bonus(multiplier) @...
module XcodeMove class GroupMembership def initialize(group) @group = group @project = group.project @siblings = @group.children.to_set end # Returns an array of targets that have build files in `group`. def sibling_targets compiled_targets = @project.targets.select{ |t| t.re...
require 'player_options' class GameParameters PLAYER_TYPE = 'player_type' MOVE = 'move-taken' GRID = 'grid' def initialize(params, session, board_adapter) @params = params @session = session @board_adapter = board_adapter end def player_option PlayerOptions::player_type_for_id(session[PLA...
json.array!(@debates) do |debate| json.extract! debate, :id, :affirmative_id, :negative_id, :judge_left_id, :judge_right_id, :status, :start_date, :start_time, :topic_id json.url debate_url(debate, format: :json) end
module Drivy::Lint class CommitLinter def initialize(commit) @commit = commit end def lint @commit.files.each do |file| next if file.removed? lint_file(file) end end private def lint_file(file) Linters.all.each do |linter_name| linter_klass = ...
class AddReportTypeToDocuments < ActiveRecord::Migration def up add_column :documents, :report_type, :string Document.find_each do |d| d.update_attributes(report_type: d.title.titleize.delete(" ").underscore) unless d.title.blank? end end def down remove_column :documents, :report_type, :s...
######################################################################################### # # A simple terminal user interface for ProximitySearch # # Author: Paul Allen <pea1@cornell.edu> # ######################################################################################### require_relative './proximitySearch' r...
class ScrambledWordTestsController < ApplicationController before_filter :authenticate_user! def new @scrambled_word_test = ScrambledWordTest.setup_for(current_user) @scrambled_word_chart = ScrambledWordTest.chart_for(current_user) end def create @scrambled_word_test = ScrambledWordTest.new(params...
require 'van' describe Van do it 'get bikes from the dock' do docking_station = DockingStation.new bike1 = Bike.new docking_station.dock(bike1, 'broken') subject.gets_bikes_from_dock(docking_station) # Outputted print_van_stuff, came out as array so fix line 10 soon expect(subject.print_van_s...
# Copyright 2015, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the f...
# CMSBinding.rb require 'net/http' require 'rexml/document' require 'rexml/xpath' require 'rubygems' require 'memcache' module CMSBinding class Base def get_text( element ) return '' unless element.kind_of? REXML::Element return_text = '' if( element.has_elements? ) formatter ...
require 'rake' require 'anonymized/anonymizer' namespace :anonymize do task all: :environment do require 'highline/import' require 'term/ansicolor' require 'logger' include Term::ANSIColor @logger = Logger.new($stdout) @logger.formatter = proc do |severity, datetime, progname, msg| "#...
class UsersController < ApplicationController before_action :check_admin,only:[:index,:admin_index,:destroy] before_action :get_all_users,only:[:index,:admin_index] before_action :set_user,only:[:show,:edit] def new if !current_user.blank? log_out end @user=User.new end def create ...
# encoding: UTF-8 # Copyright 2012 Twitter, Inc # http://www.apache.org/licenses/LICENSE-2.0 require 'json' require 'open-uri' require 'set' require 'yaml' module TwitterCldr module Resources class PostalCodesImporter < Importer BASE_URL = 'https://chromium-i18n.appspot.com/ssl-address/data/' ou...
require 'rails_helper' RSpec.describe Api::V1::UserTokensController, type: :controller do describe "POST 'create'" do it "should return error without an right email add" do post :create, { user: { email: "invalid@test.com", encrypted_password: "aaaaaaa", nickname: "nick"} } parsed_response = JSON...
# Code's gotta go somewhere module Darklite # Utilities for common use class Utils # TODO: Convert to runtime config NIGHTTIME_CT = 500 EVENING_CT = 294 DAYTIME_CT = 153 def self.change_lights(brightness, temperature) $log.info "Updating lights to b: #{brightness}, t: #{temperature}" ...