Skip to content

Instantly share code, notes, and snippets.

@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>"
@shirish87
shirish87 / main.ts
Created July 9, 2019 08:58
AWS Systems Manager: Parameter Store
import * as AWS from 'aws-sdk';
async function getParameterStoreValues(names: string[], region: string) {
const ssm = new AWS.SSM({ region });
const { Parameters = [], InvalidParameters = [] } = await ssm.getParameters({ Names: names }).promise();
if (InvalidParameters.length) {
throw new Error(`Invalid parameter names: ${InvalidParameters.join(', ')}`);
}
@shirish87
shirish87 / Makefile
Last active May 16, 2019 08:45
Manage docker-compose containers with make. With the directory structure in place, run `make deploy` to launch production mode locally.
# root/
# |_ app/
# | |_ Dockerfile
# | |_ secrets.env
# | |_ secrets.dev.env
# |_ web/
# | |_ Dockerfile
# | |_ secrets.env
# | |_ secrets.dev.env
@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 / JSONView Dark Theme.css
Created June 20, 2017 17:52 — forked from timnew/JSONView Dark Theme.css
This is a dark theme for JSONView chrome extension
body {
white-space: pre;
font-family: monaco, Consolas, Menlo, monospace;
color: white;
background: #282a36;
font-size: 12px;
line-height: 1.5m;
}
.property {
@shirish87
shirish87 / index.js
Created February 5, 2017 08:36
Authentication using external token microservice. file: src/services/authentication/index.js
'use strict';
const auth = require('feathers-authentication');
const request = require('request');
module.exports = function() {
const app = this;
const config = app.get('auth');
const authHost = config.local.authHost;
@shirish87
shirish87 / patch-boto-sqs.sh
Created January 22, 2017 06:31
Patches the boto library (v2) with the correct hostnames for Amazon SQS.
#!/usr/bin/env python
"""
Patches the boto library (v2) with the correct hostnames for Amazon SQS.
Work around for Celery issue:
https://github.com/celery/celery/issues/3221
which is waiting on PR in boto:
https://github.com/boto/boto/pull/3633
"""
from __future__ import print_function
@shirish87
shirish87 / bringit.go
Last active November 2, 2016 02:41
Util for ARM devices to download partial files using Range header. 'cuz curl'ing be buggy and wget 1.17.x doesn't support Range header when response is piped (http://savannah.gnu.org/bugs/?func=detailitem&item_id=20416).
package main
import (
"fmt"
"io"
"gopkg.in/cheggaaa/pb.v1"
"os"
"net/http"
"strconv"
"strings"
@shirish87
shirish87 / restrict_plex_dlna
Last active January 23, 2018 10:51
iptables-based blocking of Plex's DLNA ports
# =====================================================
# USAGE
# $> ips="192.168.0.10 192.168.0.11 192.168.0.12"
# $> restrict_plex_dlna block "$ips"
# $> restrict_plex_dlna unblock "$ips"
# =====================================================
restrict_plex_dlna() {
filters="tcp,32469 udp,1900"
@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)