A right kerfuffle

A blog about web development, programming and the awesomeness of the Internets

Free ebook on database indexes

For a great indepth tutorial of indexes and its uses in SQL databases, I recommend taking a peek at Use the index, Luke:

A site explaining SQL indexing to developers—no crap about administration. SQL indexing is the most effective tuning method—yet it is often neglected during development. Use The Index, Luke explains SQL indexing from grounds up and doesn’t stop at ORM tools like Hibernate.

Read “Use the index, Luke”

Identifying non-authenticated users with fingerprints

When building an app without user authentication, you sometimes still want to limit anonymous user actions. One route could be using cookies or IP numbers, but both are limited in that cookies can be manipulated (or deleted) and IP numbers might change. Luckily, there’s a another alternative and its called fingerprints.

Much like a persons fingerprints, a device can be anonymously identified by the combination of certain metrics that are available to the browser. Your screen resolution, operating system and language settings are in themselves not enough to single you out – but adding up enough of these identifiers you have a pretty unique set.

So instead of setting up a system of cookies, I recommend using the fingerprint as an anonymous but unique user ID, one that can be persisted and used globally in your app.

Five favorite online utilities

The Brandmark font generator

Get ideas for font pairings for your website with this handy little utility.

What’s my browser

Some users are tech-savvy, but most are not. Just send them to “What’s my browser” and get a reliable set of metrics for troubleshooting back when problems arise.

TinyPNG

When you need to quickly compress a bunch of PNG or JPEG files. Just super easy to use and produces great results.

Crontab Guru

Cron jobs aren’t that complicated, but I sometimes use this to quickly verify a crontab schedule expression, or as a quick crontab reference sheet.

What the status code

Another simple online utility, for finding the correct HTTP code.

Moved to Vultr

This blog doesn’t pull that many visitors, it’s sort of a work in progress. So when moving from a shared hosting solution I was looking for an option that:

  1. Is cheap
  2. Requires little manual tinkering

This was surprisingly difficult to find. I mean, you could always get another shared hosting solution, or choose a package solution specifically for running one WordPress site, but most either put unnecessary restrictions (“you can only have one of these selected WordPress themes”) or just cost more than I used to spend. It’s just a WordPress blog after all. And on the other end – sure, you could always spin up a VPS instance for $5 per month and that would do. But then you’ll spend too much time just setting up your own server.

So when I found Vultrs app containers I was pleasantly surprised. At $5 you can get your own instance of a pre-configured container running WordPress (or something else). A few minutes of configuration and you’re basically up. It remains to be seen if this approach comes with any substantial drawbacks but initially I’m pleased with the service.

The only safe email is text-only email

Modern email clients try to safeguard us from malicious code injected in HTML emails. They might help by flagging suspicious looking senders, or hiding embedded images. But getting junk email is like being forced to visit some weird Russian site offering BitCoins. How many of us still maintain “oh but we don’t visit shady sites so there’s no real risk”? And yet, when someone with malicious intent can send this to us directly, we expect the amazingly dated browser in what, Outlook to keep us safe?

Read “The only safe email is text-only email”

Laravel routes in different files

When starting a new Laravel 5 project, all “web” routes reside in the routes/web.php. Adding a bunch of routes, maybe using Route::group for different controllers, quickly adds up and makes it hard to keep things neatly organized. Lucky for us it is very simple to add your own route files!

First create a new route file in routes folder. I’m gonna call mine admin.php and move all my admin area controllers to this file.

Open your app/Providers/RouteServiceProvider.php and find your method map():

public function map()
{
    $this->mapApiRoutes();

    $this->mapWebRoutes();

    // Add your own method here:
    $this->mapAdminRoutes();
}

And for your mapAdminRoutes() method you simply register a new route file. In my case I’m gonna use /admin as a prefix for my admin controllers, and control access through a special middleware:

protected function mapAdminRoutes()
{
    Route::prefix('admin')
        ->middleware(['web', 'authAdmin:admin_access'])
        ->namespace($this->namespace)
        ->group(base_path('routes/admin.php'))
    ;
}

There you go! Now my new route file can be stripped from its Route::group, and routes/web.php is kept to only public controllers.

Choose boring technology

A modern classic, one could say. Dan McKinley about the perils of early adoption:

One of the most worthwhile exercises I recommend here is to consider how you would solve your immediate problem without adding anything new. First, posing this question should detect the situation where the “problem” is that someone really wants to use the technology. If that is the case, you should immediately abort.

Read Choose Boring Technology

In defense of XML

Niche Software writes a blog in defense of the XML format. To be honest, I’m guilty of this. I hate XML documents that are verbose and unsightly.

However, should poor use of XML, even if widespread, be sufficient for us to abandon use completely? Especially when the very flexibility — extensibility — of XML has allowed it to be misused in the first place.

Read “In defense of XML”

How to make your code sustainable – what they don’t teach you

Great talk from Christin Gorman about making code just complex enough. (Her ranting about interfaces reminds of my everyday job.)

How the Database Will Hurt Your Startup

Excellent piece, poor title. Curtis Poe writes about the importance of understanding relational databases:

Your application is all about data. For many people in management, they see the app or the web page, but they don’t see the database hidden underneath. They understand that without their data the company is probably in serious trouble, but they don’t give much thought to it. In fact, while total data loss will probably bankrupt your company, few give much thought to the the standard data quality issues that are a constant financial drain because it’s assumed to be part of the cost of doing business. And the developers who don’t understand how to use databases often tell management “that’s just the way this technology works.”

How the Database Will Hurt Your Startup

Page 1 of 2

Powered by WordPress & Theme by Anders Norén