This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import logging as mod_logging | |
import cartesius.main as mod_cartesius | |
import cartesius.charts as mod_charts | |
import cartesius.colors as mod_colors | |
import srtm as mod_srtm | |
import gpxpy.geo as mod_geo | |
mod_logging.basicConfig(level=mod_logging.DEBUG, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80> | |
ServerName mysite.com | |
#ServerAlias ... | |
ServerAdmin webmaster@mysite.com | |
DocumentRoot .../projects/mysite | |
#Alias /robots.txt .../projects/qreminder-on-email/static/robots.txt | |
#Alias /favicon.ico .../projects/qreminder-on-email/static/favicon.ico |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dummy model: | |
class DbCounter(models.Model): | |
count = models.IntegerField() | |
def get_count(table, where): | |
# Check strings for sql injections here before doing this! | |
return DbCounter.objects.raw('select 1 as id, count(*) as count from %s where %s' % (table, where))[0].count | |
# View: | |
def index(request): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import unicodedata as mod_unicodedata | |
all_unicode = ''.join(unichr(i) for i in xrange(65536)) | |
UNICODE_LETTERS = ''.join(c for c in all_unicode if mod_unicodedata.category(c)=='Lu' or mod_unicodedata.category(c)=='Ll') | |
UNICODE_LETTERS_AND_NUMBERS = '1234567890' + UNICODE_LETTERS | |
def extract_unicode_words(text, allowed_chars=None): | |
if text.__class__ != unicode: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import textwrap as mod_textwrap | |
import django.db.models.fields as mod_fields | |
def wordwrap_fields(model): | |
""" | |
When models are not created through forms (so standard form validation didn't prevent | |
too long strings), this can be used to automatically wordwrap. | |
""" | |
for field in model._meta.fields: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import logging.handlers | |
import os.path as path | |
def setup_logging(file_name, log_directory=None, stream=None, max_bytes=None, | |
backup_count=None): | |
""" | |
Log directory may be a file in that directory. | |
""" | |
f = logging.Formatter(fmt='%(levelname)s:%(name)s: %(message)s ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/xml" | |
"fmt" | |
"os" | |
) | |
func main() { | |
f, _ := os.Open("test_files/gpx1.1_with_all_fields.gpx") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(!window.assert) { | |
window.assert = function() { | |
if(!arguments.length || arguments < 2) { | |
alert('Invalid assert, use assert(expression, message1, message2, ...)') | |
return | |
} | |
var expression = arguments[0] | |
if(!expression) { | |
var message = '' | |
for(i = 1; i < arguments.length; i++) message += ' ' + arguments[i] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map.mapTypes.set("OSM", new google.maps.ImageMapType({ | |
getTileUrl: function(coord, zoom) { | |
var imagesPerUnit = Math.pow(2, zoom); | |
// Stitch horizontaly: | |
var x = coord.x < 0 ? imagesPerUnit + (coord.x % imagesPerUnit) : coord.x; | |
var x = x >= imagesPerUnit ? 0 : x; | |
// Do not stitch verticaly, if overflow -- don't show: | |
if(coord.y < 0 || coord.y >= imagesPerUnit) |
OlderNewer