Skip to content

Instantly share code, notes, and snippets.

View alicraigmile's full-sized avatar

Ali Craigmile alicraigmile

View GitHub Profile
@alicraigmile
alicraigmile / motd.sh
Created October 22, 2014 10:58
Print my personal message of the day.
#!/bin/bash
function motd() {
echo "------------------------------------------------------------------------------"
cat ~/.motd
echo "------------------------------------------------------------------------------"
}
function vm() {
$EDITORI ~/.motd
@alicraigmile
alicraigmile / welcome.sh
Last active May 23, 2021 21:54
Say hello to me.
#!/bin/bash
#Source: https://gist.github.com/alicraigmile/cc83201e07ddc8472765
function welcome() {
HOUR=$(date +%H)
HOUR=$(expr $HOUR + 0) #fix for leading zeros
NAME=$(finger $USER |head -n1 |cut -d : -f3 | sed -e 's/^ *//' | cut -d ' ' -f1) #firstname (remove last 'cut' for full name)
if [[ $HOUR -lt 5 ]]; then
@alicraigmile
alicraigmile / reithproxies.sh
Last active August 29, 2015 14:07
Switch between BBC (Reith) Network and Direct Connection on a BBC Desktopped Mac OS X machine
#!/bin/bash
#Switch between BBC (Reith) Network and Direct Connection on a BBC Desktopped Mac OS X machine
function bbc-on-network() {
scselect "BBC On Network"
}
function bbc-off-network() {
scselect "BBC Off Network"
@alicraigmile
alicraigmile / desktop-shortcut.sh
Created October 19, 2014 21:54
Create a shortcut on the desktop to a file on the command line (MacOS X)
shortcut on desktop
desktop-shortcut() {
osascript -e "tell application \"Finder\" to make new alias file at desktop to POSIX file \"$(myreadlink $1)\""
}
@alicraigmile
alicraigmile / proxy
Created October 16, 2014 08:58
Decide which proxies to use in ssh on Mac OS X based on your current network settings.
# Usage: add 'ProxyCommand ~/.ssh/proxy %h %p' to your ~/.ssh/config file
#set -x
connect_directly() {
nc -X 5 $1 $2
}
connect_to_host_outside_the_bbc_from_within() {
nc -x "socks-gw.reith.bbc.co.uk:1085" -X 5 $1 $2
@alicraigmile
alicraigmile / gedit.sh
Created October 16, 2014 08:52
Launch TextEdit to edit documents graphically (work on MacOS X)
# Launch TextEdit to edit documents graphically
gedit() {
osascript -e "tell application \"TextEdit\" to open POSIX file \"$1\"" -e "tell application \"TextEdit\" to activate"
}
@alicraigmile
alicraigmile / trac2confluence.pl
Last active August 29, 2015 14:00
Prototype wiki markup converter - given trac format wiki code on STDIN, convert it to confluence format
#!/usr/bin/env perl
# Prototype wiki markup converter - given trac format wiki code on STDIN,
# convert it to confluence format.
#
# Last updated: 12/Jun/2008
# (c) 2008 Ali Craigmile
#
# Usage:
# cat trac-wiki-code.txt | ./trac2confluence.pl
#/bin/sh
MAXTUNER=46
i=0
while [ $i -lt $MAXTUNER ];
do
rmmod tuner saa7134 saa7134-alsa
modprobe saa7134 card=70 tuner=$i
modprobe saa7134-alsa
echo "Actual tuner is:" $i
sleep 1 # this is to make sure /dev/video is registered when tvtime starts
@alicraigmile
alicraigmile / sortpics.pl
Created April 18, 2014 18:11
Sort a folder of images and movies from your phone or digital camera into an archive folder tree (a folder per year/month)
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Std;
use constant DEFAULT_DEST => '/content/Media/Pictures';
use constant FATAL => 1;
our %opts = (); #eek - nasty hack alert!!!
On Error Resume Next
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000
Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D
Const ONE_HUNDRED_NANOSECOND = .000000100
Const SECONDS_IN_DAY = 86400
Set objADSystemInfo = CreateObject("ADSystemInfo") ' LINE 8
Set objUser = GetObject("LDAP://" & objADSystemInfo.UserName) ' LINE 9