Skip to content

Instantly share code, notes, and snippets.

View dlion's full-sized avatar
🦁
If you can dream it, you can do it ~

Domenico Luciani dlion

🦁
If you can dream it, you can do it ~
View GitHub Profile
@dlion
dlion / check_url.php
Created April 19, 2013 17:49
check if is a url
<?php
public function checkURL($url) {
$reg = '%^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@|\d{1,3}(?:\.\d{1,3}){3}|(?:(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)(?:\.(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)*(?:\.[a-z\x{00a1}-\x{ffff}]{2,6}))(?::\d+)?(?:[^\s]*)?$%iu';
$url = htmlspecialchars(trim($url));
if(preg_match($reg,$url))
return true;
else
{
@dlion
dlion / cod_fisc.php
Last active December 16, 2015 00:18
Function to extract birthdate and sex from fiscal code.
<?php
function trova_data_fiscale($codice)
{
$mesi = array('A' => '01', 'B' => '02', 'C' => '03', 'D' => '04', 'E' => '05', 'H' => '06', 'L' => '07', 'M' => '08', 'P' => '09', 'R' => '10', 'S' => '11', 'T' => '12');
$dati_finali = array();
$data_presa = substr(strtoupper($codice),6,5);
$anno = substr($data_presa,0,2);
$mese = substr($data_presa,2,1);
$giorno = strval(substr($data_presa,3,2));
if($giorno >= 40)
@dlion
dlion / info_joystick.cpp
Created February 24, 2013 15:41
Retrieve Joystick Information using plib libraries
#include <plib/js.h>
int main()
{
jsJoystick *js[1];
float *assi[1];
int j;
jsInit();
@dlion
dlion / bubble sort 5.c
Created February 20, 2013 21:37
Bubble Sort versione 5
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define DIM 100
void randomico(int *A)
{
int i;
srand(time(NULL));
@dlion
dlion / quick.c
Last active December 13, 2015 23:59
Quick sort
#include <stdio.h>
#include <stdlib.h>
void scambia(int*,int*);
void stampa(int*,int);
void crea(int*,int);
void quicksort(int*,int,int);
int main()
{
@dlion
dlion / somma_rico.c
Created February 20, 2013 01:30
Sommare gli elementi di un vettore A con puntatori e funzioni ricorsive. Domenico Luciani aka DLion anno 2013 Facoltà di Scienze Informatiche, 1° anno. 20/02/2013
/*
* Sommare gli elementi di un vettore A con puntatori e funzioni ricorsive.
* Domenico Luciani aka DLion anno 2013 Facoltà di Scienze Informatiche, 1° anno.
* 20/02/2013
*/
#include <stdio.h>
#include <stdlib.h>
void stampa(int*,int);
@dlion
dlion / BlinkLed.c
Last active May 23, 2017 08:41
A simple source to blink 2 LED when push button is pressed. You can compile it with: gcc BlinkLed.c -o BlinkLed -lwiringPi and you can run it with: sudo ./BlinkLed
/*
Blink 2 Led with push button
By Domenico Luciani aka DLion
http://dlion.it
*/
//Using wiringPi library
#include <wiringPi.h>
#include <stdio.h>
#include <stdlib.h>
@dlion
dlion / heart.c
Last active December 12, 2015 07:09
Because a nerd in love is too smart.
#include <stdio.h>
char*z="ou"; char*(b)="ar";
char*a="Y";char*s=" ";char*c="cfbvujgvm"
;int main(int(argc),char*argv[]){printf("%s",a);
;char(space)[2];(space)[0]=(s)[0];(space)[1]='\0';
;printf("%s",z);printf("%s",space);printf("%se",b)
;char*l=space;printf("%s",l);int(i);char(n)[10];
for(i=0;i<10;i++){n[i]=c[i]-1;}n[9]='\0';
printf("%s",n);printf("%s",".")
;printf(("%s"),("\0"));
@dlion
dlion / conv.c
Last active December 12, 2015 01:08
Programmazione e laboratorio Prova pratica – 29 Gennaio 2013 Compito A 1) Date due successioni numeriche an e bn, la loro convoluzione è una successione il cui termine n-simo cn è dato da: cn = a0bn + a1b(n -1) + ....+ a(n -1)b1 + anb0 Date le successioni an = (n + 1)² e bn = 1 / (n + 2) si scriva una funzione in C che preso in input un intero n…
/*
* Prova d'esame di programmazione e laboratorio by Domenico Luciani aka DLion
* 01/02/13 - 03:17
*/
#include <stdio.h>
#include <stdlib.h>
void convoluzione(int);
@dlion
dlion / wget_thread.sh
Created January 20, 2013 02:51
Allows to download a file with wget using multi-threading.
function wget_thread()
{
for i in {1..4}; do
wget -rnp -c -N $1 &
done
}