Skip to content

Instantly share code, notes, and snippets.

View jamesknelson's full-sized avatar

James K Nelson jamesknelson

View GitHub Profile
@jamesknelson
jamesknelson / README.md
Last active August 20, 2022 22:21
Convert a video into a gif

A 4-line shell script to convert your movies into gifs. Defaults to 10fps, 700px wide.

WIDTH=420 FPS=12 togif input.mov

You'll need to have ffmpeg installed -- on mac, you can do this with brew:

brew install ffmpeg
import * as Govern from 'govern'
import axios, { AxiosInstance, AxiosResponse, AxiosRequestConfig } from 'axios'
export interface HTTPOperation<Success = any, Rejection = any> {
hasEnded: boolean
isBusy: boolean
wasCancelled: boolean
wasSuccessful: boolean
wasRejected: boolean
@jamesknelson
jamesknelson / index.html
Created March 27, 2020 14:37
JavaScript Fireworks
<body>
<style>
body {
background-color: black;
overflow: hidden;
}
.firework {
top: 0;
left: 0;
@jamesknelson
jamesknelson / index.html
Created March 25, 2020 14:41
Falling sakura 1
<body>
<style>
body {
/* background-color: rgb(195, 226, 224); */
background-color: black;
overflow: hidden;
}
.petal {
position: absolute;
@jamesknelson
jamesknelson / index.html
Last active March 24, 2020 14:30
Fireworks with HTML/CSS
<style>
body {
background-color: black;
}
.dot {
position: absolute;
top: 50%;
left: 50%;
}
@jamesknelson
jamesknelson / index.html
Created March 21, 2020 14:35
WIP code for first lesson of Learn Something About Programming In 30 Minutes
<link href="https://fonts.googleapis.com/css?family=Squada+One&display=swap" rel="stylesheet">
<style>
body {
background-color: black;
}
h1 {
color: #EEE;
font-family: 'Squada One', cursive;
font-size: 60px;
@jamesknelson
jamesknelson / model.js
Created November 24, 2019 04:26
A model class for storing data fetched with React Suspense
const PurgeDelay = 1000
class Model {
fetcher: (id: string) => Promise<any>
cache = {}
callbacks = {}
holds = {}
purgeTimeouts = {}
@jamesknelson
jamesknelson / createSubscribe.js
Created October 22, 2019 07:41
Turn an async function into something you can subscribe to (untested)
const requests = {}
export const createSubscribe = (asyncFn) => {
return subscribeToData = (params, onUpdate) => {
onUpdate('pending')
const key = JSON.stringify(params)
const request = requests[key]
if (!request) {
request = requests[key] = {
@jamesknelson
jamesknelson / BlackTriangle.js
Last active April 8, 2019 19:00
A black triangle. It spins if ES6 works, otherwise it doesn't.
export default class BlackTriangle {
constructor(selector) {
this.angle = 0;
this.innerEl = document.querySelector(selector).querySelector('.BlackTriangle-inner');
}
rotate(amount) {
this.angle = (this.angle + amount) % 360;
}
const CombinedStream = require('combined-stream2');
function concatStringsAndStreams(strings, ...args) {
let combinedStream = CombinedStream.create()
combinedStream.append(Buffer.from(strings[0], 'utf8'))
for (let i = 0; i < args.length; i++) {
let arg = args[i]
let string = strings[i+1]
if (arg && arg.pipe) {
combinedStream.append(arg)