make

A small make orientation guide. make is a versatile task runner, its core competency is in creating files from other files Make essentials Equal signs Built-in variables Phony targets C specifics Custom variables Implicit variables Example Makefiles Make essentials make generates files from other files, using recipes, the syntax is as follows. Please note, thanks to POSIX standardisation the recipe MUST be indented with a tab (not spaces): target_file: prerequisite_file1 prerequisite_file2 shell command to build target_file (MUST be indented with tabs, not spaces) another shell command (these commands are called the "recipe") Unless you specify otherwise, Make assumes that the target (target_file above) and prerequisites (prerequisite_file1 and prerequisite_file2) are actual files or directories. You can ask Make to build a target from the command line like this: ...

October 9, 2016 · 7 min

Linux Ops Guide

Here I aim to cover a set of common administration tasks. Things like, the hostname, system logs, what users are currently logged in, physical devices that are connected, logical volumes, file system and inode allocation, attached network interfaces and their addressing, processes and daemons currently running, kernel verison, local users and groups, installed packages, remote mounts, network shares, system uptime, bread and butter OS stats (CPU, IO, network, memory). Booting shutdown -r +5 System going down for a reboot #wall broadcast msg shutdown -c #cancel reboot shutdown -r 00:00 #schedule for midnight shutdown -h +5 #halt system in 5 mins shutdown -h now Alternatively, just use systemd: ...

August 1, 2016 · 12 min

Secure SHell (SSH)

The OpenSSH secure shell, ssh, provides the necessary client/server security plumbing, to allow shell execution on a remote machine. ssh can be used interactively, as per a normal shell, or to run one off commands, for example: $ ssh ben@wookie.local uname -a ben@wookie.local's password: Linux wookie.local 3.14-1-686-pae #1 SMP Debian 3.14.7-1 (2014-06-16) i686 GNU/Linux Hot tip: the w command is gem for showing users currently logged in $ w -f USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT ben tty2 :0 17:05 10:36m 16:53 50.97s /usr/bin/evince /home/ben/podcasts/redhat/Docs/RH124-RHEL7.pdf User ben logged into virtual console 2 (tty2) via a graphical login (:0) at about 5PM. OK, lets access a couple of the virtual terminals: ...

August 1, 2016 · 6 min

Architecture

A collection of software concepts I plan to apply to some up coming projects. Some fundamental philosophies: Automation everywhere. A clean (agnostic) contract with the underlying operating system, promoting portability between execution environments. Can scale without major changes to tooling, architecture or development. Smallest possible delta between development and production, enabling continuous integration. Deployment Processes are first class citizens. Execute the application as one or more stateless processes. Model process types explicitly, e.g. HTTP requests might be handled by a web process, while long running backend tasks by a worker process. Always rely on the operating systems user-space process manager (e.g. systemd, Upstart) to manage output streams, respond to crashed processes and handle user initiated restarts and shutdowns. Concurrency; Physical distribution and clean contract with operating system, e.g. containers (e.g. docker). Versioning; the ability to deploy and hotswap versions side by side. Pluggable; ability to snap modules into architecture (punch through all layers), see attached resources under backing services. Store all runtime configuration as environmental variables. They are a language and OS agnostic standard, and unlike other config options such as Java System Properties, are not accidentially added into the source code repo. The array of process types and number of processes of each type is known as the process formation. ...

July 13, 2016 · 3 min

soapUI mock bug

Today I stumbled onto interesting soapUI quirk, involving a combination of mock services, SOAP 1.2 and multipart message definitions. In essence, the soapUI mock service will always return an HTTP 500, with the following response: {% highlight xml %} <soap:Envelope xmlns:soap=“http://www.w3.org/2003/05/soap-envelope"> soap:Body soap:Fault soap:Code soap:ValueServer</soap:Value> </soap:Code> soap:Reason <soap:Text xml:lang=“en”>Missing operation for soapAction [http://services.net.bencode/wsdl/2016/06/01/retrievecoolnesslevelrequest] and body element [{http://services.net.bencode/wsdl/2016/06/01}retrieveCoolnessLevelRequest] with SOAP Version [SOAP 1.2]</soap:Text> </soap:Reason> </soap:Fault> </soap:Body> </soap:Envelope> {% endhighlight %} Sigh. Thankfully some legend known as fyerf posted a solution on the smartbear community forums. ...

June 1, 2016 · 3 min

DIY Computer Part 4 Machine Language

A continuation of my participation in the amazing Nand2Tetris course, by Noam Nisan and Shimon Schocken, now running on Coursera. In this course you will build a modern computer system, from the ground up. We’ll take you from constructing elementary logic gates all the way through creating a fully functioning general purpose computer. In the process, you will learn how really computers work, and how they are designed. If interested, see prior posts: ...

May 23, 2016 · 7 min

bash

Bash is a Unix shell written by Brian Fox in 1989 for the GNU Project as a free replacement for the Bourne shell. To this day, Bash remains one of the most powerful and ubiquitous scripting tools on the planet. Contents Useful Shortcuts Initialisation Shell Grammar Variables Local variables Environment variables Positional arguments Expansions Brace expansion Command substitution Arithmetic expansion Double and single quotes Stream Redirection here documents Arrays Conditions if statements case statements Loops For Loops Select Loops While Loops Until Loops Functions Coprocesses Builtins Bash Recipes Top 6 largest things in the current directory Display the 23rd line of /etc/passwd Filter the first column from process status Delete Subversion scrap files Move shell scripts and mark them as executable Pattern matching Scan code base against list of patterns Rename Multiple Files Run a command every time a file is modified Keep a program running after leaving SSH session Simple menu and functions Complete example Resources Kudos to Denys Dovhan and his awesome Bash handbook. The most digestable, and enjoyable method I’ve found to groking bash. <3 ...

May 1, 2016 · 16 min

Classloaders

First some kudos and credits to the below. None of the material in this post is original, and I have documented it for my personal learning. Please refer to the below original (and superior) articles. ZeroTurnaround’s Jevgeni Kabanov awesome and most practical Do You Really Get Classloaders? Oracle’s A Sundararajan Understanding Java class loading All the way from 1996 by Chuck Mcmanis The basics of Java classloaders Hello java.lang.ClassLoader A Java class is loaded (i.e. born into the JVM) by a concrete implementation of java.lang.ClassLoader. If a class must be class loaded, what loads the java.lang.ClassLoader class itself (i.e. who loads the loader)? It turns out that there is a bootstrap classloader wired into the JVM. The bootstrap loader loads java.lang.ClassLoader in additional to many other Java platform classes (e.g. java.lang.*) into memory. The essential API: ...

April 20, 2016 · 11 min

thinkfan

I run Debian on a ThinkPad T420s. ThinkPad’s have a great Linux compatibility story, and the T420s is no exception. The cooling fan situation seemed in need of some attention though, with fans running at high RPM most of the time. Not only was this really noisy, hit the battery quite hard too. Enter thinkfan, a simple fan control program. Works with any linux hwmon driver, especially with thinkpad_acpi. It is designed to eat as little CPU power as possible. ...

March 19, 2016 · 2 min

Struts

Struts, the famous Java MVC web framework of the late 90’s and early 00’s that pioneered well structured server side web logic. Many Java based enterprise applications developed during this era (a metric s#!t ton) still make heavy use of Struts 1.x today. Apache Struts 1 is a discontinued open-source web application framework for developing Java EE web applications. It complements the Servlet API to encourage developers to adopt a model–view–controller (MVC) architecture. It was originally created by Craig McClanahan and donated to the Apache Foundation in May, 2000. ...

March 17, 2016 · 16 min