Skip to content

Instantly share code, notes, and snippets.

@fgnass
fgnass / microbit.ts
Created August 18, 2018 13:48
Microbit Game
let ball: game.LedSprite = null
let player: game.LedSprite = null
let score = 0
let lives = 0
input.onButtonPressed(Button.A, () => {
player.move(-1)
})
input.onButtonPressed(Button.B, () => {
player.move(1)
})
r = readline;
[...Array(+r())]
.map(r)
.map(l => /(.+): (.+) /.exec(l))
.map(
([, n, c]) =>
(c.split("-").map(c => 117 - c.charCodeAt(0)) + "").padEnd(20, ",1") + n
)
.sort()
.map(e => writeline(e.slice(20)));
@fgnass
fgnass / keybase.md
Created August 23, 2020 12:22
keybase.md

Keybase proof

I hereby claim:

  • I am fgnass on github.
  • I am fgnass (https://keybase.io/fgnass) on keybase.
  • I have a public key ASBTra-cTg-Ff-R-1_WL1vyGiYM8zCgf9oBm5lSqUqM1iQo

To claim this, I am signing this object:

@fgnass
fgnass / README.md
Created October 19, 2020 14:04
Next.js SSR + Capacitor

Goal

The goal is to package a server-side rendered Next.js app as SPA for capacitor.

Approach

Pages with dynamic routes/data use getServerSideProps(). For capacitor we need at least one page that can be rendered statically, preferably the index page.

When there are pages that use getServerSiedeProps() we can't use next export (it will fail with an error).

@fgnass
fgnass / cursorrules.md
Created January 5, 2025 11:18
.cursorrules

Persona

You are a senior full-stack developer, pair-programming with me, also a senior full-stack developer.

Be critical of my ideas. Avoid trying to please me; instead, challenge assumptions, highlight risks, and express doubts when unsure about a direction.

When I ask a question, do not write code immediately. Only provide explanations, guidance, or feedback. Write code only when explicitly instructed to do so.

When you are uncertain about something, admit it! Never make random changes.

@fgnass
fgnass / sizes.js
Created January 15, 2025 14:02
Generate sizes attributes for all responsive images on a page.
// Quick helper to generate sizes attributes for your responsive images.
// It loads the current page into an invisible iframe and resizes it to the different breakpoints,
// where it measures the images and converts their width to vw.
// Usage: Open the HTML page you want to add sizes attributes to in your browser,
// paste this code in the console and hit return. The result will be logged to the console.
(async () => {
const sizesData = new Map();