Hi! If you see an error or something is missing (like :focus-within
for few years :P) please let me know ❤️
Element -- selects all h2
elements on the page
h2 {
A warning occurred (42 apples) | |
An error occurred |
#!/usr/bin/env python | |
""" | |
Convert camel-case to snake-case in python. | |
e.g.: CamelCase -> snake_case | |
Relevant StackOverflow question: http://stackoverflow.com/a/1176023/293064 | |
""" |
ipython nbconvert --to markdown <notebook>.ipynb --config jekyll.py |
def calc_lift(x,y,clf,bins=10): | |
""" | |
Takes input arrays and trained SkLearn Classifier and returns a Pandas | |
DataFrame with the average lift generated by the model in each bin | |
Parameters | |
------------------- | |
x: Numpy array or Pandas Dataframe with shape = [n_samples, n_features] | |
y: A 1-d Numpy array or Pandas Series with shape = [n_samples] |
#!/bin/env python | |
# Requires: youtube_dl module | |
# Requires: ffmpeg | |
# Usage: | |
# | |
# python youtube2mp3.py <URL>, ... | |
# | |
# Example: | |
# | |
# python youtube2mp3.py https://www.youtube.com/watch?v=dQw4w9WgXcQ |
""" | |
Produces load on all available CPU cores. | |
Requires system environment var STRESS_MINS to be set. | |
""" | |
from multiprocessing import Pool | |
from multiprocessing import cpu_count | |
import time | |
import os |
Log into your server with ssh, something like
ssh -i "my_secret.pem" [email protected]
If it's a new server, you'll need to install a few things.
Install conda with
from PIL import Image, ImageOps | |
def padding(img, expected_size): | |
desired_size = expected_size | |
delta_width = desired_size - img.size[0] | |
delta_height = desired_size - img.size[1] | |
pad_width = delta_width // 2 | |
pad_height = delta_height // 2 | |
padding = (pad_width, pad_height, delta_width - pad_width, delta_height - pad_height) |
# Source: https://stackoverflow.com/a/33597599/5391200 | |
from pylab import * | |
cmap = cm.get_cmap('seismic', 5) # matplotlib color palette name, n colors | |
for i in range(cmap.N): | |
rgb = cmap(i)[:3] # will return rgba, we take only first 3 so we get rgb | |
print(matplotlib.colors.rgb2hex(rgb)) | |
cmap = cm.get_cmap('plasma', 101) |