Skip to content

Instantly share code, notes, and snippets.

View matteomallus's full-sized avatar

Matteo Mallus matteomallus

  • Cagliari (Italy)
View GitHub Profile
import hashlib
from functools import wraps
from django.core.cache import cache
from django.utils.encoding import force_text, force_bytes
def cache_memoize(
timeout,
prefix='',
@heskyji
heskyji / hmac_sha1.py
Created September 17, 2015 01:08
Generate HMAC-SHA1 Signature using Python 3
import hashlib
import hmac
import base64
def make_digest(message, key):
key = bytes(key, 'UTF-8')
message = bytes(message, 'UTF-8')
@miromannino
miromannino / service.md
Last active May 7, 2024 14:28 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debian/ubuntu

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name
@digitaljhelms
digitaljhelms / post-rewrite
Created September 22, 2014 14:49
Git hook to call `git submodule update` automatically.
#!/bin/sh
echo "[post-rewrite hook: $1]"
# quick script to call "git submodule update" automatically if the
# .gitmodules file is changed
changedfiles=( `git diff-tree --no-commit-id --name-only HEAD@{1} HEAD` )
if [[ "${changedfiles[*]}" =~ ".gitmodules" ]]; then
echo "initializing & updating submodule(s)"