Instantly share code, notes, and snippets.



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.


View returning_pointers.go
package main
import (
// Triangle is a struct for modeling triangle shapes
type Triangle struct {
base, height float64
View hash
#! /usr/bin/env python
import argparse
import hashlib
parser = argparse.ArgumentParser(description='Hash DN')
args = parser.parse_args()
hashed = hashlib.sha256(args.dn)

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.

View clouds.yaml
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
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"
#!/usr/bin/env python3
import argparse
parser = argparse.ArgumentParser()
help=('User survey results as a file with each line being a list of '
'responses per user.')
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: