Skip to content

Instantly share code, notes, and snippets.

View josefarias's full-sized avatar

Jose Farias josefarias

View GitHub Profile
@cpjolicoeur
cpjolicoeur / gist:3590737
Created September 1, 2012 23:15
Ordering a query result set by an arbitrary list in PostgreSQL

I'm hunting for the best solution on how to handle keeping large sets of DB records "sorted" in a performant manner.

Problem Description

Most of us have work on projects at some point where we have needed to have ordered lists of objects. Whether it be a to-do list sorted by priority, or a list of documents that a user can sort in whatever order they want.

A traditional approach for this on a Rails project is to use something like the acts_as_list gem, or something similar. These systems typically add some sort of "postion" or "sort order" column to each record, which is then used when querying out the records in a traditional order by position SQL query.

This approach seems to work fine for smaller datasets, but can be hard to manage on large data sets with hundreds (or thousands) of records needing to be sorted. Changing the sort position of even a single object will require updating every single record in the database that is in the same sort group. This requires potentially thousands of wri

@kevin-smets
kevin-smets / iterm2-solarized.md
Last active April 21, 2025 14:57
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@rahularity
rahularity / work-with-multiple-github-accounts.md
Last active April 21, 2025 22:13
How To Work With Multiple Github Accounts on your PC

How To Work With Multiple Github Accounts on a single Machine

Let suppose I have two github accounts, https://github.com/rahul-office and https://github.com/rahul-personal. Now i want to setup my mac to easily talk to both the github accounts.

NOTE: This logic can be extended to more than two accounts also. :)

The setup can be done in 5 easy steps:

Steps:

  • Step 1 : Create SSH keys for all accounts
  • Step 2 : Add SSH keys to SSH Agent
<?
# MIT license, do whatever you want with it
#
# This is my invoice.php page which I use to make invoices that customers want,
# with their address on it and which are easily printable. I love Stripe but
# their invoices and receipts were too wild for my customers on Remote OK
#
require_once(__DIR__.'/../vendor/autoload.php');
@nateberkopec
nateberkopec / 0_roadmap.md
Last active March 31, 2025 19:35
Speedshop Retainer Roadmap + Changelog

Speedshop Retainer Roadmap

This is the roadmap for the Speedshop Ruby on Rails performance retainer service. It was last updated March 28th, 2025. Items are in rough priority order.

In-Progress:

  1. Alerting and dashboard scorecards: We want everyone to be on the same footing with SLOs for queues and tracking our core set of 20 metrics, plus your app's specific key metrics (see next bullet). The output will be a scorecard page that's pass/fail on each point.
  2. Formalizing key metrics with everyone: Since we started the retainer, we learned it's helpful to have a set of 3 or fewer key metrics to monitor and improve upon over the course of the retainer. If we haven't already formalized these with you, we'll do so.
  3. Automated checks: jemalloc, YJIT, RMP, SQL comments, bcrypt version. We have a few automated checks that can be implemented just by reading your source code and doing a couple of static checks. We'll also ship some detailed guides for