text stringlengths 10 2.61M |
|---|
require 'pry'
class Dog
attr_reader :name
@@all = []
def initialize(name)
@name = name
save()
end
def self.clear_all
@@all = []
end
def save
@@all << self
end
def self.all
@@all.uniq!
@@all
end
def self.print_all
@@all.u... |
module Test
module Unit
class TestCase
def self.let(x, &block)
define_method x do
ivar_key = "@___#{x}"
unless instance_variable_defined?(ivar_key)
value = yield block
instance_variable_set(ivar_key, value)
end
instance_variable_get(iva... |
begin
source = File.new('tracks.txt', 'r')
output = File.new('output.txt', 'w')
source.each_line do |line|
output.write(line.reverse)
end
source.close
output.close
rescue
puts "Error opening file."
end |
# frozen_string_literal: true
# adds a default false activated attribute to the user table
class AddActivatedToUsers < ActiveRecord::Migration[5.2]
def change
add_column :users, :activated, :boolean, default: false
end
end
|
class FontPiazzolla < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/piazzolla"
desc "Piazzolla"
desc "Serif font family for media"
homepage "https://fonts.google.com/specimen/Piazzolla"
def install
(share/"fonts").install "Piazzoll... |
module Methods
def build_tree(arr)
arr = arr.uniq.sort unless arr.empty?
return arr[0] if arr.size < 1
mid = arr.length / 2 if arr.length.odd?
mid = (arr.length / 2) - 1 if arr.length.even?
@root = Node.new(arr[mid], build_tree(arr[0...mid]), build_tree(arr[(mid + 1)...arr.length]))
end
def... |
# frozen_string_literal: true
require "spec_helper"
describe GraphQL::Schema::Loader do
Boolean = "Boolean"
ID = "ID"
Int = "Int"
let(:schema) {
node_type = Module.new do
include GraphQL::Schema::Interface
graphql_name "Node"
field :id, ID, null: false
end
choice_type = Class.n... |
class AddBatchIdToCollectionMasterParticularReport < ActiveRecord::Migration
def self.up
add_column :collection_master_particular_reports, :batch_id, :integer, :null => false
end
def self.down
remove_column :collection_master_particular_reports, :batch_id
end
end
|
# encoding: UTF-8
require "spec_helper"
describe Gitlab::Git::Blob do
let(:repository) { Gitlab::Git::Repository.new(TEST_REPO_PATH) }
describe :find do
context 'file in subdir' do
let(:blob) { Gitlab::Git::Blob.find(repository, SeedRepo::Commit::ID, "files/ruby/popen.rb") }
it { blob.id.should ... |
class CreateAddresses < ActiveRecord::Migration
def change
create_table :addresses do |t|
t.string :street, :null => false
t.string :suite
t.string :city, :null => false
t.string :state, :null => false
t.string :zip, :null => false
t.integer :updated_by, :null => false
t.... |
require_dependency "application_controller"
require_dependency "feedjira"
module UnsFeeder
class FeedsController < ApplicationController
before_action :set_feed, :except => [:create]
before_action :authenticate_user!
def create
begin
river = current_user.rivers.find(params[:river_id])
... |
# frozen_string_literal: true
require 'spec_helper'
require 'bolt_spec/integration'
require 'bolt_spec/files'
describe "installing puppetfiles" do
include BoltSpec::Integration
let(:synced_modules) { [] }
let(:boltdir) { File.join(@root, 'Boltdir') }
# Usually temp dirs would just be created under the syste... |
class AddGuestIdToReservation < ActiveRecord::Migration[5.2]
def change
add_column :reservations, :guest_id, :integer
end
end
|
require_relative './helper'
describe ConceptQL::Operators do
Dir['./test/statements/**/*'].each do |f|
next if File.directory? f
f.slice! './test/statements/'
basename = File.basename(f)
it "should produce correct results for #{f}" do
test_type = basename.split("_").first
case test_typ... |
class CardsController < ApplicationController
before_action :authenticate_user!
before_action :set_card, only: [:show, :edit, :update, :destroy]
# GET /cards
# GET /cards.json
def index
@cards = Card.all
end
# GET /cards/1
# GET /cards/1.json
def show
end
# GET /cards/new
def new
@buy... |
module PolepinHelper
def timestamp_columns(model_class)
Polepin::Utility.timestamp_columns(model_class)
end
def record_name(record)
Polepin::Utility.record_name(record)
end
def collection_name(association)
association.name.to_s.humanize
end
def link_to_record(record)
link_to record_nam... |
require 'rails_helper'
RSpec.describe CommentsController, type: :controller do
let(:user) { User.create!(email: 'faje@fake.com', :password => '123123123') }
let(:report1) { Report.create!(title: 'rpt1', rating: 5) }
let(:comment) { Comment.create!(content: 'commentcomment') }
describe 'create' do
context... |
=begin
You notice a progress bar that jumps to 50% completion. Apparently, the door isn't yet satisfied, but it did emit a star as encouragement. The instructions change:
Now, instead of considering the next digit, it wants you to consider the digit halfway around the circular list. That is, if your list contains 10 i... |
class OutcomeItem < ApplicationRecord
has_many :outcomes
end
|
require 'spec_helper'
require 'rack-flash'
require_relative 'helpers/session_helpers'
include SessionHelper
feature 'User signs up' do
scenario 'through the sign-up link and they are added to the database' do
expect(User.count).to eq 0
expect { sign_up }.to change(User, :count).by(1)
expect(User.first.n... |
# frozen_string_literal: true
#
# This class manages all of the +ExternalService+s used by
# the system. It should be the only code aware of the actual
# external services in use by the system. Any other code should
# call the methods of this class to deal with external services.
class ExternalServiceManager
@@serv... |
class CreateStock < ActiveRecord::Migration[5.2]
def change
create_table :stocks do |t|
t.references :item, polymorphic: true, null: false
t.references :category
t.integer :total, null: false, default: 0
t.integer :available, null: false, default: 0
t.integer :in_use, null: false, de... |
class Timer
attr_accessor :seconds
def initialize
@seconds = 0
end
def seconds
@seconds
end
def time_string
hrs = @seconds/3600
@seconds -= 3600*hrs
minutes = @seconds/60
@seconds -= 60*minutes
time_string = hrs.to_s.rjust(2,"0") + ":" + minutes.to_s.rjust(... |
class CategoryController < ApplicationController
before_action :apply_gon
before_action :set_parents
def new
@children = Category.find(params[:parent_id]).children
respond_to do |format|
format.html
format.json
end
end
def show
@category_name = Category.find(params[:id])
if @... |
require 'rails_helper'
RSpec.describe UsersController, type: :controller do
login_user
let(:valid_session) { {} }
describe 'show action' do
it 'returns http success' do
get :show, params: { id: subject.current_user.id }, session: valid_session
expect(response).to be_successful
end
end
d... |
class BookController < ApplicationController
#create
get '/books/new' do
#renders new book form
redirect_if_not_logged_in
@book = Book.new
erb :'/books/new'
end
post '/books' do
#proccess form
@book = current_user.books.build(title: params[:titl... |
class CargoWagon < Wagon
def initialize
super
@wagon_type = 'грузовой'
end
end
|
class RenameNameColumnToPlaces < ActiveRecord::Migration
def change
rename_column :places, :name, :place_name
end
end
|
class Article < ActiveRecord::Base
attr_accessible :author, :content, :title, :date, :photo, :short_description,
:publication_name, :publication_link, :article_type, :enabled, :seo_title, :seo_description, :seo_keywords
validates :user_id, presence: true
validates :title, presence: true, length: { maximum: 80... |
class AddNullValuteToDateExists < ActiveRecord::Migration[5.2]
def up
change_column :testimonials, :date_exists, :boolean, null: true
end
def down
change_column :testimonials, :date_exists, :boolean, null: false
end
end
|
class ProfesorInvestigacion < ApplicationRecord
has_many :profesor
has_many :grupo_investigacion
end
|
require 'spec_helper'
require 'shared_examples'
describe Kata::Algorithms::SumOfThreeHash do
describe '#find_three' do
examples = Kata::Algorithms::SpecHelper::SumOfThree.read_examples_for_find_three
examples.each do |exmpl|
context "from #{exmpl['input']}" do
it_behaves_like "method that find... |
class Candidate < ActiveRecord::Base
belongs_to :election
validates_uniqueness_of :name, scope: :election_id
end
|
# Copyright (c) 2009-2011 VMware, Inc.
require "eventmachine"
require "em-http-request"
require "vcap/common"
require "vcap/component"
require "sinatra"
require "nats/client"
require "redis"
require "json"
require "sys/filesystem"
require "fileutils"
require "services/api"
require "services/api/const"
$LOAD_PATH.unshi... |
class RemoveYearFromMovies < ActiveRecord::Migration[5.2]
def up
remove_column :movies, :year, :integer
end
end
|
class PatientCount < ApplicationRecord
belongs_to :host
has_one :line_count
end
|
class Book < ApplicationRecord
# Association
has_many :reviews
belongs_to :author
# Custom scope
scope :by_book_name, lambda{|book_name|where(["book_name=?", book_name])}
# Validation
validates_presence_of :book_name, :short_description, :long_description, :book_chapter, :publication_date, :genre
end
|
class User < ActiveRecord::Base
validates :first_name, :last_name, :email_address, :age, :presence => true
validates :first_name, :last_name, :length => { :minimum => 2 }
validates :age, numericality: { only_integer: true, greater_than_or_equal_to: 10, less_than: 150 }
end
|
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
include SessionsHelper
# To set a cart by browser session
def current_cart
if !session[:cart_id].nil?
@cart = Cart.find(session[:cart_id])
else
@cart = Cart.new
@cart_id = session[:cart_id]
... |
require 'spec_helper'
describe Skill do
it "has a valid factory" do
expect(create :skill).to be_valid
end
describe ".associations" do
it { should belong_to :user }
it { should embed_many :questions }
end
describe ".validations" do
context "when valid" do
it { should validate_presence_... |
module EasyCRUD
module Model
extend ActiveSupport::Concern
included do
class_attribute :model_icon_name
class << self
def model_icon(icon)
self.model_icon_name = icon
end
end
end
end
end
|
class AccountsController < ApplicationController
def edit; end;
def update
if current_account.update_with_password(account_params)
flash[:success] = 'Account updated'
bypass_sign_in(current_account)
redirect_to root_path
else
flash[:error] = current_account.errors.full_messages.join... |
# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
share_examples_for "login with pending application" do
context "when pending application" do
before(:each) do
@application = JobApplication.new(job: mock_model(Job), motivation: "Just because")
session[:p... |
class Document < ActiveRecord::Base
resourcify
#attr_accessible :avatar, :avatar_cache
belongs_to :project
enum status: {project: 0, personal: 1, publish: 2}
mount_uploader :avatar, AvatarUploader
validates :project_id,:name,:status,:size, presence: true
def size_s
s = self.size
if s < 1024
... |
# -*- coding: utf-8 -*-
#
# Author:: lnznt
# Copyright:: (C) 2011 lnznt.
# License:: Ruby's
#
require 'gmrw/extension/all'
require 'gmrw/ssh2/loggable'
module GMRW; module SSH2; module Server; class Connection
module Channel
include SSH2::Loggable
forward [:die, :logger, :at_close] => :service
class RW... |
class InstitutionAttendant < ActiveRecord::Base
attr_accessible :institution_id, :user_id
belongs_to :user
end
|
module EventosAdversosHelper
def leve_moderado_intenso?(codigo)
case (codigo)
when EventoAdverso::LEVE
"Leve"
when EventoAdverso::MODERADO
"Moderado"
when EventoAdverso::SEVERO
"Severo "
else
"N/A"
end
end
end
|
class ProposalQuery
def initialize(proposal)
@proposal = proposal
end
def approvers
User.joins(:steps).where(
"steps.type = :step_type AND steps.proposal_id = :proposal_id",
step_type: "Steps::Approval",
proposal_id: proposal.id
).order("steps.position ASC")
end
def purchasers
... |
require 'test_helper'
class TestDeadpoolFailoverProtocolEtcHosts < Test::Unit::TestCase
def setup
app_root = File.expand_path('../../..', __dir__)
config_file = File.join(app_root, 'test', 'fixtures/etc_hosts.yml')
@config = YAML.load(File.read(config_file))
@failover_config = @config['failover_prot... |
class LikesController < ApplicationController
def create
@bookmark = Bookmark.find(params[:bookmark_id])
like = current_user.likes.build(bookmark: @bookmark)
if like.save
flash[:notice] = "You liked the bookmark."
redirect_to(:back)
else
flash[:error] = "The bookmark couldn't be liked... |
# encoding: utf-8
require "logstash/outputs/base"
require "logstash/namespace"
require "aws-sdk"
require "yaml"
require "securerandom"
class LogStash::Outputs::DynamoDB < LogStash::Outputs::Base
config_name "dynamodb"
config :table_name, :validate => :string, :required => true
config :region, :validate => :strin... |
require_relative '../../../../spec_helper'
describe 'icinga::service_template', :type => :define do
let(:title) { 'important_service' }
let(:params) { {'contact_groups' => ['jims_friends','jims_enemies']}}
it { is_expected.to contain_file('/etc/icinga/conf.d/service_template_important_service.cfg').
with_con... |
class ProposalDecorator < Draper::Decorator
delegate_all
def detailed_status
if object.status == "pending" && actionable_steps.any?
"pending"
else
object.status
end
end
def capitalized_detailed_status
detailed_status.capitalize
end
def total_price
client_data.try(:total_pr... |
# Represents the concept of a Guess - a single character which a user has
# guessed in the context of a game
class Guess < ApplicationRecord
belongs_to :game
validates :value,
format: { with: /\A{1}[A-Za-z]\z/, message: \
'must consist of a single alpha char only' },
uniqueness... |
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
if Rails.env.production?
abort('The Rails environment is running in production mode!')
end
require 'spec_helper'
require 'rspec/rails'
RSpec.configure ... |
class ReturnCalculator
attr_reader :property, :year
def initialize(property, year)
@property, @year = property, year
end
def cash_flow
@cash_flow ||= CashFlowCalculator.calculate(property, year)
end
def appreciation
@appreciation ||= EquityFromAppreciationCalculator.calculate(property, year)
... |
class AddLevelToUsers < ActiveRecord::Migration
def change
add_column :users, :level, :string
add_column :users, :name, :string
add_column :users, :point, :integer, default: 0, null: false
add_column :users, :introduce, :text
#add_column :users, :image, :string
end
end
|
class CollegesController < ApplicationController
def index
list
render :action => 'list'
end
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
verify :method => :post, :only => [ :destroy, :create, :update ],
:redirect_to => { :action => :list }
def list
@college_... |
Yt.configure do |config|
config.api_key = CONFIG['google_api_key']
end
|
require "net/http"
require "cgi"
module Vanity
class Metric
# Specifies the base URL to use for a remote metric. For example:
# metric :sandbox do
# remote "http://api.vanitydash.com/metrics/sandbox"
# end
def remote(url = nil)
@remote_url = URI.parse(url) if url
@mutex ||= Mu... |
require('minitest/autorun')
require('minitest/rg')
require_relative('../card.rb')
class TestCard < MiniTest::Test
def setup()
@card1 = Card.new("spade", 1)
end
def test_suit_of_card()
assert_equal("spade", @card1.suit)
end
def test_value_of_card()
assert_equal(1, @card1.value)... |
puts "Play Paper Rocks Scissors!"
choice_array = %w(p r s)
choice_hash = {"r" => "Rocks", "p" => "Paper", "s" =>"Scissors"}
def winning_choice(selection)
case selection
when 'r'
puts "Rock smashes Scissor"
when 's'
puts "Scissors cuts Rocks"
when 'p'
puts "Paper wraps Rocks"
end
end
loop do
... |
# frozen_string_literal: true
require 'test_helper'
describe FeedFetcher do
describe 'performed with non existing feed' do
it 'raises Shreds::InvalidFeed exception' do
assert_raises(Shreds::InvalidFeed) { described_class.new.perform 'example.com' }
end
end
describe 'performed with existing feed' ... |
class Reservations < ActiveRecord::Migration
def change
create_table :reservations do |t|
t.integer :pure_id
t.string :doi
t.datetime :created_at
t.string :created_by
end
end
end
|
class User < ActiveRecord::Base
rolify
has_one :user_profile, :dependent => :destroy
has_many :posts, :dependent => :destroy
accepts_nested_attributes_for :user_profile
acts_as_follower
acts_as_followable
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable a... |
class Assignment < ActiveRecord::Base
belongs_to :group
belongs_to :giver, class_name: 'User'
belongs_to :receiver, class_name: 'User'
validates :group_id, :giver_id, :receiver_id, presence: true
end
|
class UpdateInfoForProduct < ActiveRecord::Migration
def change
add_column :products, :active, :boolean
remove_column :products, :exotic, :boolean
remove_column :products, :farm, :boolean
remove_column :products, :domestic, :boolean
end
end
|
class ScriptJob < ApplicationJob
queue_as :default
def perform run
return if run.canceled?
run.mark_as_running
Run.transaction do
run.should_be_canceled? ? run.cancel : run.execute
run.execute_triggers
end
end
end
|
ActiveAdmin.register Host do
menu priority: 3, label: "Testing Sites"
permit_params :name, :address_1, :address_2, :city, :state, :zipcode
index do
selectable_column
id_column
column :name
column :address_1
column :address_2
column :city
column :state
column :zipcode
actions
... |
class Tweet < ApplicationRecord
validates :content, presence: true
belongs_to :user
has_many :likes
has_many :retweets
paginates_per 50
scope :tweets_for_me, -> (ids) { where(user_id: ids)}
#scope :last_user_retweet, ->(ids) { maximum(created_at:) }
end
|
xml.rss(RSS_SPEC) do
xml.channel do
xml.title @feed[:title]
xml.link @feed[:link] || "http://www.scpr.org"
xml.atom :link, href: all_news_feed_url(format: :xml), rel: "self", type: "application/rss+xml"
xml.description @feed[:description]
xml << render_content(@content.first(15),"f... |
require_relative '../test_case'
module RackRabbit
class TestHandler < TestCase
#--------------------------------------------------------------------------
def test_handle_message
handler = build_handler
message = build_message
response = handler.handle(message)
assert_equal(200, ... |
class RenameSubjectInSubjects < ActiveRecord::Migration
def change
rename_column :subjects, :subject, :subject_name
end
end
|
#
#
#
# todo:
# - server aufsetzen und verlinken im Intranet
# - server per ssh key erreichbar
#
#
#
set :application, "BerichtsheftTool"
set :domain, "192.168.10.47"
set :deploy_to, "/var/www/projects/berichtshefttool"
set :app_path, "app"
set :user, "root"
set(:password) { Capistrano:... |
require 'test_helper'
class BindersControllerTest < ActionController::TestCase
setup do
@binder = binders(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:binders)
end
test "should get new" do
get :new
assert_response :success
end
... |
require "ripper"
require "pp"
code = 'puts "Hello, World!"'
actual = Ripper.sexp(code)
# [:program,
# [[:command,
# [:@ident, "puts", [1, 0]],
# [:args_add_block,
# [[:string_literal,
# [:string_content, [:@tstring_content, "Hello, World!", [1, 6]]]]],
# false]]]]
# Shape of a node:
# [:identifie... |
module Authority
# Gets included into the app's controllers automatically by the railtie
module Controller
extend ActiveSupport::Concern
include ActiveSupport::Rescuable unless defined?(Rails)
def self.security_violation_callback
Proc.new do |exception|
# Through the magic of `instance_e... |
source 'https://supermarket.getchef.com'
# OSL Base deps
cookbook "aliases", git: "git@github.com:osuosl-cookbooks/aliases"
cookbook "apt", ">= 2.3.8"
cookbook "base", git: "git@github.com:osuosl-cookbooks/base"
cookbook "database", ">= 2.0.0"
cookbook "firewall", git: "git@github.com:osuosl-cookbooks/firewall"
cookbo... |
#!/usr/bin/ruby
require 'socket'
xnfs_server = (ARGV[0])
target_port = (ARGV[1] || 2049)
#RPC/Portmap packet
beepbeep=
"\x1c\xd1\xef\xab" + # XID
"\x00\x00\x00\x00" + # Message Type: Call (0)
"\x00\x00\x00\x02" + # RPC Version: 2
"\x00\x01\x86\xa3" + # Program: 100003
"\x00\x00\x00\x02" + # Program Version: 2
"\x0... |
#!./miniruby
while arg = ARGV[0]
break ARGV.shift if arg == '--'
/\A--([-\w]+)(?:=(.*))?\z/ =~ arg or break
arg, value = $1, $2
re = Regexp.new('\A'+arg.gsub(/\w+\b/, '\&\\w*')+'\z', "i")
case
when re =~ "srcdir"
srcdir = value
when re =~ "archdir"
archdir = value
when re =~ "extout"
extout... |
# donmai.us specific
class CloudflareService
def key
Danbooru.config.cloudflare_key
end
def email
Danbooru.config.cloudflare_email
end
def zone
Danbooru.config.cloudflare_zone
end
def options
Danbooru.config.httparty_options.deep_merge(headers: {
"X-Auth-Email" => email,
"X... |
shared_examples "CommonAttributes::DiscountRate is included" do
[25, 50, 100].each do |percent|
it { should allow_value(percent).for(:discount_rate) }
end
[nil, 1, 75].each do |percent|
it { should_not allow_value(percent).for(:discount_rate) }
end
end
shared_examples "CommonAttributes::OfferCapCent... |
require 'chefspec'
# here lies the fur of many yaks
# TLDR: https://github.com/chefspec/chefspec/issues/718
ENV['BERKSHELF_CHEF_CONFIG'] = '/dev/null'
require 'chefspec/berkshelf'
require 'aws-sdk'
TOPDIR = __dir__
$LOAD_PATH << __dir__
# Require all our libraries
Dir['libraries/*.rb'].each { |f| require File.expand_... |
require 'colorize'
require 'simnos/utils'
module Simnos
class DSL
class Subscription
include Simnos::TemplateHelper
def create
Simnos.logger.info("Create Topic(#{@aws_topic[:topic].topic_arn.split(':').last}) Subscription. protocol: #{protocol.inspect}, endpoint: #{masked_endpoint.inspect}#{... |
require 'sqlite3'
require 'singleton'
require 'byebug'
class QuestionsDatabase < SQLite3::Database
include Singleton
def initialize
super('questions.db')
self.type_translation = true
self.results_as_hash = true
end
end
class User
attr_accessor :fname, :lname
attr_reader :id
def initialize(o... |
class Book < ActiveRecord::Base
belongs_to :author
has_and_belongs_to_many :bookstores
attr_accessible :name
end |
class Api::SessionsController < Devise::SessionsController
respond_to :json
include NoJSONRoot
skip_before_action :verify_authenticity_token
def create
if params[:user][:uid].present?
@authenticate = find_authentication
if @authenticate.present?
sign_in_user(@authenticate, "No #{@authen... |
require 'spec_helper'
begin
require File.expand_path("lib/cluster_data.rb")
require File.expand_path("lib/hypervisor_node.rb")
rescue NameError => ex
raise("Failed to load: #{ex}")
end
describe BACH::ClusterData::HypervisorNode do
include BACH::ClusterData::HypervisorNode
context 'lists vms' do
#
# ... |
require File.dirname(__FILE__) + '/../test_helper'
class NodeGroupNodeAssignmentTest < Test::Unit::TestCase
fixtures :nodes
fixtures :node_groups
fixtures :node_group_node_group_assignments
# See comment below about why we're not using this fixture
#fixtures :node_group_node_assignments
def test_virtual... |
class ImagesController < ApplicationController
before_action :set_post, only: [:create, :destroy, :new]
def new
@image = Image.new
end
def create
@image = @post.images.new(image_params)
@image.user = current_user
authorize @image
if @image.save
flash[:notice] = "Image was saved."
redirect_to @post... |
class TodoItemsController < ApplicationController
before_action :set_todo_list
def create
@todo_item = @todo_list.todo_items.create(todo_item_params)
respond_to do |format|
format.html {redirect_to @todo_list}
format.js
end
end
def destroy
@todo_item = @todo_list.todo_items.find(params[:id])
@todo_... |
class AlterTableCampaignsDropConstraintFkCampaignsModeratorId < ActiveRecord::Migration
def up
execute <<-SQL
ALTER TABLE campaigns DROP CONSTRAINT IF EXISTS fk_campaigns_moderator_id;
SQL
end
def down
end
end
|
# -*- mode: ruby -*-
# vi: set ft=ruby :
# This Vagrantfile and puppet manifest package is intended to be used for DEVELOPMENT ONLY
#
# Will run a Symfony 2 Application set up with traditional LAMP (No Mongo)
# Additionally supports Java (Solr using Jetty) and Predis
# Intended to be used with your files hosted on th... |
class FrontendController < ApplicationController
before_filter :correct_key, only: [:edit, :update_project_from_json]
def new
@project = Project.new
render :layout => 'frontend'
end
def edit
render :layout => 'frontend'
end
def new_project_from_json
@project = Project.new
sav... |
class CreateContacts < ActiveRecord::Migration
def change
create_table :contacts do |t|
t.integer :from, null: false
t.integer :to, null: false
t.timestamps
end
add_index :contacts, :from
add_index :contacts, :to
end
end
|
class CommentsController < ApplicationController
respond_to :html, :json
# GET /1/comments/1
# GET /1/comments/1.json
def show
@comment = Comment.find(params[:id])
respond_with @comment
end
# POST /1/comments
# POST /1/comments.json
def create
if params[:comment_id]
@parent = Comme... |
module TrackRate
class SendGridsController < ApplicationController
def open
tracking_object = tracking_class.find_by(sanitized_params[:email])
ProcessOpen.perform(tracking_object, 'email')
end
private
def sanitized_params
params.permit(:email)
end
end
end
|
class Description < ActiveRecord::Base
validates :description, :length => { :maximum => 16384 } , :presence => true
validates :submitter_id, :presence => true
validates :image_id, :presence => true
belongs_to :image
end
|
class FontNotoSansThai < Formula
head "https://noto-website-2.storage.googleapis.com/pkgs/NotoSansThai-unhinted.zip", verified: "noto-website-2.storage.googleapis.com/"
desc "Noto Sans Thai"
homepage "https://www.google.com/get/noto/#sans-thai"
def install
(share/"fonts").install "NotoSansThai-Black.ttf"
... |
# require 'csv'
require_relative 'player'
require_relative 'die'
require_relative 'game_turn'
require_relative 'treasure_trove'
module StudioGame
class Game
attr_reader :title
def initialize(title)
@title = title
@players = []
end
def add_player(player)
@players << player
e... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.