Skip to content

Instantly share code, notes, and snippets.

View danimal's full-sized avatar

Dan Bostonweeks danimal

View GitHub Profile
@nunosans
nunosans / robots.txt
Last active June 23, 2024 19:23
Robots TXT file to disallow AI crawlers
# Disallow the Amazon AI bot.
User-agent: Amazonbot
Disallow: /
# Disallow the Anthropic AI bot.
User-agent: anthropic-ai
Disallow: /
# Disallow the Apple Intelligence bot.
User-Agent: Applebot
@steipete
steipete / View.swift
Created April 4, 2021 13:43
Accept dropping a file onto SwiftUI (both iOS and macOS)
.onDrop(of: [.fileURL], isTargeted: nil) { providers in
if let loadableProvider = providers.first(where: { $0.canLoadObject(ofClass: URL.self) }) {
_ = loadableProvider.loadObject(ofClass: URL.self) { fileURL, _ in
if let fileURL = fileURL, fileURL.pathExtension.lowercased() == "zip" {
self.logger.info("Dropped \(fileURL.path)")
DispatchQueue.main.async {
importer.open(zipArchiveURL: fileURL)
}
}
}
#! /bin/bash
# Information came from https://apple.stackexchange.com/questions/358651/unable-to-completely-uninstall-zoom-meeting-app
# I just added more stuff to delete so there is no manual stuff to execute.
echo Zoom cleanup 🧹
echo Cleaning Application Cached Files...
sudo rm -rf ~/Library/Application\ Support/zoom.us
sudo rm -fr ~/Library/Application\ Support/ZoomPresence
echo Cleaning Application...
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active September 6, 2024 18:49
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@eminarcissus
eminarcissus / libjpeg.sh
Last active March 20, 2023 19:30 — forked from dulacp/libjpeg.sh
Download & Compile Libjpeg for iOS (all architectures)
# Builds a Libjpeg framework for the iPhone and the iPhone Simulator.
# Creates a set of universal libraries that can be used on an iPhone and in the
# iPhone simulator. Then creates a pseudo-framework to make using libjpeg in Xcode
# less painful.
#
# To configure the script, define:
# IPHONE_SDKVERSION: iPhone SDK version (e.g. 8.1)
#
# Then go get the source tar.bz of the libjpeg you want to build, shove it in the
# same directory as this script, and run "./libjpeg.sh". Grab a cuppa. And voila.
@patr1ck
patr1ck / KeyboardListener.swift
Last active February 21, 2018 22:55
A simple extension for handling keyboard shows/hides
//
// KeyboardListener.swift
//
// Created by Patrick B. Gibson on 7/16/16.
//
import UIKit
protocol KeyboardListener: AnyObject {
var view: UIView! { get }
@chockenberry
chockenberry / finder_icons.sh
Last active February 10, 2024 19:05
A simple shell script to turn the Finders desktop icons on and off
#!/bin/sh
defaults read com.apple.finder CreateDesktop > /dev/null 2>&1
enabled=$?
if [ "$1" = "off" ]; then
if [ $enabled -eq 1 ]; then
defaults write com.apple.finder CreateDesktop false
osascript -e 'tell application "Finder" to quit'
open -a Finder
@commanda
commanda / del
Last active May 18, 2016 01:02
A bash script that moves the given file or directory into the Trash.
#!/bin/sh
TRASH="$HOME/.Trash/";
args=("$@");
for f in $args; do
base=$(basename $f);
if [ -e "$TRASH$base" ] ; then
TS=`date`;
@asmallteapot
asmallteapot / 01-usage.swift
Last active March 7, 2019 01:55
An attempt at making UITableView cell reuse a bit more idiomatic in Swift.
@objc class ExampleTableCell: UITableViewCell, ReuseableObject, NibLoadable {}
@objc class ExampleViewController: UITableViewController {
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override init(style: UITableViewStyle) {
@nickv2002
nickv2002 / YouTubePlayerViaTVJS.swift
Last active October 21, 2021 06:19
Swift code to play YouTube videos on AppleTV tvOS via a TVJS call using XCDYouTubeKit
//
// Created by Nick Vance on 12/4/15.
// Copyright © 2015 ToWatchList. All rights reserved.
//
import AVKit
import XCDYouTubeKit
import TVMLKit
class YTPlayerViewController: AVPlayerViewController, AVPlayerViewControllerDelegate {