Skip to content

Instantly share code, notes, and snippets.

//
// StreamLogoMarchingAnts.swift
// CustomShapeOutlines
//
// Created by from getstream.io on 12.2.2022.
//
import SwiftUI
struct StreamLogoMarchingAnts: View {
#!/bin/sh
# make sure you have imagemagick installed: brew install imagemagick
# your app_icons.sh file should have the correct permissions: run `chmod 775 app_icons.sh` in your terminal from where you put this file
# put your `my_icon.png` next to this file and run ./app_icons.sh to export your app icons
x=my_icon.png
y=${x%.*}
# delete the export directory so we start clean
@berkcebi
berkcebi / progress-indicator-spinning-color.swift
Created August 23, 2018 00:45
Changing the color of a spinning `NSProgressIndicator` using Core Image filters.
extension NSProgressIndicator {
func set(tintColor: NSColor) {
guard let adjustedTintColor = tintColor.usingColorSpace(.deviceRGB) else {
contentFilters = []
return
}
let tintColorRedComponent = adjustedTintColor.redComponent
import Foundation
import PlaygroundSupport
/// A thread-safe array.
public class SynchronizedArray<Element> {
private let queue = DispatchQueue(label: "io.zamzam.ZamzamKit.SynchronizedArray", attributes: .concurrent)
private var array = [Element]()
public init() { }
@andreacipriani
andreacipriani / Bash.swift
Last active February 15, 2024 12:50
Execute shell/bash commands from Swift
import UIKit
protocol CommandExecuting {
func run(commandName: String, arguments: [String]) throws -> String
}
enum BashError: Error {
case commandNotFound(name: String)
}
@matthewreagan
matthewreagan / controlclick.swift
Last active January 3, 2019 09:16
Fixing control-click vs right-click contextual menus in NSView
override func mouseDown(theEvent: NSEvent)
{
/* Hard-coding this behavior isn't great, and shouldn't be necessary. (It should
be up to OS X to define what a contextual-menu click is/isn't, and we should
only care about vending our NSMenu via `menuForEvent:`). */
let modifierFlags = theEvent.modifierFlags;
if (modifierFlags.contains(.ControlKeyMask))
{
@tempire
tempire / array_modification.swift
Last active December 1, 2020 06:18
swift array modification in loop
// FAILURE
var array = [["name": "glen"]]
for item in array {
item["rank"] = "advanced" // Generates an @lvalue error
}
// Even though array is immutable, it's of type <Array<Dictionary<String,String>>,
// item is assigned by let automatically.
@bojan
bojan / .gitignore
Last active August 8, 2022 07:43
Git ignore file for development on Apple platforms. Covers Xcode, AppCode, SPM, Carthage, CocoaPods, Fastlane, etc.
# --------------------------------
# macOS temporary files
# --------------------------------
.DS_Store
*.lock
*.swp
# --------------------------------
# Xcode
# --------------------------------
@alexrozanski
alexrozanski / gist:972958
Created May 15, 2011 08:00
Reposition Traffic Lights
NSButton *closeButton = [self standardWindowButton:NSWindowCloseButton];
NSView *themeFrame = [closeButton superview];
CGFloat buttonYOrigin = NSMaxY(themeFrame.frame)-34;
//Alter the button frames
NSRect closeFrame = closeButton.frame;
closeFrame.origin.y = buttonYOrigin;
closeButton.frame = closeFrame;