Skip to content

Instantly share code, notes, and snippets.

View adamelliotfields's full-sized avatar
🤗
hf.co/adamelliotfields

Adam Fields adamelliotfields

🤗
hf.co/adamelliotfields
View GitHub Profile
@adamelliotfields
adamelliotfields / npm_upgrade.sh
Last active August 31, 2023 12:58
Upgrade pinned NPM dependencies
#!/usr/bin/env bash
#shellcheck disable=SC2155
set -euo pipefail
# upgrade outdated pinned dependencies and commit the changes
npm_upgrade() {
local dry_run=false
local prod_only=false
local help=false
local help_msg="npm_upgrade
@adamelliotfields
adamelliotfields / windows-ssh-no-password-with-keys-wsl2.md
Last active March 22, 2025 13:35
Windows SSH Server with Password-less Key Authentication and Default WSL2 Shell

Windows SSH Server with Password-less Key Authentication and Default WSL2 Shell

Disclaimer: I am not a Windows Admin and I'm not even that good with PowerShell.

I wanted to be able to SSH into my Windows laptop directly into Linux. I also wanted to disable password authentication and only allow public key (RSA in my case) authentication.

Scott Hanselman wrote a blog post on how to make your default WSL2 distro your default shell for SSH. Windows OS Hub published an article on using public key

@adamelliotfields
adamelliotfields / index.scss
Created January 30, 2020 18:42
Bootstrap 4 Flex Grid
/*!
* Bootstrap Grid v4.4.1 (https://getbootstrap.com/)
* Copyright 2011-2019 The Bootstrap Authors
* Copyright 2011-2019 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
$grid-columns: 12 !default;
$grid-row-columns: 6 !default;
$grid-gutter-width: 30px !default;
@adamelliotfields
adamelliotfields / index.js
Last active August 11, 2023 16:17
Grafana Dashboard Screenshot using Puppeteer
#!/usr/bin/env node
/**
* Grafana Dashboard Screenshot
*
* Derived from https://github.com/sindresorhus/capture-website/blob/v0.8.0/index.js
* by @sindresorhus (MIT).
*/
const fs = require('fs');
@adamelliotfields
adamelliotfields / docker_lib.sh
Last active November 14, 2019 00:01
Access /var/lib/docker on Mac
#!/bin/bash
set -e
docker run \
-it \
-v /var/lib/docker:/var/lib/docker \
-w /var/lib/docker \
--rm \
--name=debian \
@adamelliotfields
adamelliotfields / enable_bridge_netfilter.sh
Created November 11, 2019 06:07
Persist bridge-nf-call-iptables on Reboot
#!/bin/bash
set -e
# Running `modprobe br_netfilter` does not persist.
echo 'br_netfilter' >> /etc/modules
# Running `sysctl net.bridge.bridge-nf-call-iptables=1` does not persist.
echo 'net.bridge.bridge-nf-call-iptables=1' >> /etc/sysctl.conf
echo 'net.bridge.bridge-nf-call-ip6tables=1' >> /etc/sysctl.conf
@adamelliotfields
adamelliotfields / reset_iptables.sh
Last active November 12, 2019 03:47
Reset iptables / ip6tables
#!/bin/bash
set -e
if [ "$(id -u)" != '0' ]; then
SUDO=sudo
fi
policies=(
'INPUT'
@adamelliotfields
adamelliotfields / index.scss
Created July 27, 2019 20:50
Bootstrap 3 Sass Grid
$grid-columns: 12;
$grid-gutter-width: 30px;
$grid-breakpoints: (
xs: 0,
sm: 768px,
md: 992px,
lg: 1200px,
);
$screen-sm-min: map-get($grid-breakpoints, "sm");
@adamelliotfields
adamelliotfields / select.sql
Last active March 24, 2019 20:08
SQL Select Tables without Primary Key in Database
SELECT tables.table_schema, tables.table_name
FROM tables
LEFT JOIN key_column_usage AS kcu ON (
kcu.table_name = tables.table_name AND
kcu.constraint_schema = tables.table_schema AND
kcu.constraint_name = 'PRIMARY')
WHERE tables.table_schema = @db_name AND
kcu.constraint_name IS NULL;
@adamelliotfields
adamelliotfields / docker-compose.yml
Created February 10, 2019 22:39
Docker Compose Mongo with Mongo Express
version: "3.5"
services:
mongo:
image: mongo:latest
container_name: mongo
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: admin
ports: