Skip to content

Instantly share code, notes, and snippets.

View robatwilliams's full-sized avatar

Robat Williams robatwilliams

View GitHub Profile
@robatwilliams
robatwilliams / .bashrc
Last active August 19, 2020 13:38
Auto-launching ssh-agent for GitHub on Git Bash in Windows. Minor modification from what's given at https://help.github.com/articles/working-with-ssh-key-passphrases
SSH_ENV="$HOME/.ssh/environment"
# start the ssh-agent
function start_agent {
echo "Initializing new SSH agent..."
# spawn ssh-agent
ssh-agent | sed 's/^echo/#echo/' > "$SSH_ENV"
echo succeeded
chmod 600 "$SSH_ENV"
. "$SSH_ENV" > /dev/null
@robatwilliams
robatwilliams / require.intellisense.js
Last active February 12, 2024 00:02
Hacking require.intellisense.js so that Intellisense still works in modules that also have text resources loaded via the text plugin.
/// <reference path="require.js" />
!function (window) {
var defines = [],
moduleUrls = [],
oldDefine = window.define,
oldRequire = window.require,
oldLoad = requirejs.load;
var loadEvent = document.createEvent("event");
@robatwilliams
robatwilliams / gist:4318604
Created December 17, 2012 14:17
Send commands to an interactive program (e.g. ftp / lftp) from a shell script
lftp hostname <<SCRIPT
put ~/myfile.txt
quit
SCRIPT
echo "now carry on with script (check return code etc.)"
@robatwilliams
robatwilliams / gist:4318580
Created December 17, 2012 14:14
Loop over files in a directory, which might be empty
# in case of empty dir
shopt -s nullglob
local fullPath
local fileName
for fullPath in directory/*
do
fileName=`baseName $fullPath`
done
@robatwilliams
robatwilliams / gist:4318481
Created December 17, 2012 14:01
Make a Bash script source another script from the same folder as it itself is located
source `dirname $BASH_SOURCE`/otherscript.sh
@robatwilliams
robatwilliams / gist:4318465
Created December 17, 2012 13:58
Get process id based on some identifier used in the command that started it
# $1 is the identifier
local idStart=`echo $1 | cut -c 1`
local idEnd=`echo $1 | cut -c 2-`
local idComplete="[$idStart]$idEnd"
ps -f -u $USER | grep -i "identifier=$idComplete" | awk '{ print $2}'
@robatwilliams
robatwilliams / gist:4318429
Created December 17, 2012 13:53
Processing shell script options
unset OPTSTRING
unset OPTIND
local opt
while getopts "ab:c" opt; do
case $opt in
a)
aSpecified=true
;;
b)
@robatwilliams
robatwilliams / gist:4318053
Created December 17, 2012 12:48
Get the username part of the SVN repository url. Doesn't echo anything unless there is one.
# e.g from svn+ssh://username@myrepo.internal
svn info | grep URL: | cut -d / -f 3 | cut -d @ -s -f 1
# output: username