I was having some weird problems with pretty much any Makefile I found to upload/compile arduino source code and upload it and I really didn’t want to have to use that terrible IDE they provide so I rolled my own rake file.
The entire rakefile is available on github. Please feel free to fork and submit a pull request!
curl this code to a Rakefile and run
rake compile to compile your project and
rake upload to upload it.
curl https://github.com/AndrewVos/arduino-tools/raw/master/rakefile.rb > Rakefile