Skip to content

Instantly share code, notes, and snippets.

View mbeaudru's full-sized avatar

Manuel Beaudru mbeaudru

View GitHub Profile
@Geczy
Geczy / migrate.sh
Last active November 14, 2024 14:25
Migrate Coolify to a new server
#!/bin/bash
# This script will backup your Coolify instance and move everything to a new server. Docker volumes, Coolify database, and ssh keys
# 1. Script must run on the source server
# 2. Have all the containers running that you want to migrate
# Configuration - Modify as needed
sshKeyPath="$HOME/.ssh/your_private_key" # Key to destination server
destinationHost="server.example.com"
@antfu
antfu / doc-table.md
Last active October 14, 2023 20:09
Doc Table in Markdown

Example

Name

Description


@gvergnaud
gvergnaud / typescript-type-variance.ts
Last active August 30, 2022 15:52
TypeScript type variance (covariance, contravariance and invariance)
/**
* We call "variance" the direction of assignability between two types
* (in other words, which type is a subtype of the other).
*
* The same type can have a different variance in function of his position
* in a larger type, and this is what makes assignability in TypeScript
* not always straightforwards.
*
* There are 4 kinds of variance:
* - Covariant: if the type `a` is assignable to `a | b`.
@viclafouch
viclafouch / designMode.js
Last active January 25, 2024 14:21
Edit your website in live by using `document.designMode` and killing links
// Disable anchor links
window.addEventListener('click', event => event.preventDefault(), false)
// Disable click eventlisteners
window.addEventListener("click", event => event.stopPropagation(), true)
// Enable design mode
document.designMode = "on"
@jioo
jioo / share-git-stash.md
Last active September 25, 2024 16:06
How to export stash as a file, and apply it to another computer

Stash current changes

  • git > Stash > Stash (Include Untracked)

Create stash as patch

git stash show "stash@{0}" -p > changes.patch

Apply patch

@florapdx
florapdx / react-conf-2019.md
Last active November 6, 2019 02:40
My extremely biased and non-exhaustive list of React Conf 2019 notes/takeaways :)

Thought I'd post my React Conf notes here for anyone who is interested!

  • New! Prerelease channels: In order to support other library and framework devs, and to enlist early feedback, the React team is debuting 3 new prerelease channels: Latest (stable), Next (on-deck for stable release, but doesn't adhere to semver and may intro breaking changes), and Experimental (caution! likely to contain large and breaking changes). Latest is the only channel recommended for user-facing applications.

  • New! Experimental release of Concurrent Mode: Concurrent Mode supports interruptible rendering, including suspending render in components whose data has not yet returned (Suspense API). I got a glimpse of SuspenseList in action in the context of rendering a list of photos from a remote source and it was pretty neat - I think there's a lot to be excited for here, especially for mobi

@ryandabler
ryandabler / Proxy.js
Last active November 30, 2020 00:24
Complete example of proxying an array for this article: https://itnext.io/meta-programming-in-javascript-with-proxies-64fa4898070e
const db = [
{
name: 'John Doe',
age: 28,
lastModified: Date.now(),
lastAccessed: Date.now()
},
{
name: 'Jane Smith',
age: 30,
@clarkbw
clarkbw / redux-performance-mark.js
Last active February 8, 2024 05:03
A User Timing middleware for redux to create performance markers for dispatched actions
const timing = store => next => action => {
performance.mark(`${action.type}_start`);
let result = next(action);
performance.mark(`${action.type}_end`);
performance.measure(
`${action.type}`,
`${action.type}_start`,
`${action.type}_end`
);
return result;
@gauntface
gauntface / sw-test-cleaup.js
Last active April 22, 2024 05:02
Function to unregister SW and clear out old caches.
window.__testCleanup = () => {
const unregisterSW = () => {
return navigator.serviceWorker.getRegistrations()
.then((registrations) => {
const unregisterPromise = registrations.map((registration) => {
return registration.unregister();
});
return Promise.all(unregisterPromise);
});
};
@gnarf
gnarf / auto-readme-real-source.js
Last active February 18, 2019 10:39
An example of how to use storybook-addon-info with real source files and readme support
const storyFiles = require.context('../src', true, /__stories__\/.+\.js$/)
const sources = require.context('!!raw-loader!../src', true,
/__stories__\/.+\.js$/)
const readme = require.context('!!raw-loader!../src', true, /README\.md$/)
const READMES = readme.keys().reduce((memo, key) => {
const [,baseName] = key.match(/^\.\/([^\/]+)\//)
memo[baseName] = readme(key)
return memo
}, {})