Skip to content

Instantly share code, notes, and snippets.

View punitganshani's full-sized avatar

Puneet Ghanshani punitganshani

View GitHub Profile
@punitganshani
punitganshani / WebBackgroundTasks.cs
Created July 18, 2015 14:47
Scheduling Background Tasks in ASP.NET using Quartz
using Quartz;
using Quartz.Impl;
namespace Tasks
{
public class MaintenanceJob : IJob
{
public void Execute(IJobExecutionContext context)
{
var ftpLocation = context.JobDetail.JobDataMap.Get("ftp.location");
@punitganshani
punitganshani / Get-FileEncodingOfFilesInFolder.ps1
Last active August 29, 2015 14:25
Get Encoding of Files [PowerShell]
function Get-FileEncodingOfFilesInFolder
{
[CmdletBinding()] Param (
[Parameter(Mandatory = $True, ValueFromPipelineByPropertyName = $True)] [string]$Path, [string]$pattern
)
$files = Get-ChildItem -path $Path $pattern -Recurse | Select-Object FullName
$encodings = @{}
@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;
@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 / 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 / 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 / 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 / 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 / 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 / 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 = @()