Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh -e
#git-cache-meta -- simple file meta data caching and applying.
#Simpler than etckeeper, metastore, setgitperms, etc.
#from http://www.kerneltrap.org/mailarchive/git/2009/1/9/4654694
#modified by n1k
# - save all files metadata not only from other users
# - save numeric uid and gid
# 2012-03-05 - added filetime, andris9
$.fn.extend({
"fullHeight" : function(p) {
var s;
with($(this)) {
var bs = css("box-sizing");
s = height() + (bs!="border-box"?
parseInt(css("border-top-width")) +
parseInt(css("border-bottom-width")) +
(bs!="padding-box"?
parseInt(css("padding-top")) +
@MrSwed
MrSwed / jQuery-modal-extender.js
Last active October 4, 2016 05:31
Simple Modal extender for custom css ( demo http://jsfiddle.net/2wg2p6km/)
$.fn.extend({
"modal": function(cm, p){
/* Modal windows jQuery extender
* Source https://gist.github.com/MrSwed/2e64367959a60866cf30
* Demo http://jsfiddle.net/2wg2p6km
*/
if (!cm) cm = "init";
var o = $(this);
p = $.extend({}, {debug: false, "afterOpen": false, "afterClose": false}, p);
if (cm != "init" && !o.data("inited")) o.modal("init", p);
@MrSwed
MrSwed / jQuery-tabs-extender.js
Last active September 14, 2017 13:05
Simple tabs control only (demo http://jsfiddle.net/6vz1wbmw/ )
$.fn.extend({
"tabs": function(p){
// Simple jQuery tabs extender. https://gist.github.com/MrSwed/4246691aa788058a9934
// actItem, deActItem extenders required (below)
// last update 2017/09/14
return $(this).each(function(){
var _t = this;
_t.p = $.extend({
"headers": $(".headers", _t),
"contents": $(".contents", _t),
@MrSwed
MrSwed / jQuery-class-extender.js
Last active August 29, 2015 14:17
Get className even is empty jQuery object
$.fn.extend({
"class": function() {
return $(this).attr("class") || $(this).selector.toString().replace(/^.*[\s]+([^\s])/,"$1").replace(/(^[^\.]+\.|[:][^\s]+)/,"").split(".").join(" ").trim();
}
});
#!/bin/sh
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ ! -n "$oemail" ]
then
oemail="$OLD_EMAIL"
fi
function number_format( num, decimals, dec_point, thousands_sep, hide_null ) {
if (num && typeof num == "string") num = num.replace(/ /g,"");
if (hide_null && !parseInt(num)) return "";
var i, j, kw, kd, km, minus = "";
if(num < 0){
minus = "-";
num = num*-1;
}
if( isNaN(decimals = Math.abs(decimals)) ){
decimals = 2;
@MrSwed
MrSwed / tv-list-resoure-recursive.txt
Created May 7, 2015 06:30
Modx примеры. Создание TV параметра со списком ресурсов в виде дерева.
@EVAL
function getItems($p, $l=0){
global $modx;
$c=array();
foreach($modx->getDocumentChildren($p,1,0,"id,pagetitle,isfolder") as $k) {
$c[] = str_pad("",$l*2,"-",STR_PAD_RIGHT)." ".$k['pagetitle']." (".$k['id'].")==".$k['id'];
$c = array_merge($c,getItems($k['id'],$l+1));
}
return $c;
}
@MrSwed
MrSwed / jQuery.trigger-change-hooks.js
Created July 3, 2015 12:07
Trigger change on changed prop or attr
// it getted from https://forum.jquery.com/topic/should-chk-prop-checked-true-trigger-change-event
$.attrHooks.checked = {
set: function(elem, value, name) {
var ret = (elem[ name ] = value);
$(elem).trigger("change");
return ret;
}
};
@MrSwed
MrSwed / is_mobile.tpl
Created September 3, 2015 12:40
Определение мобильного браузера. MODx.Chunk
<?php
/**
* is_mobile
*
* Определение мобильного браузера
*
* @category snippet
* @version 1.0
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License (GPL)
* @internal @properties