Skip to content

Instantly share code, notes, and snippets.

@nmandery
nmandery / hexcolor_to_mapserver.sql
Created March 29, 2011 08:59
convert hex colors to mapserver format in postgresql
create or replace function public.hexcolor_to_mapserver(hexcolor text) returns text as
$body$
declare
thexcolor text;
color_r int;
color_g int;
color_b int;
begin
thexcolor := trim(both ' ' from hexcolor);
if not thexcolor ~ '^#[0-9a-fA-F]{6}$' then
@nmandery
nmandery / size_schemata.sql
Created March 18, 2011 08:17
views to get relations sizes in postgresql
create or replace view public.size_schemata as
select table_schema,
pg_size_pretty(sum(pg_total_relation_size(table_schema || '."' || table_name || '"')::bigint)::bigint) As fulltblsize,
pg_size_pretty(sum(pg_relation_size(table_schema || '."' || table_name || '"')::bigint)::bigint) As justthetblsize
from information_schema.tables
where table_catalog = current_database()
group by table_schema
@nmandery
nmandery / wget_github.sh
Created March 15, 2011 16:59
bash function to download github tarballs
function wget_github {
GHUSER=$1
GHREPO=$2
wget --no-check-certificate "https://nodeload.github.com/$GHUSER/$GHREPO/tarball/master" -O "./$GHUSER-$GHREPO.tar.gz"
}
@nmandery
nmandery / camera_audio_trigger.py
Created December 25, 2010 19:54
camera_audio_trigger.py
#!/usr/bin/python
import alsaaudio, time, audioop
import sys
import piggyphoto
# init camera
try:
C = piggyphoto.camera()
CREATE OR REPLACE FUNCTION posting_set_keywords(postingid integer, kw_array text[])
RETURNS void AS
$BODY$
begin
-- remove keywords which do not anymore exist
delete from test.posting_keyword where
posting_id=postingid and
keyword_id in (
select pl.keyword_id
from test.posting_keyword lk
# -*- coding: utf-8 -*-
from mapmatters.client import wms as wmsclient
from mapmatters.parser import wms as wmsparser
WMS_URL = "http://www.example.com/wms"
wms = wmsclient.WmsClient(WMS_URL)
parser = wmsparser.Service(wms.capabilities)
#!/usr/bin/lua
--[[
a parser for google-like search queries
]]--
lex_keywords = {
-- keywords with quotes
"([a-zA-Z]+)%s*:%s*[\"\']([^\"\']+)[\"\']",
-- keywords without quotes