Skip to content

Instantly share code, notes, and snippets.

View cimnine's full-sized avatar

Christian Mäder cimnine

View GitHub Profile
@cimnine
cimnine / Numeric.cs
Created June 25, 2012 16:35
A way to check if a type is numeric in C#
using System;
namespace ch.cimnine.Util
{
public sealed class Numeric
{
/// <summary>
/// Determines if a type is numeric. Nullable numeric types are considered numeric.
/// </summary>
/// <remarks>
@cimnine
cimnine / COPYING
Created September 17, 2012 12:09
Sync script for hsr.ch
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@cimnine
cimnine / yack.js
Created December 4, 2012 08:14
Little lib to access the HSR IntTe'12 "Testat2" chat server
(function(window) {
"use strict";
var Yack = function(playerToken) {
if(playerToken) {
this.playerToken = playerToken;
} else {
var o = this;
callSrv('Connect', {}, function(res) {

Adding a Certificate to a Key Store

// This method adds a certificate with the specified alias to the specified keystore file.
public static void addToKeyStore(File keystoreFile, char[] keystorePassword,
  String alias, java.security.cert.Certificate cert) {
    try {
        // Create an empty keystore object
        KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());

// Load the keystore contents

@cimnine
cimnine / gist:7913819
Last active July 29, 2021 22:01
Luhn Algorithm in VBA (for example for use in Excel)
' Version 1.0.0
' You may use these functions directly in Excel: "=luhnCheck(A55)"
' probably only needed internally
Function luhnSum(InVal As String) As Integer
Dim evenSum As Integer
Dim oddSum As Integer
evenSum = 0
@cimnine
cimnine / forever.sh
Last active November 19, 2015 12:32
#!/bin/bash
#
# (c) Netcetera AG
date="19.11.2015"
version="1.2"
#
help() {
script=$(basename "$1")
firewall {
ipv6-name dmz-lan-6 {
default-action drop
enable-default-log
rule 100 {
action accept
log enable
protocol ipv6-icmp
}
rule 1 {

Keybase proof

I hereby claim:

  • I am cimnine on github.
  • I am cma (https://keybase.io/cma) on keybase.
  • I have a public key whose fingerprint is 15ED 97B3 AFFC 073C BDD9 68C2 5A51 249E FCF5 C5F1

To claim this, I am signing this object:

@cimnine
cimnine / 0_README.md
Last active June 20, 2024 03:37
A script to import custom fields from a YAML into Netbox

custom field import script

Usage:

./manage.py shell --plain < import_custom_fields.py

A Note On Boolean Custom Fields

import itertools
from ruamel.yaml import YAML
from pathlib import Path
def load_yaml(yaml_base_path: str):
yaml_path = Path(yaml_base_path)
content_list = []
content_list.append(load_file(yaml_path.with_suffix('.yml')))
load_dir(content_list, yaml_path.with_suffix('.d'))
return flatten(content_list)