Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex King alexkingorg

View GitHub Profile
@mrdoob
mrdoob / RequestAnimationFrame.js
Created Feb 22, 2011
Provides requestAnimationFrame in a cross browser way.
View RequestAnimationFrame.js
/**
* Provides requestAnimationFrame in a cross browser way.
* @author paulirish / http://paulirish.com/
*/
if ( !window.requestAnimationFrame ) {
window.requestAnimationFrame = ( function() {
return window.webkitRequestAnimationFrame ||
@mjangda
mjangda / wpcom-open-graph.php
Created Sep 5, 2011
Add Open Graph tags to your WordPress site
View wpcom-open-graph.php
<?php
/**
* Open Graph Tags
*
* Add Open Graph tags so that Facebook (and any other service that supports them)
* can crawl the site better and we provide a better sharing experience.
*
* @link http://ogp.me/
* @link http://developers.facebook.com/docs/opengraph/
*/
@litchfield
litchfield / doubledecode.py
Created Oct 12, 2011
Double decode utf8 and cp1252
View doubledecode.py
#!/usr/bin/env python
"""
Ever had a mysqldump of utf8 data stored in latin1 tables, dumped in utf8 and
munged with windows cp1252?
If so this is your friend. Just pipe it through this little baby and spare
yourself hours of unicode hell- it'll take your dirt and spit out clean utf8.
You can also import it and use it in your python code.
@bigdawggi
bigdawggi / README.txt
Created Oct 24, 2011 — forked from alexkingorg/wp-switch-to-post.php
switch_to_post() stack implementation (similar to switch_to_blog()) for WordPress
View README.txt
# Switch to Post README
## Overview
switch_to_post() stack implementation (similar to switch_to_blog()) for WordPress
## Questions
1. Do we want to still switch to post if the get_post fails?
2. Have a (bool) return value based on get_post?
## Test Steps
@bigdawggi
bigdawggi / Outbound Link Tracking - Google Analytics.js
Created Nov 22, 2011
jQuery-based outbound link tracking with cases for new window as well as same window locations
View Outbound Link Tracking - Google Analytics.js
@markjaquith
markjaquith / .all
Last active Oct 10, 2018
Bash stuff
View .all
for f in ~/Dropbox/bash/*; do source $f; done
@bdha
bdha / vbox_to_kvm.txt
Created Mar 1, 2012
Migrating from VirtualBox to KVM on ZFS
View vbox_to_kvm.txt
# 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
View opengraphbookmarklet.js
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;
@gordonbrander
gordonbrander / tiny-state-machine.js
Created May 25, 2012
World's Tiniest JavaScript State Machine
View tiny-state-machine.js
var StateMachine = {
// Register valid states for this object.
__states__: {
'success': ['failure'],
'failure': ['success']
},
// Set initial state.
__state__: 'success',
@evansolomon
evansolomon / gist:3568555
Created Sep 1, 2012
Bash helpers for navigating WordPress code
View gist:3568555
# 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
You can’t perform that action at this time.