Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am conundrumer on github.
  • I am delu (https://keybase.io/delu) on keybase.
  • I have a public key whose fingerprint is 48AA B300 E48D 75A1 49AE 5805 00B6 5AB6 8C2E CFC2

To claim this, I am signing this object:

@conundrumer
conundrumer / combiner.js
Created September 15, 2016 06:26
cli tool for combining line rider tracks
// i suppose i should put this somewhere before accidentally losing it
// need to update lr-core to have file import/export so this can work depending only on that and lodash and yargs
'use strict'
let path = require('path')
let fs = require('fs')
let _ = require('lodash')
let argv = require('yargs')
.usage('usage: node combiner.js output.track.json')
.option(0, {
@conundrumer
conundrumer / pandora.json
Created October 22, 2016 22:41
conundrumer's pandora likes
[
{
"title": "Magaz Stinged",
"artist": "Funckarma",
"station": "Klik Me Radio"
},
{
"title": "Rare & Pelentiful",
"artist": "Tipper",
"station": "Klik Me Radio"
fn fib(n: u64) -> u64 {
match n {
0 => 1,
1 => 1,
_ => fib(n - 1) + fib(n - 2)
}
}
fn fib_fast(n: u64) -> u64 {
let mut seen = vec![None; 1 + n as usize];
@conundrumer
conundrumer / fill.js
Created March 12, 2017 01:19
fill tool example
import track from 'lr/track'
import ui from 'lr/ui'
import tools from 'lr/tools'
import React from 'react'
module.info = {
name: 'Fill Tool',
version: '0.1.0',
author: 'David Lu'
}
@conundrumer
conundrumer / jsonReader.js
Created March 21, 2017 08:04
.track.json reader/writer
let decompress = require('lz-string').decompressFromBase64
const linesArrayAttr = ['type', 'id', 'x1', 'y1', 'x2', 'y2', 'extended', 'flipped', 'leftLine', 'rightLine']
function validateJson ({version, startPosition, lines}) {
if (!(version === '6.2' || version === '6.1')) {
throw new Error(`This track does not have a valid version: ${version}`)
}
if (!(
startPosition instanceof Object &&
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style type="text/css">
html, body {
width: 100%;
height: 100%;
}
</style>
/*
* float.js
* fromHex: takes a 64-bit number encoded as a hex string (eg 34F5CA0157FF00FF)
* and returns a float whose binary representation is this number
* toHex: takes a number and returns the binary encoding as a hex string
*/
/*eslint-env node */
'use strict';
@conundrumer
conundrumer / lrjs.v0.9.7.update.md
Last active December 28, 2017 21:21
documentation of added functionalities of lrjs v0.9.7

line tool

given a line being drawn:

  • +shift: angle lock (to the line that the drawn line is snapped to)
  • +shift+mod: length snap (to nearest power of 2)
  • +shift+mod+alt: length snap + angle snap

selection tool

@conundrumer
conundrumer / speedometer.jsx
Created January 2, 2018 02:17
lrjs speedometer
import React from 'react'
import Vector from 'core/Vector'
function angleTo (u, v) {
return Math.atan2(u.cross(v), u.dot(v))
}
export default function Speedometer ({rider, prevRider, toolbarsOpen}) {
let style = {position: 'absolute', top: toolbarsOpen ? 40 : 0, right: 0, padding: 8, textAlign: 'right', fontFamily: 'monospace', backgroundColor: 'rgba(255,255,255,0.8)'}
let avgPos = rider.points.reduce((acc, {pos}) => acc.add(pos), new Vector(0, 0)).divS(rider.points.length)