Skip to content

Instantly share code, notes, and snippets.

View pokoli's full-sized avatar
🚴‍♂️

Sergi Almacellas Abellana pokoli

🚴‍♂️
View GitHub Profile
@pokoli
pokoli / calculate_iban.sql
Created January 23, 2014 09:20
PostgreSQL Function to calculate IBAN the given a Spanish Acount Number
CREATE OR REPLACE FUNCTION calculate_iban(account varchar)
RETURNS varchar AS $$
DECLARE num numeric;
DECLARE DC varchar(2);
BEGIN
SELECT CAST(replace(account, ' ', '')|| '142800' AS numeric) INTO num;
SELECT LPAD(CAST(98 - MOD(num, 97) AS varchar(2)), 2, '0') INTO DC;
RETURN 'ES' || DC || replace(account, ' ', '');
END;
$$ LANGUAGE plpgsql;
@pokoli
pokoli / doctest exceptions
Last active December 29, 2015 16:39
Catching exceptions on doctest
#Testing expected exceptions
>>> from exceptions import UserError
>>> try:
... someOperation()
... except UserError as e:
... e.message
u'ExpectedMessage'
>>> # continue test
@pokoli
pokoli / test_results.txt
Created June 14, 2013 17:41
Nereid-project failing test
test_project.py
======================================================================
FAIL: test_0030_create_project_when_user_is_admin (__main__.TestNereidProject)
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests/test_project.py", line 341, in test_0030_create_project_when_user_is_admin
response.data
AssertionError: False is not true
@pokoli
pokoli / socket.io.test.js
Created October 30, 2011 12:32
Socket.io test
var port = 8080,
io = require('socket.io').listen(port);
module.exports = {
"Test socket.io" : function(beforeExit){
var client = require('socket.io-client').connect( "http://localhost", { port: port });
client.on('connect', function() {
console.log('connect')
client.disconnect();