Skip to content

Instantly share code, notes, and snippets.

View akrisanov's full-sized avatar

Andrey Krisanov akrisanov

View GitHub Profile
@akrisanov
akrisanov / latency_numbers.md
Created March 11, 2018 16:09
Latency Numbers Every Programmer Should Know
Task ns us ms
L1 cache reference 0.5
Branch mispredict 5
L2 cache reference 7 14x L1 cache
Mutex lock/unlock 25
Main memory reference 100 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 3
Send 1K bytes over 1 Gbps network 10,000 10
Read 4K randomly from SSD* 150,000 150 ~1GB/sec SSD
# heights and positions are available as lists
# Import numpy
import numpy as np
# Convert positions and heights to numpy arrays: np_positions, np_heights
np_positions = np.array(positions)
np_heights = np.array(heights)
# Heights of the goalkeepers: gk_heights
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(123)
all_walks = []
# Simulate random walk 250 times
for i in range(250) :
random_walk = [0]
for x in range(100) :
# Define plot_pop()
def plot_pop(filename, country_code):
# Initialize reader object: urb_pop_reader
urb_pop_reader = pd.read_csv(filename, chunksize=1000)
# Initialize empty DataFrame: data
data = pd.DataFrame()
# Iterate over each DataFrame chunk
@akrisanov
akrisanov / data_camp5.py
Last active July 21, 2018 18:47
DataCamp: Importing Data in Python (Part 1)
import numpy
# Print the keys of the MATLAB dictionary
print(mat.keys())
# Print the type of the value corresponding to the key 'CYratioCyt'
print(type(mat['CYratioCyt']))
# Print the shape of the value corresponding to the key 'CYratioCyt'
print(numpy.shape(mat['CYratioCyt']))
@akrisanov
akrisanov / asyncio-async-await.py
Last active September 11, 2018 10:06 — forked from miguelgrinberg/asyncio-async-await.py
Python Async Examples
import asyncio
loop = asyncio.get_event_loop()
async def hello():
await asyncio.sleep(3)
print('Hello!')
if __name__ == '__main__':
loop.run_until_complete(hello())
import re
import matplotlib.pyplot as plt
import seaborn as sns
def word_in_text(word, text):
word = word.lower()
text = tweet.lower()
match = re.search(word, text)
if match:
$ gem install license_finder
$ license_finder
........................................
Dependencies that need approval:
bundler, 1.12.5, MIT
minitest, 5.10.2, MIT
rake, 12.0.0, MIT
simplecov, 0.13.0, MIT
simplecov-html, 0.10.1, MIT
@akrisanov
akrisanov / Gemfile
Last active August 30, 2018 20:48
Annotated Gemfile
## Backgroud jobs, queue ---------------------------
gem "daemons", "1.2.4" # Aug 2016
gem "delayed_job", "4.1.3" # May 2017
gem "delayed_job_active_record", "4.1.2" # May 2017
gem "delayed_job_web", "1.4" # May 2017
gem "stomp", "1.4.4" # Jun 2017
## Logs, metrics -----------------------------------
@akrisanov
akrisanov / Flexible Dockerized Phoenix Deployments.md
Created September 21, 2018 22:45 — forked from jswny/Flexible Dockerized Phoenix Deployments.md
A guide to building and running zero-dependency Phoenix (Elixir) deployments with Docker. Works with Phoenix 1.2 and 1.3.

Prelude

I. Preface and Motivation

This guide was written because I don't particularly enjoy deploying Phoenix (or Elixir for that matter) applications. It's not easy. Primarily, I don't have a lot of money to spend on a nice, fancy VPS so compiling my Phoenix apps on my VPS often isn't an option. For that, we have Distillery releases. However, that requires me to either have a separate server for staging to use as a build server, or to keep a particular version of Erlang installed on my VPS, neither of which sound like great options to me and they all have the possibilities of version mismatches with ERTS. In addition to all this, theres a whole lot of configuration which needs to be done to setup a Phoenix app for deployment, and it's hard to remember.

For that reason, I wanted to use Docker so that all of my deployments would be automated and reproducable. In addition, Docker would allow me to have reproducable builds for my releases. I could build my releases on any machine that I wanted in a contai