Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# This script backs up files using restic and sends emails on success or errors.
#
# Files that the script expects:
# /usr/local/etc/restic/repo.env: shell variables that define the restic repository
# /usr/local/etc/restic/include.txt: paths to back up
# /usr/local/etc/restic/exclude.txt: paths to not include in the backup, even if they are in include.txt
#
# Inspired by https://gist.github.com/perfecto25/18abbd6cfbaa4e9eb30251470e9b7504
@haplo
haplo / kdeconnect
Created May 25, 2020 14:31
KDE Connect ufw application profile
; put in /etc/ufw/applications.d/kdeconnect
[kdeconnect]
title=KDE Connect
description=Remote smartphone control
ports=1714:1764/tcp|1714:1764/udp
@haplo
haplo / gist:b6b5b456227350d8a0d894c88eacec7e
Created September 24, 2017 15:14
Onename verification
Verifying that "fidelramos.id" is my Blockstack ID. https://onename.com/fidelramos
@haplo
haplo / keybase.md
Last active October 17, 2016 04:48

Keybase proof

I hereby claim:

  • I am haplo on github.
  • I am fidel (https://keybase.io/fidel) on keybase.
  • I have a public key whose fingerprint is 7977 CF4B DFCC 46B9 264A 3C2C 7F07 1B7C 479F EDD1

To claim this, I am signing this object:

@haplo
haplo / json_encoder.py
Created October 24, 2012 17:10
Custom JSONEncoder
from decimal import Decimal
try:
import simplejson as json
except ImportError:
import json
from django.utils.functional import Promise
class CustomJSONEncoder(json.JSONEncoder):
@haplo
haplo / admin.py
Created May 14, 2012 18:52
Blank admin filter for Django 1.4+.
from django.contrib import admin
class BlankFilter(admin.SimpleListFilter):
"""Abstract base class for filtering blank fields.
To use define a subclass that defines title and parameter_name fields:
class ConcreteBlankFilter(BlankFilter):
title = "some title"
@haplo
haplo / mp3_cbr_converter.sh
Created July 1, 2010 20:18
Transform mp3 files to CBR 128
#!/bin/bash
# This script converts all MP3 files in the current directory to a
# constant bitrate (128 in this case) using lame. I use this to make
# a more compact version of my music library to fit in a CD for my car.
#
# WARNING: search is recursive and files WILL BE OVERWRITTEN. You probably
# want to make a copy of the files to be converted.
#
# Notes:
# * id3 tags are lost when converting with lame.
@haplo
haplo / fabfile.py
Created June 10, 2010 12:30
Fabric deployment with virtualenv support in the server
"""
This fabfile deploys projects versioned in git and that use a virtualenv in the
remote server.
The deploy and deploy_version tasks are framework-independent.
The freshdb task is specific for Django projects.
The restart task is for projects deployed using FastCGI.
@haplo
haplo / .bashrc
Created March 12, 2010 11:47
Nice git prompt for bash
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo " ("$(parse_git_dirty)${ref#refs/heads/}")"
}
BLUE="\[\033[1;34m\]"
@haplo
haplo / natural key example
Created February 17, 2010 11:42
Example usage for Django's get_by_natural_key
from django.db import models
class AuthorManager(models.Manager):
    def get_by_natural_key(self, first_name, last_name)
        return self.get(first_name=first_name, last_name=last_name)
class Author(models.Model):
    first_name = models.CharField(max_length=50)
    last_name = models.CharField(max_length=50)