Skip to content

Instantly share code, notes, and snippets.

@purpleblues
purpleblues / main.m
Created February 26, 2025 08:01 — forked from larussverris/main.m
Creating an aggregate device using Core Audio in Objective-C
#import <Foundation/Foundation.h>
#import <CoreAudio/CoreAudio.h>
#import "utilities.h"
/*
This example demonstrates how to create an aggregate device using Core Audio in Objective-C.
It creates an aggregate device with two sub-devices, which are the default input and output devices.
*/
int main(int argc, const char * argv[]) {
@purpleblues
purpleblues / README.md
Created July 27, 2022 09:12 — forked from IsaacXen/README.md
(Almost) Every WWDC videos download links for aria2c.
// Similar to defer in Swift
#define pspdf_defer_block_name_with_prefix(prefix, suffix) prefix ## suffix
#define pspdf_defer_block_name(suffix) pspdf_defer_block_name_with_prefix(pspdf_defer_, suffix)
#define pspdf_defer __strong void(^pspdf_defer_block_name(__LINE__))(void) __attribute__((cleanup(pspdf_defer_cleanup_block), unused)) = ^
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-function"
static void pspdf_defer_cleanup_block(__strong void(^*block)(void)) {
(*block)();
}
#pragma clang diagnostic pop
@purpleblues
purpleblues / View.swift
Created April 4, 2021 14:44 — forked from steipete/View.swift
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)
}
}
}
@purpleblues
purpleblues / CPBitmap.swift
Created January 17, 2021 15:51
Parse cpbitmap file and make image
import Foundation
import CoreImage
struct CPBitmap {
var data: Data
var bitmapRange: Data.Indices {
data.startIndex ..< (data.endIndex - 24)
}
@purpleblues
purpleblues / Content.swift
Created October 22, 2020 13:39
Converting SwiftUI View to Image in Playground
/*
Paste it to Xcode Playground
*/
import SwiftUI
import PlaygroundSupport
extension NSView {
func cachedImageRepresentation() -> NSBitmapImageRep {
@purpleblues
purpleblues / ContentView.swift
Last active October 5, 2020 06:55
SwiftUI Gestures Example
//
// ContentView.swift
// GestureTest
//
// Created by 김성민 on 2020/10/05.
//
import SwiftUI
@purpleblues
purpleblues / brew-checkleaves.py
Last active February 3, 2020 12:54
Show Homebrew formulars that no other formulars are dependent on.
#!/usr/bin/python3
import subprocess
brew_commands = subprocess.check_output(["brew", "ls"]).splitlines()
result = [ command.decode('utf8') for command in brew_commands
if len(subprocess.check_output(["brew", "uses", "--installed", command]).split()) == 0 ]
print(*result)
@purpleblues
purpleblues / tensorflow_keras_gpu_problem_solution.py
Last active January 4, 2020 08:41
Tensorflow & Keras GPU problem solutions
### for Tensorflow 2.0
import tensorflow as tf
physical_devices = tf.config.experimental.list_physical_devices('GPU')
assert len(physical_devices) > 0, "Not enough GPU hardware devices available"
tf.config.experimental.set_memory_growth(physical_devices[0], True)
@purpleblues
purpleblues / FillingZip.swift
Created September 3, 2018 12:33
zip with sequences with different lengths
struct FillingZip<Sequence1: Sequence, Sequence2: Sequence>: Sequence {
private let sequence1: Sequence1
private let sequence2: Sequence2
init(_ sequence1: Sequence1, _ sequence2: Sequence2) {
self.sequence1 = sequence1
self.sequence2 = sequence2
}