Aug 2010

Tue, 24 Aug 2010

Pretty list of database and table sizes with PostgreSQL

A very handy way to estimate the on-disk size of your databases in PostgreSQL:

> SELECT datname,pg_size_pretty(pg_database_size(datname)) FROM pg_database;
    datname    | pg_size_pretty
 template1     | 4144 kB
 template0     | 4144 kB

And the same for individual tables:

> SELECT tablename,pg_size_pretty(pg_total_relation_size(tablename))
    FROM pg_tables WHERE schemaname NOT IN ('information_schema','pg_catalog');

         tablename          | pg_size_pretty
 django_content_type        | 40 kB
 django_session             | 152 kB
 django_site                | 24 kB

Now go and bug your application developers to save your resources.

posted at 10:20 | path: /unix | permanent link to this entry

Fri, 20 Aug 2010

Javascript based Picasa photo roll on your webpage

From the department of 5-minute Javascript hacks comes this little gem, which handles the 'Random photo' to the right. It uses the JSON-API Google API to get the data from the Picasa-Web-Albums.

<script><!-- //
// Creative Commons Attribution-ShareAlike 3.0 Unported License
// (c) Jan Dittmer <> 2010
var es = [];
function r() {
       var idx = Math.floor(Math.random()*es.length);
       var m = es[idx]['media\$group'];
       var i = document.getElementById("i");
       document.getElementById("t").innerHTML = m['media\$description']['\$t'];
       i.src = m['media\$thumbnail'][0]['url'];
function j(p) {
       es = p['feed']['entry'];
function picasa() {
       var url='' +
       var s = document.createElement('script');
       s.src = url; document.body.appendChild(s);
window.onload = picasa;
<a href=""> <img id="i"> </a>
<div id="t"></div>

posted at 20:56 | path: /web | permanent link to this entry

How to use glutBitmapCharacter in Perl

glutBitmapCharacter is an OpenGL function used to display a single character. The C function signature looks like this:

void glutBitmapCharacter(void *font, int character);
Seeing this, it should be clear that you have to call it from perl with a numeric character value:
The trick is to use ord to convert the character to the character code. Don't try without or you'll just the the background color and no error message, I just lost nearly an hour over this simple thing, which is not so obvious if you just look at C examples. But 'J' are two very different things in Perl and C.

posted at 11:35 | path: /gl | permanent link to this entry

Sun, 01 Aug 2010

Personal bibliography

posted at 12:00 | path: /personal | permanent link to this entry

RF MEMS Literature

posted at 12:00 | path: /personal | permanent link to this entry

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.