Skip to content

Instantly share code, notes, and snippets.

View milosdjakonovic's full-sized avatar

Miloš Đakonović milosdjakonovic

  • Belgrade, Republic of Serbia
View GitHub Profile
@milosdjakonovic
milosdjakonovic / real3d.js
Last active March 12, 2016 14:29
Real3d detects support for csstransforms3d and gives result both to html classes and javascript property
/**
*
* real3d detects support for csstransforms3d and gives
* result both to html classes and javascript property
* (just like Modernizr does)
*
* Unlike Modernizr, it's doing this non trivial test
* on real element inside real document's body, relaying
* on computated css transform property as distinctive
* factor for testing.
@milosdjakonovic
milosdjakonovic / zindexconsole.js
Created February 18, 2016 18:57
Console print z-index props from any element
/*
* Find out what is that damn element with highest z-index,
* or simply get the z-index 'picture' of DOM
*
* USAGE: simply paste this in console, hit enter
*/
var all = document.getElementsByTagName('*'),
allLength = all.length;
@milosdjakonovic
milosdjakonovic / elwrap.js
Created January 10, 2016 11:18
jQuery like data function in vanilla JavaScript
/**
*
* Element wrapper, necessary
* for attaching custom user
* data to element.
*
* It acts like jQuery wrapper
* -creates an instance of wrapper
* with element as zero field
* providing access to `data`
@milosdjakonovic
milosdjakonovic / jquery.contenteditablechanged.js
Last active November 26, 2015 08:37
contenteditablechanged event for jQuery
/**
* jQuery contenteditablechanged
*
* Fires custom event named 'contenteditablechanged' when
* textcontent of element marked with contenteditable='true'
* changes.
*
* Usage:
* $('[contenteditable]').on('contenteditablechanged', function(e){
* console.log(e); //-- Event properits
/**
* $(element).triggerOnce('muCustomEvent') instead
* of $(element).trigger('muCustomEvent')
* when goal is to neutralize multiple event triggering
*/
$.fn.triggerOnce = function(eventName){
if (! this.data( 'triggered-' + eventName ) ) {
this.trigger(eventName).data( 'triggered-' + eventName, true );
}
return this;
@milosdjakonovic
milosdjakonovic / MatrixConverter.js
Last active December 30, 2015 17:04
Small tool for conversion of transform functions from human readable to matrix and matrix3d values
/*
* Useful for forcing all transform functions defined in @keyframes to execute simultaneously
* Many (including myself until recently) doesn't know that transform functions defined
* into @keyframes doesn't play simultaneously
* but in reversed order of declaration
*
* More info about this issue:
* https://css-tricks.com/debugging-css-keyframe-animations/
*
* USAGE
@milosdjakonovic
milosdjakonovic / checkproftpd.sh
Created December 29, 2014 10:41
Based on detected status of ProFTPD service, start undesirably stopped ProFTPD service. Intended to run AFTER cron.daily and to be workaround until Debian bug #675081 is resolved.
#!/bin/bash
RESULT="$(ps -A | grep proftpd)"
if $( echo $RESULT | grep --quiet 'proftpd' )
then
echo 'Service PROFTPD is fine, no need for action...'
else
service proftpd stop
service proftpd start