Skip to content

Instantly share code, notes, and snippets.

@sebleier
sebleier / gist:1473587
Created December 13, 2011 19:49
Big-Q notation

Big-Q Notation

Big-Q notation is exactly the same as Big-O notation, except for the understanding that the constant multiplier for the asymptotic bound function is greater.

For example Big-O is defined as:

f(x) <= C * g(x) 

Big-Q notation could be defined as:

@theophani
theophani / gist:2250859
Created March 30, 2012 11:14
Y U NO RESIZE? bookmarklet
// put this in a bookmarklet
// click it as required
javascript: (function () {
var style = document.createElement('style');
style.innerHTML = '* { -webkit-text-size-adjust:auto; }';
document.head.appendChild(style);
})();
@mjtamlyn
mjtamlyn / gist:2897920
Created June 8, 2012 20:10
App-loading in django

Application loading refactor

At present application loading is handled in different ways through Django. Because of some of the limitations of Python, and some peculiarities of how models work, modules should not be reimported. Consequently Django maintains a global static, called the application cache. Models are imported from the application cache transparently when interacting with the database. But applications listed in INSTALLED_APPS contain more than just models. Some contain template tags, admin.py files, search_indexes.py files from

@idan
idan / customstorages.py
Created November 3, 2012 20:15
Protocol-Relative S3BotoStorage for django-storages
from urlparse import urlsplit, urlunsplit
from storages.backends.s3boto import S3BotoStorage
class ProtocolRelativeS3BotoStorage(S3BotoStorage):
"""Extends S3BotoStorage to return protocol-relative URLs
See: http://paulirish.com/2010/the-protocol-relative-url/
"""
@harrisj
harrisj / meter.rb
Created April 3, 2013 14:47
Some sample code for the term logic in the haiku finder
So, basically, scanning a sentence becomes like this:
1. Split the sentence into words
2. For each word, create a cleaned version (basically strip off quotes and punctuation) and look up in the dictionary.
3. If not found, try a few fallbacks based on stemmming rules or such
4. Otherwise, add the word to a term_misses table.
These code is really ugly (sorry!), and you might notice I actually am talking about meter in it. This is because the background image for the haikus is generated from the meter. But I don't want to do the meter for new words (sorry, syllable is enough), so for those I just return - as the meter (otherwise it's a combination of 1 or 0)
HAIKU (11000 1010011 11110)
@idan
idan / Default (OSX).sublime-keymap
Created October 27, 2011 17:51
Sublime Text asymmetric layout - place files in Packages/User
[
{
"keys": ["super+alt+shift+5"],
"command": "set_layout",
"caption" : "1-2 Grid",
"args":
{
"cols": [0.0, 0.5, 1.0],
"rows": [0.0, 0.5, 1.0],
"cells":
/*
A simple new-line delimited JSON protocol with upgrades.
Receiving Usage:
protocol = require('./frame-protocol');
// parsing data
parser = protocol.Parser();
@marcionicolau
marcionicolau / pg_postgis_20_92.sh
Last active November 7, 2017 06:59 — forked from rolo/gist:1481128
Install Postgis-2.0 to PostgreSQL 9.2 Server on Ubuntu 12.04 Server
#!/bin/bash
#
# Install Postgres 9.2, PostGIS and create PostGIS template on an Ubuntu 12.04 Server
# add official postgresql.org ubuntu repos (http://wiki.postgresql.org/wiki/Apt)
# Create /etc/apt/sources.list.d/pgdg.list. The distributions are called codename-pgdg.
echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg2.list
# Import the repository key from http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc, update the package lists, and start installing packages:
@unixmonkey
unixmonkey / Cucumber Plain Text Feature.tmLanguage
Created March 10, 2011 20:15
Cucumber Language definition file for TextMate; modified to work with Sublime Text 2
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>feature</string>
</array>
<key>firstLineMatch</key>
<string>기능|機能|功能|フィーチャ|خاصية|תכונה|Функціонал|Функционалност|Функционал|Особина|Могућност|Özellik|Właściwość|Tính năng|Savybė|Požiadavka|Požadavek|Osobina|Ominaisuus|Omadus|OH HAI|Mogućnost|Mogucnost|Jellemző|Fīča|Funzionalità|Funktionalität|Funkcionalnost|Funkcionalitāte|Funcționalitate|Functionaliteit|Functionalitate|Funcionalitat|Funcionalidade|Fonctionnalité|Fitur|Feature|Egenskap|Egenskab|Crikey|Característica|Arwedd(.*)</string>
@imlucas
imlucas / add_users.py
Created April 12, 2012 12:58
Using Amazon Cloudsearch with Python and Boto
from cloudsearch import connect_cloudsearch, get_document_service
endpoint = 'paste your doc service endpoint here'
service = get_document_service(endpoint=endpoint) # Get a new instance of cloudsearch.DocumentServiceConnection
# Presumably get some users from your db of choice.
users = [
{
'id': 1,