Skip to content

Instantly share code, notes, and snippets.

View hohl's full-sized avatar

Michael Hohl hohl

View GitHub Profile
@hohl
hohl / RedisEventEmitter.test.ts
Last active August 29, 2015 14:18
RedisEventEmitter for Node.JS written in TypeScript
/*
*
* █████╗ ██╗ ██╗ ██╗ █████╗ ██╗ ██╗███████╗ ██████╗ ███╗ ██╗ ██╗██████╗ ██████╗
* ██╔══██╗██║ ██║ ██║██╔══██╗╚██╗ ██╔╝██╔════╝██╔═══██╗████╗ ██║██╗██╗██║██╔══██╗██╔════╝
* ███████║██║ ██║ █╗ ██║███████║ ╚████╔╝ ███████╗██║ ██║██╔██╗ ██║╚═╝╚═╝██║██████╔╝██║
* ██╔══██║██║ ██║███╗██║██╔══██║ ╚██╔╝ ╚════██║██║ ██║██║╚██╗██║██╗██╗██║██╔══██╗██║
* ██║ ██║███████╗╚███╔███╔╝██║ ██║ ██║ ███████║╚██████╔╝██║ ╚████║╚═╝╚═╝██║██║ ██║╚██████╗
* ╚═╝ ╚═╝╚══════╝ ╚══╝╚══╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ╚═════╝
*
*
@hohl
hohl / pg_backup.sh
Last active September 5, 2015 11:35
Bash script which dumps a Postgres DB and uploads it via SFTP
#!/bin/bash
# Purpose: Dumps a PostgreSQL database and uploads it via SFTP to another host.
# Author: Michael Hohl <me@michaelhohl.net>
# -----------------------------------------------------------------------------
display_usage() {
echo "Usage: $0 <dbname> <user@stfp-target>"
}
if [ $# -ne 2 ]; then
@hohl
hohl / Parser.scala
Created September 14, 2015 09:21
Why does this single test case fail, while others work as expected?
// ...
lazy val prefix: Parser[Prefix] =
(host | nick) ~ opt('!' ~> user) ~ opt('@' ~> host) ^^ {
case t ~ u ~ s => Prefix(t, u, s)
}
lazy val host = """[a-zA-Z0-9.:\-^_\-\[\]\\/`]+""".r
lazy val nick = """(\p{L}|[0-9]|[-_\[\]\\`^\{\}\|])+""".r
lazy val user = """[^(\s|@)]+""".r
@hohl
hohl / ThreadQueue.swift
Last active August 28, 2016 14:25
Serial dispatch queue implementation for cross-platform usage with Vapor. Feel free to use the code below as you want.
import Core
/**
Defines the basic ability of a job queue to dispatch jobs on a queue.
ThreadQueue is designed as protocol to support further implementations like a ConcurrentQueue.
*/
public protocol ThreadQueue {
func dispatch(_ function: @escaping () -> Void)
}
sudo dpkg -i </path/to/cudnn-runtime.deb>
sudo dpkg -i </path/to/cudnn-developer.deb>
# replace the parts between < and > with your real file paths
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo add-apt-repository "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /"
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
# Press [ENTER]
sudo apt-get install python3.7 python3.7-{dev,venv,distutils}
# Then create a virtual environment, for ex.:
mkdir ~/venvs && cd ~/venvs
python3.7 -m venv tf21
source tf21/bin/activate
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt install -y nvidia-driver-435
# According to the official "Build from source" steps:
# https://www.tensorflow.org/install/source
pip install -U 'future>=0.17.1'
pip install -U keras_applications --no-deps
pip install -U keras_preprocessing --no-deps
# My own additions
pip install -U numpy six wheel pip
# Download the TensorFlow 2.1 source:
curl -LO https://github.com/tensorflow/tensorflow/archive/v2.1.0.tar.gz
# Add NVIDIA package repositories
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.1.243-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1804_10.1.243-1_amd64.deb
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo apt-get update
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb
sudo apt install ./nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb
sudo apt-get update
# Install NVIDIA driver