Skip to content

Instantly share code, notes, and snippets.

View fbedussi's full-sized avatar

Francesco Bedussi fbedussi

View GitHub Profile
if (!('indexedDB' in window)) {
//throw new Error('This browser doesn\'t support IndexedDB');
}
var db;
const openDb = (dbName, user) => new Promise((resolve, reject) => {
const request = indexedDB.open(dbName);
var newDb = false;
@fbedussi
fbedussi / jquery.fadecss.js
Created October 5, 2017 08:28
Apply class to allow fade in and fade out management via CSS transitions, invisible elements are in "display: none" to be invisible even to screen readers
(function ($) {
$.fn.fadeCss = function (action) {
try {
var defaultOptions = {
hideClass: 'hide',
fadeInClass: 'fadeIn',
fadeOutClass: 'fadeOut',
zeroOpacityClass: 'transparent',
fullOpacityClass: 'opaque',
@fbedussi
fbedussi / objHasDeepProp.js
Created October 5, 2017 08:26
check if an object exsits and if it has the specified nested property
export default const objHasDeepProp = (obj, deepProp) => {
const props = deepProp.split('.');
var objToTest = obj;
var result = true;
if (!obj) {
return false;
}
for (let i = 0; i < props.length; i++) {
@fbedussi
fbedussi / .gitconfig
Last active January 2, 2019 13:46
My .gitconfig
[http]
sslVerify = false
sslCAinfo = C:/Program Files/Git/usr/ssl/certs/ca-bundle.crt
sslCAinfo = C:/Program Files/Git/usr/ssl/certs/ca-bundle.trust.crt
[core]
autocrlf = true
excludesfile = C:\\Users\\bedussif\\Documents\\gitignore_global.txt
editor = \"C:/Program Files (x86)/GitExtensions/GitExtensions.exe\" fileeditor
ignorecase = false
[user]
@fbedussi
fbedussi / getRootOf.js
Created October 5, 2016 20:04
Get root prototype on an object
function getRootOf(obj) {
var proto = Object.getPrototypeOf(obj);
while (!proto.hasOwnProperty('id')) {
proto = Object.getPrototypeOf(proto);
}
return proto;
}
var Obj = {id: 1}
function shuffle(array) {
for(var j, x, i = array.length; i; j = parseInt(Math.random() * i), x = array[--i], array[i] = array[j], array[j] = x);
return array;
}
@fbedussi
fbedussi / getTransitionDuration
Last active September 18, 2017 10:02
Return the transition duration (in millisecond) for the specified property on the specified element
/**
* @desc returns the duration in milliseconds of a CSS transition on the element $el for the given property
* @param {type} $el
* @param {type} property = 'transform'
* @returns {type}
*/
function getTransitionDuration($el, property = 'transform') {
return $el
.css('transition')
.split(',')