Skip to content

Instantly share code, notes, and snippets.

@replete
replete / bootstrap.sh
Created October 23, 2021 16:48
Node/mongo application bootstrap script WIP
#!/bin/bash
log() { echo -e "\x1b[0m\033[1;30m$(date +%H:%M:%S)\x1b[0m $@ \x1b[0m" ; }
INFO='\x1b[0m\033[1;30m[>]\x1b[0m'
OK='\x1b[0m\033[1;32m[✔]\x1b[0m'
WARN='\x1b[0m\033[1;33m[?]'
ERROR='\x1b[0m\033[1;31m[!]'
NODEVER=v17.0.1
MONGODBNAME=appdb
@replete
replete / wip-abandoned-node-app-bootstrapper.js
Created October 23, 2021 13:45
Beginnings of a node-based bootstrapper for apps, abandoned for better bash scripting but there is a handy log function here and a few patterns useful when working with child_process sync
const fs = require('fs')
const exec = (cmd) => require('child_process').execSync(cmd, { shell: '/bin/bash' })
try {
let nodePath = exec('which node').toString().replace('\n', '')
let nodeVer = exec('node -v').toString().replace('\n', '')
const expectedNodeVer = fs.readFileSync('.nvmrc', 'utf-8').replace('\n', '')
const npmVer = exec('npm -v').toString().replace('\n', '')
const nodeVerComparison = versionCompare(nodeVer.substring(1), expectedNodeVer.substring(1))
@replete
replete / log.ts
Created October 13, 2021 18:36
Color-enhanced logger for Typescript Node
const color = {
reset: '\x1b[0m',
bright: '\x1b[1m',
dim: '\x1b[2m',
underscore: '\x1b[4m',
blink: '\x1b[5m',
reverse: '\x1b[7m',
hidden: '\x1b[8m',
fgBlack: '\x1b[30m',
@replete
replete / backupAndroid.sh
Created May 5, 2021 16:22
Android adb Backup bash script with notifications/checks on Mac
#!/usr/bin/env bash
# Backup Android via ADB
set -euf -o pipefail
# configuration
ADB_DEVICE_ID="beefdead" # your device id from `adb devices`
OUT_DIR="/Volumes/SOMEDRIVE/Android Backups"
FILENAME="android-$(date +%Y-%m-%d-%H%M).ab"
# change to script directory
@replete
replete / validators.blacklisted-characters.directive.js
Created April 18, 2017 16:03
Angular 1.x blacklisted characters (not allowed) validator.
(function() {
'use strict';
angular.module('shopperTrak.validators')
.directive('blacklistedCharacters', function (){
return {
require: 'ngModel',
restrict:'A',
link: function(scope, elem, attrs, ngModel) {
@replete
replete / validators.blacklisted-values.directive.js
Created April 18, 2017 16:02
Angular 1.x blacklisted values validator. Accepts a list of values that are not allowed.
(function() {
'use strict';
angular.module('shopperTrak.validators')
.directive('blacklistedValues', function (){
return {
require: 'ngModel',
restrict:'A',
link: function(scope, elem, attr, ngModel) {
@replete
replete / AutoHotkey_BrowserGestures_SwipeLeftRight.ahk
Created April 6, 2017 22:12
AutoHotkey - Browser Gestures (Swipe left/right navigate back/forward, middle-click like firefox)
GroupAdd, Browsers, ahk_class Chrome_WidgetWin_1
GroupAdd, Browsers, ahk_class MozillaWindowClass
GroupAdd, Browsers, ahk_class ApplicationFrameWindow
#MaxHotkeysPerInterval 219
;-----three finger tap for middle click-----
+^#F22::
SendInput, {MButton}
return
@replete
replete / initBrowserSupport.js
Created March 14, 2017 18:04
Browser support- alternative to modernizr
// Browser support
(function (d, h, w, n) {
//function hasProperties(properties, tagName) {
// var isStyle = !!!tagName;
// tagName = tagName || 'div';
// var el = d.createElement(tagName);
// for (var prop in properties) {
// if ((isStyle ? el.style[properties[prop]] : el[properties[prop]]) !== undefined ) {
// return true;
@replete
replete / replete.select.js
Created February 7, 2017 15:16
Select.js
(function (w, d, undefined) {
'use strict';
// TODO: Make some methods private for better inheritance
var h = d.documentElement;
function getNamespace(ns, names) {
for (var i = 0, n = names.split('.'), l = n.length; i < l; i++) {
@replete
replete / Dockerfile
Created February 1, 2017 15:09
Test dockerfile
FROM debian:latest
RUN apt-get -y update && apt-get install -y fortunes
CMD /usr/games/fortune