Skip to content

Instantly share code, notes, and snippets.

View thomelane's full-sized avatar

Thom Lane thomelane

  • Vancouver
View GitHub Profile
@thomelane
thomelane / main.sh
Created June 28, 2020 22:50
Remove git-secrets from a local project
# run from inside the project folder
find . -regex '.*/\.git/hooks/commit-msg' -exec sed -i '' -e 's/git secrets --commit_msg_hook -- "$@"//' {} \;
find . -regex '.*/\.git/hooks/pre-commit' -exec sed -i '' -e 's/git secrets --pre_commit_hook -- "$@"//' {} \;
find . -regex '.*/\.git/hooks/prepare-commit-msg' -exec sed -i '' -e 's/git secrets --prepare_commit_msg_hook -- "$@"//' {} \;
@thomelane
thomelane / main.sh
Created June 2, 2020 15:53
Jupytext
source activate JupytextSystemEnv
pip install jupytext --upgrade
jupyter serverextension enable jupytext
@thomelane
thomelane / index.py
Created May 10, 2020 23:25
Runtime install of PyPI package inside AWS Lambda function
import tempfile
from pathlib import Path
import subprocess
import sys
tmp_path = Path(tempfile.gettempdir())
packages = ['crhelper']
for package in packages:
subprocess.check_call([
@thomelane
thomelane / after_start.sh
Last active June 2, 2020 20:24
theia-ide-sagemaker
#!/bin/bash
set -e
## INSTALL THEIA IDE FROM SOURCE
EC2_HOME=/home/ec2-user
mkdir ${EC2_HOME}/theia && cd ${EC2_HOME}/theia
### begin by installing NVM, NodeJS v10, and Yarn
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash
source ${EC2_HOME}/.nvm/nvm.sh
nvm install 10
@thomelane
thomelane / commands.sh
Created November 20, 2019 01:28
GLX Commands
# On local MacOS machine...
1) Download and Install TurboVCN
Only source for binaries was sourceforge: https://sourceforge.net/projects/turbovnc/files/2.1.2/
`TurboVNC-2.1.2.dmg` failed to run on MacOS Siera, but `TurboVNC-2.1.2-AppleJava.dmg` was sucessful.
Only after installing an old version of Java: https://support.apple.com/kb/DL1572?locale=en_GB
2) Start AWS p3.2xlarge instance
@thomelane
thomelane / optimize.sh
Created October 29, 2019 23:42
MacOS Productivity Optimisations
# disable dock bouncing annimation
defaults write com.apple.dock no-bouncing -bool TRUE; killall Dock
@thomelane
thomelane / main.sh
Last active February 7, 2019 06:27
Git Commands
# Rename branch (local and remote)
git branch -m new_name
git push origin :old_name new_name
git push origin -u new_name
# checkout PR on github
git clone https://github.com/apache/incubator-mxnet.git
git fetch origin pull/13647/head:lipnet
git checkout lipnet
@thomelane
thomelane / layouts.csv
Last active September 21, 2018 06:37
Convolution layouts on Medium
Convolution Input Layout Kernel Layout Output Layout
1D (batch_size,in_channels,width) (channels,in_channels,width) (batch_size,channels,width)
2D (batch_size,in_channels,height,width) (channels,in_channels,height,width) (batch_size,channels,height,width)
3D (batch_size,in_channels,depth,height,width) (channels,in_channels,depth,height,width) (batch_size,channels,depth,height,width)
@thomelane
thomelane / conv.py
Created September 20, 2018 23:11
[Convolutions on Medium] Used in Medium blog post series #python #convolutions
def apply_conv(data, kernel, conv):
"""
Args:
data (NDArray): input data.
kernel (NDArray): convolution's kernel parameters.
conv (Block): convolutional layer.
Returns:
NDArray: output data (after applying convolution).
"""
# add dimensions for batch and channels if necessary
@thomelane
thomelane / xorg.conf
Created September 14, 2018 07:10
P3 xorg
Section "Files"
EndSection
Section "InputDevice"
# generated from default
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/psaux"