Skip to content

Instantly share code, notes, and snippets.

View DerekK19's full-sized avatar

Derek Knight DerekK19

View GitHub Profile
@DerekK19
DerekK19 / deploy.rb
Created August 23, 2013 02:26
Sample Capistrano deploy file. Noteworthy since it has no source code control, but also has default quiet running and customised progress messages (credit to http://jondavidjohn.com/blog/2012/04/cleaning-up-capistrano-deployment-output#comment-5861)
require "rvm/capistrano"
require "capistrano/ext/multistage"
require "colored"
logger.level = Logger::IMPORTANT # make capistrano quiet by default!
STDOUT.sync
before "deploy:update_code" do
print "Updating Code........"
start_spinner()
@DerekK19
DerekK19 / gist:6273700
Created August 19, 2013 20:27
Run Apache from a command line
# If apache isnt starting, Try this to help debug:
sudo bash -x /usr/sbin/apachectl -k start
@DerekK19
DerekK19 / gist:6259046
Created August 17, 2013 22:42
Set Mac OSX machine name
# for example Name with capital is "Derekmac" and fully qualified lower case name is "derekmac.derek.domain.com"
sudo scutil --set ComputerName <Name with capital>
sudo scutil --set LocalHostName <Name with capital>
sudo scutil --set HostName <fully qualified lower case name>
dscacheutil -flushcache
@DerekK19
DerekK19 / .motd
Last active February 21, 2017 04:51
Raspberry Pi MOTD script (includes stuff like weather, IP address)
let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
let secs=$((${upSeconds}%60))
let mins=$((${upSeconds}/60%60))
let hours=$((${upSeconds}/3600%24))
let days=$((${upSeconds}/86400))
UPTIME=`printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs"`
WEATHER=`curl -s "http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=OCN|NZ|NZ130|DEVONPORT|" | sed -n '/Currently:/ s/.*: \(.*\): \([0-9]*\)\([CF]\).*/\2\3, \1/p'`
IP=`/sbin/ifconfig | /bin/grep "192.168" | /usr/bin/cut -d ":" -f 2 | /usr/bin/cut -d " " -f 1`
# get the load averages
@DerekK19
DerekK19 / Xcode select
Created August 9, 2013 02:48
Xcode select, to set path for command line tools
sudo xcode-select --switch /Applications/<insert Xcode app path here>/Contents/Developer
@DerekK19
DerekK19 / .bash_aliases
Last active December 20, 2015 17:58
OSX bash aliases
alias emal="emacs ~/.bash_aliases"
alias doal=". ~/.bash_aliases"
alias dosh=". ~/.bashrc"
alias cd..="cd .."
alias rgrep="grep -r"
alias cls='tput clear'
alias ls='CLICOLOR_FORCE=1 ls -G'
alias less='less -R'
@DerekK19
DerekK19 / launch-slave
Created April 3, 2013 05:40
Daemon processes to run Jenkins. This is the only configuration I have found that works: A Daemon config file (plist) will run as root and will launch a shell script. That shell script runs a second shell script as the _jenkins user. This configuration ensures that the launch-slave script is running as the _jenkins user and has got a correct run…
#!/bin/bash
LOG=/Developer/jenkins/logs/slave.log
sudo rm -f $LOG
date >$LOG
chmod 777 $LOG
echo ============================= >> $LOG
echo whoami >> $LOG
@DerekK19
DerekK19 / gist:5235935
Created March 25, 2013 09:21
Create a user and account to use when running a daemon
MyMac:~ myuser$ sudo dscl
Password: (your password)
Entering interactive mode... (type "help" for commands)
> cd /Local/Default/
/Local/Default >
/Local/Default > ls Groups gid
@DerekK19
DerekK19 / doxygen end section
Last active October 11, 2015 12:08
XCode Doxygen section terminator
/** @} */
@DerekK19
DerekK19 / doxygen start section
Last active October 11, 2015 12:07
XCode Doxygen interface section header
/**
@interface <#Interface#>
@addtogroup <#Group#>
@{
*/
/**
@brief <#Brief description#>
<#Full description#>