Skip to content

Instantly share code, notes, and snippets.

View mjul's full-sized avatar

Martin Jul mjul

View GitHub Profile
@mjul
mjul / AzureStorageCloudBlobLease.cs
Created November 21, 2018 08:23
Azure StorageAccount ClobBlob leases - useful as semaphores for ensuring e.g. only on job is processing a given queue at a time
public class AzureStorageCloudBlobLease
{
private readonly CloudBlob blob;
private string leaseId;
public AzureStorageCloudBlobLease(CloudBlob blob)
{
this.blob = blob ?? throw new ArgumentNullException(nameof(blob));
}
@mjul
mjul / JsonNetSerialization.csproj
Created December 20, 2018 09:07
Using JsonConverter<T> with NewtonSoft Json to serialize a class as an object where the keys and values are defined dynamically in a dictionary member of the class
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
@mjul
mjul / ItemsConverter.cs
Created December 20, 2018 09:56
A custom Newtonsoft JSON JsonConverter for writing a class instance as a dictionary (JSON object)
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace Foobar
{
public class ItemsConverter : JsonConverter
@mjul
mjul / licenses.ps1
Created June 27, 2019 13:44
Get licenses for npm packages in node_modules
write-host "Scanning..."
$packages = Get-ChildItem .\node_modules -Filter 'package.json' -Recurse
write-host ("Found {0} packages." -f $packages.Count)
$licenses = @()
write-host "Reading licenses..."
foreach ($p in $packages) {
$file = $p.FullName
$data = Get-Content -Path $file | ConvertFrom-Json
$license = $data.license
@mjul
mjul / kalender.ipynb
Last active August 28, 2023 03:17
Create secondary x-axis with date and days since start in Matplotlib
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mjul
mjul / GPG-FIX.md
Created November 18, 2022 19:02
gpg: signing failed: Inappropriate ioctl for device

Fixing GPG "Inappropriate ioctl for device" errors

6th November 2016 Linux 24 Comments https://d.sb/B5N 
    Error: gpg: using "D5673F3E" as default secret key for signing 
    Error: gpg: signing failed: Inappropriate ioctl for device 
    Error: gpg: [stdin]: sign+encrypt failed: Inappropriate ioctl for device