Skip to content

Instantly share code, notes, and snippets.

View theoomoregbee's full-sized avatar
👀

Theophilus Omoregbee theoomoregbee

👀
View GitHub Profile
@gaearon
gaearon / 00-README-NEXT-SPA.md
Last active July 19, 2024 06:35
Next.js SPA example with dynamic client-only routing and static hosting

Next.js client-only SPA example

Made this example to show how to use Next.js router for a 100% SPA (no JS server) app.

You use Next.js router like normally, but don't define getStaticProps and such. Instead you do client-only fetching with swr, react-query, or similar methods.

You can generate HTML fallback for the page if there's something meaningful to show before you "know" the params. (Remember, HTML is static, so it can't respond to dynamic query. But it can be different per route.)

Don't like Next? Here's how to do the same in Gatsby.

@mikermcneil
mikermcneil / is-sails-maintained.md
Last active June 20, 2024 16:57
Is Sails maintained?

Originally posted in sindresorhus/awesome-nodejs#998 (comment)

Just want to clear things up here: the Sails framework is actively maintained and widely used. For context, I am its creator and BDFL. @eashaw is lead maintainer and community manager. @DominusKelvin also maintains an active supplementary community called SailsCasts. https://sailsjs.com/support has a full list of resources you might want to check out. As far as what that means: there's a daily check for vulnerable code paths, a weekly roundup of community GitHub issues/PRs, and active development as needed to fix any priority bugs. This is all funded by Flagship customers and supplemented by my continued personal financial commitment to keep the Sails framework alive.

This will continue for many years to come.

image ![image](https://user-images.githubusercontent.com/618009/108785018-37378000-753

@paulmwatson
paulmwatson / cypress_test_404_spec.js
Created January 14, 2021 08:33
Testing a 404 page with Cypress
cy.visit('/404')
//=> Test fails
cy.visit('/404', {failOnStatusCode: false})
//=> Test passes but does not test the HTTP code was 404
cy.request({url: '/404', failOnStatusCode: false}).its('status').should('equal', 404)
cy.visit('/404', {failOnStatusCode: false})
//=> Test passes, tests that the HTTP code was 404, and tests page was visited
@isocroft
isocroft / detecting_navigation_direction_in_spas.js
Last active July 7, 2023 17:23
Monkey-patch on the History interface
/**
* Algorithm {getNavDirection} created by @isocroft
*
* Copyright (c) 2021-2023 | Ifeora Okechukwu
*
* Works in ReactJS / VueJS / jQuery / Angular / Vanilla
*
* Algo implmented in Javascript: used to determine the direction
* of a single-page app navigation to track "Rage Refreshes" and to
* determine when the user visits a page from the back/forward button
// put markdown files in articles/*.md
// run `node build.mjs`
// upload to a host
import path from "path";
import { promises as fs } from "fs";
import shell from "shelljs";
import cheerio from "cheerio";
import remark from "remark";
import html from "remark-html";
import report from "vfile-reporter";
@jbutko
jbutko / handle-file-download-react-axios.js
Last active July 23, 2024 18:18
React, JS, Axios: Download blob file (PDF...)
import axios, { AxiosResponse } from 'axios';
import { get } from 'lodash-es';
const rest = axios.create({
baseURL: 'some base URL goes here',
});
// this one send file as Blob type
const getPdf = () => (
rest.get(`/get-pdf`, {
@rubencaro
rubencaro / README.md
Last active April 18, 2024 11:47
Python installation guide

Python installation guide

These are my notes, not a generic solution. They are not meant to work anywhere outside my machines. Update version numbers to whatever are the current ones while you do this.

Install asdf and its python plugin, then install Python

asdf lives in https://github.com/asdf-vm/asdf

Follow its installation instructions, which at the moment of writing were:

@t-palmer
t-palmer / polyfills.ts
Last active August 26, 2019 18:43
polyfills file for so Angular can support Internet Explorer
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
// @flow
import { ApolloClient } from 'apollo-client';
import { ApolloLink } from 'apollo-link';
import { HttpLink } from 'apollo-link-http';
import { RetryLink } from 'apollo-link-retry';
import { AuthLink } from './link-auth';
import cache from './cache';
@vktr
vktr / rule.js
Created February 10, 2018 18:54
Add Stripe Customer Id to Auth0 via custom rule
function (user, context, callback) {
user.app_metadata = user.app_metadata || {};
if ('stripe_customer_id' in user.app_metadata) {
context.idToken['https://example.com/stripe_customer_id'] = user.app_metadata.stripe_customer_id;
return callback(null, user, context);
}
var stripe = require('stripe')('sk_....');
var customer = {