Skip to content

Instantly share code, notes, and snippets.

View punitganshani's full-sized avatar

Puneet Ghanshani punitganshani

View GitHub Profile
@punitganshani
punitganshani / Permissions.md
Last active February 26, 2024 16:53
Create AAD App and ClientID/Secrets Programmatically

Create Registration App

Scope

Scope Type Description Admin Consent
Application.Read.All Application Read all applications Yes
Application.ReadWrite.All Application Read and write all applications Yes
Application.ReadWrite.OwnedBy Application Manage apps that this app creates or owns Yes
offline_access Delegated Maintain access to data you have given it access to No
@punitganshani
punitganshani / get-products-from-ado-artifacts.py
Created September 5, 2023 04:27
Azure DevOps Packages List in Python
import os
import requests
import base64
import json
import pandas as pd
# Retrieve variables from system environment variables
organization = os.environ.get("AZURE_DEVOPS_ORG_NAME")
project = os.environ.get("AZURE_DEVOPS_PROJECT_NAME")
feed_id = os.environ.get("AZURE_DEVOPS_FEED_ID")
@punitganshani
punitganshani / RepoLanguagesForAzureDevOps.ps1
Created March 9, 2023 09:17
Get Repository Languages for Azure DevOps
$url = "https://dev.azure.com/{org}/{project}/_apis/projectanalysis/languagemetrics"
$pat = ""
# Create header with PAT
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($pat)"))
$header = @{authorization = "Basic $token"}
$response = Invoke-RestMethod -Uri $url -Headers $header -Method Get -ContentType "application/json"
$array = @()
@punitganshani
punitganshani / pygit-commit-age.py
Created February 23, 2023 05:49
PyGit: Last Commit with Age > 30d
# %%
#!/bin/env python3
import pygit2, os, datetime, json
from pygit2 import GIT_SORT_TOPOLOGICAL, GIT_SORT_REVERSE, Commit
# %%
repo = pygit2.Repository(pygit2.discover_repository(os.getcwd()))
time_now = datetime.datetime.now()
@punitganshani
punitganshani / key-operations.ps1
Created June 22, 2018 02:26
Azure PowerShell
Get-AzureRmProviderOperation | Where Operation -like "*listkey*" | ft Operation, OperationName
Get-AzureRmProviderOperation -OperationSearchString "Microsoft.ServiceBus/*" | Where Operation -like "*listkey*" | ft Operation, OperationName
@punitganshani
punitganshani / MyRuleRocks.json
Last active May 29, 2018 01:09
Roslyn way to generate NRules
{
"RuleName": "MyRuleRocks",
"Product": "general",
"Version": "1.0",
"Description" : "Wonderful rule, that doesnot do wonders",
"Tags": [
"latest"
],
"IsActive": true,
"IfExpression": "() => customer, c => c.IsPreferred",
@punitganshani
punitganshani / 01 Get Docker Image.md
Last active February 20, 2018 05:54
PI Docker Swarm

Installing Docker on Raspberry PI

sudo apt-get upgrade
sudo apt-get update
curl -sSL https://get.docker.com | sh
sudo usermod -aG docker pi
sudo reboot

@punitganshani
punitganshani / xamarinandroidbindings.md
Created May 2, 2017 14:41 — forked from JonDouglas/xamarinandroidbindings.md
Xamarin Android Bindings Troubleshooting

Approaching a Xamarin.Android Bindings Case

1. Investigation

One of the best ways to investigate a problematic Xamarin.Android Binding is to first ensure you have the proper tooling available:

@punitganshani
punitganshani / azure-eventhub-https.js
Created September 26, 2015 05:56
Azure Event Hub HTTPS
console.log('started');
var https = require('https');
var crypto = require('crypto');
var moment = require('moment');
var uuid= require('node-uuid');
var os = require("os");
var deviceName = "galileo"; //os.hostname();
@punitganshani
punitganshani / AsyncContext.cs
Created August 12, 2015 15:18
AsyncContext for Console Applications - Static Main
public class AsyncContext
{
public static void Run(params Func<Task>[] tasks)
{
if (tasks == null)
return;
Task[] asyncTasks = new Task[tasks.Length];
int counter = 0;