Skip to content

Instantly share code, notes, and snippets.

code for food

Gianluca Pacchiella gipi

code for food
View GitHub Profile
renchap /
Last active Jan 1, 2021
One-line certificate generation/renews with Letsencrypt and nginx

Prerequisites : the letsencrypt CLI tool

This method allows your to generate and renew your Lets Encrypt certificates with 1 command. This is easily automatable to renew each 60 days, as advised.

You need nginx to answer on port 80 on all the domains you want a certificate for. Then you need to serve the challenge used by letsencrypt on /.well-known/acme-challenge. Then we invoke the letsencrypt command, telling the tool to write the challenge files in the directory we used as a root in the nginx configuration.

I redirect all HTTP requests on HTTPS, so my nginx config looks like :

server {
maurisvh /
Last active Jun 15, 2020
ANSI art spectrogram viewer that reads audio from a microphone
import numpy
import pyaudio
import re
import sys
WIDTH = 79
BOOST = 1.0
AGWA / cook_rsa_key.go
Last active Oct 11, 2018
Demonstrates that an RSA signature does not uniquely identify a public key.
View cook_rsa_key.go
* Demonstrates that an RSA signature does not uniquely identify a public key.
* Given a signature, s, and a message m, it's possible to construct a new RSA key
* pair such that s is a valid signature for m under the new key pair.
* Requires Go version >= 1.5. Go <= 1.4 doesn't work due to a bug in the bignum
* package:
* Written in 2015 by Andrew Ayer <>
rupey / mandelbrot.sql
Last active Dec 7, 2020
Mandelbrot plot in postgres
View mandelbrot.sql
x(i) AS ( VALUES (0)
WHERE i < 101),
Z(Ix, Iy, Cx, Cy, X, Y, I) AS (
bnagy /
Last active Dec 29, 2020
Mutt, Gmail and GPG

GPG / Mutt / Gmail


This is a collection of snippets, not a comprehensive guide. I suggest you start with Operational PGP.

Here is an incomplete list of things that are different from other approaches:

  • I don't use keyservers. Ever.
  • Yes, I use Gmail instead of some bespoke hipster freedom service
public class ShadowLayout extends FrameLayout implements ViewGroup.OnHierarchyChangeListener {
private int mBackgroundColor;
private int mShadowColor;
private float mShadowRadius;
private float mCornerRadius;
private float mDx;
private float mDy;
private Paint mPaint;
Takhion /
Last active Jul 10, 2020
Collection of methods to achieve better circular arc drawing, as Canvas.drawArc() is unreliable. See the related article:
* Copyright (c) 2014 BioWink GmbH.
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is

Workflows (States) in Django

I'm going to cover a simple, but effective, utility for managing state and transitions (aka workflow). We often need to store the state (status) of a model and it should only be in one state at a time.

Common Software Uses

  • Publishing (Draft->Approved->Published->Expired->Deleted)
nuxlli /
Last active Mar 3, 2021
Examples of http request (in unix domain socket) with bash and [nc|socat]
# References
magopian /
Created Nov 19, 2013
Django admin command to "fix permissions" (create them properly for proxy models). This is needed because of the following bug in Django (not fixed as of 1.6):
# -*- coding: utf-8 -*-
"""Add permissions for proxy model.
This is needed because of the bug
in Django (as of 1.6, it's not fixed).
When a permission is created for a proxy model, it actually creates if for it's
base model app_label (eg: for "article" instead of "about", for the About proxy