Skip to content

Instantly share code, notes, and snippets.

# Generic Aliases
alias ll='ls -latr' # List all file in long list format by modification time
alias ..='cd ..' # Go up one directory
alias ...='cd ../..' # Go up two directories
alias ....='cd ../../..' # Go up three directories
alias -- -='cd -' # Go back
alias c='clear' # Clear Screen
alias k='clear' # Clear Screen
alias cls='clear' # Clear Screen
alias _="sudo" # Execute with sudo
In [4]: np.arange(10).astype(object).mean(axis=0)
Out[4]: 4.5
In [5]: np.__version__
Out[5]: '1.8.1'
@mfcabrera
mfcabrera / min-char-rnn.py
Last active August 29, 2015 14:26 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@mfcabrera
mfcabrera / stream_sample.py
Last active August 29, 2015 14:27 — forked from anonymous/stream_sample.py
Stream sample
"""
Programming task
================
Implement the method iter_sample below to make the Unit test pass. iter_sample
is supposed to peek at the first n elements of an iterator, and determine the
minimum and maximum values (using their comparison operators) found in that
sample. To make it more interesting, the method is supposed to return an
iterator which will return the same exact elements that the original one would
have yielded, i.e. the first n elements can't be missing.
@mfcabrera
mfcabrera / gist:0296b7830c4009cd859c
Created November 2, 2015 09:57 — forked from mayoff/gist:1185476
Emacs Lisp to reload a URL in Chrome (using AppleScript)
(defun mayoff:open-url-in-chrome (url)
"Open URL in Google Chrome. I use AppleScript to do several things:
1. I tell Chrome to come to the front. If Chrome wasn't launched, this will also launch it.
2. If Chrome has no windows open, I tell it to create one.
3. If Chrome has a tab showing URL, I tell it to reload the tab, make that tab the active tab in its window, and bring its window to the front.
4. If Chrome has no tab showing URL, I tell Chrome to make a new tab (in the front window) showing URL."
(when (symbolp url)
; User passed a symbol instead of a string. Use the symbol name.
(setq url (symbol-name url)))
(do-applescript (format "
db.getCollection("all").stats(scale=1024*1024*2014)
{
"ns" : "group_category.all",
"count" : 2092188, //2 million
"size" : 23, //GB
"avgObjSize" : 23470 (~23 KB),
}
;; Doopla
(defun doopla ()
(interactive)
(with-output-to-temp-buffer "*doopla*"
(shell-command "doopla 2>/dev/null &" "*doopla*" "*Messages*")
(pop-to-buffer "*doopla*")))
@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”
@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
@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