Skip to content

Instantly share code, notes, and snippets.

View elebow's full-sized avatar

Eddie Lebow elebow

View GitHub Profile
@elebow
elebow / recursive_factory.py
Created October 17, 2019 01:03
factory_boy fixture with a recursive factory
import factory
class Comment:
"""A comment model can have replies, which are also Comments."""
def __init__(self, author, text, replies=[]):
self.author = author
self.text = text
self.replies = replies
@elebow
elebow / viv_session_backup.sh
Created January 21, 2019 03:49
cron-able Vivaldi session backup script, with rotating history
BACKUP_PARENT=$HOME/.config/vivaldi/viv_session
BACKUP_LAST=$(find "$BACKUP_PARENT" -type d | sort -h | tail -n 1)
VIVDIR=$HOME/.config/vivaldi/Default
diff "$BACKUP_LAST/Current Session" "$VIVDIR/Current Session" > /dev/null 2>&1
if [ $? -eq 0 ]; then
#echo "no change"
exit 0;
fi
@elebow
elebow / socat-share-vim.md
Last active March 13, 2020 00:29
Use socat(1) and dtach(1) to share a single vim session among multiple remote hosts. Great for pair programming.
  1. Install socat and dtach on all hosts, and openssl on at least one host. And vim on the server!

  2. Generate two self-signed keypairs. You can accept all default values.

    for h in server client; do
    openssl req -newkey rsa:2048 -nodes -keyout $h-key.pem -x509 -days 365 -out $h-cert.pem
    done
@elebow
elebow / xcompose-to-osx-defaultkeybindingdict.rb
Created October 22, 2018 03:27
xcompose-to-osx-defaultkeybindingdict.rb
# Please don't even look at this horrible, write-only code
require 'parslet'
require 'pry'
class XComposeParser < Parslet::Parser
rule(:line) do
input.as(:input) >> spaces >>
match(':') >> spaces >>
output.as(:output) >> match['\n'].maybe
### Keybase proof
I hereby claim:
* I am elebow on github.
* I am eddielebow (https://keybase.io/eddielebow) on keybase.
* I have a public key whose fingerprint is 3C49 6E8B F9C9 2612 BA78 2714 F1D8 CC3A D29D 3693
To claim this, I am signing this object:
[{"text": " <a href=http://saturn.jpl.nasa.gov>Cassini</a>, <a href=http://saturn.jpl.nasa.gov/news/significantevents/significantevents20140724/>Titan Flyby</a>, Successful", "date1": "2014 7 20", "date2": null}, {"text": " <a href=http://www.nasa.gov/press/2014/july/nasa-honors-historic-first-moon-landing-eyes-first-mars-mission/>45th Anniversary (1969)</a>, <a href=http://en.wikipedia.org/wiki/Apollo_11>1st Man On The Moon (Apollo 11)</a>", "date1": "2014 7 20", "date2": null}, {"text": " <a href=http://ssd.jpl.nasa.gov/sbdb.cgi?orb=1;sstr=106P>Comet 106P/Schuster</a> <a href=http://scully.cfa.harvard.edu/cgi-bin/returnprepeph.cgi?d=c&o=0106P>Perihelion</a> (1.546 AU)", "date1": "2014 7 20", "date2": null}, {"text": " <a href=http://ssd.jpl.nasa.gov/sbdb.cgi?orb=1;sstr=283P>Comet 283P/Spacewatch</a> <a href=http://scully.cfa.harvard.edu/cgi-bin/returnprepeph.cgi?d=c&o=0283P>At Opposition</a> (2.880 AU)", "date1": "2014 7 20", "date2": null}, {"text": " <a href=http://ssd.jpl.nasa.gov/sbdb.cgi?ID=c00128_b>Co
@elebow
elebow / gist:002ec17cd7647fc1b251
Created August 9, 2014 21:55
Prepare JSON for space calendar
#!/usr/bin/python3
import urllib.request
import re
import json
#The source is HTML 3.2. Every modern parser I tried choked on it. So, we'll use regexes to extract what we want. The
#source HTML appears to be generated by a simple algorithm and has a very regular structure. I am aware of the
#implications of using regexes on HTML, but I think it's safe given the known constraints on our input.