Jekyll2025-07-10T03:41:30+00:00https://twlee.nz/feed.xmltwlee.nzLittle snippets of this and thatOnline again; now locally built2025-07-10T02:19:59+00:002025-07-10T02:19:59+00:00https://twlee.nz/local-render<p>After being down for some time due to an issue with the hosting provider, this twlee.nz is online again. This static site is now locally built rather than relying on an cloud-based build step. One extra step to do but it provides more control over builds and deployment.</p> <p>Some longer term goals:</p> <ul> <li>Convert from Jekyll to Hugo: Jekyll is more of a pain to install than Hugo, so I’m planning to migrate to Hugo to build the static site.</li> <li>Move TrackScribe away from Google Maps to be an OSM-based mapping app.</li> <li>See if I can provide a web-based version of <em>Rātā me te rākau</em> to make it more accessible.</li> </ul>After being down for some time due to an issue with the hosting provider, this twlee.nz is online again. This static site is now locally built rather than relying on an cloud-based build step. One extra step to do but it provides more control over builds and deployment.Converted to Jekyll2021-09-29T08:17:32+00:002021-09-29T08:17:32+00:00https://twlee.nz/welcome-to-jekyll<p>My website has now been converted to Jekyll. A few notes for myself:</p> <p>You’ll find this post in your <code class="language-plaintext highlighter-rouge">_posts</code> directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run <code class="language-plaintext highlighter-rouge">jekyll serve</code>, which launches a web server and auto-regenerates your site when a file is updated.</p> <p>Jekyll requires blog post files to be named according to the following format:</p> <p><code class="language-plaintext highlighter-rouge">YEAR-MONTH-DAY-title.MARKUP</code></p> <p>Where <code class="language-plaintext highlighter-rouge">YEAR</code> is a four-digit number, <code class="language-plaintext highlighter-rouge">MONTH</code> and <code class="language-plaintext highlighter-rouge">DAY</code> are both two-digit numbers, and <code class="language-plaintext highlighter-rouge">MARKUP</code> is the file extension representing the format used in the file. After that, include the necessary front matter. Take a look at the source for this post to get an idea about how it works.</p> <p>Jekyll also offers powerful support for code snippets:</p> <figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="k">def</span> <span class="nf">print_hi</span><span class="p">(</span><span class="nb">name</span><span class="p">)</span> <span class="nb">puts</span> <span class="s2">"Hi, </span><span class="si">#{</span><span class="nb">name</span><span class="si">}</span><span class="s2">"</span> <span class="k">end</span> <span class="n">print_hi</span><span class="p">(</span><span class="s1">'Tom'</span><span class="p">)</span> <span class="c1">#=&gt; prints 'Hi, Tom' to STDOUT.</span></code></pre></figure> <p>Check out the <a href="https://jekyllrb.com/docs/home">Jekyll docs</a> for more info on how to get the most out of Jekyll. File all bugs/feature requests at <a href="https://github.com/jekyll/jekyll">Jekyll’s GitHub repo</a>. If you have questions, you can ask them on <a href="https://talk.jekyllrb.com/">Jekyll Talk</a>.</p>My website has now been converted to Jekyll. A few notes for myself:Rātā me te rākau2020-02-05T04:39:23+00:002020-02-05T04:39:23+00:00https://twlee.nz/rata-me-te-rakau<p>I made a game for my pūrākau assignment for Te Reo Māori classes at AUT, based on the pūrākau of <em>Rātā me te rākau</em>. This was made using RPGMaker VX Ace, and should run on a Windows PC. It is available for download here: <a href="https://www.dropbox.com/s/8g12c5lnt1m982e/rata_me_te_rakau_game_v0.9.zip?dl=1">Rātā me te rākau</a></p>Tet Woo LeeI made a game for my pūrākau assignment for Te Reo Māori classes at AUT, based on the pūrākau of Rātā me te rākau. This was made using RPGMaker VX Ace, and should run on a Windows PC. It is available for download here: Rātā me te rākauGet the NT Hash of a password2019-11-24T08:55:19+00:002019-11-24T08:55:19+00:00https://twlee.nz/get-the-nt-hash-of-a-password<p>I’ve added a simple script to calculate the <a href="https://en.wikipedia.org/wiki/NT_LAN_Manager"><em>NT Hash</em></a> of a password:<br /> <a href="/get_password_nt_hash/">get_password_nt_hash</a></p>Tet Woo LeeI’ve added a simple script to calculate the NT Hash of a password: get_password_nt_hashPreventing automatic restarts in Windows 102018-09-22T14:18:54+00:002018-09-22T14:18:54+00:00https://twlee.nz/preventing-automatic-restarts-in-windows-10<p>Windows 10 annoyingly automatically restarts without warning to install updates, potentially causing you to lose work that is left open. There is no easy option to stop this, but it is possible to continuously change the active hours window for your computer so that Windows 10 can’t find an inactive window to do this restart. Changing the active hours can be done by editing the registry, at <code class="language-plaintext highlighter-rouge">HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings</code> with the <code class="language-plaintext highlighter-rouge">ActiveHoursStart</code> and <code class="language-plaintext highlighter-rouge">ActiveHoursEnd</code> keys (<code class="language-plaintext highlighter-rouge">DWORD</code> values). I’ve tested this ‘fix’ for a few months and so far it seems to work as expected, although knowing Microsoft it may stop working at some stage, or for certain updates.</p> <p>Provided here are three files to implement this scheme:</p> <ol> <li> <p><a href="https://gist.github.com/twlee79/46ec701fbddf20ce576c6ec9b31c9f48"><code class="language-plaintext highlighter-rouge">ChangeActiveHours.bat</code></a> which edits the registry to change the active hours to -1 to +9 of current time</p> </li> <li> <p><a href="https://gist.github.com/twlee79/aa164cbe8abdfe02c95f0b3df4c1ba9a"><code class="language-plaintext highlighter-rouge">ChangeActiveHours.xml</code></a> which is a Task Scheduler XML file to automatically execute the above batch file every hour in the background. This file will need to be edited with the location of <code class="language-plaintext highlighter-rouge">ChangeActiveHours.bat</code> under <code class="language-plaintext highlighter-rouge">&lt;Command&gt;</code>.</p> </li> <li> <p><a href="https://gist.github.com/twlee79/0e4b586f8df0f64c1265f13ec5bd0b4f"><code class="language-plaintext highlighter-rouge">CreateTaskChangeActiveHours.bat</code></a> which automatically adds the above XML file to the Task Scheduler. Run as follows: <code class="language-plaintext highlighter-rouge">CreateTaskChangeActiveHours.bat /ru "ComputerName\Username" /rp</code> and it will prompt you for your password.</p> </li> </ol>Tet Woo LeeWindows 10 annoyingly automatically restarts without warning to install updates, potentially causing you to lose work that is left open. There is no easy option to stop this, but it is possible to continuously change the active hours window for your computer so that Windows 10 can’t find an inactive window to do this restart. Changing the active hours can be done by editing the registry, at HKLM\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings with the ActiveHoursStart and ActiveHoursEnd keys (DWORD values). I’ve tested this ‘fix’ for a few months and so far it seems to work as expected, although knowing Microsoft it may stop working at some stage, or for certain updates.Simple local+cloud backups with Duplicacy2018-09-22T13:24:05+00:002018-09-22T13:24:05+00:00https://twlee.nz/simple-localcloud-backups-with-duplicacy<p>I’ve started using <a href="https://duplicacy.com/home.html">Duplicacy</a> to do my backups. It’s marketed as a ‘cross-platform cloud backup tool’ and I’ve been happy with it so far. I previously used <a href="https://sites.google.com/a/duplicati.com/duplicati/home">Duplicati 1</a> but found it be extremely slow preparing the list of files to back up. In comparison, Duplicacy has been fast and easy to use.</p> <p>Although I originally tried the GUI version of Duplicacy, I found the CLI to be more to my liking. The CLI version is free for personal use, but if you do find it useful, I suggest paying for a personal license to support the developer.</p> <h2 id="duplicacy-cli-quick-start">Duplicacy CLI quick start</h2> <p>Here’s a quick run down of how to get Duplicacy up and running in a few minutes using the CLI:</p> <ol> <li>Create a folder <code class="language-plaintext highlighter-rouge">.duplicacy</code> in the root of the location you wish to back up (this is called the <em>repository</em>). All files and directories to be backed up must be under this root.&lt;/p&gt;</li> <li> <p>Create a file <code class="language-plaintext highlighter-rouge">filters</code> in the <code class="language-plaintext highlighter-rouge">.duplicacy</code>. The <code class="language-plaintext highlighter-rouge">filters</code> file allows you to set up what files and directories to back up using wildcard matching. A complete description of this is in <a href="https://forum.duplicacy.com/t/filters-include-exclude-patterns/1089">Duplicacy User Guide</a>. For a Windows system, an <a href="https://gist.github.com/twlee79/af09e991b52d228005c3c1b79afbd5eb">example <code class="language-plaintext highlighter-rouge">filters</code> file is provided here</a>. This includes some directories under <code class="language-plaintext highlighter-rouge">users/John Doe</code>, excludes an <code class="language-plaintext highlighter-rouge">unwanted_directory/</code>, includes <code class="language-plaintext highlighter-rouge">please_back_up_another_wanted_directory/</code> under the root, but excludes all other directories under the root by default, as well as unwanted Windows <code class="language-plaintext highlighter-rouge">Thumbs.db</code>, <code class="language-plaintext highlighter-rouge">desktop.ini</code>, <code class="language-plaintext highlighter-rouge">~*</code>, shortcuts, and directories marked with <code class="language-plaintext highlighter-rouge">_del*</code>.</p> </li> <li>Initialise the repository for backup by setting the default storage location for the backup by running:</li> </ol> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>`cd root_folder` `duplicacy init &lt;snapshot id e.g. COMPUTER1-user-C&gt; &lt;backup storage location e.g. \\network\folder&gt; -e` This command will create storage named `default` for this repository. The `-e` option enables encryption. Duplicacy will ask for the encryption password when you execute the command. </code></pre></div></div> <ol> <li>Do a dry run to check everything is set up correctly:</li> </ol> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>`duplicacy backup -dry-run -stats` </code></pre></div></div> <ol> <li>Modify any settings (e.g. the <code class="language-plaintext highlighter-rouge">filters</code> file) as needed, and when ready run the backup proper:</li> </ol> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>`duplicacy backup` </code></pre></div></div> <ol> <li>Obviously, the above command can be run whenever you want to do a backup.</li> </ol> <h2 id="multiple-storage-locations-using-the-copy-command">Multiple storage locations using the <code class="language-plaintext highlighter-rouge">copy</code> command</h2> <p>A useful feature of Duplicacy is you can add multiple storage locations for each backup repository. You can then use the <code class="language-plaintext highlighter-rouge">copy</code> command to copy the backup from one storage to another. In addition, the <code class="language-plaintext highlighter-rouge">copy</code> command can be run from a different computer than the one containing the initial repository. Therefore, it is possible to have a repository on <em>Laptop1</em> that is backed up to a (local) network storage location (e.g. shared directory) on <em>Desktop1</em>. On <em>Desktop1</em>, you can add an additional cloud storage location for that backup and run <code class="language-plaintext highlighter-rouge">copy</code> to copy the back up to the cloud, ensuring that you have two copies of the backup in different locations, and with the copying running in the background on a computer with a more reliable network connection.</p> <p>To set up the above scenario, follow these steps:</p> <ol> <li>On the computer that is doing the copy, run: <code class="language-plaintext highlighter-rouge">cd backup_storage_location_root</code> (e.g. <code class="language-plaintext highlighter-rouge">/backups/duplicacy</code>)</li> </ol> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>`duplicacy init &lt;snapshot id e.g. COMPUTER1-user-C&gt; &lt;backup storage location e.g. /backups/duplicacy/computer1&gt; -storage-name &lt;name e.g. default_computer1&gt; -e` This initialises a repository with storage of the provided name at the specified location. (If `-storage-name` isn&amp;#8217;t used, the name `default` will be used, but I suggest a more descriptive name in the case where you want to use the same root directory to store multiple backups). If you have already run `init` for a different backup here, you can instead add the storage as follows: `duplicacy add &lt;name e.g. default_computer2&gt; &lt;snapshot id e.g. COMPUTER2-user-C&gt; &lt;backup storage location e.g. /backups/duplicacy/computer2&gt; -e` </code></pre></div></div> <ol> <li>Add a cloud storage location:</li> </ol> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>`duplicacy add &lt;name e.g. GoogleDrive_myaccount_computer1&gt; &lt;snapshot id e.g. COMPUTER1-user-C&gt; &lt;backup storage location e.g. "gcd://duplicacy/computer" -copy &lt;original storage name e.g. default_computer1&gt; -e` This adds a new storage location; the `-copy` commands ensures that is compatible with the original storage. </code></pre></div></div> <ol> <li>Do the copy:</li> </ol> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>`duplicacy copy -from &lt;original storage name e.g. default_computer1&gt; -to &lt;new storage name e.g. GoogleDrive_myaccount_computer1&gt;` </code></pre></div></div> <ol> <li>Obviously, you will need to recopy whenever you do a new backup to the local folder.</li> </ol> <p>Note: For Windows users, the <code class="language-plaintext highlighter-rouge">doskey</code> command can be used to make an alias for Duplicacy:</p> <p><code class="language-plaintext highlighter-rouge">doskey duplicacy="path\to\duplicacy_win_x64_2.1.1.exe" $*</code></p>Tet Woo LeeI’ve started using Duplicacy to do my backups. It’s marketed as a ‘cross-platform cloud backup tool’ and I’ve been happy with it so far. I previously used Duplicati 1 but found it be extremely slow preparing the list of files to back up. In comparison, Duplicacy has been fast and easy to use.Changing an exFAT volume serial number2018-05-18T13:59:33+00:002018-05-18T13:59:33+00:00https://twlee.nz/changing-exfat-volume-serial-number<p>Reformatted an SD card and want it to be recognised as the same SD card by your Android Phone? Or want to change your volume serial number for some other reason? You need to record the original volume serial number and replace the new one with this number after formatting. Here’s how to do that for an exFAT volume.</p> <p>Changing an exFAT volume serial number is relatively trivial with a disk editor. All you need to do is change the serial number at offset <code class="language-plaintext highlighter-rouge">0x64</code> of the boot sector (the boot sector is the first sector of the volume, has “<code class="language-plaintext highlighter-rouge">EXFAT&gt;</code>” at offset <code class="language-plaintext highlighter-rouge">0x03</code>, and you should recognise the serial number at <code class="language-plaintext highlighter-rouge">0x64</code>).</p> <p>The only tricky part is you need to re-calculate and update the boot sector checksum (sector 11 of the volume contains a repeated checksum of sectors 0‒10, which is calculated by summing shuffled bits, excluding a few variable bytes of the boot sector).</p> <p>To help with this, I’ve made a simple Python script to help calculate the checksum: <a href="https://gist.github.com/twlee79/81f1b8f62246952c2efaaf5935058ce6"><code class="language-plaintext highlighter-rouge">exfat_bootsector_checksum.py</code> </a></p> <p>Further instructions are in the script description.</p>Tet Woo LeeReformatted an SD card and want it to be recognised as the same SD card by your Android Phone? Or want to change your volume serial number for some other reason? You need to record the original volume serial number and replace the new one with this number after formatting. Here’s how to do that for an exFAT volume.TrackScribe: A run/cycle/walk route planner for New Zealand2017-04-18T01:51:04+00:002017-04-18T01:51:04+00:00https://twlee.nz/trackscribe-nz-route-planner<p><a href="/content/2017/TrackScribe_promo3.png"><img loading="lazy" class="alignnone size-full wp-image-58" src="/content/2017/TrackScribe_promo3.png" alt="TrackScribe., an NZ run/cycle/walk route planner" width="1203" height="638" srcset="/content/2017/TrackScribe_promo3.png 1203w, /content/2017/TrackScribe_promo3-300x159.png 300w, /content/2017/TrackScribe_promo3-768x407.png 768w, /content/2017/TrackScribe_promo3-1024x543.png 1024w" sizes="(max-width: 1203px) 100vw, 1203px" /></a>I’ve deployed the first public version of <a href="/trackscribe">TrackScribe</a> on this website. This is a run, cycle or walk route planner that sources elevation data from the NZTopo database.</p> <!--more--> <p>TrackScribe is a <a href="https://developers.google.com/maps/">Google Maps API</a>-based front-end that allows running, cycling etc. tracks to be planned by manual point placement and <a href="https://developers.google.com/maps/documentation/directions/">Directions API</a> auto-routing. Tracks can be loaded and saved to a simple csv format.</p> <p>A unique feature of this webapp is that it interfaces with my own <a href="https://nz-twlee-demlookup.appspot.com">NZLookDEMUp</a> <a href="https://cloud.google.com/appengine/">Google AppEngine</a>-based backend that looks up New Zealand elevation data from <a href="http://www.otago.ac.nz/surveying/research/geospatial/otago040574.html">NZSoSDEM v1</a>. This is a digital elevation model (DEM) created by the School of Surveying at the University of Otago that covers the whole of New Zealand at a spatial resolution of 15m and generated by fractal interpolation of LINZ topographic data from the NZTopo database. This should given path elevation data that is ‘as good as’ the NZTopo map series. Elevation look ups outside of New Zealand are not supported.</p> <p>The version has had limited testing and may be buggy! It was created mainly for my own enjoyment, but hopefully the interface is straightforward enough for others to use. Note that elevation is not looked up until you click the “Lookup height” tool twice. This to prevent my backend being overloaded.</p> <p>The GPL-licensed source code for the <a href="https://github.com/twlee79/trackscribe">TrackScribe</a> webapp and the <a href="https://github.com/twlee79/nzlookdemup">NZLookDEMUp</a> back-end are available on my <a href="https://github.com/twlee79/">GitHub</a> page.</p>Tet Woo LeeI’ve deployed the first public version of TrackScribe on this website. This is a run, cycle or walk route planner that sources elevation data from the NZTopo database.CopyPMID Chrome extension2016-05-17T12:01:25+00:002016-05-17T12:01:25+00:00https://twlee.nz/copypmid-chrome-extension<p><a href="/content/2016/CopyPMID-Promotional-image.png"><img loading="lazy" class="alignnone wp-image-27 size-medium" src="/content/2016/CopyPMID-Promotional-image-300x191.png" alt="CopyPMID Promotional image" width="300" height="191" srcset="/content/2016/CopyPMID-Promotional-image-300x191.png 300w, /content/2016/CopyPMID-Promotional-image.png 440w" sizes="(max-width: 300px) 100vw, 300px" /></a></p> <p>I’ve published my <a href="https://chrome.google.com/webstore/detail/copypmid/cjncnimjejonnepbihgjefeekaphhjll"><em>CopyPMID</em></a> Chrome extension in the Chrome web store. It’s one of the most boring extensions in the world, as all it does is add a button to <a href="http://www.ncbi.nlm.nih.gov/pubmed">PubMed</a> pages to allow quick copying of the PubMed ID to the clipboard, but I needed to publish it on the web store so I could use it myself! I use it quickly import PubMed references into <a href="http://www.jabref.org/">JabRef</a> by PMID. The source code is also available on <a href="https://github.com/twlee79/CopyPMID">my GitHub page</a>.</p>Tet Woo LeeMy GitHub page and profscore2016-02-08T10:30:09+00:002016-02-08T10:30:09+00:00https://twlee.nz/my-github-page-and-profscore<p>I’ve added a link to my <a href="https://github.com/twlee79">GitHub</a> page to the sidebar. At the moment, the only project available there is <a href="https://github.com/twlee79/profscore">ProfScore</a>, the p<span class="repository-meta-content">rofile-based conservation score for biopython published in the <em><a href="http://onlinelibrary.wiley.com/doi/10.1002/prot.24711/abstract">Proteins: Structure, Function and Bioinformatics</a></em> (<a href="http://dx.doi.org/10.1002/prot.24711">doi: 10.1002/prot.24711</a>).</span></p>Tet Woo LeeI’ve added a link to my GitHub page to the sidebar. At the moment, the only project available there is ProfScore, the profile-based conservation score for biopython published in the Proteins: Structure, Function and Bioinformatics (doi: 10.1002/prot.24711).