Skip to content

Instantly share code, notes, and snippets.

View bjornbouetsmith's full-sized avatar

Bjørn Smith bjornbouetsmith

View GitHub Profile
// Based on https://gist.github.com/halmartin/28e013a9034be04777073bccc918cb95 (python)
// And uses Crc32 and Base32 from other github code
// Code should run on .NET Framework 4.7+
using System.Security.Cryptography;
// The 3 constants is byte definitions inside the library mentioned in the original code
// These should be HEX encoded to strings without leading 0x, i.e. "0d0a" etc.
const string AES_IV = "";// This is one of the values you need to dig out of the library;
const string HMAC_KEY = "";// This is one of the values you need to dig out of the library
const string HMAC_MSG_RAW = "";// This is one of the values you need to dig out of the library
@bjornbouetsmith
bjornbouetsmith / sx6012_fans.txt
Created January 11, 2023 14:16
Mellanox SX6012 Fan control
Connect to console on switch via console cable
Log in with admin/admin unless you changed the default username/password
Type 'enable' hit <enter>
Type 'conf t' hit <enter>
Type 'fae mlxi2c set_fan /MGMT/FAN1 1 25' hit <enter>
This will set fan speed to 25% and not make such noise
@bjornbouetsmith
bjornbouetsmith / autostart.sh
Last active October 12, 2020 10:58
ESXi script to auto start virtual machine that exports NFS shares to ESXi, i.e. FreeNAS/TrueNAS/whatever
#!/bin/sh
# ESXi script to auto start virtual machine that exports NFS shares to ESXi, i.e. FreeNAS/TrueNAS/whatever
VMNAME=TrueNAS
SHARE=TrueNAS
MAXLOOPSVM=10
MAXLOOPSSHARE=10
@bjornbouetsmith
bjornbouetsmith / gist:e361c965fb8e64de6fb90bd149ebf171
Created July 5, 2019 18:21
freenas no buffer space available problem and solution
Installed a new FreeNAS and I wanted to apply my usual 10Gbit network tunables.
It turns out it matters a lot in which order you apply them - if you apply them in the wrong order your
system stops responding and loses network capabilities.
I added net.inet.tcp.sendspace with a value of 4194304 and seconds after my system stopped responding and when logging onto the console
- I got messages from all network usage no buffer space available
So I looked at the tunables I added with sysctl -a
@bjornbouetsmith
bjornbouetsmith / gist:5b258ad1870daa8af60fd5d26ab2f909
Created June 30, 2019 14:17
Fix nuget restore failing in Azure DevOps 2019
You can end up in a situation where Azure DevOps for one pipeline refuses to restore packages
and for another that references same packages it just works.
I am guessing there is a bug in Microsofts code somewhere.
This can me remedied by adding a default nuget.config to the roaming app data directory for the user that is running the build agents.
i.e. I have an agent running with the username tfsbuildagent
I have created a nuget.config in
@bjornbouetsmith
bjornbouetsmith / etc-sysctl.conf
Last active April 7, 2023 14:36
FreeNAS 10GBe tuning
Add these lines to the file /etc/sysctl.conf
#10GBE tuning
kern.ipc.soacceptqueue=2048
kern.ipc.somaxconn=2048
kern.ipc.maxsockbuf=33554432
net.inet.tcp.recvbuf_inc=2097152 # (default 16384)
net.inet.tcp.recvbuf_max=16777216 # (default 2097152)
net.inet.tcp.recvspace=4194304 # (default 65536)
When creating VIC server with pasted in certs from vsphere it get garbled somehow,
causing the server not to be able to start the admiral service on the vic server
with an error similar to:
start_admiral.sh[8031]: Exception in thread "main" java.lang.RuntimeException: Failed to read PKCS#8 PEM file. file=/configs/server.key
So ssh to the vic server and fix the certs.
when connected:
@bjornbouetsmith
bjornbouetsmith / vsphere_vic_firewall_notes.txt
Created May 5, 2019 10:26
vSphere Integrated Containers notes about firewall
vSphere Integrated Containers
* requires that firewall on esxi hosts are updated with the following firewall rule,
otherwise the containerhosts (vch) cannot communicate properly with the vic host
<!-- vSphere Integrated Containers Engine to allow outbound 2377/cp -->
<service id='0044'>
<id>vic-engine</id>
<rule id='0000'>
<direction>outbound</direction>
@bjornbouetsmith
bjornbouetsmith / vmdk_size.sh
Created April 29, 2019 16:55
vmdk real space taken
#!/bin/sh
echo "Total size in bytes of all vmdk"
stat *flat.vmdk|grep Size|cut -d ' ' -f 5|awk '{ SUM += $1} END { print SUM*512 }'
#install mbuffer
apt-get install mbuffer
#on receiver side start
mbuffer -s 128k -m 4G -4 -I 9090 | zfs receive -F tank/esxi
#on sender side: