Skip to content

Instantly share code, notes, and snippets.

// -*- node.jz -*-
let input = ''
process.stdin.on('readable', () => input += process.stdin.read() || '')
process.stdin.on('end', () => {
main()
})
const dist = (i, j) => Math.abs(i) + Math.abs(j)
@kevincharm
kevincharm / day10.js
Created December 10, 2017 11:35
long
// -*- node.jz -*-
let input = ''
process.stdin.on('readable', () => input += process.stdin.read() || '')
process.stdin.on('end', () => {
const args = process.argv.slice(2)
const rounds = args[0]
main(rounds)
})
@kevincharm
kevincharm / day9-no-eval.js
Last active December 9, 2017 07:27
aoc2017
// -*- node.jz -*-
let input = ''
process.stdin.on('readable', () => input += process.stdin.read() || '')
process.stdin.on('end', () => main())
const evil = eval
class DepthCounter {
constructor() {
this.depth = 0
// -*- node.jz -*-
let input = ''
process.stdin.on('readable', () => input += process.stdin.read() || '')
process.stdin.on('end', () => main())
function ecmascriptify(input) {
const regs = {}
const weEczemaSkriptNow = input
.split('\n')
@kevincharm
kevincharm / fizzbuzz.js
Last active November 29, 2017 03:57
The Fizziest of Buzzes. Note: this is a joke.
const magic = 0x46697a7a
const witchcraft = magic ^ (0x41c << 16)
const u = x => a => b => (x >> a) + (x & b)
const v = x => a => b => x > a ? x - b : x
const w = x => u(u(u(x)(16)(0xffff))(8)(0xff))(4)(0xf)
const rin = x => s => !!parseInt(x) ? s : x + s
const c = x => a => b => String.fromCharCode((x >> a) & b)
const cccc = x => c(x)(24)(0xff)+c(x)(16)(0xff)+c(x)(8)(0xff)+c(x)(0)(0xff)
const fizz = x => !(v(u(u(u(w(x))(2)(3))(2)(3))(2)(3))(2)(3))
const buzz = x => !(v(v(v(w(x))(14)(15))(4)(5))(4)(5))
@kevincharm
kevincharm / cloneFbx.js
Created November 19, 2017 14:12
Clone an already-loaded FBX model in three.js and be able to animate it. Adapted from: https://gist.github.com/cdata/f2d7a6ccdec071839bc1954c32595e87
const cloneFbx = (fbx) => {
const clone = fbx.clone(true)
clone.animations = fbx.animations
clone.skeleton = { bones: [] }
const skinnedMeshes = {}
fbx.traverse(node => {
if (node.isSkinnedMesh) {
skinnedMeshes[node.name] = node
@kevincharm
kevincharm / keybase.md
Created September 7, 2017 07:41
keybasev2

Keybase proof

I hereby claim:

  • I am kevincharm on github.
  • I am kevincharm (https://keybase.io/kevincharm) on keybase.
  • I have a public key whose fingerprint is BCF1 8249 4254 7EFE EC77 D14C 1843 EB66 5597 F727

To claim this, I am signing this object:

@kevincharm
kevincharm / git_merge_ours.js
Created January 30, 2017 07:31
Node script that automates git checkout --ours or --theirs for all files in a merge conflict
#!/usr/bin/env node
'use strict'
const childProcess = require('child_process')
function bash() {
return new Promise((resolve, reject) => {
const terminal = childProcess.spawn('bash')
resolve(terminal)
})
@kevincharm
kevincharm / cassandra.service
Created October 22, 2016 16:54 — forked from s0undt3ch/cassandra.service
CentOS 7 Cassandra systemd service file
# /usr/lib/systemd/system/cassandra.service
[Unit]
Description=Cassandra
After=network.target
[Service]
PIDFile=/var/run/cassandra/cassandra.pid
User=cassandra
Group=cassandra
@kevincharm
kevincharm / bitarray.service.js
Last active November 29, 2017 06:10
bitarray.service.js
/**
* bitarray.js
*
* Utility for working with JS TypedArrays at bit level. (Angular Service)
*
* @author kevincharm
* @license MIT
*/
angular