Category: Coding


  • Rust

    Rust

    Picked up a book, Programming Rust (2nd Edition) by Jim Blandy, and have been working through it over the holidays (non-stop party here).

    Published in late 2021, it’s surprising how much of the code doesn’t work and it isn’t encouraging to spend half an hour searching for solutions to an early worked example. Nothing in the book’s errata.

    So if you’re stuck with the early “serving pages to the web” example on page 15, it was caused by a breaking change in actix-web crate‘s chrono dependency. I ended up setting the version before the change.

    [package]
    name = "actix-gcd"
    version = "0.1.0"
    edition = "2021"
    
    # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
    
    [dependencies]
    chrono = { version = "= 0.4.29" }
    actix-web = "1.0.8"
    serde = { version = "1.0", features = ["derive"] }

    Funnily the author wrote “One of Rust’s strengths is the collection of freely available library packages […]” and “[…] by naming the specific versions we tested this code against, we can ensure the code will continue to compile even as new versions of the packages are published.“. True, as long as every dependency behaves itself and it reminded me of this XKCD:

    XKCD

    Anyway it’s a great read and these things happen. There’s updated version of the completed exercise code on Github.


  • Static sites with Jekyll in Ubuntu

    Static sites with Jekyll in Ubuntu

    Setup Ruby

    Remove the default Ubuntu install, otherwise you’ll get an error You don't have write permissions for the /var/lib/gems/3.x.x Directory and configure Ruby to install gems to a folder in your home.

    (more…)

  • Expo on Codespaces

    Expo on Codespaces

    What will I need?

    How long will it take?

    About ten minutes.

    Lets give it a go!

    Create a new Codespace using the blank template:

    Once initalised, create an empty Expo React App (select (y)es when prompted):

    npx create-expo-app example

    Install the expo-cli command line tool globally:

    npm install -g expo-cli

    Change into your example project’s folder and edit App.js, maybe adding an image or whatever, before updating packages:

    cd example
    npm update

    Login to your Expo account from the command line:

    Create an account with Expo and login using the expo login command.

    Expo-cli supports tunnelling, a proxy URL accesible from any device over the Internet, using ngrok.

    expo start --tunnel

    After installing the requested library (@expo/ngrok@^4.1.0), you should see a QR code:

    Open the Expo Go app on your device, login, and then scan the QR code. The app will bundle and be available on your device.

    Further reading