Skip to content

Instantly share code, notes, and snippets.

View 342b45's full-sized avatar
🖤

#342b45 342b45

🖤
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.

@omar2205
omar2205 / PgDriver.ts
Last active April 4, 2024 20:13
Deno + Kysely + Postgres
import { Client } from 'postgres'
import { CompiledQuery, DatabaseConnection, Driver, QueryResult, TransactionSettings } from 'kysely'
type QueryArguments = unknown[] | Record<string, unknown>
export class PostgresDriver implements Driver {
readonly #connectionMutex = new ConnectionMutex()
@karlhadwen
karlhadwen / .zshrc
Last active April 12, 2024 01:56
.zshrc settings
export ZSH="/Users/karlhadwen/.oh-my-zsh"
export PATH=${PATH}:/usr/local/mysql/bin/
ZSH_THEME="robbyrussell"
ZSH_DISABLE_COMPFIX=true
plugins=(
git
zsh-autosuggestions
last-working-dir
@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active November 17, 2024 14:13
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@P403n1x87
P403n1x87 / blighty_spotify
Last active July 30, 2022 11:36
A simple Spotify widget written in Python for Blighty to celebrate the 1k download mark.
#!/usr/bin/env python
"""
This file is part of "blighty" which is released under GPL.
See file LICENCE or go to http://www.gnu.org/licenses/ for full license
details.
blighty is a desktop widget creation and management library for Python 3.
@chrisveness
chrisveness / crypto-pbkdf2.js
Last active October 25, 2024 21:03
Uses the SubtleCrypto interface of the Web Cryptography API to hash a password using PBKDF2, and validate a stored password hash against a subsequently supplied password. Note that both bcrypt and scrypt offer better defence against ASIC/GPU attacks, but are not available within WebCrypto.
/**
* Returns PBKDF2 derived key from supplied password.
*
* Stored key can subsequently be used to verify that a password matches the original password used
* to derive the key, using pbkdf2Verify().
*
* @param {String} password - Password to be hashed using key derivation function.
* @param {Number} [iterations=1e6] - Number of iterations of HMAC function to apply.
* @returns {String} Derived key as base64 string.
*
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active November 19, 2024 10:49
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname