Skip to content

Instantly share code, notes, and snippets.

View take-five's full-sized avatar

Alexey Mikhaylov take-five

View GitHub Profile
@take-five
take-five / elasticsearch.py
Last active March 12, 2021 07:53
AWS ElasticSearch service Ansible dynamic inventory
#!/usr/bin/env python3
import argparse
import json
import re
import boto3
from botocore.config import Config
try:
from collections.abc import Mapping
@take-five
take-five / LICENSE.md
Last active April 1, 2024 22:55
Fast logical replication initializer for PostgreSQL

Copyright 2020 Glia Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER D

defmodule Friends.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
def start(_type, _args) do
# List all child processes to be supervised
children = [
@take-five
take-five / fib.rb
Created March 21, 2017 08:38
backend-dev interview code example
class FibonacciCalculator
def initialize
end
def run
number = ARGV.first
puts "Fibonacci number for N=#{number}: #{fib(number.to_i)}"
end
@take-five
take-five / gist:5112f12cc23a4001364a
Created March 27, 2015 18:30
Deploy without downtime

Taken from here

Barsoom

Deploy without downtime

We deploy without downtime when we can to avoid user frustration. It's pretty rare that we can't.

There's a great talk/slideshow on this, but no convenient reference that we're aware of – hence this document.

@take-five
take-five / gist:512cb30363caff6b4508
Last active August 29, 2015 14:16
readability test
def f(q,n)
if(n==nil)
return null;
end
l=0; h=ln(q)-1;d=l<=h;
while d
x=(l+h)/2;v=q[x]
if v>n then h=x-1
elsif v<n then l=x+1
else return v
WITH table_scans as (
SELECT relid,
tables.idx_scan + tables.seq_scan as all_scans,
( tables.n_tup_ins + tables.n_tup_upd + tables.n_tup_del ) as writes,
pg_relation_size(relid) as table_size
FROM pg_stat_user_tables as tables
),
all_writes as (
SELECT sum(writes) as total_writes
FROM table_scans
./extract.sh | wc -l
@take-five
take-five / push_parser.rb
Last active December 20, 2015 19:18
ox push parser (enumerator)
require 'enumerator'
require 'ox'
module Ox
class PushParser
DEFAULT_BUFSIZE = 4096
def initialize(handler, options = {}, &blk)
@buf = ''
@generator = Enumerator.new(&blk)