Sublime Text 2 opens files in new window

A small annoyance of Sublime Text 2 for me was the fact that it always opened files in new windows instead of reusing the existing ones (OS X only). It turns out it's quite easy to change this behavior. Here's how:

Sublime Text 2 menu > Preferences > Settings - Default

Now search for the following: open_files_in_new_window

The line will look like this:

// OS X only: When files are opened from finder, or by dragging onto the
// dock icon, this controls if a new window is created or not.
"open_files_in_new_window": false,

Just change "false" to "true" and you're done!
Now whenever you open a file it will reuse any existing window you already have.

Bash script to check server load and notify by email

Lately I have been dealing with high server load problems, both at work and on my own server so I've been reading about it and trying to understand what it means and how to debug such issues. I don't mean to lecture you on the subject on this post but I will point you to a great article that explains it in a very simple way: Understanding Linux CPU Load - when should you be worried?

After reading that you'll know a lot more about what load means and the its different types. So how do you know if your server has a sudden spike of traffic causing high load for example? You surely can't be logged in all day typing 'uptime'. You could, however, have some sort of monitoring tool that will alert you automatically. If you're dealing with a high traffic production server you most certainly have a "real" monitoring tool such as Nagios or Zabbix. If you're like me and host a small website on a small VPS then some of those solutions might be overkill.

Continue reading →

Samba shares and SELinux – how to fix “Invalid key 0 given to dptr_close”

I recently had the need to configure a samba share on a linux box running Scientific Linux and I ran into a very annoying problem. I'm not going to explain all the details about how to configure the samba server and configure it (there are quite a few tutorials around for that, and I actually used Webmin which makes it very easy).

So after configuring everything, setting permissions and creating a user with simple password authentication, I was able mount the share on my mac but no contents were shown, not a single file.

Continue reading →

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 (xml mainly) 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 the TextWrangler script.

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/