Skip to content

Instantly share code, notes, and snippets.

@nonZero
nonZero / cool.html
Created November 11, 2015 09:22
display points as leaflet markers
{% load staticfiles %}
<!doctype html>
<style>
#map {
height: 500px;
}
</style>
cool!
sudo apt-get install postgis postgresql-9.3-postgis-2.1
sudo -iu postgres createuser proj123 -S -D -R
sudo -iu postgres createdb proj123 -O proj123
sudo -iu postgres psql -c \"alter user proj123 with password 'proj123';\"
sudo -iu postgres psql proj123 -c \"CREATE EXTENSION postgis;\
sudo -iu postgres psql proj123 -c \"CREATE EXTENSION postgis_topology;\""
@nonZero
nonZero / read_nli_dict.py
Created November 4, 2015 09:52
iter parse xml
from lxml import etree
def clear_element(e):
e.clear()
while e.getprevious() is not None:
del e.getparent()[0]
def parse_file(filename):
@nonZero
nonZero / ext_info.py
Created October 17, 2015 19:02
Python 3.5 version
import collections
import pathlib
import sys
USAGE = """usage: {} path
displays number of files and total size per extension in the specified path."""
def get_info(path):
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
]
import threading
import itertools
from time import sleep
from random import random
def main():
c = Container(value=0)
adders = [threading.Thread(target=lambda x: x.add(1), args=(c,))
for _ in xrange(10000)]
@nonZero
nonZero / maze.py
Created October 28, 2013 14:44
MAZE (can you spot the bug?)
MAZE_DRAWING = """
###################################
###################################
###########################
## ######## #######
## ########### ############ #######
## ########### ############ #######
## ########### #######
class Iframe(object):
def __init__(self, prm):
self.param = prm
def __call__(self, view):
def df(*args, **kwargs):
for i in args:
if type(i) == WSGIRequest:
host = i.META['HTTP_REFERER']
from bottle import get, post, request, run
import time
LIMIT = 500
messages = []
@get('/')
def poll_messages():
ts = float(request.query.timestamp or "0")
@nonZero
nonZero / models.py
Created October 30, 2012 08:37 — forked from neara/models.py
class Occupation(models.Model):
event = models.ForeignKey(Event, related_name='sections')
section = models.ForeignKey(Section)
expected_capacity = models.PositiveIntegerField(
help_text=)
def __unicode__(self):
return self.section.name
class OccupationForm(forms.ModelForm):