Skip to content

Instantly share code, notes, and snippets.

View joshwnj's full-sized avatar

Josh Johnston joshwnj

View GitHub Profile
@joshwnj
joshwnj / gist:1089055
Created July 18, 2011 09:53
Setting up heroized locally
For apache virtualhost you just need something simple like this:
<VirtualHost *:80>
ServerName heroized
DocumentRoot /vagrant/heroized
<Directory /vagrant/heroized>
Options Indexes FollowSymLinks
AllowOverride all
</Directory>
@joshwnj
joshwnj / duration.php
Created January 30, 2012 22:27
Creating ISO 8601 durations
<?php
$parts = secondsToDuration(61);
assert($parts['hours'] === 0);
assert($parts['minutes'] === 1);
assert($parts['seconds'] === 1);
assert('PT0H1M1S' === formatDuration($parts));
$parts = secondsToDuration(7202);
assert($parts['hours'] === 2);
@joshwnj
joshwnj / gist:1813347
Created February 13, 2012 03:38
filterstat
#!/bin/bash
# Wrapper for "svn status". Shows only files matching the filter
# Usage: filterstat [?CMAI]
#
# source: http://subversion.tigris.org/faq.html#switch-problems
filter=$1
svn status --no-ignore | grep ^[${filter}] | sed s/^[${filter}]//
@joshwnj
joshwnj / files-to-update.sh
Created March 21, 2012 15:08
get a list of filenames that will be modified when you update
#!/bin/sh
svn st -u | grep '*' | sed -E 's/^.*[\*].*[0-9 ]+//'
@joshwnj
joshwnj / files-from-month.sh
Created May 21, 2012 22:17
give me a list of files from the month of May 2011
## give me a list of files from the month of May 2011
ls -laht --color=never | egrep 'May[ ]+[0-9]+[ ]+2011(.*)' | sed 's/.*2011 / /'
## move them to a separate directory
mkdir may-2011; ls -laht --color=never | egrep 'May[ ]+[0-9]+[ ]+2011(.*)' | sed 's/.*2011 / /' | xargs -I {} mv {} may-2011/
;; turn line numbers off by default
(global-linum-mode -1)
(defun goto-line-with-feedback (&optional line)
"Show line numbers temporarily, while prompting for the line number input"
(interactive "P")
(if line
(goto-line line)
(progn
(linum-mode 1)
@joshwnj
joshwnj / nav.html
Created September 6, 2012 09:04
Create a select element from a bunch of links
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<select id="nav-select"></select>
<nav id="nav" class="nav" role="navigation">
@joshwnj
joshwnj / .osx
Created December 18, 2012 10:07
## source: https://github.com/hij1nx/dotfiles/blob/master/.osx
# Enable the 2D Dock
defaults write com.apple.dock no-glass -bool true
# Automatically hide and show the Dock
defaults write com.apple.dock autohide -bool true
# Make Dock icons of hidden applications translucent
defaults write com.apple.dock showhidden -bool true
####
## path
export PATH='$HOME/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/usr/local/share/npm/bin'
####
## bash
alias ll='ls -halG'
@joshwnj
joshwnj / UrlShortener.php
Created February 14, 2013 09:21
using the bitly api
<?php
class UrlShortener {
const API_URL = 'http://api.bitly.com/v3/shorten';
private $_config;
function __construct ($config) {
$this->_config = $config;
}