Skip to content

Instantly share code, notes, and snippets.

View telesma's full-sized avatar

Frank Rossi telesma

View GitHub Profile
@gaearon
gaearon / 00-README-NEXT-SPA.md
Last active October 14, 2024 00:05
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.

@danpetitt
danpetitt / esmodules.md
Last active November 12, 2024 13:11
Typescript, Jest and ECMAScript Modules

Typescript, Jest and ECMAScript Modules (ESM)

Package.json

Add the type property to package.json to ensure modules are supported:

{
  "type": "module",
}
@rmorse
rmorse / react-router-dom-v.6.02.prompt.blocker.js
Last active November 13, 2024 16:02
Adds back in `useBlocker` and `usePrompt` to `react-router-dom` version 6.0.2 (they removed after the 6.0.0 beta, temporarily)
/**
* These hooks re-implement the now removed useBlocker and usePrompt hooks in 'react-router-dom'.
* Thanks for the idea @piecyk https://github.com/remix-run/react-router/issues/8139#issuecomment-953816315
* Source: https://github.com/remix-run/react-router/commit/256cad70d3fd4500b1abcfea66f3ee622fb90874#diff-b60f1a2d4276b2a605c05e19816634111de2e8a4186fe9dd7de8e344b65ed4d3L344-L381
*/
import { useContext, useEffect, useCallback } from 'react';
import { UNSAFE_NavigationContext as NavigationContext } from 'react-router-dom';
/**
* Blocks all navigation attempts. This is useful for preventing the page from
* changing until some condition is met, like saving form data.
@smarr
smarr / fib.S
Created November 6, 2019 14:13
8-bit implementation of a recursive fibonacci
; Fibonacci
; executable with https://schweigi.github.io/assembler-simulator/
; Result is in register A
JMP .start
; fib(n) <- n is in register A
fib:
CMP A, 1 ; compare n to a
JE .fibReturnOne
JB .fibReturnZero
@fisshy
fisshy / bitbucket-pipelines.yml
Last active August 26, 2017 11:24
Bitbucket pipline for FTP Publishing.
# This is a sample build configuration for Javascript (Node.js).
# Check our guides at https://confluence.atlassian.com/x/14UWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: node:7.8.0
pipelines:
default:
- step:
@tonytonyjan
tonytonyjan / 1-README.md
Last active June 21, 2023 06:14
Remote React Components Loading
var {handleResponse} = require('.utils')
var {setErrorMessages} = require('./messages')
var CHECK_TOKEN = 'auth/CHECK_TOKEN'
var CHECK_TOKEN_FAILURE = 'auth/CHECK_TOKEN_FAILURE'
var CHECK_TOKEN_SUCCESS = 'auth/CHECK_TOKEN_SUCCESS'
var LOGIN = 'auth/LOGIN'
var LOGIN_FAILURE = 'auth/LOGIN_FAILURE'
@joshangell
joshangell / default.vcl
Last active January 5, 2022 11:35
Varnish config for Craft
# Varnish 4.0 configuration for Craft
#
# Based on the following:
# - https://github.com/mattiasgeniar/varnish-4.0-configuration-templates/blob/master/default.vcl
# - https://gist.github.com/aelvan/eba03969f91c1bd51c40
vcl 4.0;
import std;
import directors;
@bryandugan
bryandugan / Craft CMS SEO Meta.twig
Last active October 9, 2022 15:21
Craft CMS SEO Meta Tags
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/png" href="{{ siteUrl }}favicon.png">
<title>{% if homeTitle is defined %}{{ siteName }} | {{ entry.homeTitle }}{% elseif entry.title is defined %}{{ entry.title }} | {{ siteName }}{% else %}{{ title }} | {{ siteName }}{% endif %}</title>
<link rel="stylesheet" href="{{ siteUrl }}assets/css/app.css" />
<script src="{{ siteUrl }}assets/bower_components/modernizr/modernizr.js"></script>
<!-- General Page Meta -->
{% if entry.seoDescription is defined %}
{% if entry.seoDescription is not empty %}
@bradoyler
bradoyler / inview.js
Created April 2, 2015 02:38
inview jquery plugin
// based on the idea of Remy Sharp, http://remysharp.com/2009/01/26/element-in-view-event-plugin/
(function ($) {
var inviewObjects = {}, viewportSize, viewportOffset,
d = document, w = window, documentElement = d.documentElement, expando = $.expando, timer;
$.event.special.inview = {
add: function(data) {
inviewObjects[data.guid + "-" + this[expando]] = { data: data, $element: $(this) };