Skip to content

Instantly share code, notes, and snippets.

View cayblood's full-sized avatar

Carl Youngblood cayblood

View GitHub Profile
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 / tezos-baker-setup.sh
Last active December 9, 2020 23:47
How to set up a tezos baker on EC2 ubuntu 18.04
###############################################################
# TEZOS BAKING SETUP
#
# Technical overview: http://tezos.gitlab.io/mainnet/whitedoc/proof_of_stake.html
#
# other tools: https://github.com/bakechain/bakechain
# https://github.com/Cryptonomic/Deployments/wiki/Galleon:-Releases
#
# short link: http://bit.ly/tezos-baker
#
@cayblood
cayblood / tezzigator.sh
Last active May 19, 2018 22:47
Script to automatically execute the steps in Tezzigator baking tutorial https://medium.com/@Tezzigator/permanent-tezos-sandboxing-509368945c4a on Ubuntu 16.04 LTS
#!/bin/bash
git clone -b zeronet https://gitlab.com/tezos/tezos.git
cd tezos
curl https://gist.githubusercontent.com/cayblood/329d24a099555e9a436f55a1cb8eb541/raw/c120c025465edfc8fa6bf4bbdbbef1ac79181da6/dictator-key.patch | patch -p1
sudo add-apt-repository ppa:avsm/ppa
sudo apt-get update
sudo apt-get install ocaml-nox opam
opam init
opam update