Monday, february 1st, 2010

Launching iTerm shells from Quicksilver

I recently decided to give iTerm a try, so I needed a way to launch shells and other things requiring a terminal the same way I launched them inside rxvt-unicode: using Quicksilver.

I suppose I could use AppleScript to do this, but…

  1. I don’t really like its syntax;
  2. I’m currently addicted to python;

So I made qslaunch, a very small python package to help do the job, and this little post to tell how to use it :)

In this post, I’m assuming some knowledge of python, regular expressions and how to use a shell.

I won’t detail things too much either as I think the code speaks by itself.

Read the whole post…
Posted at 20:13
Anglais seulement
Tags: iTerm · python · qslaunch · Quicksilver
Friday, january 29th, 2010

“Repeat command” in TextMate revisited

As I said in a previous post (“Repeat command” in TextMate), one of the things I use a lot in jed editor, my favorite terminal editor, is the “repeat command”: pressing ESC, typing a number and then something will repeat something number times. This also works in emacs and bash.

It can also be used with other commands like delete, yank (paste) and such. I don’t do that often, but I do use this for lines of '-' or '=' quite often.

The previous solution I posted was a “snippet”. It implied typing a number, “:”, what to repeat, select that text and then hit some hotkey.

Slow, and annoying because we have to toy with the shift + arrow keys to select the text.

Here’s a new version as a “command”.

Read the whole post…
Posted at 21:14
Tags: osx · TextMate
Sunday, january 24th, 2010

iTerm: word shortcuts

In a terminal, I need both the “option” key to access alternate glyphs, like “•”, “∞” and French accents, like “é”, and to act like a “meta” key, which essentially sends an “escape” character followed by the key value.

Obviously a key can’t be two things at the same time, at least on Os X. On other Unix-like systems, you often have the left “alt” playing the role of the meta key, and the right “alt” playing the “altgr” role.

Some of the shortcuts I use the most are word navigation, using meta-left-arrow and meta-right-arrow, and word deletion, with meta-backspace (or “meta-delete” on Macs) to delete the word on the left, and meta-d to delete the word on the right.

So here are my recipies to bind those keys in iTerm.

Read the whole post…
Posted at 02:23
Tags: iTerm · osx · terminal
Sunday, january 24th, 2010

iTerm: extend the “send text” action

iTerm's key mapping system allows for a number of possible “actions”:

  • “send escape sequence” simply sends a “\e” followed by the text as-is;
  • “send hex code” scans for one 8-bit code, and sends that;
  • “send text” allows for “\e” (escape), “\n” (newline), “\a” (bell), and “\t” (tab), and normal text.

The goal of this small patch is to add two escape sequences to the “send text” action:

  • “\\” to send a single backslash;
  • “\xAA” or “\xBBBB” to send an arbitrary unicode character specified in hexadecimal.

For example, to bind the conventional “backward-kill-word” to option-delete (or alt-delete or meta-delete, or “backspace” on PC keyboards), you can simply add a key mapping for “delete”, checking “option”, selecting “send text” as the action, and typing, in the text box, “\e\x7f”.

From then on, hitting option-delete will delete the word on the left of the cursor :)

Read the whole post…
Posted at 01:30
Anglais seulement
Tags: iTerm · osx · terminal
Wednesday, january 13th, 2010

Using bogofilter on comments in django

Five minutes after I placed my new django-based website online, I got my first spam. Yesterday, I got as many comments (all spam) as I used to get in a month when this website was based on ExpressionEngine!

Of course EE’s captcha was enabled, so it helped, but spam still got through – a few every other day.

So, what can I do about it?

  • Conventional captchas are not so efficient (cracked, cheap human labor, …), and they are often as tough on humans as they are on scripts;
  • Akismet: I don’t want to depend on external entities unless I have exhausted all other possibilities;
  • The popular reCAPTCHA – apparently often cracked, and doesn’t fit my external policy;
  • “Are you human” thingies, like simple mathematical formulas – I strongly believe “1+4” to be easily parsable and calculable by any script, and I find most other solution I found too annoying to implement and/or use (like “drag the pencil image to some box on the right”).

So what about bogofilter?

Read the whole post…
Posted at 17:06
Anglais seulement
Tags: bogofilter · django · spam
Tuesday, january 12th, 2010

The Big Move To Django!

First, Wordpress, then, for a year, ExpressionEngine. And now, since yesterday, this website runs under django!

Well, it actually runs on much more than django:

Just like the previous version, based on EE, used much more than EE. For example, its search system was also Sphinx-based. (And the humanized markup language I used was called “HTML” – I don’t really like Markdown nor textile, and reST is only in python :)

Why the move? Well… such a simple question deserves a simple answer: I personally have much more fun pythonning than PHP-ing. Maybe because I did so much PHP, and python is still new to me. Or maybe my mind works more like python :P

Anyway, my first complaint: using django’s native comment system certainly attracts spam! So I suppose I’ll have to do something about that, yeah! More pythonning to do! >:)

Posted at 16:06
Wednesday, november 4th, 2009

“Repeat command” in TextMate

(Note: this post is superseded by “Repeat command” in TextMate revisited)

The text editor I used the most in the past ten years is definitely jed. I still use it a lot, both local and over ssh, but I now mostly use TextMate when programming.

I love it for the most part. The feature I miss the most from emacs and jed are split views. Can't do much about this however.

The second feature I miss the most is the “repeat command” (press ESC or Control-U, a number, and something, to repeat “something” “number” times).

As I said on stackoverflow, it's actually quite easy to do.

First, open the Bundle Editor, then create a “New Snippet”, preferably in a personnal bundle (I put personnal things in “_Serge”). In the new snippet, add this:

1
2
`python -c "print ':'.join('$TM_SELECTED_TEXT'.split(':')[:-1]) * \
 int('$TM_SELECTED_TEXT'.split(':')[-1])"`

To use, simply type the text to repeat, “:”, then a number, select the text, and run the snippet.

Here are some examples:

Text Result
*:10 **********
::10 ::::::::::
\':10 ''''''''''
-*-:10 -*--*--*--*--*--*--*--*--*--*-
Posted at 22:22
Anglais seulement
Tags: osx · TextMate
Saturday, september 19th, 2009

A new design, again!

When I ported this to EE, I made an ugly greyish skin that I still can’t believe I placed online.

Well, that junk is now gone, replaced by something I believe to be much cleaner. Maybe I’ll also make me sick in a few days, but for now I like it way better!

So, it should display correctly on Safari, Firefox, Chrome, and Opera. It should also look OK on IE6-8. I still believe IE8 to be a big piece of junk. Somehow, Microsoft can’t seems to read specifications.

Posted at 16:02
Tag: greyworld
Tuesday, august 18th, 2009

Updated Freetype2 patch for PHP/GD, 2009-08-18

Posted the patch for php 5.3.0 on the project's page PHP/GD: Better Freetype2.

Also fixed another bug causing segmentation faults when using imagettftext() instead of imagefttext().

Posted at 07:47
Anglais seulement
Tags: fonts · freetype2 · gd · php · postscript
Thursday, may 14th, 2009

Updated Freetype2 patch for PHP/GD

The patch giving more control over Freetype2’s parameters in PHP/GD has been updated!

The nasty bug that made the optional parameter $extrainfo not really optional (omitting it caused no font output) was fixed at last (a minor fix, but laziness is hard to overcome sometimes).

Also released new patches for PHP 5.2.8 and 5.2.9.

See project PHP/GD: Better Freetype2.

Posted at 22:13
Anglais seulement
Tags: fonts · freetype2 · gd · php · postscript

Pages: next 1 2 3