15:48, 16th February 2022
Julia Programming: a Hands-on Tutorial
Julia is a free, open-source, general-purpose programming language originally developed by researchers at MIT, designed to combine the speed of compiled languages like C and Fortran with the ease of use associated with Matlab and Python. It achieves this through a just-in-time compiler, meaning code that appears interpreted runs at speeds comparable to fully compiled alternatives, often with significantly fewer lines of code required. The language supports optional typing, offers clean mathematical syntax and benefits from a thriving package ecosystem, making it particularly well-suited to scientific and engineering applications.
09:26, 15th February 2022
Hugo and Data: Advanced Manipulation with Slices and Maps
Advanced data manipulation in Hugo using Slices and Maps is a topic that receives little attention in the Hugo community, yet it is critical for building pages from remote sources such as API endpoints or Markdown files. Slices, which function as ordered arrays, can be created, appended to and filtered using built-in Hugo functions such as slice, append, uniq, first, last and where, while the index function allows retrieval of specific elements. Maps, which are associative arrays of key and value pairs, can be created using the dict function and combined using merge, with the reflect.IsSlice and reflect.IsMap functions available for type checking.
When slices and maps are combined, developers can construct structured data collections that can be browsed using range loops, filtered using where clauses with operators such as in and intersect, and sorted in ascending or descending order using the sort function. While hard-coding data in this way is useful for defining defaults and reusable bases, real-world projects typically draw data from external sources such as APIs or user-managed content files, with more advanced transformation techniques building upon these foundational concepts.
09:24, 14th February 2022
Add Sub Menu in Hugo Website
Hugo, the static site generator, does not natively support nested menu structures, but this can be achieved through a series of manual configuration and file creation steps. The process involves updating the config.toml file to define parent and child menu items using identifiers, names, URL's, weights and parent references, then creating or modifying a menu.html partial to render the nested structure using Hugo's built-in menu functions.
Styling is handled through custom CSS that manages the visibility and positioning of dropdown submenus across different screen sizes, and a JavaScript file is used to handle menu toggle behaviour for mobile views. Posts can be mapped to specific submenu items by applying matching tags in the front matter of each post, which Hugo then associates with the corresponding tag URL defined in the menu configuration. The approach is demonstrated using the Hugo Mainroad theme, so users of other themes may need to adapt the HTML, CSS and JavaScript to suit their particular setup.
19:42, 13th February 2022
Making Google Fonts Faster in 2022
Optimising font loading performance involves a balance between leveraging existing services like Google Fonts and implementing custom solutions for greater control. Strategies include preloading critical resources to ensure fonts are available early, in-lining essential CSS to enable quicker discovery of font requirements and using tools like subfont to automate font subsetting and optimisation. Hosting static assets on a reliable CDN can further enhance delivery speeds, especially for global audiences. While Google Fonts offers optimised variants and benefits from its extensive infrastructure, self-hosting allows for tailored control over file sises and caching strategies.
However, the decision to self-host should weigh the trade-offs between reduced file sises and the potential loss of shared caching benefits, which are no longer widely available due to browser security changes. Testing performance improvements through tools like WebPageTest is crucial to understanding the impact of each choice, ensuring that any adjustments align with the specific needs of the project and its users.
09:03, 11th February 2022
Tips for Customizing Hugo RSS Feed
Customising Hugo's RSS feed involves overriding its default template to tailor content inclusion. By modifying the template file located at layouts/_default/rss.xml, users can adjust the range expression to include all pages, filter by specific sections such as blog, or exclude non-post pages like section indices. Combining these adjustments allows for precise control, ensuring only relevant content appears in the feed. The final template typically includes metadata, item listings with titles, links, publication dates and content, structured to meet standard RSS format requirements while reflecting the site's specific needs.
21:14, 10th February 2022
R Graphical User Interface Comparison
A detailed comparison of nine graphical user interfaces (GUIs) for the R programming language evaluates each across four categories: ease of use, general usability, graphics and analytics. BlueSky Statistics and R-Instat rank closely together overall, though they differ greatly in their approaches and strengths. JASP leads on ease of use alongside Jamovi and BlueSky, while R-Instat tops the general usability and graphics categories, largely due to its extensive data wrangling capabilities and broad range of graph types. R Commander dominates the analytics category, benefiting from decades of development and 42 add-ons covering statistical, machine learning and artificial intelligence methods.
Each GUI has distinct characteristics: Jamovi offers an interactive interface with Bayesian analysis but limited data management; JASP excels at Bayesian methods but cannot display the R code it generates; Rattle focuses narrowly on machine learning; R AnalyticFlow supports flowchart-based workflows but lacks breadth in analysis methods; RKWard combines a point-and-click interface with an advanced development environment; and Deducer, despite an appealing interface, appears to have stalled in development. The comparison is intended to help users select the most appropriate tool for their needs, whether they are students, statisticians or data scientists.
09:51, 8th February 2022
broken-link-checker
This tool identifies broken links in HTML documents by scanning clickable elements, media references and other specified tags, while respecting robots.txt directives and excluding certain link types based on user-defined filters. It offers both command-line and API-based usage, allowing for custom configurations such as defining accepted protocols, setting rate limits and handling HTTP errors through retry mechanisms.
The package provides detailed feedback on each link's status, including reasons for exclusion or failure, and supports advanced features like checking external sites or parsing sitemaps in future updates. Designed for developers and SEO professionals, it operates under an MIT licence and is available as an NPM module, with ongoing improvements aimed at enhancing accuracy and usability in link validation tasks.
09:47, 8th February 2022
Roll Your Own Comment System for a Static Site
After migrating a personal blog from WordPress to Gatsby, the author found that Disqus, the recommended commenting solution, injected numerous scripts and displayed intrusive advertisements. Rather than adopting another third-party solution with similar drawbacks, the author built a custom comment system in a single day using a Node.js and Express API server connected to a PostgreSQL database hosted on Heroku. While the approach required more initial effort than off-the-shelf alternatives, it offered complete design control, no advertising, no injected third-party scripts and minimal spam exposure.
The system stores comments against article slugs, supports basic reply threading and includes protected endpoints for moderating, editing and deleting entries. The front end, built in React, retrieves and posts comments via standard fetch calls and renders a simple form alongside existing comments. Though the comment system was removed later due to the ongoing effort required to moderate a high-traffic personal blog, the approach is suggested as a worthwhile exercise for those seeking a lightweight, self-hosted solution.
09:47, 8th February 2022
How to Pre-render Comments | Gatsbyjs Guide
Pre-rendering comments on a Gatsby blog can improve search engine visibility by making dynamically loaded content available to crawlers at build time. The process involves creating a backend API route that retrieves all stored comments from a database, then building a custom Gatsby source plugin that fetches those comments and inserts them into Gatsby's data layer as GraphQL nodes. Once available in the data layer, the blog post template can be updated to query both the post content and its associated comments simultaneously.
On the front end, the commenting component is designed to serve the pre-rendered comments when running in a server environment, while switching to live, real-time comments fetched from the API when running in a browser. This is achieved by checking whether the window object is defined, which distinguishes server-side rendering from client-side execution. The end result is a setup where search engines index the pre-rendered comments at build time, while visitors still see up-to-date content when they land on a page. The approach can be verified by running a local build and inspecting the generated HTML files to confirm that comment content is present.
09:46, 8th February 2022
Build a Node.js, Express, & PostgreSQL REST API
Tania Rascia walks through the process of building a REST API using Node.js, Express and PostgreSQL, then deploying it to Heroku. Starting with local PostgreSQL setup, including creating a user, database and table, the process moves on to configuring an Express server with GET and POST endpoints, managing environment variables and establishing a database connection using the node-postgres package. Dependencies such as express, pg, dotenv and cors are covered, along with development tooling via nodemon.
The deployment section details setting up the Heroku CLI, creating an app instance and provisioning a PostgreSQL add-on before pushing the project live. The walkthrough concludes with a series of production recommendations, covering HTTP header security and compression via helmet and compression, CORS restriction to specific domains, rate limiting through express-rate-limit, input validation using express-validator and basic API key authorisation to restrict unauthorised endpoint access.