Skip to content

Instantly share code, notes, and snippets.

@reidblomquist
reidblomquist / advent2021_day_3.js
Created December 3, 2021 17:23
Heard you kids still like 'em shloppy - here's day 3
const data = require('./data.json');
const getFrequency = (arr) => {
const dict = {};
arr.forEach(function(el) {
if (!dict[el]) dict[el] = 0;
dict[el]++;
});
return {
leastFrequent: `${Object.keys(dict).find(key => dict[key] === Math.min(...Object.values(dict)))}`,
@reidblomquist
reidblomquist / advent2021_day_2.js
Created December 3, 2021 03:40
still pretty schlopy day 2 advent
const data = require('./data.json');
const results = data.data.reduce((acc, val, idx, arr) => {
const [direction, rawValue] = val.split(' ');
const value = Number(rawValue);
switch (direction) {
case 'up':
acc.aim -= value;
break;
@reidblomquist
reidblomquist / advent2021_day_1.js
Last active December 3, 2021 02:54
real shloppy advent of code day 1
const data = require('./data.json');
const sumArray = (array) => array.reduce((a, b) => a + b, 0);
const results = data.data.reduce((acc, n, idx, arr) => {
const lenIn = arr.length;
const isPastTupleTime = lenIn - idx <= 2;
const newAcc = {
...acc,
lastValue: n,
@reidblomquist
reidblomquist / Clock.cs
Created February 18, 2018 00:13
example stopwatch solution (taking catlikecoding's clock tutorial further)
using System;
using UnityEngine;
using UnityEngine.UI;
public class Clock : MonoBehaviour {
const float
degreesPerHour = 30f,
degreesPerMinute = 6f,
degreesPerSecond = 6f;
@reidblomquist
reidblomquist / .coinfavs
Last active January 17, 2018 00:50 — forked from donpdonp/.coinfavs
coinmarketcap cli display
"ETH", "ADA", "BTC", "BCH"
@reidblomquist
reidblomquist / index.js
Created October 18, 2017 00:29
Github PR Approval Email Bookmarklet
javascript:(
(function(){
var project = document.querySelector('[itemprop=name]').textContent.trim().toUpperCase();
var title = document.querySelector('.js-issue-title').textContent.trim();
var comments = document.querySelector('.timeline-comment-wrapper').querySelector('.comment-body').textContent.trim().split('\n').join('%0D%0A');
var url = window.location.href;
var subject = `Alpha approval request for: ${project} ${title}`;
var body = `Requesting Alpha deploy approval for ${project}: ${title}%0D%0A%0D%0AChangelog:%0D%0A${comments}%0D%0A%0D%0AView more here: ${url}`;
@reidblomquist
reidblomquist / .zshrc
Created May 4, 2017 20:17
zshrc (w/ prezto and powerlevel9k)
#
# Reid Blomquist's zshrc
#
# stuff being used:
# - zsh
# - prezto
# - powerlevel9k
# - a bunch of other shit
#
@reidblomquist
reidblomquist / navigation.js
Last active March 3, 2017 00:05
Quick Vanilla JS Nav Hideymajig
export default class Navigation {
constructor () {
this.didScroll_ = false
this.lastScrollTop_ = 0
this.delta = 5
this.navbarHeight_ = document.querySelector('.nav').offsetHeight // change to your desired class/selector
window.addEventListener('scroll', () => {
this.didScroll_ = true
})
setInterval(() => { this.checkScroll() }, 250)
@reidblomquist
reidblomquist / index.html
Last active January 12, 2017 23:49
Swing.js w/ video (issues on cards below first w/ unwanted video pause onclick)
<!DOCTYPE html>
<html>
<head>
<title>Wat</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<style>
ul,
li {
@reidblomquist
reidblomquist / rangifier.rb
Created August 2, 2016 17:24
Scrape aws' region json file to write out us-east-1 ip ranges for Ansible/iptables
require "json"
require "yaml"
require "net/http"
require "uri"
yaml_file = "#{Dir.pwd}/range.yml"
uri = URI.parse("https://ip-ranges.amazonaws.com/ip-ranges.json")
http = Net::HTTP.new(uri.host, uri.port)