Skip to content

Instantly share code, notes, and snippets.

Ian Gilham igilham

View GitHub Profile
@igilham
igilham / find-spec-versions.sh
Created Sep 18, 2014
Find RPM spec versions in projects below current directory
View find-spec-versions.sh
cd $WORKSPACE/dcable-rpms/
svn up ./*
find . -iname '**.spec' | xargs grep -i '^Version' | sed -e 's_./.*/SPECS/__' -e 's/\.spec//' -e 's/Version://'
@igilham
igilham / CMakeLists.txt
Last active Aug 29, 2015
CMake Template
View CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project(mylib C CXX)
# TODO: in cmake 3.2, we can set the version without making new variables
# project(asimux VERSION "1.0.0" C CXX)
set(VERSION_MAJOR "1")
set(VERSION_MINOR "0")
set(VERSION_PATCH "0")
set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
@igilham
igilham / test-urls.sh
Last active Aug 29, 2015
Test if a list of files (URLS) exist on a web server
View test-urls.sh
#!/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}"
@igilham
igilham / proxy
Created Oct 3, 2014
Enable/Disable proxy settings defined elsewhere
View proxy
#!/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 / update-java.sh
Created Nov 4, 2014
Update Java Version on Mac OS X
View update-java.sh
#!/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/
View relink-java-binaries.sh
@igilham
igilham / CMakeLists.txt
Created Dec 9, 2014
CMake add_sources Macro
View CMakeLists.txt
set(SRCS "")
macro (add_sources)
foreach (_src ${ARGN})
if (_relPath)
list (APPEND SRCS "${_src}")
else()
list (APPEND SRCS "${_src}")
endif()
endforeach()
@igilham
igilham / opencaster-pauser.py
Created Jan 16, 2015
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.
View opencaster-pauser.py
#!/usr/local/bin/env python
import signal
import sys
packet_size = 188
position = 0
paused = False
def pause_handler(signal, frame):
@igilham
igilham / git-migrate.sh
Created Feb 27, 2015
Migrate a file with history from one Git repo to another
View git-migrate.sh
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 / randline-1-liner.py
Created Jan 5, 2011
read a random line from a file
View randline-1-liner.py
import random
print(random.choice([line for line in open('oblique.txt')]))
You can’t perform that action at this time.