Skip to content

Instantly share code, notes, and snippets.

@kylehowells
kylehowells / max_size.swift
Created July 9, 2020 03:03
Get the maximum supported Metal texture size for the current device on iOS or macOS.
import SceneKit
import CoreGraphics
static func getMaxImageWidth() -> Int {
let device = MTLCreateSystemDefaultDevice()!
// According to the Metal Feature Set Tables there are only two supported maximum resolutions
// 16384px for macs and the latest iOS devices
// 8192px for the older iOS devices
// Older Apple devices used to be limited to 4,096, 2,048 or even 1,024, but are no longer supported
You are an excellent, logical, programmer. You are currently acting as my programming assistant.
Please keep the initial response short and to the point.
If a more lengthy reply and more details are needed it will be asked for.
- Follow the user's requirements carefully & to the letter.
- First think step-by-step.
- Briefly describe your plan for what to build in psuedocode, written out in detail.
- Then output the code in a single codeblock.
- Minimize any other prose and try to answer concisely, while still fully answering the request.
@kylehowells
kylehowells / gist:36b6f7e3f584590d0943
Created December 4, 2014 01:18
MRMediaRemoteGetNowPlayingInfo Keys
MRMediaRemoteGetNowPlayingInfo(dispatch_get_main_queue(), ^(CFDictionaryRef information) {});
/* [information allKeys]
(
kMRMediaRemoteNowPlayingInfoTotalDiscCount,
kMRMediaRemoteNowPlayingInfoShuffleMode,
kMRMediaRemoteNowPlayingInfoTrackNumber,
kMRMediaRemoteNowPlayingInfoDuration,
kMRMediaRemoteNowPlayingInfoRepeatMode,
kMRMediaRemoteNowPlayingInfoTitle,
//
// TappableUILabelDemoViewController.swift
// Label Link Test
//
// Created by Kyle Howells on 2024-03-20.
//
import UIKit
@kylehowells
kylehowells / Tap links in UILabel.swift
Created March 20, 2024 01:24
Tap Links in UILabel
@kylehowells
kylehowells / Speedo.swift
Created June 28, 2020 17:37
Scifi Style Speedometer Concept in SwiftUI
import SwiftUI
struct ContentView: View {
let backgroundGradient = Gradient(colors: [
Color(red: 65.0/255.0, green: 65.0/255.0, blue: 84.0/255.0, opacity: 1.0),
Color(red: 20.0/255.0, green: 20.0/255.0, blue: 24.0/255.0, opacity: 1.0)
])
let blueGradient = Gradient(colors: [

Getting a streamable link is done by the client.

You basically need to send the service a detailed list of the type of media you can play, and it will give you a transcode URL to call if it thinks you need transcoding in order to play this file.

If you don't and can play the file directly it won't give you a transcode URL.

POST <server_address>/Items/<item_id>/PlaybackInfo?UserId=<current_user_id>
@kylehowells
kylehowells / correct_dates.py
Created February 14, 2020 21:18
Automatically Corrects Insta360 Studio Snapshot Dates according to the filename.
import os
import re
import datetime
import piexif
filepath = os.path.abspath(".")
# Find files with `screenshot` in the name.
files = [f for f in os.listdir(filepath) if "screenshot" in f and f.endswith(".jpg")]
print(files)
@kylehowells
kylehowells / gist:8625390
Last active November 26, 2023 05:51
Pseudo code for creating a notification on iOS 7 in SpringBoard
//SBBulletinBannerController
-(BBBulletinRequest*)showTestBanner:(NSString*)something {
//r14 = self
//r15 = something
static NSInteger testCount = 0;
BBBulletinRequest *request = [[BBBulletinRequest alloc] init];
[request setBulletinID:something];
[request setTitle:something];
[request setMessage:[NSString stringWithFormat:@"Fake iTunes notification %ld", testCount]];
@kylehowells
kylehowells / FileWatcher.cs
Created May 9, 2019 13:06
Monitor iOS files for changes using GCD dispatch_source_create DISPATCH_SOURCE_TYPE_VNODE in Xamarin
using System;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
using System.IO;
namespace LoadRuntimeXAML.iOS
{
public class FileWatcher : IDisposable
{