Skip to content

Instantly share code, notes, and snippets.

View skatkov's full-sized avatar
🏠
Working from home

Stanislav (Stas) Katkov skatkov

🏠
Working from home
View GitHub Profile
@skatkov
skatkov / wip_graphql_demo.rb
Created May 2, 2018 07:40 — forked from marckohlbrugge/wip_graphql_demo.rb
Ruby example of creating a todo and then completing it using wip.chat graphql.
# NOTE: Be sure to set the API key further down in the code!
require "net/http"
require "uri"
require "json"
class WIP
def initialize(api_key:)
@api_key = api_key
end
@skatkov
skatkov / string_auto_clear.rb
Last active January 29, 2018 16:29
String removal from malloc
class String
def auto_clear
begin
result = yield self
result.equal?(self) ? nil : result # avoid leaking
ensure
clear
end
end
end
@skatkov
skatkov / tsheets_users_controller.rb
Created October 27, 2017 12:57
TypeError: superclass mismatch for class UsersController
#file: app/controllers/tsheets/users_controller.rb
module Tsheets
class UsersController < ApplicationController
def update
# does something important here
render json: 'test: test'
end
end
end
GEM
remote: https://rubygems.org/
specs:
enumerable-lazy (0.0.2)
ffi (1.9.18)
haml (5.0.3)
temple (>= 0.8.0)
tilt
i18n (0.8.6)
mail (2.6.6)
@skatkov
skatkov / Gemfile
Created August 22, 2017 07:36
sep-contentino-comments
source 'https://rubygems.org'
ruby '2.4'
gem 'faker'
gem 'watir'
gem 'selenium-webdriver'
gem 'pry'
@skatkov
skatkov / Gemfile
Created June 17, 2017 19:42
JSON parser benchmarks
source 'https://rubygems.org'
ruby '2.4'
gem 'benchmark-ips'
gem 'yajl-ruby'
gem 'oj'
@skatkov
skatkov / Gemfile
Created June 10, 2017 10:14
map bencmark
source 'https://rubygems.org'
ruby '2.4'
gem 'benchmark-ips'
@skatkov
skatkov / benchmark.rb
Created February 9, 2017 10:49
Testing immutable data structure called 'Values' -> https://github.com/tcrayford/values/
require 'ostruct'
require 'benchmark'
require 'values'
COUNT = 10_000_000
NAME = "Test Name"
EMAIL = "[email protected]"
class Person
attr_accessor :name, :email
class QuestionType
## This is a class to avoid database lookup for survey_question_types table
## replicate actual table :
# id => :name
DATA = {
3 => 'Rank order',
4 => 'Constant sum',
5 => 'Drop-down menu',
6 => 'Numeric Freeform Input',
7 => 'Comment Box',
@skatkov
skatkov / spec_helper.rb
Created December 8, 2015 14:51
profiling rspec's with stackproof
# read here: http://blog.iempire.ru/2015/10/13/profiling-specs/
RSpec.configure do |config|
config.around(:each) do |example|
path = Rails.root.join("tmp/stackprof-cpu-test-#{example.full_description.parameterize}.dump")
StackProf.run(mode: :cpu, out: path.to_s) do
example.run
end
end
end