Skip to content

Instantly share code, notes, and snippets.

View rkuzsma's full-sized avatar

Rich Kuzsma rkuzsma

View GitHub Profile
@rkuzsma
rkuzsma / install-node-10-raspberry-pi.md
Created January 2, 2023 00:37
How to install node 10 on Raspberry Pi 3

I couldn't get the current version of NodeJS to install on Raspberry Pi. I kept getting errors like this during installation:

node: /usr/lib/arm-linux-gnueabihf/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by node)
node: /usr/lib/arm-linux-gnueabihf/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by node)
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `nvm use --delete-prefix v12.2.0` to unset it.

I manually installed an older version of Node and npm using a tarball download. Note that I had to use the armv6l, not armv7, to prevent the error.

@rkuzsma
rkuzsma / gist:0ceefeb3739b96d16b04342cbc5fe54a
Created May 16, 2019 18:10
How to run an old Firefox browser in Docker Ubuntu with VNC
```
docker run -p 6080:80 -v /dev/shm:/dev/shm dorowu/ubuntu-desktop-lxde-vnc
```
Browse to http://127.0.0.1:6080/
In the VNC UI, run the LXTerminal. Paste these commands to install a given version of Firefox. Set `FF_VERS` to the release you want. See available releases at http://releases.mozilla.org/pub/firefox/releases
```
apt-get update && apt-get install wget
@rkuzsma
rkuzsma / karma-headless-docker-chromefirefox-configuration.md
Created October 28, 2018 14:38
Example Karma config using Docker images for Chrome Headless and Firefox Headless

Here's an example snippet for how to configure karma.conf.js to use Dockerized Chrome Headless and Dockerized Firefox Headless.

See also how to let Karma run JavaScript tests on Internet Explorer 11 in Windows with VirtualBox on Mac OS X

You have to npm install @rkuzsma/karma-docker-launcher. And, because this module name is scoped, Karma won't automatically recognize it by the karma-* prefix, so the plugins addition below is necessary.

// karma.conf.js
module.exports = function (config) {
  config.set({
@rkuzsma
rkuzsma / virtualbox-ie11-win.md
Created October 28, 2018 14:32
Let Karma run JavaScript tests on Internet Explorer 11 in Windows with VirtualBox on Mac OS X
@rkuzsma
rkuzsma / update_etc_hosts.sh
Last active February 2, 2023 07:12
Bash function to add a hostname:ip entry into your /etc/hosts file
#!/bin/bash
# Usage:
# update_etc_hosts "some-host-name" "some-ip-addr"
update_etc_hosts () {
HOST_NAME=$1
HOST_IP=$2
NO_SUDO=$3
HOST_ENTRY="$HOST_IP $HOST_NAME"
HOSTS_FILE="/etc/hosts"
TMPFILE=$(mktemp)
@rkuzsma
rkuzsma / time_unit.rb
Last active July 24, 2017 02:46
TimeUnit helper written in Ruby to convert time expressions with a unit to milliseconds. e.g. 1m -> 60_000, 60s -> 60_000, 5000ms -> 5, 10s -> 10_000
# Created under Apache 2.0 License.
# Author: Rich Kuzsma
# Date: July 23, 2017
# Convert time duration strings like "10s" into milliseconds
module TimeUnit
UNITS_IN_MS = {
'd' => 86_400_000,
'h' => 3_600_000,
'm' => 60_000,
@rkuzsma
rkuzsma / top-cpu-process.sh
Created June 12, 2017 00:37
Bash script to fetch and sort the top CPU consuming process, displaying a concatenated form of the process startup command line arguments
# The sed expression is intended to replace this:
# %CPU %MEM COMMAND
# 0.0 0.1 some really really really long process args
# with this:
# %CPU %MEM COMMAND
# 0.0 0.1 some reall...ocess args
# In the sed regex:
# [^[:space:]]* means "a sequence non-whitespace characters"
# \s* means "a sequence of whitespace characters"
# The sed regex matches the first and last 10 characters of the process args,
@rkuzsma
rkuzsma / Dockerfile
Created April 1, 2017 21:53
Demonstrate failed attempt to build and run Jamvm with OpenJDK 8 inside Docker
FROM openjdk:8
# Download jamvm from source and apply this patch to src/classlib/openjdk/natives.c:
# https://sourceforge.net/u/tdaitx/jamvm/ci/f342a84116edfe28ab75ebfa17fcf929bafb02c1/tree/src/classlib/openjdk/natives.c?diff=236f9d849cf52faeb150a6cd5ba6fbeb61bd2f1f
RUN apt-get update -qq && apt-get install -y \
vim build-essential zlib1g-dev \
openjdk-8-jre-jamvm libtool autoconf automake
RUN git clone https://git.code.sf.net/p/jamvm/code jamvm-code
@rkuzsma
rkuzsma / get-k8s-node-ip-addresses.sh
Created January 5, 2017 03:33
Get external IP address of Kubernetes nodes
#!/bin/bash
kubectl get nodes --selector=kubernetes.io/role!=master -o jsonpath={.items[*].status.addresses[?\(@.type==\"ExternalIP\"\)].address}
@rkuzsma
rkuzsma / store-secrets.md
Created December 30, 2016 23:48
Poor-man's secure ENV variable storage using GPG

Store the secrets on a local machine:

mkdir -p ~/.secrets
touch ~/.secrets/my_secrets
chmod 600 ~/.secrets/my_secrets
cat << EOF | gpg -c -o ~/.secrets/my_secrets
export SOME_SECRET_VARIABLE=some value
export ANOTHER_SECRET_VARIABLE=another value
EOF