Skip to content

Instantly share code, notes, and snippets.

View Starmel's full-sized avatar
🍌
ring ring ring banana phone

Starmel Starmel

🍌
ring ring ring banana phone
View GitHub Profile

Simple KMM framework transitive linking

Problem:

  1. Required to share KMM library with linked Xcode Frameworks to other KMM projects
  2. Xcode project is use Cocoapods
  3. KMM project (library consumer) is built by Xcode with :embedAndSignAppleFrameworkForXcode

How to:

fun <Element> AsyncResult.Companion.fromCoroutine(
source: suspend () -> Element
): AsyncResult<Element> {
return create { emitter ->
val job = CoroutineScope(defaultDispatcher).launch {
try {
val result = source.invoke()
emitter.onSuccess(result.makeShared())
} catch (error: Throwable) {
class AsyncResult<Element>(
private val source: (AsyncResultEmitter<Element>) -> Unit
) {
fun subscribe(
onSuccess: (Element) -> Unit,
onError: (Throwable) -> Unit
): AsyncResultDisposable {
val emitter = AsyncResultEmitter(onSuccess, onError)
@Starmel
Starmel / commonprofile_frag.metal
Created May 4, 2020 19:17
SceneKit Shader fragment functions
////////////////////////////////////////////////
// CommonProfile Shader v2
#import <metal_stdlib>
using namespace metal;
#ifndef __SCNMetalDefines__
#define __SCNMetalDefines__
import AVFoundation
open class ImageVideoGenerator {
public static func generateVideo(image: CGImage, duration: TimeInterval, frameSize: CGSize) throws -> URL {
let outputURL = URL.createTempFile()
let videoWriter = try AVAssetWriter(outputURL: outputURL, fileType: .mp4)
let videoSettings: [String: Any] = [AVVideoCodecKey: AVVideoCodecType.h264,
stages:
- deploy
- notification
.send-mt-notification: &send-mt-notification |
curl -X POST \
$WEBHOOK_URL \
-H 'Content-Type: application/json' \
-d "{
\"channel\": \"town-square\",
@Starmel
Starmel / gist:1aa0183e37f6ad258b773bf7fad8d6ae
Created March 13, 2019 11:51
ios video text animation example
// STEP 1 - load resources
let asset = AVURLAsset(url: videoURL, options: nil)
let track = asset.tracks(withMediaType: AVMediaType.video)
let videoTrack = track[0] as AVAssetTrack
// STEP 2 - Prepare new layers to video.
const int RED_PIN = 10;
const int YELLOW_PIN = 11;
const int GREEN_PIN = 12;
void setup() {
pinMode(RED_PIN, OUTPUT);
pinMode(YELLOW_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT);
}