Skip to content

Instantly share code, notes, and snippets.

@shirish87
shirish87 / downloader.js
Created November 21, 2017 08:56
Apply response timeout when downloading large files from S3 using Axios.
const axios = require('axios')
const fs = require('fs-extra')
const TimeoutStream = require('./timeoutStream')
const DEFAULT_TIMEOUT = 10000
module.exports.download = function download(downloadURL, destPath, timeout=DEFAULT_TIMEOUT) {
const tmpPath = `${destPath}.tmp`
@shirish87
shirish87 / jq-jwt.sh
Created March 14, 2024 16:48
jq-jwt.sh
jq -R 'split(".") | .[:2] | map( @base64d | fromjson | if (.exp) then (. + ({ "expiry": .exp | strflocaltime("%Y-%m-%dTT%H:%M:%S %Z") })) else . end )' <<< "$1"
runtime.cc:655] Runtime aborting...
runtime.cc:655] Dumping all threads without mutator lock held
runtime.cc:655] All threads:
runtime.cc:655] DALVIK THREADS (38):
runtime.cc:655] "Binder:17466_1" prio=5 tid=14 Runnable
runtime.cc:655] | group="" sCount=0 dsCount=0 flags=0 obj=0x13501ec0 self=0x7a21018080
runtime.cc:655] | sysTid=17485 nice=0 cgrp=default sched=0/0 handle=0x784c2fbcc0
runtime.cc:655] | state=R schedstat=( 26369115 43215835 91 ) utm=2 stm=0 core=2 HZ=100
runtime.cc:655] | stack=0x784c204000-0x784c206000 stackSize=995KB
runtime.cc:655] | held mutexes= "abort lock" "mutator lock"(shared held)
EQ preset applied=0
EQ preset=Normal
EQ Normal band=0 level=300 / 1500
EQ Normal band=1 level=0 / 1500
EQ Normal band=2 level=0 / 1500
EQ Normal band=3 level=0 / 1500
EQ Normal band=4 level=300 / 1500
EQ preset=Classical
EQ Classical band=0 level=500 / 1500
EQ Classical band=1 level=300 / 1500
@shirish87
shirish87 / audiobook-split-parts.sh
Last active December 15, 2022 14:47 — forked from vi/split_by_silence.sh
Using FFmpeg to split mp3 audiobook file into mp3 parts based on audio volume level
#!/bin/bash
IN="$1"
MIN_DUR_MINS="${2:-30}"
MIN_PART_DURATION_SECS=$(($MIN_DUR_MINS * 60))
IN_PATH=`realpath "$1"`
DEFAULT_OUTDIR="$(dirname "$IN_PATH")/parts"
OUTDIR="${3:-$DEFAULT_OUTDIR}"
OUTFILE_PATTERN="${OUTDIR}/part-%03d.mp3"
@shirish87
shirish87 / debkit.sh
Last active December 22, 2021 00:52
Install Debian (jessie) chroot on Android
#!/system/bin/sh
# #######################################
# Adapted from DebKit
# https://github.com/cybertim/DebKit/blob/db894dea44705c4a67e0bb8faa67fc3010755483/src/main/res/raw/debkit
# #######################################
set -e
# directory for setting up debkit
ROOT=$(pwd)
@shirish87
shirish87 / check-inet.sh
Last active September 28, 2021 00:13
Script on the intranet raspberry pi to reconnect the PPPoE internet connection in the TP-Link gateway. Notifies other devices using push notifs via Gotify server.
#!/bin/bash -e
######
# Installed under cron for root user
# sudo crontab -e
# * * * * * bash /home/marvin/cron-scripts/check-inet.sh >> /tmp/check-inet.log 2>&1
######
GATEWAY_IP=192.168.0.1
GATEWAY_AUTH="Basic <base64:userpass>"
import {
ClientOptions,
WritePrecision,
WriteOptions,
WritePrecisionType,
} from '@influxdata/influxdb-client/dist/options';
import TransportImpl from '@influxdata/influxdb-client/dist/impl/node/NodeHttpTransport';
import WriteApiImpl from '@influxdata/influxdb-client/dist/impl/WriteApiImpl';
import QueryApiImpl from '@influxdata/influxdb-client/dist/impl/QueryApiImpl';
import {
@shirish87
shirish87 / extract-product-list.sh
Created April 15, 2020 14:41
Scripts to extract product list (for organizing pooled orders to StarBazaar during COVID-19 lockdown)
#!/bin/bash -e
# Usage: ./extract-product-list.sh foodgrains.json > foodgrains.txt
jq -j '.ProductList[] | .product[] | .Name, " (Price: ", .Price, ", Offer Price: ", .sale_price, ")\n"' $@
#!/bin/bash -e
dest="$(date '+%Y-%m-%d')-snapshot"
container="${1:-influxdb-1}"
db="${2:-comp_prices}"
destpath="/tmp/${dest}"
destfile="/tmp/${dest}.tgz"
docker exec -it $container influxd backup -portable -database $db "$destpath"