Decant is a dependency-free frontmatter-aware framework-agnostic wrapper around a directory of static content (probably Markdown). It pairs perfectly with Parklife plus your favourite Ruby web framework to help you make a content-driven static website. Usage Start by defining a Decant model-like content class that points to a directory of files and their extension. You can declare convenience…
Very occasionally I’m inspired by a code challenge , this time it’s finding the longest gap in minutes between consecutive timestamps (via @andycroll ). Here’s my approach using Ruby: def find_longest_time_gap ( times ) times . map { _1 . split ( ':' , 2 ). map ( & :to_i ) } . map { | ( h , m ) | h * 60 + m } . sort . each_cons ( 2 ) . map { | ( a , b ) | b - a } . max || 0 end…
Operatic defines a minimal standard interface to encapsulate your Ruby operations. The job of Operatic is to receive input and make it available to the operation, and to gather output and return it via a result object. This leaves you a well-defined space to write the actual code by implementing the #call method – and with so much of the ceremony taken care of it feels like writing a function but…
Sinatra supports streaming, Phlex supports streaming, but until recently I hadn’t put the two together in phlex-sinatra . Well now I have and from version 0.3 you can pass stream: true like so: get '/foo' do phlex MyView . new , stream: true end When streaming is enabled Phlex will automatically flush to the response after a closing </head> which means that the browser can start processing…
Phlex already works with Sinatra (and everything else) but its normal usage leaves you without access to Sinatra’s standard helper methods. That’s why I created phlex-sinatra which lets you use Sinatra’s url() helper from within Phlex (along with the rest of the usual helper methods available in a Sinatra action). To enable the integration use the phlex method in your Sinatra action and pass an…
Like many others last year I fell into a daily Wordle routine – I also collected the results. It’s taken a while but I’ve turned the data into a microsite of my Wordle results . It’s a Sinatra/Parklife app and a good (albeit tiny) example of using Parklife in the wild showing just how incredibly easy it is to take a standard Sinatra app and turn it into a static production build. Whilst Ruby and…
Parklife turns any Rack app (Rails, Sinatra, Hanami, Roda, Camping) into a static HTML build ready to be hosted on GitHub Pages, Netlify, Now, S3, or any other web server. The great thing is that your development flow remains completely unchanged – keep working with the frameworks you already know and love and all those other gems you favour, keep running the usual development server, and keep…
Before thinking about aliases the best thing you can do to make git nicer to use is configure tab completion. If you’re using Homebrew follow their shell completion docs otherwise you’re on your own – but do it! The great thing about git aliases is that they’re also tab completable. Here are the git aliases I use all the time , add them to your ~/.gitconfig : [alias] browse = !gh browse co =…
I’ve only just learned that Vim can syntax highlight Markdown fenced code blocks by their language with the addition of a setting in your .vimrc : let g:markdown_fenced_languages = [ 'html' , 'js=javascript' , 'ruby' ] The js=javascript syntax above means that a fenced code block with the language js will load the javascript Vim syntax file. It’s worth noting that this can slow down opening a…
Operatic defines a minimal standard interface to encapsulate your Ruby operations (often referred to as “service objects”). The job of Operatic is to receive input and make it available to the operation, and to gather output and return it via a result object, this leaves you a well-defined space to write the actual code by implementing the #call method. And with so much of the ceremony taken care…