Skip to content

Instantly share code, notes, and snippets.

View matagus's full-sized avatar
🐿️
I miss the old Github activity stream

Matías Agustín Méndez matagus

🐿️
I miss the old Github activity stream
View GitHub Profile
@matagus
matagus / django-exceptions-tracedump.txt
Created December 15, 2011 02:58
How to analyze rare exceptions in django/python projects by G. Dumpleton
from: http://groups.google.com/group/modwsgi/browse_thread/thread/f289c8167923aab7
The problem with Django is that there are certain circumstances where
it will hide the actual error message and traceback and replace it
will a higher level exception, but with the traceback then being where
that higher level exception was raised. This is one such case.
To try and find the real location of the exception add the following
to your WSGI script file.
@matagus
matagus / example.py
Created July 11, 2012 15:15
django transactions
from django.db import transaction
def manual_rollback():
"""Create and rollback using manual transaction calls"""
transaction.enter_transaction_management()
transaction.managed()
try:
try:
create()
error()
@matagus
matagus / SourceCodeSearchEngines.md
Created October 7, 2015 09:39 — forked from phillipalexander/SourceCodeSearchEngines.md
Source Code Search Engines You Can Use For Programming Projects

Source Code Search Engines

NOTE: This list is almost entirely copy/pasted from THIS awesome article. I've made my own personal edits (adding some additional content) which is why I keep it here.

Every day meanpath crawls over 200 million websites capturing the visible text, HTML source code, CSS and Javascript. This information is used by many companies to monitor the growth of web facing technology.

@matagus
matagus / newrelic_exception.py
Created July 19, 2012 20:14
recording exception to New Relic using python agent
import sys
import newrelic.agent
try:
# ...
# some code
# ...
except Exception as e:
git branch --merged origin/master | grep -v '\* master' | xargs -l1 git branch -d
@matagus
matagus / postactivate
Created January 24, 2013 18:22
Post activate hook for virtualenvwrapper for loading env variables /paht/to/your/virtualenvs/postactivate
#!/bin/bash
# This hook is run after every virtualenv is activated.
envname="$(basename $VIRTUAL_ENV)"
if [ -e ".env" ]
then
source .env
fi
from django.contrib import admin
from django.contrib.admin import SimpleListFilter
from django.utils.translation import ugettext_lazy as _
from object_images.models import ObjectImage
class ObjectImagesListFilter(SimpleListFilter):
title = _("object images")
parameter_name = "images"
* If you don’t care about the results of a task, be sure to set the ignore_result option, as storing results wastes time and resources:
@celery.task(ignore_result=True)
def mytask(...)
something()
Results can even be disabled globally using the CELERY_IGNORE_RESULT setting.
* Or instead of routing it you could rate limit the task instead, so that only 10 tasks of this type can be processed in a minute (10/m):
Spanish
Portuguese
English
Norwegian
Hungarian
Danish
Finish
French
Italian
Dutch
server {
server_name www.sarasa.com sarasa.com;
if ($host != 'sarasa.com' ) {
rewrite ^/(.*)$ http://sarasa.com/$1 permanent;
}
# Serve an empty 1x1 gif _OR_ an error 204 (No Content) for favicon.ico
location = /favicon.ico {
empty_gif;