Skip to content

Instantly share code, notes, and snippets.

View austinjreilly's full-sized avatar

Austin J. Reilly austinjreilly

View GitHub Profile
@austinjreilly
austinjreilly / chrome-different-tz.sh
Last active March 1, 2018 14:06 — forked from c0mpiler/chrome-different-tz.sh
Open chrome with a spoofed timezone set
#!/usr/bin/env bash
# chrome-different-tz
#
# Use this script on OS X to launch a new instance of Google Chrome
# with its own empty cache, cookies, and user configuration.
#
# The first time you run this script, it will launch a new Google
# Chrome instance with a permanent user-data directory, which you can
# customize below. Perform any initial setup you want to keep on every
@austinjreilly
austinjreilly / sort-array.php
Created August 4, 2014 14:56
Sort Multi-Dimensional Array By Value In PHP
<?php
/**
* Sort Multi Dimensional Array by value in PHP
*
* @link http://www.paulund.co.uk/sort-multi-dimensional-array-value
*/
// Original array
Array
(
@austinjreilly
austinjreilly / Gruntfile.js
Created May 22, 2014 21:28
Basic Grunt/Sass Setup
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
build: {
src: 'js/scripts.js',
dest: 'js/scripts.min.js'
}
@austinjreilly
austinjreilly / post_type_rewrite_slug.php
Last active August 29, 2015 14:00
Gets rewrite slug for custom post type.
$postTypeObject = get_post_type_object( $postType );
$rewriteSlug = $postTypeObject->rewrite['slug'];
$linkPrefix = home_url() . '/' . $rewriteSlug . '/';
@austinjreilly
austinjreilly / person_list.php
Created February 28, 2014 02:03
Takes array of people and outputs a single name, 2 names separated by an ampersand, or 3 or more names separated by a comma and the last one by an ampersand
function person_list( $personArray ) {
$personCount = count( $personArray );
for ( $i = 0; $i < $personCount; $i++ ) {
$name = $personArray[$i]['name'];
$personHTML .= "<span class=\"name\">{$name}";
if ( $personCount == 2 ){
if ( $i < ($personCount - 1 ) ) {
$personHTML .= " &amp; ";
@austinjreilly
austinjreilly / top_terms.php
Created February 26, 2014 16:56
Generates list of most popular terms
//Adapted from http://wpsnipp.com/index.php/tags/show-most-used-tags-in-list/
function top_terms( $termName ){
$terms = get_terms( $termName );
$counts = $termLinks = array();
foreach ( $terms as $term ){
$counts[$term->name] = $term->count;
$termLinksArray[$term->name] = get_term_link( $term );
}
asort( $counts );

Make it useful

  • Install Package Control. For SublimeText 2, paste the following in Terminal:
import urllib2,os; pf='Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler( ))); open( os.path.join( ipp, pf), 'wb' ).write( urllib2.urlopen( 'http://sublime.wbond.net/' +pf.replace( ' ','%20' )).read()); print( 'Please restart Sublime Text to finish installation')

From here on out, use Package Control to install everything. +Shift+P, then type Install to get a list of installable packages you can 'livesearch through. After installing plugins, they should be running.

@austinjreilly
austinjreilly / switchenv.sh
Last active August 29, 2015 13:56
Shell function that allows users of the University of Texas Web Central to quickly toggle between test and live environments.
function switchenv(){
TEST="/export/httpd/vhosts/wwwtest/data/law"
PROD="/export/bulk/law"
CURRENTDIR=$(pwd -P)
if [[ "$CURRENTDIR" == *"$TEST"* ]]
then
#In test, so remove test prefix and replace with prod prefix
NEWDIR=${CURRENTDIR/$TEST/$PROD}