Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am naure on github.
  • I am naure (https://keybase.io/naure) on keybase.
  • I have a public key ASCQ851JoRb_9jF7stjiVNLDCoTAVjHx-ue1ZBNlYBz0Nwo

To claim this, I am signing this object:

@naure
naure / Makefile
Created August 2, 2017 16:27
Commands to encrypt and decrypt secrets in git
# Store encrypted secrets in git.
#
# 1. Put all your keys and passwords in a directory called secrets/
# 2. make encrypt_secrets, and enter a password twice.
# 3. git commit, push, pull, etc.
# 4. make decrypt_secrets, and enter the password again.
#
encrypt_secrets:
tar cz secrets | openssl aes-256-cbc -out secrets.tgz.aes
@naure
naure / Makefile
Last active August 16, 2017 11:03
Interactive work on remote server
# Start a stable Jupyter server.
# Connect to http://localhost:9999/ with token 1234
# May require: echo "AllowTcpForwarding yes" | sudo tee -a /etc/ssh/sshd_config
remote-jupyter:
ssh SERVER \
-L 9999:localhost:9999 -t \
'nohup \
jupyter notebook \
--port=9999 --port-retries=0 \
@naure
naure / keras_selu.py
Last active June 10, 2017 19:34
SELU in Keras and Numpy
import keras
from keras import backend as K
def kr_selu(x, alpha=1.6732632423543772848170429916717, scale=1.0507009873554804934193349852946):
""" Scaled Exponential Linear Units
Magic values target activations of 0 mean and 1 variance.
See https://arxiv.org/abs/1706.02515
"""
return scale * K.elu(x, alpha)
@naure
naure / sharedCats.py
Created May 30, 2017 17:15
pandas: Manage shared categories for several columns and dataframes
#%% Manage shared categories for several columns and dataframes
import pandas as pd
from collections import defaultdict
globalCats = defaultdict(lambda: pd.Categorical([]))
def convertCategories(df, field, fieldForCats=None):
" Convert field in df to categories "
cats = globalCats[fieldForCats or field]
@naure
naure / manifest.json
Last active January 9, 2017 16:47
Go directly to facebook messages, avoiding the feed time sink
{
"manifest_version": 2,
"name": "Nope facebook",
"description": "Go directly to messages, avoiding the feed time sink.",
"version": "1.0",
"content_scripts": [
{
"matches": ["https://www.facebook.com/"],