Skip to content

Instantly share code, notes, and snippets.

@unuigbee
unuigbee / js
Last active September 12, 2016 13:25
Setting new array of document references when updating a document
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 }
@unuigbee
unuigbee / README.md
Created September 26, 2016 20:32 — forked from addyosmani/README.md
108 byte CSS Layout Debugger

CSS Layout Debugger

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

@unuigbee
unuigbee / ImageDarkness.swift
Created September 14, 2021 17:11 — forked from adamcichy/ImageDarkness.swift
Determine if a UIImage is generally dark or generally light in Swift 3
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]
@unuigbee
unuigbee / LoopingAnimationView.swift
Last active July 1, 2024 15:27
Looping GLTransitions in SwiftUI using MagicKit
// https://github.com/mrcreatoor/MagicKit
import MagicKit
import SwiftUI
import Combine
// MARK: Implementation
public struct LoopingAnimationView<Content: View>: View {
private let animatableViews: [Content]