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 / 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
@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
/**
* $(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 / 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
@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 / 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 / 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 / README.md
Created July 15, 2016 12:50 — forked from Spea/README.md
Script to auto reply emails.

General

This script can be used in conjunction with the ISPmail tutorial and the Roundcube autoreply plugin

Installation

Database setup

Create the following table in the database where you created the tables from the ISPmail tutorial.

@milosdjakonovic
milosdjakonovic / datasrc.js
Created July 15, 2016 12:52
Auto lazy load of data-src images
;(function(w,d){
var fn=function(){
var body = d.body || d.getElementsByTagName('body')[0];
if(d.querySelectorAll)
var allimgs = d.querySelectorAll('img[data-src]'), allimgs_len = allimgs.length;
for(var i=0;i<allimgs_len;i++){
allimgs[i].setAttribute('src', allimgs[i].getAttribute('data-src'));
}
}
@milosdjakonovic
milosdjakonovic / pattern.js
Created July 28, 2016 18:50
Regex to match media queries and get values
/@\s*?media\s*?\(\s*?(min|max)-(width|height)\s*?:\s*?(\d+)(px|em)\s*?\)\s*?{(.*)}/gms
/**
* Only basically tested.
* Should match min-max-width-height number px|em and following rules.
* Provides capturing groups to determinate condition alongside with css.
*
* Created with help of regex101
* https://regex101.com/r/zA6fX2/1