Skip to content

Instantly share code, notes, and snippets.

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 / 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
@kesor
kesor / jQuery_each_slice.js
Created May 6, 2012
jQuery Each Slice loop
View jQuery_each_slice.js
/* definition */
(function($){
$.fn.each_slice = function( iterator ) {
var index, objects;
objects = this;
for (index=0; index<=objects.length-1; index++) {
var single = objects.slice(index, index+1);
this = single;
iterator(single);
}