View imagelightbox.js
/*
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';
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View lorem-ipsum.sh
function lorem(){
# Copy lorem ipsum to your clipboard in OS X
# usage:
# $ lorem <int> <htmlflag>
# where <int> is how many paragraphs of lorem ipsum you want, each separated by 2 newlines
# and <htmlflag> is anything, indicating you want each paragraph surrounded by <p></p>. Omit if you don't want this.
View batchDownload.js
// 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.";
}
View rotateArrayRight.js
function rotateArrayRight( arr ){
// rotates a 2D array 90 degrees to the right (clockwise)
var newarr = [];
for( var x = 0; x < arr[0].length; x++ ){
newarr[x] = [];
for( var y = arr.length - 1; y >= 0; y-- ){
newarr[x].push( arr[y][x] );
}
View terminus-search-replace.sh
terminus wp "search-replace 'find' 'replace' --dry-run" --site=mysite --env=dev|test|live
View add-www-alias.sh
echo "alias www='cd ~/Desktop/www;clear;pwd;ls -a'" >> ~/.bash_profile
View php-process-user.php
# http://stackoverflow.com/questions/9557646/php-mkdir-permissions-denied-mac
$processUser = posix_getpwuid(posix_geteuid());
echo($processUser['name']);
View gist:e1a89c3f80e2e7f9c644
var code = null;
jQuery(window).keypress(function(e){
code = e.which;
});
jQuery('#myform').submit(function(e){
if( code == 13 ){//if Enter is pressed...
code = null;//Reset keycode to allow submission via click.
e.preventDefault();
View trimText.js
// Trim text.
/*
- Respects word boundaries by default (will not chop a word up to create ellipses by default).
- Allows for ellipses or no ellipses.
*/
function trimText( jquery_obj_to_trim, int_trim_length, bool_ellipses, bool_respect_word_boundaries ){
var ellipses;
if( typeof bool_ellipses === "undefined" ){