pringlized.com
28Dec/110

Git: Remove a remote origin

I was creating a new project on github today and needed to add the remote origin before I pushed:

$ git remote add origin git@github.com:email@gmail.com

Then I realized I entered the wrong account/project info.  After a simple remove command:

$ git remote rm origin

I added the correct remote origin, and pushed:


$ git remote add origin git@github.com:account/project.git
$ git push -u origin master

Worked like a charm.

22Oct/110

Make OS X Lion run faster by disabling Time Machine and Local Snapshots

I upgraded to Lion over a month ago and was noticing diminished performance.  I guess it should be expected this early in a new release.  I'm currently running Lion 10.7.2 on my 2.4 GHz Core 2 Duo Macbook with 4 gigs of ram.  Unfortunately, Lion is still bogging down to the point I can't work as effectively as I could with Snow Leopard.

For those who just want the executable app and skip the explanation:

Download Backup.app

I'm currently running Lion 10.7.2 on my 2.4 GHz Core 2 Duo Macbook with 4 gigs of ram.  So I fired up Activity Monitor and found a process called mtmd, which is Time Machine's daemon.  mtmd was running constantly and appeared to be the culprit that was slowing down my machine.  Lion also has a new feature called local snapshots that is automatically turned on when Time Machine is running.  If your not familiar with them, read this first before continuing.  I ended up finding a nice little utility named tmutil (that comes with Lion) which does a few tasks including enable/disabling of time machine and local snapshots.  Using tmutil, I disabled both Time Machine and local snapshots that run under the mtmd process.  To my pleasant surprise the machine wasn't feeling so slugish anymore.

$ sudo tmutil
Password:

Usage: tmutil help
Usage: tmutil version
Usage: tmutil enable
Usage: tmutil disable
Usage: tmutil startbackup [-b|--block]
Usage: tmutil stopbackup
Usage: tmutil enablelocal
Usage: tmutil disablelocal
Usage: tmutil snapshot
Usage: tmutil delete snapshot_path ...
Usage: tmutil restore [-v] src dst
Usage: tmutil compare [-a@esmugtdrvEX] [-D depth] [-I name]
       tmutil compare [-a@esmugtdrvEX] [-D depth] [-I name] snapshot_path
       tmutil compare [-a@esmugtdrvEX] [-D depth] [-I name] path1 path2
Usage: tmutil setdestination mount_point
       tmutil setdestination [-p] afp://user[:pass]@host/share
Usage: tmutil addexclusion [-p] item ...
Usage: tmutil removeexclusion [-p] item ...
Usage: tmutil isexcluded item ...
Usage: tmutil inheritbackup machine_directory
       tmutil inheritbackup sparse_bundle
Usage: tmutil associatedisk [-a] mount_point volume_backup_directory
Usage: tmutil latestbackup
Usage: tmutil listbackups
Usage: tmutil machinedirectory
Usage: tmutil calculatedrift machine_directory
Usage: tmutil uniquesize path ...
Use `tmutil help <verb>` for more information about a specific verb.

As far as Time Machine goes, I manually run it every few days.  For me, it made no sense to have the mtmd process running all the time.  Local snapshots was a different decision all together.  It's nice to have periodic backups of what I'm working on, but the performance hit I'm currently taking isn't worth it.  But when I'm out of town, having local snapshots running could be a savior.  Since snapshots can be running without Time Machine, it makes sense to just turn them on and off when I need.  After a little thought, I created a simple applescript that will turn on/off both Time Machine and local snapshots.  When I was finished, I saved it as an app to /Applicatons/Utilities/Backup.app.

Backups.scpt applescript source:

set timemachine to display dialog ¬
	"Time Machine: on / off?" with title ¬
	"Lion Backup" with icon 2 buttons {"On", "Off", "Cancel"} ¬
	default button 2

set localsnapshot to display dialog ¬
	"Local Snapshots: on / off?" with title ¬
	"Lion Backup" with icon 2 buttons {"On", "Off", "Cancel"} ¬
	default button 2

if timemachine = {button returned:"On"} then
	do shell script "sudo tmutil enable" with administrator privileges
	set timemachine_action to "on."

else if timemachine = {button returned:"Off"} then
	do shell script "sudo tmutil disable" with administrator privileges
	set timemachine_action to "off."

else if timemachine = {button returned:"Cancel"} then
	exit repeat

end if

if localsnapshot = {button returned:"On"} then
	do shell script "sudo tmutil enablelocal" with administrator privileges
	set localsnapshot_action to "on."

else if localsnapshot = {button returned:"Off"} then
	do shell script "sudo tmutil disablelocal" with administrator privileges
	set localsnapshot_action to "off."
else if localsnapshot = {button returned:"Cancel"} then
	exit repeat

end if

display dialog ¬
	"Time Machine is " & timemachine_action & "\n" & ¬
	"Local Snapshots are " & localsnapshot_action ¬
	with title "Lion Backup" with icon 2 buttons {"Ok"}

It's simple, no frills.  After running it, decide if you want Time Machine running:
Select whether Lion should make local snapshots:

It needs admin privileges to continue.

And when it's finished, it'll tell you what was executed.  In this case both are off.  In the background I had Activity Monitor running.  Notice that mtmd is not running:

In this example, I turned on local snapshots without Time Machine.  You'll see in the Activity Monitor that mtmd is running now:


Since turning off Time Machine and local snapshots (the real culprit), my Macbook is performing like it did with Snow Leopard.  Now I can easily turn snapshots on or off when I need.

Download Backup.app

Download Backup.app & applescript source

17Sep/110

Axon microcontroller programmer

I have an Axon I just started working with.  I was using fboot on XP to flash the controller for a while then decided it was time to upgrade to Win7.  Without thinking I installed Win7 64bit.  Imagine my surprise (not really) that fboot doesn't work under 64bit. In comes McUber.  It's a nice simple java app that can bootload your Axon and Axon II.  It's in beta so don't expect any bells and whistles.  But if you use 64bit Windows, it does the trick.

Note: McUber works on both 32bit and 64bit machines.  It currently is only available for Windows, but Yetasoft plans on releasing it for Linux and Mac soon.

To get the most out of this article I'll assume:

  • You have an Axon or Axon II
  • You have gone through the Getting Started for your Axon or Axon II
  • Have built a project using AVR Studio (Eclipse, etc) and have a .hex file ready to bootload to the controller

Get Everything Ready

  1. Download McUber and move it to where you want the program to live
  2. Make sure you have a java jre installed. If not install it.
  3. Connect your Axon via the USB

Using McUber

  1. Start the app by double clicking McUber.jar
  2. Choose Microcontroller: Currently only Axon II is available in the list. Works with original Axon as well.
  3. Choose the Com Port the Axon is on.  Check your device manager if your not sure. For me that's under Device Manage > Ports > Silicon Labs CP210x USB to UART Bridge (COM3)
  4. Set your baud rate to the com port setting. I use 115200, which is defined in the Device Manager.
  5. Under Programmer Configuration, locate the hex file you want to program to the controller
  6. Press Program
  7. Turn on (attach power to) your Axon

On occasion you might get an error message saying the flashing failed.  This could be for a variety of reasons.  In my case, I noticed my on/off switch catches sometimes when I try to turn it on, which caused the failure. I had to do it a few times at first to get it to work.  If you experience an error, turn off the Axon and repeat the process again.  This time wait an extra second or two before turning on the Axon.

 


If all goes as planned, you'll see a successful output under Status:

That's it.  This app has a lot of promise in the future.  And nicely enough, it is released under the BSD License.