Skip to content

Instantly share code, notes, and snippets.

Igor Serebryany igor47

Block or report user

Report or block igor47

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
View pres.py
from collections import defaultdict
import random
def left_or_right():
return 'l' if random.randint(0, 9) == 0 else 'r'
def make_group():
d = defaultdict(lambda: 0)
for i in range(45):
d[left_or_right()] += 1
View keybase.md

Keybase proof

I hereby claim:

  • I am igor47 on github.
  • I am igor47 (https://keybase.io/igor47) on keybase.
  • I have a public key whose fingerprint is 9F5D ADC0 1FB0 4BE0 9AA4 8808 5725 5CA7 693C 0FF9

To claim this, I am signing this object:

View sre.json
[
{"kScreenSaverURL":"https://app.datadoghq.com/screen/board/2582?fullscreen=true","kScreenSaverTime":"5"},
{"kScreenSaverURL":"https://rpm.newrelic.com/accounts/7358/applications/2237","kScreenSaverTime":"5"},
{"kScreenSaverURL":"https://dashboards.airbnb.com/screens/1","kScreenSaverTime":"5"}
]
@igor47
igor47 / converge.sh
Created Jan 21, 2014
airbnb's chef-solo converge script
View converge.sh
#!/bin/bash -eu
repo="/etc/chef/src"
origin=`cat /etc/chef/origin`
branch=`cat /etc/chef/branch`
role=`cat /etc/chef/role`
env=`cat /etc/chef/environment`
# create temporary files
git_clone=`mktemp -d`
@igor47
igor47 / parse_haproxy_matrix.py
Created Nov 5, 2013
The haproxy configuration manual contains a matrix listing configuration keywords and their applicability by haproxy section (defaults, listen, backend, frontend). This code parses the manual and produces a json hash of sections and the keywords that apply in those sections.
View parse_haproxy_matrix.py
#!/usr/bin/env python
from collections import defaultdict
import json
import requests
config_url = "http://haproxy.1wt.eu/download/1.5/doc/configuration.txt"
longest_keyword = 42 #works for haproxy 1.5 docs, but might need to be adjusted
# first, get the lines that pertain to the matrix
@igor47
igor47 / smartstack.md
Created Oct 31, 2013
services guide from airbnb
View smartstack.md

Smart Stack

We connect our REST services together using smartstack. Smartstack is mainly the combination of nerve and synapse. Nerve lets your service be discovered by other services, and synapse lets you discover services you yourself need.

Resources

In order to play well with smartstack, you need to define two special resources in your service. Both should return Content-type: text/plain.

@igor47
igor47 / walls.py
Last active Jun 4, 2016
another solution to the problem found in this post about twitter interviewing: http://qandwhat.apps.runkite.com/i-failed-a-twitter-interview/ this was on hacker news: https://news.ycombinator.com/item?id=6639839 the original post author solved it here: https://gist.github.com/mkozakov/59af0fd5bddbed1a0399 i use a state machine. this seemed like …
View walls.py
#!/usr/bin/python
def water(levels, second_pass = False):
# sanity check
if len(levels) < 2:
return 0
# state machine
filling = False
h = 0
@igor47
igor47 / chef_to_hash.rb
Created Jul 15, 2013
a recursive to_hash for chef 11; also handles arrays inside the hash.
View chef_to_hash.rb
class Chef
class Node
class ImmutableMash
def to_hash
h = {}
self.each do |k,v|
if v.respond_to?('to_hash')
h[k] = v.to_hash
elsif v.respond_to?('each')
h[k] = []
You can’t perform that action at this time.