Skip to content

Instantly share code, notes, and snippets.

View igilham's full-sized avatar

Ian Gilham igilham

View GitHub Profile
@igilham
igilham / find-spec-versions.sh
Created September 18, 2014 13:07
Find RPM spec versions in projects below current directory
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 August 29, 2015 14:06
CMake Template
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 / insert-seq-nested-query-oracle.sql
Created January 5, 2011 16:11
Insert using a sequence in a nested query in Oracle Database
CREATE SEQUENCE cid_seq
START WITH 100
INCREMENT BY 1;
CREATE OR REPLACE FUNCTION get_next_cseq
RETURN NUMBER AS l_return NUMBER;
BEGIN
SELECT cid_seq.NEXTVAL INTO l_return FROM DUAL;
RETURN l_return;
END;
@igilham
igilham / randline.py
Created January 5, 2011 16:09
Read a random line from a file
#!/usr/bin/env python
import os
import random
import sys
def randline(fname):
result = ''
if os.path.exists(fname):
result = random.choice([line for line in open(fname)])
return result
@igilham
igilham / randline-1-liner.py
Created January 5, 2011 16:07
read a random line from a file
import random
print(random.choice([line for line in open('oblique.txt')]))
@igilham
igilham / randline.sh
Created January 5, 2011 16:05
Read a random line from a text file
shuf -n 1 oblique.txt
# or
rl -c 1 oblique.txt
# or
sed -n $((RANDOM%$(wc -l < leader.txt)+1))p oblique.txt