Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Erdem ILDIZ erdemildiz

🏠
Working from home
View GitHub Profile
View CameraSessionViewController.swift
import UIKit
import AVFoundation
enum CameraSession: Error {
case inValidInput
case inValidOutput
}
final class CameraSessionViewController: UIViewController {
// Camera Setting
@erdemildiz
erdemildiz / custom-environment-swiftui.swift
Created Jun 1, 2022
Custom Environment usage SwiftUI
View custom-environment-swiftui.swift
// Source: https://useyourloaf.com/blog/swiftui-custom-environment-values/
// 1. Create the key with a default value
private struct CaptionColorKey: EnvironmentKey {
static let defaultValue = Color(.secondarySystemBackground)
}
// 2. Extend the environment with our property
extension EnvironmentValues {
var captionBackgroundColor: Color {
get { self[CaptionColorKey.self] }
@erdemildiz
erdemildiz / swiftui-top-view-has-modal.swift
Created May 18, 2022
SwiftUI check has modal on modal
View swiftui-top-view-has-modal.swift
extension UIApplication {
var currentKeyWindow: UIWindow? {
UIApplication.shared.connectedScenes
.filter { $0.activationState == .foregroundActive }
.map { $0 as? UIWindowScene }
.compactMap { $0 }
.first?.windows
.filter { $0.isKeyWindow }
.first
}
View run-applescript.swift
// https://www.jessesquires.com/blog/2018/11/17/executing-applescript-in-mac-app-on-macos-mojave/
private func runScript() {
// Solution 1
let script = """
tell application "Notes"
tell account "iCloud"
make new note at folder "Notes" with properties {name:"14:53 Daily Notes", body:""}
set noteRunTime to get notes whose name is "14:53 Daily Notes"
show item 1 of noteRunTime
View socketserver-appside-ui.swift
//
// ContentView.swift
// socket-demo
//
// Created by Erdem ILDIZ
//
import SwiftUI
import SocketIO
View socketserver-appside-model.swift
//
// CurrencyListModel.swift
// socket-demo
//
// Created by Erdem ILDIZ
//
import Foundation
// MARK: - CurrencyList
View socketserver-index.js
import express from "express";
import { createServer } from "http";
import { Server } from "socket.io";
import fetch from "node-fetch";
const app = express();
const server = createServer(app);
const io = new Server(server, {
allowEIO3: true,
});
View socket-package.json
{
"name": "socketdemo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
View socket-npm-init.sh
mkdir socketdemo && cd socketdemo && touch index.js && npm init