Skip to content

Instantly share code, notes, and snippets.

James Swift JamesSwift

Block or report user

Report or block JamesSwift

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@JamesSwift
JamesSwift / gist:7492869
Created Nov 15, 2013
NQC Code to alow a Lego RCX brick to stand on two wheels. I place this code in the public domain. No rights reserved.
View gist:7492869
#define FULL_POWER_OFFSET 3
task main()
{
SetSensor(SENSOR_2,SENSOR_LIGHT);
int last_reading=SENSOR_2;
//start adjust_power;
SetPower(OUT_A+OUT_C,7);
@JamesSwift
JamesSwift / gist:5273325
Created Mar 29, 2013
I was having trouble initiating the `ssh-agent` on Git Bash (Git for Windows) in my `.bashrc` file using the example provided at: https://help.github.com/articles/working-with-ssh-key-passphrases So I created a simple script that does the job. It initiates a ssh-agent when you open Git Bash, and kills it when you close the bash. Note, it doesn't…
View gist:5273325
#! /bin/bash
#Start ssh-agent
eval `ssh-agent`
#Uncomment the next line if you want to automatically load ssh-keys at startup
#ssh-add
#Kill ssh-agent when we close the shell
trap "ssh-agent -k" EXIT
@JamesSwift
JamesSwift / commit_if_changed.sh
Created Aug 3, 2012
Sometimes you want to run an automated "git commit -a" (perhaps as a cron job), but you don't want to clog up your history if nothing has changed. I use the following script to run a commit only if changes have been made.
View commit_if_changed.sh
#!/bin/bash
cd /path/to/your/git/repo/
if [ "$(git status -s)" ] ; then
echo "Changes detected. Commiting."
git add .
git commit -am "Your explanation here"
else
echo "No changes detected. Commit canceled."
fi
You can’t perform that action at this time.