Skip to content

Instantly share code, notes, and snippets.

/*
Implements different bin packer algorithms that use the MAXRECTS data structure.
See http://clb.demon.fi/projects/even-more-rectangle-bin-packing
Author: Jukka Jylänki
- Original
Author: Claus Wahlers
- Ported to ActionScript3
from babel import support
def man_gettext(string, domain, **variables):
translations = support.Translations.load(os.path.join(www.root_path, 'translations'))
return translations.dgettext(domain, string) % variables
def man_lazy_gettext(string, domain, **variables):
from speaklater import make_lazy_string
return make_lazy_string(man_gettext, string, domain, **variables)
{
"_links": {
"self": { "href": "/foo" },
},
"_controls": {
"attack": {
"target": "/attacks",
"method": "POST",
"headers": {
"Content-Type": "application/json"
@josegonzalez
josegonzalez / access.lua
Created December 3, 2012 18:26
Simple lua file enabling oauth support for nginx via nginx-lua and access_by_lua.
- certain endpoints are always blocked
if nginx_uri == "/_access_token" or nginx_uri == "/_me" then
ngx.exit(403)
end
-- import requirements
local cjson = require "cjson"
-- setup some app-level vars
local app_id = "APP_ID"
import sqlalchemy
from sqlalchemy import *
from sqlalchemy.ext.mutable import Mutable
class JSONEncodedObj(types.TypeDecorator):
"""Represents an immutable structure as a json-encoded string."""
impl = String
def process_bind_param(self, value, dialect):
@hbokh
hbokh / gist:33d9ff5d87e433410e77
Created May 6, 2014 12:25
Logstash, collectd and kibana for one host's system resources
{
"title": "System Resources",
"services": {
"query": {
"list": {
"0": {
"query": "collectd_type:\"load\"",
"alias": "Load",
"color": "#70DBED",
"id": 0,
@lewisd32
lewisd32 / iptableflip.sh
Created April 15, 2015 18:20
Snippet of Unbounce script for restarting HAProxy with zero downtime
echo "Flipping tables! (╯°□°)╯︵ ┻━┻"
num_rules=3
real=3 # exposed to the ELB as port 443
test=4 # used to install test certs for domain verification
health=5 # used by the ELB healthcheck
blue_prefix=855
green_prefix=866