Skip to content

Instantly share code, notes, and snippets.

@tknerr
tknerr / Vagrantfile
Created Nov 23, 2020
Developer VM for building a yocto images
View Vagrantfile
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 / custom-script-extension-remove-sf-server-headers.json
Last active Oct 4, 2019
Automated way to disable Service Fabric / HTTP.sys server headers via AzureRM template
View custom-script-extension-remove-sf-server-headers.json
{
"apiVersion": "[variables('apiVersionVmss')]",
"type": "Microsoft.Compute/virtualMachineScaleSets",
"name": "[variables('sfVmssNode1Name')]",
"location": "[variables('location')]",
"properties": {
"virtualMachineProfile": {
"extensionProfile": {
"extensions": [
{
@tknerr
tknerr / actual-requests-vs-past-day-average.appinsights
Last active Nov 8, 2018
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.
View actual-requests-vs-past-day-average.appinsights
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 Apr 11, 2018
ping exercise in plain bash
View output
$ ./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 Feb 28, 2018
A Git Bash Prompt for Ubuntu 16.04
View git-ps1.bash
#!/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 / README.md
Created Jan 26, 2018
How to create a Visual Studio 2017 Offline Installer
View README.md

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.

@tknerr
tknerr / ci_jobs.groovy
Created Jan 18, 2018
Example JobDSL for a multibranchPipelineJob which keeps only the last 10 builds
View ci_jobs.groovy
// define the bitbucket project + repos we want to build
def bitbucket_project = 'myproj'
def bitbucket_repos = ['myrepo1', 'myrepo2']
// create a pipeline job for each of the repos and for each feature branch.
for (bitbucket_repo in bitbucket_repos)
{
multibranchPipelineJob("${bitbucket_repo}-ci") {
// configure the branch / PR sources
branchSources {
@tknerr
tknerr / Jenkinsfile.groovy
Last active Feb 29, 2020
Debugging Powershell Sequential / Parallel Workflows and Error Reporting in Jenkinsfile
View Jenkinsfile.groovy
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 / ci_jobs.groovy
Created Oct 6, 2017
JobDSL example for setting up master / release branch builds + PR builds via bitbucket-branch-source-plugin (using the generated JobDSL)
View ci_jobs.groovy
// define the bitbucket project + repos we want to build
def bitbucket_project = 'awesome'
def bitbucket_repos = ['foo','bar','baz']
// create a pipeline job for each of the repos and for each feature branch.
for (bitbucket_repo in bitbucket_repos)
{
multibranchPipelineJob("${bitbucket_repo}-ci") {
// configure the branch / PR sources
branchSources {
@tknerr
tknerr / chefdk-install.log
Last active Aug 17, 2017
ChefDK doesn't install on Win 10 1703 - log output of `msiexec /i chefdk-windows-1.5.0.msi /l*V chefdk-install.log`
View chefdk-install.log
=== Verbose logging started: 8/18/2017 4:19:49 Build type: SHIP UNICODE 5.00.10011.00 Calling process: C:\Windows\system32\msiexec.exe ===
MSI (c) (D8:A0) [04:19:49:117]: Font created. Charset: Req=0, Ret=0, Font: Req=MS Shell Dlg, Ret=MS Shell Dlg
MSI (c) (D8:A0) [04:19:49:117]: Font created. Charset: Req=0, Ret=0, Font: Req=MS Shell Dlg, Ret=MS Shell Dlg
MSI (c) (D8:B4) [04:19:49:180]: Resetting cached policy values
MSI (c) (D8:B4) [04:19:49:180]: Machine policy value 'Debug' is 0
MSI (c) (D8:B4) [04:19:49:180]: ******* RunEngine:
******* Product: chefdk-windows-1.5.0.msi
******* Action: