Josh Kunz

Read this first

Howto: Gargle Authentication in Jupyter

TL;DR: See the code snippet at the bottom of this post for the code needed to get this to work.

gargle is a great little library for the R programming language that implements several authentication mechanisms against Google accounts. It’s used to power useful integrations like googlesheets4, and googledrive that allow R scripts to load data out of Google cloud resources. I recently started trying out Tiller for managing my personal finances, and I wanted to access my data from a JupyterLab notebook. When running on the command line, or in RStudio, gargle helpfully executes the OAuth flow by running a little local webserver that processes the authentication flow. In my JupyterLab setup, the kernel isn’t running on my machine directly. I tried running googlesheets4’s gs4_auth, but got back:

Error in `gs4_auth()`:
! Can't get Google credentials.
ℹ Are you running googlesheets4 in a

Continue reading →

Random Linux Oddity #1: ru_maxrss is Inherited

These days I do roughly 100% of my development on and for systems running Linux. Since my work and personal interests are pretty “low level”, I have spent quite a bit of time investigating the weird, and surprising details of the Linux kernel. Every time I spend hours or days tracking one of these little oddities down, I have a strong desire to shout it from rooftops, and “share it with the world”. Unfortunately, these tidbits are too small to really fill out a full-length “blog entry”. To date, I have avoided posting them because of this. But today, after spending another 6 hours investigating yet another quirk, I’ve yet again become overwhelmed with the need to share. So today, I’m creating a series of all the small annoyances and surprising wonders I’ve run into working on Linux called “Random Linux Oddities”. Each will be numbered starting from 1 for no particular reason.

The oddity...

Continue reading →

Selective “force” re-sync with syncthing

To synchronize files from one of my servers to my local machine I use [syncthing][st] with the server’s folder in [“Send Only”][master] mode. Usually this works flawlessly. As files are added to the directory, syncthing copies them to my local machine without a hitch. However, sometimes it doesn’t work, and the remote files will just never show up. In this case syncthing provides the [“Override Changes”][master] button, but this is usually not what I want to do. I don’t want to re-sync all of the files from master to my local machine, I just want to sync a single file, or folders worth of files.

In this case there’s a neat little trick you can do, which is obvious in hindsight but it took me a while to think of it: just update the mtimes. SSH onto the server and run something like:

$ find /path/to/folder/to/force/sync -type f -print0 | xargs -0 -n1 touch

This will go through every...

Continue reading →

Bit-field Packing in GCC and Clang

Recently for a school assignment we were given a C bit-field and tasked with packing a similar struct into the bit-field without the help of the compiler. All struct and bit-field manipulations had be be done manually using only the bytes of the structures. Amazingly, I didn’t even know what a bit-field was before starting this assignment, so I’ll give a little background before getting into the nitty-gritty details.

What is a bit-field

So, almost anyone familiar with C knows that it allows you to pack a group of variables into a new type called a ‘struct’. They look like this in C code:

struct mystruct {
    int a;
    short b;
    unsigned int c;

The C standard specifies that each platform will define a specific set of ‘alignments’ that will specify how structures like the one above are actually represented in memory. For example, the linux 32 bit standard specifies that chars...

Continue reading →