I'm .ok you're .ok: introducing folder profiles for bash and powershell


Summary: a .ok file holds a bunch of handy one-liners, specific to the folder it is in. It can be viewed or executed with a simple command. It makes you smarter and more efficient.

I work on lots of little projects and each one has its own nuances and tricks. Context switching from one project to the next is hard on the brain. Some projects are brand new, some are ten years old. Some are in Windows, some are in Linux.

Every time I go to resume work on a project there is that moment of confusion as the brain tries to reload a dusty tape of facts from cold storage.

To make it easier to recall all pertinent facts, I've started putting a little file called ".ok" in each project. This file holds any relevant shell commands I use with that project. (I have a powershell version and a bash version)

For example here's the .ok file from my "Today I Learned" project:

.\quick.ps1; .\deploy.ps1; # quick-build, prepare to deploy
.\build.ps1 # complete build, after which you can see preview
_book\index.html # see preview
.\wordcount.ps1 # custom word count script

If I type the command "ok" then I will see a listing of this file with a number against each line:

> ok
1. .\quick.ps1; .\deploy.ps1; # quick-build, prepare to deploy
2. .\build.ps1 # complete build, after which you can see preview
3. _book\index.html # see preview
4. .\wordcount.ps1 # custom word count script

And if I type "ok 3" then it will run line number 3, like this:

> ok 3
> _book\index.html # view preview

(And in this case I'll see a HTML preview of the current state of the book)

To make "ok" extra useful, I've setup my system so that every time I navigate into any folder (via cd), the command "ok" is run immediately. So if there is a ".ok" file I'll immediately see the available commands. (I did this by removing the "cd" alias, and making a custom "cd" function that does a set-location followed by a call to "ok")

If I want to add a command to the file, it is the work of a moment. I can do it immediately by editing the ".ok" file with "ed" or any standard editor.

Source code is here:

"ok" folder profiles for bash

And here:

"ok" folder profiles for powershell

Sometimes I write a thing and slowly stop using it. Other times I use it more and more, day after day, year after year, as happened with NimbleText. So far, "ok" seems to be one of those "use it more and more" solutions. So I think you would do well to give it a try.

Any issues, lemme know.


2017 by the Numbers

Being productive in 2017 was particularly challenging. The most powerful nation on earth elected a madman, and no-one could really think about anything else. If you produced nothing, but managed to survive, then good for you.

Here's a summary of things I shipped. Numbers in parens, e.g. "(3)", are last year's figures.

Things I didn't publish:

  • A massive pile of genealogical research.
  • Research into Python in Minecraft
  • "Epic Loot Quest of the Dungeon Raider" (threejs fps)
  • "Androids versus Electric Sheep" (Artificial Life program)
  • Linqpad scripts for generating Guitar chord/key/scale cheatsheets and progressions.
  • 65 stub articles at the wiki.

Your photos are a mess! Maybe this PowerShell script can help

As a family, you have a huge photo problem. Well, at least my family does.

After a holiday we have thousands of photos on two smartphones, two regular cameras, and a few on an iPads as well. From this horrible mess, my wife wants to select the best of the best and print them in a photobook.

Before she can start putting the photobook together, we need to collate the photos from all the devices in such a way that photos are in precise chronological order, regardless of which camera they came from. And to make matters worse, the smartphones have automatically adjusted for timezones, while the others have not.

Enter the "Rename-Photo" commandlet I put together in Powershell. This thing has improved my life far more than the average PowerShell script.


First: if you're going to use this, there is no warranty, and I advise testing on one or two pictures first, before blasting all of your photos.
Second: I'm not a great PowerSheller and haven't turned this into a reusable "module". If you want to help me turn it into a module please do!

With those caveats out of the way, I'll show you why I love this script and why it brings bliss to my whole family.

First, you bring all the photos together, from all the devices, onto one hard drive, in separate folders. This might itself involves lots of rummaging for cables and some cursing and various levels of frustration. But eventually you might have a structure like this, with one folder for each device:

photo folders

Once you've got those folders in place, you will need to run a script in each folder (more details below).

First, you can grab the script from here:


or by running:

git clone https://github.com/secretGeek/rename-photo.git

And to make sure the Rename-Photo function is available, "dot source" the PowerShell file, by running:

. .\RenamePhoto.ps1

(from Powershell!)

Done that? Now go into one of your photo folders (in PowerShell) and run the rename-photo function against all the files. You'll need to know what values to provide for a few snazzy parameters.

For example

dir *.jpg | % { Rename-Photo $_.FullName "iPhoneSally" "Martinique" }

This will rename all of the jpg files in the current folder, to have a filename like this:



  • 2017-11-10-14-12-10 — is a sortable representation of the date the photo was taken (from the Date taken EXIF data). It's not formatted in strict ISO 8601 format. If the file doesn't have the relevant EXIF data (for example if it's a png file) then the LastWriteTime is used instead.
  • iPhoneSally — is the device name you've supplied as a parameter. This can be helpful later if you need to work out who took a particular photo
  • Martinique — is from the 'location' parameter
  • 53959339 — is the number of bytes of the file, and acts as a useful tiebreaker in-case two photos were taken on the same device in the same second. (This was effective for me, over tens of thousands of photos, so I wasn't forced to use something like a checksum for tie-breaking.)

There's one more parameter, and you can use it for fixing the infamous timezone issue. Once you've worked out that the camera's internal clock was reporting times that were 10 hours earlier than the real local time, then add a final parameter of "10", e.g.

dir *.jpg | % { Rename-Photo $_.FullName "iPhoneSally" "Martinique" 10}

If you've made a small mistake, the script can be re-run. There's no limit on how many times you can re-name the same file. And you can alter the script to improve the format.

The real filename formatting work is done in the line that looks like this:

$newName = ("{0:yyyy-MM-dd-HH-mm-ss}_{1}_{2}_{3}{4}" -f $exactDate, $device, $location, $length, $extensionWithDot)

And if you change the script, just dot it again. There's no limit on the number of times you can do this either.

Once you're happy with the filenames, copy all of the files, from all of the devices, together into a single folder.

I tend to break them down into one folder for each year, so you don't totally overwhelm the file system.

Then all the files are together, and the joyous hurdy gurdy of a family trip has been sorted into a single stream of captured moments.

Any improvements, please submit a pull request or raise an issue on GitHub.

Any questions, the comments are open.

kind regards


How to Discuss the Important Things With Your Kids

With my youngest about to turn 7, I found it an important time to discuss with her the most important question of all:

How do 7-segment LCD displays work?


7-segment LCD displays are the sort you see on old-fashioned digital watches, microwave ovens, time-traveling deloreans and other common household appliances.

First I drew 10 sets of the 7 cells, all inactivated. I described to her how the 7 cells are switched on or off to make the numbers. Together we colored in the right cells to make up each digit.

7 segment display

We talked about how the digits from 0 to 9 can be described by 7 switches. I drew up a blank truth table and filled out the first row, to show which switches were on or off for the '0' digit.

She got it immediately and set about filling out a lot more of it. She soon optimized filling out the truth table by doing a single segment at a time across all numbers (rather than getting a single digit done at a time). i.e. she would fill in one column at a time instead of one row at a time. I found that a surprising optimization, and it was definitely a faster way to do it.

I described a bit about how you could make a circuit that does this. (She's made simple analog circuits with roominate and snap circuits). I talked about the use of a decoder and an oscillator; I doubt she absorbed much of that... digital circuit design can wait, this was more of a way to spark her own thinking.

Later that day I asked the kids what their favorite part of the day was. My youngest replied that her favorite was the bit where we drew the 7 segment displays. I was happily surprised so set about writing this "bragpost". I think it means this is an activity that kids might enjoy more than you'd initially expect.


Navigating at the command line

stupid ideas slackathon logo

People say "real life" is the thing, but I prefer the command line. I live there all day.

One thing I recommend for your powershell profile, is this little piece of ascii art:

function ..() { cd ..}
function ...() { cd ..\..}
function ....() { cd ..\..\..}
function .....() { cd ..\..\..\..}
function ......() { cd ..\..\..\..\..}
function .......() { cd ..\..\..\..\..\..}
function ........() { cd ..\..\..\..\..\..\..}
function .........() { cd ..\..\..\..\..\..\..\..}
function ..........() { cd ..\..\..\..\..\..\..\..\..}
function ...........() { cd ..\..\..\..\..\..\..\..\..\..}
function ............() { cd ..\..\..\..\..\..\..\..\..\..\..}

It's super helpful when you're navigating around.

If you want to move "up" by 3 folders, you just type "...."

In bash you can put an equivalent thing in your profile.

alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ......='cd ../../../../..'
alias .......='cd ../../../../../..'
alias ........='cd ../../../../../../..'
alias .........='cd ../../../../../../../..'

For bonus points, don't use cd -- use pushd instead (it works in bash, powershell, even DOS) -- and it means you can return to a previous location with popd.


The value of realistic goals (with data)

(I guess I'm one of those productivity gurus now.... sorry)

I accidentally created some data that seems to have broad implications:


If you set your goals even a little bit too high, then your performance will be considerably worse.


I've started using my iPhone to track how many steps I do each day.

When I first started tracking my steps, I set the goal at 10,000 steps per day (10K) because that's what I'd heard was good. I'd make it most days but fail on other days. Sometimes I'd smash way past 10k, then crash really low for a day or two. In 3 weeks, I missed my goal on about a quarter of days. It felt quite frustrating.

I took a step back (pun intended) and decided to lower my goal to just 8,000 steps per day (8K). This was still a big increase from the low activity levels I'd exhibited before tracking my steps. (Working from home: hard to keep active!)

steps streak

With this lower goal of 8K per day, I've now managed to achieve my goal every day for 42 days, also maintained a much higher weekly average than I had during the 10k days, and I feel a lot better about it. I might increase the goal soon but would only increase it to 8,500. If I manage that consistently I'll bump it up again: but the increases will be slow and steady and always achievable.


How to get in the zone

Be very careful with this knowledge. Use it sparingly.

Yesterday I had a mountain of work in front of me. It was 3 pm and I knew I would be working until at least 7 pm.

I took a deep breath and reached for a Spotify playlist called 'Deep Focus'.

I took one large slug from my coffee cup, pressed play on Spotify, and turned toward my work.

It was as if someone had pressed the turbo button on my mind.


Within moments the hyperdrive was fully engaged.


I sped through the galaxy at beyond light speed.

2001 odyssey zing

All knowledge and facts and wisdom of the ages were immediately available for use by my expanded neural membranes.

leon thinking

A bubbling fractal panorama of tasks roiled up in front of me and was completed and delivered as quickly as it emerged.

trippy landscape

I was a digital demigod surveying the writhing landscape of technical problems, assisting the lightning arcs of insight to cut down from the bubbling clouds of possibility and materialize into the dazzling particles of fully realized innovation.

There was no yak whose hirsuit locks could challenge the sharpened razor of my wizened scalpel.

Less than an hour later I pressed commit on the last of these tasks.

I looked down to find my coffee was cold, completely untouched.

There was no more work to be done. I basked for a moment in the featureless landscape of a world with no remaining tasks. It was warm and dark and devoid of form. I felt at peace and at one with the flowing energy of the universe.

What I'm saying is that the Spotify 'Deep Focus' playlist is OK.

This morning I listened to the playlist once more. It sounded trite and useless. The magic was gone. I'd become immune to the effects, I'd grown tolerant to the active ingredient. I'd need to up the dose if I wanted the same high.

Now I'm on the prowl for playlists that bring a deeper and deeper sense of focus. Will I ever get back into that zone? Send playlists.


Publishing on Amazon: Lakes Creek Adventures

I turned my Dad's handwritten memoirs into an actual paperback book, available from Amazon (and on Kindle) under the title "Lakes Creek Adventures".

Cover of Lakes Creek Adventures

See 'Lakes Creek Adventures' (at Amazon)

And you can do the same. Need advice or assistance? Ask me anything in the comments or by email to leonbambrick at gmail. (Seriously, you're welcome.)

The book covers just the years of World War II wherein my Dad, a sandy-haired kid aged 6-12, was raised in a pub (a hotel, a drinking establishment) in Rockhampton (Queensland, Australia) in a large family. During the last half of the war, Rockhampton expected to be attacked by Japanese bombs at any moment. The population of Rockhampton was doubled with an influx of 42,000 American soldiers. It was a surreal time to grow up, and full of adventures.

corrugated iron canoe sm

Making the book 'print ready' was an educational exercise. After a bit of research, I decided to use CreateSpace (an Amazon company) and mostly followed this guide: A Step-by-Step Guide to Book Publishing with Createspace. I've had published authors look at the product and be surprised at the level of professionalism. It could be better, but it's far from terrible and my dad was very happy with the result.

If you get the chance to do the same, I heartily recommend it.


Using Computers to Invent New and *Fun* European Style Board Games

I've been playing board games with some of my nerd buddies lately, and, as always happens when I partake of cultural activities, the creative impulse is fired up and I start thinking (mono-maniacally) about how to make my own.

As I see it, there are 3 major design aspects for these games:

  1. Theme
  2. Mechanics and
  3. Art work.

Theme and art work can be evaluated using your own sense of taste.

But mechanics can only be evaluated by "play testing". And this is the major limiting factor for a solo designer; even for a team of people this a very resource intensive problem.

So my mind then turns to genetic algorithms (GA)... how can I build a system that represents the rules of a game in such a way that they can be evolved? And in particular: how can the effectiveness of a set of rules be evaluated?

There's two tricky aspects here:

First you'd need to build a general game playing engine that can play the game against itself.

Second, you'd need it to provide information about how "fun" a given rule-set is to play. This sense of "fun" is the crucial thing that needs to be defined.

But on that first problem for a moment: a general game playing engine. My research led me to find that there are "general game playing" engines out there. And the academic term for them is (drum roll) "general game playing engines". One example is Zillions of Games("ZOG") which encodes rules as S-expressions. (Old timers: yes lisp of course; newbs: like JSON.) ZOG includes a 'self-play' mode in which it plays the games against itself. I don't know how good it is at the games.

However ZOG is not capable of representing the kind of games I want to evolve.

Background reading:

I read this short paper: Automatic Design of Balanced Board Games (pdf)

This was an interesting and very straight forward read.

They used ZOG and a GA to explore rule variations in 2 player board games (such as checkers, reversi, connect 4) to evolve rule systems.

They had a very limited sense of "fun" Comprised of just two things:

  1. Don't confer an advantage or disadvantage to the first player (they call this "balance" -- though game designers use the word balance for a lot of other concepts too)
  2. Avoid games ending in a draw.

Representing any type of game.

In my theoretical system you'd need to be able to represent all sorts of games that combine cards, boards, pieces, trading, information hiding, and so forth.

It might be worth describing first a single "über" game that demonstrates all possible elements.

Here's a partial example.

(Numbers like X6 are numeric variables which would be set in the rules. Most such variables would be equal to zero.)

Start of game

  • Each player is given X1 "Action" cards and X2 "currency1" cards and X3 currency2 cards and x4 "currency3" cards (and so on for N1 types of currency).
  • They are also given X5 Power cards, and X6 cards from a shuffled deck of all card types. They hold these cards where other players can't see them.
  • They are also given X7 cards, face down which they cannot see.
  • And X8 cards which are placed facing out in front of each player, such that they cannot see them but every other player can. They also have X9 cards face up in front of them.

The layout and setup of the board(s) would need to be described in a similarly generic way.

A turn might be described something like this:

  • Player may roll a dice, result d1.
  • Player may roll a dice, result d2.
  • Player may flip a coin: c1.
  • Player discards n2 cards from their hand, turns over n3 cards, picks up n4 cards and discards d1 cards from their hand and picks up d2 cards.
  • Player may choose to play A1 action cards. Or they may allowed to buy the right to play up to A2 action cards. They may...


A possible "building" phase and a "trading" phase would be included as well, including moving pieces on a board, and trying to guess some series of facts.

Game ends when any player fully understands the rules. Ha ha.

Let's say we succeeded at building out a complete über game in that manner. It would be trivial to represent in a GA and easy to combine/mutate. The challenge would then be how to evaluate the "fun" that each player has.

My idea of fun

It's generally fair to say that the first player shouldn't be more or less likely to win than any other player. And games resulting in a draw are not satisfying. So we'd need to inherit those two rules.

But there's a lot more to it as well.

The sense of fun that you're targeting will be different at different times. You might want a game that is quick to play or long to play. You might enjoy learning a few complex rules, or a lot of complex rules. You might like games where the optimal strategy to employ changes throughout the game. You might like it if there is a constant change of who is in front (unlike, say, monopoly, where one person gets in front and then slowly destroys their competitors over a long period of time). You might be able to evolve games where being in front is a disadvantage until the end: or you might hate that.

It's crucial that every part of the mechanics has an influence on winning/losing. You shouldn't need to hold more than a few things in your short term memory. Card counting probably shouldn't be rewarded.

You might like games that involve double-crossing. You might hate such games. You might like games that reward skill, or that have a certain mix of skill and luck.

You may need to try encoding other succesful games and see if you can find a way to measure the types of fun that they involve.

Anyway -- it sounds like a big task. I wish you luck. I think I'll get on with doing other things.

Something easier

Anyway, while researching this I was at Board Game Geek, and under the "Board Game Design" part of their forums I noticed a Seeking Play Testers forum.

This gave me an idea for a film or series of films, or a sitcom:

A frustrated boardgame designer abducts a group of nerds, and keeps them in an underground lair, where he forces them to playtest his hundreds of wacky game ideas.

It would be a comedy but would also be spooky creepy scary fun and drama too. I picture the nerds as being a kind of Buffy Gang, though maybe with a bit of an IT Crowd tilt.

I think this could be an awesome sitcom. I'd definitely watch it. So instead of making that complex game evaluation engine, why don't you bash out a few episodes for "Games Underground."

Email me the royalty checks when you're done. Cheers.

External Links


Dadding 101: Give Your Kids A Trail of Codes To Break

This is one of those classic parental games that's fun and educational.

My youngest kidlet was home sick last week, and she happened to find a strange note that was composed of just numbers.

Where did this note come from? What did it mean? It was most puzzling.

She's only just learning to read, and getting her to do her reading writing tasks is pretty challenging. But she's read enough Billie B Brown Secret Mystery Club books to know that a note composed of just numbers is always the start of an exciting adventure.

She went with the assumption that "A=1", drew up a translation chart, and she was away!

IMG 2489 th.jpg

IMG 2490 th.jpg

When decoded the message told her to look on the printer. When she went to the printer there was a fresh note that required decoding. That one led her to under the stairs.

And so on, all day long, she chased a linked-list of notes, and practiced de-referencing a pointer, like a good little program.

The final clue told her to ask her mother for the next clue. Mum produced a clue, which when decoded, said "It's ice-cream time!" and everyone was happy with that. I was particularly pleased because I had no idea of how it should end, and sent it to mum as an easy exit.

All up, I strongly recommend trying this kind of puzzle on your own kids, or any kids you find in the neighborhood.

The simple "A=1" puzzle was good for a 6 year old, but you can progress to harder encryption techniques for older and more wizened children, or have the puzzles increase in difficulty as they go. My eldest would've lost interest if she'd been given the same material.

A good "next step" would be a Caesar Cipher, where the "shift" amount is provided. A good step up from that is a Caesar Cipher where the shift amount is not given. That leads into the topic of frequency analysis (though other approaches will work fine too). A nice code to demonstrate is the 'pigpen cipher' (also known as the Freemason cipher), particularly because of it's cool alien-looking characters.

My good buddy and aussie-bush-walker Dr Richard Mason says the EJ12 series of books have some great codes and puzzles aimed at kids (girls in particular). The "39 Clues" is another series I've heard of but haven't seen.

Have you ever tried getting kids into code-making or code-breaking? What happened?