Skip to content

Instantly share code, notes, and snippets.

View dhensby's full-sized avatar

Daniel Hensby dhensby

  • London, UK
  • 05:01 (UTC +01:00)
  • X @dhensby
View GitHub Profile
@dhensby
dhensby / cert-merge.js
Last active March 2, 2022 14:44
Add an intermediate certificate to an Azure Key Vault Certificate (Node CLI)
const { DefaultAzureCredential } = require('@azure/identity');
const { CertificateClient } = require('@azure/keyvault-certificates');
const { SecretClient } = require('@azure/keyvault-secrets');
const { pkcs12, asn1, pki } = require('node-forge');
const { writeFile, readFile } = require('fs').promises;
const [nodePath, scriptPath, vaultName, certName, pathToIntermediate, outFile] = process.argv;
function output(string) {
return new Promise((resolve, reject) => process.stdout.write(`${string}\n`, (err) => err ? reject(err) : resolve()));
@dhensby
dhensby / az-signed-publickey-auth.js
Created March 25, 2021 10:49
Example of publickey authentication with ssh2-streams and azure key vault
const { CryptographyClient, KeyClient } = require('@azure/keyvault-keys');
const { AzureCliCredential } = require('@azure/identity');
const { SSH2Stream, utils, constants: { ALGORITHMS: { SUPPORTED_SERVER_HOST_KEY } } } = require('ssh2-streams');
const { Socket } = require('net');
const { asn1, pki, md, ssh, jsbn: { BigInteger } } = require('node-forge');
const VAULT_URI = process.env.VAULT_URI;
// this is lifted from node-forge (https://github.com/digitalbazaar/forge/blob/0.10.0/lib/rsa.js#L284-L313)
// unfortunately it's not exported
@dhensby
dhensby / README.md
Last active October 2, 2022 19:01
Unattended provisioning of CS:GO LinuxGSM cloud server using Cloud Init / User Data

CS:GO LinuxGSM Server with Cloud Init

This cloud-init config will provision a CS:GO server using LinuxGSM without the need for any manual intervention.

Usage

When provisioning a cloud server with providers such as Digital Ocean, you can provide "user data" to help provision cloud servers.

This configuration allows you to make use of the "user data" to automatically provision the CS:GO server.

#!/usr/bin/env bash
echo `pwd`
LEGACY_CORE=('cms' 'reports' 'siteconfig' 'framework' 'installer')
LEGACY_TAG="4.2.0-beta1"
LEGACY_BRANCH="4.2.0"
RECIPES=('recipe-cms' 'recipe-core')
@dhensby
dhensby / release-branches.sh
Last active July 23, 2018 18:54
Create release branch from specific tag
#!/usr/bin/env bash
echo `pwd`
LEGACY_CORE=('cms' 'reports' 'siteconfig' 'framework' 'installer')
LEGACY_TAG="4.2.0-beta1"
LEGACY_BRANCH="4.2.0"
RECIPES=('recipe-cms' 'recipe-core')
@dhensby
dhensby / mergup.sh
Last active July 30, 2018 10:28
Merge up core SS modules
#!/usr/bin/env bash
LEGACY_CORE=('cms' 'reports' 'siteconfig' 'framework' 'installer')
LEGACY_BRANCHES=('4.2.0' '4.2' '4' 'master')
RECIPES=('recipe-cms' 'recipe-core')
RECIPE_BRANCHES=('4.2.0' '4.2' '4' 'master');
NEW_CORE=('assets' 'admin' 'asset-admin' 'campaign-admin' 'errorpage' 'versioned')
NEW_BRANCHES=('1.2.0' '1.2' '1' 'master')
@dhensby
dhensby / main.go
Created July 11, 2018 00:04
Pwned Passwords API - Go CLI script to test your passwords locally
package main
import (
"fmt"
"os"
humanize "github.com/dustin/go-humanize"
)
var (
password string
@dhensby
dhensby / pwned.php
Created July 10, 2018 14:55
Pwned Passwords API - PHP CLI script to test your passwords locally
#!/usr/bin/env php
<?php
/**
* Usage: pwned.php '<password>'
*/
// get the first argument as the password
$password = $argv[1];
@dhensby
dhensby / SimpsonsAdmin.php
Created December 13, 2017 16:47
SPIKE Find and replace for SilverStripe
<?php
use SilverStripe\Admin\LeftAndMain;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Control\HTTPResponse_Exception;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\Form;
use SilverStripe\Forms\FormAction;
use SilverStripe\Forms\TextField;
@dhensby
dhensby / speedy-provision.sh
Created September 7, 2017 11:01
Speedily provision a silverstripe lamp stack on CentOS 7 including my custom user with ssh keys
#!/usr/bin/env bash
GISTID=''
if [ -z "$GISTID" ]; then
echo "GIST ID NEEDED"
exit 1
fi
# install deps