Skip to content

Instantly share code, notes, and snippets.

View shaundon's full-sized avatar

Shaun Donnelly shaundon

View GitHub Profile
@shaundon
shaundon / ImageRendererPoC.swift
Last active June 10, 2022 11:42
Proof of concept of using a SwiftUI `ImageRenderer` with a map, and how it blanks out the map.
import SwiftUI
import MapKit
struct ContentView: View {
@State private var mapRegion = MKCoordinateRegion(
center: CLLocationCoordinate2D(
latitude: 51.5,
longitude: -0.12
),
@shaundon
shaundon / ScreenshotView.swift
Created December 15, 2021 16:03
Proof of concept of code to take a screenshot of a view in SwiftUI.
import SwiftUI
struct ScreenShotView: View {
var body: some View {
GeometryReader { geo in
VStack {
Text("Hello world")
Button("Take screenshot") {
let generatedImage = self.takeScreenshot(
@shaundon
shaundon / InstagramShareView.swift
Created July 6, 2021 11:48
Proof of concept of sharing to Instagram Stories from SwiftUI
import SwiftUI
struct InstagramShareView: View {
var imageToShare: Image {
// An image defined in your app's asset catalogue.
return Image("SomeImage")
}
var body: some View {
/*
Adds an input to bongo.cat so you can preset your own tunes.
*/
(() => {
const simulateKey = (simKey) => {
var instrument = InstrumentPerKeyEnum[simKey.toUpperCase()];
var key = KeyEnum[simKey.toUpperCase()];
if (instrument !== undefined && key !== undefined) {
$.play(instrument, key, true);
import SwiftUI
struct Heading: View {
let title: String
let accessoryView: AnyView?
init(
_ title: String,
accessoryView: AnyView? = nil
) {
import SwiftUI
struct RoundedVStack<Content: View>: View {
let content: Content
init(@ViewBuilder content: () -> Content) {
self.content = content()
}
var body: some View {
import SwiftUI
class MyModel: ObservableObject {
@Published var segmentedControlValue: Int = 0 {
didSet {
self.accumulator += 1
print("segmentedControlValue set to \(self.segmentedControlValue)")
}
}
@Published var accumulator: Int = 0
//
// PageSlide.swift
// personal-best
//
// Created by Shaun Donnelly on 20/06/2020.
// Copyright © 2020 Shaun Donnelly. All rights reserved.
//
import SwiftUI

Bash functions

Some functions I have installed in my ~/.bash_profile to make life easier. Source code

clone

Description

Clone a repo into your projects folder and cd into it.

@shaundon
shaundon / app.js
Created February 1, 2016 10:06
Very simple NodeJS server that returns 500 errors
var express = require('express');
var app = express();
app.get('/', function(req, res) {
res.sendStatus(500);
});
app.listen(6969);