Skip to content

Instantly share code, notes, and snippets.

View sidwood's full-sized avatar

Sid Wood sidwood

  • Upsurance Ltd
  • London, UK
View GitHub Profile
@sidwood
sidwood / Dockerfile
Last active June 3, 2019 07:16
Node.js Dockerfile example
FROM node:10.16-alpine
WORKDIR /opt/app
ARG NODE_ENV=production
ARG NODE_PATH=./lib
ARG NPM_TOKEN
ARG REVISION
ARG VERSION
@sidwood
sidwood / package.json
Created December 11, 2018 12:39
Testing Moleculer services with event interfaces
{
"name": "moleculer-event-testing",
"version": "0.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest --watch some-process.service.spec.js"
},
"keywords": [],
"author": "Sid Wood",
@sidwood
sidwood / Dockerfile
Last active September 26, 2017 04:39
Node.js dockerfile templates
FROM node:7.10-alpine
RUN mkdir -p /opt/app
WORKDIR /opt/app
COPY ./package.json /opt/app
RUN apk add --update --no-cache tini &&\
apk add --virtual .build-dependencies make gcc g++ python &&\
npm install --production &&\
@sidwood
sidwood / selenium.sh
Created September 1, 2014 10:45
A selenium server management script for node.js projects. Dug this relic up and updated line #7 so that it can act as a replacement for protractor's currently broken `webdriver-manager update`. Just pop this in your ./bin folder, make it executable, and run `./bin/selenium.sh install`. Jobs a good’un.
#!/usr/bin/env bash
#
# Constants
#
# DOWNLOAD_PATH=vendor/selenium
DOWNLOAD_PATH=node_modules/protractor/selenium
CD_VERSION=2.10
@sidwood
sidwood / products.test.js
Created July 2, 2014 09:46
Hapi plugin test that illustrates plugins containing route definitions with array values for the method will fail when the plugin is registered to more than one server instance.
// plugins/products-api/test/products.test.js
'use strict';
var Lab = require('lab');
var Hapi = require('hapi');
var productsApi = require('../index');
var dataStore = require('../../store');
@sidwood
sidwood / matchers.js
Created June 7, 2013 16:55
An example of asserting that a test double is implementing it's role/interface correctly in AngularJS test suites suing Jasmine. http://www.meetup.com/AngularJS-London/events/106468592/
// client/test/support/matchers.js
beforeEach(function() {
this.addMatchers({
toRespondTo: function(method) {
return void 0 !== this.actual[method];
}
});
});
@sidwood
sidwood / countries.rb
Created January 21, 2012 14:33
Country Codes (ISO 3166-1 alpha-2 subset)
# ISO 3166-1 alpha-2 subset
# Removed the following
# - BV: Bouvet Island (uninhabited)
# - IO: British Indian Ocean Territory (no civilian population)
# - TF: French Southern Territories (no permanent population)
# - HM: Heard Island and McDonald Islands (uninhabited)
# config/initializers/countries.rb
COUNTRIES = {
@sidwood
sidwood / cucumber_support_code_example.rb
Created January 16, 2012 14:13
Quick example of cucumber support code
# features/step_definitions/search_steps.rb
When /^I search for "([^"]*)"$/ do |search_term|
search_catalogue_with search_term, :using_direct_model_access
end
# features/support/search_support.rb
module SearchSupport
class SearchAutomator
@sidwood
sidwood / gist:1070580
Created July 7, 2011 21:27
Ruby Style Guide
= Dan Kubb's Ruby Style Guide
You may not like all rules presented here, but they work very well for
me and have helped producing high quality code. Everyone is free to
code however they want, write and follow their own style guides, but
when you contribute to my code, please follow these rules:
== Formatting:
@sidwood
sidwood / sinatra_cms.rb
Created December 10, 2010 12:23
Micro CMS Concept
%w{rubygems sinatra haml sass dm-core}.each {|lib| require lib}
configure :production, :staging do
require 'dm-postgres-adapter' # for heroku
end
configure :development do
DataMapper.auto_upgrade!
end