Skip to content

Instantly share code, notes, and snippets.

View mkj-is's full-sized avatar
📱
Building iOS apps

Matěj Kašpar Jirásek mkj-is

📱
Building iOS apps
View GitHub Profile
//
// ContentView.swift
// AnimationTimingCurve
//
// Created by Chris Eidhof on 25.09.19.
// Copyright © 2019 Chris Eidhof. All rights reserved.
//
import SwiftUI
import Foundation
import AppKit
import AVFoundation
extension NSImage {
@objc var CGImage: CGImage? {
get {
guard let imageData = self.tiffRepresentation else { return nil }
guard let sourceData = CGImageSourceCreateWithData(imageData as CFData, nil) else { return nil }
return CGImageSourceCreateImageAtIndex(sourceData, 0, nil)
@ole
ole / Mojave-dynamic-wallpaper-notes.md
Last active March 8, 2024 02:17
Reverse-engineering the dynamic wallpaper file format in macOS Mojave.

The dynamic wallpaper in MacOS Mojave is a single 114 MB .heic file that seems to contain 16 embedded images.

It also contains the following binary plist data in its metadata under the key "Solar". It's an array of 16 items, each with four keys:

  • i (integer). This seems to be the image index.
  • o (integer). This is always 1 or 0. Stephen Radford thinks it indicates dark mode (0) vs. light mode (1).
  • a (decimal). I’m pretty sure this is the angle of the sun over the horizon. 0º = sunset/sunrise. 90º = sun directly overhead. Negative values = sun below horizon.
  • z (decimal). This seems to be the cardinal position of the sun relative to the camera. 0º = sun is directly in front of the camera. 90º = sun is directly to the right of the camera. 180º = sun is directly behind the camera.
@zvonicek
zvonicek / ServiceHolder.swift
Last active November 23, 2016 14:27
ServiceHolder
import Foundation
protocol Service {
init()
}
class ServiceHolder {
private var servicesDictionary: [String: Service] = [:]
init(services: [Service.Type]? = nil) {
@zvonicek
zvonicek / truty_filter.rb
Last active August 29, 2015 14:12
Truty filter for Liquid
require 'truty'
module Jekyll
module TrutyFilter
def truty(input)
Truty.fix(input, :czech)
end
end
end
@jemmons
jemmons / top_level.swift
Created November 22, 2014 21:31
`returning` for Swift
func returning<T>(object:T, block:(_:T)->Void)->T{
block(object)
return object
}
@ijoshsmith
ijoshsmith / Array+Shuffle.swift
Last active December 24, 2018 21:55
Randomly shuffle a Swift array
import Foundation
extension Array
{
/** Randomizes the order of an array's elements. */
mutating func shuffle()
{
for _ in 0..<10
{
sort { (_,_) in arc4random() < arc4random() }
@lqi
lqi / gist:5358513
Last active July 29, 2017 14:33 — forked from gavrix/gist:5054182
source ~/.bash_profile
hash oclint &> /dev/null
if [ $? -eq 1 ]; then
echo >&2 "oclint not found, analyzing stopped"
exit 1
fi
cd ${TARGET_TEMP_DIR}