Skip to content

Instantly share code, notes, and snippets.

View brendanfalkowski's full-sized avatar
🏍️
💨💨💨💨💨💨

Brendan Falkowski brendanfalkowski

🏍️
💨💨💨💨💨💨
View GitHub Profile
function toggleAudio (event, audioId, buttonId) {
event.preventDefault();
var audio = document.getElementById(audioId);
var button = document.getElementById(buttonId);
if (audio.paused) {
audio.play();
button.classList.add('playing');
button.classList.remove('paused');
<h1>PictureFill 2 Upgrade</h1>
<p>
Upgrading to PictureFill 2 lets us take advantage of native functionality in
modern browsers for responsive images. This is critical for performance
because it uses browser the preloader rather than waiting for JS to parse
the source. Older browsers will still work with JS, but with some limitations
because of the leaner fallback for modern browsers to work efficiently.
</p>
@brendanfalkowski
brendanfalkowski / gist:11240002
Created April 24, 2014 03:01
"sudo pip install ansible" fails
Requirement already satisfied (use --upgrade to upgrade): ansible in /Library/Python/2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): paramiko in /Library/Python/2.7/site-packages (from ansible)
Requirement already satisfied (use --upgrade to upgrade): jinja2 in /Library/Python/2.7/site-packages (from ansible)
Requirement already satisfied (use --upgrade to upgrade): PyYAML in /Library/Python/2.7/site-packages (from ansible)
Downloading/unpacking pycrypto>=2.1,!=2.4 (from paramiko->ansible)
Downloading pycrypto-2.6.1.tar.gz (446kB): 446kB downloaded
Running setup.py (path:/private/tmp/pip_build_root/pycrypto/setup.py) egg_info for package pycrypto
Downloading/unpacking ecdsa (from paramiko->ansible)
Downloading ecdsa-0.11.tar.gz (45kB): 45kB downloaded
@brendanfalkowski
brendanfalkowski / flex-centering.html
Created March 29, 2014 01:05
Vertical and horizontal centering with flexbox.
<div class="xx">
<img src="http://placehold.it/1250x600" alt="#" />
<div class="yy">
<div class="zz">
Nulla facilisi. Duis aliquet egestas purus in blandit. Curabitur
vulputate, ligula lacinia scelerisque tempor, lacus lacus ornare
ante, ac egestas est urna sit amet arcu.
</div>
</div>
@brendanfalkowski
brendanfalkowski / flex-wrap.html
Created March 26, 2014 21:01
Example of multi-column RWD with flex-wrap.
<div class="flex-test">
<p class="flex-test-item">Nulla facilisi. Duis aliquet egestas purus in blandit. Curabitur vulputate, ligula lacinia scelerisque tempor.</p>
<p class="flex-test-item">Nulla facilisi. Duis aliquet egestas purus in blandit. Curabitur vulputate, ligula lacinia scelerisque tempor. ligula lacinia scelerisque tempor. ligula lacinia scelerisque tempor.</p>
<p class="flex-test-item">Nulla facilisi. Duis aliquet egestas purus in blandit. Curabitur vulputate, ligula lacinia scelerisque tempor.</p>
<p class="flex-test-item">Nulla facilisi. Duis aliquet egestas purus in blandit. Curabitur vulputate, ligula lacinia scelerisque tempor.</p>
</div>
<style>
.flex-test {
display:flex;
@brendanfalkowski
brendanfalkowski / fire-callback-on-click.js
Created January 25, 2014 02:56
Get "data-callback" attribute from markup, check if the function exists, and then call it.
var elem = $('.selector');
elem.on('click', function (e) {
var callbackName = $(this).data('callback');
if ($.isFunction(window[callbackName])) {
window[callbackName].call(this);
}
});
@brendanfalkowski
brendanfalkowski / recursive-text-replace.sh
Last active August 10, 2022 17:35
Replace all occurrences of one string with another string in all child directories matching specific file types. Useful for normalizing Magento's copyright changes to get code-only diffs between releases.
############################
# Basic usage
############################
cd path/to/project
# One file type:
# Replace "red rover" with "black dog" in PHP files
@brendanfalkowski
brendanfalkowski / monitor-then-duplicate.js
Created May 1, 2013 03:16
jQuery snippet to monitor an element for an element to appear in the DOM, then duplicate its contents into another element.
var cachedContentHtml = '';
window.setInterval(function() {
var watchElem = $('.watch-me');
// Check if "element" exists in DOM yet
if ( watchElem.length ) {
// Grab the content we need
var contentHtml = $('.content').html();
@brendanfalkowski
brendanfalkowski / toggle-next-sibling.js
Created December 7, 2011 19:18
onClick toggle the next sibling of an element
function gravdept_next(elem) {
do {
elem = elem.nextSibling;
} while (elem && elem.nodeType != 1);
return elem;
}
function gravdept_toggle(elem) {
var nextElem = gravdept_next(elem);
@brendanfalkowski
brendanfalkowski / jquery_twitter_getRecent.js
Created May 4, 2011 03:59
Gets the most recent tweet and adds links
/* for Twitter JSON request */
function linkify (text) {
var exp = /(\b(https?|mailto):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
return text.replace(exp,"<a href='$1'>$1</a>");
}
/* jQuery start */
$(document).ready(function(){