Skip to content

Instantly share code, notes, and snippets.

def delimited(filename, delimiter=' ', bufsize=4096):
'''
Creates a generator of word from a file based on a delimiter (by default white space).
'''
buf = ''
with open(filename) as file:
while True:
newbuf = file.read(bufsize)
if not newbuf:
(defun read-lines (filePath)
"Return a list of lines of a file at filePath."
(with-temp-buffer
(insert-file-contents filePath)
(split-string (buffer-string) "\n" t)))
(defun parse-spec (s)
(let ( (parsed (split-string s " " t) ) )
(list
def apply_processors(processors, df, callback=None):
def _callback(processor, df):
if callback is None:
return
callback(processor, df)
for fn in processors:
df = fn(df)
_callback(fn, df)
@mfcabrera
mfcabrera / installing_nvidia_driver_cuda_cudnn_linux.md
Created November 11, 2020 07:02 — forked from kmhofmann/installing_nvidia_driver_cuda_cudnn_linux.md
Installing the NVIDIA driver, CUDA and cuDNN on Linux

Installing the NVIDIA driver, CUDA and cuDNN on Linux (Ubuntu 20.04)

This is a companion piece to my instructions on building TensorFlow from source. In particular, the aim is to install the following pieces of software

on an Ubuntu Linux system, in particular Ubuntu 20.04.

@mfcabrera
mfcabrera / braking.md
Last active June 12, 2019 19:05
Theorie Test / Q & A - These are the more difficult questions. They are not all of the questions you may encounter on the test.

Braking

Standard Braking Distance

  • DE: (Geschwindigkeit / 10) * (Geschwindigkeit / 10)
  • EN: (Speed / 10) * (Speed / 10)

Evasive (Emergency) Braking Distance

  • DE: ((Geschwindigkeit / 10) * (Geschwindigkeit / 10)) / 2
  • EN: ((Speed / 10) * (Speed / 10)) / 2
@mfcabrera
mfcabrera / ansible-macos-homebrew-packages.yml
Created May 6, 2019 18:33 — forked from mrlesmithjr/ansible-macos-homebrew-packages.yml
Install MacOS Homebrew Packages With Ansible
---
- name: Install MacOS Packages
hosts: localhost
become: false
vars:
brew_cask_packages:
- 'atom'
- 'docker'
- 'dropbox'
- 'firefox'
@mfcabrera
mfcabrera / unit-to-pytest.sh
Last active February 7, 2019 15:47
Sed commands to change from Unittest assertion to pytest style
sed -i ".bak" -E 's/self\.assertFalse\((.*)\)/assert not \1/g' tests/*.py
sed -i ".bak" -E 's/self\.assertTrue\((.*)\)/assert \1/g' tests/*.py
sed -i ".bak" -E 's/self\.assertEqual\(([^,]*), (.*)\)$/assert \1 == \2/g' tests/*.py
sed -i ".bak" -E 's/self\.assertIn\(([^,]*), (.*)\)$/assert \1 in \2/g' tests/*.py
sed -i ".bak" -E 's/self\.assertNotEqual\(([^,]*), (.*)\)$/assert \1 != \2/g' tests/*.py
sed -i ".bak" -E 's/self\.assertNotIn\(([^,]*), (.*)\)$/assert \1 not in \2/g' tests/*.py
sed -i ".bak" -E 's/self\.assertIsNone\((.*)\)$/assert \1 is None/g' tests/*.py
sed -i ".bak" -E 's/self\.assertIsNotNone\((.*)\)$/assert \1 is not None/g' tests/*.py
sed -i ".bak" -E 's/self\.assertAlmostEqual\(([^,]*), (.*)\)$/\2 == pytest.approx\(\1\)/g' tests/*.py
#!/usr/bin/perl
# Program to filter Wikipedia XML dumps to "clean" text consisting only of lowercase
# letters (a-z, converted from A-Z), and spaces (never consecutive).
# All other characters are converted to spaces. Only text which normally appears
# in the web browser is displayed. Tables are removed. Image captions are
# preserved. Links are converted to normal text. Digits are spelled out.
# Adapted for the german language based on the script written by Matt Mahoney
# http://mattmahoney.net/dc/textdata.html
@mfcabrera
mfcabrera / install-tensorflow.sh
Last active November 20, 2016 20:20 — forked from erikbern/install-tensorflow.sh
Installing TensorFlow on EC2
# Note – this is not a bash script (some of the steps require reboot)
# I named it .sh just so Github does correct syntax highlighting.
# This install Tensorflow 0.11, Cuda 8.0 and cudnn-8.0
# The CUDA part is mostly based on this excellent blog post:
# http://tleyden.github.io/blog/2014/10/25/cuda-6-dot-5-on-aws-gpu-instance-running-ubuntu-14-dot-04/
# I extened Erick using additional instructions from http://ramhiser.com/2016/01/05/installing-tensorflow-on-an-aws-ec2-instance-with-gpu-support/
# Install various packages
sudo apt-get update
sudo apt-get upgrade -y # choose “install package maintainers version”
;; Doopla
(defun doopla ()
(interactive)
(with-output-to-temp-buffer "*doopla*"
(shell-command "doopla 2>/dev/null &" "*doopla*" "*Messages*")
(pop-to-buffer "*doopla*")))