Skip to content

Instantly share code, notes, and snippets.

View masonmark's full-sized avatar
🕺
totally

Mason masonmark

🕺
totally
View GitHub Profile
@masonmark
masonmark / WastingTimeOnStackOverflowTests.swift
Last active August 5, 2023 03:15
check whether array index is valid in Swift
// WastingTimeOnStackOverflowTests.swift Created by mason on 2016-09-18.
import XCTest
/// Measures performance of two different ways of checking whether an index is valid
/// for a given array (the variable "a" is an array of 1,000,000 unique strings, and
/// "val" is the index to be checked):
///
/// a.indices.contains(val)
/// vs:
@masonmark
masonmark / keybase.md
Created February 9, 2017 03:30
keybase.md

Keybase proof

I hereby claim:

  • I am masonmark on github.
  • I am masonmark (https://keybase.io/masonmark) on keybase.
  • I have a public key ASAwAUdfwTc-kIw-jIMOA2XxzrXxqRPPvylGFYFCrIkxsAo

To claim this, I am signing this object:

@masonmark
masonmark / run_circle_ci.rb
Created April 4, 2017 10:12
A script to trigger a CircleCI 2.0 build without actually committing and pushing to GitHub
#!/usr/bin/env ruby
# This script is for when you are tweaking the .circleci/config.yml file itself, and don't
# want to have to actually push a bunch of changes to the project master repo each
# time you want to test a change to the config. (Using this will also reduce spam from any
# bots that might be watching for git spam, and so on...)
#
# Adapted from: https://discuss.circleci.com/t/efficiently-testing-configuration-file-migrating-to-2-0/11620/2
#
# Assuming a project using GitHub, running this file will trigger CircleCI (2.0 platform) without
@masonmark
masonmark / fuckery.js
Last active April 8, 2017 07:10
chromedriver bug workaround
function clickElementById(id, timesTriedAlready) {
// var elem = element(by.id(id));
// elem.click();
// TRY: https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/2766#issuecomment-191963206
// Mason 2017-04-08
var elem = element(by.id(id));
@masonmark
masonmark / screenshot_example.js
Last active April 13, 2017 13:56
example of a function to take a screenshot from within a Protractor 5 ( / Selenium 3) test case
function takeScreenShot(optionalFileNameFragment) {
return browser.takeScreenshot().then(function (pngData) {
var fragment = '' + (optionalFileNameFragment || "screenshot");
var now = new Date();
var fullName = fragment + "-" + now.toISOString() + ".png";
var fullPath = (process.env.CIRCLE_ARTIFACTS || "/tmp") + "/" + fullName;
var stream = fs.createWriteStream(fullPath);
stream.write(new Buffer(pngData, 'base64'));
stream.end();
@masonmark
masonmark / static-class-method-that-references-subclass-type.swift
Last active September 28, 2019 22:23
One way to let a subclass inherit a method referencing its own type in Swift
// NOTE: this first attempt has been superseded by a slightly better one:
// https://gist.github.com/masonmark/967ec16161d6e0b26e146f32c2f35898
// Mason 2019-09-28: This is one way to allow subclasses to inherit a
// method with a parameter whose type refers to the actual subclass type
// (and not the parent class's type).
//
// One purpose here is to define a base class, that can have various
// subclasses, and enable all of the subclasses to inherit a class method
// named configure(), which creates an instance of the subclass and then
@masonmark
masonmark / static-class-method-that-references-subclass-type-try-2.swift
Created September 28, 2019 22:22
One way to let a subclass inherit a method referencing its own type in Swift (slightly improved)
// Mason 2019-09-29: This is one way to allow subclasses to inherit a
// method with a parameter whose type refers to the actual subclass type
// (and not the parent class's type).
//
// One purpose here is to define a base class, that can have various
// subclasses, and enable all of the subclasses to inherit a class method
// named configure(), which creates an instance of the subclass and then
// configures the instance and its various subclass-specific properties.
//
// The improvements are based on feedback in this thread on the Swift forum:
@masonmark
masonmark / reference-subclass-type-in-inheritied-static-method.ts
Last active September 28, 2019 23:09
How to reference a subclass type in an inheritied static method in TypeScript
/**
* Mason 2019-09-29: This is one way to allow subclasses to inherit a
* method with a parameter whose type refers to the actual subclass type
* (and not the parent class's type).
*
* One purpose here is to define a base class, that can have various
* subclasses, and enable all of the subclasses to inherit a class method
* named configure(), which creates an instance of the subclass and then
* configures the instance and its various subclass-specific properties.
[
"https://twitter.com/masonmark/status/714070652",
"https://twitter.com/masonmark/status/1316546416",
"https://twitter.com/masonmark/status/22150795488",
"https://twitter.com/masonmark/status/22151113217",
"https://twitter.com/masonmark/status/41495917286658048",
"https://twitter.com/masonmark/status/42146325457944576",
"https://twitter.com/masonmark/status/42394383559045121",
"https://twitter.com/masonmark/status/46095265169539073",
"https://twitter.com/masonmark/status/46955542752673792",
<html>
<head>
<meta charset="UTF-8">
<meta name="generator" content="Screenotate 3.0.0">
<title>Honoring Boris Nemtsov on the Seventh Anniversary of his Murder - United States Department of State, 2022-02-28 at 3.40.25 PM</title>
</head>
<body>
<div>
<img height="293.0" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABX4AAAJKCAYAAACbAF1YAAABRGlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8bAxCDDwM5gwiCVmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsgshSo3vkfPFBaL5Ats0jistQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKOA7DkgdjqEvQHEToKwj4DVhAQ5A9k3gGyB5IxEoBmML4BsnSQk8XQkNtReEODxcVcICVMIDnYOMiLgXNJBSWpFCYh2zi+oLMpMzyhRcASGUqqCZ16yno6CkYER0EpQmENUfxYDhyWj2CmEWL4VA4PFCQYG5qkIsSSg37bfZGCQ5EaIqQDDmj+egWFbb0FiUSLcAYzfWIrTjCEeY+QpYmBg/fH//2dZBgb2XQwMf4v+//899///v0uA5gPNO1AIAF+IXqFPFjSiAAAAbGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAAqACAAQAAAABAAAFfqADAAQAAAABAAACSgAAAAC3LyDqAAAACXBIWXMAABYlAAAWJQFJUiTwAABAAElEQVR4Aey9CaBlRXUuvM45d556HphpUAQFFBU1zk