Skip to content

Instantly share code, notes, and snippets.

View kevinkirkup's full-sized avatar

Kevin S Kirkup kevinkirkup

  • Digital Realty Trust
  • Raleigh, NC
View GitHub Profile
@kevinkirkup
kevinkirkup / gist:245183
Created November 30, 2009 01:23
Bash function to extract and type of archive
############################################################
# Function to extract archives
function extract() {
case $1 in
*.tar.bz2) tar xjvf "$1" ;;
*.tar.gz) tar xvzf "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.gz) gunzip "$1" ;;
*.tar) tar xvf "$1" ;;
*.tbz2) tar xjvf "$1" ;;
@kevinkirkup
kevinkirkup / gist:245184
Created November 30, 2009 01:24
Bash function to grep the process list
############################################################
# Function to grep the list of precesses
function grep_process() {
if [ ! -z "$1" ] ; then
ps aux | grep -i "$1" | grep -v grep
else
echo "Need a process name to grep processes for..."
fi
}
@kevinkirkup
kevinkirkup / gist:245186
Created November 30, 2009 01:26
Bash function to grep the command history
############################################################
# Function to grep the command history
function grep_history() {
if [ ! -z "$1" ] ; then
history | grep "$1" | grep -v histg
else
echo "Need a command to grep history for..."
fi
}
alias chg='grep_history'
@kevinkirkup
kevinkirkup / gist:245187
Created November 30, 2009 01:27
Dynamically set the path to VIM
# Get Vim Path
export VIMRUNTIME=`vim -e -T dumb --cmd 'exe "set t_cm=\<C-M>"|echo $VIMRUNTIME|quit' | tr -d '\015' `
@kevinkirkup
kevinkirkup / kevin2.vim
Created November 30, 2009 01:35
Kevin2 VIM syntax color file
" Vim color file
" Maintainer: Kevin S Kirkup <kevin.kirkup@gmail.com>
" Last Change: 2005 Feb 27
" This color scheme uses a black background.
" First remove all existing highlighting.
set background=dark
highlight clear
@kevinkirkup
kevinkirkup / bblean.vim
Created November 30, 2009 01:37
bblean vim syntax highlighter
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Filename: bblean.vim
" Purpose: Vim syntax file for bblen resource files
" Language: bblean *.rc files
" Maintainer; Kevin S Kirkup kevin.kirkup@sonyericsson.com
" URL:
" Last Update: Sat 11/19/2005
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"-----------------------------------------------------------
@kevinkirkup
kevinkirkup / COM String Utilities
Created April 1, 2011 16:15
Utilities to convert from C++ basic types to COM String Types
#include <comutil.h>
_com_util::ConvertBSTRToString("")
_com_util::ConvertStringToBSTR("");
@kevinkirkup
kevinkirkup / COM Return Array of Strings
Created April 1, 2011 16:18
COM Method implementation to return an array of strings
STDMETHODIMP CMyClass::GetThings(VARIANT* returnThings)
{
HRESULT hr = S_OK;
SAFEARRAY FAR* safeArray;
SAFEARRAYBOUND safeArrayBound;
if (m_thing != NULL)
{
std::set<const char *>::iterator it;
std::set<const char *> things = m_thing->GetThings();
@kevinkirkup
kevinkirkup / gist:1266475
Created October 6, 2011 03:59
Applescript Trim Subroutine
(*
A sub-routine for trimming unwanted characters from strings.
Taken from http://www.macosxautomation.com
*)
on trim_line(this_text, trim_chars, trim_indicator)
-- 0 = beginning, 1 = end, 2 = both
set x to the length of the trim_chars
-- TRIM BEGINNING
if the trim_indicator is in {0, 2} then
repeat while this_text begins with the trim_chars
@kevinkirkup
kevinkirkup / gist:2029043
Created March 13, 2012 14:16
jQuery Async Script loading
//
// Dynamically generate the html script tag to prevent
// blocking the parser.
// http://css-tricks.com/thinking-async/
//
jQuery.ajax({
url: '//third-party.com/resource.js',
dataType: 'script',
success: function() {
// script loaded, do stuff!