Skip to content

Instantly share code, notes, and snippets.

View glombard's full-sized avatar

Gert Lombard glombard

View GitHub Profile
@glombard
glombard / new-bootstrap-project.bat
Created February 12, 2014 17:34
Quickly get going with bower, bootstrap, knockout
D:
md work\Topics
cd work\Topics
cinst curl
cinst nodejs.install
set path=%path%;C:\Program Files\nodejs
setx path "%path%" /m
npm install -g bower
bower install bootstrap
bower install knockout
@glombard
glombard / Progress-Module.ps1
Created March 4, 2014 19:30
A simple module to wrap a nicer interface around Write-Progress. It allows you to first register each step you're going to perform and then you activate/set each step as you progress through your script.
# A simple module to wrap a nicer interface around Write-Progress.
# It allows you to first register each step you're going to perform and
# then you activate/set each step as you progress through your script.
$progress = New-Module -ScriptBlock {
[string]$title = 'Progress'
[int]$totalSteps = 0
function Activity {
param([string]$activity)
@glombard
glombard / unblock-files.ps1
Created April 7, 2014 10:11
Unblock files downloaded from the internet using streams.exe
if (!(Test-Path "$env:Temp\streams.exe")) {
(new-object System.Net.WebClient).DownloadFile('http://live.sysinternals.com/streams.exe', "$env:Temp\streams.exe")
}
# "Unblock" the files...
& "$env:Temp\streams.exe" @('-d', '*.*')
@glombard
glombard / setup-angularjs-tools.sh
Last active August 29, 2015 14:00
Install Grunt/Bower/Yo tools for AngularJS on OS X
# Install nodejs under /usr/local/Cellar/node/0.10.26/
brew update
brew install node
# install global node modules under /usr/local/lib/node_modules/
npm install -g grunt-cli
npm install -g yo
npm install -g bower
npm install -g generator-angular
npm install -g protractor
@glombard
glombard / set-npm-vs-version.ps1
Created July 27, 2014 18:18
Set Visual Studio version to use for Node's NPM on Windows (by default it uses VS2010)
# See: https://www.npmjs.org/package/node-gyp
$vsVersion = "2012"
if (Test-Path HKLM:\Software\Microsoft\VisualStudio\12.0) {
$vsVersion = "2013"
}
npm.cmd config set msvs_version $vsVersion
@glombard
glombard / get-boot2docker-with-vbga.sh
Created August 2, 2014 18:51
Replace boot2docker.iso with version with VBox guest additions (by steeve and mattes)
# see: https://github.com/boot2docker/boot2docker/pull/284
URL=$(curl -s https://medium.com/boot2docker-lightweight-linux-for-docker/boot2docker-together-with-virtualbox-guest-additions-da1e3ab2465c | grep -io '"http://[^"]*iso"' | sed -E 's/"(.*)"/\1/' | head -1)
if [ -f ~/.boot2docker/boot2docker.iso ] && [ ! -f ~/.boot2docker/boot2docker-original.iso ]
then
echo Backup existing file to ~/.boot2docker/boot2docker-original.iso ...
mv ~/.boot2docker/boot2docker.iso ~/.boot2docker/boot2docker-original.iso
fi
@glombard
glombard / .bash_profile
Created August 3, 2014 18:18
Create a BitBucket Git repo for my current working directory
function mkrepo () {
BBUSER=user
BBPASS=password
BBLOGIN=$BBUSER:$BBPASS
DIR=${PWD##*/}
echo "Making BitBucket repo '$DIR' ..."
git init
curl -u $BBLOGIN -X POST https://api.bitbucket.org/1.0/repositories/ -d "name=$DIR&is_private=1" -v
git remote add origin https://$BBUSER@bitbucket.org/$BBUSER/$DIR.git
}
@glombard
glombard / repo.json
Created August 21, 2014 16:56
Repository Metadata
{
"name": "Tools",
"url": "http://20.30.40.50:8080/tfs/DefaultCollection/Project/_git/Tools",
"description": "Internal developer tools",
"developers": [
"Gert Lombard <gert.lombard@gmail.com>"
],
"dependencies": [
"http://20.30.40.50:8080/tfs/DefaultCollection/Other/_git/Libraries"
],
@glombard
glombard / ssh-vm.sh
Created October 14, 2014 20:10
Connect to my VMWare Fusion linux vm
GUEST_VMX=`vmrun list | tail -n+2`
GUEST_IP=`vmrun getGuestIPAddress "$GUEST_VMX"`
ssh root@$GUEST_IP
@glombard
glombard / gerrit_users.py
Created December 1, 2014 18:37
Get the Gerrit users emails as a string list using ssh and gsql query.
class GerritUsersListProvider(object):
def get_users(self):
"""Gets the Gerrit users emails as a string list."""
server = os.environ.get('GERRIT_SERVER', GERRIT_SERVER)
logging.debug('Querying all user accounts from ' + server)
text = subprocess.check_output([
'ssh', '-p', '29418', server, 'gerrit', 'gsql', '--format',
'JSON_SINGLE', '-c', "'select preferred_email from accounts'"])
accounts_json = json.loads(text)
return self.json_to_list(accounts_json)