Skip to content

Instantly share code, notes, and snippets.

@dmrub
dmrub / unifi-ls-all-clients.py
Last active April 8, 2022 17:46
List all Unifi clients
#!/usr/bin/env python
#
# This code is based on
# https://github.com/finish06/pyunifi/blob/master/unifi-ls-clients
#
# 1. Install pyunifi
# pip install --user pyunifi
# 2. Run this script
# unifi-ls-all-clients -c UNIFI_HOST -b UNIFI_PORT -u USER -p PASSWORD -V
@dmrub
dmrub / angular-webpack-patch.js
Created May 23, 2019 11:31
angular-webpack-patch.js
// https://gist.github.com/niespodd/1fa82da6f8c901d1c33d2fcbb762947d
const fs = require('fs');
const f = 'node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js';
fs.readFile(f, 'utf8', function (err,data) {
if (err) {
return console.log(err);
}
var result = data.replace(/node: false/g, 'node: {crypto: true, stream: true, fs: \'empty\'}');
@dmrub
dmrub / n3-test.js
Created May 16, 2019 10:52
N3.js example for parsing RDF string, storing tuples to store and retrieving them from store
const N3 = require('n3');
const { DataFactory } = N3;
const { namedNode, literal, defaultGraph, quad } = DataFactory;
const store = new N3.Store();
const parser = new N3.Parser();
parser.parse(
`PREFIX c: <http://example.org/cartoons#>
c:Tom a c:Cat.
c:Jerry a c:Mouse;
@dmrub
dmrub / Dockerfile
Last active May 8, 2024 17:07
Dockerfile piece for installing su-exec in debian/ubuntu container
# Install latest su-exec
RUN set -ex; \
\
curl -o /usr/local/bin/su-exec.c https://raw.githubusercontent.com/ncopa/su-exec/master/su-exec.c; \
\
fetch_deps='gcc libc-dev'; \
apt-get update; \
apt-get install -y --no-install-recommends $fetch_deps; \
rm -rf /var/lib/apt/lists/*; \
gcc -Wall \
#!/bin/bash
set -e
if ! [[ -x "$(command -v curl 2> /dev/null)" ]]; then
echo >&2 "No curl command"
exit 1
fi
if ! [[ -x "$(command -v openssl 2> /dev/null)" ]]; then
@dmrub
dmrub / this_dir.sh
Created April 23, 2018 16:14
How to get directory path of a shell script in bash
THIS_DIR="$(dirname "$(readlink -f "$BASH_SOURCE")")"
THIS_DIR=$( (cd "$(dirname -- "$BASH_SOURCE")" && pwd -P) )
THIS_DIR=$(dirname "$( readlink -f "${BASH_SOURCE}" 2>/dev/null || \
python -c "import os,sys; print(os.path.realpath(sys.argv[1]))" "${BASH_SOURCE}" )")