Skip to content

Instantly share code, notes, and snippets.

RATE_LIMIT_SCRIPT = r'''
local now = tonumber(ARGV[1])
local required = tonumber(ARGV[2])
local rate = tonumber(ARGV[3])
local per_secs = tonumber(ARGV[4])
local do_subtract = tonumber(ARGV[5]) == 1
local full_at = tonumber(redis.call('GET', KEYS[1])) or 0
local score, result
if full_at < now then
score = rate
import re
from jinja2 import Markup
from SOMEOTHERLIBRARYFOROTHERSTUFF import format_user_input
def strip_auth_tokens(value):
from classlet.models import auth_token_re
return auth_token_re.sub(u'', value)
@tarcieri
tarcieri / warbird.rb
Created January 3, 2012 22:49
Playing around with @j_brisbin's Disruptor web server idea in JRuby
# Requires Java! OH NO!
require 'java'
require 'disruptor' # you'll need to snag disruptor.jar
module Warbird
class Worker
include com.lmax.disruptor.WorkHandler
java_import 'java.nio.ByteBuffer'
def initialize(ring_buffer)
@bbeck
bbeck / Thread Dump
Created June 26, 2012 03:28
Asgard Issues
Debugger attached successfully.
Server compiler detected.
JVM version is 20.0-b12
Deadlock Detection:
No deadlocks found.
Thread 10819: (state = BLOCKED)
- java.lang.Thread.sleep(long) @bci=0 (Interpreted frame)
- com.amazonaws.http.IdleConnectionReaper.run() @bci=3, line=75 (Interpreted frame)
@coryalder
coryalder / fb_open_source_ios
Created August 23, 2012 20:10
Open source libraries used in the new Facebook app.
Appirater
AQGridView
AutoHyperlinks
Boost
Chromium
CocoaLumberjack
CoreTextHyperlinkView
EGODatabase
EGOTableViewPullRefresh
HPGrowingTextView
@leandrosilva
leandrosilva / klogd.py
Created September 6, 2012 20:12
My dumb Python script to stream Syslog messages to a Kafka server
# ==========================
# Getting Started with klogd
# ==========================
#
# Klogd is a dumb script to stream Syslog messages to a Kafka server.
#
# 1) Make sure you have all dependencies installed properly
#
# - Twisted
# - PyParsing
@n0ts
n0ts / gist:3810200
Created October 1, 2012 08:01
keepalived supervisor.conf
[program:keepalived-check]
command=/usr/sbin/keepalived
--use-file /etc/keepalived/keepalived.conf
--dont-fork
--dump-conf
--log-detail
--log-facility 0
--check
--pid /var/run/keepalived_check.pid
redirect_stderr=true
require 'rubygems'
require 'railsless-deploy'
# Your application name
set :application, "someapp"
# We're not deploying from a repo, since this is scala and we
# need to compile. Set SCM to none
set :scm, :none
# Our deploy is to copy the contents of…
@ewalk153
ewalk153 / upgrade_postgres.bash
Created January 3, 2014 03:32
upgrade heroku postgres from crane to yanari
# this can be done anytime
heroku addons:add heroku-postgresql:standard-yanari --app nav-chronos; heroku pg:wait
# about 3m30s
heroku maintenance:on
heroku ps:scale worker=0
heroku pgbackups:capture --expire
# less than 20 min
@DTrejo
DTrejo / top3stories.js
Created January 21, 2011 22:41
Gets top three articles from frontpage and newpage of Hacker News. Blog post on scraping: http://blog.dtrejo.com/scraping-made-easy-with-jquery-and-selectorga
// Scraping Made Easy with jQuery and SelectorGadget
// (http://blog.dtrejo.com/scraping-made-easy-with-jquery-and-selectorga)
// by David Trejo
//
// Install node.js and npm:
// http://joyeur.com/2010/12/10/installing-node-and-npm/
// Then run
// npm install jsdom jquery http-agent
// node numresults.js
//