Skip to content

Instantly share code, notes, and snippets.

View BigBlueHat's full-sized avatar
🎩
building Web things

BigBlueHat BigBlueHat

🎩
building Web things
View GitHub Profile
@mnot
mnot / link_header.py
Created October 15, 2009 00:41
link_header.py: HTTP Link header parsing
@WorldMaker
WorldMaker / celtx2renpy.py
Created March 31, 2010 23:27
Celtx to Ren'Py Script
#!/usr/bin/python
# Celtx HTML Film Script to Ren'Py Script Tool (Based on KeyLimePie tools)
# Copyright 2010 Max Battcher. Some Rights Reserved.
# Licensed for use under the Ms-PL.
from BeautifulSoup import BeautifulSoup, Tag
import logging
def tagtext(contents):
def txt(thing):
if isinstance(thing, Tag):
@eligrey
eligrey / object-watch.js
Created April 30, 2010 01:38
object.watch polyfill in ES5
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
//Changes filter: "conflicts": "function(doc, req) { if(doc._conflicts) { return true; } else { return false; }}"
var dbase = 'focus';
var ddoc = 'app';
var sys = require('sys'),
couchdb = require('node-couchdb/lib/couchdb'),
client = couchdb.createClient(5984, 'crate.im'),
db = client.db(dbase),
changes = db.changesStream({filter: ddoc + '/conflicts'});
@agaoglu
agaoglu / USAGE.md
Created October 7, 2010 15:29
Simple CRUD function for couchapps

CRUD requires jquery.deepjson.js to work so it should be included

<script type="text/javascript" src="js/jquery.deepjson.js"></script>

Then you can assign whatever's in crud.json to a variable or you can put crud.json into your evently directory and let couchapp push it to your application.

Simplest way to use it is

@faried
faried / maildirtocouch.py
Created February 1, 2011 22:02
Store messages in a Maildir into a couchdb database.
#!/usr/bin/env python
"""Store messages in a Maildir into a couchdb database."""
import couchdb
from mailbox import Maildir
from optparse import OptionParser
import os
from pprint import pprint
import sys
from uuid import uuid4
RDBMS schema safety tips & common practices...
- define primary keys, even if artificial
- normalize your schema, and denormalize carefully
- use indexes judiciously
- distributed 2PC is a tool best left in the toolbox
- __many more known relational schema and modeling tips & tricks go here, but too lazy to type__
Document database / couchdb "schema" safety tips & common practices...
@esperlu
esperlu / mysql2sqlite.sh
Created April 27, 2011 05:46
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
@mbox
mbox / Dualcache
Last active September 3, 2019 16:14
Two-level cache for Django
To use the two-layer cache:
* Run memcached on each Django webserver
* Add "LOCAL_CACHE_ADDR = ('127.0.0.1:11211',)" to settings.py
* Replace "from django.core.cache import cache" with "from dualcache import cache" everywhere
you want to use the two-layer cache. It can be freely mix and matched with Django's default caching.
@jchris
jchris / jquery.couchLogin.js
Created May 9, 2011 22:48
jQuery plugin for CouchDB login/signup/logout in 80 lines (2kb minified)
// Copyright Chris Anderson 2011
// Apache 2.0 License
// jquery.couchLogin.js requires jquery.couch.js
//
// Example Usage (loggedIn and loggedOut callbacks are optional):
// $("#mylogindiv").couchLogin({
// loggedIn : function(userCtx) {
// alert("hello "+userCtx.name);
// },
// loggedOut : function() {