Skip to content

Instantly share code, notes, and snippets.

View evu's full-sized avatar
🌎
>>> ▌

evu

🌎
>>> ▌
View GitHub Profile
@evu
evu / condaenv.txt
Last active July 31, 2018 13:52 — forked from pratos/condaenv.txt
To package a conda environment (Requirement.txt and virtual environment)
# To create a conda environment:
conda create --name <environment-name> python=<version:2.7/3.5>
# To create a requirements.txt file:
conda list
conda list -e > requirements.txt
# To export environment to a file:
activate <environment-name>
conda env export > <environment-name>.yml
@evu
evu / curl.md
Created August 1, 2018 22:32 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@evu
evu / BillingAlerts.yml
Created September 10, 2018 17:17
AWS CloudFormation template for billing alerts
# Put this in an S3 bucket and invoke it like this:
# https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/review?templateURL=https://s3.amazonaws.com/yourbucketname/BillingAlerts.yml&stackName=My-Billing-Alarms
AWSTemplateFormatVersion: 2010-09-09
Description: 'Billing Alerts for AWS Account'
Parameters:
EmailAddress:
Type: String
Description: "Enter email address for billing alerts"
@evu
evu / python_exception_hierarchy.txt
Created March 14, 2019 14:38
Python Exception Hierarchy (3.7)
BaseException
+-- SystemExit
+-- KeyboardInterrupt
+-- GeneratorExit
+-- Exception
+-- StopIteration
+-- StopAsyncIteration
+-- ArithmeticError
| +-- FloatingPointError
| +-- OverflowError
@evu
evu / l2_norm.py
Last active April 17, 2019 00:13
L2 norm
import numpy as np
def l2_norm(vec):
return np.sqrt(np.square(vec).sum())
def test_l2_norm():
for _ in range(1000):
ref = np.random.rand(100, 1)
@evu
evu / aws.sh
Created January 10, 2019 14:53
#!/bin/bash
role_name=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/`
creds=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/$role_name`
current_region=`curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | jq -c -r .region`
export AWS_ACCESS_KEY_ID=`printf "%s" "$creds" | jq -r .AccessKeyId`
export AWS_SECRET_ACCESS_KEY=`printf "%s" "$creds" | jq -r .SecretAccessKey`
export AWS_SESSION_TOKEN=`printf "%s" "$creds" | jq -r .Token`
export AWS_DEFAULT_REGION=$current_region
@evu
evu / self-signed-certificate-with-custom-ca.md
Created June 14, 2019 17:25 — forked from fntlnz/self-signed-certificate-with-custom-ca.md
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@evu
evu / bastion_proxy_setup.md
Last active June 20, 2019 16:00
Proxy through a bastion host

Proxy through a bastion host

On local machine

Generate an ssh key:

ssh-keygen -t ed25519 -f bastion -C "" -N ""
@evu
evu / jupyter_plotsize_fix.py
Last active August 12, 2019 19:42
Change plot size in Jupyter
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (20,10)
@evu
evu / pandas_cheatsheet.py
Created August 13, 2019 20:04
My Fav Pandas 🐼
# Summary statistics for numeric variables
df.describe().transpose()
# Summary statistics for categorical/string variables
df.describe(include=['O']).transpose()
# Info about column names, datatypes, and null values
df.info()
# Get a sample