Skip to content

Instantly share code, notes, and snippets.

View njbbaer's full-sized avatar

Nate Baer njbbaer

View GitHub Profile
@yeedle
yeedle / hourly-weather.R
Last active February 5, 2022 04:14
Temperature of every hour in NY since 1973
library(tidyverse)
library(R.utils)
library(glue)
library(magrittr)
library(weathermetrics)
library(padr)
library(ggExtra)
library(lubridate)
library(scales)
library(hrbrthemes)
@njbbaer
njbbaer / tunnel-ssh.service
Created July 30, 2017 08:01
autossh reverse tunnel systemd service file
[Unit]
Description=autossh reverse tunnel
After=network.target
[Service]
User=<local_user>
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -M 0 -o "ServerAliveInterval 30" -o "ServerAliveCountMax 10" -NR <remote_port>:localhost:<local_port> <remote_user>@<address>
[Install]
@simonw
simonw / recover_source_code.md
Last active May 30, 2024 00:39
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@njbbaer
njbbaer / ca.py
Last active October 27, 2022 18:05
Fast implementation of cellular automata using 2D convolution
import time
import numpy as np
from numpy.fft import fft2, ifft2
from matplotlib import pyplot, animation
def fft_convolve2d(board, kernal):
board_ft = fft2(board)
kernal_ft = fft2(kernal)
height, width = board_ft.shape
@njbbaer
njbbaer / fog-creek.py
Last active August 6, 2016 08:28
Solution to Fog Creek's developer puzzle
'''
http://www.fogcreek.com/jobs/dev
Find a 9 letter string of characters that contains only letters from: acdegilmnoprstuw
such that the hash(the_string) is: 945924806726376
if hash is defined by the following pseudo-code:
Int64 hash (String s) {