The Asterisk Next to the Filename in Vim’s Netrw

Yesterday I was opening up a file, but since I didn’t quite remember the name of it, I decided to instead open the containing directory in Vim:

:vsp ../dir-name

This worked as expected, opening the file browser, which I learned is called Netrw. However, I noticed that one of the files had an asterisk next to its name:


I immediately started to wonder what that was about, but a quick search on produced no satisfactory results, so I hit F1 in vim, and the help page came up. Then I searched for *


which, of course, started to find a lot of asterisks because it seems vim uses them a lot in the help pages, but at some point I finally came to a section that explains that

“The |getftype()| function is used to append a bit of filigree to indicate filetype to locally listed files:”

Those indicators are as follows:

directory : /
executable : *
fifo : |
links : @
sockets : =

So there you have it; an asterisk next to a filename in Netrw means the file is executable.

The Netrw man page seems to be full of really nice information, so I now owe it to myself to give it a good read. You should too if you are into Vim.

The WordPress Auto Draft

Disclaimer: I’ve been away from the wordpress world for over a couple of years now, so I don’t know if this is common knowledge in the wordpress circles or not. Heck! I don’t even know if this is something that has always happened, or if it is something that was implemented while I was away from WP, but it is definitely something that threw me off a bit recently.

After some time away from WP, I decided it was time to go back and try all the new features that have arrived to WP since I left it a while back. I started developing a small webapp. I know I could have used something better suited for the task, like Laravel, but the goal here is to get WP to do something that clearly stretches its limits. One of the things I wanted to do was to assign an ID to custom-type posts. I didn’t want to rely on the post’s id, but rather create an md5 hash of the post’s title. The key part was to create it when the post was first created and then never change it again, even if the title changes. The post’s id would have suffice, but remember that this is an exercise to get back into wordpress development.

My first instinct was to use the `save_post_{$post->type}` action hook. This action passes a boolean parameter to the callback function that specifies if the post being saved is an update of an existing one. If it isn’t, we can assume the post being created is brand new. Relying on this boolean seemed like the obvious choice since it would allow me to save the md5 hash only once when the post is first created, and never touch it again. So, I did it this way. However, later, when I decided to display a custom row in the all-posts table that displayed the post’s custom id, I realized that all the posts had the same custom id. How was this possible? Digging into wordpress I found out that every time you open the new post page, a new post is saved in the database with title “Auto Draft” so all my md5 hashes were being generated from that “Auto Draft” title. No wonder they were all the same!

So, how does this happen?

When you first open the new post page (post-new.php) a function named `get_default_post_to_edit` is called, which, among other things, creates a new post in the DB, creates a new post object for it, and passes it along to other functions and hooks. This is actually a good thing because it makes sure you are always working with a real post object that has a DB record, and an ID. However, if you aren’t aware of it, it may get you scratching your head for a little while when something doesn’t happen as you’d expect it to happen. Knowing these kind of subtleties is what makes the difference between a good, and excellent developers.

Read, the docs, but more importantly, read the codes!

Links of the Day

Some may be repeated from previous posts. I have been reviewing old reads lately.

Click to access presentation.pdf

Click to access Principles_and_Patterns.pdf

How to get HTML5 working in IE and Firefox 2 (Not very interesting, or useful, but just for the record…)

If You’re Busy, You’re Doing Something Wrong: The Surprisingly Relaxed Lives of Elite Achievers

Why there’s no money: the imaginary part of financial systems

Links Of the Day – 11/24/2012

As I stated on my previous post, I’ve been almost exclusively reading the AIR documentation, but I do have a few links to share with you today: Twitter I got to this very basic article about Android security. – Also via Twitter, I found this mildly interesting article (Spanish) about the general profile of most Millionaires in the U.S. – Via Hacker News I got to this interesting article. I won’t spoil it for you, but I must say that you ought to read it, just to increase your general knowledge about the gadgets you use.

Links of the Day – 11/15/2012

Whit this post I start a new category on the blog. I will be sharing the URLs to articles that I’ve read on that day or the previous days and that I found interesting. So, here they are:

Design and Web Development: As the title says, a manifesto on web designing done directly on the browser. Via search on (yeap, I don’t use google! Say no to the bubble!) Get free virtual machines for testing on old versions of IE. Via Hacker News

Programming: A cool site for programmers. Just check it out! A presentation on Python programming language. A book on algorithms. Via Hacker News A bug report that causes touchmove and touchend events not to be fired if preventDefault is not called on touchstart. Found after dealing with this problem on a project. Developing with backbone.js via Hacker News.

Security: Cracking Skype accounts. Via Hacker News Password are obsolete. Via Hacker News. Rob Pike on OOP. Via Hacker News.

Other Interesting Articles: An article about eating habits through history. Via Hacker News. About selling games on the conventional way. Via Hacker News. Facebook likes and how they could spam your friends. Via Hacker News.