Skip to content

Instantly share code, notes, and snippets.

@andreafrancia
andreafrancia / test_wps.py
Created August 4, 2011 13:29
Bug encoding PyWPS
from nose.tools import assert_equals, assert_true
import sys
sys.path.append("./pywps-svn")
import pywps
def test_no_problems_passing_normal_chars():
wps = pywps.Pywps(pywps.METHOD_GET)
wps.parseRequest(
'service=WPS&version=1.0.0&'
'request=Execute&identifier=stub&'
@andreafrancia
andreafrancia / test_pywps_bug.py
Created September 1, 2011 13:49
Bug: PyWPS does not escape properly ExceptionText
import unittest
import sys
sys.path.append("./pywps-svn")
import pywps
import pywps.config
pywps.config.loadConfiguration('tests/pywps-no-logging.cfg')
class TestWps(unittest.TestCase):
def test_what_happen_on_process_errors(self):
wps = pywps.Pywps(pywps.METHOD_GET)
@andreafrancia
andreafrancia / Prova.java
Created February 16, 2012 13:11
Equality for strings in Java
/* Run with:
javac Prova.java && java Prova
*/
class Prova {
public static void main(String[] args) {
StringBuilder o = new StringBuilder("o");
System.out.println("\"pippo\" == \"pippo\" ~~> " + ( "pippo" == "pippo") );
System.out.println("\"pippo\" == \"pipp\" + \"o\" ~~> " + ( "pippo" == "pipp" + "o") );
System.out.println("\"pippo\" == \"pipp\" + o ~~> " + ( "pippo" == "pipp" + o) );
import nose
class TestToBeRun:
def test_it_should_fail(self):
assert False
# possibly other test cases that should not be run
if __name__ == '__main__':
list_of_test_to_be_run=[TestToBeRun,]
# Copyright: Andrea Francia 2012, lincesed under GPL-v2
from __future__ import martin
try:
martin.dont_mess_the_timeline()
except martin.ParentsDontFallInLoveError, e:
(george, lorraine) = e.parents()
while 'Enchantment Under The Sea':
@andreafrancia
andreafrancia / 1955.py
Created November 11, 2012 20:08
Back to the Future in Python
# Copyright: (C) Andrea Francia 2012
# License CC BY-SA <http://creativecommons.org/licenses/by-sa/3.0/>
from __future__ import martin
try:
martin.dont_mess_the_continuum()
except martin.ParentsDontFallInLoveError, e:
(george, lorraine) = e.parents()
- (void)saveScreenshot
{
NSString * name = @"ciao";
BOOL includeStatusBar = NO;
//Get image with status bar cropped out
BOOL isRetina = [[UIScreen mainScreen] scale] != 1.0f;
CGFloat StatusBarHeight = isRetina ? 40 : 20;
CGImageRef CGImage = UIGetScreenImage();
BOOL isPortrait = UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation]);
CGRect imageRect;
#[cfg(not(test))]
fn main() {
use std::io::BufferedReader;
use std::io::stdin;
let mut stdin = BufferedReader::new(stdin());
match stdin.read_line() {
Ok(line) => println!("line:{}", line),
Err(io_error) => println!("problem reading line: {}", io_error)
}
@andreafrancia
andreafrancia / gist:9551500
Last active August 29, 2015 13:57
Objective-C API for mock library inspired to Python Voidspace library
- (void)testMockery
{
Mockery * mockery = [[Mockery alloc]init];
id<AddressSink> sink = [mockery mockWithName:@"sink"];
[sink findAddressWithUUID:@"123"];
XCTAssertEqualObjects([mockery calls:^{
[sink findAddressWithUUID:@"123"];
}], [mockery trackedCalls:sink]);