Skip to content

Instantly share code, notes, and snippets.

View long-blade's full-sized avatar

Michael. M long-blade

  • Moon
View GitHub Profile
@long-blade
long-blade / magic_array.js
Last active February 1, 2022 14:47
[Magic koa array] A simple query param array converter
const toMagicArray = x => (Array.isArray(x) ? x : x.split(',')).filter(y => y);
// input: '56' output: ['56']
// input: ['56', '6'] output: ['56', '6']
// input: 56,6,3 output: ['56', '6', '3']
@long-blade
long-blade / docker-compose.yml
Last active February 3, 2022 13:57
[Redis-Kafka-Neo4j] Boot up all in one a kafka cluster and neo4j + redis databases! #kafka #zookeeper #neo4j #redis #docker #docker-compose
version: '3'
services:
redis:
image: 'bitnami/redis:latest'
ports:
- 6379:6379
environment:
- REDIS_PASSWORD=password
- ALLOW_EMPTY_PASSWORD=yes
@long-blade
long-blade / resize.sh
Last active January 14, 2022 19:57
[Image resizer] Resize images for a directory of image files. #bash, #bashscripting
#! usr/bin/bash
## execute: bash resize.sh /path/to/files
for f in "$1"/*.{jpg,png}; do
[ -f "$f" ] || continue #skip in case f is not a regular file.
base=$(basename "$f")
echo "Converting $1/${base%.*}.${base##*.}"
convert "$f" -resize 1920x1322 -gravity center -background white -extent 1600x1102 "$1/${base%.*}.${base##*.}"