Skip to content

Instantly share code, notes, and snippets.

View btbytes's full-sized avatar
🐎
🏈

Pradeep Gowda btbytes

🐎
🏈
View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SoundCloud OAuth 2 User Agent Authentication Flow Demo</title>
<script type="text/javascript" charset="utf-8" src="javascript/jquery-1.4.2.js"></script>
<script type="text/javascript" charset="utf-8">
$(function () {
var extractToken = function(hash) {
#!/usr/bin/perl -w
# vim:et:sw=4 ts=4
# servermenu_pl - an server menu example client for LCDproc
# Displays some server stats: mem, cpu, local time
# and offers the possibility to shutdown the machine via
# the buttons.
# Copyright GPL 2005, Guido Socher
use IO::Socket;
use Getopt::Std;
use Fcntl;
@swaroopch
swaroopch / flask-boilerplate-tmux.bash
Created December 5, 2010 07:00
A command that scripts a tmux session
#!/bin/bash
function flask-boilerplate-tmux
{
# https://github.com/swaroopch/flask-boilerplate
BASE="$HOME/code/flask-boilerplate"
cd $BASE
tmux start-server
tmux new-session -d -s flaskboilerplate -n model
@rlm
rlm / gist:746185
Created December 18, 2010 05:19
curry.clj
(ns sunil.curry)
(defn partial+
"Takes a function f and fewer than the normal arguments to f, and
returns a fn that takes a variable number of additional args. When
called, the returned function calls f with args + additional args.
differs from the core version in that it works on just one argument."
{:added "1.0"}
([f] f)
([f arg1]
@liamoc
liamoc / gist:762380
Created January 2, 2011 07:30
Creating Tables in C
#include <stdio.h>
/* BEGIN HACKERY */
typedef struct field {
enum {
TABLE_NAME,
TABLE_FIELD,
TABLE_TERMINATOR
} tag;
@btbytes
btbytes / siri_words.markdown
Created January 9, 2011 15:42
Siri Words

My 13 month old daughter Siri speaks these words, in three languages :

  • kn = Kannada (Pradeep's Mother tongue)
  • ko = Konkani (Nayan's Mother tongue)
  • en = English
  • ba = Baby talk

2011-01-09

@philikon
philikon / wtf8.py
Created February 8, 2011 08:22
WTF-8 codec for Python
# wtf8.py
import codecs
def encode(input, errors='strict'):
return input.encode('utf-8', errors).decode('latin-1', errors).encode('utf-8', errors), len(input)
def decode(input, errors='strict'):
return input.decode('utf-8', errors).encode('latin-1', errors).decode('utf-8', errors), len(input)
class StreamWriter(codecs.StreamWriter):
@fdmanana
fdmanana / gist:832610
Created February 17, 2011 20:27
The CouchDB replicator database

1. Introduction to the replicator database

A database where you PUT/POST documents to trigger replications and you DELETE to cancel ongoing replications. These documents have exactly the same content as the JSON objects we used to POST to /_replicate/ (fields "source", "target", "create_target", "continuous", "doc_ids", "filter", "query_params".

Replication documents can have a user defined "_id". Design documents (and _local documents) added to the replicator database are ignored.

The default name of this database is _replicator. The name can be changed in the .ini configuration, section [replicator], parameter db.

2. Basics

@btbytes
btbytes / kill_idle_pg.sh
Created April 6, 2011 14:17
Kill the oldest postgresql idle transaction if there are more than 5 such processes.
/usr/bin/test `/usr/bin/pgrep -f 'idle in transaction' | \
/usr/bin/wc \-l ` \-gt 5 && /usr/bin/pkill \-o \-f 'idle in transaction'
@mikeyk
mikeyk / redis_session_backend.py
Created April 8, 2011 18:01
A redis backend for Django Sessions, tested on Django 1.3+
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
from django.utils.encoding import force_unicode
import redis
class SessionStore(SessionBase):
""" Redis store for sessions"""
def __init__(self, session_key=None):
self.redis = redis.Redis(