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 / tvgamejam.p8
Last active February 2, 2019 16:33
TV Game Jam title card for PICO-8
pico-8 cartridge // http://www.pico-8.com
version 16
__lua__
-- displays a TV Game Jam title card
-- using code from dw817: https://www.lexaloffle.com/bbs/?tid=31725
function titlecard()
cls()
bit6to8("/a]a.p.adp.q.q.q.adadp.a/a=..p.quu[3{v1@y@y/bk.{3#y@y@[v{3wuuad/az..pduu3{@y#/by.3{3#y@[3wuea/am..py]/b9.3{yva/ah..px/bw.{3]/bm.3{3#e/ah..{/b@.3{a/af..6/bl.3{3#/bh.3{3]3{3{3#3{3{y/bd.{3]/bf.3{3#a.....t{3{y/bd.{3{y{3{3]3{3{3w.qdqtuuuuuw3y{3wg-3{3{3{uq5{3{3]/bd.3{3#3{3#3{y{3{3wa....6/bd.3{y/bh.{3/al..p2#e..]3{3{3w.px{3{3{3#3{3{3]3{3]3{3{3{y{3m.....]3{3{3#3{3]3]3{y{3{3{3]3{e/al..[e...d{3]y{y...x{3{3]/bd.3{y{3{3{3]3{3{y.....+{y{3{y{3{3{3#3{3{3#3]3{3w/al..tg....x{3{3wa...+{y{3{3{y{3]/bf.3{3wc....63{3#/be.3{3]/bd.3{3/am..2f...p3{3{3....p5/bl.{3f.....<3{3{3{3]3]3{3{3{3]3{3]3{uqep.a.a.qdud-3a...~3{3wc...d{3{3{3#3{3{3{y{3#3{3{3]3{y.....x{3]3{3{3{3#3{3{3]3{3{3]3{3{3wa....]3{3{y....<3{3..a.p5/bf.{3{y/be.{3wc....p5/bf.{3]3{3{3]/bd.3{3a...p3{3{3{u....{3wc....]3{3{y{3{3]3{3{3{3]3{3{3{3f.....]3{3]3{y/bj.{3{e....-3{3{3{a
@lafiosca
lafiosca / App.js
Created September 25, 2019 19:45
Swipe card overlap problem reproduction
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React from 'react';
import {
@lafiosca
lafiosca / test.sql
Created October 23, 2019 17:48
MySQL: multiple foreign keys referencing same parent field, where one is or is not part of child table's primary key
CREATE TABLE `parent` (
`id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE `child` (
`id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '',
`parent1Id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
`parent2Id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
PRIMARY KEY (`id`, `parent1Id`), -- parent field foreign key is part of child primary key
@lafiosca
lafiosca / AmplifyCommunityAsyncStorage.ts
Created November 6, 2019 01:12
TypeScript Amplify Auth storage module for pre-emptive upgrade to @react-native-community/async-storage
import AsyncStorage from '@react-native-community/async-storage';
const memoryKeyPrefix = '@MemoryStorage:';
interface MemoryData {
[key: string]: string;
}
export default class AmplifyCommunityAsyncStorage {
static memoryData: MemoryData = {};
@lafiosca
lafiosca / migrations.ts
Last active November 15, 2019 21:31
redux-persist TypeScript migrations example
interface RootStateV0 {
a: {
b: number;
};
d: {
e: number;
};
}
@lafiosca
lafiosca / persistMigration.ts
Last active February 13, 2024 03:42
redux-persist migrations in TypeScript with a little help from patch-package
import { createMigrate } from 'redux-persist';
import { RootState } from './modules/reducer';
/*
* Latest version (V3) is simply the currently used redux RootState.
*/
type PersistedRootStateV3 = RootState;
/*
@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:
@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 / 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 / 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