Skip to content

Instantly share code, notes, and snippets.

View wouterraateland's full-sized avatar
🎯
Focusing

Wouter Raateland wouterraateland

🎯
Focusing
View GitHub Profile
@wouterraateland
wouterraateland / bookingmood-search-example.js
Created May 14, 2024 14:15
Search example for Bookingmood (JavaScript)
const API_KEY = "YOUR_API_KEY";
// Append additional options here (fetch using /v1/attribute_options)
const OPTION_MAP = [
{ name: "Videography", id: "a32963c2-8c80-4ed1-914d-726796ca1eea" },
{ name: "Photography", id: "ec26c3c2-b07c-4b99-b3b7-c1a60fdbf7f6" },
{ name: "Austin", id: "f71b772e-3c57-476e-9204-d1b5bde20b8f" },
{ name: "San Antonio", id: "24583a14-2c9f-4dc8-a0e2-4dc5b0e8fd72" },
{ name: "New York City", id: "3cc28053-1d65-4aee-95b4-c9348486bcf1" },
];
@wouterraateland
wouterraateland / bookingmood-search-example.ts
Last active May 14, 2024 14:15
Search example for Bookingmood (TypeScript)
const API_KEY = "YOUR_API_KEY";
// Append additional options here (fetch using /v1/attribute_options)
const OPTION_MAP = [
{ name: "Videography", id: "a32963c2-8c80-4ed1-914d-726796ca1eea" },
{ name: "Photography", id: "ec26c3c2-b07c-4b99-b3b7-c1a60fdbf7f6" },
{ name: "Austin", id: "f71b772e-3c57-476e-9204-d1b5bde20b8f" },
{ name: "San Antonio", id: "24583a14-2c9f-4dc8-a0e2-4dc5b0e8fd72" },
{ name: "New York City", id: "3cc28053-1d65-4aee-95b4-c9348486bcf1" },
];
@wouterraateland
wouterraateland / storage-available.ts
Created April 15, 2024 09:10
TS storage availability check function
export function storageAvailable(type: "localStorage" | "sessionStorage") {
if (typeof window !== "object") return false;
try {
const storage = window[type];
const x = "__storage_test__";
storage.setItem(x, x);
storage.removeItem(x);
return true;
} catch (e) {
try {
@wouterraateland
wouterraateland / screenshot_guidelines.md
Created November 2, 2022 10:18
Consistent screenshots in browser

Consistent screen setup:

  1. Open devtools alt + cmnd + I
  2. Open device toolbar cmnd + shift + M
  3. Click on dots top right and click "Add device pixel ratio" (DPR)
  4. Set DPR (probably to 2.0)
  5. Set resolution

Consistent screenshots:

  1. Select the element you want to capture in the "Elements panel"
  2. Open command center cmnd + shift + P
@wouterraateland
wouterraateland / numerical_integral.js
Created September 24, 2017 11:16
Numerically calculate the integral value of a single dimensional function between points x0 and x1
const integrate = (fn, x0, x1, steps=100) =>
Array(steps)
.fill(0)
.reduce((acc, _, i) =>
acc + (x1 - x0) / steps * fn(x0 + (x1 - x0) * ((i + .5) / steps)),
0
)