Skip to content

Instantly share code, notes, and snippets.

@wwwins
wwwins / vim-align-txt.md
Created November 1, 2023 03:16
vim align text

align-1

isobartw-push:
		$(DK) push isobartw/node:$(NODE_TAG)-alpine
		$(DK) push isobartw/node:$(NODE_TAG)
		$(DK) push isobartw/node:lts
		$(DK) push isobartw/node:$(NODE_TAG)-alpine-pm2
		$(DK) push isobartw/node:$(NODE_TAG)-pm2
		$(DK) push isobartw/node:$(NODE_TAG)-alpine-gm
		$(DK) push isobartw/node:$(NODE_TAG)-gm
@wwwins
wwwins / upload.js
Created June 12, 2023 05:15
Uploading an image(binary data) with nodejs
/**
*
* Uploading binary data with nodejs
* axios + fs.createReadStream
*
* */
const fs = require('fs');
const axios = require('axios').default;
const FormData = require('form-data');
@wwwins
wwwins / 1image2video.sh
Last active December 16, 2022 02:49
Create video from one image
ffmpeg -r 0.01 -loop 1 -i image.jpg -c:v libx264 -tune stillimage -preset ultrafast -ss 00:00:00 -t 00:00:10 -pix_fmt yuv420p -shortest out.mp4
@wwwins
wwwins / c920.md
Last active December 8, 2022 09:37
live streaming from raspberry pi with logitech usb c920

video stream(v4l2-ctl)

v4l2-ctl --list-devices
mmal service 16.1 (platform:bcm2835-v4l2):
        /dev/video0

HD Pro Webcam C920 (usb-3f980000.usb-1.2):
        /dev/video1
@wwwins
wwwins / logger.sh
Created October 18, 2022 03:18
pretty-printed fastify log output
# convert unix timestamp to the local timezone
tail -f logs/access.log | jq '.time |= (tonumber / 1000 | strflocaltime("%c %Z"))'
@wwwins
wwwins / zip-subfolder.sh
Last active October 4, 2022 08:50
Compress all subfolders to separate files
// without hidden folders
for f in $(ls -d */);
do
echo "zip -r -X ${f:0:-1}.zip $f"
done
// include hidden folders
for f in $(ls -Al | awk -F" " '/^d/ {print $9}';
do
echo "zip -r -X $f.zip $f"
@wwwins
wwwins / replace.sh
Created March 16, 2022 03:22
Find and replace a string in multiple files
# Replace "4bk.aaa.com.tw" -> "bk.aaa.com.tw" in *.js|htm|html|css files
find www -type f \( -iname "*.js" -or -iname "*.htm" -or -iname "*.html" -or -iname "*.css" \) -exec sed -i '' 's/4bk.aaa.com.tw/bk.aaa.com.tw/g' {} +
@wwwins
wwwins / curl.sh
Last active January 15, 2021 08:20
curl tips
# POST multipart/form-data with a file upload
curl --request POST --url https://postman-echo.com/post -F "foo1=bar1" -F "foo2=bar2" -F "image=@/Users/isobar/Downloads/radar.jpg"
## POST multipart/form-data with json string
curl --request POST --url https://postman-echo.com/post -F "json=$jsonString"
# POST on windows
curl --request POST --url https://xxxxxx.ngrok.io/upload/ -F "filename=@d:\Data\My documents\Processing\mySample_http_post\test.tif"
# POST binary data with a file upload
@wwwins
wwwins / tips.sh
Last active October 6, 2020 16:16
Bash shell script tips
# copy a-*.ejs to d-*.ejs
$ for f in a-*.ejs; do cp $f d${f: 1}; done;
cp a-1.ejs d-1.ejs
cp a-2.ejs d-2.ejs
cp a-3.ejs d-3.ejs
cp a-4.ejs d-4.ejs
# copy loop_*.mp3 to loop_*.wav
$ for f in loop_*.mp3; do echo $f ${f:0:-4}.wav; done;
loop_1.mp3 loop_1.wav
@wwwins
wwwins / create-vod-hls.sh
Created September 10, 2020 08:10 — forked from maitrungduc1410/create-vod-hls.sh
Bash scripts to create VOD HLS stream with ffmpeg (Extended version)
#!/usr/bin/env bash
START_TIME=$SECONDS
set -e
echo "-----START GENERATING HLS STREAM-----"
# Usage create-vod-hls.sh SOURCE_FILE [OUTPUT_NAME]
[[ ! "${1}" ]] && echo "Usage: create-vod-hls.sh SOURCE_FILE [OUTPUT_NAME]" && exit 1
# comment/add lines here to control which renditions would be created
renditions=(