Skip to content

Instantly share code, notes, and snippets.

View eskil's full-sized avatar

Eskil Heyn Olsen eskil

View GitHub Profile
@eskil
eskil / pycurl_curlmulti_ssl.py
Created April 4, 2012 00:48
Example code doing SSL using pycurl and CurlMulti
# Example code doing SSL using pycurl and CurlMulti
import pycurl
import cStringIO
response_buffer = cStringIO.StringIO()
multi = pycurl.CurlMulti()
curl = pycurl.Curl()
curl.setopt(pycurl.URL, 'https://www.yammer.com')
curl.setopt(pycurl.SSL_VERIFYPEER, 1)
"CREATE TRIGGER Dive_Update AFTER "
"UPDATE OF dive_datetime ON Dive BEGIN "
"UPDATE Dive "
"SET dive_number= "
" (SELECT CASE "
" WHEN dive_id = NEW.dive_id THEN "
" /* The updated dive, set the number to the number of older dives */ "
" 1 + (SELECT COUNT(*) FROM Dive WHERE dive_datetime < NEW.dive_datetime) "
" WHEN NEW.dive_datetime > OLD.dive_datetime "
" /* All other dive, move by +/- 1 depending on whether we've moved the datetime "
@eskil
eskil / gdivelog new dive trigger
Created March 18, 2012 20:32
The ORM is inside me.
DROP TRIGGER Dive_Insert;
/*
if no dives predate this then
if lowest number is > 1:
lowest number - 1
else
1
else
pick most recent +1