the personal weblog of raffy banks

Archive for the ‘Software’ Category

Adding a Confirmation Message to GitX’s ‘Gist it’ Button

Tuesday, March 17th, 2009

gitx-gist-itUse GitX?

Ever been tempted to click the Gist it button? Or maybe you accidentally did click it, only to find out…

GitX will try to upload your current commit as a git patch to gist.github.com - GitX User Manual

The attempt will be made without any confirmation on your part.

So, what if you don’t want to upload your commit?

Well, you could just make sure never to click the ‘Gist it’ button.

Or you could disable the button from within the preferences, and flip it back on when you do want to Gist something.

disable-gist-it

That’s OK, but what I really want is a message confirming the action, so if I do ever accidentally press the ‘Gist it’ button, I can just cancel the request. And since the code that GitX uses to run these commands is in HTML and Javascript, It is very easy to slip in some code of our own.

Here’s how to add a confirmation message for when the ‘Gist it’ button is clicked

fyi. This is a really quick and semi-dirty hack that will be lost if you re-install or download a new version of GitX.

  1. Open Finder > Application, ctrl (right) click the GitX application and select ‘Show Package Contents’.
  2. Navigate to ‘Contents/Resources/html/views/history/’ and open ‘index.html’ in TextMate or other plain text editor.
  3. Add the following within the head tags:
    1. <script type="text/javascript" charset="utf-8">
    2.     var confirm_gist = function(confirmation_message) {
    3.         // Set optional confirmation_message
    4.         confirmation_message = confirmation_message || "Yes. Paste this commit.";
    5.         // Show div#notification, since it’s set to display:none; by default
    6.         $("notification").style.display = "";
    7.         // Hide img#spinner, since it’s visible by default
    8.         $("spinner").style.display = "none";
    9.         // Insert the verification links into div#notification_message
    10.         $("notification_message").innerHTML = ‘This will upload your commit to http://gist.github.com/<br/>Are you sure you want to continue?<br/><br/>’ +
    11.         ‘<a href="#" onClick="hideNotification();return false;">No. Cancel.</a> | ‘ +
    12.         ‘<a href="#" onClick="gistie();return false;">’ + confirmation_message + ‘</a>’;
    13.     }
    14. </script>
  4. Update the ‘Gist it’ button to look like:
    1. <a class="servicebutton" id="gist" onClick="confirm_gist();return false" href=‘#’>
    2.     Gist it
    3. </a>
  5. Save the changes made then quit (if open) and re-launch GitX.

Now, whenever you click the ‘Gist it’ button, a notification message will appear within the notification_message div (The same place as ‘Gist it’ status notifications):

gist-it-confirmation

confirm_gist() also takes an optional string which can be used to alter the confirmation link, like so:

  1. <a class="servicebutton" id="gist" onClick="confirm_gist(’Upload this commit.’);return false" href=‘#’>
  2.     Gist it
  3. </a>

Caveat

Re-installing or upgrading GitX will wipe this ‘hack’ which is why I didn’t alter the gistie() method in the history.js file. Altering as little as possible, and only the index.html file makes it a bit easier to ‘track’ and save if a feature like this is not implemented in future releases.

Lighthouse user James T uploaded a patch, https://gist.github.com/fc3c9773f6a2bcbeb7a9, that may be worth a look. It is very similar to what I have done, but involves rewriting-or-renaming the gistie() method and creating two new javascript methods. He also added some nice CSS stylings to the buttons.

You can alter or add to the stylings by adding to the stylesheets found in Contents/Resources/html/css/

Also see GitX’s Lighthouse ticket on this very matter: #58 Suggestion: Usability of “Gist It” button. As of this post (16 March 2009), and GitX ver. 0.6.1, this ticket is still open and clicking ‘Gist it’ will upload your commits to gist.github.com without confirmation.

To Rewrite?

Friday, March 13th, 2009

I’m getting very tempted to rewrite an application that I’ve been working on for about three months now. All sorts of reasoning to do so have tugging at me, but what actually prompted this temptation is a side project I’m working on with @iheartcinnamon (kat). It made me realize how hard it actually would be to move the application forward.

The core of the application, while works flawlessly, is implemented rather poorly. The code is horribly organized, methods were created on a case-by-case basis which has lead to duplication throughout, business logic is confusing at best, the XHTML templating system is a complete mess, and, well, I could go on for awhile.

My side project has reaped the benefits of this, it’s core is implemented with clarity, ready to be extended anywhere. Since the two projects have similar core needs, writing it came as second nature; I already knew what it needed to be and how I to get it there. But does this warrant a complete code rewrite?

Three months is not a long time, per say, but extending the development time would cut deeply into its launch date. What to do? How do I satisfy my itch of rewriting it, bring clarity to the code so it can be extended with ease and make sure I launch fast and often?

Before I do anything, I’m off to do some research into the implications of rewrites and I will return to this topic in another post.

First Screens of Google Chrome on OS X

Friday, February 13th, 2009

Venture Beat: Early pictures: Google Chrome on the Mac

Using MarcoPolo to Lock Down Your Mac When Connected to a Public WiFi Network

Thursday, February 5th, 2009

On my PowerBook I run quite a few sharing services, things like Web Sharing, Bonjour for file sharing and Screen Sharing. But the thing is, I only need these services running when I am at home; I’d rather not “publish” theses services when I am surfing at my local Internet cafe.

I’d also like to enable some sort of password protection for when I walk away from my PowerBook momentarily.

Enter MarcoPolo

MarcoPolo lets you switch your Mac between locations; Which it can do automatically or you can manually switch it. This means that when I am at home, I can switch to my “Home” location profile have any password protection disabled and all my services flipped on. When I am at a cafe, I can switch to my “Public” profile I can enable a screensaver password protection and have all my services flipped off.

MarcoPolo Switching Locations

Rules enable automatic switching between locations.

MarcoPolo Rules


The only problem I found with MarcoPolo was the poor help documentation and poor verbage within the app itself. So, here is…

How to use MarcoPolo to enable a screensaver password

Once downloaded and installed, click the compass icon on the menu bar and select “Preferences…”.

1. Click the context tab and then the plus symbol and add a profile named “Public”.

2. Click the actions tab, then the plus symbol and select “Add ScreenSaver Password Action…” and enter info as below:
MarcoPolo ScreenSaver

3. You will now want to create another “Add ScreenSaver Password Action…”, but with the context set to “Automatic” that is set to disable the screensaver password so you don’t have the password prompt when at home.

That’s it. Now when you flip to your “Public” location there will be a password that flips on when your screensaver kicks in.


There are actually quite a few actions your Mac can take, based on your location:

  • Setting your default printer
  • Changing your desktop background
  • Enable or disable particular firewall rules
  • Setting iChat status message
  • Setting the default IMAP or SMTP server for Mail.app
  • Mounting network shares (smb://, afp://, etc.)
  • Muting or Unmuting system audio
  • Changing OS X network location
  • Opening a file (an application, a document, etc.)
  • Quit an application
  • Enabling or disabling screen saver password
  • Start/stop screen saver
  • Changing screen saver idle timeout
  • Running a shell script (or any other kind of script, via Platypus)
  • Turning on or off Bluetooth
  • Turning on or off WiFi (AirPort)
  • Establish or disconnect VPN

You can also set you Mac to automatically switch between locations automatically based on quite a few rules

  • Visible WiFi networks
  • Current Audio Output device (headphones/internal speakers)
  • Discoverable Bluetooth devices
  • Advertised Bonjour (Zeroconf) services
  • Attached FireWire devices
  • Assigned IP addresses
  • Ambient Light level
  • Attached Monitors
  • Active Network Links
  • Power source (power adapter/battery)
  • Running Applications
  • Current Time Of Day
  • Attached USB devices

You can even run AppleScript or shell script actions when switching between locations…

Very cool!

Feedly is a great way to start the day

Friday, January 30th, 2009

Feedly is a website+browser-plugin that creates a customized newspaper-like start page based on your media subscriptions; RSS, Google Reader, Flickr, Twitter, FriendFeed, etc.

So basically you install the Firefox plugin, tell feedly about the various subscriptions you have scattered around the web and presto! A custom news feed. From there you can do things like share articles to your Twitter or FriendFeed account, etc.

What I like the most is the clean design and layout; Full articles are pulled in to the software so flipping between articles is fast and not as jaunting when moving from site to site. (Of course you lose the aesthetic of the site the article belongs to)

Feedly Cover Thumbnail

I’ve only just begun using it, but so far I love it.

Editing PDFs in OS X

Monday, May 5th, 2008

Here is a great little Mac OS X app for editing PDFs: PDFPen from Smile On My Mac.

PDFPen

Some of its features:

  1. Replace text in original PDF with editable text blocks
  2. Fill out and save PDF forms
  3. Move, resize, copy and delete images in original PDF
  4. Copy and paste rich text; retain fonts and formatting when copying
    from PDFs
  5. Select and copy text across multiple columns
  6. Overlay text and images onto PDF (for example, sign purchase orders
    by applying signature image)
  7. Show PDFs in single, facing-page, multi-page, and multiple facing-page views
  8. Insert and remove pages; re-order pages in a PDF by drag & drop

Facebooker at Chirb

Tuesday, February 5th, 2008

Mike Mangino gave a fantastic talk on Facebook and Facebooker, a Ruby gem and Rails plugin for the Facebook REST API, at the Chirb meeting tonight.

What is fantastic about Facebooker, a point Mike reiterated throughout his talk, is that all you are really doing is creating a typical Rails app. Facebooker is all about helpers, doing all the FBML (Facebook’s Markup Language) lifting for you.

It took some time for my brain to wrap itself around such a simple concept, but the last thirty+ minutes Mike spent actually building a Facebook app., which put most of my concerns into perspective.

I just wish there would have been more time for a detailed discussion on topics like caching and scaling. Something that Mike alluded was simple, thanks to Facebook’s architecture.

I have never created a single profile on a single “conventional” social network. But I might have to now.

Google Reader Should Read My Mind

Thursday, November 8th, 2007

I primarily use the Google Reader as my RSS reader, but one thing about it kind of irks me… It doesn’t read my mind.

No, seriously. Whenever I subscribe to a new RSS feed through Firefox Google asks me if I want to add the feed to my Google Homepage (iGoogle) or to my Google Reader.

Google Reader RSS Snapshot

Ok. No biggie, right? I can deal with one simple question, a quick click of the mouse. But I have never used the Google Homepage nor have I once clicked the “Add the Google Homepage” button.

I know this would be easy for Google to implement, just read my mind and remember which one I like. Or is there a way to set this in my Google settings I am not seeing?

Time Machine Vs. SuperDuper

Thursday, November 8th, 2007

UPDATE (Jan. 29, 2008): You can complete a full system restore to a new hard drive with Time Machine. After installing the new hard drive startup your Mac with the OS X Leopard install DVD. But instead of going on with the usual install process, select Utilities > Restore System from Backup and follow the prompts. (via lifehacker at Restore Your Data with Time Machine)

Time Machine and SuperDuper are both backup solutions for Apple’s OS X operating system (SuperDuper is not yet available on Leopard at the time of this writing). Both effectively copy your entire hard drive to an empty volume like an external USB or Firewire drive, but there are a couple of subtle differences.

I thought I may be able to drop SuperDuper once I upgraded to Leopard, but it looks like it will be a part of my arsenal for some time still. Here are the key attractions of each:

Time Machine
1. Copies all files to backup location.
2. You can restore individual files by date. Going back a year by default.
3. You are unable to boot form the backup source.
4. Has the potential to eat up quite a bit of storage.

SuperDuper
1. Copies all files to backup location.
2. No historical recovery.
3. Boot directly from the backup source. (External Firewire drive)
4. Space used for storage will remain relatively the same.

The ability to backup from my external Firewire drive is HUGE to me. If my hard drive crashes I want to be able to simply restart my Mac and boot directly from my backup drive and have a working system. Time Machine lacks this luxury. Instead you would need to replace the hard drive, reinstall Leopard and then run a recovery from Time Machine.

It does have historical backups going for it though. So if you deleted a file a few days back and realized you now need it, you can still get it - You can also recover older versions of a file.

It seems redundant to have two dedicated backup drives, but if I want the best of both worlds…

RJB is proudly powered by WordPress | Subscribe: Entries (RSS) | Email: raffybanks at gmail