code
stringlengths
1
1.73M
language
stringclasses
1 value
module ExtJS4 module SassExtensions module Functions module Utils def parsebox(list, n) assert_type n, :Number if !n.int? raise ArgumentError.new("List index #{n} must be an integer") elsif n.to_i < 1 raise ArgumentError.new("List index #{n} must...
Ruby
module ExtJS4 module SassExtensions module Functions module ThemeImages def theme_image(theme, path, without_url = false) path = path.value images_path = File.join($image_path, "themes", "images", theme.value) real_path = File.join(images_path, path) ...
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 'menu' #require 'mainmenu' class WindowManager def initialize(window) @window = window @menu = Menu.new(window) #instantiate the menu, passing the Window in the constructor #@mainmenu = MainMenu.new(window) @showloading = false @TOP_COLOR = Gosu::Color.new(0xFF1EB1FA...
Ruby
class Tile attr_accessor :posX attr_accessor :posY attr_accessor :tile_id attr_accessor :tile_attribute def initialize(window, x, y, tileid, attribute) @posX = x; @posY = y; @tile_id = tileid; @tile_attribute = attribute; end def update end def draw $t...
Ruby
module MenuStates MAIN_MENU = 1 PLAYER_MENU = 2 INGAME = 3 end module IngameMenu Show = false MenuId = 1 end
Ruby
module ZOrder Shadow, Shape, Highlight = *4..7 end class Particle def initialize(sprite, x, y, ang, speed, decay, red, green, blue, random) @x = x @y = y @angle = 90-ang @speed = speed @d_x = Gosu::offset_x(@angle, @speed) @d_y = Gosu::offset_y(@angle, @speed) @life = 1 ...
Ruby
class Npc attr_accessor :name attr_accessor :posX attr_accessor :posY attr_accessor :moving attr_accessor :chasing attr_accessor :loosing attr_accessor :sight attr_accessor :direction def initialize(window, name, sight, imageset) @window = window @image_array = ima...
Ruby
require 'particles' require 'tile' require 'npc' class GameManager def initialize(window) @window = window @particles = Particles.new(@window, 0, 255, 100, true, 0) @emitter = Emitter.new(@particles, 800 / 2, 600 / 2, 2) @tiles = Array.new @npcs = Array.new @npcdata = Array.new i...
Ruby
class MenuItem HOVER_OFFSET = 0 def initialize (window, image, x, y, z, callback, hover_image = nil) @window = window @main_image = image @hover_image = hover_image @original_x = @x = x @original_y = @y = y @z = z @callback = call...
Ruby
require 'rubygems' rescue nil require 'gosu' require 'constants' require 'windowmanager' require 'gamemanager' GC.start class GameWindow < Gosu::Window def initialize super(800, 600, false) self.caption = "Catorious" $font = Gosu::Font.new(self, Gosu::default_font_name, 20) $b...
Ruby
require 'menuitem' class Menu def initialize (window) @window = window @items = Array.new end def add_item (image, x, y, z, callback, hover_image = nil) item = MenuItem.new(@window, image, x, y, z, callback, hover_image) @items << item s...
Ruby
# Copyright 2008-2009 Nokia Siemens Networks Oyj # # 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...
Ruby
#!/usr/bin/env ruby class ExampleRemoteLibrary def count_items_in_directory(path) Dir.entries(path).find_all{|i| not i.match('^\.')}.length end def strings_should_be_equal(str1, str2) puts "Comparing '#{str1}' to '#{str2}'" if str1 != str2 raise RuntimeError, "Given strings are not equal" ...
Ruby
class RubyLibraryExample def get_server_language 'ruby' end # Basic communication def passing end def failing(message) raise message end def logging(message, level='INFO') puts "*#{level}* #{message}" end def returning 'returned string' end # Logging def one_message_w...
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
# Author: Michael Burns (mburns@cs.princeton.edu) # Copyright (c) 2009 Michael Burns # # This program is distributed under the terms of the # GNU General Public License. See the COPYING file # for details. require 'collada/exporter.rb'
Ruby
# Author: Michael Burns (mburns@cs.princeton.edu) # Copyright (c) 2009 Michael Burns # # This program is distributed under the terms of the # GNU General Public License. See the COPYING file # for details. module Collada class Material attr_reader :id def initialize(id, color) ...
Ruby
# Author: Michael Burns (mburns@cs.princeton.edu) # Copyright (c) 2009 Michael Burns # # This program is distributed under the terms of the # GNU General Public License. See the COPYING file # for details. module Collada class IdManager def initialize(initial_entries = []) @id_hash = {} ...
Ruby
# Author: Michael Burns (mburns@cs.princeton.edu) # Copyright (c) 2009 Michael Burns # # This program is distributed under the terms of the # GNU General Public License. See the COPYING file # for details. require 'rubystdlib.rb' require 'rexml/Document' module Collada class Mesh attr_accessor :id ...
Ruby
# Author: Michael Burns (mburns@cs.princeton.edu) # Copyright (c) 2009 Michael Burns # # This program is distributed under the terms of the # GNU General Public License. See the COPYING file # for details. module Collada def Collada.ccw(a, b, c) a[0] * (b[1] - c[1]) - b[0] * (a[1] - c[1]) + c[0] *...
Ruby
# Author: Michael Burns (mburns@cs.princeton.edu) # Copyright (c) 2009 Michael Burns # # This program is distributed under the terms of the # GNU General Public License. See the COPYING file # for details. module Collada class Contours attr_accessor :vertex_indices, :normal_indices, :count ...
Ruby
# Author: Michael Burns (mburns@cs.princeton.edu) # Copyright (c) 2009 Michael Burns # # This program is distributed under the terms of the # GNU General Public License. See the COPYING file # for details. module Collada class AnimationPath def AnimationPath.set_path(object) object.se...
Ruby
# Author: Michael Burns (mburns@cs.princeton.edu) # Copyright (c) 2009 Michael Burns # # This program is distributed under the terms of the # GNU General Public License. See the COPYING file # for details. module Collada def Collada.p_to_s(p) p = p.collect { |n| if n.abs < 1e-10 then 0.0 else n end } ...
Ruby
# Author: Michael Burns (mburns@cs.princeton.edu) # Copyright (c) 2009 Michael Burns # # This program is distributed under the terms of the # GNU General Public License. See the COPYING file # for details. module Collada class Lines attr_accessor :vertex_indices, :count def init...
Ruby
# Author: Michael Burns (mburns@cs.princeton.edu) # Copyright (c) 2009 Michael Burns # # This program is distributed under the terms of the # GNU General Public License. See the COPYING file # for details. module Collada class LineStrips attr_accessor :vertex_indices def initial...
Ruby
# Author: Michael Burns (mburns@cs.princeton.edu) # Copyright (c) 2009 Michael Burns # # This program is distributed under the terms of the # GNU General Public License. See the COPYING file # for details.i module Collada class Triangles attr_accessor :vertex_indices, :normal_indices, :count ...
Ruby
# Author: Michael Burns (mburns@cs.princeton.edu) # Copyright (c) 2009 Michael Burns # # This program is distributed under the terms of the # GNU General Public License. See the COPYING file # for details. module Collada class Component attr_accessor :node def initialize(node) ...
Ruby
# Author: Michael Burns (mburns@cs.princeton.edu) # Copyright (c) 2009 Michael Burns # # This program is distributed under the terms of the # GNU General Public License. See the COPYING file # for details. require 'rexml/formatters/default' module REXML module Formatters # Pretty-prints an XML document. T...
Ruby
# Author: Michael Burns (mburns@cs.princeton.edu) # Copyright (c) 2009 Michael Burns # # This program is distributed under the terms of the # GNU General Public License. See the COPYING file # for details. require 'sketchup.rb' require 'rubystdlib.rb' require 'rexml/Document' load 'collada/id_manager.rb' load 'co...
Ruby
# Author: Michael Burns (mburns@cs.princeton.edu) # Copyright (c) 2009 Michael Burns # # This program is distributed under the terms of the # GNU General Public License. See the COPYING file # for details. module Collada class Node attr_accessor :name, :id, :geometries, :components, :nodes, :anima...
Ruby
# Author: Michael Burns (mburns@cs.princeton.edu) # Copyright (c) 2009 Michael Burns # # This program is distributed under the terms of the # GNU General Public License. See the COPYING file # for details. if not file_loaded?("rubystdlib.rb") processor, platform, *rest = RUBY_PLATFORM.split("-") cas...
Ruby
# Author: Michael Burns (mburns@cs.princeton.edu) # Copyright (c) 2009 Michael Burns # # This program is distributed under the terms of the # GNU General Public License. See the COPYING file # for details. require 'sketchup.rb' module SelectionFilter def SelectionFilter.filter(type) new_selection = Sketch...
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
# $ext_path: This should be the path of where the ExtJS SDK is installed # Generally this will be in a lib/extjs folder in your applications root # <root>/lib/extjs $ext_path = "../../" # sass_path: the directory your Sass files are in. THIS file should also be in the Sass folder # Generally this will be in a resource...
Ruby
# include the utils rb file which has extra functionality for the ext theme dir = File.dirname(__FILE__) require File.join(dir, 'lib', 'utils.rb') # register ext4 as a compass framework Compass::Frameworks.register 'ext4', dir
Ruby
# $ext_path: This should be the path of the Ext JS SDK relative to this file $ext_path = "../../extjs" # sass_path: the directory your Sass files are in. THIS file should also be in the Sass folder # Generally this will be in a resources/sass folder # <root>/resources/sass sass_path = File.dirname(__FILE__) # css_pat...
Ruby
# Compass configurations sass_path = File.dirname(__FILE__) css_path = File.join(sass_path, "..", "css") # Require any additional compass plugins here. images_dir = File.join(sass_path, "..", "img") output_style = :expanded environment = :production
Ruby
module ExtJS4 module SassExtensions module Functions module Utils def parsebox(list, n) assert_type n, :Number if !n.int? raise ArgumentError.new("List index #{n} must be an integer") elsif n.to_i < 1 raise ArgumentError.new("List index #{n} must...
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' }]) # Major.create(:name...
Ruby
class CreateTopics < ActiveRecord::Migration def self.up create_table :topics do |t| t.column "skill_id", :int, :null => false t.column "name", :string, :null => false t.column "name_en", :string, :null => false t.column "code", :int, :null => false t.column "xflag", :char, :null => ...
Ruby
class CreateSkills < ActiveRecord::Migration def self.up create_table :skills do |t| t.column "name", :string, :null => false t.column "name_en", :string, :null => false t.column "code", :int, :null => false t.column "xflag", :char, :null => false, :default => 'E' t.timestamps en...
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.column "uid", :string, :null => false, :limit => 30 t.column "upw", :string, :null => false, :limit => 30 t.column "alias", :string, :null => false, :limit => 30 t.column "exam_in_progress", :int t.c...
Ruby
class CreatePassages < ActiveRecord::Migration def self.up create_table :passages do |t| t.column "code", :int, :null => false t.column "content", :text, :null => false t.column "xflag", :char, :null => false, :default => 'E' t.timestamps end end def self.down drop_table :pass...
Ruby
class CreateExamParts < ActiveRecord::Migration def self.up create_table :exam_parts do |t| t.column "exam_id", :int, :null => false t.column "item_id", :int, :null => false t.column "question_no", :int, :null => false t.column "answer", :char t.timestamps end end def self.d...
Ruby
class CreateDifficulties < ActiveRecord::Migration def self.up create_table :difficulties do |t| t.column "name", :string, :null => false t.column "name_en", :string, :null => false t.column "code", :int, :null => false t.column "xflag", :char, :null => false, :default => 'E' t.times...
Ruby
class CreateSubtopics < ActiveRecord::Migration def self.up create_table :subtopics do |t| t.column "topic_id", :int, :null => false t.column "name", :string, :null => false t.column "name_en", :string, :null => false t.column "code", :int, :null => false t.column "xflag", :char, :nu...
Ruby
class CreateCategories < ActiveRecord::Migration def self.up create_table :categories do |t| t.column "skill_id", :int, :null => false t.column "name", :string, :null => false t.column "name_en", :string, :null => false t.column "code", :int, :null => false t.column "xflag", :char, :...
Ruby
class CreatePartcodes < ActiveRecord::Migration def self.up create_table :partcodes do |t| t.column "skill_id", :int, :null => false t.column "category_id", :int, :null => false t.column "subskill_id", :int, :null => false t.column "topic_id", :int, :null => false t.column "subtopic_...
Ruby
class CreateExams < ActiveRecord::Migration def self.up create_table :exams do |t| t.column "user_id", :int, :null => false t.column "theta", :float, :null => false, :default => 0.0 t.column "skill_id", :int, :null => false t.column "exam_code", :string, :null => false t.column "irt_...
Ruby
class CreateSubskills < ActiveRecord::Migration def self.up create_table :subskills do |t| t.column "skill_id", :int, :null => false t.column "name", :string, :null => false t.column "name_en", :string, :null => false t.column "code", :int, :null => false t.column "xflag", :char, :nu...
Ruby
class CreateItems < ActiveRecord::Migration def self.up create_table :items do |t| t.column "code", :int, :null => false t.column "passage_id", :int t.column "question", :text, :null => false t.column "a", :string t.column "b", :string t.column "c", :string t.column "d", ...
Ruby
require File.expand_path(File.dirname(__FILE__) + "/../../test/unit_test_helper") require RAILS_ROOT + "/test/unit/irt/irt_algorithm_test" require RAILS_ROOT + "/test/unit/irt/irt_exam_test" require RAILS_ROOT + "/test/unit/irt/irt_examinee_test" require RAILS_ROOT + "/test/unit/irt/irt_item_test" require RAILS_ROOT +...
Ruby
require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require File.expand_path(File.dirname(__FILE__) + "/../config/boot") require File.expand_path(File.dirname(__FILE__) + "/../lib/irt_ruby") # Dir["#{File.expand_path(File.dirname(__FILE__) + '/../app/models')}/*.rb"].each {|file| require file }...
Ruby
# ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' class ActiveSupport::TestCase # Transactional fixtures accelerate your tests by wrapping each test method # in a transaction that's rolled back on completion. This ensures that the # test ...
Ruby
# Get the directory that this configuration file exists in dir = File.dirname(__FILE__) # Load the sencha-touch framework automatically. load File.join(dir, '..', '..', '..', '..', 'resources', 'themes') # Compass configurations sass_path = dir css_path = File.join(dir, "..", "css") # Require any additional compass ...
Ruby
# Get the directory that this configuration file exists in dir = File.dirname(__FILE__) # Load the sencha-touch framework automatically. load File.join(dir, '..', '..', '..', '..', 'resources', 'themes') # Compass configurations sass_path = dir css_path = File.join(dir, "..", "css") # Require any additional compass ...
Ruby
# Get the directory that this configuration file exists in dir = File.dirname(__FILE__) # Load the sencha-touch framework automatically. load File.join(dir, '..', '..', '..', '..', 'resources', 'themes') # Compass configurations sass_path = dir css_path = File.join(dir, "..", "css") # Require any additional compass ...
Ruby
# Get the directory that this configuration file exists in dir = File.dirname(__FILE__) # Load the sencha-touch framework automatically. load File.join(dir, '..', 'themes') # Compass configurations sass_path = dir css_path = File.join(dir, "..", "css") environment = :development output_style = :expanded
Ruby
# Get the directory that this configuration file exists in dir = File.dirname(__FILE__) # Load the sencha-touch framework automatically. load File.join(dir, '..', 'themes') # Compass configurations sass_path = dir css_path = File.join(dir, "..", "css") environment = :production output_style = :compressed
Ruby
# This file registers the sencha-touch framework with compass # It's a magic name that compass knows how to find. dir = File.dirname(__FILE__) require File.join(dir, 'lib', 'theme_images.rb') Compass::Frameworks.register 'sencha-touch', dir
Ruby
stylesheet 'sencha-touch.scss'
Ruby
module SenchaTouch module SassExtensions module Functions module ThemeImages def theme_image(theme, path, mime_type = nil) path = path.value images_path = File.join(File.dirname(__FILE__), "..", "images", theme.value) real_path = File.join(images_path, path) u...
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/dbconsole'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/dbconsole'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../../config/boot', __FILE__) require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/generate'
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module CatHelper end
Ruby
class Difficulty < ActiveRecord::Base has_many :items end
Ruby
class ExamPart < ActiveRecord::Base belongs_to :exam belongs_to :item end
Ruby
class Partcode < ActiveRecord::Base has_many :items belongs_to :skill belongs_to :categorys belongs_to :subskill belongs_to :topic belongs_to :subtopic end
Ruby
class Exam < ActiveRecord::Base belongs_to :user has_many :exam_parts, :order=>'question_no ASC' belongs_to :skill end
Ruby
class Skill < ActiveRecord::Base has_many :items has_many :exams has_many :categories has_many :subskills has_many :topics has_many :subtopics has_many :partcodes end
Ruby
class Subskill < ActiveRecord::Base has_many :items has_many :partcodes belongs_to :skill end
Ruby
class Item < ActiveRecord::Base has_many :exam_part belongs_to :skill belongs_to :category belongs_to :subskill belongs_to :topic belongs_to :subtopic belongs_to :difficulty belongs_to :partcode belongs_to :passage end
Ruby
class Subtopic < ActiveRecord::Base has_many :items has_many :partcodes belongs_to :topic end
Ruby
class User < ActiveRecord::Base has_many :exams, :order => 'taken_at DESC, updated_at DESC' belongs_to :exam, :foreign_key => :exam_in_progress_id end
Ruby
class Category < ActiveRecord::Base has_many :items has_many :partcodes belongs_to :skill end
Ruby