Skip to content

Instantly share code, notes, and snippets.

View joedooley's full-sized avatar

Joe Dooley joedooley

  • Florida
  • 03:54 (UTC -04:00)
View GitHub Profile
@joedooley
joedooley / _middleware.ts
Created August 2, 2022 15:42 — forked from alexjtupper/_middleware.ts
@auth0-nextjs getSession compatible with Next.js Edge Runtime (middleware)
import { getSession } from './getMiddlewareSession';
import { NextMiddleware } from 'next/server';
const middleware: NextMiddleware = async (req, event) => {
try {
let session = await getSession(req)
console.log(session.user.name)
} catch (err) {
console.error(err)
}
@sindresorhus
sindresorhus / esm-package.md
Last active April 26, 2024 03:53
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@nikasepiskveradze
nikasepiskveradze / http.ts
Created January 8, 2021 17:06
Http client example with TS and RXJs
import {Observable, of} from "rxjs";
import {catchError, map} from "rxjs/operators";
import {ajax} from "rxjs/ajax";
class Http {
public get<T extends Object = Object>(url: string, headers?: any): Observable<T> {
return ajax.get.apply(undefined, [`${url}`, headers]).pipe(catchError(this.catchError), map(this.map));
}
public post<T extends Object = Object>(url: string, body?: any, headers?: any): Observable<T> {
@nvbn
nvbn / App.js
Last active August 29, 2023 13:39
Hooks with classes
import React from "react";
import Counter from "./Counter";
const App = () => {
return (
<div className="App">
<Counter initialCount={100} />
</div>
);
};
@OliverJAsh
OliverJAsh / README.md
Last active February 24, 2022 05:26
Flexbox gutters

Flexbox gutters

Problem

  • We use flexbox for our layout.
  • We want to add horizontal and vertical gutters inbetween these items.
  • Items wrap according to contents (flex-wrap: wrap), therefore we can't decide when/where to apply gutters using breakpoints.

Solution

@Integralist
Integralist / Go Guru.md
Last active June 28, 2022 12:05
[Go Guru and Vim-Go] #go #golang #guru #interfaces #vim #vim-go

Go Guru

See official doc: Using Go Guru

go get golang.org/x/tools/cmd/guru
guru -help

Guru command line usage:

@cecilemuller
cecilemuller / 2019-https-localhost.md
Last active April 26, 2024 03:07
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

@sebmarkbage
sebmarkbage / The Rules.md
Last active April 22, 2024 04:41
The Rules of React

The Rules of React

All libraries have subtle rules that you have to follow for them to work well. Often these are implied and undocumented rules that you have to learn as you go. This is an attempt to document the rules of React renders. Ideally a type system could enforce it.

What Functions Are "Pure"?

A number of methods in React are assumed to be "pure".

On classes that's the constructor, getDerivedStateFromProps, shouldComponentUpdate and render.

@Geoff-Ford
Geoff-Ford / composing-software.md
Last active March 3, 2024 08:48
Eric Elliott's Composing Software Series

Eric Elliott's "Composing Software" Series

A collection of links to the excellent "Composing Software" series of medium stories by Eric Elliott.

Edit: I see that each post in the series now has index, previous and next links. However, they don't follow a linear flow through all the articles with some pointing back to previous posts effectively locking you in a loop.

@zackkatz
zackkatz / gravityforms-modify-value-after-update.php
Created August 14, 2017 20:41
Gravity Forms - Modify field value after updating in Gravity Forms OR GravityView
<?php
/**
* Modify a field value after updating an entry
*
* @param array $form Gravity Forms form object
* @param int $entry_id ID of the entry that was updated
* @param array $original_entry Original entry object, before update
*
* @return void