Skip to content

Instantly share code, notes, and snippets.

Avatar

Adrian Calinescu snobu

View GitHub Profile
@snobu
snobu / temp_control.py
Last active Oct 25, 2021
PySimpleGUI Thermostat example
View temp_control.py
#!/usr/bin/env python3
import PySimpleGUI as sg
def read_temp1():
return 24.0
def read_temp2():
return 21.1
@snobu
snobu / defaultServiceVersion.md
Created Sep 28, 2021
Set Azure Blob Storage default API version (defaultServiceVersion)
View defaultServiceVersion.md
PowerShell> Update-AzStorageBlobServiceProperty -DefaultServiceVersion 2017-07-29 -resourcegroupname bonsai-rg-bonsai-025b200c-f80c-46df-98e5-01e49c78aed6 -StorageAccountName bonsai26 -Debug


HTTP Method:
PUT

Absolute Uri:
https://management.azure.com/subscriptions/SUBSCRIPTION_ID/resourceGroups/bonsai-rg-bonsai-025b200c-f80c-46df-98e5-01e49c78aed6/providers/Microsoft.Storage/storageAccounts/bonsai26/blobServices/default?api-version=2021-04-01
View gist:b04f5ec8c7a34f9443f36db645d69581
https://forms.office.com/formapi/api/forms/v4j5cvGF_ORMS_ID_MUDBWQS4u/responses
@snobu
snobu / nginx-conf-configmap.yaml
Last active Sep 17, 2021
WordPress on AKS with rook-ceph
View nginx-conf-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: nginxconf
data:
nginx.conf: |-
user nginx; # match php-fpm user so we can purge cache from Nginx Helper WP plugin
worker_processes auto;
error_log /var/log/nginx/error.log notice;
@snobu
snobu / servicebus_fw.md
Last active Aug 23, 2021
Add/remove IP addresses from Service Bus firewall (Premium SKU)
View servicebus_fw.md
PUT https://management.azure.com/subscriptions/SUBSCRIPTION_ID/resourcegroups/premiumbus/providers/
Authorization: Bearer eyJ...

{
    "id": "/subscriptions/SUBSCRIPTION_ID/resourcegroups/premiumbus/providers/Microsoft.ServiceBus/
    "properties": {
        "defaultAction": "Deny",
        "ipRules": [
            {"ipMask": "86.125.28.105"},
@snobu
snobu / function.cs
Created Sep 3, 2020
Call remote API from Azure Function with Managed Identity
View function.cs
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Azure.Identity;
@snobu
snobu / app.java
Created Aug 31, 2020
JDBC to Azure Database for MySQL
View app.java
package azuremysqltest;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
public class App {
public static void main(String[] args) {
@snobu
snobu / get_secret.py
Last active Jun 25, 2020
Get secret from Azure Key Vault in Python
View get_secret.py
#!/usr/bin/env python3
# pip install azure-keyvault-secrets azure-identity
from blessings import Terminal
t = Terminal()
import json
from azure.identity import DefaultAzureCredential, InteractiveBrowserCredential
from azure.keyvault.secrets import SecretClient
@snobu
snobu / gist:7dbee9a5fc43c6c664b73409bb2f7f88
Created Feb 28, 2020 — forked from Aninstance/gist:8210e210f3cfab0200450db5a91c5ccc
Javascript (Typescript): Remove empty properties from object
View gist:7dbee9a5fc43c6c664b73409bb2f7f88
deleteEmptyProps(obj: any): any {
// modifies passed obj in place, removing empty properties (inc. empty arrays)
return Object.keys(obj).forEach(k => {
if (!obj[k] || obj[k] === undefined ||
Array.isArray(obj[k]) && obj[k].length === 0) {
delete obj[k];
}
});
}
@snobu
snobu / gist:169a5ad1e1ae07e0261f61438e86dca3
Created Jan 20, 2020
keyvalult base64 encoded json as secret
View gist:169a5ad1e1ae07e0261f61438e86dca3
$ cat secret.json | base64 > secret.json.base64
$ az keyvault secret set --vault-name alice --name secret-from-cli -f secret.json.base64
{
...
"tags": {
"file-encoding": "utf-8"
},
"value": "ewogICAgInRoaXMiOiAiaXMiLAogICAgInNvbWUiOiAianNvbiwKICAgICJtYXliZSI6IHsKICAgICAgICAieWVhaCI6IDEKICAgIH0KfQo=\n"
}