Skip to content

Instantly share code, notes, and snippets.

View lidio601's full-sized avatar

Fabio Cigliano lidio601

View GitHub Profile
@lidio601
lidio601 / quick_sort.py
Last active August 29, 2015 14:27
Sample implementation of the Quick Sort algorithm ( O(N log(N)) order of complexity ) - Merge Sort variant
import random
__author__ = 'fabiocigliano'
def genarray():
n = int(random.random() * 10) + 1
ris = range(n)
random.shuffle(ris)
return ris
@lidio601
lidio601 / insert_sort.py
Created August 9, 2015 05:34
Sample implementation of the Insert Sort algorithm ( O(N^2/4) order of complexity )
import random
__author__ = 'fabiocigliano'
def genarray():
n = int(random.random() * 10) + 1
ris = range(n)
random.shuffle(ris)
return ris
@lidio601
lidio601 / bubble_sort.py
Last active August 29, 2015 14:27
Sample implementation of the Bubble Sort algorithm ( O(N^2/2) order of complexity )
import random
__author__ = 'fabiocigliano'
def genarray():
n = int(random.random() * 10) + 1
ris = range(n)
random.shuffle(ris)
return ris
@lidio601
lidio601 / naive_sort.py
Last active August 29, 2015 14:27
Sample implementation of the Naive sorting algorithm ( O(N^2/2) order of complexity )
import random
__author__ = 'fabiocigliano'
def genarray():
n = int(random.random() * 10) + 1
ris = range(n)
random.shuffle(ris)
return ris
@lidio601
lidio601 / picasa_sync.py
Created May 18, 2015 12:49
It was an alpha version of a script to mirror a remote Picasa album with a local directory
#!/usr/bin/python
"""
Alpha program to mirror a remote Picasa Album
with local directory
"""
__author__ = "fabiocigliano"
import gdata.photos
@lidio601
lidio601 / jsonparser.c
Created May 13, 2015 09:35
Simple JSON parser in C, parse a JSON-like string and look for the first key-value pair by using jsonparse(jsonstring, key); Run this with gcc test.c jsonparser.c; [ $? -ne 0 ] | ./a.out
/*
Copyright (c) 2015 Fabio Cigliano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@lidio601
lidio601 / extlibrary.cpp
Created May 8, 2015 22:39
Octave to C bridging for calling an Octave / MatLAB routine from a C program
// clear; mkoctfile extlibrary.cpp -o extlibrary.a
// mkoctfile extlibrary.cpp -M --link-stand-alone -o extlibrary.a
// clear; mkoctfile extlibrary.cpp --link-stand-alone -o extlibrary.o
//#include <iostream>
#include <octave-3.2.4/octave/oct.h>
@lidio601
lidio601 / TestWebviewVC.h
Created May 8, 2015 22:35
Objective-C: web view on a ios app. test of javascript injection
//
// ViewController.h
// testWebView
//
// Created by Fabio Cigliano on 21/02/13.
// Copyright (c) 2013 Fabio Cigliano. All rights reserved.
//
#import <UIKit/UIKit.h>
@lidio601
lidio601 / TestKeyStore.java
Created May 8, 2015 21:56
Sample Java class to test the keystore support
/**
* Sample Java class to test the keystore support
*/
package net.fabiocigliano.test.keystore;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@lidio601
lidio601 / Callbackable.java
Last active August 29, 2015 14:20
Sample Java class to simulate the Javascript callback functionality
/**
* Sample class that define a Callbackable object to act like a Javascript callback function
*/
package net.fabiocigliano.test.callback;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;