Skip to content

Instantly share code, notes, and snippets.

View AlexChesters's full-sized avatar

Alex Chesters AlexChesters

View GitHub Profile
@AlexChesters
AlexChesters / jq-cheetsheet.md
Created July 2, 2024 12:10 — forked from olih/jq-cheetsheet.md
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@AlexChesters
AlexChesters / no-more-hn-discussions.user.js
Created April 6, 2021 08:53
hides all discussions on Hacker News
// ==UserScript==
// @name No More HN Discussions
// @version 0.0.1
// @grant none
// @include https://news.ycombinator.com/*
// ==/UserScript==
// hide all comments
const allTableLinks = document.querySelectorAll('td.subtext > a')
@AlexChesters
AlexChesters / select-all-plugins.js
Last active October 7, 2020 13:37
Greasemonkey script to allow you to easily select all Jenkins plugins to update them
// ==UserScript==
// @name Jenkins - select all plugins
// @version 0.1
// @description provides a utility button to allow you to select all Jenkins plugins at once
// @author Alex Chesters
// @match https://ci.itv.test.tools.bbc.co.uk/pluginManager/
// ==/UserScript==
const selectAll = () => {
const allInputs = document.querySelectorAll('table input')
@AlexChesters
AlexChesters / ukpd-example.js
Created June 18, 2020 12:34
example usage of ukpd
const UKPD = require('ukpd')
try {
const data = await UKPD.streetLevel('52.629729', '-1.131592', '2016-07')
console.log(`there were ${data.length} crimes in the area during 2016-07`)
} catch (err) {
console.error('An error occurred', err)
}
@AlexChesters
AlexChesters / race.js
Created July 25, 2019 13:47
race promises
const invertPromise = (promise) => new Promise(
(resolve, reject) => promise.then(reject, resolve)
)
const raceToSuccess = (promises) => invertPromise(
Promise.all(promises.map(invertPromise))
)
const fast = () => {
return new Promise((resolve) => {
@AlexChesters
AlexChesters / budget.json
Created July 12, 2018 22:45
An example CloudFormation template for an AWS Budget with an alarm
{
"Description": "A Budget, with alarm, to monitor My Component",
"Resources": {
"EmailTopic": {
"Type": "AWS::SNS::Topic",
"Properties": {
"Subscription": [
{
"Endpoint": "bill.bob@gmail.com",
"Protocol": "email"
import boto3
client = boto3.client(‘rekognition’, region_name=’eu-west-1')
def compare_faces(source_image_path, target_image_path):
source_image = open(source_image_path, ‘rb’)
target_image = open(target_image_path, ‘rb’)
response = client.compare_faces(
SourceImage={‘Bytes’: bytearray(source_image.read())},
TargetImage={‘Bytes’: bytearray(target_image.read())}
)
@AlexChesters
AlexChesters / shared-library.groovy
Last active July 20, 2017 13:41
An example of using a Shared Library in a Jenkins Pipeline
@Library('connected-tv-pipeline-shared-library') _
pipeline {
stages {
stage('Install dependencies') {
steps {
script {
new org.casper.Casper().installDependencies()
}
}
@AlexChesters
AlexChesters / script-in-declarative.groovy
Created July 13, 2017 21:37
An example of using script block in a Declarative Jenkins Pipeline
stage('Set the build display name') {
steps {
script {
CURRENT_BRANCH = sh(returnStdout: true, script: 'git rev-parse --abbrev-ref HEAD').trim()
CURRENT_HASH = sh(returnStdout: true, script: 'git rev-parse --short HEAD').trim()
currentBuild.displayName = "$CURRENT_BRANCH - $CURRENT_HASH"
}
}
}
@AlexChesters
AlexChesters / declarative.groovy
Last active July 13, 2017 21:24
An example of a declarative Jenkins Pipeline
pipeline {
stages {
stage('Preparation') {
env.mvnHome = tool 'M3'
}
stage('Build') {
sh "'${mvnHome}/bin/mvn' -Dmaven.test.failure.ignore clean package"
}
}
post {