Skip to content

Instantly share code, notes, and snippets.

View mhaylock's full-sized avatar

Mark Haylock mhaylock

  • abitofthought.com
  • Christchurch, New Zealand
View GitHub Profile
@mhaylock
mhaylock / nock.js
Last active January 17, 2020 10:49
Integrating Nock with Jest
const nock = require('nock')
// Prevent requests being made to any outside services:
nock.disableNetConnect()
// Allow requests through to localhost, which is used by SuperTest to send
// requests during integration tests:
const localhost = '127.0.0.1'
nock.enableNetConnect(localhost)
@mhaylock
mhaylock / feature_spec_artifacts.rb
Created August 29, 2016 04:10
An Spec support file for capturing useful debug artifacts when a feature spec fails (integrates with CircleCI to make those artifacts available for review in the "Artifacts" tab of the build).
# frozen_string_literal: true
# When a feature spec fails it can sometimes be difficult to determine the
# cause, here we hook into RSpec and if a feature spec fails we save the
# following artifacts to disk:
#
# - A copy of the HTML of the currently open page.
# - A screenshot of the currently open page (if the Capybara driver supports
# screenshots).
# - A copy of the segment of log/test.log that was generated for the failing
@mhaylock
mhaylock / no_animations.rb
Last active May 2, 2017 17:08 — forked from keithtom/no_animations.rb
Rack Middleware to disable Disable CSS3/jQuery Animations for Capybara
module Rack
# disable CSS3 and jQuery animations in test mode for speed, consistency and avoiding timing issues.
# Usage for Rails:
# in config/environments/test.rb
# config.middleware.use Rack::NoAnimations
class NoAnimations
def initialize(app, options = {})
@app = app
end
@mhaylock
mhaylock / boost.sh
Last active October 29, 2015 02:58 — forked from faithfracture/boost.sh
Boost build script for iOS (armv7, armv7s, arm64), iOS Simulator (i386, x86_64), and OSX (i386, x86_64)
#===============================================================================
# Filename: boost.sh
# Author: Pete Goodliffe
# Copyright: (c) Copyright 2009 Pete Goodliffe
# Licence: Please feel free to use this, with attribution
# Modified version
#===============================================================================
#
# Builds a Boost framework for iOS, iOS Simulator, and OSX.
# Creates a set of universal libraries that can be used on an iOS and in the
/* This is a FluidApp userscript for Google Inbox for Mac.
Includes options for total badge count and unread badge count.
1) You need the paid version of FluidApp (http://fluidapp.com/)
2) Point Fluid to https://inbox.google.com (I recommend the icon from here: https://medium.com/@chrismessina/create-an-icon-for-google-inbox-in-your-dock-ed269312e3bc)
3) Set the user-agent to Chrome
4) Go to window -> userscript and add click the plus sign under the first table (on the left). Name the item 'Inbox'.
5) In the second table (on the right) click the plus and type in "*inbox.google.com*".
6) Paste the contents of this document into the script area below that.
7) Configure badge count (for total or unread only) in the code below.
@mhaylock
mhaylock / private.xml
Created March 12, 2015 09:50
Karabiner (https://pqrs.org/osx/karabiner/index.html.en) Configuration for remapping "Sculpt Ergonomic Desktop" mouse's Windows button to Mouse Button 4. Derived from http://blog.yorkxin.org/posts/2014/04/12/microsoft-sculpt-mobile-mouse-and-mac/.
<?xml version="1.0"?>
<root>
<devicevendordef>
<vendorname>MICROSOFT</vendorname>
<vendorid>0x045e</vendorid>
</devicevendordef>
<deviceproductdef>
<productname>SCULPT_ERGONOMIC_DESKTOP</productname>
<productid>0x07a5</productid>
@mhaylock
mhaylock / gist:b7b83911d779f4b351da
Last active August 29, 2015 14:02
Cleaning up old branches from a Git repo
# Update local remote refs, and delete all local remote refs that have been
# deleted on Github:
$ git fetch -p
# Switch to a primary branch (i.e. 'api' or 'master'), you will use this branch
# to find all merged branches that you will delete:
$ git checkout api
@mhaylock
mhaylock / gist:8528394
Last active January 3, 2016 22:29
AppleScript to tell Xcode to run app on multiple devices at once. Use here to run on "Example’s iPad" and "iPhone". For some reason Xcode crashes if I try to choose the iOS version in the simulator as well, i.e. `menu_click({"Xcode", "Product", "Destination", "iPhone"})` will work fine, but `menu_click({"Xcode", "Product", "Destination", "iPhone…
---- Handy menu_click code from http://hints.macworld.com/article.php?story=20060921045743404:
-- `menu_click`, by Jacob Rus, September 2006
--
-- Accepts a list of form: `{"Finder", "View", "Arrange By", "Date"}`
-- Execute the specified menu item. In this case, assuming the Finder
-- is the active application, arranging the frontmost folder by date.
on menu_click(mList)
local appName, topMenu, r

foo

  1. index is the 0 based index value of the button pressed

  2. label is the text label of the button pressed

         function showConfirm() {
             var confirmDelegate = navigator.notification.confirm(
                 'You are the winner!',  // message
    

'Game Over', // title

@mhaylock
mhaylock / gist:4727993
Created February 7, 2013 02:46
Instructions for adding Cedar to an existing project. Cedar does exist as a CocoaPods project but that doesn't get you access to the templates, so this approach installs it as a git submodule - YMMV.

Existing project details

This document uses a project named "Example" that has an existing target "ExampleApp". This is the target you will host you tests in.

Adding Cedar as a submodule and installed templates into Xcode:

  $ mkdir Externals
  $ git submodule add git://github.com/pivotal/cedar.git Externals/Cedar
  $ cd Externals/Cedar/; ./installCodeSnippetsAndTemplates; cd -;