This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
Task<Void,Never> { | |
do { | |
if let url = URL(string: "http://localhost:22") { | |
let (_, response) = try await URLSession.shared.data(from: url) | |
if let response = response as? HTTPURLResponse { | |
print(response.statusCode) | |
} | |
else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let okString = "WTF\r\nHELLO" | |
let wtfString = AttributedString(okString) | |
if let lineRange = okString.range(of: "\n") { | |
let lineSubstring = okString[okString.startIndex..<lineRange.lowerBound] | |
type(of: lineSubstring) | |
lineSubstring.count | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# usage: | |
# ql /tmp/file.jpg | |
# cat /tmp/file.jpg | ql | |
# cal -h | ql | |
if [ -z "$*" ]; then | |
cat > /tmp/ql.stdin | |
mime_type=$(file --brief --mime-type /tmp/ql.stdin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import Foundation | |
// NOTE: This playground shows how to use Swift's AttributedString with Markdown. | |
// | |
// This code was used to display Markdown content in the Tot iOS Widget <https://tot.rocks> | |
// MARK: - Helpful Links | |
// NOTE: The following links helped me figure this stuff out. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Add this code to a new file in Script Editor | |
2) Export the script as "Application" and make sure it's code signed | |
3) Put "Startup.app" in the root folder of the test website (e.g. where index.html is located) | |
4) Make sure that "Startup.app" has Full Disk Access in System Preferences > Security & Privacy > Privacy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "Terminal" | |
set ws to windows | |
if (true) then -- set to false to see current window positions | |
set c to 80 | |
set ps to {{4215, 27}, {3629, 27}, {3043, 27}, {3043, 734}, {2457, 734}, {3629, 734}, {4215, 734}} | |
set r to 48 | |
set ix to 1 | |
repeat with p in ps | |
set w to item ix of ws |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ -z "$1" ]; then | |
echo "usage: $0 <package_name>" | |
echo "" | |
echo "<package_name> is the Name under Archives in the Organizer" | |
exit | |
fi | |
app=$1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let srcRowBytes = workingBuffer.buffer.rowBytes | |
let srcData: UnsafeMutablePointer<Pixel_8> = workingBuffer.buffer.data!.assumingMemoryBound(to: Pixel_8.self) | |
let srcIndex = y * srcRowBytes + x * workingBuffer.bytesPerPixel | |
var srcPointer = srcData[srcIndex] | |
withUnsafeMutablePointer(to: &srcPointer) { srcPointer in | |
// srcPointer is (UnsafeMutablePointer<Pixel_8>) | |
var srcBuffer = vImage_Buffer(data: srcPointer, height: vImagePixelCount(h), width: vImagePixelCount(w), rowBytes: srcRowBytes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Braccio:~ craig$ brew install mtr | |
==> Tapping homebrew/core | |
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'... | |
remote: Enumerating objects: 52, done. | |
remote: Counting objects: 100% (52/52), done. | |
remote: Compressing objects: 100% (28/28), done. | |
remote: Total 742888 (delta 29), reused 42 (delta 24), pack-reused 742836 | |
Receiving objects: 100% (742888/742888), 299.21 MiB | 3.00 MiB/s, done. | |
Resolving deltas: 100% (492001/492001), done. | |
Error: Invalid formula: /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/step.rb |