/dev/nikc/blog

Kuolleiden purjehduskenkien seura

May 4th 2015

URLs Need Due Diligence

11:25

Considering how central the URL (Uniform Resource Locator) is to the World Wide Web, it should really be blatantly obvious that it needs proper attention during the design process of any new website. It’s not always easy, and I for one have certainly at times been guilty of poor URL design, but making changes later can be a tall mountain to climb.

bq.. URL Design is a complex subject. I can’t say there are any “right” solutions — it’s much like the rest of design. There’s good URL design, there’s bad URL design, and there’s everything in between — it’s subjective.

URL Design

What I especially liked in the article is the notion that URLs are for humans. SEO is useful, not the least because it employs a whole industry, but really the human you’re trying to attract to your website should always be at the centre. But all other things aside, the absolute most important attribute about a URL, is and always has been is that it works, and that it keeps on working.

bq.. What makes a cool URI?
A cool URI is one which does not change.
What sorts of URI change?
URIs don’t change: people change them.

Cool URIs don’t change

Having revisited older posts in this blog, it’s unfortunate to see so many dead external links. Luckily there are projects like the Internet Archive that make internet archaeology possible.

So do the internet a favour: keep your URLs alive, and donate to the Internet Archive project to mitigate the consequences of dying URLs.

Shorts

Feb 21st 2015

Host aliases and tab completion for SSH

13:02

Despite being a relentless tinkerer, for some bizarre reason instead of using the proper mechanics I’ve resorted to aliases for hosts I log in to frequently. Thankfully, the mental strain of remembering all the hosts I log in to finally forced me to sit down for 2 minutes and add the host + username combinations into my ssh-config. (Procrastination is such a beautiful word!)

<code>Host freq
HostName some.long.hostname.that.i.need.frequently.com
User mysysadminassignedmethis</code>

Configuration blocks like the example above shorten the full command to ssh freq from ssh mysysadminassignedmethis@some.long.hostname.that.i.need.frequently.com. Quite an improvement, I’m sure you’ll agree.

However, since I did a proper job, naming things in a logical and consistent manner using patterns such as servicename-stg for the staging environment and servicename-prod for the corresponding live host, there was still quite a lot of typing to do. If you saw my post about tab completion for project folders you can probably guess where this is going.

As I now have all the relevant information in ~/.ssh/config it’s very easy to parse out a helpful wordlist to create ssh tab completion. I have it and now you can have it, too.

Download ssh-complete.bash, source it from your ~/.bashrc and simply TAB away.

There are plenty of other useful things you can set in your ssh-config. See its man page for further information.

Shorts

  • “Stand Still. Stay Silent” is a post apocalyptic webcomic with elements from nordic mythology mixed in, set 90 years in the future. Contains plenty of friendship, exploration adventure and some horror.

    Stand still, stay silent

    (0) #

  • A blast from the past: Is JavaScript Here To Stay?

    (0) #

Nov 10th 2014

Differential Syncing

16:57

For a personal project, I looked into the magical world of how to sync work from two or more peers on a single item, without anyone losing their work.

Thankfully, Neil Fraser has published a paper on Diff Strategies, Fuzzy Patching, and indeed Differential Synchronization. Even more thankfully, Google has open sourced a diff-match-patch library (ported to several popular programming languages) that does all the heavy lifting for you.

Most likely my personal project will never be finished to a point where it would be made public, but since I found this stuff interesting, I just thought I’d put this out there for others to enjoy.

Jul 19th 2014

Better tools for procrastination

14:20

I have a problem: the internet. Or rather the vast amount of interesting content being published versus the time and energy I have to consume it. I’ll read an article here, bookmark an article there, but mostly I just open stuff in tabs in order to “read them later.” And I know I’m not alone.

Currently, I have too many bookmarks to count both locally and in various cloud services, but more importantly around 80 tabs across 9 windows open. More importantly because those tabs and windows each use up a chunk of the finite RAM memory in my computer. As a result of this my computer almost constantly feels sluggish.

Now, I know the right course of action would be to address my behaviour. But who does the right thing?

In lieu of improving my judgment on what’s truly worth my time and attention, I instead found a tool to help me with the immediate symptom: The Great Suspender.

The Great Suspender suspends a tab after a set timeout, unless it matches a white list, or on demand. Individual tabs or all tabs in a window can later be restored as needed.

What I really need is a plugin that will simply close unattended tabs after a period of time. Because, even though I really do revisit some of those postponed articles, many are just waiting to be bookmarked and forgotten about forever. Perhaps I’ll add it to my ever growing list of hobby projects…

Shorts

Dec 3rd 2013

Managing scrollTop in your Backbone single-page app

19:04

One of the great caveats of single-page apps is that they rely on taking over many of the browser’s default behaviours. One of the more significant ones is how the browser behaves on page-to-page navigation, be it forwards or backwards. By default, the browser will take you to the top of the page when you navigate forwards by following a link. In contrast, you expect to be returned to the position on the page where you followed a link, when you use your browser’s back-button.

In case you happen to be using Backbone to power your single-page app, this behaviour can be restored with very little effort and code. Unfortunately, this will only work in browsers supporting the History API, so old-IE (IE 9 and earlier) users are out of luck.

To pull it off, a global navigation event listener is used to store the current scrollTop just-in-time.

<code>// A global a.onclick event handler for all your navigational needs
// see e.g. Backbone Boilerplate for a more complete example
$(document).on("click", "a", function (ev) {
    ev.preventDefault();

    // Replace current state before triggering the next route, 
    // storing the scrollTop in the state object
    history.replaceState(
        _.extend(history.state || {}, { 
            scrollTop: document.body.scrollTop || $(document).scrollTop() 
        }),
        document.title,
        window.location
    );

    Backbone.history.navigate(this.pathname, { trigger: true });
});</code>

Listening to the route event from your Backbone.Router you then restore scrollTop when it exists in history.state, or default to page top. To catch navigation happening via the back- and forward-buttons in the browser, Backbone.history should be set up to listen for popState events by setting { pushState: true } in the options to Backbone.history.start().

<code>// Backbone.Routers trigger the route-event
// after the route-handler is finished
var router = new AppRouter(); // AppRouter extends from Backbone.Router

router.on("route", function () {
    // Inspect history state for a scrollTop property,
    // otherwise default to scrollTop=0
    var scrollTop = history.state && history.state.scrollTop || 0;

    $("html,body").scrollTop(scrollTop);
});</code>

For those who need to see before they believe, take a look at the demo.

NB. The code examples are simplified to the extreme and shouldn’t be treated as complete drop in code.

Shorts

Oct 21st 2013

Revisiting an old classic

11:02

Last weekend, I clocked in quite a few hours playing an old classic: Frontier: Elite II. What inspired me to dust off a 20 year old game, was a series of Frontier tutorial videos I stumbled upon. While waiting for the upcoming Elite: Dangerous to be released, I’ll probably spend copious amounts of time exploring the vastness of space.

If the idea of being a space trader or rogue assassin tickles your fancy, but you’re the kind of person who prefers more advanced graphics, you should check out Pioneer. It’s an open source remake of Frontier with a very nice looking facelift.

If you, like me, prefer the original, a good source of information can be found at the Frontierverse website.

Aug 24th 2013

DigiPod wants to revive your old gear

22:57

DigiPod promises to deliver what Silicon couldn’t. The sub full-frame sensor is a bit of a let-down, but the prospect of having all that film gear for digital photography is interesting nonetheless.

Shorts

Meta

Pages

Search blog

Latest comments