Skip to content

Instantly share code, notes, and snippets.

View chris-erickson's full-sized avatar

Chris Erickson chris-erickson

View GitHub Profile
@chris-erickson
chris-erickson / SingletonClass.h
Created June 9, 2013 23:04
This is a preferred way to set up a singleton.
#import <Foundation/Foundation.h>
@interface SingletonClass : NSObject
{
}
// Properties of the singleton
+(SingletonClass *)sharedSingleton;
@chris-erickson
chris-erickson / days_until.sh
Created July 29, 2013 16:37
Using the terminal, determine number of days until some future date.
echo $(expr '(' $(date -j 05252013 +%s) - $(date +%s) ')' / 86400) "days until graduation"
@chris-erickson
chris-erickson / LaunchSublime.sh
Last active December 20, 2015 20:59
Set up terminal to launch Sublime using 'sublime <filename>' From: https://gist.github.com/olivierlacan/1195304
echo "alias sublime='/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl'" >> ~/.bash_profile
# Restart Terminal or:
source ~/.bash_profile
@chris-erickson
chris-erickson / ls_color.sh
Last active December 20, 2015 21:19
Re-map ls so that directories are colored.
echo "alias ls='ls -Gfh'" >> ~/.bash_profile
# Restart Terminal or:
source ~/.bash_profile
@chris-erickson
chris-erickson / filesizes.sh
Created August 21, 2013 17:29
Do a file size analysis from the command line. This is recursive for all directories contained in the specified.
sudo du -sch <directory>*
<?
php error_reporting(E_ALL);
ini_set('display_errors', True);
@chris-erickson
chris-erickson / bashrc.sh
Created August 29, 2013 21:53
Make ssh prompts a bit more helpful - show the more informative hostname. These usually would default to something a bit more cryptic like cerickson@ln417 ~: $, as indicated by SERVER_NAME_HERE. (Note: this is for Ubuntu, generally)
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
@chris-erickson
chris-erickson / millertime
Last active November 7, 2015 21:42
A helper to notify you when you have brews ready to update
#!/bin/bash
# This script runs the homebrew updater, then reports if any of your packages are out of date
# Generally, this should be run automatically using a launchctl task (see end of file for an example)
#
# In addition, you might want to change the notification style to be an "alert" so it hangs around a while.
# This can be done in System Preferences -> Notification Center (look for homebrew-notifier)
#
# Requires:
# - Homebrew
# - terminal-notifier (brew install terminal-notifier)
@chris-erickson
chris-erickson / gist:18d2dffe5d88ae7de222
Created June 5, 2014 14:30
A helper to run the homebrew updater
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.zerowidth.launched.homebrew_updater</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
@chris-erickson
chris-erickson / get-jira-branchname.js
Last active August 29, 2015 14:25
Something dumb to make getting JIRA branchnames faster.
var selectedIssue = document.querySelectorAll(".ghx-selected")[0];
var key = selectedIssue.dataset.issueKey;
var description = selectedIssue.childNodes[0].childNodes[0].childNodes[2].title;
var text = key + '-' + description;
var MAX_LENGTH = 35;
var slug = text.replace(/\s+/g, '-').replace(/[^\w\-]+/g, '').replace(/\-\-+/g, '-').replace(/^-+/, '').replace(/-+$/, '').substring(0, MAX_LENGTH);
window.prompt("Copy this!", 'git checkout -b \'' + slug + '\'');