MS Surface Pro 4

I’ve been using an old iPad for many years and generally find it OK for web browsing, watching videos and so on, but even with an external keyboard attached it sucks for “PC like” tasks. Maybe I’m just an MS slave, but the Office apps are hard to beat, and the limits on file access and sharing on the iPad make it really hard to do anything significant.

I considered upgrading my very old laptop, but then I’d also want to upgrade my iPad – so simple solution seemed to be get a Surface: laptop and tablet in one.

The model I got is a Pro 4, Core i7, 8MB memory 256GB disk – and it’s brilliant.

Type cover is as good as most laptop keyboards I’ve used, and has all the keys in the right layout unlike all the bluetooth iPad keyboards I’ve seen.

Speed is what you would expect of a Core i7 and an SSD – basically very quick, no lag on doing anything that I can see. Of course I’ll try to keep it light on servers and background crap that run on my main PC.

Pen is OK, but I don’t really use it much – the writing recognition is amazing (even with my dreadful scrawl), but I can simply type faster than I can write, and the keyboard + built-in full width stand is really comfortable on my knee because the whole thing is so light.

And the screen – wow, the text looks like it’s been laser printed. In fact it’s so clear it looks kind of “big” – I keep checking the font size against other screens and it’s comparable, but the clarity makes it stand out, even in paler colours that some people seem fond of using in emails.

So my conclusion is that it’s the best laptop I’ve owned by some margin (unbeatably light, easily powerful enough), and almost as good as an iPad as a tablet.

Big Stumble by StumbleUpon

One year ago:

“Our badge/widget isn’t compatible with https sites; there are no plans at this time to change it.”

https://getsatisfaction.com/stumbleupon_help_center/topics/badge_widget_https_mixed_content_problem

Wow, how to ignore an ever growing set of your content base, specifically those most up-to-date and therefore probably interesting, in one sweeping statement.

Must be trying to compete with Reddit for the foot shooting prize.

Cute File Browser

I found this very neat jQuery based file browser:

http://tutorialzine.com/2014/09/cute-file-browser-jquery-ajax-php/

This uses a simply PHP script to form JSON output defining the filesystem, however in my case I want to serve files on a Windows PC using just static content. This is relatively easy to code – we just need to create the file listing in advance, e.g. into something called files.json, and modify the javascript to retrieve this instead of scan.php.

My batch script to do that is listed here – it simply scans recursively from the current directory creating the necessary JSON on the output; you can pipe it to the appropriate location for the files.json output.

@echo off
setlocal enableextensions disabledelayedexpansion

set p=%1
set n=%2
set comma=
set oldcomma=X

call:funcdo "%1" "%2"

endlocal
goto:eof

:funcdo
setlocal
set "p=%~1"
set "n=%~2"

echo {"name":"%n%","type":"folder","path":"%p%","items":[

set oldcomma=%oldcomma%%comma%
set comma=N

for /d %%d in (*) do (
    cd "%%d"
    call:funcdo "%p%/%%d" "%%d"
    echo ,
    cd ..
)

for /f "tokens=*" %%f in ('dir /b *.divx *.mpg *.mpeg *.avi *.mkv *.mp4 *.wmv 2^>nul ^| sort') do (
    echo {"name":"%%f","type":"file","path":"%p%/%%f","size":"%%~zf"},
)

echo {}]}

set comma=%oldcomma:~-1%
set oldcomma=%oldcomma:~0,-1%
endlocal
goto:eof

It’s not very polished and could no doubt be improved, but it works.

Mail forwarding blocked by SPF

Some time ago I moved away from Yahoo mail to my own hosted address, and used the forwarding function to pass through any residual mail. This worked fine for several years, but now my host has implemented strict SPF control and a lot of the forwarded mails get rejected.

Unfortunately Yahoo doesn’t give any sophisticated options to handle this, eg. there are a number of options they could have implemented for forwarding from the Yahoo address without looking like it’s spam:

  • normal forwarding, or as an attachment
  • putting the sender in the Reply-To header
  • or even a line of text saying who the original sender was

The only way I found to get around this was to stop the forwarding, and use a PHP script to periodically check my Yahoo account via POP and move the mail to my new IMAP account. This actually works fine, so in case it’s of use to others here is the script I use:

<html><body><pre>
<?php 

docopy("{pop.mail.yahoo.com:995/pop3/ssl}INBOX","Yahoo email","Yahoo password",
       "{Target imap:143}INBOX", "Target login", "Target password");

function docopy($smailbox, $suser, $spwd, $tmailbox, $tuser, $tpwd) {
  echo "--------------------\nCopying mail from $smailbox:$suser to $tmailbox:$tuser\n--------------------\n";

  if (!($source = imap_open($smailbox, $suser, $spwd))) {
    echo "Connect to source failed";
    exit(1);
  }

  echo "Connected source: $source\n";

  $msgcount = imap_num_msg($source);

  if ($msgcount == 0) {
    echo "No messages to process\n\n";
    imap_close($source);
    return;
  }

  echo "Messages: $msgcount\n";

  if (!($target = imap_open($tmailbox, $tuser, $tpwd))) {
    echo "Connect to target failed";
    imap_close($source);
    exit(1);
  }

  echo "Connected target: $target\n";

  for ($msg = 1; $msg <= $msgcount; $msg++) {
    echo "\nProcessing message $msg\n";

    $header = imap_fetchheader($source, $msg);
    $body = imap_body($source, $msg);

    if (!imap_append($target, $tmailbox, $header . $body)) {
      echo "Saving message failed";
      imap_close($source);
      imap_close($target);
      exit(1);
    }

    echo "Message saved\n";

    if (!imap_delete($source, $msg)) {
      echo "Deleting message failed";
      imap_close($source);
      imap_close($target);
      exit(1);
    }

    echo "Message deleted\n";
  }

  imap_expunge($source);

  imap_close($source);
  imap_close($target);

  echo "Completed copy\n\n";
}
?>
</pre></body></html>

Obviously you have to fill in the bits for Yahoo email, Yahoo password, Target imap etc. It should also work for other POP or IMAP sources/targets, but I haven’t tried it.

The function can be called several times if you have more than one account to copy, in my case two works fine.

It’s written to give some level of output if you run it through a web server, then once it’s working you can schedule it to run every few minutes via cron or similar.