Skip to content

Instantly share code, notes, and snippets.

View SiddharthShyniben's full-sized avatar
💭
Bored

Siddharth SiddharthShyniben

💭
Bored
View GitHub Profile
@SiddharthShyniben
SiddharthShyniben / golfs.md
Last active April 30, 2024 04:31
Golfing

A router in 108 89 83 bytes

(a,b,c=_=>(a.find(p=>b=p.path.exec(location.hash))?.render(b),c))=>onhashchange=c()

Shortened with inspiration from @Posandu

const route = (a,b,c=_=>(a.find(p=>b=p.path.exec(location.hash))?.render(b),c))=>onhashchange=c();
@SiddharthShyniben
SiddharthShyniben / ninja-code.md
Last active October 25, 2022 09:35
Ninja Code from javascript.info. For my self reference.

Ninja code

Learning without thought is labor lost; thought without learning is perilous.

Confucius

Programmer ninjas of the past used these tricks to sharpen the mind of code maintainers.
Code review gurus look for them in test tasks.
Novice developers sometimes use them even better than programmer ninjas.
Read them carefully and find out who you are – a ninja, a novice, or maybe a code reviewer?

@fnky
fnky / ANSI.md
Last active May 11, 2024 13:38
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27

By Mark Damon Hughes kamikaze@kuoi.asui.uidaho.edu

The original Rogue algorithm is pretty nifty. Any time you need a random dungeon, give this a try:

  1. Divide the map into a grid (Rogue uses 3x3, but any size will work).
  2. Give each grid a flag indicating if it's "connected" or not, and an array of which grid numbers it's connected to.
  3. Pick a random room to start with, and mark it "connected".
  4. While there are unconnected neighbor rooms, connect to one of them, make that the current room, mark it "connected", and repeat.
  5. While there are unconnected rooms, try to connect them to a random connected neighbor (if a room has no connected neighbors yet, just keep cycling, you'll fill out to it eventually).
  6. All rooms are now connected at least once.