code

Quick Shell Tip: Find empty lines after closing PHP tags

If you’re using PHP to output XML, and you have empty lines outside of your <?php and ?> tags, you may insert empty lines before your opening XML tag - a big no-no. Apparently, that invalidates XML.

To detect this, use this Bash code in a directory of PHP files:

for file in `find -type f -name "*.php"`; do lines=$((`wc -l ${file} | cut -d' ' -f1`+1)); pos=`grep -Hn '?>' ${file} | cut -d: -f2`;  `(($lines != $pos ))` && echo $file ; done

Disclaimer: I wrote this code while in an unnatural state (who ever is?). It may break your code, impregnate your cat, cause your baby sister to fall madly in love with your microwave, or really, anything else. It even might (definitely) fail to check for newlines before you opening <?php tag! And it’ll complain if you don’t have a closing ?> tag (you’d be surprised how … inconsistent people may be). Anyway, don’t complain to me.

Snippits 0.5.2 released

I’ve just released Snippits 0.5.2, my Ruby text expansion program for Linux. This version contains mostly bugfixes and documentation updates. The full changelog is below. I also have put together a roadmap of future versions of snippits, and what they might entail. Take a look; any feedback is appreciated.

  • Bugfixes
    • Updated README on how to use GPG-encrypted files. Please try it and report

Snippits

About

This is Ruby text expansion program – it will type text for you. It uses ‘snippits’, small text files with a simple syntax to determine what to type. However, snippits can be very powerful, since they can contain embedded Ruby, special keys (Control, Shift, Up, etc), and can contain a cursor placement instructions.

Install

Install by running: sudo gem install snippits

Screencast

Below is a demo of how snippits works…

How To Update Facebook, Twitter, and Kopete's Status All At Once

I have whipped up a short script to update Facebook’s status, Twitter, and Kopete’s status all at once. The Facebook portion of the code comes directly from Kerry Buckley’s script

Syndicate content