Skip to content

Instantly share code, notes, and snippets.

@colby
colby / gist:657791
Created November 1, 2010 07:41
Connects to simpledesktops.com and grabs a random image to assign as your profiles desktop image.
import random
import urllib
import urllib2
import tempfile
import subprocess
from appscript import app, mactypes
import lxml.html as lh
url = "http://simpledesktops.com/browse/"
random_page = str(random.randint(1,20))
@colby
colby / Time tracking bash function
Last active August 29, 2015 13:57
A simple function for your bashrc to track time into a dotfile.
now() {
$file="$HOME/.now"
if [[ -z $@ ]]; then
today="$(date "+%Y-%m-%d")"
grep --color=never $today $file | cut -d' ' -f2-
else
stamp="$(date "+%Y-%m-%d %H:%M:%S")"
echo $stamp - "$@" >> $file
fi
}
@colby
colby / ee-perms.sh
Created July 7, 2014 23:58
A small bash script to set the required permissions for an ExpressionEngine installation.
#!/usr/bin/env bash
pushd /var/www/html/
# Set default permissions
find . -type d -exec chmod 755 '{}' ';'
find . -type f -exec chmod 644 '{}' ';'
# Set directories permissions
ee_dirs=(
@colby
colby / gist:b324ff13b96d03e37976
Created July 16, 2014 18:55
Simple deploy script
#!/bin/bash
usage()
{
cat << EOF
usage: $0 ENV OPTIONS
This script will deploy to the host host.
ENVIRONMENTS:
@colby
colby / -
Created August 7, 2014 20:56
# Dynamically generated file dropped off by Chef!
fs.file-max=131072
kernel.shmall=32768
kernel.shmmax=536870912
net.core.netdev_max_backlog=4096
net.core.optmem_max=25165824
net.core.rmem_default=25165824
net.core.rmem_max=25165824
net.core.somaxconn=4096
@colby
colby / 10-work_related.sh
Last active August 29, 2015 14:11
Lunch time script and time tracker function
@colby
colby / .git_bashrc.sh
Created January 9, 2015 00:45
Big dumb prompt for .bashrc
RESTORE='\[\033[0m\]'
RED='\[\033[00;31m\]'
GREEN='\[\033[00;32m\]'
YELLOW='\[\033[00;33m\]'
PURPLE='\[\033[00;35m\]'
GRAY='\[\033[00;37m\]'
# Normal user is purple, root is red.
if [ "$(id -u)" == '0' ]; then
USER_COLOR=$RED
# save last status
PROMPT_COMMAND='export last_status=$?'
PS1="\n\u@\H:\w\$(git_prompt)\n\$(last_status)\$ "
# only show status when non zero
function last_status {
if [ $last_status -gt 0 ]; then
echo $last_status
fi
@colby
colby / rdio.sh
Last active August 29, 2015 14:13
A bash script to find the first HD video that matches the current Rdio song playing.
#!/usr/bin/env bash
if ! pgrep -q Rdio
then
echo "Error: Rdio is not running"; exit 1
fi
function check {
which "$1" || echo "Missing dep: $1"; exit 1
}
@colby
colby / imgur.sh
Last active August 29, 2015 14:14
Imgur bash function to upload images
# Note: uses some random ClientID for authentication, does not handle errors
# Usage: $ imgur ~/Desktop/oleg.png
function imgur {
[ $# -lt 1 ] && echo "imgur: requires an image file path" && exit 1
curl -sH "Authorization: Client-ID 3e7a4deb7ac67da" -F "image=@$1" "https://api.imgur.com/3/upload" | grep -oE "http:.*\.[a-z]{3,4}" | tr -d '\'
}