Skip to content

Instantly share code, notes, and snippets.

Avatar

Mike Frawley ratbeard

View GitHub Profile
View gist:9adfd986ae4eec17f9ec091aea800b5d
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:launchpad.xxx.us</string>
<string>applinks:launchpad.xxx.us</string>
<string>applinks:launchpad.xxx.com</string>
</array>
View 👩🏻‍🍳.ts
//a
<SectionsEditor
assetState={assetState}
dispatchToAssetState={dispatchToAssetState}
key={index}
section={section}
sectionIndex={index}
canAddSection={canAddSection}
canMoveSection={canMoveSection}
canRemoveSection={canRemoveSection}
View new-hotness.js
{
"logoUrl": "https://s3.amazonaws.com/playbook-us/public/images/scrimmage-logo-dark.svg",
"background": "purple linear-gradient(125deg, #194795, #0C2652)",
"textColor": "#232323",
"actionColor": "#0073FF",
"buttonBackground": "#0073FF",
"buttonColor": "#ffffff"
}
View compact.ts
type Falsey = undefined | null | 0 | false | '';
/** Returns a new array with falsey values removed */
export function compact<T>(array: (T | Falsey)[]): T[] {
// .ts is not smart enough about filter()
return array.filter(item => !!item) as T[];
}
View figments of our imagintation.ts
// https://stackoverflow.com/questions/46641380/exhaustive-map-over-a-union-of-typed-objects
// https://www.typescriptlang.org/docs/handbook/advanced-types.html
export function getInteractiveSection2({ question }: {
question: Question;
}) {
switch(question.type) {
case 'multiple-choice':
return <ChoicesSection {...buildItChoice({ question })} />;
case 'fill-in-the-blank':
View myst.ts
/*
griz asks:
something I didn't get
question isn't in the object passed in, and the order of the args doesn't match
seems like that'd be a type error?
*/
export function MatchingQuestion({ onSelectChoice, onBreakMatch, questionState }: {
View da.test.tsx
import { typeSwitch } from './typeSwitch';
interface Circle {
type: 'circle';
radius: number;
}
interface Square {
type: 'square';
width: number;
}
type Shape = Circle | Square;
@ratbeard
ratbeard / hardships.ts
Last active Feb 14, 2019
So many options in life…
View hardships.ts
// X)
it('JUST works', () => {
let result = appendQueryParams('rat.com', { a: 1, b: 'cool' })
expect(result).toEqual('rat.com?a=1&b=cool')
])
// Y)
it('JUST works', () => {
expect(
appendQueryParams('rat.com', { a: 1, b: 'cool' })
View huh?.tx
export function buildSequenceItem({ activity, baseUrl, sequenceItem }: {
activity: Activity,
baseUrl: string,
sequenceItem: SequenceItem,
}): SequenceItemUI {
}
export function buildQuestionPool(
View x.tsx
export function Logo({ src }: {
src: string,
}) {
return ifPresent(src, (
<div className='web-activity-header-logo'>
<img src={src} className='web-activity-header-img' />
</div>
));
}