-
SQLite Hex-ULIDs
Identifiers are an essential aspect of any database schema design. There are various approaches with their various pros and cons. There are likewise various database engines. Today, I want to explore generating universally unique, sortable identifiers in SQLite.
Continue reading … -
Handling variables
The third in a series of posts laying out the process, step by step, of building an interpreter in Ruby for working with propositional logic. In this post, we expand the interpreter to work with variable expressions in classical propositional logic, like
Continue reading …~p & q
. Since we are dealing with variable expressions and not fixed expressions (like~T & F
), we need to be able to output full truth tables, and not simply resolve the final boolean output. -
Slideover Bootstrap Modals
Sometimes we don’t want a modal floating in the center of the viewport; sometimes, we want a full-height modal that slides into frame. Luckily, we can write a bit of CSS to extend the Bootstrap
Continue reading …modal
component to support slideover modals. -
Rails Forms and Request Parameters
Sometimes in our Rails applications we need to build forms that represent state stored in URL query parameters that is independent of any persisted object in our backend datastore, like in the case of a search form. In this post I offer a simple, flexible, generic helper for doing just that.
Continue reading … -
Flattening Nested Hashes in Ruby
Sometimes, especially when working with external data, you will be handed a thickly nested blob of JSON, represented in Ruby as a nested hash. I have found in my experience that processing this data is often simpler when we can work with a flat hash instead, collapsing the key paths into a simple array key. And so, I wrote a function that does just this – it flattens a nested hash into a flat hash.
Continue reading … -
Expecting Exceptions in Ruby
Sometimes in Ruby code, having to use the
Continue reading …begin ... rescue .. end
construction to capture and deal with exceptions can feel overly burdensome. I recently found myself in such a situation and wrote a small function to make my code read a bit more elegantly. -
Safely Accessing Values from Nested Hashes (again)
Implementing a companion method to
Continue reading …Hash#dig
that always returns a value and never throws an error and allows for a default return value. -
Basic RESTful Filtering with Rails
Filtering a collection of data objects into a subset is one of the most common tasks in data-management applications. While well-tread, this problem space provides rich opportunity for exploring and learning about how to implement RESTful, maintainable, flexible, and robust Rails applications. In this post I want to implement a simple filtering feature, walking through the various aspects at the model, controller, and view layers.
Continue reading … -
Building Pure CSS Trees (part 5)
After the first 4 parts of our series, we have some flexible (S)CSS that will render nested lists as trees. It can render horizontal trees, vertical trees, trees going from top-to-bottom or bottom-to-top, left-to-right or right-to-left , and even bracket-style centered trees.
Continue reading … -
Building Pure CSS Trees (part 4)
The last we left our pure-CSS tree component, it could render both horizontally oriented as well as vertically oriented as well as the inverse direction for either. With each orientation now capable of being rendered in either direction, might we be able to build a tree component that could put the root node in the center of the graph and have half of the descendant graph render to left and have to the right (for the horizontal orientation) or half to the top and half to the bottom (for the vertical orientation)?
Continue reading …