Skip to content

Instantly share code, notes, and snippets.

View lafiosca's full-sized avatar
😸
Coding a lot lately

Joe Lafiosca lafiosca

😸
Coding a lot lately
View GitHub Profile
@lafiosca
lafiosca / example.ts
Last active October 12, 2021 18:03
TypeScript 4.4.3 extended mapped types in generic functions
// Approaches 1-3 do not work, yielding errors in each of the functions.
// Approach 4 seems to work.
type MappedWithExtra1<T extends Record<string, unknown>> = {
[K in keyof T]?: string;
} & { extra?: string };
type MappedWithExtra2<T extends Record<string, unknown>> = {
[K in keyof T as K | 'extra']?: string;
};
@lafiosca
lafiosca / x.js
Created March 12, 2021 02:32
try/catch behavior with returned async functions that throw
'use strict';
const x1 = () => {
console.log('x1');
throw new Error('hi');
};
const x2 = async () => {
console.log('x2');
throw new Error('hi again');
@lafiosca
lafiosca / Bitrise and React Native.md
Last active October 17, 2022 15:26
Bitrise and React Native
@lafiosca
lafiosca / Portfile
Last active June 7, 2020 00:15
Installing OpenCBM and nibtools for MacOS Catalina (10.15)
PortSystem 1.0
name nibtools
version 0.5.0
categories emulators
license GPL mBSD
description nibtools disk transfer tools
long_description NIBTOOLS is a disk transfer program designed for copying original disks \
and converting into the G64 and D64 disk image formats. These disk images \
@lafiosca
lafiosca / !code-of-conduct.md
Last active July 1, 2024 20:18
Discord community Code of Conduct and summary messages template

Welcome to the [COMMUNITY NAME] community!

In order to foster a welcoming and inclusive environment for everyone, we ask all members to read and agree to our Code of Conduct when joining. This Code of Conduct is a living document and will be updated from time to time as necessary. The current version can always be found at [LINK]. All changes will be announced in the [#META] channel of our Discord server as they are made. Agreeing to the Code of Conduct implies that you will monitor these changes and revoke your agreement if and when you no longer agree.

Our Pledge

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

@lafiosca
lafiosca / code-of-conduct.md
Last active July 7, 2020 21:05
Rosy Double Cross community Code of Conduct

Welcome to the Rosy Double Cross community!

In order to foster a welcoming and inclusive environment for everyone, we ask all members to read and agree to our Code of Conduct when joining. This Code of Conduct is a living document and will be updated from time to time as necessary. The current version can always be found at this link. All changes will be announced in the #meta channel of our Discord server as they are made. Agreeing to the Code of Conduct implies that you will monitor these changes and revoke your agreement if and when you no longer agree.

Our Pledge

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sex

@lafiosca
lafiosca / deploy-8515.sh
Last active May 7, 2020 03:38
Minimal ATMega8515L STK500 USB-Serial Adapter OSX deployment
#!/bin/bash
set -e
if (( $# != 1 ))
then
echo "Usage: $0 <file.c>"
exit 1
fi
@lafiosca
lafiosca / object-or-null.ts
Created January 17, 2020 00:36
Inconsistent type inference of object or null
const foo = (x: unknown) => { // function(x: unknown): object | null
if (x === null || typeof x !== 'object') {
throw Error();
}
return x;
};
const bar = (x: unknown) => { // function(x: unknown): object
if (typeof x !== 'object' || x === null) {
throw Error();
@lafiosca
lafiosca / any-vs-unknown.ts
Created January 16, 2020 22:01
Type inference with any versus unknown
const foo: any = 42;
if (foo !== undefined && typeof foo !== 'string') {
throw new Error('foo must be a string if defined');
}
console.log(foo); // foo: any
const bar: unknown = 42;
@lafiosca
lafiosca / forwarded-ref-children.tsx
Last active April 14, 2023 11:51
React Native TypeScript children of ForwardRefExoticComponents
import React, {
forwardRef,
FunctionComponent,
PropsWithChildren,
Ref,
} from 'react';
import { View, Text, ViewProps } from 'react-native';
/*
* First we create a simple function component which forwards a View ref: