December 2010
15 posts
GMX: Big Email Fail
So what’s Email for? You can converse with your friends, subscribe to, and read mailing lists, subscribe to online services. I’m sure you already know all that. So, the point is, my GMX account has recently been blocked. And they couldn’t respond to support Email in two days, so I researched a bit and it turned out they blocked quite a few accounts, and it wasn’t the first...
Dec 26th
3 tags
Dec 24th
1 note
2 tags
Reading the Current Keyboard Layout With Conky
I use Conky to fill in the status bar in scrotwm. I wanted it to show the current keyboard layout, so I googled around, and after hacking some examples, I came up with a working solution. Here’s the code: XKB: ${exec setkxbmap -v 7 | grep layout | awk '{print $2}'} [${exec setxkbmap -v 7 | grep variant | awk '{print $2'}'}] The first part extracts the line that says layout:...
Dec 19th
2 tags
Scrotwm is Awesome Not
I’m just kidding. It’s awesome. But it’s not awesome-wm, that’s my point. And it’s a good thing too. After an update, my awesome window manager no longer understood my fine-tuned configuration file (AGAIN!). And that was in the middle of something I was doing, and I really didn’t feel like digging through the changelog (which looks like a dump from their SCM)...
Dec 19th
3 tags
So Many Choices: Haskell's Turn
These days I’m on a platform testing binge of a kind. I’ve been programming in Python for quite a while now (has it been 3 years already?!). I’ve also used Ruby on Rails before that, for something like 6 to 12 months. I’ve also used PHP for a week, and server-side JavaScript for two days recently. I fiddled with Erlang and Yaws, and haven’t gotten too far. So why am I...
Dec 18th
3 tags
Ranger: Vim-Like CLI File Manager
If you like Vim, you’re gonna just love Ranger. It’s a file manager that works like Vim, feels like Vim, and smells like Vim. In one word: awesome. Ranger comes from hut, fellow Arch Linux user, and obviously a command line freak. It’s not your average twin-panel commander clone. It features a tree-like multi-column view, and you walk the tree using (yes, you’ve...
Dec 16th
1 note
2 tags
Organizing Code in PHP
Because of the way PHP handles includes and scope, it may sometimes be challenging to organize your code in multiple scripts. It’s however, possible to do so with just a little bit of (not necessarily demanding) planning. So let’s see how including works in PHP and how to organize code better. Unified scope Here’s a diagram of a simple response cycle with two incudes. ...
Dec 12th
3 tags
Strangling PHP Scripts with Vim
Sometimes, you just get blank screens, or you’re curious to take a look at what your class method does. You can set up a server, and load a page, sure, but that’s too cumbersome. Even running your script through php in your terminal is tedious sometimes. You just don’t feel like it. Good news is, you’re one of the smart programmers using Vim. Good for you, because the...
Dec 10th
2 notes
3 tags
PHP Lambdas and List Comprehensions
I know I said I’d write about lambdas, but it turned out there are no list comprehensions in PHP 5.3, and you need to use functional tools like arrray_map() in conjunction with lambdas in order to achieve things that are commonly done through list comprehensions. As a reference, here’s a piece of code that creates option elements for a select list written in Python: a = [ (1,...
Dec 9th
2 tags
PHP and Short-Circuit Evaluation
Short-circuit evaluation is something I really liked in Python, and is one of those things I really can’t give up. Sadly, PHP converts all values to boolean type when used with boolean operators, so the classic a = b or 'default' type of evaluation is not possible. There are two ways around this that I’m aware of (not counting the possibility of writing custom functions). The syntax is...
Dec 9th
3 tags
CSRF4PHP: GPL Cross-Site Request Forgery...
I’ve looked around the Internet a bit, and haven’t had much luck locating a CSRF protection library for PHP. There was a page on OWASP website about the PHP CSRF Guard that mentions a download, but no links. Search for PHP CSRF Guard also turned out nothing. So I kept looking until I stumbled upon a script that was downloadable, but sadly not free (doesn’t allow commercial use)....
Dec 8th
1 note
3 tags
Separating Logic from Templates
One of the great advantages (in my opinion) of PHP over other languages is its birthplace within HTML. This makes it a 2-in-1: templating and programming language. While some consider it a bad thing, I actually find it a great asset, and the inability to separate logic from the template (HTML) that everyone seems to be talking about is probably a matter of skill (or lack thereof) rather than...
Dec 7th
3 tags
Lately, I’ve been thinking about how much religion actually creeps into the lives of most programmers I know, including myself. Our discussions not only hinge on technical merit, but also on beliefs and prejudice. When I was starting off as a web developer a couple of years back, my first contact with actual programming wasn’t PHP, but things like Ruby and Rails, Python and Django,...
Dec 7th
5 tags
Turn Vim into Powerful JavaScript Editor
After trying NetBeans, AptanaStudio, Emacs, KomodoEdit, and Jedit, I’ve finally settled on Vim (again) for my JavaScript/HTML/CSS editing needs. AptanaStudio is ok by default, but extending it wasn’t very fun. NetBeans simply doesn’t do what I need. KomodoEdit has no code re-indentation (code formatting) feature which is a big fail in my opinion. Jedit was just ugly, and the...
Dec 4th
13 notes
2 tags
DVCU: the Bootstrap
I’ve played a bit with what will become the foundation of the future DVCU framework. The first step was to introduce a better way to organize the JavaScript files. The asynchronous nature of JavaScript makes it a bit more difficult, and I’m still getting used to. One thing is rock solid right now, and that’s the bootstrap script. The bootstrap script is a very simple concept....
Dec 3rd