Skip to content

Instantly share code, notes, and snippets.

@mcastilho
mcastilho / Makefile
Last active November 11, 2022 14:59
Makefile for Medium article
.PHONY: all tags clean test build install generate image release
REGISTRY_REPO = <..redacted..>
OK_COLOR=\033[32;01m
NO_COLOR=\033[0m
ERROR_COLOR=\033[31;01m
WARN_COLOR=\033[33;01m
# Build Flags
package main
import (
"net/http"
"database/sql"
"fmt"
"log"
"os"
)
@yml
yml / tasks.py
Created July 26, 2012 13:17
Background tasks to be run either by uwsgi, or directly if on dev server.
"""Background tasks to be run either by uwsgi, or directly if on dev server.
"""
import cPickle as pickle
import logging
from django.core.mail import send_mail
LOG = logging.getLogger(__name__)
HAS_UWSGI = False
@evildmp
evildmp / gist:1328038
Created October 31, 2011 17:14
Attempt to understand the menu system
=========================
How the menu system works
=========================
Basic concepts
==============
Registration
------------
@gcollazo
gcollazo / Backbone.sync_csrftoken.js
Created September 25, 2011 14:56
This is what I did to insert the CSRF token in backbone requests. This works with django.
var oldSync = Backbone.sync;
Backbone.sync = function(method, model, options){
options.beforeSend = function(xhr){
xhr.setRequestHeader('X-CSRFToken', CSRF_TOKEN);
};
return oldSync(method, model, options);
};
@diox
diox / clear_johnny_cache.py
Created July 5, 2011 16:30
Django management command to clear johnny-cache cache :-)
import sys
import logging
from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
class Command(BaseCommand):
help = ("Invalidates portions of the queryset cache based on the app names"
" or models provided as arguments to the command. If no arguments "
"are provided, nothing is done. To clear the entire queryset "