Skip to content

Instantly share code, notes, and snippets.

View aslakhellesoy's full-sized avatar
🤠
typing...

Aslak Hellesøy aslakhellesoy

🤠
typing...
View GitHub Profile
@aslakhellesoy
aslakhellesoy / post-fetch
Created January 4, 2018 22:14
post-receive
#!/bin/sh
# This isn't really a git hook, but it's manually called it after every fetch run.
# This script essentially wraps the actual post-receive hook.
# Build the standard input for the post-receive hook
touch CPRO_HEAD
cat refs/heads/* | paste CPRO_HEAD - > post-fetch.tmp
find refs/heads/* | paste post-fetch.tmp - | awk '{print $1, $2, $3}' > post-fetch.stdin
# features/support/parameter_types.rb
suffix = '(?:st|nd|rd|th)'
ParameterType(
name: 'flight',
regexp: /(\d+)#{suffix} flight/,
transformer: ->(n) { n.to_i }
)
ParameterType(
@aslakhellesoy
aslakhellesoy / remove-bom.sh
Created November 23, 2017 12:52
Remove BOM from a bunch of files
#!/usr/bin/env bash
function removeBom
{
awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}{print}' "$1" > .nobom
mv .nobom "$1"
}
shopt -s globstar
for f in **/*.{cs,config,feature,feature.cs,csproj,sln,md}; do
@aslakhellesoy
aslakhellesoy / circleZapier.js
Created June 27, 2017 12:43
Find failed build task in Circle build - Zapier function
fetchBuild(inputData.buildNum, CIRCLE_TOKEN)
.then(failedAction)
.then(function(action) {callback(null, {'Failed Action': action})})
.catch(function(err) {callback(err)})
function fetchBuild(buildNum, circleToken) {
return fetch(
'https://circleci.com/api/v1.1/project/github/cucumber-ltd/cucumber-pro/' +
buildNum +
'?circle-token=' +
# Install a bunch of tools:
#
# eslint - looks for logical mistakes in the code (unused params etc), *not* formatting
# eslint-config-prettier - overrides default eslint rules to disable formatting rules
# eslint-plugin-prettier - configures `eslint --fix` to format code with prettier
# prettier - prettifies code
# lint-staged - only runs `eslint --fix` on files that have been staged with `git add`
# husky - automatically installs a precommit hook that runs lint-staged
#
yarn add --dev eslint eslint-config-prettier eslint-plugin-prettier prettier lint-staged husky
@aslakhellesoy
aslakhellesoy / gist:b6c3bbc70e447399f5d7e697f83780a6
Last active March 22, 2017 13:37
Replace `import Stream from "stream"` with `const Stream = require('stream')` in JavaScript (Atom)
^import (.*) from ["'](.*)["']$
const $1 = require('$2')
export default
module.exports =
@aslakhellesoy
aslakhellesoy / bumbailiff
Last active February 19, 2021 10:03
You can have a little tech debt for a short time. After that the bumbailiff will be up your bum.
#!/usr/bin/env bash
#
# The bumbailiff allows the team to take up a small amount of technical debt
# (TODOs in the code) for a limited period. After that period the script fails.
#
# Originally written by Aslak Hellesoy
#
set -ef -o pipefail
IFS=$'\n' # make newlines the only separator
Feature: Create Healthcare Study Team user account
The back-office users should be able to create a Healthcare
Study Team user account.
Rules:
- The following fields are mandatory:
- Gender (male, female)
- Last Name
- First Name
# This script sets up (or removes) port forwarding on VirtualBox
# for all ports defined in fig.yml
require 'yaml'
op = ARGV[0]
if op.nil? || !( /(up|down)/ =~ op )
$stderr.puts "Usage:\n ruby #{__FILE__} up|down"
exit 1
end
@main
Feature: Totals
Scenario: Create Total
@teams
Scenario: Create Team Total