code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
# Monkey patch to avoid riddle trying to exec stuff
ENV['SPHINX_VERSION'] = '2.0.4'
require 'riddle'
module Riddle
class Controller
def sphinx_version
ENV['SPHINX_VERSION']
end
end
end
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails applicatio... | Ruby |
# Disable Rake-environment-task framework detection by uncommenting/setting to false
# Warbler.framework_detection = false
# Warbler web application assembly configuration file
Warbler::Config.new do |config|
# Features: additional options controlling how the jar is built.
# Currently the following features are su... | Ruby |
CmsRails::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned o... | Ruby |
CmsRails::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
config.cache_classes = true
config.action_controller.perform_caching = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error rep... | Ruby |
CmsRails::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web ... | Ruby |
CmsRails::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test... | Ruby |
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run CmsRails::Application
| Ruby |
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
require 'rake'
CmsRails::Application.load_tasks
if Rails.env.development? || Rails.env.test?
requ... | Ruby |
require 'gdata'
module Gdoc
DOCLIST_SCOPE = 'https://docs.google.com/feeds/'
DOCLIST_DOWNLOD_SCOPE = 'https://docs.googleusercontent.com/'
CONTACTS_SCOPE = 'https://www.google.com/m8/feeds/'
SPREADSHEETS_SCOPE = 'https://spreadsheets.google.com/feeds/'
DEFAULT_FEED = DOCLIST_SCOPE + 'default/private/full'
... | Ruby |
# Monkey patch Prawn to fix 'incompatible character encodings' error in JRuby:
# https://github.com/prawnpdf/prawn/issues/283
require 'prawn'
module Prawn
module Core
def self.utf8_to_utf16(str)
str
end
end
end
| Ruby |
# Importer contains classes and methods to import data from various formats
# into the system.
module Importer
class ImportError < StandardError
end
end
| Ruby |
require 'open-uri'
require 'csv'
module Importer
class Regulation
def initialize
end
def run_file(filename)
open(filename, 'r:utf-8') do |file|
run_csv(file.read)
end
end
def run_csv(csv_string)
directive = nil
headers_seen = false
CSV.parse(csv_string) ... | Ruby |
require 'open-uri'
require 'csv'
module Importer
# Importer for specialized CSV document format
#
# Expected columns are:
# 0-4: Company control index, unused, title, description-part-1, description-part-2
# 5-6: Directive 1: description, slug(s)
# 7-8: Directive 2: description, slug(s)
# 9-10... | Ruby |
namespace :demo do
desc "Load demo seed data"
task :seed => :environment do |t, args|
demo_seed_file = File.join(Rails.root, 'db', 'demo_seeds', 'demo_seeds.rb')
load(demo_seed_file)
end
task :setup => [:environment, :"db:seed", :"demo:seed"]
task :reset, [ :subdir ] => [:environment, :"db:reset", :s... | Ruby |
namespace :export do
desc "Export help data to YAML file"
task :help, [:filename] => [:environment] do |t, args|
puts "Exporting help data to #{args[:filename]}"
File.open(args[:filename], 'w') do |file|
YAML::dump(Help.all, file)
end
end
end | Ruby |
namespace :import do
desc "Import various documents into CMS"
task :consolidated, [:filename] => [:environment] do |t, args|
puts "Import consolidated format from #{args[:filename]}"
require 'importer/consolidated'
ActiveRecord::Base.transaction do
importer = Importer::Consolidated.new
imp... | Ruby |
# Copyright (C) 2009 Google Inc.
#
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Ruby |
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "theme/css"
sass_dir = "theme/scss"
images_dir = "images"
javascripts_dir = "js"
# You can select your preferred output style here (can be overridden via the command line):
output_style = :co... | Ruby |
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "theme/css"
sass_dir = "theme/scss"
images_dir = "images"
javascripts_dir = "js"
# You can select your preferred output style here (can be overridden via the command line):
output_style = :co... | Ruby |
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.string :profile_id
t.string :email
t.string :refresh_token
end
add_index :users, :profile_id
end
def down
drop_table :users
end
end
| Ruby |
# Copyright (C) 2012 Google Inc.
#
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Ruby |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'sinatra-activerecord'
gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client'
group :development do
gem 'rake'
gem 'sqlite3-ruby'
end
| Ruby |
require 'sinatra.rb'
# Sinatra defines #set at the top level as a way to set application configuration
set :run, false
set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development)
require './main'
run Sinatra::Application | Ruby |
require 'sinatra/activerecord/rake'
require './main' | Ruby |
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "theme/css"
sass_dir = "theme/scss"
images_dir = "images"
javascripts_dir = "js"
# You can select your preferred output style here (can be overridden via the command line):
output_style = :co... | Ruby |
require 'sinatra/activerecord/rake'
require './main' | Ruby |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'sinatra-activerecord'
gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client'
group :development do
gem 'rake'
gem 'sqlite3-ruby'
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.string :profile_id
t.string :email
t.string :refresh_token
end
add_index :users, :profile_id
end
def down
drop_table :users
end
end
| Ruby |
# Copyright (C) 2012 Google Inc.
#
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Ruby |
require 'sinatra.rb'
# Sinatra defines #set at the top level as a way to set application configuration
set :run, false
set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development)
require './main'
run Sinatra::Application | Ruby |
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "/"
sass_dir = "sass"
images_dir = "images"
javascripts_dir = "javascripts"
# You can select your preferred output style here (can be overridden via the command line):
# output_styl... | Ruby |
#!/usr/bin/env ruby -wKU
require 'rubygems'
require 'open-uri'
require 'hpricot'
begin
cssfile = ARGV[0]
source = ARGV[1]
content = ""
css_sourcefile = File.new(cssfile, "r")
css_sourcefile.each_line {|line| content << line}
# process our css file into a nice array of selectors
content.gsub!(/\/\*.... | Ruby |
#!/usr/bin/env ruby -wKU
require 'rubygems'
require 'open-uri'
require 'hpricot'
begin
cssfile = ARGV[0]
source = ARGV[1]
content = ""
css_sourcefile = File.new(cssfile, "r")
css_sourcefile.each_line {|line| content << line}
# process our css file into a nice array of selectors
content.gsub!(/\/\*.... | Ruby |
# 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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | Ruby |
class CreateQuestions < ActiveRecord::Migration
def change
create_table :questions do |t|
t.integer :qID
t.string :type
t.text :text
t.integer :PosID
t.integer :AppStatus
t.timestamps
end
end
end
| Ruby |
class SorceryCore < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :email, :null => false
t.string :crypted_password
t.string :salt
t.timestamps
end
add_index :users, :email, unique: true
end
end | Ruby |
class CreatePositions < ActiveRecord::Migration
def change
create_table :positions do |t|
t.integer :posting_id
t.integer :position_type_id
t.string :title
t.text :description
t.decimal :wage
t.integer :store_id
t.string :city
t.string :state
t.boolean :is_ope... | Ruby |
class CreateQuestionDesignerModels < ActiveRecord::Migration
def change
create_table :question_designer_models do |t|
t.timestamps
end
end
end
| Ruby |
class AddSessionsTable < ActiveRecord::Migration
def change
create_table :sessions do |t|
t.string :session_id, :null => false
t.text :data
t.timestamps
end
add_index :sessions, :session_id, :unique => true
add_index :sessions, :updated_at
end
end
| Ruby |
class CreateQuestionDesignerPages < ActiveRecord::Migration
def change
create_table :question_designer_pages do |t|
t.timestamps
end
end
end
| Ruby |
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
# Add more helper methods to be used by all tests here...
end
| Ruby |
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.8'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use C... | Ruby |
json.extract! @user, :id, :email, :crypted_password, :salt, :created_at, :updated_at
| Ruby |
json.array!(@users) do |user|
json.extract! user, :id, :email, :crypted_password, :salt
json.url user_url(user, format: :json)
end
| Ruby |
module HiringSpecialistInterviewHelper
end
| Ruby |
module ApplicationHelper
end
| Ruby |
module QuestioneditorHelper
end
| Ruby |
module StaffingExpertHelper
end
| Ruby |
module EditViewQuestionsHelper
end
| Ruby |
module HiringSpecialistHomeHelper
end
| Ruby |
module QuestionDesignerPageHelper
end
| Ruby |
module QuestionPageDesignerHelper
end
| Ruby |
module EditQuestionsHelper
end
| Ruby |
module ApplicantHelper
end
| Ruby |
module HiringSpecialistHelper
end
| Ruby |
module StoreManagerHelper
end
| Ruby |
module QuestionsHelper
end
| Ruby |
module QuestionEditHelper
end
| Ruby |
module UpdateQuestionHelper
end
| Ruby |
module HomeHelper
end
| Ruby |
class Question < ActiveRecord::Base
# title :string
# text :text
# question_type :string
# possible_answers :list
# correct_answer :integer
end
| Ruby |
class User < ActiveRecord::Base
authenticates_with_sorcery!
validates :password, length: { minimum: 3 }
validates :password, confirmation: true
validates :password_confirmation, presence: true
validates :email, uniqueness: true
end
| Ruby |
class Position < ActiveRecord::Base
end
| Ruby |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :require_login
private
def require_login
unless current_user
redirect_to(:login)
en... | Ruby |
class HiringSpecialistController < ApplicationController
def home
require 'net/http'
@pInfo = Array.new
source = 'http://140.211.68.130/GetApplication'
resp = Net::HTTP.post_form(URI.parse(source), 'state' => '1')
data = resp.body
result = JSON.parse(data)
@applications = result['quest... | Ruby |
class ApplicantController < ApplicationController
def home
end #end home
def show_open_positions
require 'net/http'
source = 'http://140.211.68.130/GetOpenPositions'
resp = Net::HTTP.get_response(URI.parse(source))
data = resp.body
result = JSON.parse(data)
@full = result['positions']
... | Ruby |
class HiringManagerController < ApplicationController
def home
uri = URI.parse('http://140.211.68.130/GetAllPositionTypes')
resp = Net::HTTP.get_response(uri)
data = resp.body
result = JSON.parse(data)
@positions = result['positions']
end
def request_openings
all_positions_uri = URI.pars... | Ruby |
class StoreManagerController < ApplicationController
def home
end
def view_requested_openings
@positions = Position.all
end
def approve
require 'json'
require 'net/http'
@position = Position.find(params[:id])
if @position.posting_id == nil
@position.posting_id = params[:id]
e... | Ruby |
class StaffingExpertController < ApplicationController
def home
require 'net/http'
source = 'http://140.211.68.130/GetAllPositionTypes'
resp = Net::HTTP.get_response(URI.parse(source))
data = resp.body
result = JSON.parse(data)
@full = result['positions']
end #end home
def questions
... | Ruby |
class UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update, :destroy]
skip_before_filter :require_login, only: [:index, :new, :create]
# GET /users
# GET /users.json
def index
if(session[:permission].to_i < 5)
redirect_to(:login)
end
@users = User.al... | Ruby |
class UserSessionsController < ApplicationController
skip_before_filter :require_login, except: [:destroy]
def new
@user = User.new
end
def create
if @user = login(params[:email], params[:password])
# Get user permission here
require 'net/http'
source = 'http://140.211.68.130/getuse... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflec... | Ruby |
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a probl... | Ruby |
# Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters f... | Ruby |
# Be sure to restart your server when you modify this file.
Rails.application.config.action_dispatch.cookies_serializer = :json | Ruby |
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
| Ruby |
# Be sure to restart your server when you modify this file.
#Rails.application.config.session_store :cookie_store, key: '_CTeam_session'
Rails.application.config.session_store :active_record_store, key: '_CTeam_session'
| Ruby |
# The first thing you need to configure is which modules you need in your app.
# The default is nothing which will include only core features (password encryption, login/logout).
# Available submodules are: :user_activation, :http_basic_auth, :remember_me,
# :reset_password, :session_timeout, :brute_force_protection, :... | Ruby |
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password]
| Ruby |
Rails.application.routes.draw do
get 'login' => 'user_sessions#new', :as => :login
get 'logout' => 'user_sessions#destroy', :as => :logout
get 'applicant/home'
get 'applicant/show_open_positions'
get 'applicant/apply'
post 'applicant/start_questionnaire'
post 'applicant/app_submit'
get 'hiring_manager/... | Ruby |
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
| Ruby |
require File.expand_path('../boot', __FILE__)
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 CTeam
class Application < Rails::Application
# Settings in config/environments/* take precede... | Ruby |
# Load the Rails application.
require File.expand_path('../application', __FILE__)
# Initialize the Rails application.
Rails.application.initialize!
| Ruby |
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web serve... | Ruby |
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web serv... | Ruby |
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suit... | Ruby |
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Rails.application
| Ruby |
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Rails.application.load_tasks
| Ruby |
#!/usr/local/bin/ruby
# Copyright (C) 2003-2010 Wang Pengcheng <wpc0000@gmail.com>
# , released under the MIT license
# You may obtain a template of the MIT License at
# http://www.opensource.org/licenses/mit-license.php
$KCODE = 'utf8'
args = '["'+ARGV.join(' ')+'"]'
args ='' if ARGV.length <= 0
system 'rake','ci'+ar... | Ruby |
#!/usr/local/bin/ruby
require 'rubygems'
require 'zipruby'
require 'openssl'
require 'digest/sha1'
require 'fileutils'
require 'find'
require 'pathname'
class CrxMake < Object
VERSION = '2.0.2'
# thx masover
MAGIC = 'Cr24'
# this is chromium extension version
EXT_VERSION = [2].pack('L')
# CERT_PUBLIC... | Ruby |
#! /usr/local/bin/ruby
$KCODE = 'utf8'
require 'net/http'
require 'net/https'
# Check the server
def link_https?(server,path, username, password)
http = Net::HTTP.new(server,443)
req = Net::HTTP::Get.new(path)
#https
http.use_ssl = true
req.basic_auth username, password
begin
http.request(req)
retu... | Ruby |
#!/usr/local/bin/rake
# Copyright (C) 2003-2010 Wang Pengcheng <wpc0000@gmail.com>
# , released under the MIT license
# You may obtain a template of the MIT License at
# http://www.opensource.org/licenses/mit-license.php
$KCODE = 'utf8'
require 'fileutils'
require 'yaml'
def confirm(msg)
puts msg+'[y/n]?'
f = STD... | Ruby |
require 'fileutils'
def backup(file_name)
FileUtils.cp(file_name, file_name + ".bak")
end
def longest_code(file_name)
longest = 0
File.readlines(file_name).each do |line|
if line.include? '#' and not line.strip.start_with? '#'
code = line[0..line.index('#') - 1]
code.rstrip!
... | Ruby |
# This is the configuration file for problem "test" from round "test"
# Set the input file:
$InputFile = "test.in"
# Set the output file:
$OutputFile = "test.out"
# Set the ok file;
$OKFile = "test.ok"
# Set the granted source, the one must trusted, it will be used to compare it's output with the others.
# Note: ... | Ruby |
# This is the configuration file required for c-tester.
# Don't edit it unless you really know about it !!
$users = ["user1", "user2", "user3", "user4"]; # Write here all users
# Note: in default installation, user1, user2 and user3 have binary executables, written with gcc, g++ and gpc, and user4 has a script writ... | Ruby |
$vertex_degree = Queue.new
$vertices_for_degree_hash = Hash.new
$adjoinable_vertices = Hash.new
$genomes = Queue.new
$ans = []
$m = -1
$degree_backup = []
$hist = []
def filter_adjoinables!(vertices, v)
v.adjList.each { |w|
vertices.delete(w)
}
vertices.delete(v)
end
def compute_k(g)
n = g.count_v
max... | Ruby |
load "wgraph.rb"
def make_sample_graph
$g = WGraph.new
v = [Vertex.new(0)]
for i in 1..12
v << Vertex.new(i)
end
for i in 1..12
$g.add_vertex(v[i])
end
$g.add_edge(v[1], v[2], 1)
$g.add_edge(v[1], v[11], 1)
$g.add_edge(v[1], v[7], 1)
$g.add_edge(v[2], v[3], 1)
$g.add_edge(v[2], v[11], 1)
$g.add_edge(v[3], v[10... | Ruby |
load "wgraph.rb"
$g = WGraph.new
v = [Vertex.new(0)]
for i in 1..12
v << Vertex.new(i)
end
for i in 1..12
$g.add_vertex(v[i])
end
$g.add_edge(v[1], v[2], 1)
$g.add_edge(v[1], v[11], 1)
$g.add_edge(v[1], v[7], 1)
$g.add_edge(v[2], v[3], 1)
$g.add_edge(v[2], v[11], 1)
$g.add_edge(v[3], v[10], 1)
$g.add_edge(v[3]... | Ruby |
# utility.rb (v1.0)
# DO NOT MODIFY THIS FILE
# This file should NOT be included in your submission to the submission server
# A copy of utility.rb will already be on the submission server.
# Your code in assignment2.rb CAN make use of the methods here if desired
# -------------------------------------... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.