Skip to content

Instantly share code, notes, and snippets.

View igilham's full-sized avatar

Ian Gilham igilham

View GitHub Profile
@igilham
igilham / .profile
Last active September 28, 2015 14:52
profile
#!/bin/bash
# Profile for Mac OS X systems
# Proxy setup ----------------------------------------------------------
export PROXY_HOST=www-proxy.example.com
export PROXY_PORT=80
function proxy_reset() {
if [ "$1" = "MyCompany On Network" ]; then
@igilham
igilham / git-migrate.sh
Created February 27, 2015 17:06
Migrate a file with history from one Git repo to another
cd repository
git log --pretty=email --patch-with-stat --reverse --full-index --binary -- path/to/file_or_folder > patch
cd ../another_repository
git am < ../repository/patch
@igilham
igilham / yiq-color-balance.py
Last active November 14, 2019 11:32
Works out the YIQ values of a given RGB colour and suggests a pallet of similar colours with the same chrominance. This can be used on legacy TV platforms to reduce chroma crawl, where colours bleed into each other.
#!/usr/bin/env python
import sys
def rgb2Yiq(red, green, blue):
y = int((0.299 * red) + (0.587 * green) + (0.114 * blue))
i = int((0.596 * red) - (0.275 * green) - (0.321 * blue))
q = int((0.212 * red) - (0.528 * green) + (0.311 * blue))
return (y, i, q)
@igilham
igilham / opencaster-pauser.py
Created January 16, 2015 13:23
An untested experimental program to stream files one packet at a time, with a pause feature. This will certainly be very slow if it works at all.
#!/usr/local/bin/env python
import signal
import sys
packet_size = 188
position = 0
paused = False
def pause_handler(signal, frame):
@igilham
igilham / CMakeLists.txt
Created December 9, 2014 12:42
CMake add_sources Macro
set(SRCS "")
macro (add_sources)
foreach (_src ${ARGN})
if (_relPath)
list (APPEND SRCS "${_src}")
else()
list (APPEND SRCS "${_src}")
endif()
endforeach()
@igilham
igilham / relink-java-binaries.sh
Created November 10, 2014 11:27
Relink Java binaries
@igilham
igilham / update-java.sh
Created November 4, 2014 13:10
Update Java Version on Mac OS X
#!/bin/sh
# assuming you just installed Oracle JDK7 in '/Library/Java/JavaVirtualMachines/jdk1.7.0_72.jdk'
cd /System/Library/Frameworks/JavaVM.framework/Versions
sudo mv CurrentJDK JDK6
# the version number must match the installed version
sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_72.jdk /Library/Java/JavaVirtualMachines/jdk1.7.0
sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0/Contents JDK7
sudo ln -s JDK7 CurrentJDK
sudo cp -r JDK6/Commands JDK7/
@igilham
igilham / proxy
Created October 3, 2014 16:23
Enable/Disable proxy settings defined elsewhere
#!/bin/bash
# Toggle proxy settings.
# It will be necessary to reload ${HOME}/.profile after running this.
USAGE="usage: ${0} on|off|status"
if [[ "d${PROXY_FILE}d" == "dd" ]]; then
echo "PROXY_FILE undefined" >&2
exit 1
fi
@igilham
igilham / setup-mac.sh
Created October 3, 2014 15:49
Automate setting up software from a fresh install on Mac OS X
#!/bin/sh
# mac setup automation script based on
# http://lapwinglabs.com/blog/hacker-guide-to-setting-up-your-mac
# Check for Homebrew,
# Install if we don't have it
if test ! $(which brew); then
echo "Installing homebrew..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@igilham
igilham / test-urls.sh
Last active February 22, 2024 15:54
Test if a list of files (URLS) exist on a web server
#!/bin/bash
# List missing files from a web server. Missing means we get a non-200 response.
BASE="http://www.example.com"
FILES="index.html
about.html"
for ITEM in ${FILES}; do
URL="${BASE}/${ITEM}"