Skip to content

Instantly share code, notes, and snippets.

View andykent's full-sized avatar

Andy Kent andykent

View GitHub Profile
@gavinmn
gavinmn / KeyboardAttachedView.swift
Created August 20, 2024 02:38
Attach a view to the keyboard with interactive dismissal support
//
// ContentView.Swift
// KeyboardAttachedView
//
// Created by Gavin Nelson on 8/19/24.
//
import SwiftUI
import UIKit
@insidegui
insidegui / devicectl.sh
Created October 19, 2023 21:58
Helper functions for using devicectl to kill processes on connected iOS devices
# Add to your zsh profile
function devicepid() {
if [ -z "$1" ]; then
echo "Usage: devicepid <device-name> <search>"
echo "Example: devicepid 'iPhone 15 Pro Max' SpringBoard"
return 1
fi
if [ -z "$2" ]; then
@Berhtulf
Berhtulf / ci_post_xcodebuild.sh
Last active August 8, 2024 14:34
Xcode Cloud - CI/CD Push tag to Github
# 1. Create 'ci_scripts' folder in your main project directory
# 2. Create 'ci_post_xcodebuild.sh' inside of it
# 3. Make it an executable by running 'chmod +x $ci_post_xcodebuild.sh'
set -e # fails build if any command fails
if [ ${CI_XCODEBUILD_EXIT_CODE} != 0 ]
then
exit 1
fi
@mcrumm
mcrumm / phx_sqlite_fly_launch.md
Last active August 26, 2024 08:44
Phoenix + SQLite Deployment tips

Deploying to Fly.io with SQLite

Deploying a Phoenix app to Fly.io is a breeze...is what everyone kept telling me. In fairness, I imagine the process would have been breezier had I just used postgres, but all the sqlite and litestream talk has been far too intriguing to ignore. "Wait", you say. "It is just a flat file. How much harder can it be?"

It is easy to make something harder than it should be. It is hard to take something complex and make it truly simple. flyctl launch does an amazing job at providing a simple interface to the utterly complex task of generating deployment resources, especially now that we are living in a containerd (erm, firecracker) world.

This gist is for anyone who, like me, thinks they know better than to read all of the documentation and therefore necessari

@behe
behe / app_store_server_notifications_v2_validation.livemd
Created February 14, 2022 07:39
Apple App Store Server Notifications v2 validation

Apple App Store Server Notifications v2 validation

Background

I recently had to upgrade our backend's handling of App Store Server Notifications to the new v2 version. The old version had pretty basic security by only having a supplied password in the response that you verified with what you had configured it to be in App Store Connect. The new version on the other hand is now in JWS (JSON Web Signature) signed with an Apple X.509 certificate chain. Since it was not straight forward to figure out how to verify this certificate chain and signature I wanted to write down how I was able to do it in Elixir:

The following steps are needed to verify the notifications:

@lukaskubanek
lukaskubanek / Bundle+TestFlight.swift
Last active August 23, 2024 05:12
A code snippet for detecting the TestFlight environment for a macOS app at runtime
/// MIT License
///
/// Copyright (c) 2021 Lukas Kubanek, Structured Path GmbH
///
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
@kylehughes
kylehughes / TornRectangle.swift
Last active May 7, 2024 07:17
A rectangle shape for SwiftUI that can render any edge like a torn piece of paper.
// Copyright 2021 Kyle Hughes
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
// Software.
//
@aibo-cora
aibo-cora / Converter.swift
Created July 17, 2021 19:15
Class to convert AVAudioPCMBuffer to CMSampleBuffer.
import Foundation
import AVFoundation
import CoreMedia
class Converter {
static func configureSampleBuffer(pcmBuffer: AVAudioPCMBuffer) -> CMSampleBuffer? {
let audioBufferList = pcmBuffer.mutableAudioBufferList
let asbd = pcmBuffer.format.streamDescription
var sampleBuffer: CMSampleBuffer? = nil
@bpsib
bpsib / BBC-Radio-HLS.m3u
Last active September 21, 2024 20:34 — forked from stengland/BBC-Radio.m3u
BBC Radio Streams
#EXTM3U
#EXTINF:-1,BBC - Radio 1
http://as-hls-ww-live.akamaized.net/pool_904/live/ww/bbc_radio_one/bbc_radio_one.isml/bbc_radio_one-audio%3d96000.norewind.m3u8
#EXTINF:-1,BBC - Radio 1Xtra
http://as-hls-ww-live.akamaized.net/pool_904/live/ww/bbc_1xtra/bbc_1xtra.isml/bbc_1xtra-audio%3d96000.norewind.m3u8
#EXTINF:-1,BBC - Radio 1Dance
http://as-hls-ww-live.akamaized.net/pool_904/live/ww/bbc_radio_one_dance/bbc_radio_one_dance.isml/bbc_radio_one_dance-audio%3d96000.norewind.m3u8
#EXTINF:-1,BBC - Radio 2
http://as-hls-ww-live.akamaized.net/pool_904/live/ww/bbc_radio_two/bbc_radio_two.isml/bbc_radio_two-audio%3d96000.norewind.m3u8
#EXTINF:-1,BBC - Radio 3
@xtabbas
xtabbas / SnapCarousel.swift
Created May 10, 2020 18:13
A carousel that snap items in place build on top of SwiftUI
//
// SnapCarousel.swift
// prototype5
//
// Created by xtabbas on 5/7/20.
// Copyright © 2020 xtadevs. All rights reserved.
//
import SwiftUI