Skip to content

Instantly share code, notes, and snippets.

View TheHiddenHaku's full-sized avatar

Alessio Bottiroli TheHiddenHaku

View GitHub Profile
@TheHiddenHaku
TheHiddenHaku / is_iban.php
Last active August 29, 2015 14:07
PHP IBAN Check
<?php
function isIban($iban, $reformat = true, $countryCode=null, $printErrors=false) {
$str = $iban;
if(!empty($str)){
if($reformat){
$str = preg_replace('/[\W_]+/', '', strtoupper($str) );
}
$errors = array();
if( 4 > strlen($str) || strlen($str) > 34 ){
$errors[] = 'Invalid string length';
@TheHiddenHaku
TheHiddenHaku / console_log.php
Last active August 29, 2015 14:06
PHP - Function to log data in javascript console
<?php
//UTILITY TO CONSOLE LOG DEBUG OUTPUT
function console_log($data, $table = 0) {
$verb = $table ? 'table' : 'log';
if(is_array($data) || is_object($data)) {
echo "<script>console.".$verb."(".json_encode($data).");</script>" ;
} else {
echo "<script>console.".$verb."(".$data.");</script>" ;
}
}
@TheHiddenHaku
TheHiddenHaku / OSX MySQL Server Location
Created September 2, 2014 23:41
OSX MySQL Server Location
sudo /usr/local/mysql/support-files/mysql.server start
/*
* Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js
*/
var http = require('http'),
fs = require('fs'),
util = require('util');
http.createServer(function (req, res) {
var path = 'video.mp4';
@TheHiddenHaku
TheHiddenHaku / html5.html
Created December 3, 2013 15:29
Very Basic HTML doc
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/main.css">
@TheHiddenHaku
TheHiddenHaku / mime.php
Created November 21, 2013 15:54
php array of mime types
<?php
$mime = array(
"323" => "text/h323",
"acx" => "application/internet-property-stream",
"ai" => "application/postscript",
"aif" => "audio/x-aiff",
"aifc" => "audio/x-aiff",
"aiff" => "audio/x-aiff",
"asf" => "video/x-ms-asf",
"asr" => "video/x-ms-asf",
@TheHiddenHaku
TheHiddenHaku / jwd.sql
Created October 30, 2013 09:51
MYSQL - Jaro-Winkler-Distance function
DELIMITER $$
CREATE DEFINER=`root`@`localhost` FUNCTION `jaro_winkler_similarity`(
in1 varchar(255),
in2 varchar(255)
) RETURNS float
DETERMINISTIC
BEGIN
#finestra:= search window, curString:= scanning cursor for the original string, curSub:= scanning cursor for the compared string
declare finestra, curString, curSub, maxSub, trasposizioni, prefixlen, maxPrefix int;
@TheHiddenHaku
TheHiddenHaku / comuni.sql
Created October 22, 2013 16:09
SQL creazione tabella comuni italiani
-- phpMyAdmin SQL Dump
-- version 2.6.0-pl3
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generato il: 18 Apr, 2007 at 04:00 PM
-- Versione MySQL: 3.23.58
-- Versione PHP: 4.3.11
--
-- Database: `test`
@TheHiddenHaku
TheHiddenHaku / province.sql
Created October 22, 2013 16:08
SQL crezione tabella provincie italiane
-- phpMyAdmin SQL Dump
-- version 2.6.0-pl3
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generato il: 18 Apr, 2007 at 04:00 PM
-- Versione MySQL: 3.23.58
-- Versione PHP: 4.3.11
--
-- Database: `test`
@TheHiddenHaku
TheHiddenHaku / regioni.sql
Created October 22, 2013 16:08
SQL Creazione tabella regioni italiane
-- phpMyAdmin SQL Dump
-- version 2.6.0-pl3
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generato il: 18 Apr, 2007 at 04:00 PM
-- Versione MySQL: 3.23.58
-- Versione PHP: 4.3.11
--
-- Database: `test`