Skip to content

Instantly share code, notes, and snippets.

View amogower's full-sized avatar

andy g amogower

View GitHub Profile
# Swift Language Fundamentals
Swift is a modern programming language for Apple platforms (iOS, macOS, etc.) with these key characteristics:
1. Core Features:
- Type inference for automatic type detection
- Optionals for safe handling of missing values
- Closures for flexible function passing
- Memory safety by design
- Built-in error handling
@mikeslattery
mikeslattery / .idea-lazy.vim
Last active May 15, 2025 20:30
LazyVim mappings for Jetbrains IDEs
" ~/.idea-lazy.vim
" LazyVim mappings for Jetbrains IDEs
" Required plugins. https://plugins.jetbrains.com/bundles/7-ideavim-bundle
" IDEAVim
" Which-Key
" IdeaVim-Sneak
" To install, add this to the top of your ~/.ideavimrc:
@tangentstorm
tangentstorm / sh.mts
Last active May 14, 2025 20:29
sh.mts: javascript shorthand (mostly for web/dom stuff)
// sh.mts: javascript shorthand
// #region array tools
/** id function (returns first argument) */
export const id=<T,>(x: T): T=>x
/** create an array filled with n copies of x */
export const af=<T,>(n: number, x: T): T[]=>Array(n).fill(x) // TODO: make this 'afl' or 'fil' (aa?)
/** loop i from 0..n, calling f(i) */
export const ii=(n: number, f: (i: number)=>void)=>{for(let i=0;i<n;i++)f(i)}
/** map f over [0..n] */
@khalidx
khalidx / node-typescript-esm.md
Last active April 15, 2025 14:15
A Node + TypeScript + ts-node + ESM experience that works.

The experience of using Node.JS with TypeScript, ts-node, and ESM is horrible.

There are countless guides of how to integrate them, but none of them seem to work.

Here's what worked for me.

Just add the following files and run npm run dev. You'll be good to go!

package.json

@kconner
kconner / macOS Internals.md
Last active May 15, 2025 02:32
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

@GeordieP
GeordieP / setup-nvim-leptos-lsp.md
Last active February 8, 2025 12:36
in the leptos-start example project, neovim will mark the SSR main function as dead code.

Problem:

in the leptos-start example project, neovim will mark the SSR main function as dead code:

image

the rust-analyzer LSP client inside nvim thinks the SSR flag is disabled by default.

Fix:

export const chaosTestStrings = (): void => {
const textNodes = getAllTextNodes(document.body);
for (const node of textNodes) {
const textNodeLength = node.textContent ? node.textContent.length : 0;
if (node.textContent === null) {
return;
}
if (node.parentElement instanceof Element) {
if (node.parentElement.dataset.originalText === undefined) {
@raphael-leger
raphael-leger / lazyWithRetry.js
Last active July 30, 2024 08:46
React LazyWithRetry
import { lazy } from 'react';
const lazyWithRetry = (componentImport) =>
lazy(async () => {
const pageHasAlreadyBeenForceRefreshed = JSON.parse(
window.localStorage.getItem(
'page-has-been-force-refreshed'
) || 'false'
);
@sindresorhus
sindresorhus / esm-package.md
Last active May 14, 2025 06:52
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@kaushikgopal
kaushikgopal / karabiner.edn
Last active May 16, 2024 00:57
My source Karabiner file in Goku's edn format - Now lives @ https://github.com/kaushikgopal/dotfiles/blob/master/.karabiner.edn
;; File has moved over to https://github.com/kaushikgopal/dotfiles/blob/master/.karabiner.edn
;; Feel free to raise github issues in that repo, if you have questions/comments/edits