Skip to content

Instantly share code, notes, and snippets.

View mattiasb's full-sized avatar

Mattias Bengtsson mattiasb

View GitHub Profile
@mattiasb
mattiasb / Makefile
Last active December 28, 2021 06:44
OpenWRT Image Builder Raspberry Pi 4 Makefile
VERSION=21.02.1
TARGET=bcm27xx-bcm2711
PROFILE=rpi-4
PACKAGES=kmod-usb-net-rtl8152 luci luci-ssl
FILESYSTEM=ext4
###################
BUILDER_BASEURL=https://downloads.openwrt.org/releases/$(VERSION)/targets/$(subst -,/,$(TARGET))
BUILDER_TARBALL=openwrt-imagebuilder-$(VERSION)-$(TARGET).Linux-x86_64.tar.xz
@mattiasb
mattiasb / Output
Created December 11, 2020 17:09
Ansible some tasks don't prepend role name
TASK [check : Type Checking mount field in storage_lvm_volumes] **********
ok: [machine-test.local] => (item={'path': '/'}) => changed=false
ansible_loop_var: item
item:
path: /
msg: All assertions passed
TASK [storage : check : Type Checking bools] *****************************
ok: [machine-test.local] => changed=false
msg: All assertions passed
@mattiasb
mattiasb / Vagrantfile
Created December 10, 2020 13:40
Vagrantfile: Theoretical change to shell provisioner to allow changing guest ssh port
config.vm.define "git.local" do |server|
server.vm.hostname = "git.local"
server.ssh.port = 2222
# The ssh_port field doesn't exist in Vagrant, but would make it possible to
# change guest ssh port during provisioning.
server.vm.provision "shell", ssh_port: 22, inline: <<-SHELL
set -ex
sed -i -Ee 's/^[[:blank:]]*#[[:blank:]]*Port[[:blank:]]+22$/Port 2222/' \
/etc/ssh/sshd_config
systemctl restart sshd.service
@mattiasb
mattiasb / Jenkins log
Created March 2, 2020 14:20
Jenkins dind
Started by user Mattias Bengtsson
Running in Durability level: PERFORMANCE_OPTIMIZED
[Pipeline] Start of Pipeline
[Pipeline] node
Running on builder22_Linux in /home/company/jenkins/workspace/Experiments/mattiasb/DockerTest
[Pipeline] {
[Pipeline] isUnix
[Pipeline] sh
+ docker inspect -f . node:7-alpine
.
@mattiasb
mattiasb / Testkörning
Last active November 14, 2019 21:08
Enkel Python
$ python3 ./hej.py
Hello Pelle!
Hello Pelle!
Hello Kalle!
Hello Kalle!
@mattiasb
mattiasb / shuffler.cs
Last active September 15, 2019 02:07
Shuffler example
using System.Linq;
using System.Collections.Generic;
using System;
public class UniqueRandom {
private HashSet<int> intSet = new HashSet<int>();
private Random rng;
public UniqueRandom(Random rng) {
this.rng = rng;
@mattiasb
mattiasb / Jenkinsfile
Last active March 23, 2018 13:21
Will I get the same agent?
// In the following pipeline the stages that start with 'Build: ' needs to run
// on the same node and in the same workspace, the same is true for the stages
// that begin with 'Test: '
// Will this be the case as the pipeline is written?
// If not, can I force the pipeline to do so?
pipeline {
options {
skipDefaultCheckout()
}
#!/bin/bash
function _help-flag() {
[[ " ${@} " == *" --help "* ]] || [[ " ${@} " == *" -h "* ]]
}
if _help-flag "${@}" || [ $# -lt 3 ] ; then
echo "Usage: ${0} <STR1> <STR2> FILE..."
echo
echo "Rename a bunch of files by replacing STR1 with STR2 in their filename."
@mattiasb
mattiasb / compile_commands.json
Created April 8, 2017 16:48
Compiling libchamplain with `bear -n make` under JHBuild
[
{
"command": [
"/bin/sh",
"-c",
"fail=; \\\nif (target_option=k; case ${target_option-} in ?) ;; *) echo \"am__make_running_with_option: internal error: invalid\" \"target option '${target_option-}' specified\" >&2; exit 1;; esac; has_opt=no; sane_makeflags=$MAKEFLAGS; if { if test -z '0'; then false; elif test -n 'x86_64-redhat-linux-gnu'; then true; elif test -n '4.1' && test -n '/home/mattiasb/Code/gnome/build/libchamplain'; then true; else false; fi; }; then sane_makeflags=$MFLAGS; else case $MAKEFLAGS in *\\\\[\\ \\\t]*) bs=\\\\; sane_makeflags=`printf '%s\\n' \"$MAKEFLAGS\" | sed \"s/$bs$bs[$bs $bs\t]*//g\"`;; esac; fi; skip_next=no; strip_trailopt () { flg=`printf '%s\\n' \"$flg\" | sed \"s/$1.*$//\"`; }; for flg in $sane_makeflags; do test $skip_next = yes && { skip_next=no; continue; }; case $flg in *=*|--*) continue;; -*I) strip_trailopt 'I'; skip_next=yes;; -*I?*) strip_trailopt 'I';; -*O) strip_trailopt 'O'; skip_next=yes;; -*O?*) strip_trailopt
bd = "!f() { git for-each-ref --sort=committerdate refs/heads/ --format='%(refname:short):%(committerdate:relative)'; }; f | column -t -s ':'"