Skip to content

Instantly share code, notes, and snippets.

@hanswolff
hanswolff / Dockerfile
Created November 9, 2023 12:48
pytorch3d GPU Dockerfile for CUDA 11.7
FROM nvidia/cuda:11.7.1-cudnn8-devel-ubuntu22.04
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Berlin
RUN apt-get update \
&& apt-get install -y software-properties-common \
&& add-apt-repository -y ppa:deadsnakes/ppa \
&& apt-get update \
&& apt-get install -y python3.9 python3.9-distutils python3.9-dev python3.9-venv \
@hanswolff
hanswolff / CustomizableXmlWriter.cs
Created January 14, 2015 12:09
Wrapped XmlWriter that can remove blank attributes
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
/// <summary>
/// Wrapped XmlWriter that can remove blank attributes
/// </summary>
public class CustomizableXmlWriter : XmlWriter
{
@hanswolff
hanswolff / MiniInjectionFramework.cs
Last active August 29, 2015 14:10
Very simple dependency injection framework (licensed under MIT license or do what you like with it)
//// Example:
//
// using (var context = new MiniInjectionContext())
// {
// context.Register<IMyInterfaceType>(c => new MyClassImplementingInterface());
//
// var instance = context.Get<IMyInterfaceType>();
// }
//}
@hanswolff
hanswolff / BreakInternedStringRepresentation.cs
Last active August 29, 2015 14:07
Break interned string representation
using System;
using System.Runtime.InteropServices;
class Program
{
[StructLayout(LayoutKind.Explicit)]
struct Union
{
[FieldOffset(0)]
public string A;
@hanswolff
hanswolff / GHash128.cs
Last active August 29, 2015 13:56
GHash method for Galois/Counter Mode used in AES GCM
// The MIT License (MIT)
// Copyright (c) 2014 Hans Wolff
// Source: https://gist.github.com/hanswolff/9089707
// Contains translated parts made by Juho Vähä-Herttua
// Source: https://github.com/bitwiseshiftleft/sjcl/blob/master/core/gcm.js
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@hanswolff
hanswolff / CounterSignal.cs
Created February 6, 2014 12:48
Counter that can be waited on for reaching a certain value
//
// Copyright 2013-2014 Hans Wolff
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
@hanswolff
hanswolff / CounterModeCryptoTransform.cs
Last active December 2, 2015 21:35
Counter Mode for any symmentric block cipher in C#
// The MIT License (MIT)
// Copyright (c) 2014 Hans Wolff
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@hanswolff
hanswolff / AesCounterMode.cs
Last active December 29, 2023 23:34
AES Counter Mode implementation in C# (should work for AES 128, 192, 256 -> just initialize with proper key length)
// The MIT License (MIT)
// Copyright (c) 2020 Hans Wolff
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@hanswolff
hanswolff / InterlockedBoolean.cs
Last active December 31, 2015 03:19
Interlocked for boolean type
//
// Copyright 2013 Hans Wolff
//
// Source: https://gist.github.com/hanswolff/7926751
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
@hanswolff
hanswolff / Curve25519.cs
Last active August 16, 2018 19:45
C# implementation of Curve25519
/* Ported parts from Java to C# and refactored by Hans Wolff, 17/09/2013
Original: https://github.com/hanswolff/curve25519
*/
/* Ported from C to Java by Dmitry Skiba [sahn0], 23/02/08.
* Original: http://code.google.com/p/curve25519-java/
*/
/* Generic 64-bit integer implementation of Curve25519 ECDH
* Written by Matthijs van Duin, 200608242056