pythonaro.com

Pythonaro blog

28 April 2008

Notes on Emacs

I'm giving Emacs a serious chance, so here are a few notes, mainly for personal future use.

  • auto-indent an entire file:
    (defun iwb ()
    "indent whole buffer"
    (interactive)
    (delete-trailing-whitespace)
    (indent-region (point-min) (point-max) nil)
    (untabify (point-min) (point-max)))
  • find .emacs on Windows: C-x C-f ~/.emacs (I know, it's banal, but...)
  • set tab size to my favourite default (3):
    (setq-default tab-width 3)
    (setq-default c-basic-offset 3)
  • php-mode: haven't quite understood how to activate it yet. I get syntax highlighting for everything BUT php. D'oh. UPDATE: ahh, you have to byte-compile it yourself. What a lazy environment for a dynamic language! Anyway, thanks to this blog post, I now know how to do it: M-x byte-compile-file (and then point to php-mode.el)
    UPDATE: Oh, and you have to use the 1.2 version with emacs 21 and lower.
  • (UPDATE) To maximize it at startup, two options:
    • Easy one: in the registry (HKCU\Software\GNU\Emacs, which you have to create), set a String property called "Emacs.Fullscreen" with value "fullboth". Unfortunately this is calculated from the very bottom of the screen, so if you have the taskbar set to "always on top" and no "auto-hide" (like me), you will end up with the taskbar covering the minibuffer.
    • better one: do
      M-x : (frame-width)
      and write down the number that comes up (e.g. 155), then repeat with (frame-height). Then (in the same key as above) set a String property "Emacs.Geometry" set to these value, e.g. 155x59. If you have the same taskbar issue as above, reduce the second parameter until it's ok (I had to reduce it by 3).

Why Emacs? I'm doing a "good deed" which involves php, and since I have to churn out loads of useless "$" and "->" and brackets, maybe it's time I learn a proper power-tool for text editing.

Labels: ,

posted by GiacomoL @ 4:39 PM   0 comments links to this post

27 April 2008

MySQL character set ("charset") options for UTF8

While dabbling with PhPeace, I found out a few things about how MySQL handles charset options.

There are several levels at which you can specify a charset, from top to bottom: server instance, database/schema, table/column and, finally, connection.
Usually, the lowest option will override the previous one, so if you specify the encoding at connection level (with a query like "SET CHARSET 'utf8'; SET NAMES 'utf8' COLLATE 'utf8_general_ci';") you should be safe. However, if you want to fix things "once and for all", you can add these options to your /etc/mysql/my.cnf file (or adding a /etc/mysql/conf.d/UTF8 in Debian with these options):

[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
default-character-set=utf8
[client]
default-character-set=utf8

The *-server* options are instance-specific, while default-character-set is connection-specific. If you wonder what the "collation" stuff is, it's the method to use for sorting. I'm not sure if, as guideline, you should use utf8_unicode_ci rather than the default utf8_general_ci, but I didn't find out how to override the default option at connection level in the .cnf file, so I'll stick to utf8_general_ci to have a consistent environment.

Labels: , , , , ,

posted by GiacomoL @ 10:25 AM   0 comments links to this post

08 April 2008

Google App Engine

Google App Engine. Write applications in Python using a WSGI-compatible application framework, then host them on Google’s highly scalable infrastructure.
(via Simon Willison's Links)

"Holy s**t" was Ryan Tomayko's comment, and my first thought as well. Google is realising the promises of WSGI, and what a sight it is.
On one hand, this is fantastic; it made me think of "J2EE done right". On the other hand, if you use GAE, you are handing your entire infrastructure and data (!) over to Google, which might not be the smartest move for lots of companies (any FTSE100 for example, and probably any NASDAQ-listed as well).

Anyway, Python rocks.

Labels: , , , , ,

posted by GiacomoL @ 12:04 PM   0 comments links to this post

07 April 2008

Do The Indie Kid

I love MJ Hibbett & The Validators, and you should too. So here's his latest video.

Labels: , , ,

posted by GiacomoL @ 4:31 PM   0 comments links to this post