Skip to content

Instantly share code, notes, and snippets.

View devahmedshendy's full-sized avatar

Ahmed Shendy devahmedshendy

  • Egypt
View GitHub Profile
@devahmedshendy
devahmedshendy / DynamicFunctions.swift
Created February 28, 2024 00:23 — forked from neonichu/DynamicFunctions.swift
Using dlopen / dlsym to call C functions from Swift
import Darwin
let handle = dlopen("/usr/lib/libc.dylib", RTLD_NOW)
let sym = dlsym(handle, "random")
let functionPointer = UnsafeMutablePointer<() -> CLong>(sym)
let result = functionPointer.memory()
println(result)
@devahmedshendy
devahmedshendy / image_as_text_foreground.swift
Last active April 25, 2024 10:56
SwiftUI View: add image as a foreground for Text view
struct ContentView: View {
private let imageUrl: String = "https://picsum.photos/seed/picsum/200/300"
var body: some View {
text
.overlay(
AsyncImage(url: .init(string: imageUrl)) { image in
image
.resizable()
.aspectRatio(contentMode: .fill)