This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def remove_github_urls(dict_in): | |
"""Remove URL entries (as returned by GitHub API) from a dictionary. | |
1st parameter = dictionary | |
Returns a copy of the dictionary, but with no entries named *_url or url. | |
""" | |
return {key: dict_in[key] for key in dict_in if \ | |
not key.endswith('_url') and not key == 'url'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you're scanning the file system in Python, you will eventually come across filenames | |
# that can't be displayed in the VS Code console because they contain characters that | |
# will raise a UnicodeDecode Error. Opening sys.stdout as shown below fixes this problem. | |
# this ensures the console will handle Unicode characters | |
import sys | |
sys.stdout = open(sys.stdout.fileno(), mode='w', encoding='utf8', buffering=1) | |
# the following print() statement crashes in the VS Code console window with a | |
# UnicodeDecodeError if you DON'T set sys.stdout as shown above |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Functions for manipulating Norwescon attendance data. | |
Query functions: | |
attended_all() ---------> Get attendees of a specified list of conventions. | |
attended_one() ---------> Get attendees of a specified convention. | |
Data-scrubbing functions: | |
download_data() --------> Download data file and save a local copy. | |
fixups() ---------------> Apply various fixups to the live data file. | |
progressbar() ----------> Display progress bar showing completion status. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Comparison of fetching web pages sequentially vs. asynchronously | |
Requirements: Python 3.5+, Requests, aiohttp, cchardet | |
For a walkthrough see this blog post: | |
http://mahugh.com/2017/05/23/http-requests-asyncio-aiohttp-vs-requests/ | |
""" | |
import asyncio | |
from timeit import default_timer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Copyright (c) Microsoft Corporation. All rights reserved. | |
Licensed under the MIT License. | |
""" | |
import base64 | |
import json | |
import os | |
import time | |
import urllib.parse | |
import uuid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Requires pypiwin32 - see installation instructions at https://github.com/mhammond/pywin32 | |
""" | |
import random | |
import win32com.client | |
# for other shape types, see MsoAutoShapeTypeEnumeration: | |
# https://msdn.microsoft.com/en-us/vba/office-shared-vba/articles/msoautoshapetype-enumeration-office | |
SHAPE_OVAL = 9 | |
# for other layout options, see PpSlideLayout Enumeration: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Convert code snippets for use in auto-generated docs. | |
""" | |
import glob | |
REPO_FOLDER = 'C:/temp/office-js-docs' # local cloned copy of repo | |
def main(): | |
"""Extract snippets for each platform/folder.""" | |
# note we're not doing Shared for now | |
for platform in ['Excel', 'OneNote', 'Outlook', 'Visio', 'Word']: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Blank snippet | |
description: '' | |
author: dmahugh | |
host: WORD | |
api_set: {} | |
script: | |
content: | | |
$("#run").click(() => tryCatch(run)); | |
async function run() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Import JSON data | |
description: Imports JSON data into a table. | |
host: EXCEL | |
api_set: {} | |
script: | |
content: | | |
$("#import-json-data").click(() => tryCatch(importJsonData)); | |
async function importJsonData() { | |
await Excel.run(async (context) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Azure Devops REST API example: list the projects in an instance | |
To run this example, create an ..\_private folder with an azuredevops.json file | |
in it that contains a PAT: | |
{ | |
"bugs-read-only": "YOUR-PERSONAL-ACCESS-TOKEN-HERE" | |
} | |
""" | |
import json |
OlderNewer