Skip to content

Instantly share code, notes, and snippets.

View cayblood's full-sized avatar

Carl Youngblood cayblood

View GitHub Profile
∴ sudo jamf recon
Password:
Retrieving inventory preferences from https://casper.amazon.com:8443/...
Finding extension attributes...
Locating applications...
Locating hard drive information...
Locating accounts...
Locating printers...
Searching path: /System/Applications
Searching path: /Applications
@cayblood
cayblood / basic-chaincode.js
Created March 19, 2020 16:21
Basic chaincode example
'use strict';
const shim = require('fabric-shim');
let Chaincode = class {
async Init(stub) {
console.info('============= Init called =============');
return shim.success();
}
async Invoke(stub) {
version: '2'
services:
cli:
container_name: cli
image: hyperledger/fabric-tools:1.2.0
tty: true
environment:
- GOPATH=/opt/gopath
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_LOGGING_LEVEL=info # Set logging level to debug for more verbose logging
@cayblood
cayblood / permissions-example.js
Last active February 26, 2020 02:19
example of how to use hyperledger fabric permissions
'use strict';
const shim = require('fabric-shim');
async function requireRole(stub, role) {
const ClientIdentity = shim.ClientIdentity;
let cid = new ClientIdentity(stub);
if (!cid.assertAttributeValue('role', role))
throw new Error(`Unauthorized access: ${role} required`);
}
@cayblood
cayblood / AMBManagementMachinePolicy.json
Created February 26, 2020 00:15
Policy attached to fabric client machine role that connects to Amazon Managed Blockchain networks.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ManageNetworkResources",
"Effect": "Allow",
"Action": [
"managedblockchain:CreateProposal",
"managedblockchain:GetProposal",
"managedblockchain:DeleteMember",
# display user@host and current working dir
PS1='\[$(tput setaf 2)\]\u\[$(tput sgr0)\]@\[$(tput setaf 3)\]\h\[$(tput sgr0)\] \w'
# display git info if applicable
PS1=$PS1'\[$(tput setaf 5)\]`if [ "$(vcprompt)" != "" ]; then echo " $(vcprompt | tr -d '"'"'[:space:]'"'"')"; fi`'
# display rvm info if applicable
PS1=$PS1'\[$(tput setaf 1)\] [`if [ "$(~/.rvm/bin/rvm-prompt)" != "" ]; then echo "$(~/.rvm/bin/rvm-prompt)"; fi`]\[$(tput sgr0)\]'
# display nvm info if available
@cayblood
cayblood / saltaires-deploy.sh
Created April 12, 2019 17:42
Saltaires static web site deployment script
#!/bin/bash
# Load RVM into a shell session *as a function*
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
# First try to load from a user install
source "$HOME/.rvm/scripts/rvm"
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
# Then try to load from a root install
source "/usr/local/rvm/scripts/rvm"
else
#!/bin/bash
INSTANCE_ID=$(aws ec2 describe-instances | jq -r '.Reservations[].Instances[] | {id: .InstanceId, name: .Tags[] | select(.Key == "Name") | .Value} | select(.name == "carl-development") | .id')
aws ec2 start-instances --instance-ids "$INSTANCE_ID"
@cayblood
cayblood / multipart
Last active April 11, 2019 04:58
User data to update a Route53 subdomain with the new IP address of an EC2 instance every time it boots. Instance must be assigned role with Route53 permissions.
Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0
--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"
#cloud-config
@cayblood
cayblood / polymer_setup.js
Last active January 17, 2019 13:33
Adding custom elements needs to wait until after polymer-ready
// 1. Load Polymer before any code that touches the DOM.
var script = document.createElement("script");
script.src = "/base/bower_components/webcomponentsjs/webcomponents.js";
document.getElementsByTagName("head")[0].appendChild(script);
// Delay Jasmine specs until WebComponentsReady
var POLYMER_READY = false;
beforeEach(function(done) {
window.addEventListener('polymer-ready', function () {