Skip to content

Instantly share code, notes, and snippets.

View malteb247's full-sized avatar
🥦

Malte malteb247

🥦
View GitHub Profile
@malteb247
malteb247 / M4L73.xml
Created March 15, 2014 12:42
My IntelliJ Colors, based on "Son Of Obsidian"
<?xml version="1.0" encoding="UTF-8"?>
<scheme name="M4L73" version="124" parent_scheme="Default">
<option name="LINE_SPACING" value="1.2" />
<option name="EDITOR_FONT_SIZE" value="14" />
<option name="CONSOLE_FONT_NAME" value="DejaVu Sans Mono" />
<option name="CONSOLE_FONT_SIZE" value="12" />
<option name="CONSOLE_LINE_SPACING" value="1.0" />
<option name="EDITOR_FONT_NAME" value="DejaVu Sans Mono" />
<colors>
<option name="CARET_COLOR" value="ffffff" />
using System;
namespace ExpressionTest
{
public class ExternalPerson
{
public int Id { get; set; }
public string FirstName {
get;
@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);
@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 / 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 / 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 / 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 / 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 / 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
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.";