Skip to content

Instantly share code, notes, and snippets.

View temirov's full-sized avatar

Vadym Tyemirov temirov

  • San Francisco, CA
View GitHub Profile

Keybase proof

I hereby claim:

  • I am temirov on github.
  • I am temirov (https://keybase.io/temirov) on keybase.
  • I have a public key ASAnfeT51Voxrr3GAHXlNohn9tyj1yVqQQ4HV63Dx1kTOQo

To claim this, I am signing this object:

@temirov
temirov / serviceapi_usage.go
Created October 9, 2018 19:57
A partial (non-compilable) example of usage of "serviceapi" package
package main
import(
"flag"
"fmt"
"lib/serviceapi"
"github.com/google/uuid"
"log"
"net/http"
)
@temirov
temirov / serviceapi_test.go
Created October 9, 2018 19:46
ServiceApi test
package serviceapi_test
import (
"lib/serviceapi"
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"
)
@temirov
temirov / serviceapi.go
Last active October 9, 2018 19:47
ServiceApi
package serviceapi
import (
"fmt"
"net/http"
)
const (
// RootPath is the root path of the server
RootPath = "/"
@temirov
temirov / bus.rb
Created May 4, 2016 05:23
Quick PubSub implementation
class Bus
def subscribers
@subscribers ||= []
end
def publish(*args)
subscribers.each do |subscriber|
subscriber.sub(*args)
end
end
@temirov
temirov / isomorphism.rb
Created May 4, 2016 04:52
Test string isomorphism
module CoreExtensions
module Histogramable
refine String do
def to_histogram
each_char.with_index.each_with_object(Hash.new { |hsh, key| hsh[key] = [] }) { |(ch, index), o| o[ch] << index }
end
end
end
end
@temirov
temirov / life.rb
Created May 3, 2016 17:54
An object evolutional mutator
class Life
attr_reader :object, :methods, :arguments, :result
def initialize(object:, methods:, arguments:, result:)
@object, @methods, @arguments, @result = object, methods, arguments, result
end
def evolve
(1..max_length).each do |size|
method_chains(size).each do |method_chain|
@temirov
temirov / before_callbackable.rb
Created November 23, 2015 17:45
Simple callback implementation in plain Ruby
module BeforeCallbackable
module ClassMethods
def before(**arg)
@before_callbacks = {} unless defined?(@before_callbacks)
@before_callbacks.merge!(arg)
end
def method_added(method_name)
if before_callbacks.key? method_name
@temirov
temirov / cyclic_array.rb
Last active November 23, 2015 17:45
A class that implements cyclic array in Ruby
class CyclicArray
include Enumerable
attr_reader :a
def initialize(a = [])
raise ArgumentError unless a.respond_to? :each
@a = a
end
@temirov
temirov / voting.rb
Last active November 23, 2015 17:47
Fibonacci voting
class Fibonacci
class << self
def number(n)
return cache[n] if cache[n]
cache[n] = number(n-1) + number(n-2)
end
private