haykot.dev
  • Blog

  • Golang
    · March 28, 2023

    TIL Creating Transient Databases For Testing

    This post explores an approach to unit testing database-dependent code by implementing a single backing Postgres instance and a disposable database for each test case.

    2 Minute Read

  • Python
    · March 5, 2023

    TIL How to Reset Python Environment

    Here’s a short script to reset your python environment to a clean state.

    1 Minute Read

  • Golang , Homebox
    · November 13, 2022

    TIL Using Custom Marshaling in Go

    A quick look at how to use custom marshaling in Go and why you might want to.

    2 Minute Read

  • Python
    · July 30, 2022

    TIL: Stopping Requests Mid Flight

    Today I learned how you stop a request mid flight with the python requests library

    1 Minute Read

  • Programming , Golang
    · February 2, 2022

    TIL: Testing Parametrized URLs with Chi Router

    Today I learned that it’s possible to slightly decouple your http handler tests from your chi router. Well sort of…

    1 Minute Read

  • · August 5, 2021

    TIL Converting Visio to PDFs Recursively

    Today I learned that you can use powershell on windows to recursively convert visio files to PDF files. I’ve found that when working with design drawings that packaging up a directory of visio files into PDFs is time consuming as most converters don’t support Visio formats. Powershell on the other hand can interface directly with the Visio ComObject and do the conversion natively on windows.

    $drawings = Get-ChildItem -Recurse -Filter "*.vsdx" # Remove Recurse if you don't want to go into nested directories
    $drawings += Get-ChildItem -Recurse -Filter "*.vsd"
    Write-Host "Converting Visio documents to PDF..." -ForegroundColor Cyan
    
    try
    {
        $visio = New-Object -ComObject Visio.Application
        $visio.Visible = $true # If you want to disable the Visio window you can set this to $false
    
    
        $i = 0
        foreach ($drawing in $drawings)
        {
            $pdfname = [IO.Path]::ChangeExtension($drawing.FullName, '.pdf')
            Write-Host "Converting:" $drawing.FullName "to" $pdfname
            $document = $visio.Documents.Open($drawing.FullName)
            # Export all pages to PDF, see constants here http://msdn.microsoft.com/en-us/library/office/ff766893.aspx
            $document.ExportAsFixedFormat(1, $pdfname, 1, 0)
            $document.Saved = $true
            $document.Close()
        }
    
    }
    
    catch
    {
        Write-Error $_
    }
    
    finally
    {
        if ($visio)
        {
            $visio.Quit()
        }
    
    }
    

    1 Minute Read

  • DevOps
    · August 5, 2021

    TIL Securing Your Ansible Vault

    When setting up your Ansible playbooks you can include this script in the top directory and run it from the terminal to add this pre-commit hook. This will check to see if your vault is encrypted before committing to source control. Make sure you set the correct path for your vault!

    1 Minute Read

hayden's headshot

hayden@haybytes.com

Stay in Touch


Hayden's Blog List

Explore Blog About Me RSS
Social Bluesky Github LinkedIn