Skip to content

Instantly share code, notes, and snippets.

View itsdouges's full-sized avatar

Michael Dougall itsdouges

  • Atlassian
  • Sydney, Australia
  • 12:23 (UTC +10:00)
  • X @itsdouges
View GitHub Profile
@itsdouges
itsdouges / importit.sh
Last active May 29, 2023 03:32
How to get Shipit sync working https://github.com/adeira/shipit
# Run this when wanting to import a pr into your repo
# You run it locally from your main branch and then it'll check out a branch locally and sync the commit keeping author/email.
# You then push up and merge whenever then it'll sync to your public repo.
npx monorepo-importit --committer-name=A --committer-email=B --pull-request=https://github.com/adeira/js/pull/1
Michael Dougall
Software Grant and Corporate Contributor License Agreement (“Agreement”)
In order to clarify the intellectual property license granted with Contributions from any person or entity, Michael Dougall must have a Contributor License Agreement ("CLA") on file that has been signed by each Contributor, indicating agreement to the license terms below. This license is for your protection as a Contributor as well as the protection of Michael Dougall; it does not change your rights to use your own Contributions for any other purpose.
You accept and agree to the following terms and conditions for Your present and future Contributions submitted to Michael Dougall. Except for the license granted herein to Michael Dougall and recipients of software distributed by Michael Dougall, You reserve all right, title, and interest in and to Your Contributions.
Definitions.
"You" (or "Your") shall mean the copyright owner or legal entity authorized by the copyright owner that is making this Agreement with
import Cylinder from "@/cylinder";
import Box from "src/box";
import { RoundedBox } from "@react-three/drei";
import Sphere from "./sphere";
export function SceneAlt() {
return (
<>
<Box />
</>
@itsdouges
itsdouges / backend.ts
Created November 29, 2022 05:15
Proof-of-concept r3f editor
import { Application, Router, RouterContext } from 'https://deno.land/x/oak@v11.1.0/mod.ts';
import {
JsxAttributeLike,
Project,
SyntaxKind,
SourceFile,
ts,
Type,
JsxSelfClosingElement,
JsxOpeningElement,
@itsdouges
itsdouges / cascaded-shadow-map.tsx
Created November 16, 2022 23:17
Cascaded Shadow Maps for React Three Fiber
import { useFrame, useThree } from '@react-three/fiber';
import { useLayoutEffect, useMemo } from 'react';
import { Camera, Vector3, Vector3Tuple } from 'three';
import CSM, { Params } from 'three-csm';
interface CascadedShadowMapProps extends Omit<Params, 'lightDirection' | 'camera' | 'parent'> {
fade?: boolean;
lightDirection?: Vector3Tuple;
}
@itsdouges
itsdouges / forward-ref-with-jsx-generic.tsx
Last active March 20, 2020 10:01
This is some bullshit
// Dirty hack to get generics working with forward ref [1/2]
interface CustomItemType {
<TComponentProps extends {}>(
props: CustomItemProps<TComponentProps> & { ref?: any } & Omit<
TComponentProps,
keyof CustomItemComponentProps
>,
): JSX.Element | null;
}
@itsdouges
itsdouges / resizer.js
Created September 18, 2019 12:41
Resize an element when it changes size using CSS only
import { Component, ReactNode, Ref, createRef } from 'react';
export class ResizingContainer extends Component {
childRef = createRef();
getSnapshotBeforeUpdate() {
if (!this.childRef.current) {
return null;
}
@itsdouges
itsdouges / listen.tsx
Created October 21, 2018 22:06
Listen to multiple document events in one call, with one call to cleanup.
export const listenTo = <K extends keyof DocumentEventMap>(
type: K | K[],
listener: (this: Document, ev: DocumentEventMap[K]) => any,
options?: boolean | AddEventListenerOptions
) => {
if (Array.isArray(type)) {
type.forEach(typ => {
document.addEventListener(typ, listener, options);
});
@itsdouges
itsdouges / hoc-wrapping-component-with-default-props.tsx
Last active January 27, 2020 19:49
Passing default props info through a HOC using TypeScript 3.1.x
import * as React from 'react';
type Omit<T, K extends keyof any> = T extends any ? Pick<T, Exclude<keyof T, K>> : never;
type ExtractProps<TComponentOrTProps> = TComponentOrTProps extends React.ComponentType<
infer P
>
? P
: never;
interface InjectedProps {