Skip to content

Instantly share code, notes, and snippets.

@tknerr
tknerr / AdbCommands
Created April 12, 2023 16:04 — forked from ernestkamara/AdbCommands
Adb useful commands list
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
== Shell
@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 / 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 / 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 / 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.

@tknerr
tknerr / ci_jobs.groovy
Created January 18, 2018 10:21
Example JobDSL for a multibranchPipelineJob which keeps only the last 10 builds
// 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 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 / ci_jobs.groovy
Created October 6, 2017 10:00
JobDSL example for setting up master / release branch builds + PR builds via bitbucket-branch-source-plugin (using the generated JobDSL)
// 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 {