April 30, 2008

Show the date in the OS X Menu Bar

Filed under: cool, osx, tip — michaelangela @ 2:43 pm

A good tip and set of instructions on how to show the date in the menu bar so you don’t have to click, hover, etc.

How To: Display Date in OS X Menu Bar – PaulStamatiou.com

While getting things settled down on my MacBook it became apparent that I did not want to rely on the calendar widget to find out the numeric date. I simply wanted to view the date alongside the time in the menu bar. Unfortunately this is not an option in OS X. However, with a slight of hand, you too can easily display the date in the OS X menu bar without the need of additional applications.


April 25, 2008

A Django HttpRequest QueryDict is not your normal Python dict – i.e. getting ids from a friend request-form

Filed under: dev, django, facebook, python, snippet, tip — michaelangela @ 5:34 pm

Doesn’t work:


Does work:


A typical Facebook friend invite sends the ids to be invited to your site as an array in 'ids[]'. Normally, you can pull values out with just request.GET['key']. But since the value of this particular key is an array and not just a string, you can’t (at least I wasn’t able to) just do ids=request.GET['ids[]']. That returns the first value of the array as a string. Not very helpful.

But, this is a QueryDict object, not a standard {} dict. As such, Django provides the getlist(key) method.

Django | Request and response objects | Django Documentation

getlist(key) — Returns the data with the requested key, as a Python
list. Returns an empty list if the key doesn’t exist. It’s guaranteed to
return a list of some sort.

April 24, 2008

Google, Search, Flex

Filed under: api, dev, flex, google, search, tool, yahoo — michaelangela @ 10:05 pm

Oooooh sweet. According to this article, Yahoo’s search API is still more “developer friendly”. Either way, having them available is quite cool.

Google Search REST API

More than one year after Google discontinued the SOAP Search API, it finally got a proper replacement. The AJAX Search API can now be used from any Web application, not just in JavaScript. The other two Google AJAX APIs for feeds and translations were updated for non-AJAX use, as well.

Flash developers, and those developers that have a need to access the
AJAX Search API from other Non-Javascript environments, the API exposes
a simple RESTful interface. In all cases, the method supported is GET
and the response format is a JSON encoded result set with embedded status codes.”

the APIs from your Flash or Server Side framework couldn’t be simpler.
If you know how to make an http request, and how to process a JSON
response, you are in business,” says Mark Lucovsky. Here’s a simple example for web search:

Python array copy

Filed under: cool, dev, one-liner, python, tip, tool — michaelangela @ 9:52 pm

I had heard about passing by reference vs. passing by value. Here is a case of passing by reference.

In [76]: a=[1,2]
In [77]: b=a
In [78]: b.append(3)
In [79]: a
Out[79]: [1, 2, 3]

That’s not what I was looking for. I was hoping to get 'b' to be [1, 2, 3] leaving 'a' unchanged. Oops. It passed 'a' to 'b' by reference so any changes to 'b' affected 'a'. So… need a copy. Simplest way I’ve seen of copying an array in python so far is to use [:].

Learn Python in 10 minutes | Poromenos’ Stuff

A useful use of the array range colon is to copy an array:

newary = oldary[:]

Concat Django Querysets

Filed under: dev, django, orm, tip — michaelangela @ 9:46 pm

Here is a good discussion on concatenating Django Querysets. Very helpful! It also introduced me to itertools. This leads to some other talk about itertools. Very interesting!

The jist though is like this:

How do you concatenate two querysets? – Django users | Google Groups

import itertools
q1 = Model1.objects.all()
q2 = Model2.objects.all()
for thing in itertools.chain(q1,q2):

Very handy.

Jump to path in OS X finder

Filed under: osx, tip — michaelangela @ 9:41 pm

Not sure where I saw this, but if you have an OS X Finder box open to, say, upload a pic to Facebook, if you hit Command-shift-G, it’ll give you a box you can paste a path in. You can also type the path in and it should give path completion so I’ve heard.


April 23, 2008

Potential facebook app success story

Filed under: business development, facebook, monetize — michaelangela @ 5:05 am

I think whereivebeen is far, far over 250,000 users. It’s successful. The problem is getting it to at least pay for itself. I haven’t seen an update past what is here though. I know some ads were put in and they aren’t obnoxious or anything so as a user I am fine with them. But does the ad revenue cover it? Just wondering… all the best to Craig though! It’s a great story any way you slice it.

Facebook | I have 250,000 users, what now?

Well my application has become incredibly popular, and I’m very excited about it, don’t get me wrong!

VideoEgg Egg Network

Filed under: monetize, tool, video — michaelangela @ 4:54 am

Monetize monetize monetize… it’s the big mystery. How to do it? So that it actually works? VideoEgg has done interesting stuff so this is another one to take a look at in the future.

Ad Platform – Publishers | Videoegg

You can integrate the EggnetworkSM AdPlatform in less than a day and begin monetizing your site traffic with quality brand advertising designed to fit into virtually any space.

Free open source video platform?

Filed under: tool, video — michaelangela @ 4:52 am

So says Miro. Interesting. Will have to look into it more later.

Creators: publish your videos the open way.

If just a few companies dominate online video, creativity will be restricted. If the most popular video tools rely on closed, proprietary distribution systems, free speech will suffer.

Miro is specifically designed to give video creators and viewers more freedom. We’ve built Miro to work with as many video hosting sites and video search engines as possible. We believe that the future of media depends on creators being able to choose the publishing services that work best for them, rather than being forced to use a few monopolistic services.

April 22, 2008

Textmate and FBML… Eclipse/Aptana anyone?

Filed under: cool, dev, facebook, fbml, plugin, textmate, tip, tool — michaelangela @ 8:57 pm

I sure wish there was something like this for Eclipse and Aptana! Perhaps this could be a start? Here’s to hoping…! 🙂

Facebook Platform Developer Forum / TextMate FBML plugin

Put together a start of a TextMate Bundle for Facebook. Does some cool stuff, like code completion and doc lookup. If anyone wants to contribute, ping me and I’l put you on the project.


Django snippets to check http_referer

Filed under: deep-linking, dev, django, snippet, tip — michaelangela @ 6:31 pm

Django snippets: Referer-checking view decorators

Here are a couple of Django decorators for limiting access to a view based on the request’s HTTP_REFERER. Both raise a Django PermissionDenied exception if the referer test fails (or a referer simply isn’t provided).

The first, referer_matches_hostname, takes a hostname
(and port, if specified) and matches it against the referer’s. If
multiple arguments are supplied a match against any of the hostnames
will be considered valid.

The second, referer_matches_re, takes a regex pattern (like Django’s urlpattern) and tests if it matches the referer. This is obviously more flexible than referer_matches_hostname providing the ability to match not just the hostname, but any part of the referer url.

Finally there’s an simple example decorator, local_referer_only, that limits a view to the current site by using Django’s django.contrib.sites to look up the current hostname.

Working with field level permissions with Django

Filed under: dev, django, snippet — michaelangela @ 5:46 pm

This might be useful but, buyer beware.

Django snippets: FieldLevelPermissionsAdmin

Have you ever needed to customize permissions, for example, allow only some fields for editing by some group of users, display some fields as read-only, and some to hide completely? FieldLevelPermissionsAdmin class does this for newforms-admin branch. Not tested well yet (>100 LOC!).

April 20, 2008

1and1 and http compression

Filed under: 1and1, gzip, modrewrite, php, snippet, tip, tool — michaelangela @ 12:11 am

I have not been able to find any info about 1and1 and http compression. It’s a shame as it really reduces bandwidth, increases transfer speed, etc. Fortunately this little script does a really nice job of it. It’s in PHP and it works a treat on 1and1. With a bit of rewrite magic I should be able to access the files normally and the gzipped ones will be passed in when needed. Nice.

Julien Lecomte’s Blog » Gzip Your Minified JavaScript Files

If your web hosting company does not offer HTTP compression, but gives
you access to PHP (that’s the case of Yahoo! Web Hosting), I wrote a simple PHP script that will compress files and set the cache control headers so that the requested files actually get cached by the browser.

April 18, 2008

Neat little Facebook snippet for Django

Filed under: dev, django, facebook, python, snippet, tip — michaelangela @ 7:51 pm

You can use this to set up a Facebook User within you Django app. This of course uses the middleware which is optional as described here.

Django snippets: Little middleware that create a facebook user

  1. Install **PyFacebook** package.
  2. After make all steps in tutorial above, put this code in your app’s
    models.py module (you maybe prefer split it and put the middleware
    class in some other file).
  3. Put the FacebookUserMiddleware python-path in the
    MIDDLEWARE_CLASSES in your settings.py (after

April 17, 2008

Django, generic views, and setting the media url via a template context processor

Filed under: dev, django, tip, tool — michaelangela @ 11:12 pm

So far I haven’t really used Django for “web sites”. It’s really been used as a data backend. Well the time has come for some web stuff. It’s set up to use a dev, staging, and production server. All is well and good. But each has a different media server. In Django, how do you tell it to use different media servers in the template?

A couple points. First, Django templates can extend other templates. So even if you have 1,000 templates (?!) but they all extend one basic template (often named "base.html") then changing the base.html updates them all. Keeps things DRY. Python is big on that and it’s good.

And to keep this process DRY, there is a context processor which can automatically provide data for your templates, i.e. a "media_url" variable. Better still, if you use Django’s generic views, any template context processor defined in your site’s settings will automatically be passed in.

James has a great writeup about this process explaining it. In fact, he even has template util library for just this very thing among others.

The B-List: Django tips: Template context processors

A recent example that came up on the django-users mailing list was a template tag to retrieve the base URL
for your media (typically you want to store “media” like images,
stylesheets and JavaScript in a particular location on your server, or
possibly even have a separate server for them if you’re using Apache
and mod_python — incurring the overhead of mod_python on a request
which will just serve up a file from disk wastes resources). Django
lets you specify where your media files come from via the MEDIA_URL setting.


As it turns out, Django provides an extremely easy way to do this.
Every time you render a template, you give it a “context”; this is a
dictionary-like object whose keys are variable names and whose values
are the values of the variables. When you render a template with a
given context, every key in the context dictionary becomes a variable
in the template that you can access and use.

Good list of Eclipse plugins specific to Flex

Filed under: cool, eclipse, flex, plugins, tool — michaelangela @ 9:09 pm

This list has many of the plugins I already use, and there are more that I haven’t looked at yet. I’ll give them a shot in due time, but it’s a good reference.

dispatchEvent » Pimp my ‘clipse – a list of must-have Eclipse plug-ins for Flex/Flash Development

FlexBuilder may have its ups and downs but it still remains my pick for best AS3/MXML editor on the market (with TextMate not far behind). Part of the beauty of FlexBuilder is that it’s built on the Eclipse SDK, one of the most versatile and powerful IDEs available, which is not only free and open source, but boasts a wealth of third party plug-ins
for every kind of (mostly Java) development. This article will take a
look at some must-have plug-ins for doing Flex development as well as
some tips for tricking out your development process.

Flex, MVC, Cairngorm and Universal Mind Extensions

Filed under: cairngorm, cool, dev, education, flex, mvc, tip — michaelangela @ 8:08 pm

This podcast with Thomas Burleson probably has the best description of MVC with Flex, why to use Cairngorm, challenges of using Cairngorm, why to use the universal mind extensions, the problem of view locators and how to work with those, etc. Good stuff. I wish there was a transcript of this.

UMEvent, UMCommand, Callbacks, and other goodies galore. Cairngorm is really, really good. It’s very lightweight. This just takes it further. Now I just need to understand how to use them. 🙂 But that’ll come later.

Another interesting bit is about the centralized error handling… oh good stuff.

Hmm… webservice is far slower than remote objects. And if they fail,
they can fail silently. Ah, that’s WSDL services. Interesting stuff.

Sequences in Cairngorm is quite different than sequences in UM Cairngorm… wow… nice stuff. It’s giving you quite a bit of flexibility: firing sequence of events and commands.

Another bit about refactoring is mentioned, i.e. every use case in Cairngorm has a command/event. It’s definitely workable but it can get tedious. The UM extensions help with that as well.

Download the file and listen to it with Quicktime Player and bump the speed up to like 175% to save some time. 🙂

The Flex Show: The Flex Show – Episode 41: Universal Mind Cairngorm Extensions w/ Thomas Burleson

Textmate the super text editor

Filed under: cool, textmate, tip, tool — michaelangela @ 6:19 pm

Just a note to remember… blogging from textmate… wow. One more reason to get it… 🙂

Andrew Powell’s ColdFusion, Flex, Java, and AJAX Blog

OK, so a lot of Mac users use TextMate for everything from text editor to IDE. I didn’t realize this until recently, but you can blog directly from TextMate. If your blog supports the WordPress, Moveable Type, and Type APIs. You get live spell checking thanks to the built-in integration with the OS X dictionary. You can edit existing posts in TextMate as well as new entries. You can upload images to your blog, simply by dragging an image into the editor window; TextMate will automatically upload it for you.

Eclipse: updating Buckminster

Filed under: dev, eclipse, tip, tool — michaelangela @ 5:58 pm

Recently I have had trouble doing any updates in Eclipse. Buckminster always failed with a 404 not found. My current Buckminster Update Site is:


Later I found this bit:

Nabble – Eclipse – Buckminster Dev – Has something changed on buckminster update site?

yes, something has changed. Eclipse 3.3.2 was released and Buckminster headless-site.xml was updated to reflect this. Obviously I’ve made a mistake somewhere. It should have redirected the requests for the file in question to the Eclipse standard update site. I’ll check…

Two things to note:

  • The update site has changed
  • Buckminster can run headless

The new update site appears to be:


That change fixes it. And running Buckminster headless seems to be a valuable tool… not something I need right now but perhaps one day.

Headless (Buckminster) – Eclipsepedia

Buckminster offers functionality and/or integrations pertaining to many activities that are useful to reach in scripted situations, for example invoking ‘build’. Such activities are frequently necessary to run in situations where a user is not available, or even in situations where it’s not possible to use a graphical user interface. Thus, Buckminster recognizes the need to provide a way to do these things from the command line. This will come in handy in situations such as for automated nightly builds, for example. In Eclipse parlance, this is typically referred to as ‘running headless’.

Nightly builds for complex systems are of course a necessity and this is how some folks work it out.

Eclipse, Quicksilver, and hopping to a folder or terminal quickly

Filed under: cool, eclipse, quicksilver, tip — michaelangela @ 2:27 am

You can pull the currently selected item in Finder into Quicksilver with Command-G. Neato! But you can also pull selected text in a current app. You probably need to install and enable the Quicksilver proxy objects. But once you do, you can grab selected text and it’ll show up in Quicksilver.

But! If you’re in Eclipse and you want to get to a file somewhere you can open up the properties, select the path name, and then do the trigger to do the Command Window with Selection. You might have to set up a shortcut for it.

But since the text is a Unix path, Quicksilver interprets that as a folder and so there you are! You can then open it, reveal in Path Finder, go to in Terminal, etc., etc. Of course I have Quicksilver index the Eclipse project files so I can get there that way but it’s just another cool tip.

Hack Attack: Advanced Quicksilver guide – slashes, appends, and proxies, oh my!

(in the QS trigger preferences it’s called Command Window with Selection).

Reduce Django facebook server load

Filed under: dev, django, facebook, python, tip — michaelangela @ 2:09 am

So say you have a Facebook app and it runs on Django. Standard practice is to load the middleware. Middleware by default adds a bit of overhead. It’s needed for some bits but completely unnecessary for anything that doesn’t need it. This is one way to take it out if you feel the need for the extra speed. I wonder how much performance suffers for the bits that don’t need the middleware?

Using PyFacebook without the Facebook middleware

Recently I have been experimenting with using PyFacebook to create a Facebook app. In the early stages of development I ran into a bit of a quandry: how to you use PyFacebook with Django, without using the PyFacebook middleware?

This is not an inrrelevant question, because the PyFacebook
middleware is just bloat for any views being loaded that do not
directly communicate with Facebook, and is even inappropriate for some
views that do communicate directly with Facebook (requests made with
the FBJSM Ajax object).

April 16, 2008

Pay as you go web hosting

Filed under: cool, dev, hosting, lowcost — michaelangela @ 10:08 pm

Interesting concept. They don’t work with long running processes like Django or Web2py, but it could be good for static files and regular scripts.

NearlyFreeSpeech.NET FAQ

What happens if I get slashdotted?

“major slashdotting” of a site hosted on our service will cost you (on
average) less than $10, one time. The best part about that is that as
soon as it’s over, your costs go back to normal, but you’ll save any usage-based discount
resulting from the traffic burst. There’s no higher-tier pricing to get
permanently pushed into, and we won’t cancel you for having something
to say that people actually want to hear.

This happens to one of our members about once a week, so you can bet
we know how to handle it. Or rather, our systems do. Our load-adaptive
clustering technology is at its best when handling demand surges, and
our pricing is at its best when you’d prefer not to be billed based on
a 1% event the other 99% of the time.

More on MVC

Filed under: dev, education, flex, mvc — michaelangela @ 4:31 am

Going to have to do some more reading here later… Joes’ article “An architectural blueprint for Flex applications” was probably the first thing I tried to chew through to understand MVC, Cairngorm, and “separating concerns” while building an app in Flex. Model adapters and view mediators look like something I have been wrapping my head around. And so… more reading here later. 🙂

joeberkovitz.com » The MVCS Architecture and ReviewTube Example Application

Use of Model Adapters. Very often, the raw information in a Model is not what a View needs to show, and using Flex data bindings to drive the View from the Model becomes extremely awkward. …snip… In such situations, and even in simpler ones, it’s often better to build a special “model adapter” that both exposes this modified view of the underlying Model, and which also listens to change events from that model, dispatching change events of its own when its “adapted” properties change in response.

Use of View Mediators. Another important pattern not illustrated by ReviewTube is the use of Mediators, in which View/View and Controller/View interactions are handled by separate objects that “decouple” these objects from knowledge of each other. …snip… Another type of example is one in which a View is fairly generic in nature and some intermediate processing of its events is required to figure out how and when to invoke the proper Controller operations based on user interaction with that View.

SWFObject 2.0, SWFAddress 2.1, Flex 3 and getting the starting path

Filed under: deep-linking, flex, swfaddress, swfobject, tip — michaelangela @ 4:19 am

I have a test project running with Flex 3 and SWFAddress 2.1 and SWFObject 1.5. It worked but I noticed that SWFObject was updated to 2.0 and SWFAddress is supposed to work with it. So I upgraded. And getting the first initial URL stopped working. Couldn’t figure it out. Then I saw this:

joeberkovitz.com » UrlKit 0.70 with various fixes and Flex 3 Support on Google Code

One possible caveat is that you must pass a unique object ID to SWFObject for the / tag (this ID is the second arg to the SWFObject constructor). Hope this helps — let me know if you’re still stuck and I’ll try and post something.

In my SWFObject 1.5 code, I wasn’t setting the attributes. SWFObject 2.0 is more strict about it. So after changing this:

var attributes = {};

to this:

var attributes = {};
attributes.id = "content";
attributes.name = "content";

It worked. The actual swfobject call is like so:

swfobject.embedSWF("path/to/app.swf", "content", "100%", "100%", "9.0.0", "path/to/expressinstall.swf", flashvars, params, attributes);

Hope that helps someone out there! Oh yes, thanks to Joe for mentioning the caveat as well. 🙂

April 15, 2008

autossh – keep your ssh tunnel running

Filed under: ssh, tip, tool — michaelangela @ 9:32 pm

Automatic reconnection of ssh tunnels. This could be quite useful. Found this from here.



  • autossh is a program to start a copy of ssh and monitor it, restarting
    it as necessary should it die or stop passing traffic. The idea is
    from rstunnel (Reliable SSH Tunnel), but implemented in C.
  • The author’s view is that it is not as fiddly as rstunnel to get to
  • Connection monitoring using a loop of port forwardings or a remote echo
  • Backs off on rate of connection attempts when experiencing rapid
    failures such as connection refused.
  • Compiled and tested on OpenBSD, Linux, Solaris, Mac OS X, Cygwin, and AIX;
    should work on other BSDs.
  • Freeware.


  • Use with “screen” for perpetual session (see included script “rscreen”).
Older Posts »

Create a free website or blog at WordPress.com.