Skip to content

Instantly share code, notes, and snippets.

View skwashd's full-sized avatar
👨‍💻
planning, coding, reviewing

Dave Hall skwashd

👨‍💻
planning, coding, reviewing
View GitHub Profile
@skwashd
skwashd / pre-commit
Last active February 6, 2024 15:20
Git pre-commit hook that blocks commits for files that contain swear words.
View pre-commit
#!/bin/bash -e
#
# Git pre-commit hook that blocks commits for files that contain swear words.
#
# Created by Dave Hall - http://davehall.com.au
# Distributed under the terms of the WTFPL - http://www.wtfpl.net/
#
# Please don't use this fucking script, it is shit!
#
@skwashd
skwashd / autoscroll.js
Created November 12, 2023 04:03
Safari doesn't support the behaviour property when calling window.scroll. This prevents smooth scrolling. Copy and paste this code into your JS console to get smooth scrolling. Great for screen capture videos.
View autoscroll.js
const footerHeight = 800;
let pos = 0,
pageHeight = document.body.offsetHeight,
winHeight = window.innerHeight,
maxPos = pageHeight - winHeight - footerHeight;
function scrollWin() {
if (pos >= maxPos) {
console.log(`We're done at ${pos}`);
@skwashd
skwashd / README.md
Last active April 11, 2023 18:02
Copy AWS SSM Parameter Store Path
View README.md

This Python (3.6+) script is for migrating Amazon AWS System Manager (SSM) Parameter Store keys from one path to another.

Quick Start

To install the script do the following:

  • Configure your AWS credentials
  • Grab the code from this gist
  • Make it executable (chmod +x /path/to/copy-ssm-ps-path.py)
  • pip install boto3 (if you don't have it installed already)
@skwashd
skwashd / .gitignore_global
Last active August 23, 2022 08:55
Global .gitignore configuration for PHP and Python developers
View .gitignore_global
# Save this file as ~/.gitignore_global
# Add the following entry to ~/.gitconfig
#
# [core]
# excludesfile = /Users/dave/.gitignore_global
#
# Compiled source #
###################
*.class
@skwashd
skwashd / README.md
Last active January 15, 2022 15:29
Auto starting minecraft server in a docker container on Ubuntu 16.04
View README.md

The better way to do this

During a twitter conversation with itzg, he suggested that I use [docker's built in --restart="unless-stopped" runtime flag] (https://gist.github.com/itzg/36e59186f6195a445f1f1fa2b0087ea9). That worked a treat and means I don't need to maintain an extra service.

My old way of doing it

This is only retained for historic record. Don't follow these steps.

If you want to run a minecraft server in a docker container on Ubuntu 16.04 and have it automatically start at boot, follow these steps:

@skwashd
skwashd / .gitconfig
Created October 3, 2021 04:31
My gitconfig
View .gitconfig
[user]
name = Dave Hall
email = skwashd@example.com
signingkey = GPG-KEY-FINGERPRINT # follow these instructions to setup https://andrewmatveychuk.com/how-to-sign-you-commits-with-gpg-git-and-yubikey/
[core]
editor = vim # no debate
excludesfile = ~/.gitignore_global # Generated using https://www.gitignore.io/api/diff,patch,go,vim,macos,python,pycharm,webstorm,archives,phpstorm,drupal,node
[commit]
@skwashd
skwashd / configure-dependabot.py
Created August 27, 2019 03:50
Batch create dependabot config.yml file in github repos
View configure-dependabot.py
#!/usr/bin/env python3
import base64
import os
import requests
token = os.environ.get("GITHUB_TOKEN")
org = os.environ.get("GITHUB_ORG")
@skwashd
skwashd / README.md
Last active September 12, 2020 18:01
Export stored passwords from Google Chrome to 1Password
View README.md

This code snippet is for exporting passwords stored in Google Chrome for use in 1Password. It generates a 1Password compatiable CSV file.

NOTE: Your password are exported as plain text. Take proper precautions when storing the file and use a secure deletion tool.

To export your passwords follow these steps:

  • visit chrome://settings-frame/passwords
  • Open the Chrome console (Mac: [Cmd] + [Option] + J / Windows or Linux: [Ctrl] + [Shift] + J`)
@skwashd
skwashd / README.md
Last active May 27, 2020 07:24
Drupal git pre-commit hook
View README.md

This pre-commit hook is designed to be used for Drupal 7 and 8 sites.

Download the pre-commit file. Save it as .git/hook/pre-commit in your git repo. You need to ensure that the file is executable.

If you want this to be added to all new projects automatically, add it to your git init templates.

To install and PHP CodeSniffer for Drupal, please read the official documentation.

To see this working checking out this short YouTube video.

@skwashd
skwashd / enable-github-security-tooling.py
Created August 26, 2019 16:24
Bulk enable dependabot and security alerts on github repos
View enable-github-security-tooling.py
#!/usr/bin/env python3
import json
import os
import requests
token = os.environ.get("GITHUB_TOKEN")
org = os.environ.get("GITHUB_ORG")