Skip to content

Instantly share code, notes, and snippets.

@sirodoht
sirodoht / restore-django-postgres-dokku.md
Last active September 15, 2018 06:29
How to restore Django Postgres on dokku (using dokku-postgres plugin backup)

First download the backup from S3. Should be in the form:

postgres-appname-2018-09-14-07-00-04.tgz

Then, delete your local db (or rename it).

Re-create (empty) db (guide).

Then extract, and cd into backup folder. There, the pg dump called export should reside. Execute:

@sirodoht
sirodoht / slugify
Last active November 14, 2018 23:44
Slugify CLI tool in Python
#!/usr/bin/env python3
# Usage:
# slugify any thing here really
# Stolen from Django:
# https://github.com/django/django/blob/277017aea4cf72a1797102e6d129165181d04e17/django/utils/text.py#L386
import re
@sirodoht
sirodoht / postgres-dump-restore.md
Last active August 30, 2019 22:43
How to dump and restore in Postgres using custom format

How to dump and restore in Postgres

Dump

$ pg_dump -h localhost -p 5432 -U dbuser -F c -b -v -f "./dump" dbname

Restore

How to generate a self-signed SSL using openssl

$ openssl req -x509 -nodes -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365

-nodes is for not requiring a passphrase (for the key).

How to remove passphrase from key using openssl

@sirodoht
sirodoht / brew-services.10m.rb
Created September 20, 2019 16:45
Brew Services BitBar Plugin by @eproxus
#!/usr/bin/env ruby
# <bitbar.title>Brew Services</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>Adam Lindberg</bitbar.author>
# <bitbar.author.github>eproxus</bitbar.author.github>
# <bitbar.desc>Shows and manages Homebrew services.</bitbar.desc>
# <bitbar.image>http://i.imgur.com/hVfhHYP.jpg</bitbar.image>
# <bitbar.dependencies>ruby, brew, brew-services</bitbar.dependencies>
@sirodoht
sirodoht / django-gen-secret-key.py
Last active September 29, 2019 21:13
Generating a SECRET_KEY for Django.
#!/usr/local/bin/python3
import random
secret_key = ''.join([random.SystemRandom().choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)])
print(secret_key)
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
html {
line-height: 1.15;
-webkit-text-size-adjust: 100%;
}
body {
margin: 0;
}
@sirodoht
sirodoht / iterm.json
Last active January 7, 2020 01:16
iTerm2 profile export
{
"Working Directory" : "\/Users\/sirodoht",
"Prompt Before Closing 2" : false,
"Selected Text Color" : {
"Red Component" : 0.34509803921568627,
"Color Space" : "sRGB",
"Blue Component" : 0.45882352941176469,
"Green Component" : 0.43137254901960786
},
"Rows" : 25,
@sirodoht
sirodoht / iterm-light.itermcolors
Created January 7, 2020 01:17
iTerm2 light colors preset
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.25882354378700256</real>
@sirodoht
sirodoht / iterm-keys.itermkeymap
Created January 7, 2020 01:20
iTerm2 keys export
{"Touch Bar Items":[],"Key Mappings":{"0xf700-0x260000":{"Action":10,"Text":"[1;6A"},"0x37-0x40000":{"Action":11,"Text":"0x1f"},"0x32-0x40000":{"Action":11,"Text":"0x00"},"0xf709-0x20000":{"Action":10,"Text":"[17;2~"},"0xf70c-0x20000":{"Action":10,"Text":"[20;2~"},"0xf729-0x20000":{"Action":10,"Text":"[1;2H"},"0xf72b-0x40000":{"Action":10,"Text":"[1;5F"},"0xf705-0x20000":{"Action":10,"Text":"[1;2Q"},"0xf703-0x260000":{"Action":10,"Text":"[1;6C"},"0xf700-0x220000":{"Action":10,"Text":"[1;2A"},"0xf701-0x280000":{"Action":11,"Text":"0x1b 0x1b 0x5b 0x42"},"0x38-0x40000":{"Action":11,"Text":"0x7f"},"0x33-0x40000":{"Action":11,"Text":"0x1b"},"0xf703-0x220000":{"Action":10,"Text":"[1;2C"},"0xf701-0x240000":{"Action":10,"Text":"[1;5B"},"0xf70d-0x20000":{"Action":10,"Text":"[21;2~"},"0xf702-0x260000":{"Action":10,"Text":"[1;6D"},"0xf729-0x40000":{"Action":10,"Text":"[1;5H"},"0xf706-0x20000":{"Action":10,"Text":"[1;2R"},"0x34-0x40000":{"Action":11,"Text":"0x1c"},"0xf700-0x280000":{"Action":11,"Text":"0x1b 0x1b 0x5b 0x4