Skip to content

Instantly share code, notes, and snippets.

@sbussard
sbussard / index.html
Created May 10, 2023 02:32
SVG Path Transformer
View index.html
<div id="root"></div>
@sbussard
sbussard / day1-part1-main.cc
Created December 2, 2022 07:26
Advent of Code
View day1-part1-main.cc
#include <iostream>
#include <fstream>
#include <unordered_set>
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
ABSL_FLAG(std::string, file_path, "", "full file path for input file");
@sbussard
sbussard / README.md
Last active December 2, 2022 06:39
encode the things
View README.md

A library for encoding things

Right now it just deals with encoding integers to an arbitrary base.

Ported from a 2013 repository.

FULL DISCLOSURE: It's pretty unreliable due to rounding errors.

Error Example:

var b = require("./base_encode");
@sbussard
sbussard / covid.ipynb
Created January 6, 2021 16:30
Covid 19 Estimate of Infection Fatality Rate
View covid.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sbussard
sbussard / isHotdog.js
Created October 6, 2020 05:19
isHotdog
View isHotdog.js
let prop = new Proxy({}, { get: (_, name) => (obj) => obj[name] });
let foods = [
{ name: 'hotdog', isHotdog: true },
{ name: 'pizza', isHotdog: false },
{ name: 'spaghetti', isHotdog: false }
];
console.log(foods.map(prop.name));
@sbussard
sbussard / machine.js
Last active March 13, 2020 07:50
Generated by XState Viz: https://xstate.js.org/viz
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@sbussard
sbussard / run-analysis.sh
Created January 15, 2020 19:50
Code Maat
View run-analysis.sh
#!/usr/bin/env bash
cd ~/Desktop
YOUR_DESKTOP_FOLDER=`pwd` # Mac
mkdir output
docker run --rm -v $YOUR_DESKTOP_FOLDER:/codemaat code-maat -l /codemaat/git.log -c git -a age > output/age.csv
docker run --rm -v $YOUR_DESKTOP_FOLDER:/codemaat code-maat -l /codemaat/git.log -c git -a abs-churn > output/abs-churn.csv
docker run --rm -v $YOUR_DESKTOP_FOLDER:/codemaat code-maat -l /codemaat/git.log -c git -a author-churn > output/author-churn.csv
docker run --rm -v $YOUR_DESKTOP_FOLDER:/codemaat code-maat -l /codemaat/git.log -c git -a authors > output/authors.csv
View exampleRef.js
import React, { useState } from "react";
let ChildComponent = ({ setRef }) => <div ref={setRef}>{/* content */}</div>;
let ParentComponent = () => {
let [ref, setRef] = useState();
useEffect(() => {
if (ref) {
// whatever you want to use ref for
@sbussard
sbussard / EnergyBalls.js
Created June 16, 2012 19:16
EnergyBalls – animated "energy balls" floating in "space"
View EnergyBalls.js
/*
Author: Stephen Bussard
Twitter: @sbussard
*/
var sin = Math.sin,
cos = Math.cos,
tan = Math.tan,
View do.jsx
let itemData = [
{ name: 'Chair', price: '$199', id: 'abc123' },
{ name: 'Table', price: '$799', id: 'def456' }
];
let Item = ({ description, id }) => <li key={id}>{description}</li>;
let makeProps = ({ name, price, id }) => ({
id,
description: `${name} - ${price}`