ocroquette's technical Blog

Icon

TTT (tips, tricks, tools)

Get list of “smtp” email addresses from Outlook messages

I had recently to export the email addresses contained in the BCC: field of an Outlook message. It turned out it’s not that easy. It achieved it with the following of Visual Basic, which will let you pick a folder and dump all recipients for all messages in this folder. I wanted to do it for a specific message and copy the result to the clipboard, but neither of this looks easy in Outlook. I spent already too much time on this so I give up, this version is good enough for me.

Sub ExtractRecipientsFromEmail()
Dim OlApp As Outlook.Application
Dim MailObject As Object
Dim RecipientObject As Object
Dim Email As String
Dim NS As NameSpace
Dim Folder As MAPIFolder
Set OlApp = CreateObject("Outlook.Application")
Set NS = ThisOutlookSession.Session
Set Folder = NS.PickFolder
For Each MailObject In Folder.Items
If MailObject.Class = olMail Then
For Each RecipientObject In MailObject.Recipients

Dim smtp As String
' Debug.Print "ad=", RecipientObject.Address

Select Case RecipientObject.AddressEntry.AddressEntryUserType
Case OlAddressEntryUserType.olExchangeUserAddressEntry
Set oEU = RecipientObject.AddressEntry.GetExchangeUser
If Not (oEU Is Nothing) Then
smtp = oEU.PrimarySmtpAddress
End If
Case OlAddressEntryUserType.olExchangeDistributionListAddressEntry
Set oEDL = RecipientObject.AddressEntry.GetExchangeDistributionList
If Not (oEDL Is Nothing) Then
smtp = oEDL.PrimarySmtpAddress
End If
End Select

Debug.Print smtp

Next
End If
Next
Set OlApp = Nothing
Set MailObject = Nothing
Set RecipientObject = Nothing
End Sub

Filed under: Uncategorized

Installing debian on a Popcorn Hour A-210

Instructions based on: http://www.networkedmediatank.com/showthread.php?tid=16317

On an existing Debian or Ubuntu system:

apt-get install debootstrap
debootstrap --arch mipsel --foreign stable debian
tar -cvzf debian.tgz debian
mount --bind /proc/ debian/proc/
mount --bind /dev/ debian/dev/

Copy the TGZ to your device, log in with telnet on your NMT, and run:

tar -xvzf debian.tgz
cd debian
usr/sbin/chroot . /bin/bash
export PATH=$PATH:/usr/bin:/usr/sbin
debootstrap/debootstrap --second-stage
# Verify the DNS settings, in case you used different network configurations on the computer and the Popcorn Hour:
cat /etc/resolv.conf
exit

Now you should have a Debian system running. Configure the package source:

usr/sbin/chroot . /bin/bash
echo "deb http://ftp.de.debian.org/debian/ squeeze main " >> /etc/apt/sources.list
echo "deb http://security.debian.org/ squeeze/updates main " >> /etc/apt/sources.list

Note: check out the following generator for sources.list : http://debgen.simplylinux.ch/generate.php

Update the package list and install the required packages:

apt-get update
# Standard stuff:
apt-get install vim less sysklogd sudo lsof nmap wget curl psmisc
# Development:
apt-get install gcc autoconf automake subversion git uuid-dev uuid-runtime make

Create a user (working as root constantly is dangerous):

adduser user

Install SSH:

apt-get install openssh-server openssh-client
/etc/init.d/ssh start

Filed under: Linux ,

Reencode videos to watch them on an Android device with ffmpeg

Here is the script I use to convert videos to watch them on a Samsung Galaxy Ace. You can probably use it for any Android device, just modify the maximum resolution.


#!/usr/bin/perl

use strict;
use Data::Dumper;
use Getopt::Long;

sub getFileResolution {
my ($file) = @_;
my $stdout = `ffmpeg -i "$file" 2>&1`;
# Stream #0.0: Video: mpeg4, yuv420p, 720x528 [PAR 1:1 DAR 15:11], 25 tbr, 25 tbn, 25 tbc
$stdout =~ /Stream.*Video:.*?([\d]+)x([\d]+)/;
my ($w, $h) = ($1, $2);
die "Failed to get original resolution of \"$file\" ($w,$h)" if ! ( $w && $h);
return ($w, $h);
}

sub getNewResolution {
my ($width, $height) = my ($newwidth, $newheight) = @_;
my $ratio = $width * 1.0 / $height;
my $maxwidth = 480;
my $maxheight = 320;
if ( $newheight > $maxheight ) {
$newheight = $maxheight;
$newwidth = $ratio * $newheight;
}
if ( $newwidth > $maxwidth ) {
$newwidth = $maxwidth;
$newheight = $newwidth / $ratio;
}
return (int($newwidth), int($newheight));
}

sub getNewName {
my ($file) = @_;
$file =~ /(.*)\./;
my $basename = $1;

my $newname = $basename . ".mp4";
return $newname if $newname ne $file;

return $basename . "-converted.mp4";
}

sub printUsage {
print STDERR "Usage: $0 --input INVIDEO [--output OUTVIDEO] [--volume N]\n";
print STDERR " Converts the input video into a MP4 video readable on mobile devices\n";
print STDERR "\n";
print STDERR " --input : the input video file\n";
print STDERR " --output : the input video file\n";
print STDERR " --volume N : increase or decrease volume ; nominal volume is N=256\n";
print STDERR "\n";
print STDERR "Example:\n";
print STDERR " $0 --input file.avi --output file.mp4 --vol 512\n";
}

my ($src, $dst, $volume);
my $gocode = GetOptions (
"input=s" => \$src,
"output=s" => \$dst,
"volume=i" => \$volume
);

if ( ! $gocode || scalar(@ARGV) ) {
printUsage();
exit(1);
}

my ($w, $h) = getNewResolution(getFileResolution($src));
$dst = getNewName($src) if ! $dst;

my @args = ("ffmpeg");
push @args, "-i", $src;
push @args, "-s", "${w}x${h}";
push @args, "-b", "600k";
push @args, "-ab", "96k";
push @args, $dst;
system(@args);

Filed under: Android, Video

git: failed to lock

Recently I had this error message “failed to lock” while trying to push some changes to a remote Git repository.

After some time Googling with no success and then troubleshooting, I realised I was trying to push to branch called “a/b” while the branch “a” existed. This is obviously not supported in Git, since having a branch “a” requires “.git/refs/heads/a” to be a file (containing the current branch head), while having a branch “a/b” requires “.git/refs/head/a” to be a directory.

Filed under: Uncategorized

rsync under Windows, permission problem

When calling rsync from Windows (e.g. with Cygwin) to sync to Unix, I had the bad surprise that all directories created on the Linux side had the permission 000 (that’s it, no permission at all). After rsync created the top level directory, it would pitifully fail to create any element underneath it (mkdir: permission denied).

The solution is to call it with the chmod option :

$ rsync -rtxv --chmod=ugo=rwX -e ssh localdir/ user@host:/remotedir

Filed under: Uncategorized

Expression Media crashing when opening a catalog

If Expression Media is crashing when you open a specific catalog, you can try the hints described in this thread :

http://www.eggheadcafe.com/software/aspnet/31633965/catalog-corrupt-crashes-mem.aspx

For the record, they are :

  1. Self repair : Hold down the Alt key on the keyboard while clicking Open in the open dialog (didn’t work at all for me)
  2. Create a new catalog and import from the corrupted catalog (didn’t work for me : the progress bar showed the import of my medias, but at the end the new catalog was empty)
  3. Open the catalog on another computer, if possible using a different OS (I could open the catalog using EM2 under Windows vs. MacOS X, unfortunately saving a copy and opening it in MacOS X again still led to a crash)

In my case, I had to combine 3. then 2. to get back to a working catalog under MacOS X. That’s a relief, because this catalog contains a hell lot of data entered manually, probably more than 500 hours of work.

 

Filed under: Photo , , ,

Random delays while accessing a web page

Some parts of a web server I am administrating was showing a bad “felt” performance. Using Firebug, I narrowed down the problem : there were random delays in the delivery of the pages. Sometimes it was PHP scripts, sometimes CSS or Javascript files. Since CSS and JS files are static, it excluded a problem with PHP or the database. The load on the server was OK, so it wasn’t that either.

I finally found out that by disabling the Keep Alive feature on the server side, the problem disappeared. I still have to investigate what the exact problem is (Keep Alive is part of the HTTP standard and used widely). It could be a problem with the Content-Length that is not reported correctly by the server, causing the browser to wait for more data.

Filed under: Web , , , , ,

Sony Alpha 100 vs Sony Alpha 550 (noise)

One huge weak point of the Sony Alpha 100 is the noise. I was expecting the 550 and its CMOS sensor to provide a major improvement to this regard, and was not disappointed.

Here is quick illustration. It’s a typical lowlight situation. Even with an aperture of 2.8, if I want to keep a reasonable exposure time of 1/30, I need 1600 ISO. Here is how the 2 cameras handle the challenge. The pictures speak for themselves.

Alpha 100 (notice the horrible noise in the background in the top left corner) :

Alpha 550 :

Alpha 100 :

Alpha 550 :

Filed under: Photo

Personal review of the Garmin Oregon 300

After some time using the Etrex Vista Hcx, I have switched some weeks ago to the Oregon 300.

Here are the pros and cons, including the ones in comparison with the Etrex Vista Hcx.

Pros (common to the Vista Hcx) :

  • Fast boot and GPS fix (typically 15 sec – 1 min )
  • Good dimensions for a hand held device
  • Can be used for turn-by-turn navigation (ie. car) if you have the right map
  • Uses normal AA batteries
  • USB connection and USB mass storage mode (to send the maps or get the logs)
  • Power over USB : very useful in the car, but no battery charging over USB
  • Good battery performance (8h or more)
  • Can save logs (ie. tracks) to the memory card
  • Customizable, ie. :
    • on all pages (map, stats, …) the displayed fields can be defined very precisely (ie. average speed, max speed, ETA…)

Pros compared to the Vista Hcx :

  • Thanks to the touch screen, the controls are much intuitive. Menu structure is very clean (but also require more steps to use, see cons)
  • Scrolling the map is faster and more intuitive
  • It’s possible to have several map files on the card, eg. if you need temporarily a new piece of map, just add the corresponding file to the memory card (no need to regenerate a huge single file). When you don’t need it anymore, just delete it
  • Clips directly on the bike mount. No need for a little piece of plastic and metal like on the Vista Hcx.
  • Different profiles possible, eg. bike, car, walk… (not tested yet)
  • Better screen resolution
  • Openstreemap maps look great (see here the instructions)

Cons (common to the Vista Hcx) :

  • Detailed maps are very expensive, especially for France
  • Batteries can not be charged over USB
  • The altitude displayed and recorded in the tracks is unusable in (pressurized) airplane cabin. The device relies much too much on the barometric altitude. Even the auto-calibration doesn’t help. The algorithm must be changed so that the GPS altitude is taken over when there is a reasonable fix and the different with the barometric altitude is more than eg. 100m
  • Garmin tools do not support MacOS X
  • For the frequency of track points stores in the log, there are 5 settings, but even “Most often” is quite coarse, so I have to force it to “Every second”, but then the track becomes huge very fast. There is no good compromise.
  • Does not record Hdop, Ldop or similar information in the track logs
  • Very limited memory for the current track log, even if you have a big SD card
  • The device has to be held 100% horizontally for the compass to be accurate. If you hold it naturally, ie. at the level of your breast with the screen perpendicular to your visual sight, then you hold it with a 10°+ angle, and that’s enough to get an error of 20° or more in the compass function
  • You can’t decide (and at the beginning it’s not clear) which altitude is displayed or stored in the log (the device can have up to 3 sources : GPS altitude, barometric altitude, map)
  • I really miss a function that would reset the statistics after X hours of inactivity, or ask at startup to do so

Cons compared to the Vista Hcx :

  • The screen is not as bright. Actually, even with the full brightness, it’s not bright enough. On a sunny day, you will have to find/make some shadow to see well
  • The Vista Hcx can save GPX files automatically to the memory card, one per day. The Oregon 300 doesn’t have this feature. A big loss !
  • The Oregon displays the time of day only with hours and minutes, not the seconds. So you used to sync the time of a digital camera by taking a picture of the Garmin’s screen (e.g. for geotagging, openstreetmap), that won’t work anymore.
  • The Vista Hcx has a key to access the settings of the current mode (eg. map, compass…). With the Oregon 300, you have to go back to the root page, and navigate to Settings, and choose the right category, change what you need, and go back to the root page, and return to the mode you were in. Very inefficient !

Other links :

Filed under: GPS

dvsplit: tool to split raw DV files based on the timestamps

Using the solutions described here, you get a big raw file.

dvsplit is a simple tool to split it in several files based on the timestamps.

See the README.

And here is the tool.

Filed under: Video , , , , , , , , ,

Follow

Get every new post delivered to your Inbox.