The Go Programming Lang

GOPATH Run, build and install Dependencies Formatting Documentation Structuring a source tree The lang Variables Control structures (if, switch and for) if switch for I/O fmt CLI Args Flags Basic Data Types Type conversion Strings Unicode String literals Numbers Integers Bitwise operations Floating point Constants Pointers Functions Grouped parameters types Variadic functions Multiple return values Named return values Recursion Deferred functional calls Functions as values Function literals (anonymous functions) Passing functions to functions Closures Error Handling Error handling strategies Propagate to caller Retry Log and continue Log and exit pkg/errors Panic and Recover Packages and Libraries Package aliases Imported unused packages for side effects Inspecting a package API Advanced Data Types Arrays Slices Extending slices Creating a slice with make Byte slices Maps Creating maps CRUD (create retrieve update delete) operations with maps Named types (user defined types) Function named type Type aliases Struct Struct embedding Field tags Struct methods Receiver Method Sets Interfaces Interface internals WARNING - dont assign nil variables to interfaces Type assertion Type switches Cool cool cool stdlib Tools Make Vim setup Libraries Data Middleware Web Effective Go is a howto on writing idiomatic Go. ...

October 5, 2019 · 30 min

Exploiting Heap Allocators Technical Paper

An academic paper I authored in October 2019, as part of studying Modern Exploit Development at UNSW. Abstract Heap oriented exploits continue to be an ongoing threat, and have gained popularity post the stack smashing frenzy of the 90’s and early 00’s. Even so called safe languages (e.g. JavaScript, Java) remain vulnerable due to their underlying C/C++ implementations. Heap allocator designs and implementations, of which there are many, struggle to strike the balance between performance and security, performance often winning out to keep programs running as fast as possible. Two ingredients are needed for a successful heap exploit, the first a memory management error in the target program, and second an exploitable heap allocator implementation. Many countermeasures in mainstream allocators seen to date are often the result of knee-jerk reactions to exploits of the past, with patching occurring to existing designs. A large body of research exists around detecting, preventing or mitigating heap attacks. ...

October 19, 2019 · 39 min

Binary Similarity Analysis Technical Paper

An academic paper I authored in May 2019, as part of studying Reverse Engineering at UNSW. Abstract Extracting meaningful semantic differences between software binaries without source code is difficult. This is a challenging problem due to the overwhelming amount of syntactic noise that small changes can result in at the assembly level. Curiously when it comes to program semantics the “signal from the noise” can be distilled in a manner that is both static and processor agnostic, through the application of control flow and graph isomorphism analysis, symbolic execution and theorem proving. The graph isomorphism problem has no known polynomial time algorithm (i.e. is NP) making brute force approaches computationally infeasible. By blending various static analysis techniques and applying some generalisations, consider a novel approach to overcoming the computationally infeasibility of this problem domain with a view to binary difference analysis. ...

May 29, 2021 · 17 min

Notes from the book Atomic Habits

I just read the kindle edition of Atomic Habits by James Clear. Its worth the time investment, giving practical ways for building desired habbits and more importantly, breaking bad ones. The habit loop The four stages of habit are an endless cycle. This habit loop is continually scanning the environment, predicting what will happen next, trying out different responses, and learning from the results. The cue triggers a craving That motivates a response That provides a reward That satisfies the craving and, ultimately, becomes associated with the cue 4 laws of behavior change The pillars of the book, are the four stages of the habit building process: ...

June 12, 2021 · 15 min

Hiking pack system

Stacked packing system Inner pack Side pockets Front pocket Options Ditty bag Food Cold soak meal recipes Refried beans Pinto beans Cous Cous Veggies Oil wrap Potato Bomb Rice Bomb Oatmeal Cereal Useful resources Lessons learned April 2021 November 2021 Over the last year I have been experimenting with reducing the weight of my hiking pack when out on track. Reading books on ultralight hiking, has me with some strategies for doing so. ...

May 29, 2021 · 5 min

Gentoo Linux

The next step in my minimalist computing journey. Enter Gentoo, my first source based GNU/Linux distro. Pre-packaged binaries, which is the approach most other (binary based) distros take, must often cater for the lowest common denominator to ensure packages can run on lots of differing setups out in the wild. On a source based distro, I can articulate my specific needs (USE flags on Gentoo) to finely tune the binaries to my system. For example, as I plan to steer clear of software like systemd, kde and gnome, I can ensure support for these packages is NOT built into other program binaries I build for my system. ...

February 22, 2021 · 13 min

Kubernetes

The name Kubernetes originates from Greek, meaning helmsman or pilot. Terminology Essentials Help Bash kubectl completion Web UI dashboard Pods Creating a pod Option 1: Imperatively with the CLI Option 2: Declaratively with YAML Port forwarding Managing pods Pod Health Deployments and ReplicaSets ReplicaSet Deployment Deployments with kubectl Deployment Options Rolling updates Blue Green Canary Rollbacks StatefulSets Services Service Types Port forwarding take 2 Services YAML NodePort example ExternalName example Testing Service and Pod with curl Storage Volumes Volume Types Viewing a Pods volumes emptyDir volume example PeristentVolumes and PeristentVolumesClaims StorageClasses Managing configuration with ConfigMaps and Secrets Defining ConfigMaps Consuming ConfigMaps Secrets Secret best practices Storing Secrets Using Secrets Secrets as environment variables Secrets as files Troubleshooting Logs Configuration verification Shell into Pod container The API General kubectl Waaay cool Samples node.js app microk8s Shell improvements PersistentVolume storage location Resources Terminology k8s is two concepts; the control plane and nodes. ...

August 18, 2020 · 20 min

Git

Aliases Common tasks Undo-ing Diff-ing Pushing and pulling Patches Uncommon tasks Branch name in Bash prompt (PS1) Discover large commits in history Concepts Rebase vs Merge Merge Rebase Interactive rebasing (-i) Submodules Detached Head Aliases From my .gitconfig. [alias] alias = config --get-regexp '^alias.*' # list available aliases # add and commit a = add aa = add --all ac = !git add . && git commit -am ap = add -p c = commit --verbose ca = commit -a --verbose cm = commit -m cam = commit -a -m m = commit --amend --verbose uncommit = reset --soft HEAD~1 # branching ba = branch -a bd = branch -d bD = branch -D branches = branch --all branchrename = branch --move branchesdiffed = !git branch | grep -i "indiff" branchesundiffed = !git branch | grep -v -i "indiff" cleanmerged = !git branch --merged | grep -v \"\\*\" | xargs -n 1 git branch -d # remove merged branches co = checkout cob = checkout -b wipelocal = checkout . # diff d = diff ds = diff --stat dc = diff --cached f = fetch -p # remote p = push pr = pull --rebase pushitgood = push -u origin --all rao = remote add origin # rebase rb = rebase rba = rebase --abort rbc = rebase --continue rbs = rebase --skip # log st = status -sb plog = log --graph --pretty='format:%C(red)%d%C(reset) %C(yellow)%h%C(reset) %ar %C(green)%aN%C(reset) %s' tlog = log --stat --since='1 Day Ago' --graph --pretty=oneline --abbrev-commit --date=relative lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit out = log --pretty=oneline --abbrev-commit --graph @{u}.. in = !git fetch && git log --pretty=oneline --abbrev-commit --graph ..@{u} rank = shortlog -sn --no-merges winning = shortlog --summary --numbered --email totalcommits = !git log --all --pretty=oneline | wc -l commitslastmonth = !git log --author=\"`git config user.name`\" --before={`date "+%Y-%m-01"`} --after={`date --date=\"$(date +%Y-%m-1) -1 month\" \"+%Y-%m-01\"`} --reverse --pretty=format:\"%cd %h %s\" --date=short commitsthismonth = !git log --author=\"`git config user.name`\" --before=now --after={`date "+%Y-%m-1"`} --reverse --pretty=format:\"%cd %h %s\" --date=short commitstoday = !git log --author=\"`git config user.name`\" --since=\"6am\" rank = shortlog -sn --no-merges Common tasks Undo-ing Dump all uncommitted changes and baseline the local files based on the latest committed change (HEAD): ...

August 11, 2018 · 6 min

KVM virtualisation

The Kernel Virtual Machine is a hypervisor for Linux on hardware with virtualization extensions (Intel VT or AMD-V). It is deployed as a loadable kernel modules, kvm.ko, and either kvm-intel.ko or kvm-amd.ko. The KVM Debian Wiki rocks, and provides details on the basics including a great performance tuning section. Install Administration tasks User specific vs system wide VMs List VMs Start VM Shutdown VM Murder (hung) VM Autostart default NATed bridged network What if the default network interface is not listed How to extend / increase a partition Use network ISO source for new VMs Windows VM disk driver Install Easy instructions to get QEMU/KVM and virt-manager up and running on Arch. ...

October 31, 2020 · 4 min

Installing Arch Linux on the Pinebook Pro

Updated 2022-04-11: Installed a minimal version of Manjaro, a SLICK flavour of Arch The pinebook pro is a beautiful 64-bit ARM based laptop, that reminds me of the form factor of a modern macbook air, shipping with a premium magnesium alloy shell, 64GB eMMC and a 10,000 mAH battery. All this for $200. As a NIX machine, I’ve found Manjaro to be delightful. I have dreams of one day installing OpenBSD. ...

July 27, 2020 · 3 min