More Keyboard Fun

Continuing along on the keyboard theme, most Google apps have keyboard shortcuts. I've started using Google calendar and found the keyboard shortcuts for it as well. Very handy.

Google Calendar keyboard shortcuts

Add a comment
Category: tools Tags:

Speaking of keyboard navigation....

Did you know that you can navigate Google search results with your keyboard?

It's a Google Labs experiment so you'll have to enable it on any machine you want to try it.

To experience the glory of navigating search results with your keyboard, head on over to Google Experimental Search and click "Join" for the Keyboard Shortcuts experiment. Then it's simply a matter of pressing "J" to navigate down the search results and "K" to move up your search results on Google. Pressing "O" will then open up the link for you. There are a few others that you might like as well so give this experiment a whirl.

The keyboard shortcuts key will also show up on your search results page so that'll help you remember them. (Experienced vi users will of course recognize these keyboard shortcuts.)

Add a comment
Category: tools Tags:

Throw away that mouse

Mouseless browsing screenshot

I'm not a big fan of using the mouse. It pains me to reach for it to accomplish something. That's why I was really excited to find the Mouseless Browsing add-on for Firefox.

From the add-on's homepage:

Mouseless Browsing (MLB) is a Firefox-Extension which enables you to browse the internet with the keyboard. The basic principle is to add small boxes with unique ids behind every link and/or form element. You just have to type in the id and press enter (there is also an automatice mode available) to trigger the corresponding action i.e. following a link, pressing a button or selecting a textfield.

I could never get w3m working how I liked it so Mouseless Browsing really scratches an itch I have.

Add a comment
Category: tools Tags:

jQuery and Friendfeed experimentation

So, I created a little page that'll dump out the last 30 items from my Friendfeed feed.

jQuery and the Friendfeed API make it incredibly easy. It only took me about 15 minutes to get it working. The rest of the time was making it ugly with my crazy design skills.

It's over on my vanity site if you are curious to check it out.

Add a comment
Category: programming Tags:

Google Code Search to the rescue

UPDATE: Google Code Search was shutdown so this fun doesn't apply anymore.

Mmkay, this tip is probably a gazillion years late but Google Code Search is a great resource for a budding developer. Heck, I'm a relatively seasoned developer and I use it.

It allows you to search public source code using a variety of methods. You can search for an exact string or a regex. You can search certain files, certain packages and certain languages.

For instance, today I was curious how to use the Perl API for writing a Pidgin plugin as their documentation is a tad sparce. A quick search looking for Purple::Find::buddy and I found a whole bunch of examples. You can also use it for silly things, like looking for quotes from "Hitchiker's Guide To The Galaxy."

It's official, Google now owns me. sigh

Add a comment
Category: programming Tags:

Machine specific startup files in BASH

Here's a helpful tip if you use a couple of different machines and need specific things set up on a specific machine.

Just add the following to your .bashrc

## Read Generic RC                                                                            
for rcfile in "$HOME/.shell/"*.rc;
do                        
    if [ -r "$rcfile" ]; 
done

Thus, common things are stored in your .bashrc (like aliases, functions, etc.) and things you want on a specific machine are in their own directory.

Then, just put whatever machine specific files you want/need in ~/.shell and name them with .rc. For instance, I have ~/.shell/smurf.rc that sets up some smurf information.

> export FAVORITE_SMURF="Poppa Smurf"
> export SMURF_LOVER=$HOME/bin/blue_love

That way, if I ever need something that's specific to a machine, I just drop it in my .shell directory and away we go.

Add a comment
Category: shell Tags:

Cost of try/catch in JavaScript

I know that in Java, using a try/catch is fairly expensive vs. a if check. Since JavaScript has the same syntax for the most part, I wrote up a simple benchmarking script to test it out. On my box, it outputs:

if avg: 0.029
try avg: 1.372

Note, that you'll need the Firebug plugin for Firefox in order to run this.

var tryFunc = function () {
  try {
    document.getElementById("fake").innerHTML = "hi there";
  } catch (e) {
    // eat it!
  }
}

var ifFunc = function() {
  var el = document.getElementById("fake");
  if (el) {
    el.innerHTML = "hi there";
  }
};

function benchmark(name, func) {
  var repeats = 1000;
  var elapsed = 0;
  var startTime =0;
  var endTime = 0;
  for (var i=0; i< repeats; i++) {
    startTime = new Date().getTime();
    func.call();
    endTime = new Date().getTime();
    elapsed += (endTime - startTime);
  }
  console.log(name + " avg: " + (elapsed / repeats ) );
}

benchmark( "if", ifFunc );
benchmark( "try", tryFunc );
Add a comment
Category: programming Tags:

HOWTO: Invoke a shell script on a file on save with emacs

At my current job, we use a lot of Template Toolkit. Due to some design decisions (that I consider a tad strange), we have to run a shell script on the template files (e.g. files that end with “.tt”) after they are saved in order for them to be displayed on the dev site.

Since I started using emacs about two months ago, I've learned quite a bit. A new thing on the learning heap is the after-save-hook. Emacs to the rescue yet again.

Here's a emacs lisp function I wrote to automate the execution of the script when a template file is saved:

(defun ssm-cheetah-after-save-hook ()
  "After saving a tt file, run the language_update file"
  (if buffer-file-name
      (progn
        (setq is-tt-file (numberp (string-match "\.tt$" buffer-file-name)))
        (if is-tt-file
            (progn
              (setq cmd (concat (getenv "B") "/bin/YOURSCRIPTHERE --template="))
              (shell-command (concat cmd buffer-file-name))
              (message "Updated template with %s" buffer-file-name))))))
(add-hook 'after-save-hook 'ssm-cheetah-after-save-hook)

What it does, is first defines a function that checks to see if we have a file name, (which should probably always be true since we are saving now that I look at it). If we do, check to see if the name ends with “.tt.” If it does, pass the name of the file to the shell script and output a message to the user saying the template was updated. Finally, the function is added to the after save hook.

Add a comment
Category: editor Tags:

Emacs Tips

Since I've been programming more Perl than Java lately, I've started using Emacs as my primary IDE. Been checking out a few sites with tips and tricks to help me along the path of conversion from vi to Emacs. Trey Jackson's blog seems pretty promising.

Hopefully, he can keep up the tip a week format. Allegedly, he has 150 tips so he should be good for 3 or so years.

Add a comment
Category: editor Tags:

Lisp Fun

Interested in learning Lisp? A new site has launched with screencast episodes about developing an application in Lisp. The site is LispCast and so far there are three videos up. It's about building a web application that is a clone of Reddit. The subject of the videos so far are writing it, developing tests and refactoring. They each clock in at about twenty minutes and are quite helpful.

It looks like the creator, one Eric Normand, has some pretty big plans for the site. Let's hope that he is able to do it. I know I'm rooting for him.

Add a comment
Category: programming Tags:

© Seth Mason 2014

Themed using aboutwilson

Powered by Pelican