Skip to content

Instantly share code, notes, and snippets.

View msutkowski's full-sized avatar

Matt Sutkowski msutkowski

View GitHub Profile
@msutkowski
msutkowski / index.ts
Last active September 12, 2022 22:24
an itty-router-based request logger.
/**
* mkdir webhook-tester && cd webhook-tester;npm i -g wrangler;wrangler init
* hit y 3 times
* npm i -D itty-router itty-router-extras @types/itty-router-extras
*
* copy and paste the below into src/index.ts
*
* start the dev server, immediately go into local mode;
* wrangler dev --local
*
async function prepare() {
// @ts-ignore
if (typeof Cypress !== 'undefined') {
const { worker } = require('./mocks/browser');
return worker.start({ onUnhandledRequest: 'warn' });
}
}
@msutkowski
msutkowski / notes-on-react-server-component.md
Last active September 26, 2021 10:49
Notes on the React Server Components Demo

Introducing Zero-Bundle-Size React Server Components

Notes

The whole experience is based around the client sending GET requests to the server at /react?location= (props are serialized as params)

  •   app.get('/react', function(req, res) {
        sendResponse(req, res, null);
      });
### Recipes for typing createAsyncThunk
// Typing with Generics
const withGenerics = createAsyncThunk<
{ banana: string },
string,
{ state: RootState }
>('test/usingGenerics', (arg, { getState }) => {
const { test } = getState()
return {
@msutkowski
msutkowski / gist:5110685
Created March 7, 2013 18:53
Will dynamically return a predetermined offset based on the window size for the affix plugin
var adjustAffixOffset = (function() {
var $stickyItem = $('.stickyform'),
defaultOffsetValue = 220,
init = function() {
changeOffsetValue();
initAffixEvent();
initAffixPlugin();
initAffixResize();
},