Skip to content

Instantly share code, notes, and snippets.

View crmitchelmore's full-sized avatar
☀️

Chris Mitchelmore crmitchelmore

☀️
View GitHub Profile
function allocateMemory(size) {
// Simulate allocation of bytes
const numbers = size / 8;
const arr = [];
arr.length = numbers;
for (let i = 0; i < numbers; i++) {
arr[i] = i;
}
return arr;
}
@crmitchelmore
crmitchelmore / update-origins.sh
Last active October 21, 2020 11:21
To update your origins to https
# Get a personal access token from github and enable SSO for it.
# Change in to the directory containing your repos
# cd /path/to/your/repo/dir
# git clone https://gist.github.com/crmitchelmore/72888315549fe33119a60e739e6ff5da
# mv 72888315549fe33119a60e739e6ff5da/update-origins.sh .
# rm -rf 72888315549fe33119a60e739e6ff5da
# chmod +x update-origins.sh
# GH_PAT=PASTyourPAThere ./update-origins.sh
# Wait :)
@crmitchelmore
crmitchelmore / model_splliter.swift
Last active November 17, 2017 17:51
Split model structs, enum, classes, extensions from 1 file to 1 per type. Types should be codable or regex will need changing
import Foundation
import PlaygroundSupport
let documentsDir = PlaygroundSupport.playgroundSharedDataDirectory
let fileManager = FileManager()
extension String {
subscript (bounds: CountableClosedRange<Int>) -> String {
let start = index(startIndex, offsetBy: bounds.lowerBound)
let end = index(startIndex, offsetBy: bounds.upperBound)
return String(self[start...end])
@crmitchelmore
crmitchelmore / ArrayExtension
Last active May 20, 2016 09:31
Converting strings in to arrays
import Foundation
extension Array: StringLiteralConvertible {
init(string: String) {
self.init()
appendContentsOf(string.componentsSeparatedByString(",").flatMap {
switch Element.self {
case is Int.Type:
return Int($0) as? Element
case is Double.Type, is Float.Type:
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = "calabash-cucumber"
s.version = "0.9.165"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Karl Krukow"]
s.date = "2014-01-20"
s.description = "calabash-cucumber drives tests for native iOS apps. You must link your app with calabash-ios-server framework to execute tests."
irb(main):002:0> keyboard_enter_text "\b"
Sending UIA command
uia.typeString(', '0.11')
Result
{"status"=>"error", "value"=>"VerboseError: Unable to type: \b", "backtrace"=>"fail__delegate@file:///Users/cmitchelmore/work/barpass/barpass-iphone-v2/8709A6E6-9D19-4F5B-83BE-F7FAB62B16D9/calabash_script_uia.js:20854:28\nfail@file:///Users/cmitchelmore/work/barpass/barpass-iphone-v2/8709A6E6-9D19-4F5B-83BE-F7FAB62B16D9/calabash_script_uia.js:20861:31\nfile:///Users/cmitchelmore/work/barpass/barpass-iphone-v2/8709A6E6-9D19-4F5B-83BE-F7FAB62B16D9/calabash_script_uia.js:21352:38\nfile:///Users/cmitchelmore/work/barpass/barpass-iphone-v2/8709A6E6-9D19-4F5B-83BE-F7FAB62B16D9/calabash_script_uia.js:11579:38\nlazy_seq_value@file:///Users/cmitchelmore/work/barpass/barpass-iphone-v2/8709A6E6-9D19-4F5B-83BE-F7FAB62B16D9/calabash_script_uia.js:8173:24\ncljs$core$ISeq$_first$arity$1@file:///Users/cmitchelmore/work/barpass/barpass-iphone-v2/8709A6E6-9D19-4F5B-83BE-F7FAB62B16D9/calabash_script_uia.js:8224:66\n_first@file:///User
irb(main):006:0> query("tableViewCell descendant view {text LIKE 'Stella Artois Bottle '}")
[
[0] {
"class" => "BPLabel",
"id" => nil,
"rect" => {
"center_x" => 178,
"y" => 80,
"width" => 244,
"x" => 56,
[10:38:57]chrismbp barpass-iphone-v2/ [calabash2]$ DEBUG=1 CALABASH_FULL_CONSOLE_OUTPUT=1 calabash-ios console
Running irb...
irb(main):001:0> start_test_server_in_background
......
irb(main):002:0> query("tableViewCell {text LIKE 'Stella Artois Bottle '}")
[]
irb(main):003:0> swipe("left", {:query => "tableViewCell {text LIKE 'Stella Artois Bottle '"})
Sending UIA command
uia.swipeOffset('{:x 160, :y 97}', '{:query "tableViewCell {text LIKE \'Stella Artois Bottle \'", :direction :left}')
Result
#import "UIBarButtonItem+BPAccessibilityIdentifier.h"
#import <objc/runtime.h>
@implementation UIBarButtonItem (BPAccessibilityIdentifier)
static void * BPBarButtonAccessibilityIdentifier = &BPBarButtonAccessibilityIdentifier;