Skip to content

Instantly share code, notes, and snippets.

View gist:11682
# Cleanup World of Warcraft AddOns folder from embedded libraries,
# only if those are installed individually or as part of a library pack (eg. Ace3)
# Usual dir on a Mac OS X is at :
# ~/Applications/World of Warcraft/Interface/AddOns
# Useful shell alias
kesor / rails_vendor_gems_ng.rb
Created Dec 29, 2008
handle vendor/gems in rails 2.2 as a dir for gems, not foreign alien shit that it is today
View rails_vendor_gems_ng.rb
# see mail reply in
# with explanation about how/why this works better than rails 2.2
module Rails
class VendorGemSourceIndex
def gemspec_filename(d)
kesor / gist:1029749
Created Jun 16, 2011
RSyslog <-> ElasticSearch LogStash events
We couldn’t find that file to show.
kesor / gist:1179782
Created Aug 30, 2011
Google AppEngine URLFetch in Unit Tests
View gist:1179782
from google.appengine.api import apiproxy_stub
from google.appengine.api import apiproxy_stub_map
class FetchServiceMock(apiproxy_stub.APIProxyStub):
def __init__(self, service_name='urlfetch'):
super(FetchServiceMock, self).__init__(service_name)
def set_return_values(self, **kwargs):
self.return_values = kwargs
kesor /
Last active Mar 16, 2021
Django cProfile middleware
from django.core.exceptions import MiddlewareNotUsed
from django.conf import settings
import cProfile
import pstats
import marshal
from cStringIO import StringIO
class ProfileMiddleware(object):
def __init__(self):
if not settings.DEBUG:
kesor /
Created Sep 20, 2011
Django SQL dump middleware
from django.conf import settings
from django.db import connection
class SqldumpMiddleware(object):
def process_response(self, request, response):
if settings.DEBUG and 'sqldump' in request.GET:
response.content = str(connection.queries)
response['Content-Type'] = 'text/plain'
return response
import jinja2
from django.template.loader import BaseLoader
from django.template.loaders.app_directories import app_template_dirs
from django.template import TemplateDoesNotExist, Origin
from django.core import urlresolvers
from django.conf import settings
import datetime
import urllib
from django.utils.timesince import timesince, timeuntil
kesor /
Created Oct 3, 2011
Caching for GenericRelation models in Django
from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
from django.core.cache import cache
from django.dispatch import receiver
class LabelsManager(models.Manager):
""" The manager for Label/s, as well as superclass of the RelatedManager/s of Label/s """
def all(self):
kesor /
Created Jan 10, 2012
Django MongoDB + SQL dump middleware
from django.core.exceptions import MiddlewareNotUsed
from django.conf import settings
from django.db import connection
from pymongo.connection import Connection
from time import time
import struct
import bson
from bson.errors import InvalidBSON
class SqldumpMiddleware(object):
kesor / LICENSE
Created Mar 13, 2012
Making Amazon AWS API Queries
Copyright (c) 2013, Evgeny Zislis
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,