Skip to content

Instantly share code, notes, and snippets.

View craigmulligan's full-sized avatar

Craig Mulligan craigmulligan

View GitHub Profile
@craigmulligan
craigmulligan / reporter.mjs
Last active November 24, 2023 22:49
Node:test Custom reporter to only print failed test console.logs
import { spec } from "node:test/reporters";
import { Transform } from 'node:stream';
class Reporter extends Transform {
// This is a custom test reporter for node:test
// it'll only log console.logs that occur during
// failed tests. For everything else it delegates
// to the default "spec" reporter.
constructor() {
super({ writableObjectMode: true })
@craigmulligan
craigmulligan / gen.js
Created November 8, 2018 13:45
frame number generator
const mod10CheckDigit = require('mod10-check-digit') // single digit check digit
const scheme_id = 1
const generation_id = 1
const totalbikes = 15
const cache = []
function getRandomInt() {
return Math.floor(Math.random() * 90 + 10)
}

Keybase proof

I hereby claim:

  • I am hobochild on github.
  • I am hobochild (https://keybase.io/hobochild) on keybase.
  • I have a public key whose fingerprint is 44D4 1828 5D08 4960 094D 5731 C760 17DB B450 A7C2

To claim this, I am signing this object:

@craigmulligan
craigmulligan / create-pages.js
Last active June 7, 2017 10:42
programatically create page from plugin
const path = require(`path`)
const slash = require(`slash`)
module.exports = ({ graphql, boundActionCreators }) => {
const { createPage } = boundActionCreators
const postTemplate = path.resolve(`${__dirname}/templates/changelog.js`)
createPage({
// Each page is required to have a `path` as well
@craigmulligan
craigmulligan / before_install.sh
Last active June 1, 2017 10:30
agile travis versionist script
echo "hello worlds!"
@craigmulligan
craigmulligan / gatsby-readme-transformer.js
Last active May 24, 2017 10:46
gatsby plugin to extract useful readme info
const crypto = require(`crypto`)
const readmeParser = require('readme-parser')
module.exports = async function onNodeCreate({
node,
getNode,
loadNodeContent,
boundActionCreators,
}) {
const { createNode, updateNode } = boundActionCreators
@craigmulligan
craigmulligan / index.js
Created May 2, 2017 17:06
script to start mock server before tests
var mockserver = require('mockserver-grunt'),
Mocha = require('mocha'),
fs = require('fs'),
path = require('path'),
Karma = require('karma').Server,
cfg = require('karma').config,
testType = process.argv[2]
var mockserverConfig = {
serverPort: process.env.RESIN_SUPERVISOR_PORT || 1080,
@craigmulligan
craigmulligan / access.sh
Created September 28, 2016 15:35 — forked from telphan/access.sh
Add public ssh key to a device
# [WARNING] Some of this commands may require root privileges
cd /home/root/.ssh/
chmod a+w authorized_keys
# One can just use copy/paste here. Replace key.public with your public key filename
xclip -i key.public && xclip -o > authorized_keys
chmod a-w authorized_keys
@craigmulligan
craigmulligan / EGL-bug.md
Created May 27, 2016 17:39
instructions on working around the docker-EGL bug.

EGL Bug/Screen freezes when using GPU-accelerated features

Symptoms

Screen freezes when trying to run a GPU-accelerated application, this can include 2D accelerated applications or video playback as well as obviously 3D applications. Generally the app runs without error but as soon as it tries to show video/render something in 3D/etc. the image freezes and often all inputs appear to freeze too. Sometimes a few frames of playback/rendering will be displayed before the freeze occurs, but not always.

Treatment

We've created a workaround for the underlying bug which causes this - in short, userland processes that use the GPU communicate with it ultimately via a messaging system called VCHIQ - this uses Process IDs (PIDs) to uniquely identify each 'service' associated with a given userland process, however under a PID namespace (which is established when a docker container is running), the PIDs as far as the kernel is concerned vs. as far as the container-run userland process is concerned vary, meanin

@craigmulligan
craigmulligan / resin-nodeSDK-example.js
Last active March 15, 2016 17:08
basic example of node reboot
var resin = require("resin-sdk")
var credentials = { email:unicorn@resin.io, password:******* };
var uuid = "7cf02a6"
resin.auth.login(credentials, function(error) {
if (error != null) {
throw error;
}
console.log("success authenticated with resin API")