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 / gist:4ab15b93d4924200c5d9
Created January 7, 2015 10:28
testing revolution :)
import requests
def visit(d):
print "Visit: %s" % d.url
if 'follow' in d.json():
visit(requests.get(next_link(d)))
else:
print d.text
def next_link(d):
<!DOCTYPE html SYSTEM>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>Brokermint</title>
<style type="text/css">
.fa {
display: inline-block;
font: normal normal normal 14px/1 FontAwesome;
@skatkov
skatkov / Bali
Last active August 29, 2015 14:18
hotels, wifi, prices, desc from Eric
## sCala
7-8.5mil/mo. Awesome pool. Very Posh. Breakfast incl. Neighborhood ok, halfway between Kuta and Canggu.
`0.3 down / 0.3 up`.
## Aqua blue
4.5/mo. Pool. 2nd floor. Kitchen in room w/ dishes. Desk and table. Neighborhood ok, (next to cScala).
`0.3 down / 1 up`.
## filadelphina bali guest house / kemiri home stay
aka Kemiri home stay (brother/sister joint business). 4.5 mil / mo. Basic. Desk. Bed. Aircon. Fridge kitchen share with owner. Pretty. Across from satu satu. Quiet road (raya pantai baway).
@skatkov
skatkov / gist:53e497c736c47d98ce92
Created May 7, 2015 08:24
spin-off heroku instances
#!/usr/bin/env ruby
$LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
require 'heroku'
require 'heroku/command/fork'
require 'heroku/command/run'
require 'github_api'
require 'heroku/client/pgbackups'
@skatkov
skatkov / gist:ffbbf7463101b4f5a5dd
Created May 8, 2015 15:52
removing all origin branches
git branch -a | grep /origin/ | awk -F/ '{print $3}'| xargs -I {} git push origin :{}
@skatkov
skatkov / HoneyBadgerFormatter
Created July 4, 2015 20:55
Honeybadger :: Rails.logger
class Logger::SimpleFormatter
def call(severity, time, progname, msg)
if Rails.env.production? && (severity == "FATAL" || severity == "ERROR")
@context = { :severity => severity.to_s, :time => time.to_s, :msg => msg.to_s }
Honeybadger.context(@context)
Honeybadger.notify(@context)
end
return "[#{severity}] #{msg}\n"
end
@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
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 / 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 = "test@example.org"
class Person
attr_accessor :name, :email
@skatkov
skatkov / Gemfile
Created June 10, 2017 10:14
map bencmark
source 'https://rubygems.org'
ruby '2.4'
gem 'benchmark-ips'