Skip to content

Instantly share code, notes, and snippets.

@pvaladez
pvaladez / blog-posts.json
Last active July 17, 2025 08:38
Payload CMS Seed Script
{
"blog_posts": [
{
"title": "Why obundle is Your Top Choice for BigCommerce Development",
"content": "In 2024, having a robust and scalable eCommerce platform is essential for business success. obundle, with its deep expertise in BigCommerce development, stands out as a leader in this space. Our team of seasoned developers understands the intricacies of the BigCommerce platform, ensuring that your store is not only functional but also optimized for performance. We offer tailored solutions that cater to your unique business needs, whether you’re a small startup or a large enterprise. With obundle, you’re not just getting a development service; you’re gaining a partner committed to helping your business thrive in the competitive eCommerce landscape.",
"shortDescription": "Discover why obundle is the top choice for BigCommerce development in 2024.",
"thumbnailImage": {
"url": "https://cdn11.bigcommerce.com/s-5unmz/images/stencil/original/image-manager/pexels-www-erzetich-co
@yuvalkarmi
yuvalkarmi / blockNextNavigation.js
Last active April 30, 2024 13:42
How to block a user from navigating away in NextJS when clicking on Link component
/*
In standard web apps, when users navigate away to a different page or website or attempt to refresh a page,
we can use the window event listener `beforeunload` to help users avoid losing the work.
However, when a user clicks on a native NextJS <Link> component, the navigation is not intercepted
because behind the scenes, no page changes are actually happening.
To intercept user navigation in a NextJS app, we can subscribe to the
router routeChangeError event and throw an error.
Note: we must throw an Error string - not a `new Error()` - which is why in the code below, we have
// eslint-disable-next-line no-throw-literal
import SingletonRouter, { Router } from 'next/router';
import { useEffect } from 'react';
const defaultConfirmationDialog = async (msg?: string) => window.confirm(msg);
/**
* Inspiration from: https://stackoverflow.com/a/70759912/2592233
*/
export const useLeavePageConfirmation = (
shouldPreventLeaving: boolean,
@coder054
coder054 / The Y combinator
Created April 5, 2023 03:23
The Y combinator
const Y = (fn) => ((g) => g(g))((g) => fn((x) => g(g)(x)))
const factorialGenerator = (f) => (n) => n === 0 ? 1 : n * f(n - 1)
const factorial = Y(factorialGenerator)
factorial(5) // 120
const sumFromZeroToNGenerator = (f) => (n) => n <= 1 ? n : n + f(n - 1)
const sumFromZeroToN = Y(sumFromZeroToNGenerator)
sumFromZeroToN(5) // 15
@leafac
leafac / init.lua
Created August 25, 2021 14:54
Hammerspoon Snippets
hs.alert("Hammerspoon configuration loaded")
hs.hotkey.bind({"", ""}, "return", function() hs.reload() end)
hs.hotkey.bind({"", ""}, ",",
function() hs.execute([[code ~/.hammerspoon]], true) end)
hs.hotkey.bind({"", ""}, "space", function() hs.toggleConsole() end)
hs.hotkey.bind({"", ""}, "escape", function()
hs.osascript.applescript("beep")
hs.sound.getByName("Submarine"):play()
end)
@bradtraversy
bradtraversy / typescript-crash.ts
Last active July 12, 2025 08:08
Basic intro to TypeScript (From YouTube Crash Course)
// Basic Types
let id: number = 5
let company: string = 'Traversy Media'
let isPublished: boolean = true
let x: any = 'Hello'
let ids: number[] = [1, 2, 3, 4, 5]
let arr: any[] = [1, true, 'Hello']
// Tuple
@markstos
markstos / Corne-3x6-v2,--markstos-layout-_All-Layers_.kbd.json
Last active March 31, 2025 11:28
Corne 3x6 v2, markstos layout (All Layers)
[
{
"name": "Corne 3x6 v2, markstos layout (All Layers)",
"author": "https://github.com/markstos",
"plate": false,
"keyboard-layout-editor": "http://www.keyboard-layout-editor.com/#/gists/adfa7c3cd8f0c6d3a7b9155c6eab1748#file-corne-crkbd_c0psrul3-default-json",
"qmk-config": "https://config.qmk.fm/#/crkbd/rev1/LAYOUT"
},
[
{

nvm Cheatsheet

Check if nvm is installed

command -v nvm

Get currently active version

nvm current -- or -- node -v

@Apsu
Apsu / vimrc
Created April 25, 2021 15:40
Colemak DHm vim remap
noremap f e
noremap p r
noremap b t
noremap j y
noremap l u
noremap u i
noremap y o
noremap ' p
noremap r s
noremap s d
@dungsaga
dungsaga / spleeter.md
Last active February 9, 2025 02:38
Voice removal AKA karaoke creator