Skip to content

Instantly share code, notes, and snippets.

Michael Brown mluisbrown

Block or report user

Report or block mluisbrown

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
mluisbrown / SwiftUIButtonBugView.swift
Created Sep 22, 2019
Example view that demonstrates bug with Buttons in Lists in SwiftUI
View SwiftUIButtonBugView.swift
import SwiftUI
struct ContentView : View {
var body: some View {
return NavigationView {
VStack {
List {
Section(header: Text("Credentials").font(.body).padding([.top, .bottom])) {
HStack {
mluisbrown / FixBTSound.applescript
Last active Jul 7, 2019
AppleScript to set macOS audio input device to "Internal Microphone"
View FixBTSound.applescript
-- Sets your audio input source to "Internal Microphone"
-- Frequently needed if you use bluetooth headpohones and
-- run the Xcode iOS simulator, which will often set your
-- headphones to be the input device, resulting in a drastic
-- decrease in sound quality, and making it mono
tell application "System Preferences" to activate
tell application "System Preferences"
reveal anchor "input" of pane id ""
end tell
mluisbrown / index.ts
Last active Oct 11, 2017
Simple JSON validation example using RamdaJS and fp-ts with Typescript
View index.ts
import { both, converge, equals as eq, ifElse, not, pipe, toLower, type, keys, curry } from "ramda"
import { Either, left, right, isLeft, isRight, getOrElse } from "fp-ts/lib/Either"
export type Json = string|number|boolean|Date|JsonObject
interface JsonObject {
[x: string]: Json;
interface JsonArray extends Array<Json> { }
mluisbrown / Array2Dict.swift
Last active Dec 14, 2016
Generic Swift function to convert an Array into a Dictionary using a key from each object in the Array
View Array2Dict.swift
func dict<T, U: Hashable>(from array: [T], getKey: (T) -> U) -> [U : T] {
var dict: [U : T] = .init(minimumCapacity: array.count)
array.forEach {
dict[getKey($0)] = $0
return dict
mluisbrown / main.swift
Last active Jul 19, 2016
UTF16 encode and decode
View main.swift
import Foundation
func encodeString(str: String) -> String {
return Array(str.utf16).map {
String(format: "%04x", $0)
}.reduce("") {
return $0 + $1
mluisbrown / main.swift
Created Jul 10, 2016
Swift code to find and count all Circular Primes below 1 million (Project Euler problem 35)
View main.swift
// Circular primes
// Problem 35
// The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime.
// There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97.
// How many circular primes are there below one million?
import Foundation
mluisbrown / AppDelegate.h
Last active Jul 3, 2019
PersistentStack for using Core Data with iCloud sync in iOS 7, adapted from code by Chris Eidhof for #4 ( The most important thing is that you don't have to know whether the user is using iCloud or not, or even has an iCloud account on their device. Core Data now transparently h…
View AppDelegate.h
@import UIKit;
#import "PersistentStack.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
You can’t perform that action at this time.