Skip to content

Instantly share code, notes, and snippets.

View jsumners's full-sized avatar

James Sumners jsumners

View GitHub Profile
@jsumners
jsumners / readme.md
Created March 3, 2021 12:54
Start new PR with an existing PR as a base

Ocassionally, someone will start a pull request and, for various reason, not see it through. Later, someone else may wish to finish that work. Even though the original author was unable to finish their work, we should still include their efforts in our project's history. To do so, the person wishing to finish the original pull request should start their new pull request using the original as the base.

The simplest workflow to accomplish this is:

$ # For the project on GitHub to your account and then:
$ git clone 
@jsumners
jsumners / no-wip.yml
Created September 23, 2020 13:28
No WIP PR merges
name: "No WIP PR Title"
on:
pull_request_target:
types:
- opened
- edited
- synchronize
jobs:
@jsumners
jsumners / bar.js
Created April 21, 2020 16:04
self-ref testing
// `lib/bar.js`
module.exports = 'bar'
@jsumners
jsumners / bar.js
Created April 21, 2020 15:55
self-ref testing
// `lib/bar.js`
module.exports = 'bar'
@jsumners
jsumners / async-await-result-pattern.js
Created June 28, 2018 16:28
A simple pattern for working with async/await
async function doFoo () {
let bar
try {
bar = await something_that_can_throw('a value')
} catch (error) {
return {error}
}
return {value: bar}
}

Change Well Known Passwords

This is an Ansible playbook for chaning default, well known, or missing passwords on a set of hosts. To use it:

  1. Start a listener: socat tcp4-listen:8000,fork stdout
  2. Run the playbook: ansible-playbook update_password.pb.yml -e 'user=target_user' -e 'passwd=known_pass'

Your listener will receive notifications like:

@jsumners
jsumners / Intro.txt
Created September 21, 2017 20:57
Deal with NICs in Ansible without knowing what udev/systemd will call them
Scenario:
You are building a load balancer wherein you want to bond the interfaces that will be used to serve the traffic.
You're managing this via Ansible. You don't want to have to boot to an OS to see what udev/system will name the
NICs you intend to bond, because that is just stupid. So you decide to work with the MAC addresses. Oops,
the `ansible_facts` don't make that easy.
Solution:
The convoluted trickery published here.
@jsumners
jsumners / ansible_git_via_ports.sh
Last active September 21, 2017 18:21
Install Ansible from GitHub with MacPorts
#!/bin/bash
sudo port install py27-pip pip_select && \
sudo port select --set python python27 && \
sudo port select --set python2 python27 && \
sudo port select --set pip pip27 && \
sudo pip install jmespath && \
sudo pip install git+git://github.com/ansible/ansible.git@stable-2.4
// https://tc39.github.io/ecma262/#sec-set-constructor
const MyList = class MyList extends Set {}
MyList.fromArray = function (aray) {
const list = new MyList()
array.forEach((a) => list.add(a)
return list
}
MyList.prototype.has = function (ele) {
@jsumners
jsumners / ntp.conf
Created July 26, 2017 16:12
RHEL7 Ansible task list to fix NTP
# {{ansible_managed}}
{% if 'vmware' in ansible_product_name|lower %}
# Disable panic quit if system is >1000s out of sync because VMware.
tinker panic 0
{% endif %}
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery