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 / 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 / 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 / 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
@keyframes anim-rotate {
0% {
transform: rotate(0);
}
100% {
transform: rotate(360deg);
}
}
body{
background: repeating-linear-gradient(to bottom, rgba(0,0,0,0.2), rgba(0,0,0,0.2) 1px, transparent 2px, transparent 3px);
}
@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,
@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 / timelapse.md
Last active October 29, 2021 06:17 — forked from alexellis/timelapse.md
ffmpeg time-lapse

Convert sequence of JPEG images to MP4 video

Crop to 4k:

ffmpeg -r 30 -pattern_type glob -i '*.JPG' -s 3840:2160 -vcodec libx264 -pix_fmt yuv420p timelapse.mp4

Crop to original:

ffmpeg -r 30 -pattern_type glob -i '*.JPG' -vcodec libx264 -pix_fmt yuv420p timelapse.mp4

(function() {
const nets = {
twitter: ['https://twitter.com/*$'],
linkedin: ['https://www.linkedin.com/company/*$', 'linkedin.com/in/*$'],
instagram: ['https://www.instagram.com/*$'],
facebook: ['https://www.facebook.com/*$'],
glassdoor: ['https://www.glassdoor.com/Reviews/*.htm$'],
github: ['https://(www.)?github.com/*$']
}
@AshKyd
AshKyd / update-bash-macos.sh
Created June 15, 2019 15:56
Update MacOS bash & set default shell
brew install bash
sudo echo /usr/local/bin/bash >> /etc/shells
chsh -s /usr/local/bin/bash