Skip to content

Instantly share code, notes, and snippets.

@almightycouch
almightycouch / psql_changefeed.sql
Last active August 16, 2019 07:56
PostgreSQL changefeed using NOTIFY
CREATE FUNCTION notify_changes() RETURNS trigger AS $$
DECLARE
BEGIN
IF TG_OP = 'INSERT' THEN
PERFORM pg_notify('insert', json_build_object('table', TG_TABLE_NAME, 'new_val', row_to_json(NEW))#>>'{}');
RETURN NEW;
ELSIF TG_OP = 'UPDATE' THEN
PERFORM pg_notify('update', json_build_object('table', TG_TABLE_NAME, 'new_val', row_to_json(NEW), 'old_val', row_to_json(OLD))#>>'{}');
RETURN NEW;
ELSIF TG_OP = 'DELETE' THEN
@ohanhi
ohanhi / frp.md
Last active May 6, 2024 05:17
Learning FP the hard way: Experiences on the Elm language

Learning FP the hard way: Experiences on the Elm language

by Ossi Hanhinen, @ohanhi

with the support of Futurice 💚.

Licensed under CC BY 4.0.

Editorial note

# db/migrate/20120625030355_add_deleted_at_to_user.rb
class AddDeletedAtToUser < ActiveRecord::Migration
def change
add_column :users, :deleted_at, :datetime
end
end
@denji
denji / http-benchmark.md
Last active July 18, 2024 09:01
HTTP(S) Benchmark Tools / Toolkit for testing/debugging HTTP(S) and restAPI (RESTful)
@kconragan
kconragan / keyrepeat.shell
Last active December 4, 2023 03:40
Enable key repeat in Apple Lion for Sublime Text in Vim mode
# Mac OS X Lion introduced a new, iOS-like context menu when you press and hold a key
# that enables you to choose a character from a menu of options. If you are on Lion
# try it by pressing and holding down 'e' in any app that uses the default NSTextField
# for input.
#
# It's a nice feature and continues the blending of Mac OS X and iOS features. However,
# it's a nightmare to deal with in Sublime Text if you're running Vintage (Vim) mode,
# as it means you cannot press and hold h/j/k/l to move through your file. You have
# to repeatedly press the keys to navigate.