Skip to content

Instantly share code, notes, and snippets.

I'm probably napping

Matt Moriarity mjm

I'm probably napping
View GitHub Profile
mjm / Observables.swift
Created Jul 3, 2020
StateObject vs. ObservableObject
View Observables.swift
// If you run this in a playground in Xcode 12, you can see the difference in behavior in the live view.
import SwiftUI
import PlaygroundSupport
class Counter: ObservableObject {
@Published var count: Int
init(_ initialCount: Int) {
self.count = initialCount
mjm / LinkedText.swift
Created May 21, 2020
Tappable links in SwiftUI Text view
View LinkedText.swift
import SwiftUI
private let linkDetector = try! NSDataDetector(types:
struct LinkColoredText: View {
enum Component {
case text(String)
case link(String, URL)
mjm / ManagedObjectChangesPublisher.swift
Created Nov 3, 2019
Observe changes to a Core Data fetch request with Combine
View ManagedObjectChangesPublisher.swift
import Combine
import CoreData
extension NSManagedObjectContext {
func changesPublisher<Object: NSManagedObject>(for fetchRequest: NSFetchRequest<Object>)
-> ManagedObjectChangesPublisher<Object>
ManagedObjectChangesPublisher(fetchRequest: fetchRequest, context: self)
mjm / main.go
Created Mar 21, 2019
Instant clone a vSphere VM
View main.go
package main
import (
mjm / example-feed.json
Last active Sep 18, 2018
A sample JSON feed for experimenting
View example-feed.json
"version": "",
"title": "My Example Feed",
"home_page_url": "",
"feed_url": "",
"items": [
"id": "3",
"content_html": "<p>This is a test post with an image:</p><img src=\"\">",
"url": ""

Keybase proof

I hereby claim:

  • I am mjm on github.
  • I am mmoriarity ( on keybase.
  • I have a public key ASAUZ6JhJyj8M6SIMQyxH8ZN7Sdj8qGjGMIQbzAnaMZEQAo

To claim this, I am signing this object:

mjm / router_test.js
Created Sep 22, 2015
Independent routers don't isolate their middleware
View router_test.js
var express = require('express');
var app = express();
var router1 = express.Router();
router1.use(function (req, res, next) {
console.log('router1 middleware called.');
router1.get('/1', function (req, res) {
View ordered_log.js
function deansi(log) {
var ansi, text;
log = log.replace(/\r\r/g, '\r').replace(/\033\[K\r/g, '\r').replace(/\[2K/g, '').replace(/\033\(B/g, '').replace(/\033\[\d+G/g, '');
ansi = ansiparse(log);
text = '';
ansi.forEach(function(part) {
var classes = [];
part.foreground && classes.push(part.foreground);
part.background && classes.push('bg-' + part.background);
part.bold && classes.push('bold');
mjm / gist:6652482
Created Sep 21, 2013
Letting AFURLConnectionOperation handle SSL requests.
View gist:6652482
[operation setWillSendRequestForAuthenticationChallengeBlock:^(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge) {
[[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge];
View gist:58316
(in-package :hax0r.fork)
(defgame fork-game
(:start-in mansion-foyer)
(:welcome "=== FORK: the cool person's game ===")
(defloc mansion-foyer "a creepy mansion foyer"
(door west other-room))
(defloc other-room "a room inside the creepy mansion"