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 / 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 / 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=(
@wwwins
wwwins / getopts.sh
Created April 23, 2020 07:20
Get shell script arguments
#!/bin/sh
usage()
{
echo ""
echo "Usage: $0 -n project-name -o project-owner -p port -t [init|update]"
echo "\t-n project name"
echo "\t-o project owner"
echo "\t-p port"
echo "\t-t init or update"
@wwwins
wwwins / qrdecoder.py
Created April 13, 2020 09:22
Python QRCode decoder
# -*- coding: utf-8 -*-
#
# Copyright 2020 isobar. All Rights Reserved.
#
# Usage:
# python qrdecoder.py img.jpg
#
import os
import sys
import json
@wwwins
wwwins / mapgeo.json
Created March 2, 2020 08:10
geo json file
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.