Skip to content

Instantly share code, notes, and snippets.

$.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-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
@MrSwed
MrSwed / reset_users_blocks.sql
Created September 15, 2015 12:08
Modx evo. Sql. Reset user lock. Cброс блокировок пользователя.
# Reset for user 1
UPDATE `modx_user_attributes` SET `blocked` = '0', `blockeduntil` = '0', `failedlogincount` = '0' WHERE `modx_user_attributes`.`id` = 1;
# Warning! Reset for all users
#UPDATE `modx_user_attributes` SET `blocked` = '0', `blockeduntil` = '0', `failedlogincount` = '0';
#!/bin/sh
# git add -r Recursively add files by pattern
# https://gist.github.com/MrSwed/fb76fde40c6c16863c87
echo "Shorter for: find . -name \"$1\" | xargs git add ${@:2}"
mask=*
if [[ $1 ]]
then
@MrSwed
MrSwed / flexbox-extend.less
Last active March 23, 2016 14:42 — forked from jayj/flexbox.less
CSS3 Flexbox - LESS Mixins
// --------------------------------------------------
// Flexbox LESS extends
// The spec: http://www.w3.org/TR/css3-flexbox
// --------------------------------------------------
// example usage as extender .mydiv:extend(.flex) {&:extend(.flex.j-center)}
@import "flexbox";
.flex {
display: -webkit-box;
display: -moz-box;