Dublin Library

The Publishing project

Compiling Go Programs

In all previous Go-related posts, we've just run the code using Go's run command, like so: bash go run main.go But there are times when we must compile the program either for internal use or to share with third parties. This post will describe how to run programs without compiling them, how to compile programs in Go, how to give them a name, how to cross-compile to support multiple platforms, and how to run the resulting binaries. Running the code To run the code execute the following command on the root directory of the project bash go run main.go Compiling...

Continue reading →

Using Third-Party Libraries in Go

So far we've covered command-line applications that only use modules in the standard library This post will explore using third-party modules by building a conversion tool from Markdown to HTML Before We Start: Initializing Go Modules bash go mod init github.com/caraya/markdown-converter Then, whenever we want to install a third-party package, we run the following command bash go get For example: bash go get github.com/BurntSushi/toml or bash go get go.abhg.dev/goldmark/frontmatter We'll point out what packages to get when it's appropriate. First Iteration: Building the Conversion Tool In the first step, I'm trying to understand how to get the Markdown parser to...

Continue reading →

Opening and Writing Files With Go

In the last post, we looked at how to build an API server using Go. In this post, we'll look at one part of building command line applications: how to open and write files. We'll also cover related areas like reading input from the command line and how to get user input and act on that input. In the next post, we'll look at how to use third-party libraries in Go programs by building a Markdown conversion tool. The first iteration: the basics The first attempt is very simple. It does the following: 1. Opens a specific file that has...

Continue reading →

Creating the Backend for a Web App in Go

I've always struggled with how to bring languages like Go and Rust into my web development work. Tooling is the easiest way to go. There is a reason why most new web development tooling is written in Rust. But I've been determined to work with Go instead. For these exercises, I will create an API server using Go's built-in HTTP router module, something similar to what you can do with Expresshttps://expressjs.com/ in Node.js. I chose to work with the net/httphttps://pkg.go.dev/net/http module, part of Go's standard library, rather than a third-party module like Gorilla Muxhttps://pkg.go.dev/github.com/gorilla/mux. We may also look at the...

Continue reading →

Making HTML Headers Look Nice

Headings can show orphan issues that can cause readability issues. In this context, an orphan is a single word or syllable that sits at the bottom of a paragraph of text. As a developer, you don't know the final size, font size, or even the language of a headline or paragraph. All the variables needed for an effective and aesthetic treatment of text wrapping, are in the browser. Using text-wrap: balancehttps://developer.chrome.com/docs/css-ui/css-text-wrap-balance we can provide better control over these orphan headings. Before we had text-wrap: balance we had few tools to keep the heading lines balanced. The best and probably only...

Continue reading →

Hanging punctuation in CSS

Chris Coyuer wrote about the hanging punctuationhttps://chriscoyier.net/2023/11/27/the-hanging-punctuation-property-in-css/ CSS property, how it works and why it may be useful. This property controls the pulling of characters, usually quotation marks, from the body of the text. See the Pen Hanging Punctuation in CSS with @supports and Custom Properties by Carlos Araya @caraya on CodePen. Officially, only Safari supports the feature so we need feature querieshttps://developer.mozilla.org/en-US/docs/Web/CSS/CSSconditionalrules/Usingfeaturequeries to make sure this works as the intended enhancement it is. We check if the browser supports the feature and then provide code using the feature along with any other relevant code. css @​supports hanging-punctuation: first {...

Continue reading →

Another set of possible color palettes

This post is an extension to the previous one What are Triadic and Tetradic Color Palettes and How to Use Themhttps://publishing-project.rivendellweb.net/what-are-triadic-and-tetradic-color-palettes/. It will explore further types of palettes, also known as harmonies in color theory, and how to generate them. Complementary colors These are two colors that are positioned on opposite ends of the color wheel, 180 degrees from each other.     Complementary Colors Split-complementary colors This is more complicated. Split complementary colors are one primary hue and two hues adjacent to the primary color’s complement. For this example I've chosen colors 30 degrees away from the complementary color...

Continue reading →

What are Triadic and Tetradic Color Palettes and How to Use Them

In my last post Creating an OKLCH Generator Toolhttps://publishing-project.rivendellweb.net/creating-an-oklch-generator-tool/, I wrote about about Triadic and Tetradic palettes and how to build them using vanilla JS. This post will cover what these palettes are and how to use them. Triadic Colors !OKLCH color wheel, provided for reference. Source Coloraidehttps://github.com/facelessuser/coloraidehttps://res.cloudinary.com/dfh6ihzvj/image/upload/cscale,w500/fauto,qauto/oklch-color-wheelkz2mmy.png Triadic colorshttps://www.interaction-design.org/literature/article/triadic-color-scheme are equidistant on the color wheel.       Example of Triadic Colors at 0, 120, and 240 degrees in the color wheel If we use blue as our starting color, the palette will loop around, that's why the third color is at 92 on the wheel.      ...

Continue reading →

Creating an OKLCH generator tool

This code started as an exercise in ChatGPT prompt generation and a way to explore what we can do with OKLCH colors. It uses vanilla Javascript and deliberately avoids using libraries like Chroma.jshttps://gka.github.io/chroma.js/ or Color.jshttps://colorjs.io/. The basis for the project is a color builder. On top of that, we build a series of additional tools to make other color experiments. CSS support for OKLCH colors is part of the CSS Color Level 4https://www.w3.org/TR/css-color-4/lab-colors specification so you need to be mindful that older versions of your browsers may not support the color space of the notation. The color components are: L...

Continue reading →

Even More Array Methods

The ECMAScript specification gained a new set of methods for the Array object. These methods work on copies of the original array rather than modifying the original array directly. There are other ways to complete the tasks these methods do. Which method you use will largely depend on whether you need to keep the original array intact or not. Reversing an array by copy with toReversed When I want to reverse the content of an array, I normally clone the array using fromhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/GlobalObjects/Array/from and then reverse it using reversehttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/GlobalObjects/Array/reverse. js let cars = 'Porsche', 'Ferrari', 'BMW' let reverseCars = Array.fromcars.reverse;...

Continue reading →