Skip to content

Instantly share code, notes, and snippets.

View psylone's full-sized avatar
💭
Be kind; everyone you meet is fighting a hard battle

Evgeniy Fateev psylone

💭
Be kind; everyone you meet is fighting a hard battle
View GitHub Profile
@psylone
psylone / rspec_unit_template.rb
Last active December 25, 2015 15:19
RSpec Unit test template.
# RSpec Unit Template
describe Model do
# Factories
describe "has facttories" do
it "model factory" do
end
it "another model factory" do
module App
class Root
def call env
[ 200, { 'Content-Type' => 'text/html' }, ["root page"] ]
end
end
class Info
require 'google/api_client' # version 0.7.1
# Set purchase data hash
data = {
token: 'gldfdkfjpnnhmnclekpndgph.AO-J1OwXKIzAKUzprnFnNTClSoe7AYx4kF6_d5IujRI7jiTUIHMwQq0oV_fXyjMXf3sUzpCaS0lUWXvqpraR5Pp5Fmk4MvN7CbGDU0lgAg_kqvKDgT1A9y6C3mpBjYBLPN64plT78M-V',
productId: 'chebucks18',
packageName: 'com.snegoffon.corruption'
}
# Initialize client
@psylone
psylone / modules.coffee
Last active August 29, 2015 13:58 — forked from anonymous/jsbin.gavivewi.coffee
Thoughts about modules
class MyModule
@EXTENSION = [
'one',
'two'
]
@one: ->
do @hello
# code_1
class Point
end
# puts Point.new
# code_1.1
@psylone
psylone / ip_tracker.rb
Created July 12, 2014 05:53
Control players with the same IP
module IPTracker
class IP
include Comparable
# Количество секунд, после которого игроки
# с одинаковым IP считаются разными
TIMESTAMP_LIMIT = 86400
@psylone
psylone / indicator.rb
Created July 12, 2014 05:58
Indicator class for control player parameters (experience, energy, attack etc.)
class Indicator < ActiveRecord::Base
include CorruptionResponder
include CorruptionIncrement
include CorruptionDecrement
include PartnerShip
include GiveUnit
PARAM_NAMES = %w{attack defence health energy clashes}
@psylone
psylone / gears.rb
Last active August 29, 2015 14:03
Gears - the way to control your logic
require 'active_support/all'
module Gears
class Base
private_class_method :new
def initialize *methods
attrs = methods.extract_options!
self.class_eval{ attr_accessor *attrs.keys }
class Ship
attr_accessor :name
def construct name = 'Andromeda'
@name = name
end
end
def reverse(string)
# gets (input from STDIN) isn't necessary cause you get string argument in this method
# input = gets.strip
# You should split your string by empty string to get an array of it's chars
string_array = string.split('')
# Class name should be started from a capital letter
new_word = Array.new