Skip to content

Instantly share code, notes, and snippets.

View moranbw's full-sized avatar

Brian Moran moranbw

View GitHub Profile
@moranbw
moranbw / external_ip.sh
Created February 27, 2023 15:42
Get External IP via Cloudflare DNS
#!/bin/sh
dig +short txt ch whoami.cloudflare @1.1.1.1 | tr -d '"'
@moranbw
moranbw / observable-batch.ts
Last active April 6, 2022 02:10
RxJS Observables -> Requests in Batches
import { from, defer } from 'rxjs';
import { mergeAll, retry } from "rxjs/operators";
const pages = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900];
const doPageRequest = async (startAt: number) => {
const response = await requestingSomeData({ startAt })
return response.data;
}
@moranbw
moranbw / UpdateRemmina.sh
Created March 7, 2021 20:13
Compile Remmina on Ubuntu 20.04
#!/bin/bash
#https://gitlab.com/Remmina/Remmina/-/wikis/Compilation/Compile-on-Ubuntu-20.04
cd /your-remmina-location/remmina_devel/FreeRDP
git pull
cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_SSE2=ON -DWITH_CUPS=on -DWITH_PULSE=on -DCMAKE_INSTALL_PREFIX:PATH=/opt/remmina_devel/freerdp .
@moranbw
moranbw / psql-s3-backup.sh
Created August 3, 2020 03:27
Get a database dump via psql and push to S3
#!/usr/bin/env bash
if [ "$1" == "" ]; then
echo "Bucket name required"
exit 1
fi
DATE=$(date +%Y%m%d_%H%M)
DB_NAME=$PGDATABASE
BUCKET=$1
@moranbw
moranbw / async-recursive-files.js
Last active May 5, 2020 04:20
Recursively get a list of files from a directory using async / await
const fs = require('fs');
const path = "/your/data/path";
(async () => {
async function recurseDir(aDir, aArr, aCond) {
//remove trailing slash if it's there
aDir = aDir.replace("\/+$", "");
let dirents = await fs.promises.readdir(aDir, { withFileTypes: true });
@moranbw
moranbw / StartStopVM.ps1
Last active March 2, 2021 00:17
Weekday Schedule to Start or Stop Azure VMs and VMSSs
Param(
[Parameter (Mandatory= $true)]
[AllowEmptyCollection()]
[String[]]$VmNames,
[Parameter (Mandatory= $true)]
[AllowEmptyCollection()]
[String[]]$VmssNames,
[Parameter (Mandatory= $true)]
[string]$ResourceGroupName,
[Parameter (Mandatory= $true)]
@moranbw
moranbw / geojson-postgis-ingest.js
Last active April 18, 2020 03:02
Ingest directory of GeoJSON files into PostGIS using NodeJS child_process
const {exec} = require('child_process');
const fs = require('fs');
const dotenv = require('dotenv');
const path = require('path');
dotenv.config();
(async () => {
let dir = process.env.JSON_DIR;