This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Get replication identity for a table. | |
SELECT CASE relreplident | |
WHEN 'd' THEN 'default' | |
WHEN 'n' THEN 'nothing' | |
WHEN 'f' THEN 'full' | |
WHEN 'i' THEN 'index' | |
END AS replica_identity | |
FROM pg_class | |
WHERE oid = 'my_table'::regclass; | |
-- Note 'my_table'::regclass is equivalent to (SELECT oid FROM pg_class WHERE relname = 'my_table') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const crypto = require('crypto'); | |
const charTbl = '0123456789abcdefghjkmnpqrstvwxyz'; | |
const encodeChunk = (n) => charTbl[n]; | |
const nthChunk = (input, idx) => { | |
const startBit = 5*idx; | |
const offset = startBit % 8; | |
const startByte = (startBit - offset)/8; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::collections::VecDeque; | |
use std::sync::{Arc, Mutex}; | |
use std::sync::mpsc; | |
use std::thread; | |
struct QueueInner<T: Send> { | |
items: VecDeque<T>, | |
is_done: bool, | |
parked_producers: VecDeque<mpsc::Sender<()>>, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns notifications.actor | |
(:require [reagent.core :as r] | |
[cljs.core.async :refer [go-loop pub sub chan <! >! put! timeout]])) | |
(defn actor-system [] | |
(atom {})) | |
(defn mailbox [address] | |
[address (chan)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const promise_ = Symbol('promise'); | |
class Deferred { | |
constructor() { | |
this[promise_] = new Promise((resolve, reject) => { | |
this.resolve = resolve; | |
this.reject = reject; | |
}); | |
} | |
get promise() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn is-error-clause? [expr] | |
(and (sequential? expr) | |
(= 'on-error (first expr)))) | |
(defn parse-clauses [exprs] | |
(let [[body error-clauses] (partition-by is-error-clause? exprs) | |
[_ error-name & error-body] (first error-clauses)] | |
{:body body | |
:error-name error-name | |
:error-body error-body})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function highlightText(text, highlights) { | |
const lcText = text.toLowerCase(); | |
highlights = highlights.map(h => h.toLowerCase()); | |
let addedChars = 0; | |
for (let i = 0; i < text.length; i++) { | |
for (const highlight of highlights) { | |
if ( | |
lcText[i] === highlight[0] && | |
lcText.substring(i, i + highlight.length) === highlight |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
docker pull postgres:11-alpine | |
docker network inspect postgres_sandbox > /dev/null 2>&1 | |
if [[ "$?" == "0" ]]; then | |
docker network rm postgres_sandbox | |
fi | |
docker network create --driver bridge postgres_sandbox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn make-mailbox | |
([] (make-mailbox {:messages [] | |
:next-id 1})) | |
([state] | |
{:deliver! | |
(fn [msg] | |
(make-mailbox | |
(-> state | |
(update :messages conj | |
(assoc msg :read? false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f97d9211-26b2-495a-a872-bc91a4873f18 |
NewerOlder