Skip to content

Instantly share code, notes, and snippets.

@alexpersian
alexpersian / LoopingVideoPlayer.swift
Last active June 5, 2017 15:33
Implementation of a looping video player using AVPlayerQueue
import AVFoundation
struct Video {
let path: URL
let title: String
}
final class LoopingVideoPlayer: AVQueuePlayer {
private let videos: [Video]
@alexpersian
alexpersian / bee-movie-password-generator
Created August 31, 2017 14:58
Create ultra-secure passwords from Jerry Seinfeld's magnum opus
$beeMovieScript = "beemoviescriptaccordingtoallknownlawsofaviationthereisnowayabeeshouldbeabletoflyitswingsaretoosmalltogetitsfatlittlebodyoffthegroundthebeeofcoursefliesanywaybecausebeesdontcarewhathumansthinkisimpossibleyellowblackyellowblackyellowblackyellowblackoohblackandyellowletsshakeitupalittlebarrybreakfastisreadyoominghangonasecondhellobarryadamoanyoubelievethisishappeningicantillpickyouuplookingsharpusethestairsyourfatherpaidgoodmoneyforthosesorryimexcitedheresthegraduatewereveryproudofyousonaperfectreportcardallbsveryproudmaigotathinggoinghereyougotlintonyourfuzzowthatsmewavetouswellbeinrow118000byebarryitoldyoustopflyinginthehouseheyadamheybarryisthatfuzzgelalittlespecialdaygraduationneverthoughtidmakeitthreedaysgradeschoolthreedayshighschoolthosewereawkwardthreedayscollegeimgladitookadayandhitchhikedaroundthehiveyoudidcomebackdifferenthibarryartiegrowingamustachelooksgoodhearaboutfrankieyeahyougoingtothefuneralnoimnotgoingeverybodyknowsstingsomeoneyoudiedontwasteitonasquirrelsuchahotheadiguesshe
@alexpersian
alexpersian / bee-movie-password-generator.rb
Last active August 31, 2017 14:58
Create ultra-secure passwords using Jerry Seinfeld's magnum opus
$beeMovieScript = "beemoviescriptaccordingtoallknownlawsofaviationthereisnowayabeeshouldbeabletoflyitswingsaretoosmalltogetitsfatlittlebodyoffthegroundthebeeofcoursefliesanywaybecausebeesdontcarewhathumansthinkisimpossibleyellowblackyellowblackyellowblackyellowblackoohblackandyellowletsshakeitupalittlebarrybreakfastisreadyoominghangonasecondhellobarryadamoanyoubelievethisishappeningicantillpickyouuplookingsharpusethestairsyourfatherpaidgoodmoneyforthosesorryimexcitedheresthegraduatewereveryproudofyousonaperfectreportcardallbsveryproudmaigotathinggoinghereyougotlintonyourfuzzowthatsmewavetouswellbeinrow118000byebarryitoldyoustopflyinginthehouseheyadamheybarryisthatfuzzgelalittlespecialdaygraduationneverthoughtidmakeitthreedaysgradeschoolthreedayshighschoolthosewereawkwardthreedayscollegeimgladitookadayandhitchhikedaroundthehiveyoudidcomebackdifferenthibarryartiegrowingamustachelooksgoodhearaboutfrankieyeahyougoingtothefuneralnoimnotgoingeverybodyknowsstingsomeoneyoudiedontwasteitonasquirrelsuchahotheadiguesshe
0 swift 0x00000001091b242a PrintStackTraceSignalHandler(void*) + 42
1 swift 0x00000001091b1866 SignalHandler(int) + 662
2 libsystem_platform.dylib 0x00007fffe4997b3a _sigtramp + 26
3 libsystem_platform.dylib 0x00007fc27734e530 _sigtramp + 2459658768
4 swift 0x0000000106d12225 swift::NominalTypeDecl::hasFixedLayout() const + 21
5 swift 0x00000001068a5f41 (anonymous namespace)::LowerType::visitAnyStructType(swift::CanType, swift::StructDecl*) + 49
6 swift 0x00000001068a4cd7 swift::Lowering::TypeConverter::getTypeLowering(swift::Lowering::AbstractionPattern, swift::Type) + 2791
7 swift 0x00000001063ff076 (anonymous namespace)::RValueEmitter::emitForceValue(swift::SILLocation, swift::Expr*, unsigned int, swift::Lowering::SGFContext) + 2342
8 swift 0x00000001063ed13d swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void
@alexpersian
alexpersian / gist:e6ab115dc12f3d48eee0e7f27dfb567d
Last active February 22, 2018 18:47
ERROR ITMS-90502 Fix

Update on ERROR ITMS-90502: "Invalid Bundle. Apps that only contain the arm64 slice must also have 'arm64' in the list of UIRequiredDeviceCapabilities in Info.plist."

This looks to be an issue with armv7 / armv7s architecture flags hanging around after a project has been transitioned to arm64 only. The UIRequiredDeviceCapabilities flag for arm64 previously was enough to block 32bit installs, but Apple must have silently changed their criteria yesterday to enforce that explicitly across all proj files within a bundle. Our main project had fully transitioned to 64bit, but an internal SDK proj and our Pods proj still had armv7/armv7s flags.

Adding this to the podfile was enough to fix the issue:

post_install do |installer|
 installer.pods_project.build_configurations.each do |config|
firstly {
// Execute all promises simultaneously
when(fulfilled: firstPromise(), secondPromise(), thirdPromise())
}.done { first, second, third in
// Once they all complete, data will be available here
let newData = [first, second, third].flatMap { return $0 }
process(newData)
}.catch { error in
print("Error: ", error.localizedDescription)
}
func requestFirstData() {
firstly {
firstPromise()
}.done { data in
self.process(content: data)
}.catch { error in
print("Error: ", error.localizedDescription)
}
}
firstly {
firstPromise()
}.then { data in
// This is just passing the data down the chain
return secondPromise()
}.then { data in
// and doesn't do what I was looking for.
return thirdPromise()
}.done { data in
self.process(data)
import SpriteKit
import PlaygroundSupport
let viewFrame = CGRect(x: 0, y: 0, width: 400, height: 400)
let view = SKView(frame: viewFrame)
let dvdNode = SKSpriteNode(imageNamed: "dvd-logo.png")
dvdNode.size = CGSize(width: 100, height: 47)
let mainScene = SKScene(size: view.frame.size)
import SpriteKit
public class DVDScene: SKScene {
private let dvdNode: SKNode
public init(node: SKNode, size: CGSize) {
self.dvdNode = node
super.init(size: size)
setup()