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/sh | |
set -e | |
function build_raylib_macos { | |
curr_dir="$(basename $(pwd))" | |
if [[ "$curr_dir" != "src" ]]; | |
then |
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
.global _start | |
.align 2 | |
.text | |
;;; COMPILE and RUN CMD: | |
;;; as -o hello.o hello.s && ld -macos_version_min 14.0.0 -o hello.bin hello.o -e _start -arch arm64 && ./hello.bin | |
;;; | |
;;; EXTRACT FLAT (PURE) BINARY: | |
;;; 1. otool -l hello.bin and search for sectname __text > offset field (it's in decimal not hex btw) | |
;;; 1a. Take the offset, convert to hex and verify code starts there in the hexdump view of the compiled binary |
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 type { Directive } from "vue"; | |
type ClickOutsideHandler = ($event: MouseEvent | TouchEvent) => void; | |
type ClickOutsideHandlerMap = Map<HTMLElement, ClickOutsideHandler> & { | |
initialized?: boolean; | |
}; | |
const clickOutsideHandlersSymbol: symbol = Symbol.for("v-click-outside-handlers"); | |
// @ts-ignore |
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
/** | |
* Fail jest test run if certain messages are logged to console (e.g., `[vuex warn] unknown getter: ....`) | |
* Conditionally (on CI or not) add this file and the file below to `setupFilesAfterEnv` in jest config. | |
* | |
* Example config: | |
* | |
* import type { Config } from "@jest/types" | |
* | |
* const config: Config.InitialOptions = { | |
* ... |
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
export async function timed<T>( | |
cb: () => Promise<T>, | |
message: string, | |
debug = (...args: any[]) => console.warn(...args), | |
): ReturnType<typeof cb> { | |
const start = performance.now(); | |
const result = await cb(); | |
const end = performance.now(); | |
let timeSpent = end - start; |
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
type MixedObject = { | |
someFn(x: number): string | |
someProp: symbol | |
} | |
// using key remapping that was added in TS 4.1 wherein | |
// if we return `never` as a value for key in the remapping logic | |
// the key is dropped from the resulting type | |
// More: https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#key-remapping-via-as | |
type Filter<InputType, AllowedValueTypes> = { |
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 assert(cond, msg) { | |
if (!cond) throw new Error(msg) | |
} | |
function doSet(source, pathToSet, newValue) { | |
assert(Array.isArray(pathToSet), 'path being set needs to be given as an array of prop names in order of access') | |
const prop = pathToSet.shift() | |
if (typeof prop === 'undefined') { |
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 createProxyHandler() { | |
const handler = { | |
get(target, prop, receiver) { | |
console.log('get>', target, prop, receiver) | |
if (prop === '_isProxy') { | |
return true | |
} | |
const value = Reflect.get(target, prop, receiver) |
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 workingHoursSchema = yup | |
.object() | |
.shape( | |
{ | |
startHour: yup.number().when(["startMinute", "endHour", "endMinute"], { | |
is: (...args: string[]) => args.reduce((acc, v) => !!v || acc, false as boolean), // really typescript :| | |
then: yup | |
.number() | |
.integer() | |
.min(0) |
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 assertArray(v) { | |
if (!Array.isArray(v)) { | |
throw new TypeError(`Expected ${v} to be an array`) | |
} | |
return true | |
} | |
function hasSequence(data, seq) { | |
assertArray(data) | |
assertArray(seq) |
NewerOlder