Skip to content

Instantly share code, notes, and snippets.

@tknerr
tknerr / Vagrantfile
Created November 23, 2020 09:45
Developer VM for building a yocto images
Vagrant.configure("2") do |config|
# basebox
config.vm.box = 'generic/ubuntu2004'
# hostname
config.vm.hostname = 'yocto-dev-vm'
# virtualbox specific customizations
config.vm.provider "virtualbox" do |vbox, override|
@tknerr
tknerr / install_ansible.sh
Created December 10, 2014 16:57
Shell script for installing ansible. Should be idempotent and work ob Ubuntu + CentOS. Based on https://github.com/vovimayhem/vagrant-guest_ansible/pull/6/files#diff-0
#!/bin/bash
if ! command -v ansible >/dev/null; then
echo "Installing Ansible dependencies and Git."
if command -v yum >/dev/null; then
sudo yum install -y git python python-devel
elif command -v apt-get >/dev/null; then
sudo apt-get update -qq
#sudo apt-get install -y -qq git python-yaml python-paramiko python-jinja2
sudo apt-get install -y -qq git python python-dev
@tknerr
tknerr / Jenkinsfile.groovy
Last active February 29, 2020 05:54
Debugging Powershell Sequential / Parallel Workflows and Error Reporting in Jenkinsfile
def powershell_workflow(String mode, String... scripts) {
powershell """
echo "starting workflow in $mode mode"
workflow runWorkflow {
$mode {
${scripts.collect { script ->
"InlineScript { ${script} *>&1 | tee -filepath ${script.replace(' ','_')}.log; if(\$LastExitCode -ne 0) { Throw \"ERROR: \'$script\' failed with exit code \$LastExitCode \" } } -ErrorAction Continue"
}.join('\n') }
}
}
@tknerr
tknerr / custom-script-extension-remove-sf-server-headers.json
Last active October 4, 2019 14:27
Automated way to disable Service Fabric / HTTP.sys server headers via AzureRM template
{
"apiVersion": "[variables('apiVersionVmss')]",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"name": "[variables('sfVmssNode1Name')]",
"location": "[variables('location')]",
"properties": {
"virtualMachineProfile": {
"extensionProfile": {
"extensions": [
{
@tknerr
tknerr / README.md
Last active February 11, 2019 19:42
Trying to get a minimal Vagrant with a Windows guest example to work...

Environment

If you are trying to reproduce this exactly, I'm using the following environment:

Basebox

First challenge is to get a windows basebox from somewhere. I couldn't find a good one, so built one myself from the windows/boxcutter packer templates:

@tknerr
tknerr / actual-requests-vs-past-day-average.appinsights
Last active November 8, 2018 00:12
Show the actual requests of the past 5 minutes vs the average request count over the past day. The threshold we want to alert upon is the past day's average amplified by a factor of 10.
let lookbackWindow=30d;
let observationInterval=1d;
let sampleInterval=5m;
let thresholdFactor=10;
// 5-min request count average measured over the past 1 day
let averagedRequestsInObservationInterval = requests
| where timestamp > ago(lookbackWindow)
| summarize sum(itemCount) by bin(timestamp, sampleInterval)
| summarize averageRequestCount = avg(sum_itemCount) by bin(timestamp, observationInterval)
| extend threshold = averageRequestCount * thresholdFactor;
@tknerr
tknerr / output
Last active April 11, 2018 20:41
ping exercise in plain bash
$ ./pinger.sh "google.com facebook.com zuehlke.com"
average ping time for zuehlke.com: 63.600 ms
average ping time for facebook.com: 61.161 ms
average ping time for google.com: 61.953 ms
@tknerr
tknerr / git-ps1.bash
Created February 28, 2018 06:42
A Git Bash Prompt for Ubuntu 16.04
#!/bin/bash
export PS1='`if [ $? = 0 ]; then echo "\[\e[32m\] ✔ "; else echo "\[\e[31m\] ✘ "; fi`\[\e[00;37m\]\u\[\e[01;30m\]@\[\e[00;37m\]\h\[\e[01;37m\]:\[\e[01;34m\]\w\[\e[00;34m\] `[[ $(git status 2> /dev/null | head -n3 | tail -n1) != "Changes to be committed:" ]] && echo "\[\e[01;31m\]" || echo "\[\e[01;33m\]"``[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] || echo "\[\e[01;32m\]"`$(__git_ps1 "(%s)")`echo "\[\e[00m\]"`\$ '
@tknerr
tknerr / Vagrantfile
Created May 5, 2015 12:34
Given the below Vagrantfile the vagrant up process keeps hanging / does not return. Might have to do with the fact that `vagrant ssh -c "echo foo"` does not work either but drops us into an interactive powershell
Vagrant.configure(2) do |config|
config.vm.box = "boxcutter/eval-win7x86-enterprise-nocm"
# tell the VM to explictly use ssh and not replace keys
config.vm.communicator = :ssh
config.ssh.insert_key = false
config.vm.provision "shell", inline: "echo hello from inline"
@tknerr
tknerr / README.md
Created January 26, 2018 15:23
How to create a Visual Studio 2017 Offline Installer

README

A Visual Studio 2017 offline installer can be created with the following command:

vs_Professional.exe --layout C:\vs2017offline --add Microsoft.VisualStudio.Workload.CoreEditor --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.Azure --add Microsoft.VisualStudio.Workload.Data --add Microsoft.VisualStudio.Workload.NetCoreTools --includeRecommended --lang en-US de-DE

It includes the workloads and language packs specific for this project. You can easily create your own custom offline installer if your project uses a different toolchain.