Skip to content

Instantly share code, notes, and snippets.

@infn8
infn8 / .bash_profile
Created August 7, 2014 13:42
Bash Profile Aliases
#!/bin/bash
#
#
# Aliases
#
alias ll="ls -la"
alias sw="sass --watch --debug-info sass:css"
alias swp="sass --watch --style compressed sass:css"
@infn8
infn8 / parse_video_link.php
Created August 21, 2014 17:56
Parse youtube or vimeo URLs
@infn8
infn8 / wordpress_import_set_authors.js
Last active November 25, 2016 21:09
Ever import a Wordpress eXtended RSS file and get sick of setting all the authors in the import file to all the SAME authors in your site? if so open your console and run this code.
jQuery('ol#authors li').each(function(index, el) {
var $, theName, parts, theOption, theID;
$ = jQuery;
theName = $(this).find('strong').text();
parts = theName.split('(');
theName = parts[0];
theID = parts[1].replace(')', '').trim();
theOption = $(this).find('select option:contains(' + theName.trim() + ')');
if(theOption.length){
$(this).find('select').val(theOption.val());
@infn8
infn8 / Modernizr.canvasblending.js
Last active August 29, 2015 14:06
Modernizer Canvas Blend Modes
Modernizr.addTest('canvasblending', function() {
if (Modernizr.canvas === false) return false;
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
ctx.globalCompositeOperation = 'screen';
return ctx.globalCompositeOperation === 'screen';
});
@infn8
infn8 / clearAllTimers.js
Created September 10, 2014 19:48
Clear All JS Timers
tempID = window.setTimeout(function() {}, 0);
while (tempID--) {
window.clearTimeout(tempID); // will do nothing if no timeout with tempID is present
}
tempID = window.setInterval(function() {}, 0);
while (tempID--) {
window.clearInterval(tempID); // will do nothing if no interval with tempID is present
}
@infn8
infn8 / Default (OSX).sublime-keymap
Created October 5, 2014 04:08
Sublime Text Bootstrap Shortcuts and Snippets
[
{ "keys": ["super+shift+alt+b", "super+shift+alt+o", "super+shift+alt+x"], "command": "insert_snippet", "args": {"name": "Packages/User/bcxo.sublime-snippet"}},
{ "keys": ["super+shift+alt+b", "super+shift+alt+x"], "command": "insert_snippet", "args": {"name": "Packages/User/bcx.sublime-snippet"}},
{ "keys": ["super+shift+alt+b", "super+shift+alt+o", "super+shift+alt+s"], "command": "insert_snippet", "args": {"name": "Packages/User/bcso.sublime-snippet"}},
{ "keys": ["super+shift+alt+b", "super+shift+alt+s"], "command": "insert_snippet", "args": {"name": "Packages/User/bcs.sublime-snippet"}},
{ "keys": ["super+shift+alt+b", "super+shift+alt+o", "super+shift+alt+m"], "command": "insert_snippet", "args": {"name": "Packages/User/bcmo.sublime-snippet"}},
{ "keys": ["super+shift+alt+b", "super+shift+alt+m"], "command": "insert_snippet", "args": {"name": "Packages/User/bcm.sublime-snippet"}},
{ "keys": ["super+shift+alt+b", "super+shift+alt+o", "super+shift+alt+l"], "command": "insert_snippet", "args": {"n
@infn8
infn8 / cascade_values.fn.php
Last active August 29, 2015 14:08
Pass an array of items and the first one that is not empty will be returned to you
<?php
function cascade_values(){
for ($i = 0; $i < func_num_args(); $i++) {
$val = func_get_arg($i);
if(!empty($val)){
return $val;
}
}
return false;
}
*~
/rsync*
.DS_Store
.svn
.cvs
*.bak
*.swp
Thumbs.db
.sass-cache/
*.log
@infn8
infn8 / swapDev.bookmark
Created November 11, 2014 16:22
Bookmarklet to swap between whatever.com and whatever.dev
javascript:(function(){parts = location.host.split('.'); last = parts.pop(); replace = last == 'dev' ? 'com' : 'dev'; parts.push(replace); location.host= parts.join('.'); })();
@infn8
infn8 / cc_spaces.fn.js
Created December 9, 2014 19:03
Credit Card Spaces
function cc_spaces(txt){
// rip all non digits from string
txt = txt.toString().replace(/[^\d]/g, '');
format = /(\d{1,4})/g;
// test for amex.
if (null !== txt.match(/^3[47]/)) {
format = /(\d{1,4})(\d{1,6})?(\d{1,5})?/;