Home » Posts tagged "code"

Link: A Brief, Incomplete, and Mostly Wrong History of Programming Languages

One Div Zero: A Brief, Incomplete, and Mostly Wrong History of Programming Languages

Been awhile, some fun Drupal code-related stuff

Been busy with the play and work. We switched to a 4 day, 9 hour work week. So that leaves me with about 2 hours each day for non-theater, non-work related stuff. Not counting the day off, I guess.

Anyway, check this out. I have been tasked with writing a SQL Server database module for Drupal 6. This is not fun. It’s slow, Drupal is written poorly for abstraction, and there are odd idiosyncracies one has to deal with. But that’s not what I want to tell you about.

This is the vargrind output between a semi-working mssql installation and a working mysql installation. That 400 number is the number of queries the MSSQL module needs to do to render the ‘My Account’ page. For comparison, MySQL only requires about 40.

SQL Server versus MySQL
(The reason it’s so high is because one must select the error code to check for an error, then select the code meaning from the database if there was an actual error. For every query.)

Coding: Rails Issues with :include

This is a sort of code analysis and something I discovered with :include usage in Rails. (This is in rails 1.1.6, so YMMV. I believe the latest Rails opts to use inner SELECTs rather than JOIN statements.

Also, this is kind of long.)
Read more

Code: Dynamically Insert HTML Into Any Rendered PHP Page

So, this pleases me enough to post it.

dynamic buffer insertion with PHP

Needed to quickly add a notice to every page on a client’s site where there was a single include, but not single-included layout pages (teachers, *sigh*).

I’ve never messed with output buffer stuff before, so this was just sort of surprising to me. It’s insanely useful.

Only took about a minute to code, and two to deploy.

Operator Precedence (ruby et al.)

Thought this was a little silly, but it generated a lot of discussion about precedence, short-circuiting of conditionals, and the value of syntactic sugar.

http://pastie.caboo.se/146194

Seriously Word Press, WTH?

While trying to figure out how to remove formatting from ‘wp_list_cats’ in Word Press, I discovered this awesome bit. Click the thumbnail for the full glory of the code.
WP List Cats Insanity!

You will notice that in my screenshot, the final function call to ‘list_cats’ at the end is truncated. This is because there are eighteen parameters. Again with the clicking.
list_cats even more insane!

Also, there’s an awesome feature in the WP DB object such that if one requeries the same table on the same page, apparently pagination offset is lost. This means that the main index page listing posts cannot also have a recent posts list — because you either will have recent posts starting with whatever the main list offset is, or you will only ever have as many posts on the index page as the recent posts query returns.

WIN!

Vim tip: keyboard shortcuts

Finally got around to learning how to define keyboard shortucts in vim. It’s easy!


map <desiredkey> <targetaction>

So, for example, I split windows vertically and want to navigate via ctrl+pagedown or pageup.

Here’s what I did (include < and > when defining)

map <c-pageup> <c-w>h
map <c-pagedown> <c-w>l

Found via a vim wiki search
[ad#Google Adsense small leaderboard]