Skip to content

Instantly share code, notes, and snippets.

Evgeny Zislis kesor

Block or report user

Report or block kesor

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:11682
#!/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 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 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 Jun 16, 2011
RSyslog <-> ElasticSearch LogStash events
We couldn’t find that file to show.
@kesor
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
kesor / profile_middleware.py
Last active May 2, 2017
Django cProfile middleware
View profile_middleware.py
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 Sep 20, 2011
Django SQL dump middleware
View sqldump_middleware.py
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
View django_jinja2_loader.py
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 Oct 3, 2011
Caching for GenericRelation models in Django
View django_generic_relation_caching.py
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 Jan 10, 2012
Django MongoDB + SQL dump middleware
View sql_mongodb_dump_middleware.py
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 Mar 13, 2012
Making Amazon AWS API Queries
View LICENSE
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,
You can’t perform that action at this time.