Skip to content

Instantly share code, notes, and snippets.

View dac09's full-sized avatar

Daniel Choudhury dac09

View GitHub Profile
@dac09
dac09 / TapePreview.tsx
Created July 22, 2021 12:55
Using canvas to create static gif
import { css } from '@emotion/core'
import { Result } from 'antd'
import { useEffect, useRef } from 'react'
import { ListTapes } from 'types/graphql'
const previewCss = css`
border-radius: 12px;
max-height: 600px;
max-width: 100%;
`
@dac09
dac09 / paramparsing.ts
Last active July 8, 2021 14:22
ParamParsing
type ParamType<constraint> = constraint extends 'Int' ? number : constraint extends 'Boolean' ? boolean : constraint extends 'Float' ? number : string
type RouteParams<Route> = Route extends `${string}/${infer Rest}`
? A.Compute<ParsedParams<Rest>>
: {}
type QueryParams = Record<string | number, string | number | boolean>
type ParsedParams<PartialRoute> =
// {a:Int}/[...moar]
@dac09
dac09 / tailwindClassregex.jsonc
Created June 2, 2021 12:22
Tailwind Classname Autocompletion
"tailwindCSS.experimental.classRegex": [
"tw`([^`]*)", // tw`...`
"tw=\"([^\"]*)", // <div tw="..." />
"tw={\"([^\"}]*)", // <div tw={"..."} />
"tw\\.\\w+`([^`]*)", // tw.xxx`...`
"tw\\(.*?\\)`([^`]*)", // tw(Component)`...`
".*ClassName=\"([^\"]*)", // <div activeClassName="..." />
["class[nN]ames\\(([^)]*)\\)", "'([^']*)'"] // classNames('..', '..')
],
@dac09
dac09 / tsc-output.shell
Last active April 30, 2021 16:28
Prisma Client TSC errors
yarn run v1.22.10
$ /Users/dac09/Projects/prisma-ts-reproduction/node_modules/.bin/tsc
../.redwood/types/routes.d.ts(4,41): error TS1110: Type expected.
../.redwood/types/routes.d.ts(4,61): error TS1005: '}' expected.
../.redwood/types/routes.d.ts(4,66): error TS1128: Declaration or statement expected.
../.redwood/types/routes.d.ts(4,67): error TS1128: Declaration or statement expected.
../.redwood/types/routes.d.ts(4,69): error TS1005: ';' expected.
../.redwood/types/routes.d.ts(4,76): error TS1005: ';' expected.
../.redwood/types/routes.d.ts(4,87): error TS1128: Declaration or statement expected.
../.redwood/types/routes.d.ts(4,167): error TS1005: ';' expected.
@dac09
dac09 / payload.json
Created June 18, 2020 17:12
Braintree Subscription Webhook
{
kind: 'subscription_canceled',
timestamp: '2020-06-18T17:06:03Z',
subject: {
subscription: {
addOns: [],
balance: '0.00',
billingDayOfMonth: 17,
billingPeriodEndDate: '2020-07-16',
billingPeriodStartDate: '2020-06-17',
@dac09
dac09 / rename-xcode.md
Last active July 8, 2018 11:51
Rename Xcode
@dac09
dac09 / floatup.css
Last active March 13, 2018 18:02
Slide in from left, slight off to right | CSSTransitionGroup
.floatUp-enter {
opacity: 0.1;
transform: translate3d(0, 30%, 0);
}
.floatUp-enter.floatUp-enter-active {
opacity: 1;
transform: translate3d(0, 0, 0);
transition: all ease-in-out 400ms;
}
@dac09
dac09 / copyFirebase.sh
Created January 30, 2018 12:39
Bash Case statement for Firebase config
case $CONFIGURATION in
*"Debug"*)
cp -f $SRCROOT/Firebase/staging/GoogleService-Info.plist ${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app;;
*"Release-Staging"*)
cp -f $SRCROOT/Firebase/staging/GoogleService-Info.plist ${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app;;
*"Release-Production"*)
cp -f $SRCROOT/Firebase/prod/GoogleService-Info.plist ${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app;;
esac
@dac09
dac09 / TabbedNavigator.js
Last active January 2, 2018 17:29
HOC With TabNavigator React Navigation
type Props = {
navigation: NavigationScreenProp<*>
};
const TabNavigatorInstance = TabNavigator(tabRouteConfig, tabNavigationConfig);
class TabbedNavigator extends Component<Props> {
// This is required for it to work, somewhat undocumented
// https://github.com/react-navigation/react-navigation/issues/3076
@dac09
dac09 / resolve-externally.js
Created December 28, 2017 12:12
Resolving promise externally
async function showRationaleDialog(title: string, message: string) {
let done;
const result = new Promise(resolve => {
done = resolve;
});
const alert = Alert.alert(title, message, [
{
text: 'OK',
onPress: () => done()