Skip to content

Instantly share code, notes, and snippets.

popt-electric_1-1 | Last message: {:tcp, #Port<0.24>, <<0, 0, 0, 8, 4, 210, 22, 48>>}
popt-electric_1-1 | 13:27:57.079 pid=<0.3403.0> proxy_session_id=5 [error] GenServer #PID<0.3403.0> terminating
popt-electric_1-1 | ** (FunctionClauseError) no function clause matching in Electric.Postgres.Proxy.Handler.handle_messages/3
popt-electric_1-1 | (electric 0.7.0) lib/electric/postgres/proxy/handler.ex:133: Electric.Postgres.Proxy.Handler.handle_messages([%PgProtocol.Message.GSSENCRequest{}], %ThousandIsland.Socket{socket: #Port<0.26>, transport_module: ThousandIsland.Transports.TCP, read_timeout: 60000, span: %ThousandIsland.Telemetry{span_name: :connection, telemetry_span_context: #Reference<0.3997643739.1119092740.165009>, start_time: -576460584819486727, start_metadata: %{parent_telemetry_span_context: #Reference<0.3997643739.1119092737.164642>, remote_address: {192, 168, 65, 1}, remote_port: 30892, telemetry_span_context: #Reference<0.3997643739.1119092740.165009>}}}, %Electric.Postgres.Proxy.Handler.S
const initialiseMenuWidths = (menuItem) => {
const menuContents = menuItem.querySelector('.menu-contents');
// Find the longest menu item
const maxWidth = Math.max(
...Array.from(menuContents.querySelectorAll('.nav-content li')).map(
(el) => el.offsetWidth
)
);
function when<A, B>(value: A | null, f: (value: A) => B): B | null;
function when<A, B>(value: A | undefined, f: (value: A) => B): B | undefined;
function when<A, B>(value: A, f: (value: A) => B) {
return value === null || value === undefined ? f(value) : value;
}
@ccapndave
ccapndave / Clock.hs
Last active June 1, 2021 18:17
Clock.hs
module Clock (addDelta, fromHourMin, toString) where
import Text.Printf
newtype Clock = Clock Int
deriving Eq
instance Semigroup Clock where
Clock a <> Clock b = mkClock $ a + b
let useMyFunction = (myfunc, deps) => {
React.useEffect(() => {
myfunc();
}, deps);
};
// In a component
useMyFunction(() => console.log(a), [a]);
// Because a is bound at the point I create the function to pass into the hook, it never updates
export function makeCache<Key, Value, ValueMap extends Map<string, Value>>(
hashKey: (key: Key) => string,
valueCodec: Codec<Value>,
fetchValueMap: (keys: readonly Key[]) => EitherAsync<string, ValueMap>,
ttl: number
{
// ValueMap is used here lots too
}
var useFetch = function (request) {
var match = React.useState(function () {
return /* Loading */ 0;
});
var setState = match[1];
React.useEffect(
function () {
fetchAndDecode(request).then(function (result) {
return Promise.resolve(
Curry._1(setState, function (param) {
#_cdielts-context-menu.menu {
width: 120px;
background-color: white;
box-shadow: 0 4px 5px 3px rgba(0, 0, 0, 0.2);
position: absolute;
display: none;
.menu-options {
list-style: none;
padding: 10px 0;
EXPLAIN SELECT * FROM `T_UserBase` AS users
LEFT OUTER JOIN `T_ScheduledTestTakerUsers` AS takers ON takers.`F_UserID` = users.`F_UserID`
LEFT OUTER JOIN `T_ScheduledTestsBase` AS tests ON tests.`F_TestID` = takers.`F_TestID`
LEFT OUTER JOIN `T_SessionTrack` AS sessions ON sessions.`F_UserID` = users.`F_UserID`
WHERE (tests.`F_TestID` = 4510) OR (sessions.`F_ContentID` = 4510)
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
function monkeyPatchXMLHttpRequest() {
const originalSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
const originalAddEventListener = XMLHttpRequest.prototype.addEventListener;
XMLHttpRequest.prototype.setRequestHeader = function (header: string, value: string): void {
if (header.toLowerCase() === "x-passphrase") {
this.passphrase = value;
} else {
originalSetRequestHeader.apply(this, [ header, value ]);
}