Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
### Copy/paste from https://wiki.ubuntu.com/JonathanFerguson/Quagga
## Use
## ===
## $ sudo ./installQuagga.sh
## Install the Quagga routing daemon
## =================================
apt-get -y install quagga
@ben-bradley
ben-bradley / remote-debugging-nodejs.md
Created July 19, 2021 14:08
Remote Debugging Node.js

How to Remotely Debug a Node.js Process

  • Open the Brave/Chrome dev tools - brave://inspect/#devices
  • Click on Open dedicated DevTools for Node
  • Log in to the remote host:
ssh USER@REMOTE_IP
  • Figure out how to add --inspect-brk to the startup for your app
  • Bounce the app with whatever process manager you use
@ben-bradley
ben-bradley / .bashrc
Last active November 20, 2020 19:59
shell prompt
# Shell prompt stuff
function dashes() {
COLS=$(tput cols)
D=${PWD/$HOME/\~}
U=$(whoami)
H=$(hostname -s)
FLEN=16 # constant for spaces & timestamp
CLEN=$(( ${#D}+${#U}+${#H}+$FLEN ))
@ben-bradley
ben-bradley / .eslintrc.json
Created November 5, 2020 14:42
Lint defs
{
"env": {
"es6": true,
"node": true,
"jest": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2017
},
'use strict';
const iteratePromise = (promise, list) =>
list.reduce((promiseChain, item) =>
promiseChain.then((results) =>
promise(item).then((result) =>
results.concat(result)))
, Promise.resolve([]));
const list = [ `a`, `b`, `c` ];
@ben-bradley
ben-bradley / template.js
Created March 26, 2018 15:40
How to use variables as ES6 templates
'use strict';
const xml = '<foo>${data.bar}</foo>';
const template = (data, string) =>
eval('((data) => `'+string+'`)('+JSON.stringify(data)+')');
const obj = {
bar: `baz`
};
@ben-bradley
ben-bradley / validateCreditCardNumber.js
Created September 15, 2017 19:40
credit card validator
'use strict';
// https://stackoverflow.com/questions/72768/how-do-you-detect-credit-card-type-based-on-number/72801
const validate = (num) => (num
.replace(/\D/g, ``) // strip all non-digit chars
.split(``) // make an array where each digit is an element
.map((n) => Number(n)) // make them all numbers
.reverse() // reverse the order
.reduce((checksum, n, i) =>
(i % 2) ? checksum + n : checksum + (n * 2), 0) % 10) === 0;
@ben-bradley
ben-bradley / installNode.sh
Created July 31, 2014 04:24
How to get NodeJS installed on VyOS
#!/bin/bash
sudo su -
mkdir /opt/node
cd /opt/node
wget http://nodejs.org/dist/node-latest.tar.gz
tar zxvf ndoe-latest.tar.gz
cd node-v*
./configure
make
@ben-bradley
ben-bradley / index.js
Last active November 22, 2016 16:18
Create-React-App with MUI
// src/index.js
import React from 'react';
import ReactDOM from 'react-dom';
import injectTapEventPlugin from 'react-tap-event-plugin';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import App from './App';
import './index.css';
injectTapEventPlugin();
@ben-bradley
ben-bradley / keep.js
Created August 29, 2016 22:18
A way to dynamically assign property names during an object declaration
'use strict';
/**
* With a Promise that receives a context object, but returns a different value that you want to
* have assigned to the context, you can assign dynamic property names like this:
*/
const keep = (ctx, prop) => (value) => Object.assign(ctx, { [ prop ]: value });
const session = {};