Skip to content

Instantly share code, notes, and snippets.

View kesor's full-sized avatar
🏠
Working from home

Evgeny Zislis kesor

🏠
Working from home
View GitHub Profile
#!/bin/sh
#
# 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
kesor / rails_vendor_gems_ng.rb
Created December 29, 2008 20:45
handle vendor/gems in rails 2.2 as a dir for gems, not foreign alien shit that it is today
# see mail reply in http://groups.google.com/group/haml/msg/12f63d9dff34a1d5
# with explanation about how/why this works better than rails 2.2
module Rails
class VendorGemSourceIndex
def gemspec_filename(d)
File.join(d,"#{File.basename(d)}.gemspec")
end
@kesor
kesor / gist:1029749
Created June 16, 2011 17:27
RSyslog <-> ElasticSearch LogStash events
We couldn’t find that file to show.
@kesor
kesor / gist:1179782
Created August 30, 2011 00:27
Google AppEngine URLFetch in Unit Tests
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
kesor / profile_middleware.py
Last active March 16, 2021 15:37
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
kesor / sqldump_middleware.py
Created September 20, 2011 17:12
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
@kesor
kesor / django_jinja2_loader.py
Created September 28, 2011 11:47
Django Jinja2 Loader
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
kesor / django_generic_relation_caching.py
Created October 3, 2011 19:45
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
kesor / sql_mongodb_dump_middleware.py
Created January 10, 2012 15:38
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
kesor / LICENSE
Created March 13, 2012 15:15
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,