Skip to content

Instantly share code, notes, and snippets.

@sirodoht
sirodoht / vscode.json
Last active March 22, 2023 18:13
VSCode settings JSON configuration
{
"editor.bracketPairColorization.enabled": true,
"editor.cursorStyle": "block",
"editor.dragAndDrop": false,
"editor.hover.enabled": false,
"editor.linkedEditing": false,
"editor.minimap.enabled": true,
"editor.minimap.showSlider": "always",
"editor.minimap.size": "fill",
"editor.renderWhitespace": "selection",
@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>

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

/*! 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 / 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

@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:

$ gpg --list-secret-keys
$ gpg --edit-key XXX
gpg> expire
gpg> key 1
gpg> expire
gpg> save
$ gpg --list-secret-keys
@sirodoht
sirodoht / longest_collatz_sequence.rs
Created January 31, 2018 09:30
Longest Collatz sequence solution, Project Euler #14
// Longest Collatz sequence
// https://projecteuler.net/problem=14
fn collatz(num: u32) -> u32 {
if num == 1 {
return num;
}
if num % 2 == 0 {
num / 2
@sirodoht
sirodoht / index.html
Last active May 13, 2020 18:16
Basic HTML/CSS boilerplate with Normalize.css
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello</title>
<link rel="stylesheet" href="main.css">
</head>
<body>