Skip to content

Instantly share code, notes, and snippets.

@drawks
drawks / graphite
Created February 14, 2012 21:24
Graphite on uwsgi/nginx
#This is the "site config" for nginx
upstream django {
# Distribute requests to servers based on client IP. This keeps load
# balancing fair but consistent per-client. In this instance we're
# only using one uWGSI worker anyway.
ip_hash;
server unix:/tmp/uwsgi.sock;
}
server {
@alotaiba
alotaiba / google_speech2text.md
Created February 3, 2012 13:20
Google Speech To Text API

Google Speech To Text API

Base URL: https://www.google.com/speech-api/v1/recognize
It accepts POST requests with voice file encoded in FLAC format, and query parameters for control.

Query Parameters

client
The client's name you're connecting from. For spoofing purposes, let's use chromium

lang
Speech language, for example, ar-QA for Qatari Arabic, or en-US for U.S. English

@mranney
mranney / emoji_sad.txt
Created January 30, 2012 23:05
Why we can't process Emoji anymore
From: Chris DeSalvo <chris.desalvo@voxer.com>
Subject: Why we can't process Emoji anymore
Date: Thu, 12 Jan 2012 18:49:20 -0800
Message-Id: <AE459007-DF2E-4E41-B7A4-FA5C2A83025F@voxer.com>
--Apple-Mail=_6DEAA046-886A-4A03-8508-6FD077D18F8B
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=utf-8
@jaigouk
jaigouk / eventmachine.rb
Created November 17, 2011 16:13 — forked from joshuasiler/eventmachine.rb
Initializer that allows EventMachine to run within Rails, and work with AMQP, Passenger, Thin and Capybara
require 'amqp'
module HiringThingEM
def self.start
if defined?(PhusionPassenger)
PhusionPassenger.on_event(:starting_worker_process) do |forked|
# for passenger, we need to avoid orphaned threads
if forked && EM.reactor_running?
EM.stop
end
Thread.new {
@bkimble
bkimble / gist:1365005
Last active May 2, 2024 01:27
List local memcached keys using Ruby
#!/usr/bin/env ruby
# List all keys stored in memcache.
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place.
require 'net/telnet'
headings = %w(id expires bytes cache_key)
rows = []
@flavianmissi
flavianmissi / django_update_view.py
Created October 10, 2011 12:37
Django UpdateView sample
#views.py
from django.views.generic import UpdateView
class UpdateBook(UpdateView):
model = Book
form_class = BookForm
template_name = 'create_form.html'
success_url = '/books/'
@cyberdelia
cyberdelia / mixin.py
Created September 21, 2011 08:26
Django class based view mixins
# -*- coding: utf-8 -*-
from django.contrib.auth.decorators import login_required
from django.utils.cache import patch_response_headers
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_page, never_cache
from django.views.decorators.csrf import csrf_exempt
class NeverCacheMixin(object):
@method_decorator(never_cache)
@stan
stan / 0_instructions.txt
Created May 19, 2011 02:25 — forked from sgruhier/0_instructions.txt
Sprocket 2 in Rails 3.0.x ala Rails 3.1
Some brief instructions on how to use Sprocket 2 in Rails to get CoffeeScript
powered JS and SASS powered CSS with YUI compression all via the magic of rack.
This stuff will be native in Rails 3.1 and the layout of the files on the
filesystem will be different but this guide will get you working with it
while we wait for all that to finalize.
Ignore the number prefixes on each file. This is just to ensure proper order in the Gist.
It's based on eric1234 gist https://gist.github.com/911003. ijust made it 3.1 compliant in terms of convention
@mikegehard
mikegehard / gist:954537
Created May 4, 2011 00:35
Waiting until all jquery ajax calls are done
//Useful if you have a slow CI server...
When /^I wait until all Ajax requests are complete$/ do
wait_until do
page.evaluate_script('$.active') == 0
end
end
@dryan
dryan / cron.py
Created September 6, 2009 18:59
Django script for backing up database to S3
from django.core.management import setup_environ
import settings
setup_environ(settings)
# database backup routine
def database_backup():
import tarfile,subprocess,tempfile,os,S3
from datetime import datetime