Skip to content

Instantly share code, notes, and snippets.

View joshbeckman's full-sized avatar
👍

Josh Beckman joshbeckman

👍
View GitHub Profile
@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 / .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
#!/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 / 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);
}
@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: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 / 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 / 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 / tags.html
Created January 22, 2014 13:31
Meta/link tags necessary to make mobile devices correctly display responsive and mobile-optimized sites.
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-type" /><!-- speak the same language -->
<meta content="width=device-width, initial-scale=1" name="viewport" /><!-- correctly relate screen size to CSS -->
<meta name="HandheldFriendly" content="true" /><!-- BlackBerry, please don't f*** with my page -->
<meta name="apple-mobile-web-app-capable" content="yes"><!-- iPhone save-to-home-screen-able -->
<link rel="icon" href="/images/favicon.png"><!-- bookmarking/favoriting image -->
<meta name="msapplication-TileColor" content="#ffffff"/><!-- Windows 8/Windows phone -->
<meta name="msapplication-TileImage" content="/images/favicon.png"/><!-- Windows 8/Windows phone -->
(function(window, document, _){
_.mixin({
'asyncRequest': asyncRequest,
'doJSONP': doJSONP,
'request': request,
'onResize': on_resize,
'scrollTo': scrollTo,
'create': create,
'onWake': onWake,
'randColor': getRandomColor,