Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am 8enmann on github.
  • I am 8enmann (https://keybase.io/8enmann) on keybase.
  • I have a public key ASA6wR0JT_nqKd__Rdi52lDWzDLg56iWFJrB3TnLXOvc9Qo

To claim this, I am signing this object:

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@8enmann
8enmann / reinstall.sh
Last active October 12, 2021 06:07
Reinstall NVIDIA drivers without opengl Ubuntu 16.04 GTX 1080ti
# Download installers
mkdir ~/Downloads/nvidia
cd ~/Downloads/nvidia
wget https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_375.26_linux-run
wget http://us.download.nvidia.com/XFree86/Linux-x86_64/384.59/NVIDIA-Linux-x86_64-384.59.run
sudo chmod +x NVIDIA-Linux-x86_64-384.59.run
sudo chmod +x cuda_8.0.61_375.26_linux-run
./cuda_8.0.61_375.26_linux-run -extract=~/Downloads/nvidia/
# Uninstall old stuff
sudo apt-get --purge remove nvidia-*
@8enmann
8enmann / post_process.py
Created May 3, 2019 22:40 — forked from Smerity/post_process.py
WikiText: Python 2 post processing used on Moses tokenized input
# encoding=utf8
import sys
reload(sys)
sys.setdefaultencoding('utf8')
import re
number_match_re = re.compile(r'^([0-9]+[,.]?)+$')
number_split_re = re.compile(r'([,.])')
======================================== SAMPLE 1 ========================================
little salad I thought to myself and the moment went by I knew that I couldn't wait to try some new fruits and vegetables at home and get my hair to grow back. It took me about 3
======================================== SAMPLE 2 ========================================
curry with bhoja and sesame seeds but I did it more for the crunch factor.
There is one caveat to this recipe
Although I enjoyed the chutney sauce, I
======================================== SAMPLE 3 ========================================
burger or had a plate of tacos. The good news is that the food is still delicious. I had just ordered the chicken tacos, the chicken was cooked and topped with onions and a casserole
======================================== SAMPLE 1 ========================================
breakfast," the janitor said. "I'm assuming it's an abundance day so everyone has extra for one coming to go," he added. The cream and butter was nice and fluffy, though I
======================================== SAMPLE 2 ========================================
French recipe before I went to college so I've learned a lot here. I'm not going to spend too much time about it, but for those of you who don't, it's a simple
======================================== SAMPLE 3 ========================================
meal from New Order for the last few weeks, and don't think that I can take days off."
Little did she know, the waiter was among the first to take advantage of both the
======================================== SAMPLE 4 ========================================
white pepper cake with my boyfriend.
@8enmann
8enmann / test_format_time.py
Created June 21, 2019 02:05
Format time in Python using pytest
"""
TDD solution to:
Input: a bunch of times, minutes and seconds, formatted as a single string like: "12:32 34:01 15:23 9:27 55:22 25:56"
Output: the sum of the times, hours, minutes, and seconds, formatted as a single string like: "2:32:41"
https://github.com/cjdev/interview-preparation
https://coderpad.io/sandbox
"""
import pytest
@8enmann
8enmann / count.py
Last active June 22, 2019 20:14
Benchmark reading files with threading and multiprocessing
"""Read files using threading and multiprocessing.
Execute on https://coderpad.io/sandbox
"""
from concurrent.futures import ThreadPoolExecutor, as_completed
from multiprocessing.dummy import Pool
import multiprocessing
from collections import Counter
import glob
@8enmann
8enmann / counter.py
Created June 22, 2019 20:18
Experimenting with pytest, cosine similarity, ngram counting
import requests
import re
from typing import List, Sequence
from collections import Counter
import numpy as np
TEST_URL = 'http://titan.dcs.bbk.ac.uk/~kikpef01/testpage.html'
URL_RE = re.compile(r'href="(http.+?)"')
TOKENIZER_RE: re.Pattern = re.compile(r'\w+')
@8enmann
8enmann / ngram.py
Created June 22, 2019 21:03
Calculate ngrams as fast as possible
"""Calculate N-gram counts as fast as possible for a large encoded file."""
import numpy as np
from collections import deque
import multiprocessing as mp
from typing import Any, Iterable, Generator
import time
from collections import Counter
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
from functools import partial