Skip to content

Instantly share code, notes, and snippets.

View marcuswestin's full-sized avatar

Marcus Westin marcuswestin

  • New York
View GitHub Profile
@marcuswestin
marcuswestin / gist:5267401
Last active August 18, 2023 23:00
Setup a new machine
SETUP NEW MAC
=============
Use https://github.com/marcuswestin/machine
@marcuswestin
marcuswestin / import-and-merge-repos-into-monorepo-with-full-history.sh
Created February 4, 2023 04:57
Import multiple repos into a single mono repo, into custom subfolder paths, while maintaining full commit history for all repos
#!/bin/bash
#
# Create a new monorepo by fusing multiple repositories.
#
# Exit immediately if a command exits with a non-zero status,
# and print commands and their arguments as they are executed.
set -ex
# Set the name of the org, and the monorepo to create
GITHUB_ORG="github-org-or-account"
@marcuswestin
marcuswestin / git-checkout-force.sh
Created February 6, 2015 16:59
Git checkout --force (checkout, or create if it doesn't exist)
(git show-branch foo1 &>/dev/null) && (git checkout foo1) || (git checkout -b foo1)
@marcuswestin
marcuswestin / generate-iOS-app-icons.sh
Created October 9, 2013 20:09
Generate all xcode 5 app icon sizes from one original large icon
mkdir -p generated
sips -Z 29 --out generated/iPhoneSettings-29x29.png sourceIcon.png
sips -Z 58 --out generated/iPhoneSettings-29x29@2x.png sourceIcon.png
sips -Z 80 --out generated/iPhoneSpotlight-40x40@2x.png sourceIcon.png
sips -Z 120 --out generated/iPhoneApp-60x60@2x.png sourceIcon.png
sips -Z 29 --out generated/iPadSettings-29x29.png sourceIcon.png
sips -Z 58 --out generated/iPadSettings-29x29@2x.png sourceIcon.png
sips -Z 40 --out generated/iPadSpotlight-40x40.png sourceIcon.png
@marcuswestin
marcuswestin / SwiftUI WrapView handler approach.swift
Last active September 25, 2021 20:03
An approach for simplified wrapping of AppKit and UIKit views in SwiftUI
import SwiftUI
#if os(macOS)
typealias OSView = NSView
typealias OSViewRepresentable = NSViewRepresentable
#elseif os(iOS)
typealias OSView = UIView
typealias OSViewRepresentable = UIViewRepresentable
#endif
@marcuswestin
marcuswestin / demo.ts
Last active September 20, 2021 16:21
Example of content-based code-folding that has a rendering bug
import {EditorState, EditorView, basicSetup} from "@codemirror/basic-setup"
import { foldEffect } from "@codemirror/fold";
import { Line } from "@codemirror/text";
import { Decoration, DecorationSet, PluginValue, ViewPlugin, ViewUpdate, WidgetType } from "@codemirror/view";
let doc = `
Test list 1
- Test item
- Test item
@marcuswestin
marcuswestin / demo.ts
Created September 20, 2021 16:21
Example of content-based code-folding that works
import {EditorState, EditorView, basicSetup} from "@codemirror/basic-setup"
import { StateField } from "@codemirror/state";
import { Line } from "@codemirror/text";
import { Decoration, DecorationSet, WidgetType } from "@codemirror/view";
let doc = `
Test list 1
- Test item
- Test item
@marcuswestin
marcuswestin / gist:4497062
Created January 9, 2013 21:20
Remove the "next/prev/done" bar from UIWebView keyboards.
- (void)keyboardWillShow:(NSNotification *)notification {
[self performSelector:@selector(removeWebViewKeyboardBar) withObject:nil afterDelay:0];
}
- (void)removeWebViewKeyboardBar {
UIWindow *keyboardWindow = nil;
for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) {
if (![[testWindow class] isEqual:[UIWindow class]]) {
keyboardWindow = testWindow;
break;
@marcuswestin
marcuswestin / SwiftUI WrappableViewController.swift
Created January 25, 2020 19:37
An approach for simplified wrapping of AppKit and UIKit view controllers in SwiftUI
//
// WrappableViewController.swift
// macOS-Wordflower
//
// Created by Marcus Westin on 1/24/20.
// Copyright © 2020 Marcus Westin. All rights reserved.
//
// My preferred approach to wrapping AppKit and UIKit viewControllers in SwiftUI
@marcuswestin
marcuswestin / SwiftUI WrappableView.swift
Last active January 25, 2020 15:38
Another approach for simplified wrapping of AppKit and UIKit views in SwiftUI.
//
// WrappableView.swift
// macOS-Wordflower
//
// Created by Marcus Westin on 1/24/20.
// Copyright © 2020 Marcus Westin. All rights reserved.
//
// My preferred approach to wrapping AppKit and UIKit views in SwiftUI