Skip to content

Instantly share code, notes, and snippets.

View joshbeckman's full-sized avatar
👍

Josh Beckman joshbeckman

👍
View GitHub Profile
@joshbeckman
joshbeckman / bashGit
Last active August 29, 2015 13:57
Useful git/bash functions
git config color.status always
///////////////////////
// add to ~/.gitconfig
[alias]
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
dh = diff --color HEAD
[color]
branch = auto
diff = auto
@joshbeckman
joshbeckman / ThreeWP_Broadcast.php
Created March 19, 2014 22:09
ThreeWP Broadcast support for Amazon S3-hosted images
/** ...Continued from within file */
/**
@brief Creates a new attachment.
@details
The $o object is an extension of Broadcasting_Data and must contain:
- @i attachment_data An attachment_data object containing the attachmend info.
@param object $o Options.
@return @i int The attachment's new post ID.
@joshbeckman
joshbeckman / gist:9a0617042ecd4d76cefe
Last active August 29, 2015 14:02
Social Share count APIs
http://api.facebook.com/restserver.php?method=links.getStats&urls=http://techcrunch.com/&format=json
@joshbeckman
joshbeckman / gist:ec331f2b57ac5fc975bb
Last active August 29, 2015 14:06
Steps to install a PROD WordPress MYSQL database locally in MAMP
  • Download Sequel Pro
  • Follow their instructions on connecting to MAMP
  • Run Sequel Pro
  • Create a new database (I suggest something like dump_import_<date>)
  • Select File > Import
  • Select your sql dump file
  • Wait like 15 minutes
  • Go in and change the necessary fields (like, site_urls, paths, etc) for every site and/or blog you want to work with
  • Edit the blogs to be in all the same network/site (MAMP doesn't handle multiple domains or path installs)
  • Open up your wp-config.php file and switch out the DB_NAME value to your newly-created database
@joshbeckman
joshbeckman / gist:7e42c24f8f7bfd5b8ef6
Created September 10, 2014 19:16
Find duration of media file asynchronously in JavaScript
function getDuration(fileURL, cb){
var a = document.createElement('audio');
a.src = fileURL;
a.preload = 'metadata';
document.body.appendChild(a);
a.addEventListener('loadedmetadata', function(evt){
var d = evt.target.duration;
cb(d);
}, false);
}
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
@joshbeckman
joshbeckman / .vimrc
Last active August 29, 2015 14:07 — forked from jenikm/My vimrc
My vimrc file (and Eugene's)
execute pathogen#infect()
syntax on
set tabstop=8 softtabstop=0 expandtab shiftwidth=4 smarttab
imap ii <Esc>
au BufRead,BufNewFile *.go set filetype=go
" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
set background=dark
@joshbeckman
joshbeckman / urlParams.js
Created April 2, 2015 11:24
Assign client url params immediately on pageload
// grab url params and assign on page load
(function (window, document) {
var match,
pl = /\+/g, // Regex for replacing addition symbol with a space
search = /([^&=]+)=?([^&]*)/g,
decode = function (s) {
return decodeURIComponent(s.replace(pl, " "));
},
query = window.location.search.substring(1);
@joshbeckman
joshbeckman / .gitconfig
Last active August 29, 2015 14:18
My .gitconfig
[core]
editor = vim
[credential]
helper = cache
[alias]
co = checkout
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
st = status
s = status -sb
ci = commit -am
@joshbeckman
joshbeckman / test.js
Last active August 29, 2015 14:18
Test the CORS injection of js file...
// TEST ability to create your own divs and such
var _myDiv = document.createElement('div');
document.body.appendChild(_myDiv);
_myDiv.style.width = "50px";
_myDiv.style.height = "50px";
_myDiv.style.background = "black";
_myDiv.id = "foobar";
_myDiv.style.position = "fixed";
_myDiv.style.top = 0;