This algorithm returns the points that form an orthogonal path between two rectangles.
// Define shapes
const shapeA = {left: 50, top: 50, width: 100, height: 100};
const shapeB = {left: 200, top: 200, width: 50, height: 100};This algorithm returns the points that form an orthogonal path between two rectangles.
// Define shapes
const shapeA = {left: 50, top: 50, width: 100, height: 100};
const shapeB = {left: 200, top: 200, width: 50, height: 100};I was poking around trying to figure out all the packages I have access to publish and got curious. So I write this little script to determine the download stats for all the packages I have publish access to.
Feel free to try it yourself. Just change the username passed to getUserDownloadStats.
By default, the stats are sorted by their average daily downloads (descending). That should give you an idea of the most "popular" package of a given user relative to how long that package has been around.
You can use it with npx like so:
| <body onload=z=c.getContext`2d`,setInterval(`c.width=W=150,Y<W&&P<Y&Y<P+E|9<p?z.fillText(S++${Y=`,9,9|z.fillRect(p`}*0,Y-=--M${Y+Y},P+E,9,W),P))):p=M=Y=S=6,p=p-6||(P=S%E,W)`,E=49) onclick=M=9><canvas id=c> |
| import log from "ololog" | |
| class Grid { | |
| rows = [] | |
| width = 0 | |
| height = 0 | |
| chars = { | |
| active: ["┌", "─", "┒", "┃", "┛", "━", "┕", "│"], | |
| inactive: ["┌", "─", "┐", "│", "┘", "─", "└", "│"], |
| import { assign, interpret, Machine, Interpreter, EventObject } from 'xstate'; | |
| // Phaser implicitly available | |
| interface PawnContext { | |
| moveTowards?: Phaser.Math.Vector2, | |
| } |
| function distributeEvenly< | |
| T extends { x: number; y: number; height: number; width: number } | |
| >(axis: "x" | "y", boxes: T[]) { | |
| const mboxes = [...boxes] | |
| const extent = axis === "x" ? "width" : "height" | |
| mboxes.sort((a, b) => a[axis] - b[axis]) | |
| // Overall boxes span | |
| const last = mboxes[mboxes.length - 1] | |
| const dist = last[axis] + last[extent] - mboxes[0][axis] |
| /* So how does this work? | |
| I'm using ANSI escape sequences to control the behavior of the terminal while | |
| cat is outputting the text. I deliberately place these control sequences inside | |
| comments so the C++ compiler doesn't try to treat them as code.*/ | |
| //[2K[2D[A[2K[A[2K[A[2K[A[2K[A | |
| /*The commands in the fake code comment move the cursor to the left edge and | |
| clear out the line, allowing the fake code to take the place of the real code. | |
| And this explanation uses similar commands to wipe itself out too. */ | |
| //[2K[2D[A[2K[A[2K[A[2K[A | |
| #include <cstdio> |
| import * as x from './xstate-fp'; | |
| export enum EditableTextState { | |
| idle = 'idle', | |
| editing = 'editing', | |
| } | |
| export enum EditableTextEvent { | |
| mouseenter = 'mouseenter', | |
| mouseleave = 'mouseleave', |