Skip to content

Instantly share code, notes, and snippets.

View schallis's full-sized avatar

Steven Challis schallis

View GitHub Profile
@schallis
schallis / geoip-bookmarklet.js
Created June 25, 2010 18:50
Bookmarklet that takes a selected IP address and performs a geoip lookup.
var selection = window.getSelection();
if (/^\d+\.\d+\.\d+\.\d+$/.test(selection)) {
window.open('http://www.geoiptool.com/en/?IP=' + selection, '_blank');
}
@schallis
schallis / gist:759659
Created December 30, 2010 10:29
Grep through a \n terminated list of people and phone extensions
# Quick Bash function to lookup telephone extensions. Better if agrep is installed.
# Usage:
# $ tel steve
# 3900 - Steve Challis
# Terminal colour codes
export CYAN="\033[0;36m"
export GREEN="\033[0;32m"
PHONE_LIST='/usr/share/phone-extensions.txt'
@schallis
schallis / parents.sh
Created August 14, 2011 15:25
A Portable Bash Function to List Process Hierarchies
parents(){ :(){
read p n <<<`ps -o ppid,comm -p $1 | awk 'NR>1{print $1,$2}'`;
echo -e "$1\t$n";
test $1 -ne 0 && : $p; };
: $1; }
@schallis
schallis / apod.sh
Created August 14, 2011 15:35
Automatically download NASA Astronomy Pictures of the Day
# Download the latest pic of the day from NASA and delete or archive any
# previous ones in a specified directory. Optionally create a copy of the most
# current picture to allow OSX to pick up pictures as wallpapers
#
# Steve Challis 2011
# http://schallis.com/2011/mar/20/nasa-astronomy-picture-of-the-day-background/
DEST=`dirname $0`
NAME='img.jpg'
NAME_COPY='imgcopy.jpg'
@schallis
schallis / gist:1206332
Created September 9, 2011 14:15
PIL compose thumbnail images
import Image
SPACING = 10
# Open source images
imgs = map(Image.open, ['1.gif', '2.gif', '3.gif', '4.gif'])
# Assume standard dimensions and store them
width, height = imgs[0].size
side_length = sqrt(len(imgs))
@schallis
schallis / gist:2705714
Created May 15, 2012 22:44
Check keychain status
export RED="\033[0;31m"
export NO_COLOUR="\033[0m"
function check_keys() {
ssh-add -l >/dev/null
if [ $? -gt 0 ]
then
echo -en $RED
echo "You should add your key to the keychain"
echo -en $NO_COLOUR
@schallis
schallis / gist:3295572
Created August 8, 2012 14:46
Git aliases
[alias]
co = checkout
st = status
cm = commit
sm = submodule
lg = log --color --graph --pretty=tformat:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
post_to_slack() {
USERNAME="<username>"
CHANNEL="<channel>"
MESSAGE="$1"
PAYLOAD="payload={\"channel\": \"$CHANNEL\", \"username\": \"$USERNAME\", \"text\": \"$MESSAGE\"}"
SLACK_URL=<webhook_url>
curl -X POST --data-urlencode "$PAYLOAD" $SLACK_URL
}
FROM google/dart
ADD ./dart-sass-1.62.0-linux-x64.tar /opt/
WORKDIR /opt/dart-sass
ENTRYPOINT ["/opt/dart-sass/sass", "--watch", "/css"]