Category Archives: Technology

Fat fingered discovery of the day

It’s amazing how much you can learn with a little clumsiness. In my case, all I wanted to do is power off the screen on my Fairphone and, instead, I took a screenshot.

A quick search reveals that this is because I (unintentionally) had my thumb on the volume down button when I pressed the power button.

So now I have a screenshot, so here it is.

flattr this!

Vim in Powershell

Because, why not.

And because I am stuck in Windows Land while at work.

And because I found myself playing around with Windows Power Shell. It’s not as good as Bash by a long stretch, but it is a significant improvement on the old Windows cmd almost-terminal. And, because I like to be able to move from task to task, without having to constantly switch windows, I thought I would give it a try.

The first thing to do, of course, is install a decent text editor. This is easy, a Windows binary exists for Vim so I downloaded and installed it. Then comes the fun bit.

Getting it to work in Powershell isn’t exactly difficult, but there are a few hoops that need to be jumped through and no clear overview of what and where these hoops happen to be. And that’s why I am posting this.

First, you need to allow scripts to run. This is not enabled by default because, obviously, if you have a scripting environment, the last thing you are going to want to do is execute scripts. Fortunately, this is easily checked and altered by means of the execution policy.

To see the current state of your execution policy, use:


This will probably tell you it’s restricted, in which case you need to tell it to run scripts by typing (or pasting):

Set-ExecutionPolicy RemoteSigned

(You can also set the execution policy to AllSigned or Unrestricted, but RemoteSigned is sufficient for now.)

Next, you need a Powershell profile (why is it that Windows terms all feel like they should be wrapped in a blink tag?), which can be created by typing (or pasting):

new-item -path $profile -itemtype file -force

And now you need to edit your profile to add a Vim alias. You’ll need to do this in Notepad:

notepad $profile

And then paste the following:

set-alias vim "C:/Program Files (x86)/Vim/Vim74/./vim.exe"

# To edit the Powershell Profile
# (Not that I'll remember this)
Function Edit-Profile
    vim $profile

# To edit Vim settings
Function Edit-Vimrc
    vim $HOME\_vimrc

(Obviously, you will need to amend the Vim path name to match the reality on your system.)

And you’re done.

I’m not sure how much use I will actually get out of Vim at work as my workflow often involves copying and pasting text from one application to another – and for that Notepad++ is probably still a better fit. However, having an additional tool certainly does no harm and I can certainly see cases where having the power of Vim available will be useful. For now, I will use both and see how each fits into my workflow.

And finally, this post was brought you you with the help of Microsoft, Marlon Abastar and Julian Kay.

flattr this!

Automated devastation

This morning, Macsen and William built a tower…

And then we knocked it down. With Robots

Okay, one robot and a toy one at that. But Macsen did do a rather good job of programming it and we had a fair bit of fun figuring out what design would collapse most spectacularly.

Rather a successful Sunday morning, I thought.

flattr this!

Executing SQL statements from within a CL with RUNSQL

Here’s a CL Command I didn’t know about, RUNSQL, which allows an SQL statement to be run from within a CL program without needing a source file.

Inevitably, I found this because I was looking for a quick solution to a transitory problem. I won’t bore you with the details but, what I wanted to do was create a temporary file, populate it with orders for a (user specified) date and then copy this file into a library that has been made available to an external ftp application.

Here is what I ended up with (field, file and library names have been changed for clarity and to protect the innocent):

  pgm &date
  dcl &date *char 8
  dcl &statement *char 150
  dcl &nbrrcd *dec (10 0)
  cpyf fromfile(template/orders) tofile(qtemp/orders) +
       mbropt(*add) crtfile(*yes)
  clrpfm qtemp/orders
  chgvar &statement value('insert into qtemp/orders +
                           select * from archlib/orders  +
                           where msgdat = ' *cat &date)
  runsql sql(&statement) commit(*none)
  rtvmbrd qtemp/orders nbrcurrcd(&nbrrcd)
  if cond(&nbrrcd *gt 0) then(do)
     cpyf fromfile(qtemp/orders) tofile(ftplib/orders) +
          mbropt(*add) crtfile(*yes)
  dltf qtemp/orders

It’s all pretty simple stuff but being able to embed the SQL statement right in the CL makes a conceptually simple solution very simple to implement.

flattr this!

MTB: Now with randon lock screens

Just a quick note to mention that MTB is now able to randomise lock screens as well as regular backgrounds.

This part of the program is not time-sensitive and doesn’t need much in the way of configuration. You just need to have a one or more pictures in ~/Pictures/Backgrounds/lock.

It works. It’s fun. Enjoy.

flattr this!

Pyrrhic Convenience: The Microsoft Poetry Edition

After three attempts, my employer has finally managed to upgrade switch my laptop from Windows XP to Windows 7. Consequently, I have spent much of the morning achieving a zen-like state of frustration as I attempt to decrapify my desktop.

I mean, how hard should it be to point a text editor at a syntax file? Very hard indeed, it appears, because Windows 7 insists on obscuring the file locations behind libraries and ‘helpfully’ shortened path names, thus turning a simple file copy into a never-ending nightmare.

But I got there, eventually, and managed to turn off most of the notifications and other annoyware that comes as standard with Windows and I even changed my desktop background to a nice relaxing landscape. And, boy, do I need to be looking at a lot of relaxing landscapes right now.

Then I noticed that some of the applications weren’t using the Windows 7 themes deciding, instead, to do something completely different. A bit of flipping back and forth between windows confirmed that the software responsible for this unpleasantly jarring effect was… Microsoft office.

Or, to put it another way, the only company unable to properly write Windows applications is Microsoft.

So, back to the internet I went to see if there was any (no-obvious, wholly unintuitive) way of fixing this. As far as I can tell, there isn’t, but I did find this:

All I can see is “White”, “Light Grey”, and “Dark Grey”…which is equivalent to “Stormtrooper White”, Stormtrooper Light Grey”, and “Stormtrooper Dark Grey”. Did the Adams Family design the Office 2013…

Or better still:

Then, you launch the Excel 2013 app…and all the life is instantly sucked right out of Windows 8. You can feel it in your bones. The Office apps are a barren, Boot Hill-esque, cold wasteland….with grey and white tumbleweeds and gravestones. Then, you go back into Metro…and WHAM…it’s the Skittles rainbow monster voraciously attacking everything in sight. Nom nom nom nom. Big blocks of color coming at you….it’s crazy like…wow man…what a Fear and Loathing in Las Vegas trip crazy! You are flying sky high with the bats and stingrays. Life is groovy. You then launch Outlook 2013 and WHAM…there you are…slammed down to the ground…back in Frankenweenie land ready to raise some dead animals or something.

Yes. That’s exactly what it’s like.

Odilon Redon once said:

What distinguishes the artist from the dilettante? Only the pain the artist feels. The dilettante looks only for pleasure in art.

May I suggest a new slogan for Windows 7, Microsoft Office and – I suspect – the whole stable of Redmondware: It’s not for dilettantes.

flattr this!

Squirt 0.1: Functionally Adequate

I think this counts as a release announcement.

Version 0.1 of Squirt, a Regex capable command-line FTP client is now available for download from GitHub.

This application started as an attempt to provide a simple way of maintaing frequently used simple FTP scripts and I have finally reached the point at which I can say that the core FTP functionality is now up and working. There is still a fair bit to do, but this release is both usable and provides a basis upon which it will be possible to develop a simple mechanism for managing scripts across a variety of protocols and, eventually, a mechanism for piping these scripts together.

Feel free to have a play with it and, if you do have any feedback, I would appreciate hearing it by way of the GitHub issue tracker.

flattr this!

Prime pair sets

I started playing around with Project Euler way back in November 2011, not least as an opportunity to hone my still nascent Python skills. And I’m still learning.

Problem 60 states:

The primes 3, 7, 109, and 673, are quite remarkable. By taking any two primes and concatenating them in any order the result will always be prime. For example, taking 7 and 109, both 7109 and 1097 are prime. The sum of these four primes, 792, represents the lowest sum for a set of four primes with this property.

Find the lowest sum for a set of five primes for which any two primes concatenate to produce another prime.

This took a bit of thinking about but the approach I eventually came up with was to create a set of concetanatable primes for each prime (up to an arbitarily chosen value of 10000). Then all I would need to do is search each set for intersecting elements until I found five intersecting sets. Since the primes are generated in order, from lowest to highest, the first set of five intersecting sets will give me the answer.

Then for the implementation…

I already have a function that returns a list of primes, so that was easy, and using a dictionary keyed by prime was a no-brainer, but looking for set intersections was a bit of a struggle. Until I discovered that Python will do it for me. Using the set class it becomes remarkably easy to build a dictionary of sets and then work through them, checking intersections, until I find five sets that intersect.

My actual code is neither nice nor fast, and it isn’t going to scale at all – but I am quite pleased to have gained a handle on yet another iterable type.

flattr this!