Skip to content

Instantly share code, notes, and snippets.

View spikeheap's full-sized avatar

Ryan Brooks spikeheap

View GitHub Profile
@spikeheap
spikeheap / PageAlerts.html
Last active August 29, 2015 14:17
Angular global user bootstrap alerts
<div>
<alert ng-repeat="alert in alerts" type="{{alert.type}}" close="alert.close()">{{alert.message}}</alert>
</div>

Keybase proof

I hereby claim:

  • I am spikeheap on github.
  • I am spikeheap (https://keybase.io/spikeheap) on keybase.
  • I have a public key whose fingerprint is 48ED EC4E F283 D4D3 EAD3 9236 F3B7 4711 D033 CD1B

To claim this, I am signing this object:

@spikeheap
spikeheap / README.md
Last active May 24, 2017 07:59
The most basic ES6-polyfilled test setup I can come up with

Karma, Browserify & Babelify

Do you need Promises and other ES6 goodness. This will give you polyfills for your tests, and a working Karma, Browserify & Babelify setup.

Caveats

This example has been drawn up for this StackOverflow question. You probably want to polyfill Promises, etc. unless all your supported browsers already contain it. You probably also want to keep your compilation/babelification/browserification process the same between build and test. Fortunately you can (hint: common config can live in package.json), but that's outside of the scope of this Gist.

@spikeheap
spikeheap / README.md
Last active October 8, 2015 08:31
Git Flow start the day

Add this function to your ZSH/BASH init to do a sane update of develop and master. Handy when you come back to a project after a couple of days.

Note that this doesn't merge develop into your current branch, but I'll leave that to you to add if you need it :).

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
@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()|@*">
@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 / 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 / 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 / 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