By x3ro on April 17, 2011
If you are already using PHP 5.3.x and you’ve just upgraded to Typo 4.3 or greater, Typo3 might start throwing exceptions where previously everything had worked out just fine.
This is because the Typo3 developers chose to take some of the error handling into their own hands and raise exceptions for certain errors. Now these “certain errors” for which exceptions are raised include E_DEPRECATED, and as a bunch of functions have been deprecated in PHP 5.3, well, you know where I’m going with this.
Fortunately, there is a configuration variable which allows to change the default behavior:
$TYPO3_CONF_VARS['SYS']['exceptionalErrors']
The default value (defined in “t3lib/config_default.php”) is
E_ALL ^ E_NOTICE ^ E_WARNING ^ E_USER_ERROR ^ E_USER_NOTICE ^ E_USER_WARNING
To disable the deprecation exceptions, just add a ^ E_DEPRECATED like this (the line goes in your localconf.php file):
$TYPO3_CONF_VARS['SYS']['exceptionalErrors'] = E_ALL ^ E_NOTICE ^ E_WARNING ^ E_USER_ERROR ^ E_USER_NOTICE ^ E_USER_WARNING ^ E_DEPRECATED;
Thanks to this guy (link in German) for sending me onto the right path.
Posted in PHP, Typo3 |
By x3ro on April 13, 2011
If you google for “Array to Hash” then you will probably see this snippet close to the top of your search results, and it works pretty well too. However, since that snippet was posted, 6 years have passed, and with Ruby 1.9 it is a bit simpler now:
Ruby < 1.9:
a = [1, 2, 3].collect { |v| [v, v*2] } # => [ [1, 2], [2, 4], [3, 6] ]
Hash[*a.flatten] # => {1=>2, 2=>4, 3=>6}
Ruby 1.9:
a = [1, 2, 3].collect { |v| [v, v*2] } # => [ [1, 2], [2, 4], [3, 6] ]
Hash[a] # => {1=>2, 2=>4, 3=>6}
This is because Ruby 1.9 features a new form for Hash[ ]:
Hash[ [ [key, value], ... ] ] → new_hash
More info in the docs.
No wonder Ruby is still my favorite language :)
Posted in Programming | Tagged array, hash, ruby |
By x3ro on March 31, 2011
Today I came along a really nasty bug in a WebApp, which was caused by not setting the correct Content-Type. Took me a while to figure it out. The App had been working fine for a while now, and after writing a small extension to it, it broke down completely, because a JSON response sent from my server was suddenly invalid and could not be parsed by jQuery. The first problem was that my handler for the AJAX requests did not set a Content-Type, which somehow defaulted to text/html. The second problem was, that I had forgotten a closing tag in the HTML which was encoded inside the JSON string returned from the handler. Because the Content-Type was text/html, the browser tried to fix the missing tag by appending it to the end of the response, which obviously broke my JSON string.
From now on I will definitely always set the right Content-Type, so I never have to deal with such a bug again.
Posted in Programming, Web |
By x3ro on March 28, 2011
I’ve been experimenting with file-based blogging software (namely Blosxom) lately, and I wanted to automatically transfer my university notes from my computer to my server. I also wanted to add some versioning for backup, so the obvious thing to do was to use Git.
Git Hooks are pretty easy to use. When creating a repository with git init, a folder hooks/ is automatically created within your .git/ directory, which contains sample/skeleton scripts for all available hooks. To enable a hook, you just set its executable bit using chmod +x hook-file.
For checking out my repository after pushing, I used the post-receive hook, so I added the following to the .git/hooks/post-receive file:
pwd = Dir.pwd
Dir.chdir("../")
%x[echo "GIT_DIR = #{pwd} git checkout -f" 1>&2]
%x[GIT_DIR="#{pwd}" git checkout -f]
What the above Ruby code does is simple. It first stores the current working directory, which for a called hooks always seems to be the .git/ folder of the repository. Then it changes to the parent folder (the actual, checked out repository), and executes a git checkout -f there. Note that with the -f option will overwrite all modification in your repository, so be careful with that.
The GIT_DIR variable needs to be set, because git does not seem to automatically recognize the .git/ folder when called within a hook, which is probably due to some environment variable being or not being set. If someone knows the exact reason, feel free to drop a comment :)
More on Git hooks can be found here.
Posted in Git, Linux, Web |
By x3ro on March 27, 2011
Today I tried to update RubyGems on my system (Mac OS X), and I was presented with the following error message:
$ gem update --system
Updating RubyGems
ERROR: While executing gem ... (NoMethodError)
undefined method `version' for nil:NilClass
This guy saved my life by having posted a simple workaround:
$ gem install rubygems-update
$ update_rubygems
And voilá, RubyGems was up to date.
I couldn’t really find a clue what was causing this problem. If anyone knows, please leave a comment :)
Posted in Linux, Programming | Tagged ruby, rubygems |
By x3ro on March 26, 2011
A few days ago I installed Blosxom to store my university notes which I write in Markdown and in German language, and which are UTF8 encoded. But I couldn’t get Blosxom to not screw up the encoding even if I set the correct Content-Type Header in HTML. It turned out that you need to modify the line which says something like
$header = {-type=>$content_type}; # Around line 280
to this
$header = {-type=>$content_type, -charset=>'utf8-'};
This tells the Perl CGI module to send the correct HTTP encoding headers for your document. You should also add
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
to your HTML Head section (which you can find around line 430 if you are using the default template.
And voila, the multibyte characters aren’t screwed up anymore :)
Note: This fix does not work for static file generation in Blosxom, only for dynamic mode.
Posted in Applications, Web |
By x3ro on March 24, 2011
I spent the last hour on trying to figure out how to get decent coloring into the Terminal.app on Mac OS X (because iTerm has some weird bug with Displaying Umlauts and the like), and I finally got it to work following these steps:
- Install SIMBL.
- Install the TerminalColors.bundle for Mac OS X 10.6 or for Mac OS X 10.7, which I recompiled so it works with systems newer than Leopard and its Terminal.app Version.
- And by installing I mean dropping it into /Library/Application Support/SIMBL/Plugins for all users, or ~/Library/Application Support/SIMBL/Plugins for your account only.
- Install a theme, for example one of the two listed below.
Night Lion Theme

Infinite Red Black Theme

This should be it. Pretty simple if you know what to do :)
Posted in Mac OS X | Tagged terminal.app, themes |
By x3ro on January 16, 2011
Some days ago I found a nice Mac OS X application called “LaTeXiT”, which makes LaTeX formula generation really easy. If you are already working in a LaTeX environment you’ve got no problem anyway, but what if you’d like to use your LaTeX formulas in Pages (or Word), Keynote, etc… Either you go with the “generate from console” approach, or you use LaTeXiT. But see for yourself:
Get it here.
Posted in LaTeX, Mac OS X |
By x3ro on November 29, 2010
Sometimes LaTeX can be a real pain… Today I wrote a document where I needed a caption inside an \item marker, e.g.:
\begin{itemize}
\item [ Something \footnote{More} ] Lorem ipsum
\end{itemize}
But that didn’t work. The footnote number was displayed, but there was no footnote at the bottom of the page. A workaround is to include the package “footnote”, and create a “save note environment” for itemize, by including the following in the document header:
\usepackage{footnote}
\makesavenoteenv{minpage} % If you want to include minipages.
\makesavenoteenv{itemize}
Posted in LaTeX |
By x3ro on October 25, 2010
Recently, I needed to build a feature where connected Facebook users (in a FB connect application) could select a bunch of their friends in order to interact with them through the app. This was supposed to happen through a Multi Friend Selector like the following:

Facebook offers such a feature through the XFBML fb:multi-friend-selector Tag, but it resulted very hard to interact with it through JavaScript (showing it after the user clicks a button, performing a certain action after he selected his friends, etc…). I ended up using jQuery Multi Friend Selector which imitates the behaviour of the XFBML Tag.
Posted in JavaScript, jQuery, Web |