Skip to content

Instantly share code, notes, and snippets.

View mjul's full-sized avatar

Martin Jul mjul

View GitHub Profile
@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
@mjul
mjul / kalender.ipynb
Last active August 28, 2023 03:17
Create secondary x-axis with date and days since start in Matplotlib
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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 / 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 / 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 / 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 / azure-devops-vsts-get-defaulthostname.ps1
Created October 22, 2018 12:41
Azure DevOps (VSTS) Get Azure WebApp DefaultHostName workaround
# Get-AzureRmWebApp does not work correctly when running under the Azure DevOps build server (October 2018).
# Here is a workaround to get the DefaultHostName
# Place your own name here:
$appName = "myspecialappname-dev"
$webApp = Get-AzureRmWebApp -ResourceGroupName $ResourceGroupName -Name $appName -ErrorAction Stop
if (!$webApp) { Write-Error ("WebApp not found: {0} (Resource Group: {1})" -f $appName,$ResourceGroupName) }
# DefaultHostName property does not work in the Azure DevOps (VSTS) build server, see: https://github.com/Azure/azure-powershell/issues/5760
# The HostNames property works, so pick one of the hostnames instead of DefaultHostName:
@mjul
mjul / git-status-colours.ps1
Created October 1, 2018 07:23
Git status colour config for PowerShell readability
# `git status` in PowerShell shows untracked files is a dark red that is hard to read on the blue background.
# Change it to high-contrast red:
git config --global color.status.untracked "bold red"
@mjul
mjul / build.fsx
Created September 27, 2018 07:54
Fake (V5) build with xUnit 2 and inline Paket
#r "paket:
nuget Fake.DotNet.Cli
nuget Fake.IO.FileSystem
nuget Fake.Core.Target
nuget Fake.DotNet.MSBuild
nuget Fake.DotNet.NuGet
nuget Fake.DotNet.Testing.XUnit2 //"
#load ".fake/build.fsx/intellisense.fsx"
open System.IO
@mjul
mjul / install-azure-functions-templates.ps1
Created August 14, 2018 14:21
Install the latest release of the Azure Functions item and project templates for dotnet new
# Install the latest release of the Azure item and project templates:
#
# See [Azure Functions Templates wiki](https://github.com/Azure/azure-functions-templates/wiki/Using-the-templates-directly-via-dotnet-new)
# See [Issue 721](https://github.com/Azure/azure-functions-templates/issues/721)
$feed = Invoke-WebRequest https://functionscdn.azureedge.net/public/cli-feed-v3.json | ConvertFrom-Json
$release = $feed.tags.v2.release
foreach ($t in "itemTemplates", "projectTemplates") {
$uri = $feed.releases."$release"."$t"