Skip to content

Instantly share code, notes, and snippets.


Kaido Kert kaidokert

View GitHub Profile
kaidokert / install-openssh.ps1
Last active May 2, 2023 02:09
Stub for testing provisioning
View install-openssh.ps1
Add-WindowsCapability -Online -Name "OpenSSH.Server~~~~"
# Dump in the key
echo ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCyFmcGw1DQhD7mns6lBQquepRf1p69ZjU/ml8bp3AA0RhDDwBYd4sjXfa/YgXS8A+5jDnivVvcqaB9jDWwGedLVYtPyObjp+OWZelGzx/hLI/E5LJ5iOh3Wu/AVJfaz+xdMEVNMq3fVNDgG72l9LlAxP8LC7tNWEGFsHESSg19RP61I8tOW5us/gjsAhwn+cZF8oURFx5daeLN7vjjXAMl6TOSvYxZR3Fcl+J/3FRTIQ0Iy5a463Jdc/lh/SMMWzwWNfTxOewm9Ay/KsA44ymcPTZOjSGfMRPeJ9KfQtbl2F/KYHkvtE5BFtwAZOVuFfrPSRWCQpPNvZp2U74/ffx2LZa8MvTIqOv1mzTeeR+/Ym6kc2CSmqkJ/STmXyj7b66gCuYfS9cwK+3Six6+8uYir1RGkjqM0WevH1V+EU0SSdyWqixK/R5GLPpwTpW3VBauEIdMZTXae4w67+EcocwiAtltZzrpizqGOE60WAHHrKPzRtGkqRo27Qor7u968kH4ir9i6Qy+4KeEiKgaZv+S0TNXIz+9tc8fpSDXw4WK0zm5Pmiu8rdRbwVLBSTFhPkvbkT4kVX2IGZtajUgP5Gw6abMGeuugeK2qYX+WsJMhXLBE6OinORTZIWsUGb5MZhPnQFCt66tcDkvuoTGYsNlujLufn99qvA8Ggo8U22/Uw== | Add-Content -Force -Path C:\ProgramData\ssh\administrators_authorized_keys
icacls 'C:\ProgramData\ssh\administrators_authorized_keys' /inheritance:r /grant 'Administrators:F' /grant 'SYSTEM:F'
Set-Service -N
kaidokert / install-openssh.ps1
Created May 1, 2023 02:10
Install openssh on Windows
View install-openssh.ps1
# OpenSSH
$capability = Get-WindowsCapability -Online -Name "OpenSSH.Client~~~~"
if($capability.State -ne "Installed") {
WriteInfoHighlighted "`t Enabling OpensSH Client"
Add-WindowsCapability -Online -Name "OpenSSH.Client~~~~"
Set-Service ssh-agent -StartupType Automatic
Start-Service ssh-agent
kaidokert /
Created May 1, 2023 01:37
Azure Free VMs terraform snippet
# Create Windows VM
resource "azurerm_windows_virtual_machine" "windows_vm" {
size = "Standard_B1s"
name = "${var.prefix}-windows-vm"
resource_group_name =
location = azurerm_resource_group.main.location
admin_username = "${var.adminname}"
admin_password = "${var.adminpwd}"
network_interface_ids = [
kaidokert / Git Subtree
Created April 29, 2023 01:13 — forked from SKempin/Git Subtree
Git Subtree basics
View Git Subtree

Git Subtree Basics

If you hate git submodule, then you may want to give git subtree a try.


When you want to use a subtree, you add the subtree to an existing repository where the subtree is a reference to another repository url and branch/tag. This add command adds all the code and files into the main repository locally; it's not just a reference to a remote repo.

When you stage and commit files for the main repo, it will add all of the remote files in the same operation. The subtree checkout will pull all the files in one pass, so there is no need to try and connect to another repo to get the portion of subtree files, because they were already included in the main repo.

Adding a subtree

Let's say you already have a git repository with at least one commit. You can add another repository into this respository like this:

kaidokert / cryptoparts.sql
Last active March 6, 2021 21:56
Query STM32 parts for security features
View cryptoparts.sql
-- The SQLite database file is in STMCube installation, cube-finder-db.db
select * from (
select substr(rpn,1,length(rpn)-2) as rpn, --remove last 2 letters of RPN which are memory size
core, featurename, featureitemname
from (
select replace(replace(rpn,'-A',''),'-X','') as rpn, --squash minor variants
strValue as core, featurename, fi.item featureitemname
from cpn
join cpn_has_attribute cha on
View Win_docker_refs.txt
kaidokert / Vagrantfile
Last active June 29, 2020 02:21
Simple quick Win VM
View Vagrantfile
Vagrant.configure("2") do |config| = "gusztavvargadr/visual-studio"
config.vm.box_version = "2019.0.2006"
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.memory = "8192"
vb.cpus = 6
vb.customize ["modifyvm", :id, "--accelerate3d", "on"]
vb.customize ["modifyvm", :id, "--clipboard", "bidirectional"]
vb.customize ["setextradata", "global", "GUI/MaxGuestResolution", "any"]
View gist:bf95571516cc49d0100030505f95c9b5
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\n",
"sources" : [ "" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "" ],
kaidokert / const_strcmp.h
Last active March 30, 2023 06:58
C++11 constexpr strcmp, from gcc 4.7.2+ and clang 3.5+
View const_strcmp.h
// API: constexpr int const_strcmp( "foo", "bar" );
// Much more readable version here:
// but that doesn't work with GCC before version 7
#include <cstddef>
#include <utility>
namespace detail {
kaidokert / const_str_len.hpp
Last active January 6, 2020 04:53
C++11 const string length, gcc 4.7+ and clang 3.5+
View const_str_len.hpp
// API: constexpr size_t const_strlen( "foo" );
// Much more readable version here:
// but that doesn't work with GCC before version 7
#include <utility> //std::forward
#include <cstddef> //std::size_t
namespace detail {
template<size_t COUNTER, typename T>