text
stringlengths
10
2.61M
#!/usr/bin/ruby $: << File.dirname(__FILE__) + "/../lib" require 'net/ssh/telnet' # Example showing debugging possibilities # Dump the ssh interaction to stdout.. ssh = Net::SSH.start(nil, nil, :host_name => "127.0.0.1", :user => "demo", :password => "g...
require 'spec_helper' describe Banker::BarclaycardUK do let(:support_files) {File.expand_path('../../support/barclaycard_uk/',__FILE__)} LOGIN_ENDPOINT = 'https://bcol.barclaycard.co.uk/ecom/as2/initialLogon.do' EXPORT_ENDPOINT = 'https://bcol.barclaycard.co.uk/ecom/as2/export.do?doAction=processRecentExportTra...
require "amqp" EventMachine.run do connection = AMQP.connect(:host => '127.0.0.1') puts "Connected to AMQP broker. Running #{AMQP::VERSION} version of the gem..." CHANNEL = AMQP::Channel.new(connection) exchange_in = CHANNEL.direct("logger.exchange") queue_in = CHANNEL.queue("low_logfile", :auto_delete => f...
# # Author:: Matheus Mina (<mfbmina@gmail.com>) # © Copyright IBM Corporation 2015. # # LICENSE: MIT (http://opensource.org/licenses/MIT) # Shindo.tests("Fog::Softlayer[:product] | place_order_test", ["softlayer"]) do @sl = Fog::Softlayer[:product] tests('success') do # should be an empty array tests("#pl...
# frozen_string_literal: true require 'rails_helper' describe '管理画面:アカウント削除', type: :system do context 'ログインしているとき' do let!(:user) { FactoryBot.create(:user, name: '削除データ') } before do sign_in_as(login_user) visit admin_users_path end context '権限が not_administrator のとき' do let(:l...
# encoding: UTF-8 require 'test/unit' require 'rack' require 'thin' require 'nokogiri' require 'restclient' require './lib/upton' require 'fileutils' module Upton module Test # class ProPublicaScraper < Upton::Scraper # def initialize(a, b, c) # super # @verbose = false # @debug =...
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require File.expand_path(File.dirname(__FILE__) + '/../rspec_methods') describe MenuItem do before(:each) do @menu_item = MenuItem.new end describe "validations" do it "should not be valid without text" do @menu_item.should_not b...
require_relative 'test_helper' begin require 'tilt/wikicloth' describe 'tilt/wikicloth' do it "is registered for '.mediawiki' files" do assert_equal Tilt::WikiClothTemplate, Tilt['test.mediawiki'] end it "is registered for '.mw' files" do assert_equal Tilt::WikiClothTemplate, Tilt['test.m...
require 'spec_helper' describe Susanoo::ServerSync::Helpers::Loggable do class LoggableIncluded include Susanoo::ServerSync::Helpers::Loggable end subject{ LoggableIncluded.new } describe "クラスメソッド" do subject{ LoggableIncluded } it { should respond_to :logger } it { should respond_to :logge...
json.set! :data do json.array! @announcements do |announcement| json.partial! 'announcements/announcement', announcement: announcement json.url " #{link_to 'Show', announcement } #{link_to 'Edit', edit_announcement_path(announcement)} #{link_to 'Destroy', announcemen...
#!/usr/bin/env ruby require 'skeleton' require 'metasploit' class WgetExecute < Skeleton include Msf::Options attr_reader :ducky self.title = 'WGET Execute' self.description = 'Download and Execute binary file ' def setup @host = @server_setup.host @port = @server_setup.port @ssl = @server_setup....
# Sum of Multiples class SumOfMultiples def initialize(*args) @divisor = args end def self.to(number) new(3, 5).to(number) end def to(number) multiples = [] @divisor.each do |divisor| multiples.push((0...number).map { |e| (e % divisor == 0) ? e : 0 }) end multiples.flatten.uniq...
IPS = {central: '192.168.150.100', central_2: '172.24.4.10', worker1: '192.168.150.101', worker1_2: '172.24.4.11', } RAM = 8000 VCPUS = 4 Vagrant.configure(2) do |config| vm_memory = ENV['VM_MEMORY'] || RAM vm_cpus = ENV['VM_CPUS'] || VCPUS config.vm.provider 'libvirt' do ...
class Wmata include ActionView::Helpers::TextHelper def station(search) station_list = get_station_list white = Text::WhiteSimilarity.new best_match = station_list['Stations'].sort { |a, b| white.similarity(b['Name'], search) <=> white.similarity(a['Name'], search) }.first stations = station_list[...
require 'spec_helper' require 'cancan/matchers' describe Customer do describe "with monkeypatched string class" do describe "fullname 'barack obama'" do it "returns 'barack_obama'" do @customer = Customer.new @customer.stub firstname:...
name 'workstation' maintainer 'Victor Mendo' maintainer_email 'victor.mendo@oracle.com' license 'all_rights' description 'Installs/Configures workstation' long_description 'Installs/Configures workstation' version '0.2.0'
class CommentsController < ApplicationController before_filter :set_access_control_headers def index @web_page = WebPage.find_or_create_by full_url: params[:web_page] render :json => @web_page.to_json end private def set_access_control_headers headers['Access-Control-Allow-Origin'] = '*' he...
require 'test_helper' class CotizmescamsControllerTest < ActionDispatch::IntegrationTest setup do @cotizmescam = cotizmescams(:one) end test "should get index" do get cotizmescams_url assert_response :success end test "should get new" do get new_cotizmescam_url assert_response :success ...
require 'forwardable' module Inspector def self.included(klass) klass.class_eval do extend Forwardable extend InspectorClassMethods @visible_vars = [] @hidden_vars = [:@inspected_vars] @visible_fields = [] @hashed_fields = [] @hide_vars = false def_delegat...
require "rails_helper" RSpec.feature "Show Unread button" do context "As an authenticated user on the index page" do let(:user) { create(:user) } before do create_list(:link, 5, user: user) user.links.last.update(read: true) user.links.first.update(read: true) allow_any_instance_of(A...
require 'machinist/active_record' require 'sham' Sham.define do name { Faker::Name.name } login { Faker::Name.first_name + " " + Faker::Name.last_name } first_name { Faker::Name.first_name } last_name { Faker::Name.last_name } email { Faker::Internet.email } activation_code { rand(10) } label { Faker::Lo...
module Geotab class Device include Geotab::Concerns::Findable include Geotab::Concerns::Initializable def status_data Geotab::StatusDatum.with_connection(parent).where({'deviceSearch' => {'id' => data.id}}) end def odometer_readings Geotab::StatusDatum.with_connection(parent).where({...
require 'rails_helper' describe Card do it 'create card with empty original text' do expect { create(:card, :with_empty_original_text) } .to raise_error(ActiveRecord::RecordInvalid) end it 'create card with empty translated text' do expect { create(:card, :with_empty_translated_text) } .to r...
module Discovery class Answer < ActiveRecord::Base attr_accessible :value, :question, :user_id belongs_to :user end end
class Photo < ActiveRecord::Base belongs_to :imageable, :polymorphic => true attr_accessible :image, :project_id, :background_color, :imageable_id validates_attachment_presence :image has_attached_file :image, :styles => { :large => "571x381#", :small => "238x159#", :thumb => "119x80#" }, :url => ":s3_domain_url", ...
class CreatePhoneSectors < ActiveRecord::Migration def change create_table :phone_sectors do |t| t.string :phone t.string :extension t.references :sector, index: true, foreign_key: true t.references :organ, index: true, foreign_key: true t.timestamps null: false end end end
# frozen_string_literal: true require "rails_helper" describe "faceted searches", type: :feature, js: true do context "with limited facets for date ranges" do before do visit "/?search_field=all_fields&q=" end it "renders a histogram plot" do expect(page).to have_css("#facet-date_range_sim ....
class ArticlesController < ApplicationController before_action :require_login, except: [:show, :add_view] before_action :require_author_status, except: [:show, :comment, :add_view] before_action :check_last_post_date, only: [:new, :create] def show @author = Author.find params[:author_id] @article = @a...
class BaseFilter # NOTE the filters basically strips out unsupported tags that might not be useful on the platform attr_reader :resource, :content # defined in lib/missing_delegator which basically adds a method_missing and respond to missing include MissingDelegator def delegated_to resource end de...
class TwilioController < ApplicationController require 'cuphon_engine' def sms twiml = TwimlSmsRequest.create_from_params(params) begin run_sms_request(twiml, params) rescue Exception => e twiml.response = "ERROR: " + e.message + "\n\nBacktrace:" + e.backtrace.inspect twiml.save ...
# encoding: utf-8 require "logstash/filters/base" require "logstash/namespace" # Filter to dig out GeoJSON fields for easier usage in ElasticStack. class LogStash::Filters::GeoJSON < LogStash::Filters::Base PROPERTIES_KEY="properties" GEOMETRY_KEY="geometry" GEOJSON_LAT_INDEX=1 GEOGJSON_LON_INDEX=0 config_n...
require File.join(File.dirname(__FILE__), 'spec_helper') describe Ballot do include Rack::Test::Methods before do @alpha = Factory(:entry) @beta = Factory(:entry) @gamma = Factory(:entry) end describe ".find_or_initialize_by_name" do it "should be case insensitive" do ballot = Factory(:...
require 'test_helper' describe O::Parser do before do @parser = O::Parser.new end it 'should parse an int' do @parser.parse("1").must_equal integer: 1 @parser.parse("-1").must_equal integer: -1 end it 'should parse a string' do @parser.parse('"a string"').must_equal string: 'a string' ...
require 'rails_helper' RSpec.describe "offers/show", type: :view do before(:each) do @offer = assign(:offer, Offer.create!( :nombre => "MyText", :descripción => "MyText", :imagen => "Imagen" )) end it "renders attributes in <p>" do render expect(rendered).to match(/MyText/) ...
namespace :worklogs do desc 'Send mail to users to reminder the worklogs.' task :day => :environment do day = ENV['day'] || Date.today.to_s puts "worklogs:day: day=>#{day}" Mailer.with_synched_deliveries do WorklogMailer.day_log(day).deliver end end desc 'week report for worklogs.' ...
class Dictionary def initialize @dict = {} end def entries @dict end def add(entry) if entry.is_a?(Hash) @dict.merge!(entry) elsif entry.is_a?(String) @dict[entry] =nil end end def keywords @dict.keys.sort end def include?(word) @dict.include?(w...
class ClinicalController < ApplicationController require 'site_constants.rb' def index end def get_clinical_variables f = File.open("../data/nationwidechildrens.org_clinical_patient_" + params[:tumor_type] + ".txt", "r") data = get_variable_names_row(f).gsub("_", " ").split("\t") num_records = get_num_reco...
if defined?(::Sequel) Haystack.logger.info("Loading Sequel (#{ Sequel::VERSION }) integration") module Haystack module Integrations module Sequel # Add query instrumentation def log_yield(sql, args = nil) name = 'sql.sequel' payload = {:sql => sql, :args => args} ...
class ChangeColumnInProducts < ActiveRecord::Migration[5.1] def change change_column :products, :image, :string, null: true end end
# frozen_string_literal: true module Types class LineChartType < Types::BaseObject field :x_axis_key, String, null: false field :line_keys, [String], null: false field :data, [Any], null: false end end
class CreateBusinessConnections < ActiveRecord::Migration def change create_table :business_connections do |t| t.references :follower t.references :followed t.timestamps end add_index :business_connections, :follower_id add_index :business_connections, :followed_id end end
class QuotesController < ApplicationController protect_from_forgery prepend: true def index @quote = Quote.order("RANDOM()").first respond_to do |format| format.html format.json { render json: @quote } end end def create @quote = Quote.create(quote_params) if @quote.i...
# frozen_string_literal: true module TurnipPrice module Formula # :nodoc: class Base # @param base_price [Number] base price # @param random [SEAD::Random] generator # # @since 0.1.0 def initialize(base_price, random) @base_price = base_price @random = random ...
module Features module SessionHelpers # If this starts getting too slow, then you should try this: # https://github.com/plataformatec/devise/wiki/How-To:-Test-with-Capybara def sign_in @user = build(:user) @user.confirmed_at = Time.now @user.save login_as(@user, :scope => :user, :...
require 'spec_helper' describe GoCardless::Bill do before :each do @app_id = 'abc' @app_secret = 'xyz' GoCardless.account_details = {:app_id => @app_id, :app_secret => @app_secret, :token => 'xxx', :merchant_id => '1'} @client = GoCardless.client end it "source...
# frozen_string_literal: true class Answer < ApplicationRecord belongs_to :question validates :body, presence: true validate :answers_limit, on: :create scope :correct_answer, -> { where(correct: true) } private def answers_limit errors.add(:limit, 'question must have 1 to 4 answers') if question.a...
class Managers::GroupsController < Managers::ApplicationController before_filter :find_group, :only => [:show, :edit, :update, :destroy] before_filter :build_instructor, :only => [:new, :create] cache_sweeper :group_sweeper, :only => [:create, :update, :destroy] add_crumb("Classes") { |instance| instance....
ActiveAdmin.register Sketch do permit_params :name, :phone, :file, :email, :description, :checked_out_at config.per_page = 10 menu :priority => 3 actions :all filter :created_at, label: 'Дата создания' filter :checked_out_at, label: 'Дата ответа' filter :name, label: 'Имя' filter :phone, label: 'Телеф...
class PostsController < ApplicationController # displays all the posts made by you and your friends def index @post = current_user.posts.build @posts = feed_posts end def create current_user.posts.create(posts_params) redirect_to root_path end private def posts_params params.req...
FactoryBot.define do factory :style do name { "Black and White" } description { "Color omitted, but not the awesome-ness. Black and White styling utilizes grey-scale (mixing white into black) to achieve shading and textures." } end end
module DemoData class Customers < ModelCollection api_path :customers def initialize( count ) super() @recv_gl_id = DemoData.gl.find{|gl| gl.number=='1200' }.id ensure_record_count( count ) do begin name = FC.name ...
class ChangeColumnPostName < ActiveRecord::Migration[5.2] def change rename_column :responses, :post_type, :postable_type rename_column :responses, :post_id, :postable_id end end
# Helper Method def position_taken?(board, index) !(board[index].nil? || board[index] == " ") end # Define your WIN_COMBINATIONS constant WIN_COMBINATIONS = [ [0,1,2], # Top row [3,4,5], # Middle row [6,7,8], # Bottom row [0,3,6], # Left column [1,4,7], # Middle column [2,5,8], # Right column [6,4,2], ...
TinymceFilemanager::Engine.routes.draw do resources :images, :only => [:index, :create,:destroy] resources :files, :only => [:index, :create,:destroy] root 'home#index' end
class OperationsController < ApplicationController inherit_resources respond_to :html, :xml, :json belongs_to :case, :parent_class => PatientCase, :singleton => true, :optional => true # This controller is used as a singleton resource. For some reason, declarative_authorization doesn't like the use of # filt...
class Story < ActiveRecord::Base scope :express, -> { where(source:"express") } scope :guardian, -> { where(source:"guardian") } scope :independent, -> { where(source:"independent") } scope :mail, -> { where(source:"mail") } scope :telegraph, -> { where(source:"telegraph") } scope :times, -> { where(source:"time...
require 'rspec' require_relative '../lib/linked_list' describe 'the linked list' do let(:list) { LinkedList.new } before(:each) do list end it 'exists' do expect(list) end it 'has a head upon initialization' do expect(list.head.class).to eq(Node) expect(list.head.value).to eq("head...
class AddNotTagsToSocialInfo < ActiveRecord::Migration def change add_column :social_infos, :not_tags, :string, default:"" end end
# -*- coding: ascii -*- # # Author:: lnznt # Copyright:: (C) 2011 lnznt. # License:: Ruby's # require 'test/unit' require 'openssl' require 'gmrw/ssh2/message/datatype' class TestField < Test::Unit::TestCase include GMRW::SSH2 def try_assert_equal(tests) tests.each_with_index do |test, i| actual, expec...
class ActivityInventoriesController < ApplicationController # GET /activity_inventories # GET /activity_inventories.xml def index @activity_inventories = ActivityInventory.find(:all) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @activity_inventories } e...
class FontLektonNerdFont < Formula version "2.3.3" sha256 "56e437509e5e56a18909f1a167858fba5f8e43c98055590ec645eb55ed47670c" url "https://github.com/ryanoasis/nerd-fonts/releases/download/v#{version}/Lekton.zip" desc "Lekton Nerd Font (Lekton)" desc "Developer targeted fonts with a high number of glyphs" ho...
class FontNotoSansShavian < Formula head "https://noto-website-2.storage.googleapis.com/pkgs/NotoSansShavian-unhinted.zip", verified: "noto-website-2.storage.googleapis.com/" desc "Noto Sans Shavian" homepage "https://www.google.com/get/noto/#sans-shaw" def install (share/"fonts").install "NotoSansShavian-R...
class RenameTokenOnTokens < ActiveRecord::Migration def change rename_column :tokens, :token, :encrypted_token end end
class UsersController < ApplicationController def show @user = User.find(params[:id]) @lists = @user.lists @favorites_count = @user.count_total_favorites end end
class Tagging < ApplicationRecord belongs_to :location, optional:true belongs_to :event, optional:true belongs_to :tag, optional:true end
class ProductsController < ApplicationController def index @products = Product.all @categories = Category.all end def show @product = Product.find(params[:id]) end def new @product = Product.create(product_params) if @product.save flash[:success] = "#{@product.name} added successfu...
class Visit < Cask url 'http://portal.nersc.gov/svn/visit/trunk/releases/2.7.0/VisIt-2.7.0-x86_64-installer.dmg' homepage 'https://wci.llnl.gov/codes/visit/home.html' version '2.7.0' sha1 'be44ee53695553396895154e7c9916bb670f772c' link 'VisIt.app' end
# frozen_string_literal: true require 'jiji/test/test_configuration' require 'jiji/model/settings/security_setting' describe Jiji::Model::Settings::MailComposerSetting do include_context 'use data_builder' include_context 'use container' let(:repository) { container.lookup(:setting_repository) } before(:exam...
# assorted helpers helpers do # rails-style partials. # with one arg: use template name '_arg', set local var to arg, if it's array - repeat for # all members # with two args, first is template name, second - hash for locals def __partial(template,locals=nil) # if first arg string or symbol - then i...
class RenameUserSubscribersGroupsToSubscribersGroups < ActiveRecord::Migration def change rename_table :user_subscribers_groups, :subscribers_groups add_foreign_key :subscribers_groups, :users, on_delete: :cascade end end
require "../factory/*" module ListFactory class ListPage include Page def initialize(title:, author:) super(title: title, author: author) end def male_html buffer = String.new buffer.add("<html><head><title>#{title}</title></head>\n") buffer.add("<body>\n") buffer.add(...
class OwnersController < ApplicationController def index owners = Owner.all render json: OwnerSerializer.new(owners) end end
module UsersHelper def redirect_signed_in_user_from_signin redirect_to user_url(current_user) if signed_in? end def redirect_signed_in_user unless signed_in? redirect_to root_url, notice: "Please sign in." end end def signed_in_user unless signed_in? store_location redirect_to si...
class BasketballSimulator::CLI def initial_call player_database greeting choice end def call greeting choice end def player_database puts "Please wait while we load up our database." @players = BasketballSimulator::Player.create_players ...
module Retryable extend ActiveSupport::Concern mattr_accessor :retry_delay, :retry_attempts included do rescue_from(StandardError) do |exception| if attempts >= Retryable.retry_attempts after_retry_attempts raise exception end retry_job wait: Retryable.retry_delay end ...
class User < ActiveRecord::Base validates_format_of :username, :with => /[a-z][a-z0-9]{2,20}/i, :message => 'debe ser alfa-numérico de 3 a 20 caracteres.' validates_format_of :password, :with => /[a-z][a-z0-9]{2,20}/i, :message => 'debe ser alfa-numérico de 3 a 20 caracteres.' end
#!/usr/bin/ruby runType = "newreno" #runType = "reno" #runType = "reno_rto" if ARGV.size < 1 puts "Usage: ./gen_tput_vs_servers_buf_fixed.rb runType" exit end runType = ARGV[0] BASEDIR = ".." puts BASEDIR GRAPHDIR = "#{BASEDIR}/graphs" synchSizeInK = 256 #synchSizeInK = 8000 bufSizeInPackets = 64 runTimeIn...
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe 'Twitter User' do describe 'with a username' do before(:each) do @user = User.new @user.twitter_username = 'logosity' end it 'provides the last five tweets from twitter' do tweets = [ { :text => 'tweet1'...
# frozen_string_literal: true class ChangeNoteLimitForOrderDetails < ActiveRecord::Migration def up add_column :order_details, :temp_note, :text execute("UPDATE order_details SET temp_note = note") remove_column :order_details, :note rename_column :order_details, :temp_note, :note end def down ...
# -*- encoding : utf-8 -*- class SetupPlannedMealsForMealPlanner < ActiveRecord::Migration[5.1] def change #Saved meals is a table the contains meals that users may wish to include later. It is also where the recipes # will be formed by using the ingredients list from there. #This is actually for saved ...
module Topograf class Log attr_reader :log def initialize(file) @file = file end def log @log ||= read end private def read if File.exists?(@file) && File.directory?(@file) logs = Dir.glob("#{@file}/*").collect { |log_file| File.read(log_file) } logs....
class Api::BlogController < ApplicationController def createPost begin user = self.verifyUser blogParams = params[:blog] blogParams[:user_id] = user.id post = self.getBlogPostService.createBlogPost(blogParams) resource = self.getFullBlogPostResourc...
class Link < ActiveRecord::Base belongs_to :media_item validates_presence_of :link_type validates_format_of :url, with: URI::regexp(%w(http https)) end
class UserMapper def initialize(db) @db = db @db.connection.collection('users').ensure_index({"email" => 1}, { "unique" => true}) end def find_by_email(email) if hash = @db.connection.collection('users').find_one("email" => email) User.new(hash["email"], hash["password"], hash["password"], hash...
require 'spec_helper' describe 'successful Github rate_limit GET request' do before do @response = RestClient.get 'https://api.github.com/rate_limit' @rate_limit_hash = JSON.parse(@response.body) @core = @rate_limit_hash['resources']['core'] @search = @rate_limit_hash['resources']['search'] @rate...
$:.unshift File.expand_path("../lib", __FILE__) require 'date' Gem::Specification.new do |s| s.name = "hiera_server" s.version = '0.0.1' s.date = Date.today.to_s s.summary = "Provides a remote server for Hiera lookups and a backend client." s.homepage = ...
module NBConfiguration def nb_api_token ENV['NB_API_TOKEN'] end def nb_slug ENV['NB_SLUG'] end def nb_configuration_valid? ENV['NB_API_TOKEN'].to_s.length > 0 && ENV['NB_SLUG'].to_s.length > 0 end def log_nb_configuration_error(logger) if ENV['NB_API_TOKEN'].to_s.empty? logger.war...
class User < ApplicationRecord has_many :events, foreign_key: :creator_id, dependent: :destroy has_many :attendees validates :username, presence: true, uniqueness: true validates :name, presence: true end
#!/usr/bin/env ruby require 'yaml' def deep_merge(old, new) old.merge(new) { |key, val1, val2| if val1.kind_of?(Hash) and val2.kind_of?(Hash) deep_merge(val1, val2) elsif val1.kind_of?(Array) and val2.kind_of?(Array) val1 & val2 else val2 end } end el6 = YAML.load_file('checks-e...
# 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 "rails_helper" describe "As an authenticated admin" do describe "when I visit kids index page" do it 'should show create buttons' do admin = create(:admin) kid_1 = admin.kids.create(name: "Kid 1") kid_2 = admin.kids.create(name: "Kid 2") event_1, event_2 = create_list(:event, 2) ...
require 'spec_helper' describe AdjustableImage::AdjustableStyles do describe '#reprocess_thumbnails' do let(:image) { double('image') } let(:subject) { StylesContainer.new({}, nil, false, image) } it 'reassigns the image to itself (force thumbnail reprocessing)' do expect(subject).to receive(:ima...
# -*- coding: UTF-8 -*- # # Author:: lnznt # Copyright:: (C) 2011 lnznt. # License:: Ruby's # require 'gmrw/extension/extension' require 'gmrw/extension/module' require 'gmrw/extension/attribute' require 'gmrw/extension/attribute/is' require 'singleton' module GMRW::Extension class Null include Singleton p...
# frozen_string_literal: true class TournamentTimeToAnswerJob < ApplicationJob include(GameOverHelper) include(TournamentHelper) queue_as :default def perform(game) return unless game.status == 'pending' return game.destroy if game.connected_players.size.zero? game.update!(winner_id: game.connect...
#import wx #import re # #from util import Rect, Point, say, Size #from notifications import KeyUpdateNotification, ModelChangeNotification, \ # LayerChangeNotification #from keydisplay import KeyDisplayPane, DisplayKey, DISPLAY_MODE_DYNAMIC_RESIZE, \ # DISPLAY_MODE_WRAPPED...
=begin /* * 功能: 模拟新浪微博登陆 * 用途: 模拟用户登陆, 以便进行后续操作, 比如自动化的控制自己的新浪app刷新某些数据 * 注意事项: * 1. 需要安装nodejs * 2. 需要下载新浪的加密js文件, 请到新浪登陆页查看网络请求自己下载最新版本(我当时用的: http://js.t.sinajs.cn/t35/miniblog/static/js/sso.js?version=e482ef2bbdaa8bc2) * 3. 对新浪加密js文件进行修改, 以便让nodejs可以运行它 * 1) 在文件前面增加下面内容 var window = { l...
require 'object-stream' module Funl module Blobber MARSHAL_TYPE = ObjectStream::MARSHAL_TYPE YAML_TYPE = ObjectStream::YAML_TYPE JSON_TYPE = ObjectStream::JSON_TYPE MSGPACK_TYPE = ObjectStream::MSGPACK_TYPE module JSON_SYM def self.load arg JSON.parse arg, symbolize_keys:...
class BookMailer < ActionMailer::Base default from: "success@examsuccess.com.au" def book_purchase(user, book, temp_password) @book = book @email = user.email @temp_password = temp_password # @name = user.name # New Headers headers["Message-ID"] = "success@examsuccess.com.au" head...
module Commentable extend ActiveSupport::Concern included do has_many :comments, as: :commentable, dependent: :destroy def klass_name self.class.to_s.downcase end end end
namespace :n2 do namespace :db do desc "Convert existing newscloud database to new format" task :convert_database do puts "This will convert an existing newscloud database to the new rails format" dump_file = "db/conversion_dump.sql" db_name = get_input "Database Name: " db_user = get_...