Skip to content

Instantly share code, notes, and snippets.

View dtudury's full-sized avatar

David Tudury dtudury

  • Danville, California, USA
View GitHub Profile
@dtudury
dtudury / emscripten_transcripten.md
Created May 5, 2016 21:44
emscripten notes and direction from Julian for Cosmin

get the repo and tools

I've run this so it should be mostly (hopefully) okay

  • setup emscripten (I think you already have)
  • install sox; if you use homebrew: brew install sox
  • get Julian's WIP: git clone [email protected]:Voxer/voxer2mp3.git and git checkout jg-emscripten
  • do the magic:
    • ./buildvoxencode.sh
  • jgautier: "so you have a VoxEncode.js file now?"
@dtudury
dtudury / hues.lum.js
Created October 17, 2016 21:40
map color hues to same luminance
let lum = ([r, g, b]) => r * 0.2126 + g * 0.7152 + b * 0.0722;
let blend = (c0, c1, s, i = 1 - s) => [c0[0] * s + c1[0] * i, c0[1] * s + c1[1] * i, c0[2] * s + c1[2] * i];
let hex = c => c.reduce((p, v) => p + Math.round(0x100 + v * 0xff).toString(16).substr(-2), "");
let colors = {
red: [1, 0, 0],
yellow: [1, 1, 0],
green: [0, 1, 0],
cyan: [0, 1, 1],
blue: [0, 0, 1],
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@dtudury
dtudury / queens.js
Created July 3, 2019 00:47
solution to eight queens puzzle
function place (placed, unplaced) {
if (!unplaced.length) return [placed]
let validPlacements = []
unplaced.forEach(unplacedRow => {
if (placed.every((placedRow, i) => {
const d = placed.length - i
return placedRow + d !== unplacedRow && placedRow - d !== unplacedRow
})) {
let possibleUnplaced = unplaced.filter(row => row !== unplacedRow)
validPlacements = [...validPlacements, ...place([...placed, unplacedRow], possibleUnplaced)]
@dtudury
dtudury / lispish.js
Last active November 2, 2020 20:53
basic lisp parser
// A *just* good-enough lisp parser
const WHITE_SPACE = /\s/
const OPEN_PAREN = /\(/
const CLOSE_PAREN = /\)/
const SUBATOMIC = /[^\s()]/
function parse (program) {
let i = 0
@dtudury
dtudury / q-idea.js
Created April 21, 2021 18:00
idea for an sql-like utility for javascript arrays and objects
const a = [
{ m: "a", id: 1 },
{ m: "b", id: 2 },
{ m: "c", id: 3 }
];
const b = [
{ n: "x", id: 1 },
{ n: "y", id: 2 },
{ n: "z", id: 3 }
];