Ruby
Ruby is a programming language which is particularly popular for web development. I don’t have much experience in Ruby, but when I used Jekyll to power this blog, I wrote a bit of Ruby for some plugins. It felt similar to Python but with slightly different syntax to what I’m used to.
2 articles
Minifying HTML on my Jekyll website
I compare three different approaches to minifying HTML.
Getting faster Jekyll builds with caching in plugins
I was able to build my Jekyll site much faster by using the built-in caching API.
10 notes
Collapsing whitespace in a Liquid template
Output an empty string with stripped whitespace, that is
{{- "" -}}.Ruby’s range can iterate over more than just numbers
You can iterate over a range between two
Stringvalues, because Ruby’sStringdoes intelligent increments of alphanumeric strings.A basic socket server in Ruby
My first bit of socket programming is a Ruby server that reads lines from the socket, and prints them. Not useful on its own, but a stepping stone to more exciting things!
You can reset the start of a regex in Ruby
The
\Kescape is the “Match-Reset Anchor”, which resets the start of the reported match, and skip any previously consumed characters.How to get the expiry date of an HTTPS certificate with Ruby
Connect to the domain using
net/http, then you can inspect thepeer_cert/not_afterproperty on the response.Find the shortest prefix to identify a string in Ruby
The built-in
Abbrevmodule can calculate a set of unambiguous abbreviations for a set of strings, and then you can look for the shortest result for each string.How to highlight Python console sessions in Jekyll
Adding a couple of options to the
consolelexer (console?lang=python&prompt=>>>) gets you syntax highlighting for a Python console session.Use the
{% raw %}tag to describe Liquid in LiquidIf you’re trying to write about using Liquid tags in a Liquid-based site, wrapping your tags in the
{% raw %}tag will prevent them being rendered.Use the
{% capture %}tag to assign complex strings to variablesIf you want to get a string that’s semi-complicated to construct, you can put a “mini-template” in the
{% capture %}tag to build it over multiple lines.How to suppress installing rdoc/ri docs when running
gem install
