Skip to content

Instantly share code, notes, and snippets.

# disable swap
sudo swapoff -a
sed -ri '/\sswap\s/s/^#?/#/' /etc/fstab
# allow UFW ports
sudo ufw allow 10250
sudo ufw allow 30000:32767\tcp
# setup kubeadm, kubelet
sudo apt-get update && sudo apt-get install -y apt-transport-https ca-certificates curl
docker images --no-trunc --format '{{.ID}} {{.CreatedSince}}' \
| grep ' months' | awk '{ print $1 }' \
| xargs --no-run-if-empty docker rmi
This file has been truncated, but you can view the full file.
#!/usr/bin/env python
#
# Hi There!
# You may be wondering what this giant blob of binary data here is, you might
# even be worried that we're up to something nefarious (good for you for being
# paranoid!). This is a base85 encoding of a zip file, this zip file contains
# an entire copy of pip (version 20.2.4).
#
# Pip is a thing that installs packages, pip itself is a package that someone
# might want to install, especially if they're looking to run this get-pip.py
@ruslanmustafin
ruslanmustafin / infinite_dataloader.py
Created April 20, 2019 15:53 — forked from MFreidank/infinite_dataloader.py
A pytorch DataLoader that generates an unbounded/infinite number of minibatches from the dataset.
from torch.utils.data import DataLoader
class InfiniteDataLoader(DataLoader):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Initialize an iterator over the dataset.
self.dataset_iterator = super().__iter__()
def __iter__(self):
import torch
import torch.nn as nn
class Conv2dSame(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride=1, bias=True, padding_layer=nn.ReflectionPad2d):
super().__init__()
ka = kernel_size // 2
kb = ka - 1 if kernel_size % 2 == 0 else ka
self.net = nn.Sequential(
#usual installation
pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension
#you are my saver!
jupyter labextension install @jupyter-widgets/jupyterlab-manager
import argparse
import random
parser = argparse.ArgumentParser()
parser.add_argument('--input', required=True, help='Input sentence to scramble')
args = parser.parse_args()
def scramble_word(w):
@ruslanmustafin
ruslanmustafin / configure_cuda_p70.md
Created February 6, 2019 11:08 — forked from alexlee-gk/configure_cuda_p70.md
Use integrated graphics for display and NVIDIA GPU for CUDA on Ubuntu 14.04

This was tested on a ThinkPad P70 laptop with an Intel integrated graphics and an NVIDIA GPU:

lspci | egrep 'VGA|3D'
00:02.0 VGA compatible controller: Intel Corporation Device 191b (rev 06)
01:00.0 VGA compatible controller: NVIDIA Corporation GM204GLM [Quadro M3000M] (rev a1)

A reason to use the integrated graphics for display is if installing the NVIDIA drivers causes the display to stop working properly. In my case, Ubuntu would get stuck in a login loop after installing the NVIDIA drivers. This happened regardless if I installed the drivers from the "Additional Drivers" tab in "System Settings" or the ppa:graphics-drivers/ppa in the command-line.