Skip to content

Instantly share code, notes, and snippets.

View davidabram's full-sized avatar
🐊
New avatar, who this?

David Abram davidabram

🐊
New avatar, who this?
View GitHub Profile

I have an Astro component at apps/website/src/components/hero.astro using a custom <Picture> wrapper:

<Picture
  src={heroImage}
  alt="CroCoder Hero Image"
  widths={[1196, 598, 553, 292]}
  loading="eager"
  fetchpriority="high"
/&gt;
type mutable_
type immutable
type 'perm byte_buf = {
raw : bytes;
}
let create_mutable size : mutable_ byte_buf =
{ raw = Bytes.create size }
const R = 100000;
const n = 10;
const values = [0];
for (let j = 1; j <= n; j++) {
values[j] = (R * R + values[j - 1] * values[j - 1]) / (2 * R);
}
function shouldStop(currentAmount, drawNumber, bestSoFar, history) {
if (drawNumber < 1 || drawNumber > n) return true;
return currentAmount >= values[n - drawNumber];
CREATE TABLE projects (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL
);
CREATE TABLE prompts (
id SERIAL PRIMARY KEY,
project_id INTEGER NOT NULL,
text TEXT NOT NULL,
FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE
/* Reset critical elements instead of all elements */
body, p, h1, h2, h3, h4, h5, h6, a, button, input {
color: white;
background: white;
border: none;
opacity: 0;
outline: 0;
}
/* Media query for dark mode */
#!/bin/bash
#
# Description: Text to speech using pico2wave
#
# sudo apt install libttspico-utils
#
# sudo apt install sox
#
#
# sudo mkdir -p /etc/apt/keyrings
@davidabram
davidabram / IsCalledOnce.tsx
Created September 7, 2022 11:56
UseEffect woes
import { useEffect, useState, useRef } from "react";
const IsCalledOnce = () => {
const [result, setResult] = useState({});
const [numberOfCalls, setNumberOfCalls] = useState(0);
const httpBinLoadingRef = useRef<boolean>(false);
const callHTTPBin = async (num: Number) => {
httpBinLoadingRef.current = true;
const response = await fetch(`https://httpbin.org/get?num=${num}`);
@davidabram
davidabram / PostgreSQL_index_naming.rst
Created February 21, 2021 15:44 — forked from popravich/PostgreSQL_index_naming.rst
PostgreSQL index naming convention to remember

The standard names for indexes in PostgreSQL are:

{tablename}_{columnname(s)}_{suffix}

where the suffix is one of the following:

  • pkey for a Primary Key constraint;
  • key for a Unique constraint;
  • excl for an Exclusion constraint;
  • idx for any other kind of index;
Verifying my Blockstack ID is secured with the address 1GNjhqyPqFH34rik4h8LFneSJxMyqhLcCX https://explorer.blockstack.org/address/1GNjhqyPqFH34rik4h8LFneSJxMyqhLcCX
Verifying my Blockstack ID is secured with the address 1GNjhqyPqFH34rik4h8LFneSJxMyqhLcCX https://explorer.blockstack.org/address/1GNjhqyPqFH34rik4h8LFneSJxMyqhLcCX