Formatting XML in Sublime Text 2 (xmllint)


I'm always looking for the best tools to make my life easier. In this constant search for the best text editor for coding and general text work (mainly XML) I decided to try the amazing Sublime Text 2.

I was using TextWrangler for a while and had finally manage to get XML pretty formatting to work on it again but I was struggling to get the same experience out of Sublime Text 2. My ideal workflow is to paste some unformatted XML, press some hotkey combination and end up something pretty. Because there's always someone with with the same problem, a quick google search took me to this page where there are a couple of scripts to do just this. Read that first to get a grip on how to implement these simple scripts.

While this seemed to work pretty well I was still having some trouble with some files that weren't being formatted exactly as I expected. These scripts use the open source tidy command, which is pretty cool. However, for some reason my XMLs (which included some CDATA elements) were not being formatted properly. So I decided to use xmllint instead, just like I had done before in TextWrangler.

Continue reading →

Getting XML Tidy (xmllint) to work on TextWrangler 4.0


TextWrangler has recently released a major update - version 4.0. A lot has changed, check out the release notes here.

One of the things that changed is the way it handles scripts and text filters. If you don't want to read through the whole thing, here's the main part:

There are two fundamental types of runnable file: "text filters", which accept the selection range (or entire document, if no selection) as input, and which return text that replaces the selection range (or document); and "scripts", which do neither. In unix-y terms, text filters accept the selection range on STDIN, and STDOUT replaces the selection range.

It just happens that I use XML Tidy a lot to format xml documents in a pretty way. To do that I had a nice little script (which is just a xmllint command really) for which I assigned a shortcut (alt+cmd+p). That made my workflow pretty fast. The problem is that this script stopped working as before so it took a while to find out why but I found a thread in google groups about this issue and someone from Barebones helped find the solution. So in summary, here's what you have to do to make XML Tidy work again in TextWrangler 4.0:

Continue reading →

How to fix warning: setlocale: LC_CTYPE: cannot change locale (UTF-8)

I recently encountered a problem when logging through SSH in to certain servers that I use for work when using my new Macbook Pro (running Lion 10.7.3).

So right after the login was completed I was getting the following message:

warning: setlocale: LC_CTYPE: cannot change locale (UTF-8)

It only happened on certain servers, for others everything would work just fine.
This caused a few problems when running some perl scripts that would complain about the locale variables not being set, even though my Terminal app was setup correctly.

To fix this I simply added the following to my ~/.bash_profile:

export LC_CTYPE="en_US.UTF-8"

Let me know if that helped you by leaving a comment below!


Lior Ron talks openly about Google Hotpot

It's a great thing when companies talk openly about their projects. Of course, never revealing the really juicy classified-type of information but giving out some very interesting details. Google has nurtured such a culture and this video is a great example of that. Lior Ron, Google's product manager for geo search, talks openly about Hotpot and the thinking behind its creation on an episode of ThisWeekIn Startups.

(Go directly to min 4:50).

 

[vsw id="zEC42W-UucA" source="youtube" width="560" height="345" autoplay="no"]

Jeremy Cowart

I just want to quickly share a great photographer that has conquered some real clients like ABC, E!, Fox, Sony, and many others.

He has a distinct style producing strong and bold images. The visual impact of his pictures makes you want to keep looking at them. Also worth mentioning is his beautiful website (it probably helps that fact that he was a designer before).

Jeremy Cowart - Website

http://www.jeremycowart.com/

Fixing the “unexpected T_ENDWHILE” error in WordPress + xampp

I have recently been through a lot of pain trying to configure a local installation of WordPress using xampp. The problem was that after activating a theme (not the default one) I was getting an error:

Parse error: syntax error, unexpected T_ENDWHILE in (...........)

This was driving me crazy but after a lot of searching I FINALLY found the solution! I'm so happy that I want to share it with the world because I really only found this valuable piece of information in one page (and I did a lot of searching, believe me).

When installing a local copy for use in a development environment one of the main problems to tackle is making sure that your local server is as close as possible to your production environment. There are many variables that can change like software versions and configuration parameters. For this specific case it's one simple parameter in the php.ini file that was causing issues.

Some php developers like to use short open tags, and even though I do agree that it can save some time and make the code a bit cleaner, there's a lot of discussion around it.

Long story short, apparently the php.ini file included in xampp has the option:

short_open_tag = Off

by default. By simply changing this to:

short_open_tag = On

all my problems were magically resolved!

I hope you find this useful.

List of essential free software

After cleaning up my computer and having to reinstall everything I decided to tidy up my archives and take advantage of my brand new 1 TB Lacie external hard drive to put all those little tools I always end up installing sooner or later. These take up something like 170mb and can be really handy. Please note these aren't listed in any particular order, and I'm also excluding basic things like Firefox - that's mandatory ;)

7-Zip

The best compression tool around. Has support for nearly all formats you'll ever use in your life. Make sure you tru the 7zip format, it has really good compression rates.

Download: http://www.7zip.com
Portable:
http://portableapps.com/apps/utilities/7-zip_portable

Continue reading →

Screenshots on steroids with PrtScr

I love simple tools that make my life easier, and I just found out one of those. And this one has an extra WOW factor because it's beautiful in the way it does what it does - grab a screenshot. It's called PrtScr and you can find it here: http://www.fiastarta.com/PrtScr/ You'd better see it by yourself: