Text

How to kill a dead SSH session gracefully

I have a bad habit of leaving an open SSH session sitting there and then coming back to it to realize that it’s dead. In the past, I’ve just killed the terminal to end it. Here’s a better way:

<Enter>~.

That’s the enter key followed by the tilda character followed by a period.

To explain, SSH has a few different escape sequences. To see them, run ~? while in an open SSH session. Here they are:

mcrittenden@freshbox$ ~?
Supported escape sequences:
  ~.  - terminate connection (and any multiplexed sessions)
  ~B  - send a BREAK to the remote system
  ~C  - open a command line
  ~R  - Request rekey (SSH protocol 2 only)
  ~^Z - suspend ssh
  ~#  - list forwarded connections
  ~&  - background ssh (when waiting for connections to terminate)
  ~?  - this message
  ~~  - send the escape character by typing it twice
(Note that escapes are only recognized immediately after newline.)

As you can see, ~. is the escape sequence to terminate the connection, and the note at the end says that they’re only recognized immediately following a newline, hence <Enter>~.

Text

Toggling between event handlers using jQuery’s toggle()

Ever been in a situation where you need to do something on click except if it’s already been done, in which case you undo it? Previously, I would do this by setting a class on the first click and then checking for that class to see if it’s already been clicked.

Turns out, there’s a function that makes it easier. Just sticking this here in hopes that someone else stumbles on it.

Text

Use jQuery to fade to a different background image on submit button hover

There’s a pretty common and nice looking that lets you fade to a different background image when you hover over a link, div, etc. For an example, see Dragon Interactive’s navigation. That method basically involves adding an empty span tag inside the link or div, and setting it to take up the full available space but be transparent. Then, on hover, you fade it into view (and you can set whatever background image you want on it so it looks nice and pretty).

However, that method doesn’t work on form submit button inputs since you can’t add HTML inside an <input> tag (since they’re self-closing). So you’re stuck trying to figure out another method. Here’s a simple one that worked for me.

Basically, instead of setting a span inside the element, you wrap the element in a div, so you’re basically doing the opposite. Then, you can set whatever background image you want on the div, and write a bit of jQuery that, on hover, fades the button to an opacity of 0.01 (so it’s transparent, showing the div’s background image instead of the button’s, but still clickable).

Here’s some code to illustrate:

The HTML for the submit button

The jQuery which wraps the submit button in a div and does the fading on hover/mouseout

The CSS to replace the button with an image (using a large negative text-indent which is just my preferred method) and to set the background image on the background div

Give me a shout if you try it out and have trouble.

Text

Source Tree Addon for Komodo Edit 6.0

If you’re looking for a version that works with Komodo Edit 6, here it is. Took me forever to find that.

Tags: Programming
Text

Check for valid HH:MM string using JS/jQuery & regex

A simple function to check whether a string is in valid HH:MM (or H:MM…the hours don’t have to be zero padded) format.

Link

A really nice jQuery UI theme that doesn’t look terrible like the default ones do.

Text

The purpose of link title attributes

I always thought that link title attributes (i.e., the little tooltips you get when hovering over a link) are important for accessibility. Turns out, I was mistaken.

Actually most screen-readers will not read the title attribute of a link when there is also link text in the anchor. Also most keyboard only users will not get the content of the title attribute as it is usually only available to those with a pointing device.

[…] Bottom line is that title is for non-important information, users must be able to determine the purpose of a link without using the content of the title attribute.

- Source

Quote

Back in my early 20’s, when I was just out of university and doing any old contract job that came around, I happened to be working on a particularly complex project that involved a heavy amount of annoyingly complex javascript (before the days of jQuery). I ended up burning myself out trying to hit an impending deadline. I collapsed into bed in the middle of the day.

A little while later, my (then) girlfriend (now wife) came into the bedroom to ask if everything was ok and, waking up in a stupor and not really being conscious about what I was saying, I mumbled that it was all going wrong and I was hoping she would help me (she’s not a programmer and wouldn’t know where to start). I woke up a few hours later to find her stressing over one of my javascript reference books and looking at me with sad eyes, saying she didn’t make much progress, because it was all a bit confusing.

I married her not long after. Didn’t need much convincing :)

Source

Text

Coding Music

I’ve been steadily building up a collection of good background music for coding. If you’re interested, here are a few bands/artists I’d recommend:

  • This Will Destroy You
  • The American Dollar
  • The Album Leaf
  • Amiina
  • Eluvium
  • Philip Glass
  • Brian Eno
  • Harold Budd
  • Aphex Twin (the ambient stuff)
  • Boards Of Canada
  • Carbon Based Lifeforms
  • Explosions in the Sky