Skip to content

Instantly share code, notes, and snippets.

View rex-sheridan's full-sized avatar

Rex Sheridan rex-sheridan

  • Cox Automotive
  • Atlanta, GA
  • 12:16 (UTC -04:00)
View GitHub Profile
@rex-sheridan
rex-sheridan / ycombinator.clj
Created August 5, 2023 11:40
Y Combinator in Clojure
(ns ycombinator)
;; Based on https://blog.klipse.tech/lambda/2016/08/07/pure-y-combinator-clojure.html
(defn factorial [n]
(if (zero? n)
1
(* n (factorial (dec n)))))
(defn factorial-gen [func]
@rex-sheridan
rex-sheridan / FindForeignKeyReferences.sql
Created February 24, 2021 13:51
Find foreign keys referencing a table: postgres
-- Find foreign keys referencing a table: postgres
-- From https://bowerstudios.com/node/1052
SELECT tc.table_schema, tc.constraint_name, tc.table_name, kcu.column_name, ccu.table_name
AS foreign_table_name, ccu.column_name AS foreign_column_name
FROM information_schema.table_constraints tc
JOIN information_schema.key_column_usage kcu ON tc.constraint_name = kcu.constraint_name
JOIN information_schema.constraint_column_usage ccu ON ccu.constraint_name = tc.constraint_name
WHERE constraint_type = 'FOREIGN KEY'
AND ccu.table_name='myTableName';
@rex-sheridan
rex-sheridan / keybase.md
Last active January 28, 2020 19:04
keybase.md

Keybase proof

I hereby claim:

  • I am rex-sheridan on github.
  • I am rexsheridan (https://keybase.io/rexsheridan) on keybase.
  • I have a public key ASC25B1r94YIE9PLzTA9ptSDqKuEad1mDpBgNZUsfi3ArAo

To claim this, I am signing this object:

SELECT *, pg_size_pretty(total_bytes) AS total
, pg_size_pretty(index_bytes) AS INDEX
, pg_size_pretty(toast_bytes) AS toast
, pg_size_pretty(table_bytes) AS TABLE
FROM (
SELECT *, total_bytes-index_bytes-COALESCE(toast_bytes,0) AS table_bytes FROM (
SELECT c.oid,nspname AS table_schema, relname AS TABLE_NAME
, c.reltuples AS row_estimate
, pg_total_relation_size(c.oid) AS total_bytes
, pg_indexes_size(c.oid) AS index_bytes
@rex-sheridan
rex-sheridan / DeferredCompletableFuture.java
Created October 28, 2016 02:21
What if you don't want to decide right away when the CompletableFuture will begin executing?
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.Function;
import java.util.function.Supplier;
public abstract class DeferredCompletableFuture<T>
implements Function<Executor, CompletableFuture<T>>, Supplier<CompletableFuture<T>> {
private static class SupplierDeferredCompletableFuture<T> extends DeferredCompletableFuture<T> {
Supplier<T> supplier;