Skip to content

Instantly share code, notes, and snippets.

View amwmedia's full-sized avatar

Andrew Worcester amwmedia

View GitHub Profile
@amwmedia
amwmedia / Challenge-1.js
Created December 8, 2017 14:10
Advent Of Code 2017 - Day 3
function getDist(num) {
let sqrt = Math.ceil(Math.sqrt(num));
let sideLengthOfSq = (sqrt % 2 === 0 ? sqrt + 1 : sqrt);
let highestNumInSq = sideLengthOfSq * sideLengthOfSq;
let targetDistFromCorner = (highestNumInSq - num) % (sideLengthOfSq - 1);
let targetDistFromSideCenter = Math.abs(targetDistFromCorner - Math.floor(sideLengthOfSq/2));
const closestDistFromSq = (sideLengthOfSq - 1) / 2;
return closestDistFromSq + targetDistFromSideCenter;
}
@amwmedia
amwmedia / Challenge-1.js
Last active December 8, 2017 14:47
Advent Of Code 2017 - Day 4
// input is array of passphrases
input.filter(
phrase => phrase
.split(' ')
.every((word, idx, arr) => arr.indexOf(word) === idx)
).length;
@amwmedia
amwmedia / Challenge-1.js
Created December 11, 2017 14:21
Advent Of Code 2017 - Day 5
// Day 5 - Challenge #1
// input is an array of integers
function escapeHops(input) {
let hops = 0;
for (let pos = 0; pos < input.length;) {
const prevPos = pos;
pos += input[pos];
hops += 1;
input[prevPos]++;
}
@amwmedia
amwmedia / Challenge-1.js
Created December 11, 2017 15:57
Advent Of Code 2017 - Day 6
// input => [10, 3, 15, ...];
function memoryBanks(input) {
const states = [];
let opCount = 0;
for (; !states.includes(input.join('|')) ;) {
states.push(input.join('|'));
const highestNum = Math.max.apply(null, input);
let idx = input.indexOf(highestNum);
let amt = input[idx];
input[idx] = 0;
@amwmedia
amwmedia / aworcester.zsh-theme
Last active October 17, 2019 15:37
Zsh Theme (Based on Agnoster)
# vim:ft=zsh ts=2 sw=2 sts=2
#
# agnoster's Theme - https://gist.github.com/3712874
# A Powerline-inspired theme for ZSH
#
# # README
#
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts).
# Make sure you have a recent version: the code points that Powerline
@amwmedia
amwmedia / plopfile.js
Last active November 25, 2019 13:51
addMany example
module.exports = function (plop) {
plop.setGenerator("test", {
description: "create a component",
prompts: [
{
type: "input",
name: "name",
message: "name"
}
],
@amwmedia
amwmedia / animation.js
Last active August 12, 2020 17:23
Launch Scripts
window.hudpad = window.hudpad || {};
window.hudpad.scripts = window.hudpad.scripts || [];
window.hudpad.scripts.push({
name: 'animation',
title: 'Demo Animation',
script: function (launch) {
// launch.showText('Hello There!');
// launch.showText('My Name is Andrew!');
// launch.showText('what is your name?');
let x = 8;
@amwmedia
amwmedia / pocketchip_first-run.md
Created September 13, 2016 17:47 — forked from boogah/pocketchip_first-run.md
PocketCHIP: First Run!

My suggested list of terminal commands for your brand new PocketCHIP. These do the following things:

  • Reset your password.
  • Give you root user access to update and install software.
  • Update your PocketCHIP's core operating system.
  • Make sure that your locale and time zone data is right.
  • Install SSH and shut off WiFi power saving to prevent timeouts.
  • Install Pocket Home (Marshmallow edition).
  • Install rsync for easier file copying. (Optional)
  • Install git to easily grab projects from GitHub. (Optional)