Text

Allowing Gmail keyboard shortcuts to pass through Pentadactyl

If you’re using Pentadactyl and you’re bothered by the fact that it keeps eating your Gmail keyboard shortcuts before Gmail can see them, then you need to set a passkey for Gmail. I had trouble finding the correct syntax for this, but here it is (just throw this into your ~/.pentadactylrc and restart Firefox):

set passkeys+=mail.google.com:jkroae<CR>,gi

Note that all the characters afte the “:” are the characters that you want to be allowed to pass through. Feel free to add or remove characters from that list based on which Gmail keyboard shortcuts you use and which you don’t.

Text

BlackBerry WebWorks and the same origin policy

Say you’re coding a website, and you need to grab a section (perhaps a specific ID) of an external website to display on your site, via AJAX. You can’t just grab the page via AJAX because it violates the same origin policy, which states that you can only grab pages on your own domain.

As a workaround, people usually create a serverside proxy of the remote site. So if you’re working on example1.com, and you need the #content section of a page on example2.com, you’d create example1.com/example2 (or whatever you want to name it) which would just be a clone of example2.com. Then you’d be free to do whatever you want to it via AJAX, since it’s on your domain.

I was working on a BlackBerry WebWorks project recently, and needed to make an AJAX request to a website, and since with WebWorks you’re limited to HTML/CSS/JS and you’re not actually working on a website (but rather an app), the serverside proxy is impossible.

Luckily, even though the docs glazed over this point, you can add trusted domains in your app’s config file, and any domains in that list ignore the same origin policy. So you’re free to make any and all AJAX requests you want to any domain in your list. Just wanted to point that out since I learned it the hard way.

Tags: apps ajax
Video
[Flash 10 is required to watch video]

Charlie is CRAZY

Text

Using DuckDuckGo as a link dropper

Update 1/27/2012: The new short URL for DDG is http://ddg.gg so use that in place of http://dukgo.com

I’m often chatting with someone or sending an email and I want to link them to a search for something, or even just the first result in a search for something. For example, if someone asks me what I use to take screenshots, I could link them to the first search result for “lookit screenshot.” The problem is, I don’t want to actually have to run the search and copy the link address for this.

So, since I’ve been using DuckDuckGo lately instead of Google, I looked there for a solution. Turns out it’s simple.

  • DDG has a shortened URL at http://dukgo.com that’s quicker to type
  • You can type http://dukgo.com/whatever to run a search for whatever
  • If you want to search multiple words, separate them with an underscore (e.g. http://dukgo.com/something_else)
  • If you want to link to the first result instead of the search, preface it with “f/” (e.g. dukgo.com/f/something_else)

So there you go. In the first example, I could just shoot my friend the link http://dukgo.com/f/lookit_screenshot to link him to the first result for a search for “lookit screenshot.” Big time saver.

Link

I’m using this, and it works really well. Check it out if you’re a Chrome user.

thechangelog:

Thanks to Tomás Senart, I’ve regained my Sight when looking at source code in the browser. Sight is another extension for Google chrome that provides:

Head to the Google extensions gallery to install or grab the source on GitHub.

Screencap Screencap Screencap

[Source on GitHub] [Install]

Tags: Chrome
Text

Why would anyone use vim?

(Note: this is a post for vim newbies. If you’re an experienced user, you won’t find anything new here)

I recently switched to vim full time after years of asking myself that question. It seemed like a huge percentage of the better hackers I came across used vim, but all I could see was “no mouse, no IDE goodies, no deal.” Why would anyone subject themselves to that? Well, turns out, here’s why:

Vim is ubiquitous

For web developers who do a decent amount of SSH’ing and editing on a server somewhere, this is huge. Pretty much any Linux box you can find yourself in will have vim installed, and it’s a huge plus when that editor just happens to be the editor you use day in and day out and are comfortable with.

To take it a step further, you can even use vim key binding in Firefox, Chrome, bash, Thunderbird, etc. More about that at StackOverflow. It has a decades-long history and tons of fans, so you start to find that almost anything you do on a computer can be done in a vim-like fashion.

Vim is lightweight

Eclipse is a beast. Aptana’s right there with it. Netbeans isn’t much better. I found myself using Gedit for about a year just because it had a decent feature set (with plugins, that is) without feeling like a wildebeest. Then I made my way to Komodo Edit, which was dangerously close to wildebeest zone, but not quite there.

Vim starts up immediately and leaves a teeny tiny footprint. Maybe this isn’t important to some, but it really makes me happy.

Vim has everything I wanted in an IDE

One of the main things that stopped me from giving vim a serious look for so long is the false belief that it was just a simple editor with some crazy key bindings. Turns out, I couldn’t be further from the truth. After just a couple days of using vim, I had set up an environment with:

  • Tab autocomplete (for both project functions and language functions) complete with a function definition popup
  • The ability to jump from function call to function declaration and back easily
  • A sidebar function outline, automatic syntax checking (even including JS using JSLint and HTML using Tidy)
  • Spell check (for typing up blog posts like this one)
  • Tabs for switching files (although it seems basic, I was worried about using multiple files in vim, but it’s really great)
  • Project search (including replace and regexp support)
  • Smart indenting and auto-indent support
  • Just about any other IDE goodie that I wanted.

I really can’t think of anything I’m missing now that I would have with a different setup.

Vim has some really great plugins

I’ve found the plugin selection for vim to be a cut above that of most other editors. Some of my favorites are:

  • NERDCommenter - Comment out lines/chunks/selections of code in many languages, with your choice of comment types.
  • Gist - Create a GitHub Gist out of the document or selection. This is really, really awesome for me as I tend to send code a lot in IRC.
  • Syntastic - Automatic syntax checking for many languages. Opens errors up in a split window, highlights problematic lines, lets you jump from error to error, etc.
  • Command-T - Quickly open project files by typing any part of the filename/path. Named “Command-T” after the keyboard combo in Textmate which does the same. Much faster than using tree-based sidebar project file lists for me.
  • Zen Coding - Vim support for the amazing Zen Coding HTML/CSS shorthand expander.
  • Taglist - Displays a toggle-able sidebar of project or current file functions/variables for easy jumping.
  • Matchit - Lets you type % to match more than just the vim default of single characters (like if you want to jump from an HTML opening tag to an HTML closing tag, for example).

Vim’s modal editing really opens doors for amazing things

This is the main thing that keeps vim users happy. Vim has a “keep your hands on the home row” philosophy, and the only way that’s really possible is by making the main keyboard keys do more than just type letters. So, because of that, you have your regular old insert mode (same as other editors), but you also have a “command mode” that lets typing things execute commands rather than inserting text. Here are a few examples:

  • Type d$ to delete everything from the cursor position to the end of the line (d = delete and $ = end of line)
  • Type o to create a new line below the current line and enter insert mode on that line.
  • Type ci" to delete everything inside double quotes and enter insert mode (c = change, i = inside, and ” = what you want to change inside of)
  • Type gg=G to autoindent the entire file (gg = top of file, “=” = autoindent, and G = end of file).

This is crazy for awhile, but then it starts to not seem so crazy, then it starts to actually seem pretty sane, then it becomes amazing. For a quick intro to vim’s commands, type the vimtutor command at a terminal and go through that - it only takes about 10-15 minutes.

Vim is fun to use

All of this adds up to a really enjoyable experience. You have a lightweight, free, feature-rich, customizable editor that’s everywhere and lets you get crap done more quickly. I’m glad I gave it a shot.

Soon, I’ll be posting a guide to setting vim up for Drupal development. Check back!

Tags: Vim Apps
Text

Why I’m using DuckDuckGo instead of Google

DuckDuckGo is now my default search, both in the browser and on my phone. Here’s why:

!Bang syntax

DDG has a cool little feature that lets you search tons of websites directly, using !websitename. For example, if you want to search Drupal.org directly, type “!drupal whatever search terms” and you will be taken to a Drupal.org search for “whatever search terms.” This works on tons of sites.

First result jumping

The vast majority of my Google searches just led me to clicking the first result. On DDG, you can add a backslash (“") to the beginning of your sites to jump directly to the first result. This is a small thing, but it’s been great for me.

Zero-click info

I often Google something I’ve never heard of just to figure out what the crap it is. This usually involves clicking through to a Wikipedia page about it. DDG instead will give you a few sentences about that thing at the top of the search, before the results. It gets this info from sites like Wikipedia, StackOverflow, GitHub (DDG is obviously pretty programmer-oriented), LyricsMode, etc. It’s a big time saver for me.

Lots of useful special queries

Get a random number from 1-10 by typing “rand 1 10” or generate a 15 character password by typing “pw 15” or run a hash by typing “md5 whatever” or count calories by typing “calories in 2 eggs” etc. Lots of great stuff going on here. Here’s some more info.

Surprisingly good results

My main hesitation about switching was just that nobody could beat the big G when it came to giving me good search results. I’m actually pleasantly surprised with how good DDG’s results have been so far. The majority of my searches are technical, programming related things, and I remember reading somewhere on Hacker News that this is one of DDG’s primary focuses (like I said, it’s very programmer related).

That said, if you do want to search google, just type “!g search terms” to search Google using the bang syntax.

Useful options

On the settings page, you can select whether to open links in new tabs, whether to display favicons or WOT (trust) ratings beside links, whether to auto-load more results when you reach the bottom of the page, etc. Lots of useful things. You can even configure colors and fonts if you’re into that kind of thing.

The warm fuzzy feeling

DDG feels sort of personal or cozy somehow. It feels like you’re doing something good, like you’re sticking it to the man.

Give it a shot! Make it your browser’s default search engine for a few days and see what you think.

Text

A rundown of keyboards for Android phones

There are a ton of keyboards you can use instead of the Android default. Here’s my take on them.

Default (pre-gingerbread)

Nice, quick and simple. Light footprint and does decent job with the auto correction. No multi touch support, no alternate layouts, nothing fancy.

Swype

The current leader in the swipe typing category, in competition with the ShapeWriter and SlideIT. Does a pretty good, although I’ve found that recent-ish updates have vastly increased the size of the dictionary which means that it recommends stupid words that I would never say and have never heard. Also runs a bit sluggish on my phone. Also annoying is that it’s still in Beta which means that you have to download it through Skype’s website rather than the market and you must manually update.

SlideIT

Basically Swype but with slightly less accurate prediction/correction (at least in my experience). At least this one’s in the market, though.

ShapeWriter

In my experience, vastly superior to both Swype and SlideIT. Runs well on my phone and has good prediction. Downside is that it’s no longer on the Android market and there’s not even an official place to get it, so I had to resort to getting it through a random forum post, which is shady at best.

Smart Keyboard Pro

A great, flexible, multi-touch keyboard with a load of options, layouts, themes, etc. Did a pretty good job correcting my typing, even with me using two thumbs and going as quickly as possible. Not sluggish at all, themes look good, and the settings (although there are tons of them) are laid out logically. Fun to use.

Better Keyboard

Basically the same as Smart Keyboard Pro but with themes listed as separate market apps, not quite as many options, and (at least in my experience), slightly less accurate typing correction. Still worth a try.

SwiftKey

This is the one I’m using as my primary keyboard now. The thing that sets it apart is its contextual word prediction - it predicts what you’re typing based on which word makes the most since to go after the words before it, and also based on what you have typed in the past. This means that it predicts a word before you even start typing it, and lots of commonly used expressions can be typed out by just hitting the space key over and over. Also has good multi-touch and looks nice (although there’s only 1 theme). Runs a little sluggish on my phone but not enough to really complain.

Tags: Android Apps
Video
Tags: Music