Skip to content

Instantly share code, notes, and snippets.

View RadoslawB's full-sized avatar
🎯
Focusing

Radosław Białowąs RadoslawB

🎯
Focusing
View GitHub Profile

Run Jupyter notebook on server

  1. run on instance: jupyter notebook --no-browser --port=<host port>
  2. in other terminal tab ssh -i <pem key> -L <client port>:localhost:<host port> user@<ip>
  3. in browser hit localhost:<client port>
import urllib.request
import tarfile
def get_data(file_url, file_name='downloaded')
urllib.request.urlretrieve(file_url)
with tarfile.open(file_name, "r:gz") as f:
f.extractall()
from matplotlib import animation
predictions_history = []
# append arrays of Y_test values to predictions hostory
fig, ax = plt.subplots()
ax.grid()
scatter = ax.scatter(X_train,Y_train, s=5, c='r')
parabola, = ax.plot(X_train, predictions_history[0])
# initialization function: plot the background of each frame

King of them all: shortcuts

@RadoslawB
RadoslawB / gist:5357ec038f758255849e3c2ad6794a92
Last active January 24, 2020 19:52 — forked from anthonyray/gist:398fde676a7704c03d6624155ba0011e
Set up OhMyZsh on Amazon EC2 instance running Ubuntu Server 14.04
  1. Connect to your EC2 instance
  2. Install zsh : sudo apt-get update && sudo apt-get install zsh
  3. Edit your passwd configuration file to tell which shell to use for user (check with whoami):sudo vim /etc/passwd`
  4. Look for ubuntu user, and replace bin/bash by bin/zsh
  5. Install OhMyZsh : sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
  6. Disconnect from your instance and reconnect it.
  7. git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
  8. git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
  9. Add in .zshrc line: plugins=(git zsh-autosuggestions zsh-syntax-highlighting). Remember to remove previous plugins=(git)
sudo apt-get update
sudo apt-get remove docker docker-engine docker.io
sudo apt install docker.io
sudo systemctl enable docker - sets Docker to run at startup.
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo docker-compose --version
sudo chmod +x /usr/local/bin/docker-compose
type Nullable<T> = T | null;
type Falsy<T> = T | false | undefined | null;
interface Dictionary<T> {
[P: string]: T;
}
type BooleanDict = Dictionary<Boolean>
from typing import List, Any, Dict
from collections import Counter
"""
Write a function that receives two sequences: A and B of integers and returns one sequence C.
Sequence C should contain all elements from sequence A (maintaining the order) except those,
that are present in sequence B p times, where p is a prime number.
"""
@RadoslawB
RadoslawB / letsencrypt
Created March 17, 2020 10:14 — forked from HarshadRanganathan/letsencrypt
Let's Encrypt SSL for Nginx in Amazon Linux AMI instance
# Install wget
yum install wget -y
# Install certbot-auto
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
# Obtain SSL certificate with Nginx plugin for the domain
sudo ./certbot-auto --nginx -d app.com --debug
@RadoslawB
RadoslawB / sortDecorator.ts
Created March 19, 2020 20:17
Javascript/Typescript sort decorator
/**
* * Decorator for methods returning T[]; where T has property fieldName
* @param fieldName: string, property name to sort by; reference _.orderBy documentation
* @param direction: string; reference _.orderBy documentation
*/
export function Sort<T>(fieldName: keyof T, direction: SortDirection = 'asc'): any {
return function(target: any, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor {
const original = descriptor.value;
descriptor.value = function(...args: any[]): any {
const result = original.apply(this, args);