Skip to content

Instantly share code, notes, and snippets.

View fritzvd's full-sized avatar

Fritz van Deventer fritzvd

View GitHub Profile
from django.db import models
from django.contrib import admin
from django.contrib.admin import widgets
from django.forms import ModelForm
from django import forms
import datetime
TITLE_CHOICES = (
('Dhr', 'Dhr.'),
('Mw', 'Mw.'),
@fritzvd
fritzvd / models.py
Created June 6, 2011 09:33
Idea for a model
class Points(models.Model):
routes = models.ForeignKey(Routes)
categories = models.ForeignKey(Categories)
attribution = models.CharField(max_length=255)
title = models.CharField(max_length=65)
lat = models.FloatField()
lon = models.FloatField()
imageURL = models.URLField(verify_exists=True)
line2 = models.CharField(max_length=40)
line3 = models.CharField(max_length=40, blank=True, null=True)
@fritzvd
fritzvd / twitterforroland.py
Created September 26, 2011 10:22
Get request from twitter search and parse it into a Python object.
import urllib2, simplejson
# Hier de respons van de website als je de query opent.
response = simplejson.dumps(urllib2.urlopen("http://search.twitter.com/search.json?geocode=51.985263,5.663259,5km&q=forum").readline())
# Format de website zo dat python het kan lezen als python objecten ipv JSON
# de 5 en de 1 slaan op de indexing van de response. Het 5e item zijn de tweets zelf in deze request, kan misschien verschillen per search.
loadaspy = simplejson.loads(simplejson.loads(response)).items()[4][1]
@fritzvd
fritzvd / gist:1446911
Created December 8, 2011 12:51
example inline
from waterqmap.maps.models import Map,MapDate
from django.contrib import admin
class MapDateInline(admin.TabularInline):
#this is the foreignkey
model = MapDate
class MapAdmin(admin.ModelAdmin):
prepopulated_field = {"slug": ("title",)}
inlines = [MapDateInline]
@fritzvd
fritzvd / colocated_cokriging_r.py
Created November 14, 2012 13:49
Colocated cokriging in python with r
def cokriging_in_r(self, x, y, z):
'''
Cokriging (and ordinary kriging) is quite fast in R.
This would anyway be more pragmatic than rewriting/porting it to Python.
For the moment this will be the 'best' way as R makes it very easy to
use kriging without fitting a variogram model, but using a standard
variogram.
'''
import rpy2
import rpy2.robjects as robj
@fritzvd
fritzvd / kriging_test.R
Created November 29, 2012 09:48 — forked from anonymous/kriging_test.R
kriging test
#Edzer Pebesma
#> Institute for Geoinformatics (ifgi), University of Münster
#> Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
#> 8333081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de
#> http://www.52north.org/geostatistics e.pebesma at wwu.de
#################################################
#krige wil alleen als er geen NA waarden in de data.frame zitten. Heel onhandig
#data(meuse.grid) # only the non-missing valued cells
@fritzvd
fritzvd / gist:4223583
Created December 6, 2012 10:40
Mapfile example
MAP
NAME "whatever"
WEB
IMAGEPATH "/www/"
IMAGEURL "/www/"
METADATA
"wms_title" "whatever"
"wms_enable_request" "*"
"wms_onlineresource" "http://localhost/cgi-bin/mapserv?mapfile=/var/www/thisfile.map&"
@fritzvd
fritzvd / lizard.app.js
Created January 29, 2013 10:22
Voorbeeldje.
Lizard.App.Home = {};
Lizard.App.Home.DefaultView = Backbone.Marionette.ItemView.extend({
template: '#home-template',
className: 'home',
onShow: function() {
console.log('onShow()');
$('.search-query').focus();
},
onDomRefresh: function() {
@fritzvd
fritzvd / git_tutorial.md
Last active December 14, 2015 14:18
Git workflows

Git for Directors

I started editing a file and forgot to switch branch

git checkout -b forgottoswitch

All modified files are now available in the new branch forgottoswitch

I made changes but want to switch to a branch without committing my changes. Although I might want to go back to changes

@fritzvd
fritzvd / angular-jqueryui.html
Created June 21, 2013 10:24
Angular JS jQuery UI Slider
<jq-schlider ng-enabled="state.master" at="time.at" max="time.max_timestep"></jq-schlider>
<script>
angular
.module('Components', [])
.directive('jqSchlider', function () {
return {
restrict: 'E',
replace: true,
template: '<div id="schlider"></div>',