Skip to content

Instantly share code, notes, and snippets.

View emorydunn's full-sized avatar

Emory Dunn emorydunn

View GitHub Profile
@chockenberry
chockenberry / finder_icons.sh
Created March 16, 2023 20:00
Script to toggle Finder icons
#!/bin/sh
defaults read com.apple.finder CreateDesktop > /dev/null 2>&1
enabled=$?
if [ "$1" = "off" ]; then
if [ $enabled -eq 1 ]; then
osascript -e 'tell application "Finder" to quit'
defaults write com.apple.finder CreateDesktop false
open -a Finder
@marcprux
marcprux / FormDemoApp.swift
Created February 17, 2021 22:54
Example of aligning labels in SwiftUI.Form on macOS
//
// FormDemoApp.swift
// FormDemo
//
// Created by Marc Prud'hommeaux
//
import SwiftUI
@main
@networkingcat
networkingcat / yet_another_motion_automation.yaml
Last active May 3, 2024 06:20 — forked from quallenbezwinger/motion_controlled_scenes_enhanced.yaml
Homeassistant blueprint for motion-activated light scene
blueprint:
name: Yet Another Motion Automation
description: >
# YAMA V10
Turn on lights or scenes when motion is detected.
Four different scenes can be defined depending on time of day.
@jordansinger
jordansinger / macOS.swift
Last active February 14, 2024 03:41
macOS SwiftUI Playgrounds code
import SwiftUI
import PlaygroundSupport
struct Desktop: View {
var body: some View {
ZStack {
// Image(uiImage: #imageLiteral(resourceName: "IMG_6281.JPG"))
Color(UIColor.systemBlue)
macOS()
}
@stephanecopin
stephanecopin / Publishers+CombineLatestMany.swift
Created February 13, 2020 00:58
An implemention of `CombineLatestMany` for Combine (Swift), which takes takes an array of `Publisher` and return a collection of values, based on their latest value.
import Combine
private protocol LockImplementation {
mutating func lock()
mutating func `try`() -> Bool
mutating func unlock()
}
private struct UnfairLock: LockImplementation {
private var unfairLock = os_unfair_lock_s()
@warpling
warpling / Mento.playground
Last active August 1, 2019 20:11
Copying Tinder's "mentos" button animation (based on tweet: https://twitter.com/warpling/status/930567671015358464?s=20)
//: Playground - noun: a place where people can play
import UIKit
class Mento: UIView {
// The thickness ratio of our mento, 1.0 being a perfect sphere.
let mentoThicknessScale: CGFloat = 0.60
let shape: UIView = {
@jedie
jedie / button_test.py
Last active January 31, 2024 05:32
microPython button irq debouncing
import time
from micropython import const
from machine import Pin, Timer
BUTTON_A_PIN = const(32)
BUTTON_B_PIN = const(33)
class Button:
"""
@trilliwon
trilliwon / uiimage-data.swift
Last active January 12, 2024 14:45
Swift UIImage to Data, Data to UIImage
// Swift4
let image = UIImage(named: "sample")
let data = image?.pngData()
let data = image?.jpegData(compressionQuality: 0.9)
let uiImage: UIImage = UIImage(data: imageData)
// deprecated
// var imageData: Data = UIImagePNGRepresentation(image)
@ariok
ariok / [swift]NSBundle-version-build.swift
Created July 7, 2015 09:40
[swift] Extend NSBundle to get Version and Build info
extension NSBundle {
class var versionNumber: String {
if let version = NSBundle.mainBundle().infoDictionary?["CFBundleShortVersionString"] as? String {
return version
}
return "N.D."
}
class var buildNumber: String {
@mjackson
mjackson / color-conversion-algorithms.js
Last active April 14, 2024 08:46
RGB, HSV, and HSL color conversion algorithms in JavaScript
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param Number r The red color value
* @param Number g The green color value
* @param Number b The blue color value
* @return Array The HSL representation