A new Litter Survey
In a culmination of litter surveys and litter picks, linked data() and data exploration, and remoteStorage and ActivityPub, I have created a web-based litter pick/survey app that I hope will allow federated citizen science.
In a culmination of litter surveys and litter picks, linked data() and data exploration, and remoteStorage and ActivityPub, I have created a web-based litter pick/survey app that I hope will allow federated citizen science.
My latest litter pick target was Hoe Stream and the White Rose Lane Local Nature Reserve. Here's how it went.
I just created a Gitlab CI job to create a release with information from a CHANGELOG.md file for some of my projects. Here's how I did it.
I noticed something strange happening during build process during a multi-tasking bug fix. Turns out I was using Gitlab CI's caching incorrectly. I should have been using artifacts. Here's what I saw.
As a birthday treat, I took the day off work to try out my electronerised litter picker. Here's how it went.
In preparation for a day of litter picking, I finally got round to a project idea - attaching a camera to a litter picker to record it all. Here's what I did.
I finally started implementing UI testing on first-draft using WebdriverIO. While writing tests was easy, getting the tests running was a little more difficult. Here is how I did it.
Hooray! My new blog is live! Based on Sapper, using MongoDB and eventually ActivityPub and ActivityStreams, it will be my federated posting hub to the world.
Creating this new blog, I wanted to make sure there was no metadata data leaking personal information. Here's how I removed all the metadata tags except the ones I wanted from my photos.
Using tmux for your terminal multiplexer but want an easy to reattach to a session? Here's a small bash script to do it.
Here's how to help your readers save time by making your post's shell commands easy to select and copy - with a simple CSS property.
Making my new blog, I didn't initially set the published dates to be native dates in the database. Here what I did to change them ...and do all the upgrades I needed.
I recently needed to test that some Vue components were creating the correct HTML. To do this, I decided to create snapshots of Object representations of the rendered HTML.
HTML5 number inputs aren't useful, but tel inputs, have all the power
I decided to look into the extortion emails I have been getting and wrote a small script to extract the bitcoin addresses that have been used.
As part of my pledge not to upgrade, I decided to repair two of my failing mice instead of replacing them with a brand new model (as tempting as it was). Here's what I did.
Testing Javascript modules that use the filesystem can be a little annoying to test sometimes, especially when using awesome parallel test runners like Ava. While developing MARSS, my Markdown blogging system, I tried to find a good way of running the tests, so they could effectively have their own environment (read folder) to test in. I came accross memfs, which implements the fs module in a virtual filesystem in memory. The author also created fs-monkey, which allows you to patch the fs module with a given fs-like implementation.
With these, you are able to make the code you are testing use your own specially crafted filesystem. Woot. (Un)fortunately, the require function also uses the fs module to read files, so when you patch the fs module, you also restrict importing any more modules. Luckily, the author has unionfs which allows you to patch two file systems together - phew.
Wiring it all together it allows you to create a test file system that you can then use to test Javascript that does operations on the file system. Below is the module I created for doing such a thing and how I used it in my tests.
The below module sets up the virtual test file system and patches the fs module for the tests.
import { patchFs } from 'fs-monkey';
import { Volume } from 'memfs';
import { ufs } from 'unionfs';
import * as fs from 'fs';
export const vol = new Volume();
const fs2 = Object.assign({}, fs);
ufs.use(fs2).use(vol);
patchFs(ufs);The test loads above module, loads tests files into is using the memfs() .fromJson() function into a folder based on the test process id.
import { vol } from '../unionfs';
import * as process from 'process';
// Import the module to test that uses the fs, eg runs a glob
import { someFunction as thingToTest } from './someFunction';
const exampleFiles = {
'folder/file1.txt': `This is the contents of file 1`,
'folder/file2.txt': `This is the contents of file 2`,
'another.txt': `You get the point`
};
const testFolder = `/test/${process.pid()}`
vol.fromJSON(exampleFiles, testFolder);
test('it returns an array of files in the directory', async (t) => {
const results = await thingToTest(testFolder);
t.deepEqual(Object.keys(exampleFiles), results);
});