Prosthetic Conscience

Jason McBrayer's weblog; occasional personal notes and commentary

Wed, 07 Apr 2010

bbcode-mode.el: a simple emacs mode for editing bbcode

A couple of years ago, I looked for a bbcode mode for Emacs, and, not finding one, wrote a very simple derived-mode for it. For some reason, syntax highlighting only worked intermittently, which I didn’t have time to put too much effort into trying to fix, and so I didn’t actually release the code for public consumption. Recently, though, I saw on Planet Emacsen an explanation for why it wasn’t working; I’ve tried to find that post to link to it and credit the author, but unfortunately, I can’t.

Anyway, having fixed the font-locking issue, I’ve released bbcode-mode.el at bitbucket. In the process of releasing it, I searched for other bbcode modes to make sure I wasn’t taking a name that was in use. It turns out that in the meantime while I wasn’t releasing my bbcode mode, Xah Lee released another, xbbcode-mode. The two modes are rather different in design, so depending on your tastes, you might reasonably prefer either one or the other.

A side note: I wish bitbucket supported org-mode README files like github does.

[ Posted: 06:43] | [ Category: ] | Permalink | Comments: 2 ]

Sun, 29 Nov 2009

Fedora 12 upgrade

So, I upgraded from Fedora 10 to Fedora 12 over Thanksgiving weekend. I had skipped the Fedora 11 upgrade because of a bug in either preupgrade or the F11 install images used by preupgrade. By the time I got a round tuit to try upgrading to F11 again, F12 was a week from being out, so I just waited, then used the F12 preupgrade. It went very quickly, and fairly smoothly. These are the problems the upgrade caused me, sorted into fixed and not-yet-fixed.

Problems fixed:

Not fixed yet

Conclusions

Fedora 12 seems nicely put together, and the upgrade was, though not the smoothest, smoother than many others I’ve gone through in the past.

[ Posted: 10:00] | [ Category: ] | Permalink | Comments: 0 ]

Thu, 02 Jul 2009

Getting html articles in Gnus to obey browse-url-browser-function

I use Gnus for email, and frequently get emails with an html part. In some cases, I even want to receive emails with an html part, as with RSS feeds that have been translated to Gnus groups via rss2email, in which I sometimes want to see images inline so I don’t have to click through to the original article. Like most people viewing html emails in Gnus, I let emacs-w3m handle the translation of html to text. The problem with this is that then hitting return on a link will use w3m to follow the link, not the browser you have specified in browse-url-browser-function.

This little code snippet fixes that. I’m not sure it’s ideal in all ways. But it works for me currently.

(eval-after-load “w3m”
  ‘(progn
     (defun jfm/open-url-dwim (&optional url)
       (interactive)
       (if (equal browse-url-browser-function ‘w3m-browse-url)
           (w3m-browse-url url)
         (if (equal (face-at-point) ‘w3m-anchor-face)
             (w3m-view-url-with-external-browser url)
           (browse-url url))))
     (define-key gnus-article-mode-map (kbd “<return>”) ‘jfm/open-url-dwim)))

[ Posted: 07:30] | [ Category: ] | Permalink | Comments: 2 ]

Thu, 18 Jun 2009

Random system beep sounds for Fancy beeper

Akkana Peck writes about her approach to using Fancy Beeper to provide random system beeps on a system with no built-in system beep. I’m thrilled to see that people are actually using Fancy Beeper in the wild and are building their own solutions around it.

[ Posted: 06:30] | [ Category: ] | Permalink | Comments: 0 ]

Wed, 17 Jun 2009

stockphoto on bitbucket

So, development of stockphoto, my Django-based photo gallery application has been languishing for a long time. Like, three years long. Like since Django 0.96 long. Mostly, that was kind of okay, because it is a tiny application, and it was working perfectly within its limited domain, until the release of Django 1.0. I had been wanting to fix it up before the Django 1.0 release, but never got a round tuit.

After my daughter was born, I needed to use it to show baby pictures to our family, so I had the motivation to at least fix stockphoto up to work with a current Django release. This is done; it mainly involved fixing up the model code, switching to forms from oldforms, fixing up the URLs, and fixing zipfile import to work with the new upload API. I have put the fixed code on bitbucket. If you pull from tip at that repository, or download a snapshot of tip from the downloads page, you will have a stockphoto package that works on Django 1.0.

This isn’t quite a release though; it needs a few cleanups before I can push out an 0.3 release:

  1. Update documentation
  2. Since there were some small model changes, I need to provide a way of migrating from 0.2.1. I am leaning towards South for providing this.
  3. Remove dead code

There won’t be any new features in stockphoto 0.3 except for non-browseable galleries (which is already in bitbucket, since I wanted it for my daughter’s site). I’m tentatively planning a 0.4 release that will have the features originally intended (since so many years ago) for 0.3, plus some suggested to me in email.

If you’re interested in using stockphoto, please follow it on bitbucket, and send me any patches you find useful.

[ Posted: 12:15] | [ Category: /django] | Permalink | Comments: 1 ]

Thu, 12 Feb 2009

identica-mode.el update

I’ve written a little update of Gabriel Saldana’s identica-mode.el, which wasn’t working on identi.ca as it currently stands, or at least not with a current Emacs. The updated version is posted on EmacsWiki. Expecting some updates from Matt in Chicago to fix @links, and planning to add support for !groups and #tags, maybe some more faces.

[ Posted: 11:22] | [ Category: ] | Permalink | Comments: 0 ]

Wed, 22 Oct 2008

Inspired by xkcd

Oracle’s a well-known dee-bee
But there’s also many freebies.
How should you the choices cull?
Choose one where ” IS NOT NULL.
BURMA SHAVE

Now thank your lucky stars I didn’t post the lines one at a time as article titles to get them to show up one-by-one in Planet Emacsen.

[ Posted: 19:30] | [ Category: ] | Permalink | Comments: 0 ]

Sun, 12 Oct 2008

Wrapper script for emacs using –daemon

For quite a while, I’ve used a variety of scripts for starting emacs, starting with dtemacs from gnuclient, which I modified in various ways to work the way I wanted it with Gnome and from the command line. The new daemon-mode in CVS emacs, combined with multi-tty, makes it a bit simpler to write a script that you can use to edit files from your desktop environment, from a command-line with or without X available, or as an external editor from a mailer, VCS or web-browser. I’ve re-written the latest version of my emacs wrapper in terms of daemon-mode, and present it here. It’s rather shorter than my pre-daemon-mode script, and does rather more. Apologies for my bad shell-scripting style.

#!/bin/sh  

# em: a script for starting emacs as needed.  

EMACSCLIENT=emacsclient  
EMACS=emacs  

if [ -z "$DISPLAY" ]  
then  
    CLIENTARGS='-t'  
    CLIENTNEWARGS='-t'  
else  
    CLIENTNEWARGS='-c -n'  
fi  

function start_daemon() {  
    echo -n "Starting emacs in the background…"  
    $EMACS –daemon  
    while ! $EMACSCLIENT –eval t >/dev/null 2>&1  
    do  
        sleep 1  
    done  
    echo "ok."  
}  

if [ -z "$@" ]  
then  
    if $EMACSCLIENT $CLIENTNEWARGS 
    then  
        exit 0  
    else  
        start_daemon  
        $EMACSCLIENT $CLIENTNEWARGS  
    fi  
else  
    if ! $EMACSCLIENT $CLIENTARGS "$@" 
    then  
        start_daemon  
        $EMACSCLIENT $CLIENTARGS "$@"  
    fi  
fi

[ Posted: 19:00] | [ Category: ] | Permalink | Comments: 1 ]

Wed, 08 Oct 2008

Underappreciated emacs function: just-one-space

I want to very briefly praise the probably-underappreciated emacs command just-one-space. It is on M-SPC by default, and what it does is replace all the spaces and tabs around point with one space (or prefix-arg number of spaces). That’s nothing terribly fancy, but it’s one of those little things that can let you save so many keystrokes when you’re reformatting text. That and transpose-chars are among the little touches that make emacs so much more convenient than a bog-standard text editing control.

[ Posted: 06:10] | [ Category: ] | Permalink | Comments: 1 ]

Thu, 25 Sep 2008

Using Windows Search with anything.el

In a previous post, I said that I wished there were a command-line client for Windows Desktop Search (or Windows Search, or whatever M$ is calling it this week) that would give back filenames in a way useful to anything.el. Well, that comment was not entirely ingenuous, because in the time between when I wrote that article and when I posted it, I wrote one. It’s written in Python, and uses the win32com module, so you’ll need regular w32 Python installed (not Cygwin python).

The script itself is here. I recommend that you install it somewhere on your PYTHONPATH. This is because command-line argument handling is very dodgy on w32, particularly when the program is interpreted, the interpreter is a native w32 program (not cygwin), and you may be calling it from a cygwin program (such as cygwin bash). More details on installing it and its limitations on its own page.

Integrating it into anything: use the following elisp code:

(defvar w32-windows-search-program
  "python.exe -m DesktopSearch"
  "Command to pass a search string to Windows Search.
Will be split on spaces to pass to start-process.")

(defvar anything-c-source-w32-windows-search
  '((name . "Windows Search")
    (candidates . (lambda ()
                    (apply 'start-process "w32-windows-search-process" nil
                           (append
                            (split-string w32-windows-search-program)
                            (list anything-pattern)))))
    (type . file)
    (requires-pattern . 3)
    (delayed))
  "Source for retrieving files matching the current input pattern
with windows desktop search.")

The given value for w32-windows-search-program depends on DesktopSearch.py being in your PYTHONPATH. With the above in your .emacs, you can add the source it provides (anything-c-source-w32-windows-search) to anything-sources just like any other anything source.

This generally works well enough for my needs. Hopefully it will be useful to other people using emacs on w32.

[ Posted: 20:00] | [ Category: ] | Permalink | Comments: 0 ]

Fri, 19 Sep 2008

anything.el and “open with default tool” on w32

My job doesn’t often offer the opportunity to “hack the good hack.” A little while ago during toolsmithing time, I got to make a neat little hack to ‘anything’, an emacs package for locating files (or buffers, or info pages, or … anything) and acting on them. Normally, use of ‘anything’ works like this: C-x C-a to start, then start typing something to search for, arrow down through the matches, and either select the default action (open the file or switch to the buffer) with RET, or hit TAB to switch to a list of actions to select.

Here’s where the hack comes in. One of the actions you can perform on files is ‘open with default command’. The catch: this is not implemented on W32, which I have to use at work. On unix and MacOS, it this action is implemented by calling an external program — ‘xdg-start’ on unix, or ‘open’ on Mac-OS — with the filename as an argument. There is no equivalent command on W32 – the closest is the cmd.exe shell internal ‘start’. But because ‘start’ is a cmd internal, it is hard to call from emacs; the quoting may be badly messed up, for example, depending on whether you use cmd.exe or cygwin sh as your shell, etc. But here’s a better approach: leave it up to emacs. Emacs on W32 has a function ‘w32-shell-execute’ that works like cmd.exe’s ‘start’ internal.

The code to integrate this is now added to anything-config.el, a package of sample configurations for Anything. I’m now co-maintaining anything-config.el.

The practical upshot of this is that I can use ‘anything’ to find my playlist files while in emacs, and start them with Windows Media Player. Now if only Windows Desktop Search let you get text-mode search results back, or if there were a version of Tracker for W32…

[ Posted: 17:30] | [ Category: ] | Permalink | Comments: 0 ]

Thu, 18 Sep 2008

What I’m missing in Google Chrome: fast proxy switching

It’s nice that Chrome has Incognito Mode. But how incognito is it when your network admin can monitor the content of your traffic? Wouldn’t it be nice to be able to switch your network traffic to a secure channel – like an SSH tunnel to an http proxy under your control, or TOR?

Firefox has the ‘Distrust’ extension that provides the same protections as Chrome’s Incognito Mode (other than the v. stylish fedora-wearing spy logo). And it also has your choice of extensions that let you switch proxies without going into the depths of the advanced settings menu: QuickProxy, SwitchProxy, FoxyProxy, and several TOR-specific extensions. Now if only Distrust had a setting that let one turn on their proxy for the duration of the Distrust session…

[ Posted: 18:15] | [ Category: ] | Permalink | Comments: 1 ]

What I’m Missing in Google Chrome: Mouseless browsing

In Firefox, I have the Mouseless Browsing plugin installed, which lets me hit a key to label links with numbers, then type the number to follow the link. But even without MLB, you can browse mouselessly with the typeahead search – type ‘/’, then start typing the text of the link, and when the link you want is highlighted, hit enter. In Chrome, you can only tab between links, not jump directly to the one you want (even with the search function). That is, you can search for link text, and it will highlight it, but you cannot then select the link without tabbing to it from the beginning.

[ Posted: 16:00] | [ Category: ] | Permalink | Comments: 2 ]

Mon, 24 Mar 2008

What a fascinating quote:

From: http://www.mindview.net/WebLog/wiki-0051 (a comment on Bruce Eckel’s weblog)

2004/03/12 10:02 EST (via web):

About the “directing” vs. “enabling” approach, you wrote: “Both approaches are reasonable and neither is wrong. I have been in both situations; for example, trying to prevent interns from ignoring or even actively circumventing coding style guidelines (where more “direction” was required), and on the other hand being frustrated by the loss of productivity that comes from being forced to conform to constraints that I wouldn’t have violated anyway […]?”.

It is interesting that you justified the “directing” approach with an example about directing others, and the “enabling” approach with an example about enabling yourself. Don’t take this as a negative critique - I did the same when I tried to come up with examples of directing/enabling.

I tend to think that others should be directed, and I should be enabled. I worked for teams whose job was developing software methodologies and the relative supporting tools for the rest of their Company. Except that, of course, they flat-out refused to apply the (directing, strict) methodologies that they were developing to their own methodology-building project. To me, that shows how much in software development is about our own relationships and fears. We still have an awful lot to learn from sociology and antropology - and maybe, oriental philosophies.

Paolo Perrotta Bologna, Italy

I prefer “enabling” approaches everywhere, and agree with the statement that if you have someone who can’t handle an enabling approach, they don’t need directing, they need training. But many people (especially in corporate IT) would argue that this places too high a bar on experience and education for programmers. Still, I’d rather see enabling done technologically, and where direction is needed, see it done socially.

[ Posted: 19:00] | [ Category: ] | Permalink | Comments: 0 ]

Tue, 13 Nov 2007

Stockphoto 0.2.1 released

I’ve just released stockphoto 0.2.1. This is a bugfix release and contains no new features relative to 0.2. I would like to thank many people for bug reports on the previous version; plese see the credits in the README file.

I’ll be opening development on stockphoto 0.3 once I decide the best way to host a public version control repository (Google code vs. Savannah, vs self-hosting). The pre-0.3 branch will include new features, some of which are listed as to-dos in the current README.

[ Posted: 15:11] | [ Category: /django] | Permalink | Comments: 0 ]

Thu, 08 Nov 2007

Hushmail: not so hushed, aktuly.

No original reporting or opinions here. Wired has a story on how Hushmail can and will turn over plaintext emails if they receive a Canadian court order. This means that while Hushmail provides good protection against on-the-wire snooping, it doesn’t protect Alice and Bob if Mallory is in law enforcement.

I’ve recommended Hushmail to friends and neighbors in the past, as a way of easing them into the idea of using encrypted email on a regular basis. When I read this news, I felt I had to email people that I had recommended it to, to let them know about the weakness. Hushmail could set up their systems so that they never store a passphrase except in volatile memory, and so that they never store plaintext of messages. But you’d have to trust them on that, and a court order could still mandate that they store them, and not tell you they were doing it.

The best thing would be for everyone to use GNU Privacy Guard on their own computer. But it can be hard to set up, especially for Windows users (though if you’re running Windows, you have bigger security problems), and your correspondents have to all be using GnuPG or OpenPGP, too. This is a big barrier to entry, and even though I’m set up to use it, very little of my total volume of email is routinely encrypted as I’d like it to be. There is also the problem of people without their own computers, who must use shared resources such as public library computers. Hushmail appeared to be the most viable option for them.

If you are interested in using GnuPG, you might look into the Enigmail plugin for Mozilla Thunderbird as a cross-platform solution. If you’re already using Linux, Evolution groupware provides easy-to-use GnuPG support. If you want to send me encrypted email, you can download my public key, the fingerprint of which is C046 0E26 8103 ABA1 68B1 D6E7 A991 E701 91DF 7DDD.

[ Posted: 20:16] | [ Category: ] | Permalink | Comments: 0 ]

Mon, 01 Oct 2007

Apple-induced Stockholm Syndrome

See here for the source of this well-turned phrase. It ought to replace “reality distortion field” in the Mac community’s lexicon.

Basically, I’m amazed by iPhone users’ collective reaction to the bricking of their phones the same way I’m amazed by the reaction on Daily Kos to the Andrew Meyers tasing. In both cases, the affected community is mostly reacting with “hurt us more! We deserve it!”.

Contrast the OpenMoko project. Install whatever you want across a whole range of supported phones. Switch phones keeping the software you installed.

How are you going to hack your life if you can’t even hack your gizmos?

[ Posted: 09:03] | [ Category: ] | Permalink | Comments: 0 ]

Sun, 30 Sep 2007

Quoted for truth

Eclipse is emacs for stupid people ;-)
— John J. Lee-2 on python-list

[ Posted: 13:11] | [ Category: ] | Permalink | Comments: 0 ]

Tue, 24 Jul 2007

Yikes! Stockphoto on Django status update!

The last couple of days I have been seeing a renewed interest in Stockphoto, my basic, minimalist photo gallery application for Django. At the time, I wondered why, since I haven’t updated Stockphoto in the last year, nor made any announcements associated with it. Then, I saw that it had been mentioned in the Django status update on July 22.

This is just a little notice on stockphoto’s status. Stockphoto 0.2 has quite a few known bugs. I have to-do items for all of them in my personal organization system, most of them with contributed patches. I’ve just been too busy in my life to integrate all of these fixes and package them into a release. I want to do better and get two releases out the door soonish.

So here’s the release plan:

  1. Stockphoto 0.2.1, soonish. Will fix all outstanding bugs that I know about.
  2. Stockphoto 0.3, later. Will include changes to the models to allow slug-based rather than id-based URLs, and some conveniences for template designers.

Please bear with me – if you are in desperate need of a full-featured Django photogallery in the very near future, you will probably want to write it yourself, possibly looking at stockphoto’s code for examples if you are not familiar with Django’s file/image upload handling or with PIL.

Thanks for your patience.

[ Posted: 07:30] | [ Category: /django] | Permalink | Comments: 0 ]

Sat, 21 Jul 2007

Web templating systems: be opinionated enough, but no more.

There’s some current discussion in the Django community on templating systems on Jacob Kaplan-Moss’s website and elsewhere.

I agree with the general argument. There is a rather fine line between putting too much power into the templating language, so that it either becomes a programming language in its own right, or simply a means of embedding primary-language code in the templates, and putting in too little, so that you can’t do more than variable substitution. That’s not a big insight in and of itself. I think almost everyone knows this by now.

What I think is significant is this:

  1. Django’s templating system hits the sweet spot for web templating. Through a combination of good taste and (probably) luck, the Django developers have produced a templating system that strongly encourages web developers to put their controller logic and their view logic in the right place.
  2. Django’s templating system is just tightly coupled enough to make people think twice before using something else. You certainly can use other view technologies, and it’s not really hard to do so (just do everything your other template system to produce a string or a file-like object representing the content of the response, and pass it as an argument to the Django response object you’re going to return).

    But neither the documentation nor the code for Django imply anywhere that other templating systems are just as good, just as suitable, or just as well-integrated into Django. The documentation mentions that you can use them, but only gives examples of the Django templating system. The code contains many shortcuts for using the Django templating system (e.g. render_to_response()) that can’t be used with other systems.

I think the latter point should really be emphasized more. The core Django developers like to talk a lot about how Django is loosely-coupled. And that’s sort-of true, and it’s a good thing. You don’t have to buy into everything to use Django. Django applications are just plain python code; they’re written not a special mini-language. But, Django is tightly coupled enough that there is only one obvious way to do it.

Here’s what I mean by that. In my work life, I’ve been learning a more corporate-friendly web development platform, the Spring framework for Java. Mostly Spring is a good thing. It manages to drag corporate web development halfway from J2EE-hell to Django in the same way that Java dragged corporate programmers halfway from C++ to Lisp. Once you get past the Enterprise Architecture Astronautics (not as bad in Spring as in other Java frameworks, because of the extensive use of interfaces rather than inheritance) and reams of XML configuration files (apparently significantly reduced in Spring relative to other Java frameworks!) it’s actually not bad, and developing for Spring MVC is very much like developing for Django while wearing mittens – you use the same patterns, but it takes twice as long to write.

But, the frustrating thing about Spring is that it is completely non-opinionated. How shall you do database access? They don’t care, and not only do they provide wrappers for the top 10 ORM systems as they’ll as plain JDBC, they support multiple completely different styles of using one of them, which require different layers of proxy objects and (of course) different XML configuration. And view technologies? They don’t much care which of those you use, either – pick one and use it. All this may make sense in an environment where the ORM layer and view layer can be mandated by corporate policy, but it’s no way to build a framework developers can be passionate about.

(Side note: for the templating language to use with Spring, I’ve settled on Apache Velocity. It is much like the Django templating language in scope, in that it interpolates variables and their properties, offers conditional constructs and iteration over collections, and so forth, but does not constitute an entire embedded programming language, or make it too easy to drop into the implementation language. Like Django’s templating language, it is a plain text language that is not tied to generating XML output. It doesn’t have two of the nicest features of Django’s template language, template inheritance and block substitution, but these are very easy to implement yourself by following certain conventions. Velocity is much closer to the templating sweet spot than JSP/JSTL.)

Django has been accused by passionate users of other Python web application frameworks of suffering from NIH Syndrome; or to put it another way, of being too opinionated. But the NIH components of Django (the ORM and the template system) provide very good implementations of that functionality for most of the target audience. If your needs are complex enough that you have to use something else, then you probably also have the skills to deal with the consequences (for example, SQLAlchemy can map existing databases that Django’s Models can’t – but if you use it, your app doesn’t get Django’s admin functionality, and probably can’t use generic views). So it goes. But the risks of being not opinionated enough are worse:

So it’s not just that Django’s templating system hits the big bulgy middle of the bell curve, but that the project as a whole does. Opinionated, but not too opinionated. Enough salt to bring out the flavors, not enough to overwhelm them.

[ Posted: 09:56] | [ Category: /django] | Permalink | Comments: 3 ]

 

Page 0 of 2  >>


Powered by PyBlosxom