Skip to content

Instantly share code, notes, and snippets.

View AshKyd's full-sized avatar
🐳
a frood who really knows where his towel is

Ash Kyd AshKyd

🐳
a frood who really knows where his towel is
View GitHub Profile
@AshKyd
AshKyd / ffmpeg.md
Last active December 1, 2019 20:30

Create a time lapse of some sort:

ffmpeg -i GH012287_1575218935438_high.MP4 -vf tmix=frames=5:weights="1 1 1 1 1",select='not(mod(n\,5))',setpts=0.5*PTS out.mp4

Optionally add deshake if it's jittery:

ffmpeg -i GH012287_1575218935438_high.MP4 -vf deshake,tmix=frames=10:weights="1",setpts=0.5*PTS out-4.mp4
@AshKyd
AshKyd / react-ratio-box-copy-paste.jsx
Last active February 6, 2020 14:36
A copy-pasteable React ratio box compont. Make boxes with customizable ratios. Should be pretty fast.
import React, { useMemo } from 'react';
import PropTypes from 'prop-types';
const topLevelStyle = {
position: 'relative'
};
const innerStyle = {
position: 'absolute',
left: 0,
body{
background: repeating-linear-gradient(to bottom, rgba(0,0,0,0.2), rgba(0,0,0,0.2) 1px, transparent 2px, transparent 3px);
}
@keyframes anim-rotate {
0% {
transform: rotate(0);
}
100% {
transform: rotate(360deg);
}
}
@AshKyd
AshKyd / go.sh
Created December 11, 2022 02:16
Optimise h26x mkv files to be playable on just about anything
files=`ls -1 *.mkv`
for file in $files
do
ffmpeg -i $file -acodec copy -vcodec copy -movflags faststart "${file%.mkv}.mp4"
done
@AshKyd
AshKyd / colourToRgba.js
Created November 20, 2023 03:13
Convert any HTML colour to its rgb equivalent using HTML5 canvas. Suitable for use in a web worker using OffscreenCanvas.
const colourToRgbaMemo = {};
/**
* Parse and convert HTML colours to RGB representations.
* @param {string} sourceColour - Any valid HTML colour. E.g. ('#ff0000', 'rgba(128,128,255)' or 'hotpink')
* @returns {number[]} RGB triplet representing the given colour. If the colour was invalid, returns black.
*/
export function colourToRgb(sourceColour) {
// return from cache if available
if (colourToRgbaMemo[sourceColour]) return colourToRgbaMemo[sourceColour];
@AshKyd
AshKyd / search.js
Created November 23, 2023 00:38
search through a gzip file line by line on the client
function search(keyword) {
let chunks = 0;
isSearching = true;
return fetch(`${__webpack_public_path__}/placeNames.tsv.gz`).then(async res => {
const blob = await res.blob();
const ds = new DecompressionStream('gzip');
const reader = blob.stream().pipeThrough(ds).pipeThrough(new TextDecoderStream()).getReader();
let partialLine = '';
@AshKyd
AshKyd / makeTsv.js
Created November 29, 2023 00:32
Make a tsv file out of a geojson blob. The properties must all be consistent or this won't really work.
const geojson = require('file.geojson');
function makeLine(object){
return Object.keys(object).map(key => {
const value = object[key];
if(!['string', 'number'].includes(typeof value)) return '-';
return value;
}).join('\t')
}
@AshKyd
AshKyd / index.html
Created December 17, 2023 06:36
iOS Chat bubbles
<p class="send">Hey there! What's up</p>
<p class="receive">Checking out iOS7 you know..</p>
<p class="send">Check out this bubble!</p>
<p class="receive">It's pretty cool…</p>
<p class="receive">Not gonna lie!</p>
<p class="send">Yeah it's pure CSS &amp; HTML</p>
<p class="receive">Wow that's impressive. But what's even more impressive is that this bubble is really high.</p>
function dataTransferItemToArrayBuffer(dataTransferItem){
return new Promise((resolve, reject) => {
if(dataTransferItem.kind !== 'file') {return reject(new Error('DataTransferItem is not of kind "file"'));}
const file = dataTransferItem.getAsFile();
var reader = new FileReader();
reader.onload = function() {
var arrayBuffer = this.result,
array = new Uint8Array(arrayBuffer);