A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.
One-line version to paste in your DevTools
Use $$ if your browser aliases it:
~ 108 byte version
| // https://github.com/mrcreatoor/MagicKit | |
| import MagicKit | |
| import SwiftUI | |
| import Combine | |
| // MARK: Implementation | |
| public struct LoopingAnimationView<Content: View>: View { | |
| private let animatableViews: [Content] |
| extension CGImage { | |
| var isDark: Bool { | |
| get { | |
| guard let imageData = self.dataProvider?.data else { return false } | |
| guard let ptr = CFDataGetBytePtr(imageData) else { return false } | |
| let length = CFDataGetLength(imageData) | |
| let threshold = Int(Double(self.width * self.height) * 0.45) | |
| var darkPixels = 0 | |
| for i in stride(from: 0, to: length, by: 4) { | |
| let r = ptr[i] |
| Lets say I had this schema: | |
| const userCommandSchema = mongo.Schema({ | |
| objectID: mongo.Schema.ObjectId, | |
| userID: { type: String, required: true }, | |
| command: { type: String, required: true }, | |
| summary: { type: String }, | |
| isFavourite: { type: Boolean, default: false }, | |
| }, | |
| { timestamps: true } |