Skip to content

Instantly share code, notes, and snippets.

// Define a trait function to that expects behavior to convert a value to type T
trait fun to<T>(): T
// So you want to require a property? Use a trait getter!
trait fun(get) displayName: String
// You can define a tuple type with parenthesis
tuple Name (String, String) {
|(first, last)| impl fun to<String>() = "${first} ${last}"
@april
april / find-all-electron-versions.sh
Last active November 16, 2024 19:07
find all apps using Electron and their versions, on macOS systems
# latest supported electron version as of october 2024
LATEST_SUPPORTED_VERSION=30
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # no color
mdfind "kind:app" 2>/dev/null | sort -u | while read app;
do
filename="$app/Contents/Frameworks/Electron Framework.framework/Electron Framework"
if [[ -f $filename ]]; then
@jeremiah-snee-openx
jeremiah-snee-openx / cSpell-Package-Dictionary.md
Last active May 17, 2023 15:16
cSpell Package Dictionary Generator

Code To Generate cSpell Dictionary from package.json

Makefile

cSpell:
  cat package.json | jq -r '.devDependencies, .dependencies | keys_unsorted | map(gsub("@"; "")) | map(split("/")) | flatten | unique[]' > ./.vscode/packages.txt

./.vscode/settings.json

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

@basarat
basarat / script.md
Created March 13, 2023 06:02
Promise Fulfilled vs Resolved

Notice that we’ve been using the term, fulfilled instead of resolved, and the reason is that a promise can be resolved to another promise and which point its fate becomes dependent on the other promise. If the other promise gets fulfilled our promise gets fulfilled, if the other promise is rejected, our promise gets rejected.

Both alpha and beta are resolved, but they settle to different fates. Alpha gets fulfilled, Beta gets rejected.

const delayFulfill =
  () => new Promise(
    res => setTimeout(() => res('fulfilled'), 1000)
 );
@markerikson
markerikson / react-data-fetching-lib-notes-2023-02-16.md
Last active May 15, 2023 11:04
React Data Fetching Library Summit notes - 2023-02-16

React Data Fetching Library Summit - 2023-02-16

Attendees

  • Lenz Weber-Tronic
  • Dominik Dorfmeister
  • Fredrik Hoglund
  • Jerel Miller
  • Alessia Bellisario
  • Andrew Clark
@JohannesMP
JohannesMP / EnableDiscordDevExperiments.md
Last active November 12, 2024 19:18 — forked from ExordiumX/betaenabler.js
Enabling Discord Dev Experiments on Discord for Windows (2022-02)

Enable Dev Experiments in Discord for Windows

image

This guide shows how to enable dev mode for the Discord desktop application running on Windows (as of February 2022).

This can be used to view beta experiments to try features currently in development that are included but hidden by default in Discord release builds.


The Freenode resignation FAQ, or: "what the fuck is going on?"

IMPORTANT NOTE:

It's come to my attention that some people have been spamming issue trackers with a link to this gist. While it's a good idea to inform people of the situation in principle, please do not do this. By all means spread the word in the communities that you are a part of, after verifying that they are not aware yet, but unsolicited spam is not helpful. It will just frustrate people.

Update 3 (May 24, 2021)

A number of things have happened since the last update.

@linuswillner
linuswillner / psa.md
Last active May 30, 2022 01:43
Public service announcement from The Coding Den staff about social engineering being utilised as an attack vector for server takeovers

Today, on the 27th of March 2021, The Coding Den was subjected to a social engineering attack that lead to a brief hostile takeover of the server before the situation was brought under control by staff. We are sharing this statement as a public service announcement on the methodology used in the scam and possible remediations to prevent it, in order to help other staff teams avoid becoming victims of it.

Methodology

The attack proliferates as follows:

  1. The attacker will look for a staff member who is presently offline. This will ensure that it appears as if the staff member's account was globally banned and forcefully booted offline.
  2. It is within the attacker's interest to choose a target with the highest possible privileges (to do the maximum amount of damage), meaning that they will likely prefer administrators over moderators and so forth.
  3. The attacker will create a new Discord account with the same name and profile picture as the target.
  4. The attacker will approach a staff member, claiming
@sindresorhus
sindresorhus / esm-package.md
Last active November 17, 2024 22:07
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.