History (Fourth Time)

I did this in 2008, 2011 and 2015 but forgot to do it for ten years.

[zarniwoop ~] history 0 | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn  | head
34675 git
5294 composer
4376 cd
3761 vi
3076 pnpm
2914 python
2188 m
1917 ls
1822 python3
1717 ssh

Compared to 2015. New: composer, pnpm, python/python3, m (run scripts for an app I work on). Climbers: git, cd. Fallers: ssh, ls. Old: c, php, pass, sudo, ruby.

COUNT(*) OVER () in Drizzle

In general I like to use COUNT(*) OVER () to get the total count for a query when retrieving a slice with OFFSET and LIMIT (very useful for pagination) rather than issuing a separate query for the total count. This is not super well supported in Drizzle but you can do it like this:

const data = await db.query.tableName.findMany({
    …
    extras: {
        // Weird cast here because COUNT(*) is a bigint which is handled as a string in js
        // https://orm.drizzle.team/docs/guides/count-rows
        total: sql<number>`CAST(COUNT(*) OVER() AS INTEGER)`.as("total"),
    },
    …