postgres: window functions
Good article about window functions. Also note how they use a postgres feature called common table expressions.
Related cards:
Postgresql: Paginate and count in one query using window functions
When paginating records, we usually need to know the number of total records in order to render pagination links. Popular pagination libraries like will_paginate or [Kaminari](https://github.com/kaminari/...
Beware: Many browsers define window.event
Some browsers define window.event
, which will return a copy of the "current" event. However, this is not defined by the W3C. Most importantly, Firefox does not support it, neither do recent versions of IE.
You should completely avoid access...
Linux: How to make a terminal window title reflect the current path
By default, your terminal emulator (Gnome Terminal, Terminator, etc.) sets some kind of window title to reflect the shell type you are running (e.g. /bin/bash
).
This is most often not too helpful, but you can change that from your shell.
To set...
How to move a window to the next monitor on Xfce, Mate and other X Window Managers
Since I use this a lot in my daily work and there were no scripts working properly for me, I made one myself.
It's actually not bound to Xfce but should work on any window manager (haven't tried it, though).
Installation
- If you don't yet ...
How to: Build a "generic observer" widget for the awesome window manager
If you want a widget for awesome that runs a command regularly (every X seconds) and puts the output into your awesome panel, this is for you.
Put the code below into your ~/.config/awesome/rc.lua
. It supplies tw...
Rails: Using PostgreSQL full-text search without a gem
PostgreSQL can cosplay as a full-text search engine. It doesn't have the features or fidelity of ElasticSearch or Algolia, but it's good enough if you just need to search and rank large volumes of text.
This card will teach you how to index, sear...
IIFEs in Coffeescript
In JavaScript we often use Immediately Invoked Function Expessions (or IIFEs) to prevent local variables from bleeding into an outside scope:
(function() {
var foo...
Webpacker: Loading code on demand
Sometimes you want to load code on demand. For instance, when a a large library is only used on a single screen, this library should only be loaded for that screen. It should not blow up the bundle size for all screens.
You can load code on deman...
Debug your Postgres SQL query plan
When debugging slow SQL queries, it’s helpful to understand the database engine's query plan. Whenever you execute a declarative SQL query, the database generates a "query plan" that outlines the exact steps the engine will take to execute the que...
Stretching an HTML page to full height
This card existed before, but was outdated due to browser implementation changes. The information below is validated for the current list of browsers we support.
By default your html
and body
elements are *only as high as the a...