Skip to content

Instantly share code, notes, and snippets.

View malteb247's full-sized avatar
🥦

Malte malteb247

🥦
View GitHub Profile
@malteb247
malteb247 / Get-UserNameList.ps1
Last active November 28, 2023 20:59
MS teams attendee log to jira user name list
[CmdletBinding()]
param (
[Parameter()]
[string]
$InputFile
)
function Get-Participants ($file) {
$allLines = Get-Content -Path $InputFile
@malteb247
malteb247 / Set-PointerSize.ps1
Last active October 4, 2023 12:25
Windows: Set cursor size via script.
<#
.SYNOPSIS
Sets pointer size
.DESCRIPTION
Can be used with e.g. desktop shortcuts to have a one-click solution
powershell.exe -NoLogo -ExecutionPolicy Bypass -Command ".\Set-PointerSize.ps1 -Size 5"
.EXAMPLE
./Set-PointerSize.ps1 -Size 3
Sets the cursor size to 3
.EXAMPLE
sub openurl {
my $url = shift;
my $platform = $^O;
my $cmd;
if ($platform eq 'darwin') { $cmd = "open \"$url\""; } # OS X
elsif ($platform eq 'MSWin32' or $platform eq 'msys') { $cmd = "start \"\" \"$url\""; } # Windows native or MSYS / Git Bash
elsif ($platform eq 'cygwin') { $cmd = "cmd.exe /c start \"\" \"$url \""; } # Cygwin; !! Note the required trailing space.
else { $cmd = "xdg-open \"$url\""; } # assume a Freedesktop-compliant OS, which includes many Linux distros, PC-BSD, OpenSolaris, ...
if (system($cmd) != 0) {
die "Cannot locate or failed to open default browser; please open '$url' manually.";
@malteb247
malteb247 / TestUtilities.cs
Last active September 23, 2019 07:42
An example of how to use appsettings in NUnit
using NUnit.Framework;
namespace Jaber.Tests
{
using Microsoft.Extensions.Configuration;
/// <summary>
/// Just an example class that contains my special configuration
/// </summary>
public class MySpecialConfig
@malteb247
malteb247 / SaveTaskOutput.cs
Created June 8, 2017 12:45
Save a file from azure batch task into linked blob storage
private static Main()
{
var outputFile = $"results_{taskId}.txt";
using (var output = File.CreateText(WorkingDir(outputFile)))
{
output.WriteLine("This is the results file");
}
// Persist the task output to Azure Storage
Task.WaitAll(
taskStorage.SaveAsync(TaskOutputKind.TaskOutput, outputFile)
@malteb247
malteb247 / Retry.cs
Last active February 2, 2017 12:17
Simple helper to implement retry logic
using System;
using System.Collections.Generic;
using System.Threading;
/// <summary>
/// Simple helper to implement retry logic
/// </summary>
/// <example>
/// // Retry 5 times with a break of 30 seconds.
/// Retry.Do(() => MyMethod(), TimeSpan.FromSeconds(30), 5)
@malteb247
malteb247 / RenameBranchLocalAndRemote.sh
Created December 11, 2016 08:00
Rename a gt branch local and remote
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch and set local branch to track the new remote
@malteb247
malteb247 / XmlExtensions.cs
Last active February 8, 2016 15:01
XmlExtensions.cs
public static class XmlExtensions
{
/// <summary>
/// Cache serialization assemblies
/// </summary>
private static readonly Dictionary<RuntimeTypeHandle, XmlSerializer> serializer_cache = new Dictionary<RuntimeTypeHandle, XmlSerializer>();
/// <summary>
/// used to remove obsolete xsd: and xsi: namespaces.
/// </summary>
@malteb247
malteb247 / crypt_unlock.sh
Last active April 22, 2022 21:05
remote unlocking LUKS encrypted LVM using Dropbear SSH (inspired by https://stinkyparkia.wordpress.com/2014/10/14/remote-unlocking-luks-encrypted-lvm-using-dropbear-ssh-in-ubuntu-server-14-04-1-with-static-ipst/) with respect to pointopoint interfaces setup.
#!/bin/sh
# location: /etc/initramfs-tools/hooks/crypt_unlock.sh
PREREQ="dropbear"
prereqs() {
echo "$PREREQ"
}
@malteb247
malteb247 / IsolatedAppDomain.cs
Created November 3, 2015 13:41
Execute in seperate app domain
public sealed class Isolated<T> : IDisposable where T : MarshalByRefObject
{
private AppDomain _domain;
private T _value;
public Isolated()
{
_domain = AppDomain.CreateDomain("Isolated:" + Guid.NewGuid(),
null, AppDomain.CurrentDomain.SetupInformation);