Skip to content

Instantly share code, notes, and snippets.

View OrderAndCh4oS's full-sized avatar
🕰️
Writing code

Sean Cooper OrderAndCh4oS

🕰️
Writing code
View GitHub Profile
# flatColourConvert image.png red
function flatColourConvert() {
magick convert "$1" -fill "$2" -colorize 100% x.png
}
# replaceColours "#1B3057" "#2B373D"
# replaceColours red "#2B373D" 70%
function replaceColours() {
magick convert *.png -set filename:original %t -channel RGB -fuzz ${3:-25%} -fill $1 -opaque $2 %[filename:original].png
}
function chunkPublicKey(key) {
const start = '-----BEGIN PUBLIC KEY-----';
const end = '-----END PUBLIC KEY-----';
const result = [];
try {
const arr = key.split('');
while(arr.length) {
result.push(arr.splice(0, 64).join(''));
}
} catch(e) {
58C2C1 Blue
3282B0 Second Blue
40C675 Green
D58F21 Orange/Yellow
6388C5 Blue
A9539A Purple
BC3F3C Red
E5265F Pink
CF6436 Orange
AD9D8D White
#!/bin/bash
brew unlink vim
brew install cmake macvim
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim;
touch .vimrc;
cat << EOF > .vimrc
set nocompatible
@OrderAndCh4oS
OrderAndCh4oS / combine-object-arrays.ts
Last active October 31, 2019 12:41
Combine object arrays without duplicates
const combineObjectArrays = (p: any[], q: any[], key = 'id') => {
const storedIds: any = [];
const arr: any = [];
for (let i = 0; i < Math.max(p.length, q.length); i++) {
if (i < p.length && !storedIds.includes(p[i][key])) {
storedIds.push(p[i][key]);
arr.push(p[i]);
}
if (i < q.length && !storedIds.includes(q[i][key])) {
storedIds.push(q[i][key]);
@OrderAndCh4oS
OrderAndCh4oS / switch-case.js
Last active July 19, 2019 08:36
Switch String Case. Coverts camelCase or PascalCase to kebab-case or snake_case or any delimited string and vice versa,
const camelCaseToDelimitedString = (string, delimiter = '-') =>
string.replace(/([a-z0-9]|(?<!^)(?=[A-Z]))([A-Z])/g, '$1'+delimiter+'$2').toLowerCase();
const delimitedStringToCamelCase = (string, delimiter = '-') =>
string.replace(new RegExp(delimiter + '([a-z])', 'g'), (m, c) => c.toUpperCase());
ffmpeg -f x11grab -y -r 30 -s 1920x1080 -i :0.0 -vcodec huffyuv out.avi
# Then convert it to .mp4
ffmpeg -y -i out.avi -s 1920x1080 -f mp4 -vcodec libx264 -preset slow -crf 18 -b:v 3000k -maxrate 4000k -bufsize 512k -c:a aac -b:a 128k -strict -2 out.mp4
# and remove the .avi
rm out.avi
@OrderAndCh4oS
OrderAndCh4oS / pngToGif.sh
Created June 12, 2019 19:46
Convert png to gif with ImageMagick
function pngToGif() {
while getopts ":i:o:" opt; do
case $opt in
i) input_file="${OPTARG}"
;;
o) output_file="${OPTARG}"
;;
\?) echo "Invalid option -${OPTARG}" >&2
;;
esac
@OrderAndCh4oS
OrderAndCh4oS / ffmpeg-stills-to-mp4
Created June 8, 2019 13:48
Command to convert a sequence of still images to and mp4 video. Using it for Processing3 Sketches.
ffmpeg -f image2 -i image-%03d.png -s 640x360 -vcodec libx264 -preset slow -crf 18 -b:v 3000k -maxrate 4000k -bufsize 512k -c:a aac -b:a 128k -strict -2 weave-1.mp4
@OrderAndCh4oS
OrderAndCh4oS / .vimrc
Last active May 28, 2019 22:34
.vimrc
set nocompatible
filetype off " required
syntax enable
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()