Skip to content

Instantly share code, notes, and snippets.

Avatar
🌱
Developing a new macOS app.

Eivind Lindbråten eivindml

🌱
Developing a new macOS app.
View GitHub Profile
@eivindml
eivindml / FetchedResultsPublisher.swift
Last active Jan 30, 2022 — forked from darrarski/FetchedResultsPublisher.swift
Swift-Combine-CoreData-Fetched-Results-Publisher
View FetchedResultsPublisher.swift
import Combine
import CoreData
public final class FetchedResultsPublisher<ResultType>: Publisher where ResultType: NSFetchRequestResult {
public init(request: NSFetchRequest<ResultType>, context: NSManagedObjectContext) {
self.request = request
self.context = context
}
@eivindml
eivindml / GameDetail.swift
Created Sep 3, 2019
SwiftUI ImageLoader with caching
View GameDetail.swift
let url = URL(string: "https://mist.eivindml.now.sh/static/Artboard.png")!
struct GameDetail: View {
@State var nowDate = Date()
private var refDate: Date {
let formatter = DateFormatter()
formatter.dateFormat = "YYYY-MM-dd HH:mm:ss"
let rDate = formatter.date(from: "20019-10-11 12:12:12")
return rDate!
View keybase.md

Keybase proof

I hereby claim:

  • I am eivindml on github.
  • I am eivindml (https://keybase.io/eivindml) on keybase.
  • I have a public key ASATuy7kGECPbRBUdF1UOy6nCe4mmVqVovReT6olRRAfQAo

To claim this, I am signing this object:

View Article.tsx
import BlockContent from "@sanity/block-content-to-react";
interface ArticleProps {
content: Array<any>;
}
export default function Article(props: ArticleProps) {
return (
<>
<BlockContent
@eivindml
eivindml / favicon.html
Last active Aug 26, 2020
Minimal default list of favicon formats to support.
View favicon.html
<!-- Touch Icons - iOS and Android 2.1+ 180x180 pixels in size. -->
<link rel="apple-touch-icon" href="/path/to/apple-touch-icon.png">
<!-- Firefox, Chrome, Safari, IE 11+ and Opera. 192x192 pixels in size. -->
<link rel="icon" href="/path/to/favicon.png">
<!-- Vector image for Safari pinned tab. Single layer svg with viewBox 0 0 16 16. -->
<link rel="mask-icon" href="website_icon.svg" color="#151714">
View ui.js
let ui = {
setDisplayName: (name) => {
document.getElementById('displayName').innerHTML = name
},
setProfilePicture: (imgBlob) => {
document
.getElementById('profileImg')
.setAttribute('src', URL.createObjectURL(imgBlob))
},
View Wheel.swift
import SwiftUI
struct WheelData {
let strokeWidth: CGFloat
let knobWidth: CGFloat
}
struct WheelView: View {
@State var position: CGSize?
@State var angle: CGFloat = 0
View CoreDataConsoleOutput.txt
CoreData: debug: CoreData+CloudKit: -[PFCloudKitOptionsValidator validateOptions:andStoreOptions:error:](35): Validating options: <NSCloudKitMirroringDelegateOptions: 0x2803fb400> containerIdentifier:iCloud.Minutes ckAssetThresholdBytes:<null> operationMemoryThresholdBytes:<null> useEncryptedStorage:NO automaticallyDownloadFileBackedFutures:NO automaticallyScheduleImportAndExportOperations:YES skipCloudKitSetup:NO preserveLegacyRecordMetadataBehavior:NO useDaemon:YES apsConnectionMachServiceName:<null> containerProvider:<PFCloudKitContainerProvider: 0x282fe90a0> storeMonitorProvider:<PFCloudKitStoreMonitorProvider: 0x282fe9090> metricsClient:<PFCloudKitMetricsClient: 0x282fe9060> metadataPurger:<PFCloudKitMetadataPurger: 0x282fe90b0> scheduler:<null> notificationListener:<null> containerOptions:<null>
storeOptions: {
NSInferMappingModelAutomaticallyOption = 1;
NSMigratePersistentStoresAutomaticallyOption = 1;
NSPersistentCloudKitContainerOptionsKey = "<NSPersistentCloudKitContainerOptions: 0x282dc
View TimerSwiftUI.swift
import SwiftUI
struct GameDetail: View {
@State var nowDate = Date()
private var refDate: Date {
let formatter = DateFormatter()
formatter.dateFormat = "YYYY-MM-dd HH:mm:ss"
let rDate = formatter.date(from: "20019-10-11 12:12:12")
return rDate!
View array-child-binding.swift
import SwiftUI
struct Model {
var title: String
var body: String
}
struct ContentView : View {
@State var models : [Model] = [
Model(title: "First Entry", body: "first body"),