Skip to content

Instantly share code, notes, and snippets.

View LeonardoCiaccio's full-sized avatar

Leonardo Ciaccio LeonardoCiaccio

View GitHub Profile
@LeonardoCiaccio
LeonardoCiaccio / $toclipboard.js
Last active September 23, 2017 16:00
Accessori, da utilizzare quasi sempre, cross browser, in espansione ...
function copyToClipboard( element ){
var $temp = $( "<input>" );
$( "body" ).append( $temp );
$temp.val( $( element ).text() ).select();
document.execCommand( "copy" );
@LeonardoCiaccio
LeonardoCiaccio / Density.js
Last active August 29, 2015 14:25
Conta la presenza di parole in una stringa
/*
Density 1.0.0
Misura la densità delle parole, ovvero conta la presenza di ogni parola
// Default RegExp //
([a-zA-Z0-9]{2,100}[a-zA-Z0-9\-]{0,100}[a-zA-Z0-9]{3,100}){1,100}
// Restituisce un array ordinato dal valore più grande al più piccolo
@LeonardoCiaccio
LeonardoCiaccio / 0_reuse_code.js
Last active August 29, 2015 14:26
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@LeonardoCiaccio
LeonardoCiaccio / Suppress.js
Created August 1, 2015 09:28
Suppress an error like "@" in PHP
at = function( test ){
try{
if( typeof test === "function" )return test();
return test || null;
}catch( e ){
/*
IDEA :
Monitorare il cambiamento di una variabile, per fare questo
dobbiamo utilizzare un oggetto che ci fornisce la possibilità
di utilizare una variabile di qualsiasi tipo purché non sia una
funzione ( JSON compatibile ) .
In sintesi ogni volta che cambia l'oggetto questo esegue una
@LeonardoCiaccio
LeonardoCiaccio / SincroScripts.js
Created August 26, 2015 10:55
Load sincro scripts
( function( tools, libs ){
// Iterator
var require = function( scripts, onEnd ){
onEnd = onEnd || function(){};
if( !scripts || scripts.length < 1 )return onEnd();
var src = scripts.splice( 0, 1),
@LeonardoCiaccio
LeonardoCiaccio / Bookmarklet.Export.Cookie.js
Last active March 19, 2017 16:13
Bookmarklet Export Cookie
@LeonardoCiaccio
LeonardoCiaccio / Bookmarklet.Password.By.File.js
Created March 19, 2017 15:11
Bookmarklet Password By File
// MD5 Lib, very fast, https://github.com/satazor/js-spark-md5
(function(factory){if(typeof exports==="object"){module.exports=factory()}else if(typeof define==="function"&&define.amd){define(factory)}else{var glob;try{glob=window}catch(e){glob=self}glob.SparkMD5=factory()}})(function(undefined){"use strict";var add32=function(a,b){return a+b&4294967295},hex_chr=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function cmn(q,a,b,x,s,t){a=add32(add32(a,q),add32(x,t));return add32(a<<s|a>>>32-s,b)}function md5cycle(x,k){var a=x[0],b=x[1],c=x[2],d=x[3];a+=(b&c|~b&d)+k[0]-680876936|0;a=(a<<7|a>>>25)+b|0;d+=(a&b|~a&c)+k[1]-389564586|0;d=(d<<12|d>>>20)+a|0;c+=(d&a|~d&b)+k[2]+606105819|0;c=(c<<17|c>>>15)+d|0;b+=(c&d|~c&a)+k[3]-1044525330|0;b=(b<<22|b>>>10)+c|0;a+=(b&c|~b&d)+k[4]-176418897|0;a=(a<<7|a>>>25)+b|0;d+=(a&b|~a&c)+k[5]+1200080426|0;d=(d<<12|d>>>20)+a|0;c+=(d&a|~d&b)+k[6]-1473231341|0;c=(c<<17|c>>>15)+d|0;b+=(c&d|~c&a)+k[7]-45705983|0;b=(b<<22|b>>>10)+c|0;a+=(b&c|~b&d)+k[8]+1770035416|0
// Like '@' for php - supress error - at( function(){} );
window.at=function(a){try{return"function"==typeof a?a():a||null}catch(a){return null}};
var params = "?q=Hello World&c=Awesome";
params = "{\"" +
params
.replace( /\?/gi, "" )
.replace( /\&/gi, "\",\"" )
.replace( /\=/gi, "\":\"" ) +
"\"}";
params = JSON.parse( params );