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 refrigerator.pp
service{"refrigerator":
ensure => running,
}
@kesor
kesor / Vagrantfile
Last active Aug 29, 2015
docker workshop
View Vagrantfile
ENV['VAGRANT_NO_PLUGINS'] = 'true'
Vagrant.configure("2") do |v|
v.vm.box = "yungsang/boot2docker"
v.vm.box_version = ">= 1.3.7"
v.vm.box_check_update = false
v.vm.network :forwarded_port, guest: 5000, host: 60050
v.vm.network :forwarded_port, guest: 8500, host: 60085
v.vm.network :forwarded_port, guest: 8080, host: 60080
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 / upload-certificate.sh
Last active Sep 9, 2015
Uploading ssl to AWS
View upload-certificate.sh
#!/bin/sh
cert_name="mycompany"
decrypted_rsa_key=$(mktemp `dirname $0`/${cert_name}-com-server-key-UNENCRYPTED.pem.XXXXXXX)
trap "rm -rf $decrypted_rsa_key" EXIT
openssl rsa -in ${cert_name}-com-server-key.pem -out $decrypted_rsa_key
# The certificate chain must start with the immediate signing certificate,
@kesor
kesor / gist:1029749
Created Jun 16, 2011
RSyslog <-> ElasticSearch LogStash events
We couldn’t find that file to show.
@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 / hostname_middleware.py
Created Apr 15, 2012
Django X-Host-Name + X-Host-IP +X-Host-MacAddress middleware
View hostname_middleware.py
class HostnameMiddleware(object):
"""Middleware that adds a header X-Hostname to erroneous pages."""
def process_response(self, request, response):
try:
if response.status_code != 200:
import socket
hostname = socket.gethostname()
addresses = ",".join( socket.gethostbyname_ex(hostname)[2] )
response['X-Host-Name'] = hostname
response['X-Host-IP'] = addresses
You can’t perform that action at this time.