Skip to content

Instantly share code, notes, and snippets.

/*
By Osvaldas Valutis, www.osvaldas.info
https://osvaldas.info/image-lightbox-responsive-touch-friendly
Available for use under the MIT License
*/
;( function( $, window, document, undefined )
{
'use strict';
@namklabs
namklabs / 0_reuse_code.js
Created October 24, 2016 16:33
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@namklabs
namklabs / batchDownload.js
Last active July 28, 2016 21:27
This function will download all of the files on a page. Use in dev console. Just tweak the selector to filter what types of links will be downloaded. Eliminates duplicate downloads. Requires jQuery. http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet
// requires jQuery
// tested only in Chrome console dev tools
// use jQuerify bookmarklet if your page doesn't have jQuery: http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet
function batchDownload( $jquery_collection_of_a_elements, buffer_ms, random_ms, timeonly_bool ){
if( $jquery_collection_of_a_elements.length < 1 ){
throw "Nothing to download! Empty jQuery collection.";
}
@namklabs
namklabs / equalheight.js
Last active June 8, 2016 18:44
Force sibling columns with .equal-height class to size to the largest height of the group.
$.fn.equalheight = function(){
var $selection = this;
var $groups = [];
while( $selection.length > 1 ){// If $selection.length is greater than 1, then it must be 2, meaning there are at least 2 equal-height divs left. This will prevent an infinite loop if there is an equal-height div without a partner equal-height div.
// Find an equal-height group.
$groups.push( $selection.eq(0).siblings('.equal-height').addBack() );
// Reduce selection by the latest equal-height group.
$selection = $selection.not( $groups[ $groups.length - 1 ] );
// Drop groups that only have 1 element - it doesn't make any sense to have a lone equal-height element.
@namklabs
namklabs / terminus-search-replace.sh
Last active April 1, 2016 14:19 — forked from wpscholar/terminus-search-replace.sh
WP-CLI Search and Replace via Terminus (on Pantheon)
terminus wp "search-replace 'find' 'replace' --dry-run" --site=mysite --env=dev|test|live
@namklabs
namklabs / add-www-alias.sh
Created January 22, 2016 19:51
alias www to your MAMP folder on OS X
echo "alias www='cd ~/Desktop/www;clear;pwd;ls -a'" >> ~/.bash_profile
@namklabs
namklabs / php-process-user.php
Created January 20, 2016 17:00
find username executing PHP process
# http://stackoverflow.com/questions/9557646/php-mkdir-permissions-denied-mac
$processUser = posix_getpwuid(posix_geteuid());
echo($processUser['name']);
// https://github.com/mikebranski/jquery-nospam
// implementation
$(function(){
function reverse(s){
return s.split("").reverse().join("");
}
var tld = addr.substring( addr.lastIndexOf('.') + 1 );
@namklabs
namklabs / .gitignore
Last active December 29, 2015 01:09
WordPress .gitignore
.DS_Store
Thumbs.db
dwsync.xm
_notes/
*.svn
*.swo
*.swp
~
*~
~*
@namklabs
namklabs / copyright.js
Created October 30, 2013 21:48
Puts current year into a <span> in the footer of your website