HTTP : The headers we want

The headers we want” is a very simple, straight to the point blog post on the Fastly blog.  Unlike many other more generic articles on the subject, it doesn’t try to explain the meaning of every HTTP header out there, and it doesn’t go into deep theory or the meaning of life, the universe and everything.

Instead it tells you plain and clear which headers should be emitted by your website or web application.  And these cover everything from the usual Content-Type and Content-Length, all the way down to the CORS and Server-Timing.

Once the basic functionality of your website or web application is done and out of the way, this blog post comes in handy with the specific best practices to make your site more secure and much faster.

For more on the same subject, have a look at “The headers we don’t want” in the same blog.

git worktree – a better way for git stash abusers

If you constantly find yourself using “git stash” while working on a project, or, even worse – have multiple copies of the same project cloned on the same machine, “git worktree” might be a much better alternative for you.

Manage multiple working trees attached to the same repository.

A git repository can support multiple working trees, allowing you to check out more than one branch at a time. With git worktree add a new working tree is associated with the repository. This new working tree is called a “linked working tree” as opposed to the “main working tree” prepared by “git init” or “git clone”. A repository has one main working tree (if it’s not a bare repository) and zero or more linked working trees.

When you are done with a linked working tree you can simply delete it.

Here are a few links to get you started:

 

When and where to determine the ID of an entity

It always amazes me when I randomly come across an article or a blog post precisely on the subject that I’m mulling over in my head – all without searching specifically for the solution or even researching the problem domain.  It’s almost like the universe knows what I’m thinking and sends help my way.

When and where to determine the ID of an entity” is an example of exactly that.  Lately, I’ve been working with events in CakePHP a lot.  And for one particular scenario, I was considering the beforeSave() event in the model layer, which would trigger some functionality that modifies data in other models.  So, having a reference of the current ID would be useful for debugging and logging purposes.  But since the current entity hasn’t been saved it, the ID is not there.   And that’s where I started thinking about this whole thing and considering where is the right place to generate the ID.

One thing that kind of bothered me on top of the theoretical discussion, was the practical implementation, especially in different frameworks.  If I remember correctly, the earlier version of CakePHP framwork, used the presence or absense of the ID in the entity to differentiate between insert and update operations.  It might still be true now, but at least there is a way to work around it, as CakePHP now has isNew() method to check if the entity needs to be inserted or updated.

 

11 Best Programming Fonts

It’s that time of the year once again, when you should take a five minute break from whatever it is you are doing.  Here are “11 Best Programming Fonts” that might help you out in being a little bit more productive.  If not that, than at least bring you a slight change and some eye candy, when staring at your code.

For me personally, Source Code Pro by Adobe (featured in the screenshot above) is still the best option.  I have it setup in the Terminator as Source Code Pro Semibold at size 11, which makes it large enough to work with the code comfortably and small enough to eat too much screen space.

If you want to find and compare more fonts, have a look at these two resources:

 

commandlinefu – a place to share and gather command line wisdom

commandlinefu is a place to learn and share your knowledge about command line tools and techniques.  It has thousands of tips, tricks, and handy shortcuts, covering a wide range of tools from shells and editors to version control and remote access.