Skip to content

Instantly share code, notes, and snippets.

View keyle's full-sized avatar
👹

keyle

👹
View GitHub Profile
@keyle
keyle / browserlogger.js
Last active January 14, 2021 03:27
console.log by topic on/off
/**
* 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]) {
@keyle
keyle / StripesBackground.css
Created December 30, 2020 04:55
Stripy Background (warning hashes) CSS
background: repeating-linear-gradient(
-45deg,
#ffcd11,
#ffcd11 10px,
#333 10px,
#333 20px
);
@keyle
keyle / NSImageViewFill.swift
Created May 3, 2020 05:36
NSImageView with Fill Aspect Ratio for Swift 4/5+
//
// 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
@keyle
keyle / docker-always-restart.sh
Created November 3, 2019 22:06
Docker container always start at boot
# docker ps, find the hash, e.g. b1d085e45f39
docker update --restart=always $1
@keyle
keyle / readme.md
Created October 25, 2019 06:10 — forked from xem/readme.md
Maths & trigonometry cheat sheet for 2D & 3D games

Conventions

  • 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

Degrees to radians

angleRad = angleDeg * Math.PI / 180;

@keyle
keyle / werp.py
Last active August 29, 2015 14:13
toy programming language, lispish and concise.
# 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 = []
@keyle
keyle / pipein.nim
Created January 10, 2015 15:07
Get the content piped into nim process
# 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:
@keyle
keyle / Flare3DView.as
Created August 31, 2014 04:44
unresponsive mouse after a while
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;