Skip to content

Instantly share code, notes, and snippets.

View amercader's full-sized avatar
🦃

Adrià Mercader amercader

🦃
View GitHub Profile
"""Default page handler.
"""
from PyISAPIe import Env
from hashlib import md5
import imp
from Error import HandleNotFound
Handlers = {}
@amercader
amercader / gist:793638
Created January 24, 2011 18:14
According to the docs, I would expect the Firefox behaviour. Am I right?
head.js(
{jquery:"https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"},
{jqueryui:"https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js"},
{gmaps:"http://maps.google.com/maps/api/js?v=3.2&sensor=false"},
{openlayers:"js/openlayers/OpenLayers.js"});
head.ready("jquery", function(){
console.log("jquery ready");
});
@amercader
amercader / gist:927079
Created April 19, 2011 09:55
British National Grid to WGS84 with pyproj
import pyproj
# Define two projections, one for the British National Grid and one for WGS84 (Lat/Lon)
# You can use the full PROJ4 definition or the EPSG identifier (PROJ4 uses a file that matches the two)
#bng = Proj("+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs towgs84='446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894'")
#wgs84 = Proj('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
bng = pyproj.Proj(init='epsg:27700')
wgs84 = pyproj.Proj(init='epsg:4326')
@amercader
amercader / wms_filter.html
Created October 23, 2011 12:41
Modify FILTER parameter in OpenLayers WMS layer
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>WMS Filter Example</title>
<link rel="stylesheet" href="http://openlayers.org/dev/theme/default/style.css" type="text/css">
<link rel="stylesheet" href="http://openlayers.org/dev/examples/style.css" type="text/css">
<script src="http://openlayers.org/dev/OpenLayers.js"></script>
@amercader
amercader / gist:2701799
Created May 15, 2012 13:30
pycsw / CKAn integration proof of concept
class CSWController(BaseController):
def dispatch(self):
import os
from pycsw.server import server
from pylons import request, response
env = request.environ
pycsw_config = config.get('ckanext.spatial.pycsw.config')
@amercader
amercader / gist:2710833
Created May 16, 2012 14:36
Quick and dirty CKAN to CKAN import
import json
import requests
ORI_SERVER = 'http://thedatahub.org'
DEST_SERVER = 'http://demo.ckan.org'
API_KEY = '<YOUR_API_KEY>'
#NAMES = ['gold-prices'] #This one failed (?)
2012-07-06 18:51:37,083 ERROR [ckan.model.modification] No object (name: tmpl_context or C) has been registered for this thread
Traceback (most recent call last):
File "/home/adria/dev/pyenvs/dgu/src/ckan/ckan/model/modification.py", line 76, in notify
observer.notify(entity, operation)
File "/home/adria/dev/pyenvs/dgu/src/ckanext-archiver/ckanext/archiver/plugin.py", line 30, in notify
self._create_archiver_task(entity)
File "/home/adria/dev/pyenvs/dgu/src/ckanext-archiver/ckanext/archiver/plugin.py", line 42, in _create_archiver_task
user = model.User.by_name(c.user)
File "/home/adria/dev/pyenvs/dgu/local/lib/python2.7/site-packages/paste/registry.py", line 137, in __getattr__
return getattr(self._current_obj(), attr)
2012-07-10 15:08:50,122 DEBUG [ckan.logic] User is not authorized to change-state <Package id=fd69d0d6-b3b1-4bfd-8590-b6ae103a4cbb name=tes title=Test CSV Buses version=None url=None author=None author_email=None maintainer=None maintainer_email=None notes= license_id=notspecified type=None state=draft revision_id=a3d77c11-9585-4307-a8f0-55a212f2fb46>
2012-07-10 15:08:50,167 ERROR [ckan.model.modification] 'module' object has no attribute 'DomainObjectOperation'
Traceback (most recent call last):
File "/var/lib/ckan/demo/pyenv/src/ckan/ckan/model/modification.py", line 68, in notify
observer.notify(entity, operation)
File "/var/lib/ckan/demo/pyenv/src/ckanext-qa/ckanext/qa/plugin.py", line 102, in notify
if operation == model.DomainObjectOperation.new:
AttributeError: 'module' object has no attribute 'DomainObjectOperation'
{% ckan_extends 'package/read.html' %}
{% block styles %}
{{ super() }}
<link type="text/css" rel="stylesheet" media="all" href="/ckanext/spatial/css/dataset_map.css" />
{% endblock %}
vagrant@lucid32:~$ sudo ckan-create-instance std default.vm.buildkit yes
Installing or upgrading CKAN std ...
Ensuring users and groups are set up correctly ...
Creating the 'ckanstd' group ...
Creating the 'ckanstd' user ...
Ensuring directories exist for std CKAN INSTANCE ...
Disabling the crontab for the ckanstd user ...
Setting log file permissions so that both Apache and cron jobs can log to the same place ...
Ensuring who.ini file exists ...