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 test = `f notification shows [@jane](http://staging/uuid) sdfjhabsdfan sf asdfjknsadf sad ff notification | |
shows [@hector](http://staging/3fd21asd32sa1f3as2d1fas32fd1a-asdfasdfa2sdf)`; | |
const result = `f notification shows @jane sdfjhabsdfan sf asdfjknsadf sad ff notification | |
shows @hector`; | |
const reg = /\[(@[^\]]*)\]\([^)]*\)/gm; | |
const testResult = test.replace(reg, "$1"); |
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
// SOA | |
import { AppAccount, Collaborator } from "@prisma/client"; | |
// list of all row type in the app | |
enum TableRowTypeString { | |
Collaborator, | |
AppAccount, | |
} | |
// list of all fields for app accounts |
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
// AOS | |
import { AppAccount, Collaborator } from "@prisma/client"; | |
// list of all row type in the app | |
enum TableRowType { | |
Collab, | |
AppAcc, | |
} | |
type Spec<A, B> = { |
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
import { atomWithStorage, createJSONStorage } from "jotai/utils"; | |
const storage = createJSONStorage(() => sessionStorage); | |
export const historyAtom = atomWithStorage( | |
"history", | |
[window.location.href], | |
storage | |
); | |
// will give you access to the history in the component you wish |
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
interface Jsonable { | |
[x: string]: string | number | boolean | Date | Jsonable | Jsonable[]; | |
} | |
// errors that can be discriminated based on a type, | |
// contain a message | |
// and can have context extra info that are serializable to json. | |
interface IdeaError<ErrorType> { | |
type: ErrorType; | |
message: string; | |
extra: Jsonable; |
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
// Better error handling in TS | |
// Exceptions in TS have a few issues: | |
// - they can't be typechecked | |
// - they can't be easily documented (this may fail) | |
// - the "catch" code is usually not colocated to what may fail, adding cognitive load | |
// - it's hard to differentiate between different errors | |
// - they are costly in performance | |
// - they can propagate all the way from the bottom to the top without the intermediate layers to be warned it may fail | |
// - anything can be thrown |
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
useEffect(() => { | |
if (!navigator.serviceWorker) | |
throw new Error("We only support browsers with service workers enabled"); | |
// The trickery below appears to be necessary to register a compiled ServiceWorker with nextjs | |
// Webpack only compiles workers imported via the pattern `new Worker(new URL("script_to_be_compiled"))` | |
// So we need to use that exact expression and have it register a service worker instead | |
const RealWorker = window.Worker; | |
( | |
window as any |
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 DIM = 5; | |
/** | |
* -1-DIM -DIM +1-DIM | |
* -1 i +1 | |
* -1+DIM +DIM +1+DIM | |
*/ | |
const _compute = (m, out) => { | |
for (let x = 1; x < DIM; x++) { | |
for (let y = 1; y < DIM; y++) { |
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 fs = require("fs"); | |
function dateCompress(d) { | |
return d.replace(/\.\d{3}\+\d{2}:\d{2}$/g, "Z"); | |
} | |
function getSize(d) { | |
return Math.ceil(d.length / 1024).toLocaleString() + "kB"; | |
} |
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
thread 'main' panicked at 'assertion failed: `(left == right)` | |
left: `Ok(())`, | |
right: `Err(ERROR_DEVICE_LOST)`', C:\Users\Baptiste\.cargo\git\checkouts\gfx-e86e7f3ebdbc4218\0244e34\src\backend\vulkan\src\lib.rs:1476:9 | |
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace | |
thread 'main' panicked at 'assertion failed: `(left == right)` | |
left: `1`, | |
right: `0`: Allocator dropped before all sets were deallocated', C:\Users\Baptiste\.cargo\git\checkouts\gpu-descriptor-a05b99db0270c787\df74fd8\gpu-descriptor\src\allocator.rs:117:9 | |
stack backtrace: | |
0: 0x7ff7e7edea0e - std::backtrace_rs::backtrace::dbghelp::trace | |
at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca\/library\std\src\..\..\backtrace\src\backtrace\dbghelp.rs:108 |
NewerOlder