- A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
- lengths are in any unit (ex: pixels)
- code snippets are in JavaScript
angleRad = angleDeg * Math.PI / 180;
| /** | |
| * logt() - extremely simple `console.log` by topic | |
| * instead `logt('topic', something)`; | |
| * to turn on, `localStorage.topic=1` in chrome console | |
| * to turn off, `delete localStorage.topic` | |
| * @param {string} topic | |
| * @param args | |
| */ | |
| let logt = (topic, ...args) => { | |
| if (localStorage[topic]) { |
| background: repeating-linear-gradient( | |
| -45deg, | |
| #ffcd11, | |
| #ffcd11 10px, | |
| #333 10px, | |
| #333 20px | |
| ); |
| // | |
| // NSImageViewFill.swift | |
| // NSImageView with Fill Aspect Ratio | |
| // Swift 4.0+ | |
| // | |
| // Written by (source) https://stackoverflow.com/a/46262418/200041 | |
| // I take no credit in this but it's too awesome not to gist. | |
| // | |
| import Cocoa |
| # docker ps, find the hash, e.g. b1d085e45f39 | |
| docker update --restart=always $1 |
| # werp.py :: toy programming language, lispish and concise. | |
| tokenize = lambda chars: chars.replace('(', ' ( ').replace(')', ' ) ').split() | |
| def read_from_tokens(tokens): | |
| if len(tokens) == 0: | |
| raise SyntaxError('Unexpected EOF') | |
| token = tokens.pop(0) | |
| if token == "(": | |
| L = [] |
| # option 1 | |
| let x = stdin.readAll | |
| echo "^ " & x | |
| # option 2 | |
| while not endoffile(stdin): | |
| let x = stdin.readLine | |
| echo "^ " & x |
| import macros | |
| macro eval(s: string): expr = | |
| result = parseStmt($s) | |
| eval("echo 5") |
| import irc, asyncdispatch, strutils, os, threadpool | |
| proc onIrcEvent(client: PAsyncIrc, event: TIrcEvent) {.async.} = | |
| case event.typ | |
| of EvConnected: | |
| discard | |
| of EvDisconnected, EvTimeout: | |
| await client.reconnect() | |
| of EvMsg: | |
| if event.cmd == MPrivMsg: |
| package game | |
| { | |
| import flare.basic.Scene3D; | |
| import flare.basic.Viewer3D; | |
| import flare.core.Camera3D; | |
| import flare.core.Mesh3D; | |
| import flare.core.Pivot3D; | |
| import flare.core.Texture3D; | |
| import flare.flsl.FLSLMaterial; | |
| import flare.physics.colliders.SphereCollider; |