Skip to content

Instantly share code, notes, and snippets.

Lance Bragstad lbragstad

Block or report user

Report or block lbragstad

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lbragstad
lbragstad / README.md
Last active Feb 6, 2019
A simple exercise in go
View README.md

Shapes

You need to use structs to model triangles and squares. Your module should have a printArea() that takes a shape as a receiver. The printArea() function should call an interface (e.g., getArea) that is implemented by your shapes and contains the implementation for calculating the area for those shapes. Shapes cannot have negative values.

Tests

@lbragstad
lbragstad / returning_pointers.go
Last active Feb 6, 2019
The difference in returning values and errors from methods in golang
View returning_pointers.go
package main
import (
"errors"
"fmt"
)
// Triangle is a struct for modeling triangle shapes
type Triangle struct {
base, height float64
@lbragstad
lbragstad / hash
Last active Jan 23, 2019
Hash a DN
View hash
#! /usr/bin/env python
import argparse
import hashlib
parser = argparse.ArgumentParser(description='Hash DN')
parser.add_argument('dn')
args = parser.parse_args()
hashed = hashlib.sha256(args.dn)
@lbragstad
lbragstad / README.md
Last active Jan 17, 2019
Simple Public Key Cryptography Examples
View README.md

Simple Public Key Cryptography Examples

I was following the examples in a post but rewrote the mathematical terminology so that it read a little bit easier.

RSA Example

A simple RSA example showing how to generate a public and private key pair for asymmetric encryption.

@lbragstad
lbragstad / clouds.yaml
Created Jan 8, 2019
System scope clouds.yaml
View clouds.yaml
clouds:
system-admin:
auth:
auth_url: http://localhost/identity
password: password
user_domain_id: default
username: admin
system_scope: all
identity_api_version: '3'
region_name: 'RegionOne'
View ftplugin-python.vim
" Set tabs to 4 spaces
set tabstop=4
" Use 4 spaces for auto indentation
set shiftwidth=4
" Use 4 spaces for tabs when editing
set softtabstop=4
" Number of space to use when replacing tabs
View x1c pub key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCozwlzKqO1DB8Kjk0UwFutImiP0F2Jp082vd9UECRBEpGDk/egH25NhwdMBqEnG+VHmiB3KkR174oyomW2qcMxE45gx0nDfsaxuA0uT+s2YlvHAP09HRmHjlzEmtTtsUnAxmYkPZnzo74jcJE6fdszXOfOm+YvXfHdEU3JXS7U6C7giBZ1ThFExwRtlAYm9QZa3Uqe/xSl0p3T/BvvD3KimZlCI0iDHIHwSbm04KHjHrVnoG3jWMRZFHylnHzFbSihHIAK5xRhMw84+AicSf9h5mVNZGokby88qI6HDKJBqz4EK+PPnOMEGZw24vigtPucKju4znD2H7txwvZBosZb lance@x1c
@lbragstad
lbragstad / policies.yaml
Last active Sep 19, 2018
Inconsistent Policies
View policies.yaml
# cinder
"volume:create_volume_metadata": "rule:admin_or_owner"
"volume:delete_snapshot_metadata": "rule:admin_or_owner"
"backup:export-import": "rule:admin_api"
"volume:failover_host": "rule:admin_api"
"volume_extension:capabilities": "rule:admin_api"
"context_is_admin": "role:admin"
"volume_extension:volume_admin_actions:force_detach": "rule:admin_api"
"volume_extension:types_extra_specs:delete": "rule:admin_api"
"backup:delete": "rule:admin_or_owner"
@lbragstad
lbragstad / parse.py
Last active Sep 7, 2018
User Survey Parser
View parse.py
#!/usr/bin/env python3
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
'filename',
help=('User survey results as a file with each line being a list of '
'responses per user.')
)
@lbragstad
lbragstad / cleanup-in-library.py
Last active Sep 5, 2018
Limit enforcement of subclassed resources
View cleanup-in-library.py
from oslo_limit import limit
def create_server(self, context, server):
claim_quantity = server.get('cores')
claim = limit.ProjectClaim('cores', context.project_id, quantity=claim_quantity)
# Verification after executing the claim is the default behavior, but calling it out
# explicitly here for the sake of the example.
with limit.Enforcer(claim, callback=self.calculate_cores_for_project, verify=True) as enforcer:
You can’t perform that action at this time.