Skip to content

Instantly share code, notes, and snippets.

@scaint
scaint / settings.sql
Created February 20, 2024 20:19
Postgres dev settings
ALTER SYSTEM SET extra_float_digits = 0;
ALTER SYSTEM SET max_wal_senders = 0;
ALTER SYSTEM SET wal_level = minimal;
ALTER SYSTEM SET effective_io_concurrency = 2;
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
data:text/html,<body style="background-color:%237f8c8d;height:100%;margin:0"></body>
# frozen_string_literal: true
source 'https://rubygems.org'
gem 'dht-sensor-ffi'
gem 'rainbow'
CREATE TEMP TABLE beer(name text);
INSERT INTO beer VALUES ('Guinness');
SELECT * FROM beer;
-- name | ctid
------------+-------
-- Guinness | (0,1)
-- (1 row)
UPDATE beer SET name = 'Guinness' WHERE name != 'Guinness';
// The Module object: Our interface to the outside world. We import
// and export values on it, and do the work to get that through
// closure compiler if necessary. There are various ways Module can be used:
// 1. Not defined. We create it here
// 2. A function parameter, function(Module) { ..generated code.. }
// 3. pre-run appended it, var Module = {}; ..generated code..
// 4. External script tag defines var Module.
// We need to do an eval in order to handle the closure compiler
// case, where this code here is minified but Module was defined
// elsewhere (e.g. case 4 above). We also need to check if Module
for p in .vim/pack/bundle/start/*; do echo "* [$(basename $p)]($(grep -oP https://.+/$(basename $p) .gitmodules))"; done
SELECT format(
E'{"index": {"_index": "%s", "_type": "%s", "_id": %s}}\n%s',
current_database() || '_users',
'user',
t.id,
json_build_object('username', t.username, 'email', t.email))
FROM users t;
DELETE FROM tbl WHERE ctid = ANY(array(SELECT ctid FROM tbl LIMIT 10000)) RETURNING *;
class Cart::Checkout < Operation::Base
call do
Order.create(...)
end
before do
cancel! if cart.empty?
end
around do
@scaint
scaint / now.sql
Last active February 9, 2016 17:02
CREATE OR REPLACE FUNCTION public.NOW() RETURNS timestamp AS 'SELECT timestamp ''2016-01-01''' LANGUAGE SQL IMMUTABLE;
SELECT NOW();
BEGIN;
SET LOCAL search_path TO public,pg_catalog;
SELECT NOW();
COMMIT;
SELECT NOW();