Skip to content

Instantly share code, notes, and snippets.

View ankona's full-sized avatar
🏠
Working from home

Chris McBride ankona

🏠
Working from home
View GitHub Profile
@ankona
ankona / sts-assume-role-powershell.ps1
Created July 11, 2016 14:41
STS Assume Role (PowerShell)
$RoleArn = "%deployer_arn%"
$ExternalId = "%assume_role_external_id%"
$Region = "us-east-1"
$Response = (Use-STSRole -Region $Region -RoleArn $RoleArn -ExternalId $ExternalId -RoleSessionName "deploy-website-s3-bucket").Credentials
$SecretAccessKey = $Response.SecretAccessKey
$SessionToken = $Response.SessionToken
@ankona
ankona / get_orgunits_properties.py
Created July 27, 2016 21:18
get_orgunits_properties from bspace valence API
def get_orgunits_properties(uc,org_unit_type_id=None,org_unit_code=None,org_unit_name=None,bookmark=None,ver='1.3',**kwargs):
"""
Custom method hitting Brightspace Valence API. Request to add to service.py in d2lvalence_util submitted; consider removal.
"""
route = '/d2l/api/lp/{0}/orgstructure/'.format(ver)
kwargs.setdefault('params', {})
if org_unit_type_id:
kwargs['params'].update({'orgUnitType': org_unit_type_id})
if org_unit_code:
kwargs['params'].update({'orgUnitCode': org_unit_code})
@ankona
ankona / gen_pf_oauth_token.py
Created August 1, 2016 17:47
Get a Ping Federate auth token from the PF server
def _make_pf_request(environment, client_id, client_secret, grant_type, service_endpoint, post_data):
logger.debug("client_id: {0}".format(client_id))
logger.debug("client_secret: {0}".format(client_secret))
logger.debug("grant_type: {0}".format(grant_type))
logger.debug("service_endpoint: {0}".format(service_endpoint))
logger.debug("post_data: {0}".format(post_data))
auth_info = "{0}:{1}".format(client_id, client_secret)
logger.debug("auth_info: {0}".format(auth_info))
@ankona
ankona / palindrome_test.py
Last active September 28, 2016 15:33
Recursive palindrome test
def is_palindrome(w):
word_length = len(w)
if word_length == 1:
return True
elif word_length == 2:
return w[0] == w[1]
else:
return w[0] == w[word_length-1] and is_palindrome(w[1:word_length-1])
@ankona
ankona / bspace.py
Created October 31, 2016 18:49
sample bspace consumption
import logging
import requests
import EnvironmentSetting
from khelib import AppSettings
import d2lvalence.auth as d2lauth
import d2lvalence_util.service as d2lservice
import d2lvalence_util.data as d2ldata
@ankona
ankona / cms-admin.txt
Last active March 16, 2017 20:49
cms-admin notes
NOTE: if the content all have the same id (e.g. if they actually are underlying in the same data table)
- applying filters, schedules, etc. is much easier.
Features:
1. Application (Client - choose a noun):
GET /client(?name=xxx) - retrieve a list of clients
- GET /client/{client-id} - retrieve specific client (vs QS version... )
POST /client - create a new client application
PUT /client/{client-id}
@ankona
ankona / cms-admin.yaml
Last active March 28, 2017 20:14
cms-admin swagger
swagger: '2.0'
info:
title: Kaplan CMS Admin API
description: |
This API enables client applications to administer CMS content in a headless manner.
## Features
1. Clients can modify CMS content including: assets, content blocks, pages, and page templates.
@ankona
ankona / ef-core-vs-dapper.ipynb
Last active April 10, 2017 18:38
ef core comparison to dapper
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ankona
ankona / decrypt_setting.py
Created May 18, 2017 18:24
Decrypt Value from DynamoDB with key in AWS KMS
"""
Retrieve & Decrypt settings from DDB.
Sample Usage:
foo=$(python settings.py decrypt <my-app> <my-config-value-name>)
echo $foo
foo=$(python settings.py settings <my-app>)
echo $foo
"""
@ankona
ankona / git-clean.sh
Last active October 6, 2017 20:33
Remove a file from repo history
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch .vscode/launch.json' --prune-empty --tag-name-filter cat -- --all
git update-index --assume-unchanged FILENAME_TO_IGNORE