Skip to content

Instantly share code, notes, and snippets.

View AlexChesters's full-sized avatar

Alex Chesters AlexChesters

View GitHub Profile
@AlexChesters
AlexChesters / incrementbuild.sh
Created July 4, 2015 14:28
Increment build number in Xcode automatically when archiving (add as a build step)
if [ $CONFIGURATION == Release ]; then
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/${INFOPLIST_FILE}"
fi
@AlexChesters
AlexChesters / URLBuilder.h
Last active December 8, 2015 14:32
URLBuilder class written in Objective-C
//
// URLBuilder.h
// lyrical
//
// Created by Alex Chesters on 13/11/2015.
// Copyright © 2015 Alex Chesters. All rights reserved.
//
#import <Foundation/Foundation.h>
@AlexChesters
AlexChesters / scripted.groovy
Last active July 13, 2017 21:24
An example of a Scripted Jenkins Pipeline
node {
try {
def mvnHome
stage('Preparation') {
git 'https://github.com/jglick/simple-maven-project-with-tests.git'
mvnHome = tool 'M3'
}
stage('Build') {
sh "'${mvnHome}/bin/mvn' -Dmaven.test.failure.ignore clean package"
}
@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 {
@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 / 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()
}
}
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 / 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"
@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 / 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)
}