Peter's Blog

Redefining the Impossible

Posts made during 2006


I tried editing videos from the k750i mobile on my pc. I copied the files from \MSSEMC\Media Files\video\camera on the camera's virtual drive to the pc using USB. The files all have a .3gp file extension. I tried opening them in pinnacle studio but it did not recognise the file format, even when opening them as *.*. I tried nero vision and that did not list .3gp as a supported file format but did open it as *.*.

However, even when recorded in 'high quality' the videos were pretty poor quality, not worth putting on a DVD unless the content is really worth it.

Now, when does my phone contract expire...?


Filed under: k750i nero pinnacle video

5 Comments

Still umming and arring about django vs turbogears. I knocked up an online questionnaire for our intranet in TurboGears in a couple of days and it is now running. I'm starting another intranet program so I thought I'd give django a try. Once again I had to go through the tutorial to remember all the steps to set the project up. I fiddled with batch files to set up environment variables and everything, hacked the source to get it to run under WingIDE, started on the database model, all the while seeming to struggle with django itself. I got the admin screens up and running and was figuring out how to stop a password being displayed in a password field. As far as I could see, this involved editing the templates for the admin screen. It's about here that I got tired and went back to turbogears as I couldn't be bothered to tackle the django template system.

In about the same amount of time with turbogears, the project was underway and I was focused on getting the main template running. There is something about turbogears that is to me more 'pythonic' in terms of things working the way you expect and not having to waste time figuring out how to do things. kid Just Works, it is fundamentally simple and keeps out of the way, leaving you to get on with your work.

SQLObject does not appear to handle relations as nicely as the Django ORM: in django it appears I can delete an object and have the associated many-to-many mapping in the database deleted automatically whereas SQLObject does not delete it automatically and neither the documentation or the tests show me how to delete it explicitly. There is a 'remove' method in there but the object model is too complex for me how to work out how to reach it. The SQLObject documentation is comprehensive but is essentially a list of examples (not a bad thing), it does not seem to include a detailed api listing. I will have to fiddle around at the interactive prompt and see if I can figure out the incantation. Then again, the django ORM api is currently being made more intuitive. If I was going to do a lot of database work I'd be tempted to use my own db wrapper: I'd have to write SQL but I don't care, I know how to write SQL, I don't know how to use these librarys.

I have looked through the tests for both projects as example code and in both the tests are a bit cursory. The django tests are far more readable than the SQLObject tests (doctestish vs unittestish). The django tests also benefit from being commented.

Right now I'm back with turbogears as the project I am working on will not have many relationships and they will rarely need deleting.

Members of both projects have left comments on this blog, making me feel guilty about picking one over the other. I like them both equally, choosing one over the other is hard. Right now I'm further along the TurboGears learning curve which for me is not as steep as the Django learning curve.


Filed under: django python turbogears

Add a comment

Yesterday I did a google for "peter clive wilkinson" (in quotes) and came across a couple of spam blogs that have stolen my content, including the copyright notice at the bottom of the page.

I tried opening the pages but the servers were dead.

Today I did the same search and the old spam blogs have gone but a new one is there.

I won't try to look at the site again as I'm a bit wary of Windows security holes right now and don't want to visit dodgy web sites.

Windows update has installed something or other and is hastling me to reboot my pc. Has it fixed the wmf hole or not? How to tell? I'll install it anyway as I don't like the idea of having gaping security holes on my pc.

Apparently the next generation of processors will have hardware protection against buffer overflow attacks. This might be the only way to protect us from Microsoft's shoddy coding.


Filed under: google windows

5 Comments

Had some users complain about drupal generating narrow little comment boxes in version 4.6.4. drupal was generating 'cols="70"' instead of 'cols="70"' in the html.

Traced it to the function include/common.inc/form_textarea which handles cols in a different way to rows and messes it up. Worse still, it looks as if someone has done this on purpose with of course no mention why. I changed the code so cols are handled in the same way as rows and I'll wait to see what has broken.

Here is my version, reformatted to avoid the last line being 413 columns long (what's that smell?).

   1  function form_textarea($title, $name, $value,
   2                         $cols, $rows, $description = NULL,
   3                         $attributes = NULL, $required = FALSE) {
   4  // pcw  $cols = $cols ? ' cols="'. $cols .'"' : '';
   5    $pre = '';
   6    $post = '';
   7  
   8    // optionally plug in a WYSIWYG editor
   9    foreach (module_list() as $module_name) {
  10      if (module_hook($module_name, 'textarea')) {
  11        $pre  .= module_invoke($module_name, 'textarea', 'pre', $name);
  12        $post .= module_invoke($module_name, 'textarea', 'post', $name);
  13      }
  14    }
  15  
  16    return theme('form_element',
  17                 $title,
  18                 $pre .'<textarea wrap="virtual"'
  19                     .' cols="' . check_plain($cols).'"'
  20                     .' rows="'. check_plain($rows)
  21                     .'" name="edit['. $name .']" id="edit-'
  22                     . $name
  23                     .'" class="'
  24                     . _form_get_class('textarea',
  25                                   $required,
  26                                   _form_get_error($name))
  27                     .'"'
  28                     . drupal_attributes($attributes)
  29                     .'>'
  30                     . check_plain($value)
  31                     .'</textarea>'
  32                     . $post,
  33                 $description,
  34                 'edit-' . $name,
  35                 $required,
  36                 _form_get_error($name));
  37  }

Filed under: drupal

Add a comment

I've been plying with unison recently, as a means of replicating my collection of 3000 photos between two computers: I nearly lost all the family photos once before, and I have been neglecting backups. With my new strategy of having the dell D410 fire up in it's docking station every night and doing backups, it can also synchronise the photo collection with the 500m which runs all the time.

The advantage of unison over rsync is that it synchronises a pair of directories, i.e. if you add, edit or delete files on one copy then the other copy will be updated accordingly. This is a bi-directional thing, changes made to the second copy will be replicated in the first. In the case of my photo's, I always use the 500m to copy them from the camera but I am likely to use the D410 to manipulate them and what I want is changes in one archive to be fed into the other.

The invocation of unison that I have come up with so far is:

unison -batch -fastcheck true <path1> <path2>
-batch
tells unison not to ask me stupid questions, it will reconcile problems automatically where it can. -force can be used toi resolve conflicts in favour of one of the paths.
-fastcheck true
tells it to compare files by timestamp and length rather than a full binary compare, as is the default under windows.

I have been using a native windows build of unison rather than the cygwin version, mainly because the windows version handles windows file names transparently, including network file names. cygwin unison via ssh does not seem to be able to find any of the file paths I give it (e.g. /cygdrive/c/blah, the cygwin form of c:\blah) and doesn't like network path names (e.g. \\server\share).

Still, it is not working properly for my photo collection but it may be because the network is not reliable enough to handle 3000 photos and 3G worth of data with absolutely no network problems. This may be another sign that the Wifi on the 500m is iffy (iffy wifi ha!) as the d410 in it's docking station has wired networking available.

Have I mentioned recently that the d410 is really nice? The 500m screen seems huge when I go back to it but the d410 is so fast, small and light.


Filed under: backup rsync unison

2 Comments

Was contemplating setting up a vpn between my debian dedicated server and my home windows pc, but how to set it up? Thought about openvpn and found this lengthy article which looked like far too much hastle.

Then I came across mention of hamachi, an easy to set up vpn system. It is closed source but still free. It is a unique system that uses a special hack to get through firewalls in the same way as voice-over-ip.

I installed it on the server first using these instructions which are pretty straightforward. I then installed the windows client which was even easier to install, it starts a wizard up automatically.

Once connected it assigns both ends of the network static ip addresses and the windows client displays the ip addresses of both ends. From windows, just ping the ip address of the server and it worked. Add the windows ip address to the servers webmin access list and I could access webmin from the pc. Hibernate the laptop and unhibernate and it reconnects automatically.

Conclusion: like it says on the box, easy vpn. Now do I trust a closed source system that is begging to be abused by hackers?

Update: should mention that this worked despite the firewalls in my di624 router, Windows XP noddy firewall and the iptables firewall on the server. I don't think it will work if the firewall blocks outgoing UDP packets.

I have realised that I have a full peer-peer tcp/ip network: no more fiddling with ssh tunnels. The server can even push stuff to the client, I'm not tied down to sftp'ing from the server. Next step is to set up samba on the server: I wouldn't want this open to the internet and it can only be tunnelled through ssh if you disable file and printer sharing in windows.

The server could send a WOL packet to my laptop to turn it on and an xml-rpc server on the laptop can do just about anything: record tv, stream webcam, turn the lights on... This was possible before but now it can all be done in an even cooler way.

Update 2: next day after writing this the Hamachi servers went down, taking my vpn, and however many other hamachi vpn's, down with it. Looking at their forum, their servers do seem a slight liability, being subject to DOS attacks and whatnot.

The linux tools don't give much in the line of diagnostic information: if it does ever time out it just says 'Failed', no clue why. Maybe good for security to give no clues but not good for debugging. Had troubles getting three computers on the same network, getting three connected happily at the same time: one or other would be unable to ping it's peers.

In conclusion, I've given up on this, when it works it is nice but I want something that is more reliable and has proven security.


Filed under: debian hamachi vpn windows

4 Comments

How to watch tv anywhere in the house?

1) Capture sound/pictures from tv to a pc and stream them round the house via wifi.

2) walk around house with gorgeous d410 laptop.

3) enjoy.

No more messing around with tv cables in the attic.

Problems:

  • how to change channel?
  • why didn't I think of this before?

Filed under: sky+ wifi windows

4 Comments

After a couple of weeks of neglect I ran an update on the packages on my debian server. It gave me a few surprises:

  • it upgraded mysql from 4.1 to version 5
  • it uninstalled the webmin mysql module
  • it uninstalled my vim-python version 6.3 and installed plain vim version 6.4

The new version of mysql seems to be running smoothly (or you wouldn't be reading this). Must see if it supports cascade delete, my all-time favourite sybase sqlanywhere feature.

I manually installed vim-python using dselect and was happy. Installer glitch. I haven't addressed webmin-mysql yet, it wasn't obvious from what dselect showed me whether what it had would work with mysql 5. Maybe it doesn't say because it doesn't matter? I find webmin-mysql can do all the mysql database administration I need (create database, add users, set permissions, view table etc) with a much simpler interface than phpmyadmin, which is slightly ott.

I think vim 6.4 is a bug fix release. Upgrading on windows involves recompiling it with python support, not a big deal but it takes time that could be spent doing other things. Sometimes I contemplate hosting vim-python for windows downloads as a public service. I'll contemplate it some more.


Filed under: debian mysql vim

2 Comments

For a long time now I have been contemplating how to validate users on a linux box against a Windows 2000 Active Directory domain. What I mean is, how to use the user names and passwords from the Windows server, without having to set up a duplicate password database on the linux box? I had been under the impression that this meant setting up a linux ldap server and migrating everything to that (as the Windows 2000 version of ldap is deliberately non-interoperable).

Been into it again today and discovered that from python it is actually very easy to validate via python samba support:

import samba.winbind

try:
    if samba.winbind.auth_plaintext( 'Domain\\%s' % strUser, strPassword) != 0:
       raise 'login failed'
except(samba.winbind.error):
    raise 'login failed'

Samba finds the domain controller and validates the user name and password. What could be easier?

This is fine for intranet activities but if you want users logging into your linux box you have to go the ldap route to give them unix groups, login shells etc. Good luck with that.


Filed under: linux python

2 Comments

My site is being really hammerred by comment spammers today but not one has got through thanks to my policy of refusing to allow comments containing urls to be submitted (not even for moderation: I moderate all comments, I found deleting comment spam to be tedious as well as annoying).

It is a simple hack to the drupal comment module but it is very effective. Ok, I could get spam without url's in but what's the point, apart from vandalism? They still go into the moderation queue and get deleted.

And when people do want to post url's they soon figure out how to get around the block. If they cannot do that then their comments are probably not worth consideration anyway.

I'd give the details of the hack here but it gives the spammers a clue. If you are interested then email me.

Update: following on from the vast surge in comment spam attempts (three or four a minute, 24/7), statcounter tells me people are searching for drupal captchas. I have given up on these, something about drupal states, redirects, session management or whatever stops them working reliably. The spam comment check is just part of the comment validation, there is nothing much that can go wrong with it, it is just straight if/then/else code.

In a way the spam check is a captcha (Completely Automated Public Turing Test to Tell Computers and Humans Apart), you can still get through if you show some smarts. It doesn't use graphics so it doesn't look cool and it doesn't shut out blind people.

The comment spam is coming from a range of ip addresses, maybe an array of compromised pc's (thanks Microsoft). Each 'failure' page is using some of my 10G/month bandwidth. I'll have to keep an eye out and see what kind of impact this is having. It could be even worse than inktomi slurps bots doing 100M of crawling a month and not directing anyone here through their search results.


Filed under: captcha drupal spam

9 Comments