Skip to content

Instantly share code, notes, and snippets.

@lenidh
lenidh / MillerRabin.java
Created December 5, 2013 20:09
Java implementation of the Miller-Rabin primality test.
package de.lenidh.misc;
/**
* Implementation of the Miller-Rabin primality test.
*/
public final class MillerRabin {
private MillerRabin() {
}
@lenidh
lenidh / RequiredIfAttribute.cs
Created December 20, 2013 23:48
Conditional data annotation.
namespace De.Lenidh.Misc
{
using System;
using System.ComponentModel.DataAnnotations;
/// <summary>
/// Specifies that a data field value is conditional required.
/// </summary>
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true, Inherited = false)]
public class RequiredIfAttribute : RequiredAttribute
@lenidh
lenidh / apt
Created April 24, 2014 13:05
bash completion for apt command
# Debian apt(8) completion -*- shell-script -*-
_apt()
{
local cur prev words cword
_init_completion || return
local dashoptions='-h --help -v --version -c --config-file -o --option -t -a'
local special i
@lenidh
lenidh / de-linux.klc
Created June 13, 2014 22:14
A windows clone of the german linux keyboard layout.
KBD de-linux "Deutsch (Linux)"
COPYRIGHT "(c) 2014 lenidh"
COMPANY "lenidh"
LOCALENAME "de-DE"
LOCALEID "00000407"
@lenidh
lenidh / dftmgen.c
Last active September 1, 2015 21:30
DFT matrix generator (gcc -std=c11 -lm dftmgen.c)
#include <complex.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define M_PI 3.1415926535897932384626433832795L
int main(int argc, char** argv) {
int n = 0;
if(argc > 1) n = atoi(argv[1]);
@lenidh
lenidh / FilePathObserver.java
Created August 22, 2016 17:40
Monitor file and directory pathnames to fire an event after the referenced file or directory was changed.
/* Copyright (c) 2016 Moritz J. Heindl
*
* 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:
*
* The above copyright notice and this permission notice shall be included in
### Keybase proof
I hereby claim:
* I am lenidh on github.
* I am lenidh (https://keybase.io/lenidh) on keybase.
* I have a public key ASDFfuUW5TkiaTQkwqDWLG3Uh0Z_SfK1zAYOcGCSgB37WAo
To claim this, I am signing this object: