Skip to content

Instantly share code, notes, and snippets.

@bigdawggi
bigdawggi / mailtrap-filter.php
Last active June 3, 2019 19:11
Mailtrap filter for WordPress
/**
* Routes all email from WP installation to specific Mailtrap
* account inbox.
*
* All you need to do is change the "Username" and "Password"
* settings to the appropriate box in Mailtrap. Then all
* mail **should** be routed to that box. Exceptions would
* be other functionality that overwrite the wp_mail() functions
* and may not use this filter, or other filters that change
* this behavior after we set it, or millions of other things.
@koop
koop / gallery.js
Created December 3, 2012 01:46
Query all attachments uploaded to a post.
@gordonbrander
gordonbrander / derp-modules.js
Created October 9, 2012 22:06
Simple, tiny, dumb JavaScript Modules
// Simple, tiny, dumb module definitions for Browser JavaScript.
//
// What it does:
//
// * Tiny enough to include anywhere. Intended as a shim for delivering
// browser builds of your library to folks who don't want to use script loaders.
// * Exports modules to `__modules__`, a namespace on the global object.
// This is an improvement over typical browser code, which pollutes the
// global object.
// * Prettier and more robust than the
@dougalcampbell
dougalcampbell / uploadables.php
Created September 28, 2012 03:36
WordPress snippet: add uploadable file types
/**
* Add uploadable mime types / file extensions
*/
function dc_add_uploadables($arr = array()) {
$new = array(
// Add file extension => mime type mapping here
'keynote|key' => 'application/vnd.apple.keynote',
'numbers' => 'application/vnd.apple.numbers',
'pages' => 'application/vnd.apple.pages'
);
@evansolomon
evansolomon / gist:3568555
Created September 1, 2012 09:53
Bash helpers for navigating WordPress code
# Alias ST2's command line tool for a shorter (easier-to-remember) name
alias st="/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl"
# Search for an open Sublime Text to a function definition
function fx() {
ack "function &?$1\(" | awk {'print $1'} | sed 's/:$//g' | xargs st
}
# Example usage from the root of a WordPress repository
@gordonbrander
gordonbrander / tiny-state-machine.js
Created May 25, 2012 17:01
World's Tiniest JavaScript State Machine
var StateMachine = {
// Register valid states for this object.
__states__: {
'success': ['failure'],
'failure': ['success']
},
// Set initial state.
__state__: 'success',
@dougalcampbell
dougalcampbell / opengraphbookmarklet.js
Last active April 8, 2019 20:23
OpenGraph Bookmarklet
javascript:$=jQuery;if(0!==$("#myogdiv").length)$("#myogdiv").hide().remove();else{var%20myogdiv=$('<div%20id="myogdiv"/>');$("body").append(myogdiv);$('head%20meta[property^="og:"],head%20meta[property^="fb:"],head%20meta[name^="twitter:"]').each(function(d,b){var%20a=$(b).attr("property"),c=$(b).attr("content");void%200==a&&(a=$(b).attr("name"));$(myogdiv).append("<div><b>"+a+":</b>"+c+"</div>");"og:image"==a&&$(myogdiv).append('<br/><img%20src="'+c+'"%20style="max-width:250px"/>');"twitter:image"==a&&$(myogdiv).append('<br/><img%20src="'+c+'"%20style="max-width:250px"/>')});$(myogdiv).css("position","absolute").css("top","0").css("zIndex",9999999).css("padding","0.5em").css("border","1px%20solid%20red").css("backgroundColor","white")}void%200;
@bdha
bdha / vbox_to_kvm.txt
Created March 1, 2012 04:04
Migrating from VirtualBox to KVM on ZFS
# It's important to convert the vbox image (VMDK or VDI or whatever) using
# the same version of VirtualBox that created it. You can try converting the image
# with qemu-img or kvm-img, but weird version mismatches will possibly make it not
# work.
# On your VirtualBox machine:
cd $VBOX_ROOT/$MACHINE_ROOT/
VBoxManage clonehd machine.vmdk machine.img --format RAW
scp machine.img root@kvm-host:/somewhere
@markjaquith
markjaquith / .all
Last active October 10, 2018 15:38
Bash stuff
for f in ~/Dropbox/bash/*; do source $f; done
@bigdawggi
bigdawggi / Outbound Link Tracking - Google Analytics.js
Created November 22, 2011 23:02
jQuery-based outbound link tracking with cases for new window as well as same window locations