Skip to content

Instantly share code, notes, and snippets.

Maksym Melnychok keymone

Block or report user

Report or block keymone

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@keymone
keymone / tailor.rb
Created Jun 21, 2012
the realtime newrelic
View tailor.rb
# Usage, assuming that production.log is your rails log
#
# $ tail -f production.log | grep Completed | ruby tailor.rb <estimate> <size>
#
# * estimate is estimated number of requests per second (make it 50% larger)
# * size is length of every stat block(second, minute, hour)
# a line to print out
#
# @accept [Integer] num number of requests
@keymone
keymone / graph.rb
Created Jul 11, 2012
puppet repo graph
View graph.rb
# Generates infrastructure graph in DOT format
# Usage:
# $ find . -name '*.pp' | while read file; do cat $file; echo; done | \
# ruby graph.rb > puppet.dot
NODE = /^\s*(class|define|node)(\s+)([\w:]+)/
RELATION = /^\s*(require|inherits|include)(\s+)([\w:]+)/
USAGE = /^\s*([\w:]*[\w])(\s*)\{(\s*)/
IGNORE = %w{file package service cron exec Exec line plugin}
@keymone
keymone / speedtest.rb
Created Jul 16, 2012 — forked from equivalent/speedtest
ljust speed test
View speedtest.rb
# just speed test for http://stackoverflow.com/questions/11502629/how-to-do-number-to-string-suffix/11502715#11502715
# if we properly test int<->str conversion the log_10 method is about 30% faster
begin
int = 5
a = Time.now.to_f
10_000_000.times { int.to_s.ljust(3, "0").to_i }
puts Time.now.to_f - a # => 1.3s
View some.sql
create table mc (id int, member varchar(3));
insert into mc values (1, 'abc'), (1, 'pqr'), (2, 'xyz'), (2, 'pqr'), (3, 'pqr'), (3, 'abc');
Select id,count(*) as total from mc group by id having total=(Select count(*) from mc where id=1);
-- Result:
-- +------+-------+
-- | id | total |
-- +------+-------+
View cart_pole.py
import gym
import numpy as np
import math
def atg01(x):
return 0.5 + math.atan(x) / math.pi
env = gym.make('CartPole-v0')
best = 1
@keymone
keymone / curlj.clj
Last active May 20, 2017
Convert curl command into http request
View curlj.clj
(def curl-opts
[["-A" "--user-agent AGENT" "User-Agent string"
:assoc-fn (fn [m _ v] (assoc-in m [:headers "User-Agent"] v))]
["-b" "--cookie DATA" "Cookie name=value"
:id :cookies :default {}
:assoc-fn (fn [m k v] (let [[kk & vv] (split v #"=")]
(assoc-in m [k kk] {:discard true
:path "/"
:value (join "=" vv)})))]
["-H" "--header DATA" "Header \"header: value\""
View keybase.md

Keybase proof

I hereby claim:

  • I am keymone on github.
  • I am keymone (https://keybase.io/keymone) on keybase.
  • I have a public key whose fingerprint is 7937 BF76 A931 9144 4FB9 7BB7 E30B 109F 55EC 7BA8

To claim this, I am signing this object:

@keymone
keymone / tiny_redis.rb
Last active Jul 4, 2017
tiny_redis_client.rb
View tiny_redis.rb
# Copyright 2017 Maksym Melnychok
# MIT License - https://opensource.org/licenses/MIT
#
# inspired by https://github.com/ptrofimov/tinyredisclient
require 'socket'
class TinyRedis
RN = "\r\n"
@keymone
keymone / fullnode.md
Last active Apr 10, 2018 — forked from romanz/fullnode.md
Bitcoin Full Node on AWS Free Tier
View fullnode.md

Bitcoin Full Node on AWS Free Tier

Provisioning

  • Launch one T2 micro instance, using Ubuntu 14.04 LTS AMI.
  • Open SSH and Bitcoin Protocol TCP ports: 22, 8333.
  • Attach 150GB EBS (General-Purpose SSD) volume for blockchain storage to /dev/sdf.

The pricing would be ~$15/month. See here for more details.

@keymone
keymone / encrypt_decrypt.rb
Last active Jun 19, 2018 — forked from wteuber/encrypt_decrypt.rb
Simply encrypt and decrypt Strings in ruby.
View encrypt_decrypt.rb
require 'openssl'
require 'base64'
# key and iv stored in configs, generated using:
# cipher = OpenSSL::Cipher::Cipher.new('AES-256-CBC').encrypt
# key = cipher.random_key
# iv = cipher.random_iv
def encrypt_id(key, iv, id)
cipher = OpenSSL::Cipher::Cipher.new('AES-256-CBC').encrypt
You can’t perform that action at this time.