Skip to content

Instantly share code, notes, and snippets.

View jongio's full-sized avatar

Jon Gallant jongio

View GitHub Profile
{
"visual": {
"name": "liquidFillGauge",
"displayName": "liquidFillGauge",
"guid": "liquidFillGaugeCA6D0134FC6446EF90CC6934C9812269",
"visualClassName": "Visual",
"version": "1.0.0",
"description": "",
"supportUrl": "",
"gitHubUrl": ""
var iotHubName = pm.environment.get("iotHubName");
var iotHubKey = pm.environment.get("iotHubKey");
var iotHubTokenExpiration = pm.environment.get("iotHubTokenExpiration");
var iotHubPolicyName = pm.environment.get("iotHubPolicyName");
pm.globals.clear("iotHubSasToken"); // clear out token on first run.
// See this doc for details: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-security
var resourceUri = encodeURIComponent(iotHubName + '.azure-devices.net'); // The resource uri
var expiry = Math.ceil((Date.now() / 1000) + iotHubTokenExpiration * 60); // Expire the token 60 minutes from now
pm.sendRequest({
url: 'https://login.microsoftonline.com/' + pm.environment.get("tenantId") + '/oauth2/token',
method: 'POST',
header: 'Content-Type: application/x-www-form-urlencoded',
body: {
mode: 'urlencoded',
urlencoded: [
{key: "grant_type", value: "client_credentials", disabled: false},
{key: "client_id", value: pm.environment.get("clientId"), disabled: false},
{key: "client_secret", value: pm.environment.get("clientSecret"), disabled: false},
@jongio
jongio / ssh-info-docker-vm-windows.sh
Last active November 3, 2021 07:36
It's not technically SSH, but here's how you can get root access to the VM that runs Docker on your Windows host.
docker run --privileged -it -v /var/run/docker.sock:/var/run/docker.sock jongallant/ubuntu-docker-client
docker run --net=host --ipc=host --uts=host --pid=host -it --security-opt=seccomp=unconfined --privileged --rm -v /:/host alpine /bin/sh
chroot /host
subscriptionId:
clientId:
clientSecret:
tenantId:
deviceStorageAccountName:
deviceStorageAccountKey:
resourceGroupName:
resourceName:
resourceKey:
iotHubCreateDeleteName:
@jongio
jongio / visual.ts
Created March 7, 2017 17:54
radio slicer gists visual.ts
module powerbi.extensibility.visual {
export class Visual implements IVisual {
private target: HTMLElement;
private selectionManager: ISelectionManager;
private selectionIds: any = {};
private host: IVisualHost;
private isEventUpdate: boolean = false;
constructor(options: VisualConstructorOptions) {
this.target = options.element;
@jongio
jongio / capabilities.json
Last active March 7, 2017 17:54
radio slicer gists
{
"dataRoles": [
{
"displayName": "Values",
"name": "values",
"kind": "Grouping"
}
],
"dataViewMappings": [
{
@jongio
jongio / pbiviz.json
Last active May 10, 2017 16:23
pbiviz.json
{
"visual": {
"name": "liquidFillGauge",
"displayName": "liquidFillGauge",
"guid": "liquidFillGauge93CE6A47554D42C181409FA800464B76",
"visualClassName": "Visual",
"version": "1.0.0",
"description": "",
"supportUrl": "",
"gitHubUrl": ""
@jongio
jongio / azure-iot-hub-device-twin-rest-apis-postman-newman.json
Created February 9, 2017 06:04
Azure IoT Hub Device Twin Properties JSON
{
"deviceId": "{{deviceId}}",
"properties": {
"desired": {
"deviceName": "{{deviceName}}"
}
}
}
@jongio
jongio / azure-iot-hub-device-twin-rest-apis-postman-newman.js
Last active November 5, 2021 08:50
Azure IoT Hub SAS Token JavaScript CryptoJS
// See this doc for details: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-security
var resourceUri = encodeURIComponent(postman.getGlobalVariable("hubName") + '.azure-devices.net'); // The resource uri
var expiry = Math.ceil((Date.now() / 1000) + postman.getGlobalVariable("expiresInMins") * 60); // Expire the token 60 minutes from now
var uriExpiry = resourceUri + '\n' + expiry; // this is the string format to gen signature from
var decodedKey = CryptoJS.enc.Base64.parse(postman.getGlobalVariable("signingKey")); // The SHA256 key is the Base64 decoded version of the IoT Hub key
var signature = CryptoJS.HmacSHA256(uriExpiry, decodedKey); // The signature generated from the decodedKey
var encodedUri = encodeURIComponent(CryptoJS.enc.Base64.stringify(signature)); // The url encoded version of the Base64 signature
// Construct authorization string (shared access signature)
var token = "SharedAccessSignature sr=" + resourceUri + "&sig=" + encodedUri + "&se=" + expiry;