Skip to content

Instantly share code, notes, and snippets.

@clooth
clooth / .bash_profile
Created August 10, 2012 19:35
My .bashrc prompt with rvm and git branch
# Colors
declare -A Colors
Colors[black]="\[\033[0;30m\]"
Colors[red]="\[\033[0;31m\]"
Colors[green]="\[\033[0;32m\]"
Colors[yellow]="\[\033[0;33m\]"
Colors[blue]="\[\033[0;34m\]"
Colors[magenta]="\[\033[0;35m\]"
Colors[cyan]="\[\033[0;36m\]"
Colors[white]="\[\033[0;37m\]"
@clooth
clooth / common_extras.py
Created August 14, 2012 21:26
Grid templatetags
from django import template
register = template.Library()
class GridViewNode(template.Node):
def __init__(self, item_template_name, objects_list):
self.item_template_name = item_template_name
self.objects_list = template.Variable(objects_list)
self.grid_template = template.loader.get_template('common/grid/grid-view.html')
@clooth
clooth / json_extras.py
Created August 14, 2012 22:03
Django json templatetag
from django.template import Library
from django.core.serializers import serialize
from django.core.serializers.json import DjangoJSONEncoder
from django.utils import simplejson
from django.utils.safestring import mark_safe
register = Library()
@register.filter
@clooth
clooth / places.json
Created August 15, 2012 10:09
PK-seudun baarit
[{"phonenumber": "(09) 7533 100", "name": "3. linja", "address": "Kolmas linja 6", "latitude": 60.1817299628, "tags": ["olutravintola"], "homepage": "", "longitude": 24.9509723639, "description": "Minikokoinen kivijalkapubi 3:nnella linjalla, jota Fredikin kulki takaisin. Baarissa kaksi televisiota. Halpa tuoppi."}, {"phonenumber": "(09) 343 2814", "name": "4 Vuodenaikaa", "address": "Rusthollarintie 2", "latitude": 60.2122766079, "tags": [""], "homepage": "", "longitude": 25.0960335589, "description": ""}, {"phonenumber": "0400 211 921", "name": "A21", "address": "Annankatu 21", "latitude": 60.1662143231, "tags": ["cocktail", "drinkkej\u00e4", "drinkkibaari", "juhlapaikka", "kokoustila"], "homepage": "http://www.a21.fi/", "longitude": 24.9378044239, "description": "Cocktail Lounge A21 keskittyy hyviin drinkkeihin eli ns. \"Fine Drinkingiin\". Cocktail-lista on jaettu nelj\u00e4\u00e4n kategoriaan, joiden kautta cocktailien laaja kirjo aukeaa maallikollekin. Tarjolla on makuja suomalaisesta luonnosta, kauden
@clooth
clooth / widgets.py
Created August 15, 2012 20:34
GoogleMapsWidget
from django import forms
from django.conf import settings
from django.utils.safestring import mark_safe
class GoogleMapsWidget(forms.HiddenInput):
# Media to be includes with the widget
class Media:
js = (
latitude = forms.CharField(widget=GoogleMapsWidget(attrs={'map_width': 640, 'map_height': 480, 'longitude_id': 'id_longitude'}),
error_messages={'required': 'Please select a location on the map.'},
label='Location'
)
longitude = forms.CharField(widget=forms.HiddenInput())
class GridBounds
constructor: (bounds) ->
this.minX = Math.min(bounds[0].x, bounds[1].x)
this.maxX = Math.max(bounds[0].x, bounds[1].x)
this.minY = Math.min(bounds[0].y, bounds[1].y)
this.maxY = Math.min(bounds[0].y, bounds[1].y)
# Process all markers in the bounds provided, using a callback
processAll: (bounds, callback) ->
for x in [bounds.minX..bounds.maxX]
for y in [bounds.minY..bounds.minX]
"foo"
processAll = function(bounds, callback) {
var x, y, _i, _ref, _ref1, _results;
_results = [];
# Process all markers in the bounds provided, using a callback
processAll: (bounds, callback) ->
for x in [bounds.minX..bounds.maxX]
for y in [bounds.minY..bounds.minX]
"foo"
processAll = function(bounds, callback) {
var x, y, _i, _j, _ref, _ref1, _ref2, _ref3;
for (x = _i = _ref = bounds.minX, _ref1 = bounds.maxX; _ref <= _ref1 ? _i <= _ref1 : _i >= _ref1; x = _ref <= _ref1 ? ++_i : --_i) {
# Process all markers in the bounds provided, using a callback
processAll: (bounds, callback) ->
for x in [bounds.minX..bounds.maxX]
for y in [bounds.minY..bounds.minX]
"foo"
@
processAll = function(bounds, callback) {
var x, y, _i, _j, _ref, _ref1, _ref2, _ref3;