This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CsvGenerator | |
CONFIG_PATH = File.join(File.dirname(__FILE__), "../../config/energy") | |
DEFAULT_YML_URL = File.join(CONFIG_PATH, "items/defaults.yml") | |
OUTPUT_FOLDER = File.join(File.dirname(__FILE__), "output/") | |
@loaded_yml = {} | |
@object_fields = [] | |
@object_states_fields = [] | |
@source = "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class YamlGenerator | |
def items_params | |
#override this function | |
return { | |
"template_name" => "", | |
"source_url" => "", | |
"output_file" => "", | |
"server_classes_folder" => "", | |
"write_mode" => "w" #w - erase and fill file, a - append to file | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Neighborhood < ActiveRecord::Base | |
has_many :requests, :dependent => :destroy, :foreign_key => 'neighborhood_id', :class_name => "NeighborhoodRequests" | |
before_save :prepare_data | |
MAX_USERS = 30 | |
TYPE_OPEN = 0 | |
TYPE_REQUEST = 1 | |
TYPE_PRIVATE = 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Rooms | |
HOME = 0 | |
RANCH = 1 | |
end | |
class RoomController < UserController | |
CONTROLLER_MANIFEST = { | |
:common_methods => { # common methods, that controller responds to | |
:to_xml => :to_xml, | |
:to_friend_xml => :to_friend_xml, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PromoController < ProxyController | |
CONTROLLER_MANIFEST = { | |
:common_methods => { # common methods, that controller responds to | |
:to_xml => :to_xml, | |
:to_friend_xml => :to_friend_xml, | |
:to_imaginary_friend_xml => :to_imaginary_friend_xml, | |
:daily_reset => :daily_reset, | |
:on_first_request => :on_first_request, | |
:on_get_user_stat => :on_get_user_stat, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StartPackController < CommonPromoController | |
CONTROLLER_MANIFEST = { | |
:common_methods => { # common methods, that controller responds to | |
:on_first_request => :on_first_request, | |
:give_product => :give_start_pack_rewards, | |
:check_product => :check_product, | |
:to_client_data => :to_client_data | |
}, | |
:commands => {}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CachedPrimitiveUserItems < ActiveRecord::Base | |
set_table_name 'primitive_user_items' | |
# for admin sapport | |
attr_accessor :user | |
class << self | |
def find_primitive_user_items(user) | |
cpi = get_record(user) | |
return nil if cpi.nil? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def anagram(input) | |
lookaheadPart = '' | |
matchingPart = '^' | |
positiveLookaheadPrefix='(?=' | |
positiveLookaheadSuffix=')' | |
letters = input.to_s.split('') | |
inputCharacterFrequencyMap = letters.reduce(Hash.new(0)) { |a, b| a[b] += 1; a } | |
inputCharacterFrequencyMap.each do |letter, freq| | |
lookaheadPart += positiveLookaheadPrefix; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def trancate | |
conn = ActiveRecord::Base.connection | |
tables = conn.execute("SELECT * FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema' AND tablename != 'schema_migrations'").map { |r| | |
r['tablename'] | |
} | |
p 'Trancate '+tables.join(',').to_s | |
tables.each { |t| | |
conn.execute("TRUNCATE #{t}") | |
} | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stub_request(:get, /some_host:9999/).with(headers: {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).to_return(status: 200, body: "stubbed response", headers: {}) |