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 / gist:958381
Created May 6, 2011 03:14
Setting up GIT Bash autocompletion

Run the following to create ~/.git-completion.bash:

curl https://raw.github.com/git/git/master/contrib/completion/git-completion.bash > ~/.git-completion.bash

Then add the following to your ~/.bashrc or ~/.bash_profile after PATH:

# Set the base PS1
PS1="\h:\W \u\$ "

Source the git bash completion file

@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 / 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 / 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 / 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: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 -;
@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
@mhaylock
mhaylock / gist:995049
Created May 27, 2011 11:11
nginx config to add Cache-Control header to rails static cache files
location / {
try_files /system/maintenance.html $uri $uri/index.html $uri.html @passenger;
expires 60s;
add_header Cache-Control public;
add_header Vary Accept-Encoding;
}