Skip to content

Instantly share code, notes, and snippets.

View alexanderson1993's full-sized avatar
🚀
Spaceshippin...

Alex Anderson alexanderson1993

🚀
Spaceshippin...
View GitHub Profile

Keybase proof

I hereby claim:

  • I am alexanderson1993 on github.
  • I am alexanderson1993 (https://keybase.io/alexanderson1993) on keybase.
  • I have a public key whose fingerprint is 86FE FC46 60BA 8BD1 27E8 BB8C 6752 B79F 33C2 085F

To claim this, I am signing this object:

<Preview
simulatorId={this.props.simulator.id}
tacticalMapId={this.state.tacticalMapId}
layers={selectedTactical.layers}
layerId={this.state.layerId}
selectObject={this.selectObject}
objectId={this.state.objectId}
updateObject={this.updateObject}
removeObject={this.removeObject}
updatePath={this.updatePath}
@alexanderson1993
alexanderson1993 / Development Breakdown
Created May 10, 2019 21:31
WakaTime Development Breakdown
Hi
@alexanderson1993
alexanderson1993 / useCounter.js
Created July 20, 2019 14:30
A hook that increments a value every 1 second.
import React from 'react'
export default function useCounter(initialCount) {
const [time, setTime] = React.useState(initialCount);
// The timer might not be exactly 1000 ms, so track the time
// between intervals manually
const lastTimeRef = React.useRef(Date.now())
// This effect resets the timer to the initial count when it changes.
React.useEffect(() => {
// animationValue is a number from 0 to 1, generated by a tweener
// In this case, I'm using a useAnimation hook.
function calculateAnimationValue(animationValue, arcLength, arcStart) {
// Figure out where the animation starts
const animationStart = arcStart / 360;
// If our arc starts after where the animation currently is, return 0
// This renders an invisible arc.
if (animationValue < animationStart) {
return 0;
@alexanderson1993
alexanderson1993 / lighting.js
Created December 13, 2019 02:37
Sending DMX messages to an ENTTEC Pro USB controller over WebUSB
async function setUpLights() {
const lightingDevice = await navigator.usb.requestDevice({ filters: [] });
await lightingDevice.open();
await lightingDevice.claimInterface(0);
// This comes from https://github.com/NERDDISCO/webusb-dmx512-controller
lightingDevice.controlTransferOut({
// It's a USB class request
requestType: "class",
// The destination of this request is the interface
import styled from "@emotion/styled";
const DragContainer = styled.div`
height: 460px;
max-height: 80vh;
width: 100%;
position: relative;
overflow: hidden;
`;
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
var stripe = require("stripe")(process.env.STRIPE_KEY_SECRET);
exports.handler = (event, context, callback) => {
//console.log('Received event:', JSON.stringify(event, null, 2));
const done = (err, res) =>
callback(null, {
statusCode: err ? "400" : "200",