code
stringlengths
1
1.73M
language
stringclasses
1 value
module X def X.included other other.module_eval { def method_missing m, *args X.send m, *args end } end class X < String def method_missing m, *args if (args.length == 0) && (val = X._get_val(m)) X.new(self.concat( X.new(val) )) else super end end def se...
Ruby
module X class X < String def x00 X.new(self + self.class.x00) end def self.x00 X.new "\x00" end def x01 X.new(self + self.class.x01) end def self.x01 X.new "\x01" end def x02 X.new(self + self.class.x02) end def self.x02 X.new "\x02" end def x03 X...
Ruby
class Bitstring < String # Bitwise AND def & other _go :&, other end # Bitwise OR def | other _go :|, other end # Bitwise XOR def ^ other _go :^, other end # ===Internal. # This function executes the bitwise functions def _go mes, other check(other) b = Bitstring....
Ruby
require 'test/unit' require 'bitstring' class Test_Bitstring < Test::Unit::TestCase B=Bitstring def test_basics b = Bitstring.new("\x31"*8) assert_equal("11111111", b) b = B.new("\xF0"*8) assert_equal("1111000011110000111100001111000011110000111100001111000011110000", b.bits) b = B.new("\x0F"*8) asse...
Ruby
require 'mkmf' PROJECT_NAME="PCSC_NATIVE" PCSC_HEADER="winscard.h" HEADER_PATHS=[ "/System/Library/Frameworks/PCSC.framework/Versions/A/Headers/" ] LIB_PATHS=[ "/System/Library/Frameworks/PCSC.framework/Versions/A/" ] dir_config(PROJECT_NAME) dir_config(PROJECT_NAME) find_header(PCSC_HEADER, HEADER_PATHS) $LDFLAGS ...
Ruby
require 'atr' require 'apdu'
Ruby
# retrieve list of known atrs from ATR_LIST = "http://ludovic.rousseau.free.fr/softwares/pcsc-tools/smartcard_list.txt" # and turn them into a `hash` of the form: # {"3B02......" => "decription", ... } # which gets written into: OUT_FILE = "atr_generated.rb" # for use by the atr routines in `iso7816.rb` require "op...
Ruby
require 'PCSC_NATIVE' module PCSC class Context def initialize @ctx = Driver.establishContext end def release Driver.releaseContext @ctx end # compare to Lib::Errors def is_valid return true # TODO end def list_readers tmp = Driver.listReaders @ctx ...
Ruby
# THIS IS A GENERATED FILE! YOU SHOULDN'T EDIT IT MANUALLY. PLEASE CHECK prepare.rb module ISO7816 class ATR ATR_HASH = { "3BFF9500FFC00A1F438031E073F62113574A334861324147D6" => "GSM SIM (issued by e-plus, Germany)", "3BFF9500FF400A8031E873F62113674A474860314200" => "Giesecke & Devrient STARSIM", ...
Ruby
module ISO7816 def b2s bytestr bytestr.unpack("H*")[0] end module APDU class APDU include ISO7816 attr_accessor :cla, :ins, :p1, :p2, :data, :le def initialize @cla = @ins = @p1 = @p2 = "\x00" end def lc unless @lc @lc = @data ? [@data.length].pack("C") : nil end ...
Ruby
module ISO7816 class ATR require 'atr_generated' # provide a string of bytes to init this object. def initialize atr @atr_bytes = atr @string_rep = ATR.stringify atr @desc = ATR.get_description atr @ta=Hash.new @tb=Hash.new @tc=Hash.new @td=Hash.new decode...
Ruby
require 'mkmf' PROJECT_NAME="TEST_NATIVE" dir_config(PROJECT_NAME) create_makefile(PROJECT_NAME)
Ruby
require "rake/rdoctask" require "rake/gempackagetask" require "rake/testtask" require "rake/clean" require "rubygems" # Some definitions that you'll need to edit in case you reuse this # Rakefile for your own project. SHORTNAME ='7816' # this should be the rubyforge project name DESC ='ruby smartcard access' PKG_VER...
Ruby
module ISO7816 module APDU def APDU.create_class name, ins cl= %Q( class #{name} < APDU def initialize card= nil super @cla= \"\\x00\" @ins= \"\\x#{ins}\" end end ) eval(cl) end [ ["ACTIVATE_FILE", "44"], ["APPEND_RECORD", "E2"], ["CHANGE_REFERENCE_DATA",...
Ruby
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) require 'card' require 'atr' require 'apdu' require 'iso_apdu' require 'pcsc_helper'
Ruby
require 'hexy' module ISO7816 def ISO7816.b2s bytestr r = bytestr.unpack("H*")[0] r.length > 1 ? r : " " end def ISO7816.make_binary value value = [value].pack("C") if value.is_a? Numeric end def b2s bytestr ISO7816.b2s bytestr en...
Ruby
require 'smartcard' module ISO7816 module Card # Dummy implementation of `Card` to describe the provided interface class Card attr_reader :atr # Set up a connection to this card and return the ATR String. # May be called with a block which will be passed `self`. Card # will call `disconnect` at t...
Ruby
require 'smartcard' module ISO7816 module PCSC # adds default params to Smartcard to make them easier to work with. class Context < Smartcard::PCSC::Context def initialize scope=Smartcard::PCSC::SCOPE_SYSTEM super end def list_readers reader_groups=nil super end end class Card < Smartcar...
Ruby
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) require 'iso7816' require 'emv/emv' require 'emv/emv_apdu' require 'emv/cps_apdu' require 'emv/data/cps_ini_update' require 'emv/crypto/crypto'
Ruby
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) require 'iso7816'
Ruby
require 'hexy' module ISO7816 class ATR # require 'atr_generated' attr_reader :atr_bytes # provide a string of bytes to init this object. def initialize atr @atr_bytes = atr @string_rep = ATR.stringify atr @desc = ATR.get_description atr @ta=Hash.new @tb=Hash.new @t...
Ruby
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) require 'iso7816'
Ruby
module EMV module APDU module CPS class SecureContext # The Kenc key used in this session attr_accessor :k_enc # The Kmac key used in this session attr_accessor :k_mac # The Kdek key used in this session attr_accessor :k_dek # The challenge sent to the card, (Rterm) attr_accessor :host_challenge...
Ruby
module EMV module APDU class EMV_APDU < ISO7816::APDU::APDU def initialize card=nil super @cla="\x80" end end def APDU.create_class name, ins cl= %Q( class #{name} < EMV_APDU def initialize card= nil super @ins= \"\\x#{ins}\" end end ) eval(cl) end [ ["APPLICATION_BLOCK", "1E"], ["APPL...
Ruby
autoload :OpenSSL, 'openssl' module EMV module Crypto # Generate Session keys according to CPS 5.3 def self.generate_session_key ic_card_key, seq, type seq = check_and_convert("seq", seq, 2) ic_card_key = check_and_convert("ic_card_key", ic_card_key, 16) derivation_data = case type ...
Ruby
module EMV # according to EMV 1, 12.2.2 PSE_DDF="1PAY.SYS.DDF01" end
Ruby
require 'tlv' module EMV module Data class InitializeUpdateData < TLV b 6*8, "Identifier of the KMC", :kmc_id b 4*8, "Chip Serial Number", :csn b 8, "Version Number of Master key (KMC)", :kmc_version b 8, "Identifier of Secure Channel Protocol", :sec_channel_proto_id b 2*8, "Sequence Counter"...
Ruby
require "rake/rdoctask" require "rake/gempackagetask" require "rake/testtask" require "rake/clean" require "rubygems" # Some definitions that you'll need to edit in case you reuse this # Rakefile for your own project. SHORTNAME ='pcsc' # this should be the rubyforge project name DESC ='ruby smartcard access' PKG_VER...
Ruby
require 'mkmf' PROJECT_NAME="PCSC_NATIVE" PCSC_HEADER="winscard.h" HEADER_PATHS=[ "/System/Library/Frameworks/PCSC.framework/Versions/A/Headers/" ] LIB_PATHS=[ "/System/Library/Frameworks/PCSC.framework/Versions/A/" ] dir_config(PROJECT_NAME) dir_config(PROJECT_NAME) find_header(PCSC_HEADER, HEADER_PATHS) $LDFLAGS ...
Ruby
require 'atr' require 'apdu'
Ruby
# retrieve list of known atrs from ATR_LIST = "http://ludovic.rousseau.free.fr/softwares/pcsc-tools/smartcard_list.txt" # and turn them into a `hash` of the form: # {"3B02......" => "decription", ... } # which gets written into: OUT_FILE = "atr_generated.rb" # for use by the atr routines in `iso7816.rb` require "op...
Ruby
require 'PCSC_NATIVE' module PCSC class Context def initialize @ctx = Driver.establishContext end def release Driver.releaseContext @ctx end # compare to Lib::Errors def is_valid return true # TODO end def list_readers tmp = Driver.listReaders @ctx ...
Ruby
# THIS IS A GENERATED FILE! YOU SHOULDN'T EDIT IT MANUALLY. PLEASE CHECK prepare.rb module ISO7816 class ATR ATR_HASH = { "3BFF9500FFC00A1F438031E073F62113574A334861324147D6" => "GSM SIM (issued by e-plus, Germany)", "3BFF9500FF400A8031E873F62113674A474860314200" => "Giesecke & Devrient STARSIM", ...
Ruby
module ISO7816 def b2s bytestr bytestr.unpack("H*")[0] end module APDU class APDU include ISO7816 attr_accessor :cla, :ins, :p1, :p2, :data, :le def initialize @cla = @ins = @p1 = @p2 = "\x00" end def lc unless @lc @lc = @data ? [@data.length].pack("C") : nil end ...
Ruby
module ISO7816 class ATR require 'atr_generated' # provide a string of bytes to init this object. def initialize atr @atr_bytes = atr @string_rep = ATR.stringify atr @desc = ATR.get_description atr @ta=Hash.new @tb=Hash.new @tc=Hash.new @td=Hash.new decode...
Ruby
require File.dirname(__FILE__) + '/../ext/pcsc/PCSC_NATIVE' module PCSC class Context def initialize @ctx = Driver.establishContext end def release Driver.releaseContext @ctx end # compare to Lib::Errors def is_valid return true # TODO end def list_readers t...
Ruby
require 'socket' require 'digest/md5' require 'stringio' require 'erlang_util' require 'erlang_node' require 'erlang_epmd' require 'erlang_type' require 'erlang_message' module Erlang module Net include Erlang::Util DFLAG_PUBLISHED =1 DFLAG_ATOM_CACHE =2 DFLAG_EXTENDED_REFERENCES =4 DFL...
Ruby
require 'stringio' require 'erlang_type' module Erlang def Erlang.to_erl str, *vals t = TermHelper.new str, vals t.parse end class TermHelper def initialize str, vals=[] io = StringIO.new(str) class << io; def read_compare s v = read(s.size) raise "Parse Error at : #{pos} expect...
Ruby
require 'thread' module Erlang class SynchronizedQueue def initialize @queue = [] @lock = Mutex.new @t = Thread.new{Thread.stop} end def push val @lock.synchronize { @queue.push val t = @t @t = Thread.new{Thread.stop} t.kill } end alias << push alias enqueue pus...
Ruby
require 'socket' class Acceptor def initialize server = TCPServer.open("", 0) puts server.addr @t = Thread.new { puts "here" puts server.accept while (s = server.accept) puts "here" puts s puts s.gets end } @t.methods end end a = Acceptor.new while true sleep 1 end
Ruby
require 'thread' require 'timeout' module Erlang class TimeoutQueue < Queue def initialize super end def pop timeout=nil val = nil begin Timeout::timeout(timeout) { val = super(false) } rescue Timeout::Error end val end end end #module Erlang
Ruby
require 'socket' port = (ARGV[0] || 80).to_i server = TCPServer.new('localhost', 0) while (session = server.accept) puts "Request: #{session.gets}" session.print "HTTP/1.1 200/OK\r\nContent-type: text/html\r\n\r\n" session.print "<html><body><h1>#{Time.now}</h1></body></html>\r\n" session.close end
Ruby
require 'erlang_type' require 'stringio' module Erlang class Protocol include Erlang::Util LINK = 1 SEND = 2 EXIT = 3 UNLINK = 4 NODE_LINK = 5 REG_SEND = 6 GROUP_LEADER = 7 EXIT2 = 8 SEND_TT = 12 EXIT_TT = 13 REG_SEND_TT = 16 MONITOR_P = 19 DEMONITOR_P = 20 MONITOR_P_EXIT = 21 PASS_THR...
Ruby
require 'socket' require 'singleton' require 'erlang_util' require 'erlang_node' require 'erlang_connection' module Erlang # common values EPMDPORT = 4369 DEBUG = true # Definitions of message codes */ EPMD_ALIVE_REQ = 'a' EPMD_ALIVE_OK_RESP = 'Y' EPMD_PORT_REQ = 'p' EPMD_NAMES_REQ ...
Ruby
require 'erlang_util' require 'erlang_epmd' require 'erlang_process' require 'socket' require 'thread' module Erlang class Node include Erlang::Util attr_accessor :extra attr_writer :host, :dist_range, :cookie, :port_no, :type, :protocol attr_reader :node_name, :creation # def decode erl_io # self...
Ruby
require 'erlang_util' require 'erlang_type' require 'erlang_connection' require 'stringio' require 'cmdline' #<<112,131,104,3,97,2,100,0,0,103,100,0,13,116,105,109,64,49,50,55,46,48,46,48,46,49,0,0,0,36,0,0,0,0,2,131,104,2,114,3,100,0,13,116,105,109,64,49,50,55,46,48,46,48,46,49,2,0,0,2,106,0,0,0,0,0,0,0,0,100,0,2,1...
Ruby
require 'synchronized_queue' require 'erlang_term' module Erlang class Process attr_accessor :name, :pid, :alive, :local_node, :trap_exit def initialize local_node, name=nil @local_node=local_node @pid=@local_node.generate_pid @name=name.to_sym if name @local_node.register_process(self) @queu...
Ruby
require 'erlang_node' require 'erlang_message' require 'erlang_type' module Erlang class Ping def initialize local_node, remote_node @local_node = local_node @remote_node = remote_node end def ping process = Process.new @local_node #ref = Ref.new(@local_node.full_name, [1,2,3],1) #tuple...
Ruby
module Erlang module Util def e_byte byte [byte].pack("C") end # converts a numeric to 2 bytes (short) big endian def e_two_bytes_big num [num].pack("n") end def d_two_bytes_big str str.unpack("n")[0] end def e_four_bytes_big num [num].pack("N") end def d_four_bytes_big str str.unpack("N"...
Ruby
require 'stringio' require 'erlang_connection' module Erlang # The tag used for small integers SMALLINT = 97 # The tag used for integers INTEGER = 98 # The tag used for floating point numbers FLOAT = 99 # The tag used for atoms ATOM = 100 # The tag used for old stype...
Ruby
# # setup.rb # # Copyright (c) 2000-2005 Minero Aoki # # This program is free software. # You can distribute/modify this program under the terms of # the GNU LGPL, Lesser General Public License version 2.1. # unless Enumerable.method_defined?(:map) # Ruby 1.4.6 module Enumerable alias map collect end end un...
Ruby
require "rake/rdoctask" require "rake/gempackagetask" require "rake/testtask" require "rake/clean" require "rubygems" require "lib/simple_http" # Specifies the default task to execute. This is often the "test" task # and we'll change things around as soon as we have some tests. task :default => [:rdoc] # The direc...
Ruby
require 'net/http' require 'net/https' require 'uri' require 'cgi' require 'base64' # Wrapper around ruby's standard net/http classes. Currently, only GET # and POST https methods are supported. `SimpleHttp` provides class # methods `get` and `post` to handle basic functionality. In case more # complicated requests n...
Ruby
require 'webrick' include WEBrick class TestServer SUCCESS_TEXT_0 = "success_0" SUCCESS_TEXT_1 = "success_1" SUCCESS_TEXT_2 = "success_2" SUCCESS_TEXT_3 = "success_3" SUCCESS_TEXT_4 = "success_4" SUCCESS_TEXT_5 = "success_5" SUCCESS_TEXT_6 = "success_6" SUCCESS_TEXT_7 = "success_7" SUCCESS_TEXT_8 = "success_8...
Ruby
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) require 'net/http' require 'net/https' require 'uri' require 'cgi' require 'base64' # Wrapper around ruby's standard net/http classes. Currently, only GET # and POST https methods...
Ruby
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) # kept for backwards compatibility # require 'simplehttp.rb'
Ruby
require 'webrick' #require 'constants' include WEBrick class TestServer SUCCESS_TEXT_0 = "success_0" SUCCESS_TEXT_1 = "success_1" SUCCESS_TEXT_2 = "success_2" SUCCESS_TEXT_3 = "success_3" SUCCESS_TEXT_4 = "success_4" SUCCESS_TEXT_5 = "success_5" SUCCESS_TEXT_6 = "success_6" SUCCESS_TEXT_7 = "success_7"...
Ruby
# A sample Gemfile source "https://rubygems.org" gem "rake" gem "sass"
Ruby
#!/usr/bin/ruby # jsmin.rb 2007-07-20 # Author: Uladzislau Latynski # This work is a translation from C to Ruby of jsmin.c published by # Douglas Crockford. Permission is hereby granted to use the Ruby # version under the same conditions as the jsmin.c on which it is # based. # # /* jsmin.c # 2003-04-21 # # Copyrig...
Ruby
class Theme def initialize(dst_dir, root = nil) @destination = dst_dir @includes = [] @root = root @extends = {} @depends = [] end attr :includes def load_theme(theme_dir, top = true) theme_dir = File.join(@root, theme_dir) theme_name = File.basename(theme_dir) master = Dir.glob(Fil...
Ruby
#!/usr/bin/ruby # jsmin.rb 2007-07-20 # Author: Uladzislau Latynski # This work is a translation from C to Ruby of jsmin.c published by # Douglas Crockford. Permission is hereby granted to use the Ruby # version under the same conditions as the jsmin.c on which it is # based. # # /* jsmin.c # 2003-04-21 # # Copyrig...
Ruby
source :gemcutter gem 'sinatra', :require => 'sinatra/base' gem 'thin', '~> 1.3' gem 'pg' gem 'data_mapper', '~> 1.2' gem 'dm-postgres-adapter' gem 'google-api-client', '>= 0.4.3' group :development do gem 'dm-sqlite-adapter', '~> 1.2' gem 'do_sqlite3', '~> 0.10' 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
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
## ## This file is only needed for Compass/Sass integration. If you are not using ## Compass, you may safely ignore or delete this file. ## ## If you'd like to learn more about Sass and Compass, see the sass/README.txt ## file for more information. ## # Default to development if environment is not set. saved = environ...
Ruby
source 'https://rubygems.org' group :development do # Sass, Compass and extensions. gem 'sass' # Sass. gem 'sass-globbing' # Import Sass files based on globbing pattern. gem 'compass' # Framework built on Sass. gem 'compass-validator' # So you can `compass ...
Ruby
notification :off group :development do # Only run Compass if we have a config.rb file in place. if File.exists?("config.rb") # Compile on start. puts `compass compile --time --quiet` # https://github.com/guard/guard-compass guard :compass do watch(%r{.+\.s[ac]ss$}) end end ## Unco...
Ruby
## ## This file is only needed for Compass/Sass integration. If you are not using ## Compass, you may safely ignore or delete this file. ## ## If you'd like to learn more about Sass and Compass, see the sass/README.txt ## file for more information. ## # Default to development if environment is not set. saved = environ...
Ruby
source 'https://rubygems.org' group :development do # Sass, Compass and extensions. gem 'sass' # Sass. gem 'sass-globbing' # Import Sass files based on globbing pattern. gem 'compass' # Framework built on Sass. gem 'compass-validator' # So you can `compass ...
Ruby
notification :off group :development do # Only run Compass if we have a config.rb file in place. if File.exists?("config.rb") # Compile on start. puts `compass compile --time --quiet` # https://github.com/guard/guard-compass guard :compass do watch(%r{.+\.s[ac]ss$}) end end ## Unco...
Ruby
## ## This file is only needed for Compass/Sass integration. If you are not using ## Compass, you may safely ignore or delete this file. ## ## If you'd like to learn more about Sass and Compass, see the sass/README.txt ## file for more information. ## # Default to development if environment is not set. saved = environ...
Ruby
source 'https://rubygems.org' group :development do # Sass, Compass and extensions. gem 'sass' # Sass. gem 'sass-globbing' # Import Sass files based on globbing pattern. gem 'compass' # Framework built on Sass. gem 'compass-validator' # So you can `compass ...
Ruby
notification :off group :development do # Only run Compass if we have a config.rb file in place. if File.exists?("config.rb") # Compile on start. puts `compass compile --time --quiet` # https://github.com/guard/guard-compass guard :compass do watch(%r{.+\.s[ac]ss$}) end end ## Unco...
Ruby
## ## This file is only needed for Compass/Sass integration. If you are not using ## Compass, you may safely ignore or delete this file. ## ## If you'd like to learn more about Sass and Compass, see the sass/README.txt ## file for more information. ## # Default to development if environment is not set. saved = environ...
Ruby
source 'https://rubygems.org' group :development do # Sass, Compass and extensions. gem 'sass' # Sass. gem 'sass-globbing' # Import Sass files based on globbing pattern. gem 'compass' # Framework built on Sass. gem 'compass-validator' # So you can `compass ...
Ruby
notification :off group :development do # Only run Compass if we have a config.rb file in place. if File.exists?("config.rb") # Compile on start. puts `compass compile --time --quiet` # https://github.com/guard/guard-compass guard :compass do watch(%r{.+\.s[ac]ss$}) end end ## Unco...
Ruby
require "./mdx" require "./mdl" require "./txt" file = "" target = "" parser = nil begin if ARGV.size < 1 raise "Not enough command-line arguments" end file = ARGV[0] if ARGV.size > 1 target = ARGV[1] else target = File.basename(file, File.extname(file)) + ".txt" end case File....
Ruby
require "./base" require "./stringstream" class MDL < Base def initialize (file) super() puts "Loading #{file}" @stream = StringStream.new(file) @token = "" @list = [] parse() end def saveMDX (target) puts "Saving #{target}" end def saveMDL (target) puts "Saving #...
Ruby
class Chunk attr_reader :token, :size def initialize (stream) @token = stream.read(4) @size = stream.readUI32() end end class VersionChunk attr_reader :version def initialize (stream) @version = stream.readUI32() end end class ModelChunk attr_reader :name, :animationFileName, :bound...
Ruby
require "./base" require "./binarystream" class MDX < Base def initialize (file) super() puts "Loading #{file}" @stream = BinaryStream.new(file) @chunk = nil @list = ["VERS", "MODL", "SEQS", "GLBS", "TEXS", "MTLS", "GEOS"] parse() end def saveMDX (target) puts "Saving #{tar...
Ruby
class Base attr_reader :vers, :modl, :seqs, :glbs, :texs, :txan def initialize () @vers = nil @modl = nil @seqs = nil @glbs = nil @mtls = nil @texs = nil @txan = nil @geos = nil end end
Ruby
class StringStream def initialize (file) @file = file @data = IO.readlines(file) @line = 0 end end
Ruby
require "./classes" class BinaryStream def initialize (file) @file = file File.open(file, "rb") { |desc| @data = desc.read } @byte = 0 end # Move the internal index by size bytes # If the index is negative or greater then the size of the stream's data, it will clamp to 0 or the las...
Ruby
require "./base" require "./stringstream" class TXT < Base def initialize (file) super() puts "Loading #{file}" @stream = StringStream.new(file) parse() end def saveMDX (target) puts "Saving #{target}" end def saveMDL (target) puts "Saving #{target}" end def save...
Ruby
# Settings specified here will take precedence over those in config/environment.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Use a different logger for distributed setups # config.logger = SyslogLogger.new # Full error repor...
Ruby
# Settings specified here will take precedence over those in config/environment.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 webserver when you make code changes. config.ca...
Ruby
# Settings specified here will take precedence over those in config/environment.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 suite and is wiped # and recreated between...
Ruby
# Be sure to restart your web server when you modify this file. # Uncomment below to force Rails into production mode when # you don't control web/app server and can't set it the proper way # ENV['RAILS_ENV'] ||= 'production' # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION =...
Ruby
# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) unless defined?(Rails::Initializer) if File.directory?("#{RAILS_ROOT}/vendor/rails") require "#{RAILS_ROOT}/vendor/rails/railties/lib/init...
Ruby
ActionController::Routing::Routes.draw do |map| # The priority is based upon order of creation: first created -> highest priority. # Sample of regular route: # map.connect 'products/:id', :controller => 'catalog', :action => 'view' # Keep in mind you can assign values other than :controller and :action # ...
Ruby
require 'game_engine' game_engine = GameEngine.new player = Player.new 1 game_engine.add_player player @strategy = "puts 'first'" game_engine.update_player_strategy 1, @strategy game_thread = Thread.new { while true do game_engine.use_player_startegies; sleep 5 end} @strategy = "puts 'second'" game_engine.update_...
Ruby
BUFFER = 100 def build_economy_with_army if my_farmers.between? 160,200 farm_max create_army else build_economy end end def create_army build_barrack (my_resources - BUFFER / 30).times {create_warrior} end def can_attack? my_warriors > 20 end def build_economy (my_resources/5).times...
Ruby
require 'game' require 'game_engine' require 'player' require 'player_exists_error' @game_engine = GameEngine.new player1 = Player.new 'Akshay' player2 = Player.new 'Chirag' @game_engine.add_player player1 @game_engine.add_player player2 puts player1.status puts player2.status @thread = Thread.new{ loop do ...
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module PlayerHelper end
Ruby
require "gruff" require File.dirname(__FILE__)+"/../../lib/gchartrb/google_chart" module StatusHelper def create_bar_chart lc = GoogleChart::BarChart.new('320x200', "Score Bars", false) lc.data_encoding = :score lc.show_legend = true lc.show_labels = false i=0 @...
Ruby