<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Ollie Cullimore's Blog</title>
  <subtitle>A technical blog of topics that have interested me</subtitle>
  <link href="/feed.xml" rel="self"/>
  <link href="https://olivercullimore.co.uk"/>
  <updated>2024-05-25T00:00:00Z</updated>
  <id>https://olivercullimore.co.uk</id>
  <author>
    <name>Ollie Cullimore</name>
  </author>
  
  <entry>
    <title>Adding a dark mode toggle</title>
    <link href="https://olivercullimore.co.uk/posts/2024/05/adding-a-dark-mode-toggle/"/>
    <updated>2024-05-25T00:00:00Z</updated>
    <id>https://olivercullimore.co.uk/posts/2024/05/adding-a-dark-mode-toggle/</id>
    <content type="html">&lt;h2&gt;The Challenge&lt;/h2&gt;
&lt;p&gt;I decided to add a dark mode toggle to my site which persists between pages and uses the browser’s default setting; all without adding external dependencies.&lt;/p&gt;
&lt;h2&gt;The Solution&lt;/h2&gt;
&lt;p&gt;I settled on using JavaScript to detect the browser’s default settings, toggle between the modes and persist it between pages using local storage. I then utilised CSS variables to define dark mode as the default and light mode to override the variables.&lt;/p&gt;
&lt;p&gt;The code for all this can be found in the CodePen below:&lt;/p&gt;
&lt;figure&gt;&lt;iframe src=&quot;https://codepen.io/olivercullimore/embed/xxNEXRa?default-tab=html%2Cresult&quot; width=&quot;1200&quot; height=&quot;600&quot;&gt;&lt;/iframe&gt;&lt;figcaption&gt;&lt;/figcaption&gt;&lt;/figure&gt;
</content>
  </entry>
  
  <entry>
    <title>Integrating with a Legacy System: Microsoft Visual FoxPro Databases</title>
    <link href="https://olivercullimore.co.uk/posts/2024/05/integrating-with-a-legacy-system-microsoft-visual-foxpro-databases/"/>
    <updated>2024-05-12T00:00:00Z</updated>
    <id>https://olivercullimore.co.uk/posts/2024/05/integrating-with-a-legacy-system-microsoft-visual-foxpro-databases/</id>
    <content type="html">&lt;h2&gt;The Challenge&lt;/h2&gt;
&lt;p&gt;In a recent side-project, I was tasked with establishing a connection to a legacy system utilizing a Microsoft Visual FoxPro database. The goal was to create a read-only method to extract data from this system into a new one.&lt;/p&gt;
&lt;p&gt;The project was developed in Go, so my initial step was to find a suitable Go package. My search led me to &lt;a href=&quot;https://github.com/Valentin-Kaiser/go-dbase&quot;&gt;go-dbase&lt;/a&gt;, which seemed to fit the bill perfectly.&lt;/p&gt;
&lt;p&gt;However, upon testing the package, I encountered an unexpected hurdle. The package was throwing errors when attempting to gain read &amp;amp; write access to the database files. This was a problem because the project requirements specified that the access should be read-only, and the project’s environment only had read-only access to the database files.&lt;/p&gt;
&lt;h2&gt;The Solution&lt;/h2&gt;
&lt;p&gt;Given that the project’s requirement was solely to retrieve data from the database, read-only access to the files should have been sufficient. This led me to delve into the package code to identify where write access was being requested - one of the many benefits of open-source software. I quickly found the answer and implemented a read-only mode for further testing. After successful testing, I submitted &lt;a href=&quot;https://github.com/Valentin-Kaiser/go-dbase/pull/62&quot;&gt;Pull Request #62&lt;/a&gt; to the original project, hoping it might be useful to others.&lt;/p&gt;
&lt;h2&gt;The Code&lt;/h2&gt;
&lt;p&gt;If you’re facing a similar challenge, the following code demonstrates how to use the new read-only mode to read a database:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-go&quot;&gt;package main

import (
    &amp;quot;encoding/json&amp;quot;
    &amp;quot;fmt&amp;quot;
    &amp;quot;github.com/Valentin-Kaiser/go-dbase/dbase&amp;quot;
)

func main() {
    // Open the database
    db, err := dbase.OpenDatabase(&amp;amp;dbase.Config{
        Filename:                          &amp;quot;./PATHTODATABASE/EXAMPLEDATABASE.DBC&amp;quot;,
        TrimSpaces:                        true,
        ReadOnly:                          true,
        DisableConvertFilenameUnderscores: true,
    })
    if err != nil {
        panic(err)
    }
    // Defer the close and handle any errors
    defer func() {
        if cerr := db.Close(); err == nil {
            err = cerr
        }
    }()
    if err != nil {
        panic(err)
    }

    // Output tables info
    fmt.Printf(&amp;quot;Tables:&#92;n%v&#92;n&#92;n&amp;quot;, db.Names())

    // Get a specific table
    tables := db.Tables()
    table := tables[&amp;quot;EXAMPLETABLE&amp;quot;]

    // Output table info
    fmt.Printf(
        &amp;quot;Table info:&#92;nName: %s Last modified: %v Column count: %v Record count: %v File size: %v&#92;n&#92;n&amp;quot;,
        table.TableName(),
        table.Header().Modified(0),
        table.Header().ColumnsCount(),
        table.Header().RecordsCount(),
        table.Header().FileSize(),
    )

    // Output table column info
    fmt.Println(&amp;quot;Table columns:&amp;quot;)
    for _, column := range table.Columns() {
        fmt.Printf(&amp;quot;Name: %v - Type: %v&#92;n&amp;quot;, column.Name(), column.Type())
    }

    // Get table rows
    fmt.Println(&amp;quot;&#92;nTable rows:&amp;quot;)
    rows, err := table.Rows(true, true)
    if err != nil {
        panic(err)
    }
    for _, row := range rows {
        // Skip deleted rows
        if row.Deleted {
            continue
        }

        // Convert row to a map
        rowMap, err := row.ToMap()
        if err != nil {
            panic(err)
        }

        // Output row map
        s, _ := json.MarshalIndent(rowMap, &amp;quot;&amp;quot;, &amp;quot;  &amp;quot;)
        fmt.Printf(&amp;quot;Row: %s&#92;n&#92;n&amp;quot;, s)
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/Valentin-Kaiser/go-dbase&quot;&gt;https://github.com/Valentin-Kaiser/go-dbase&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>How to adopt a UniFi access point with a remote controller</title>
    <link href="https://olivercullimore.co.uk/posts/2024/05/how-to-adopt-a-unifi-access-point-with-a-remote-controller/"/>
    <updated>2024-05-05T00:00:00Z</updated>
    <id>https://olivercullimore.co.uk/posts/2024/05/how-to-adopt-a-unifi-access-point-with-a-remote-controller/</id>
    <content type="html">&lt;h2&gt;The Challenge&lt;/h2&gt;
&lt;p&gt;I was recently asked how you can adopt a UniFi access point onto a UniFi controller that is located on a different network. Here’s a step-by-step guide on how to achieve this.&lt;/p&gt;
&lt;h2&gt;Prerequisites&lt;/h2&gt;
&lt;p&gt;Before proceeding, ensure the following are in place first:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A UniFi access point ready for deployment&lt;/li&gt;
&lt;li&gt;A UniFi controller with a public domain or static IP, port 8080 port-forwarded, and the “Inform Host” setting correctly configured&lt;/li&gt;
&lt;li&gt;A device connected to the same network as the access point&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Step 1 - Acquire the Necessary Tool&lt;/h2&gt;
&lt;p&gt;Begin by downloading and installing the &lt;a href=&quot;https://www.hostifi.com/hostifi-device-discovery-tool&quot;&gt;HostiFi Device Discovery Tool&lt;/a&gt; for your device.&lt;/p&gt;
&lt;h2&gt;Step 2 - Configure the Tool&lt;/h2&gt;
&lt;p&gt;Launch the HostiFi Device Discovery Tool and navigate to the settings via the cog icon.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://olivercullimore.co.uk/images/posts/50241f6c-hostifi-device-discovery-tool.png&quot; alt=&quot;HostiFi Device Discovery Tool&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Input your controller’s public inform URL into the Default inform URL field and save your changes followed by closing the pop-up at the top-right.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://olivercullimore.co.uk/images/posts/50241f6c-hostifi-device-discovery-tool-settings.png&quot; alt=&quot;HostiFi Device Discovery Tool settings&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;Step 3 - Device Adoption&lt;/h2&gt;
&lt;p&gt;Power on the UniFi access point and use the “Scan” function of the tool to detect it.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://olivercullimore.co.uk/images/posts/50241f6c-hostifi-device-discovery-tool-scan-list.png&quot; alt=&quot;HostiFi Device Discovery Tool scan list&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Once identified, click “Adopt” next to it, then re-verify the Inform URL is correct and click “Adopt”.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://olivercullimore.co.uk/images/posts/50241f6c-hostifi-device-discovery-tool-adopt-inform-url.png&quot; alt=&quot;HostiFi Device Discovery Tool adopt inform URL&quot; /&gt;&lt;/p&gt;
&lt;p&gt;A confirmation message will then be displayed.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://olivercullimore.co.uk/images/posts/50241f6c-hostifi-device-discovery-tool-adoption-results.png&quot; alt=&quot;HostiFi Device Discovery Tool adoption results&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The device will now appear in the controller’s device tab for you to proceed with its setup.&lt;/p&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://www.hostifi.com/blog/introducing-the-hostifi-discovery-tool&quot;&gt;https://www.hostifi.com/blog/introducing-the-hostifi-discovery-tool&lt;/a&gt;&lt;/p&gt;
</content>
  </entry>
</feed>