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:

my-file.php*

I immediately started to wonder what that was about, but a quick search on duckduckgo.com 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.

http://scie.nti.st/2008/8/22/gnu-screen-with-vertical-split-support/
http://lugatgt.org/content/gnu_screen/downloads/presentation.pdf
https://en.wikipedia.org/wiki/Dovecot_%28software%29
http://www.computerhope.com/ushort.htm
http://www.oreillynet.com/linux/cmd/cmd.csp?path=s/screen
http://fishbowl.pastiche.org/2004/01/19/persistent_login_cookie_best_practice/
http://developer.yahoo.com/blogs/ydn/posts/2007/01/douglas_crockford_advanced_jav/
http://courses.cms.caltech.edu/cs11/misc/xwindows.html
http://www.objectmentor.com/resources/articles/Principles_and_Patterns.pdf
http://html5doctor.com/how-to-get-html5-working-in-ie-and-firefox-2/
http://zaemis.blogspot.com/2009/06/currying-in-php.html
http://www.kuro5hin.org/story/2004/3/9/16838/14935
http://lifehacker.com/307609/reduce-terminal-clutter-with-gnu-screen
http://web.archive.org/web/20040613170158/http://ashitaka-san.home.comcast.net/yayrant/antiswitch.html
http://tomayko.com/writings/Screen (Not very interesting, or useful, but just for the record…)
http://extralogical.net/articles/currying-javascript.html
http://danwebb.net/2006/11/3/from-the-archives-cleaner-callbacks-with-partial-application
https://grouptalent.com/blog/why-we-don-t-use-heroku
http://calnewport.com/blog/2011/11/11/if-youre-busy-youre-doing-something-wrong-the-surprisingly-relaxed-lives-of-elite-achievers/
http://www.goodboydigital.com/pixi-js-is-out/
http://vinay.howtolivewiki.com/blog/other/why-theres-no-money-the-imaginary-part-of-financial-systems-3235
http://thoughtcatalog.com/2013/procrastination-is-not-laziness/

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:

http://developer.yahoo.com/blogs/ydn/posts/2012/11/android-security-for-the-novice/Via Twitter I got to this very basic article about Android security.

http://www.muyinteresante.es/retrato-robot-de-un-supermillonario?utm_source=twitter&utm_medium=socialoomph&utm_campaign=muy-interesante-twitter – Also via Twitter, I found this mildly interesting article (Spanish) about the general profile of most Millionaires in the U.S.

http://www.motherjones.com/environment/2012/11/rare-earth-elements-iphone-malaysia?page=3 – 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:
http://webdesign.tutsplus.com/articles/designing-in-browser-a-manifesto/ As the title says, a manifesto on web designing done directly on the browser. Via search on duckduckgo.com (yeap, I don’t use google! Say no to the bubble!)
http://www.microsoft.com/en-us/download/details.aspx?id=11575 Get free virtual machines for testing on old versions of IE. Via Hacker News

Programming:
http://www.codewa.rs/ A cool site for programmers. Just check it out!
https://speakerdeck.com/kennethreitz/python-for-humans A presentation on Python programming language.
http://www.cs.berkeley.edu/~vazirani/algorithms/all.pdf A book on algorithms. Via Hacker News
https://code.google.com/p/android/issues/detail?id=19827 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.
http://www.ofbrooklyn.com/2012/11/13/backbonification-migrating-javascript-to-backbone/ Developing with backbone.js via Hacker News.

Security:
http://pixus-ru.blogspot.ru/2012/11/hack-any-skype-account-in-6-easy-steps.html Cracking Skype accounts. Via Hacker News
http://www.wired.com/gadgetlab/2012/11/ff-mat-honan-password-hacker/ Password are obsolete. Via Hacker News.
https://plus.google.com/101960720994009339267/posts/hoJdanihKwb Rob Pike on OOP. Via Hacker News.

Other Interesting Articles:
http://www.bbc.co.uk/news/magazine-20243692 An article about eating habits through history. Via Hacker News.
https://plus.google.com/105363132599081141035/posts/Lce7wEJApEr About selling games on the conventional way. Via Hacker News.
http://ninjasandrobots.com/facebook-pages-nest-thermostat Facebook likes and how they could spam your friends. Via Hacker News.