Skip to content

Instantly share code, notes, and snippets.

@duzun
duzun / jq.fn.maxZIndex.js
Created November 12, 2014 09:32
Finds maximum zIndex of an element
/**
* Finds maximum zIndex of an element
*/
;(function (global) {
var $ = global.jQuery || global.Zepto;
var maxZIndex = function maxZIndex(el,min) {
var el = this
, zIdx = el.css('zIndex')
//*******************************************
// Level 1, basic API, minimum support
//*******************************************
/*
Modules IDs are strings that follow CommonJS
module names.
*/
//To load code at the top level JS file,
//or inside a module to dynamically fetch
@duzun
duzun / enableSelect-bookmarklet.html
Last active December 22, 2023 08:04
Enable Right Click and Text Selection Bookmarklet
<a class="btn btn-default btn-info bookmarklet" href="javascript:(function(d){var a=d.document,h=function(){},c=a.body||a.getElementsByTagName("body")[0],f=a.documentElement||a.getElementsByTagName("html")[0],k=[c,f,a],l=["webkit","khtml","moz","ms",""],g=["contextmenu","selectstart","select","mousedown","mouseup"],b=d.Selection,e=b&&b.prototype;e&&(e.removeAllRanges=h,b=a.selection)&&(b.clear=h);for(e=k.length;e--;)if(f=k[e]){for(b=g.length;b--;)f["on"+g[b]]=null;if(a=f.style)for(a.cursor="",a.webkitTouchCallout="initial",b=l.length;b--;)a[((c=l[b])?"-"+c+"-":c)+"user-select"]="initial"}(c=d.jQuery||d.Zepto)&&c(d).off(g)})(this);">
Enable Select
</a>
@duzun
duzun / header_cache.php
Last active August 29, 2015 14:11
Set cache control headers and manage http cache logic
/**
* Set cache control headers and manage http cache logic.
*
* @param (int|bool) $expires: true - use cache, false - no cache, int - expires timeout
* @param (time) [$modified]: Last modification time stamp
* @param (string) [$etag]: ETag content identifier
* @param (int) [$die]: 0 - no die, 1 - die on 304, -1 - no 304 headers
*
* @return (mixed) status code if cache, false if headers sent, true otherwise
*
@duzun
duzun / backup.sh
Last active August 29, 2015 14:11
MySQL auto-backup script
#! /bin/sh
#
# Author: Dumitru Uzun (DUzun)
#
# Ussage:
# backup [-k <days>] [-s <subdir>] [-d <database>] [-e <exclude_tables_list>]
#
pass='<best-password-ever>'
user=backup
/**
* A script for transitioning to HTTPS for clients that support it.
*
* This script will make a request to https:yourdomain.com/ping?_clb_=?
* from the loaded http: document.
* If the request is successful, it will convert all the internal links
* to https:
*/
jQuery(function ($) {
if(location.protocol === 'http:') {

The 10 Commandments of Modern Web Application

1. Instant Access

  • No Flash, Java or other plugins

2. Responsive Design

  • Responsive Layout
  • Mobile First