This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // usage: <span aria-hidden="true" class="u-icon--chevron--left"></span> | |
| // → | |
| .u-icon--arrow--right:before { | |
| content: '\279E'; | |
| } | |
| // ❯ | |
| .u-icon--chevron--right:before { | |
| content: '\276F'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function toggleOverlay() { | |
| if (document.getElementById('overlay') != null) { | |
| console.log(true); | |
| $('#overlay').fadeOut(300,function(){ | |
| $(this).remove() | |
| }); | |
| } else { | |
| var overlay = document.createElement('div'); | |
| overlay.id = 'overlay'; | |
| overlay.className = 'mfp-bg'; /* use existing styles */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // jQuery plugin to prevent double submission of forms | |
| jQuery.fn.preventDoubleSubmission = function() { | |
| $(this).on('submit',function(e){ | |
| var $form = $(this); | |
| if ($form.data('submitted') === true) { | |
| // don't submit | |
| e.preventDefault(); | |
| } else { | |
| // set data attr to true for next time |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ffmpeg -i input_file.mp4 -codec:v libx264 -profile:v high -preset slow -b:v 500k -maxrate 500k -bufsize 1000k -vf scale=-1:480 -threads 0 -codec:a libfdk_aac -b:a 128k output_file.mp4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getFirstSegment() { | |
| var path = window.location.pathname; | |
| seg1 = path.split("/")[1]; | |
| return seg1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //todo: de-jquery this | |
| function showRandomItem(list) { | |
| // random ad on refresh. Each a element should have style="display:none" | |
| var items = $(list).children('li'), | |
| tot = items.length; | |
| if (tot > 1) { | |
| var randNum = Math.round(Math.random()*(tot-1)); | |
| items.eq(randNum).show(); | |
| } else { | |
| $(items).show(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function formInputsToJson(form) { | |
| var $form = $(form); | |
| var fArr = $form.serializeArray() | |
| var fObj = {}; | |
| for (var i in fArr) { | |
| fObj[fArr[i].name] = fArr[i].value; | |
| } | |
| return fObj; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| validate domain (only letter, numbers, and hypens... and must start with a letter) | |
| ^[a-zA-Z]+[a-zA-Z0-9\-]*$ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var myModule = (function () { | |
| var privateMethod = function () { | |
| console.log('A private method'); | |
| }, | |
| someMethod = function () { | |
| console.log('A public method'); | |
| }, | |
| anotherMethod = function () { | |
| console.log('Another public method'); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function largestLessThanMaxLimit(limit = 10) { | |
| var maxLimit = limit; | |
| return function largestLessThanMaxLimit(...args) { | |
| return args.reduce( function(acc, val) { | |
| if( val > acc && val < maxLimit ) { | |
| return val; | |
| } | |
| else { | |
| return acc; | |
| } |