Skip to content

Instantly share code, notes, and snippets.

View spikeheap's full-sized avatar

Ryan Brooks spikeheap

View GitHub Profile
@spikeheap
spikeheap / jq_pupil_aggregating.md
Last active June 2, 2023 11:08
JQ puzzling with Adam after the May 2023 RemoteHack

JQ puzzling with Adam after the May 2023 RemoteHack

Given the input:

INPUT_JSON='{
  "students": [
    {
      "name": "Jane",
      "grades": {
@spikeheap
spikeheap / sessions.md
Last active August 20, 2017 15:09
Introduction to Coaching Workshop, Oxford 2017-08-12

Workshop sessions

First we split into groups of 5 and asked:

What experience do you have of coaching or mentoring? What’s the difference between mentoring and coaching?

Session 1

Once we’d committed to confidentiality and making the workshop a safe space, in pairs we covered:

What is it like doing your job?

# Requires the following environment variables:
#
# - COMMIT_REF
# - GITHUB_OAUTH_TOKEN
source .env.docker
curl -s -H "Authorization: token $GITHUB_OAUTH_TOKEN" "https://api.github.com/repos/growkudos/growkudos/contents/Gemfile?ref=$COMMIT_REF" \
| jq '.content' --raw-output \
| base64 --decode \
> Gemfile
root@58857b49d831:/openMVS_build# make -j2
Scanning dependencies of target Common
[ 1%] Building CXX object libs/Common/CMakeFiles/Common.dir/Timer.cpp.o
[ 3%] Building CXX object libs/Common/CMakeFiles/Common.dir/Common.cpp.o
In file included from /openMVS/libs/Common/Types.h:357:0,
from /openMVS/libs/Common/Common.h:176,
from /openMVS/libs/Common/Timer.cpp:8:
/openMVS/libs/Common/HalfFloat.h: In static member function 'static short int SEACAVE::hfloat::fromFloat(float)':
/openMVS/libs/Common/HalfFloat.h:62:29: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
const int& fltInt32((int&)fv);
@spikeheap
spikeheap / test.rb
Last active January 2, 2017 19:45
Rails Docker DB with migrations
#/config/environments/test.rb
require 'docker'
Rails.application.configure do
config.after_initialize do
logger.info "db:migrate"
ActiveRecord::Migrator.migrate(Rails.root.join("db/migrate"), nil)
end
@spikeheap
spikeheap / env_var_perf_test.php
Created November 17, 2016 22:17
A naïve perftest of EmonCMS settings logic
<?php
// 10,000,000
$run_count = 10000000;
$start_time = time();
for ($i = 0; $i < $run_count; $i++) {
//1 #### Mysql database settings
if (isset($_ENV["MYSQL_HOST"])) $server = $_ENV["MYSQL_HOST"];
if (isset($_ENV["MYSQL_DATABASE"])) $database = $_ENV["MYSQL_DATABASE"];
@spikeheap
spikeheap / stdin_reader.rb
Last active August 7, 2021 15:36
Reading STDIN with threads in Ruby
require 'thread'
queue = Queue.new
producer = Thread.new do
loop do
key = STDIN.getch
queue << key if key
end
end
@spikeheap
spikeheap / Dockerfile
Created April 29, 2016 09:34
Nginx HTTPS proxy for Rails
FROM alpine:3.2
MAINTAINER ryan@slatehorse.com
RUN apk add --update nginx openssl && rm -rf /var/cache/apk/*
COPY ./nginx.conf /etc/nginx/nginx.conf
# Generate certificates
ENV CERTIFICATE_DIR=/usr/local/app/certs
@spikeheap
spikeheap / add_m_attribute.xsl
Last active November 9, 2015 10:48
Add `m` attribute to all leaf nodes
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0"
xmlns:d="http://nihr.ac.uk/nhic/ICU/UCL/finalv8.3.2">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:variable name="dateNow" select="format-date(current-date(), '[Y0001]-[M01]-[D01]')"/>
<xsl:template match="node()|@*">
export XMLLINT_FILE=xmllint_20151103_1930.log
xmllint --schema docs/NHIC_ICU_v8.3.2-Final.xsd --noout docs/output/NIHRHIC_CC_8.3.2_Oxford\ 03112015.xml 2>&1 | grep -v "The attribute 'm' is required but missing." > $XMLLINT_FILE
# get an overview of the failure counts
cut -d':' -f3 $XMLLINT_FILE | sort | uniq -c | sort
# lookup a particular error (_0085 in this case):
cat $XMLLINT_FILE | grep _0085 | cut -d: -f7 | sort -u