Skip to content

Instantly share code, notes, and snippets.

View apple-avadhesh's full-sized avatar
🏠
Working from home

Avadhesh Sharma apple-avadhesh

🏠
Working from home
View GitHub Profile
import SceneKit
import PlaygroundSupport
var sceneView = SCNView()
PlaygroundPage.current.liveView = sceneView
sceneView.backgroundColor = .black
var scene = SCNScene()
sceneView.scene = scene
var universe = scene.rootNode
@zhaorui
zhaorui / keypad.swift
Created November 11, 2021 13:52
A console app print all key events written by swift
import Cocoa
import Foundation
@discardableResult
func acquirePrivileges() -> Bool {
let accessEnabled = AXIsProcessTrustedWithOptions([kAXTrustedCheckOptionPrompt.takeUnretainedValue() as String: true] as CFDictionary)
if accessEnabled != true {
print("You need to enable the keylogger in the System Prefrences")
@apple-avadhesh
apple-avadhesh / iOSActionCallbacks.swift
Created September 21, 2021 14:30
iOS Control Action Callbacks
// UITextField
let textField = UITextField()
textField.addAction(
UIAction { action in
let textField = action.sender as! UITextField
print(textField.text ?? "")
},
for: .editingChanged
)
@apple-avadhesh
apple-avadhesh / Model.swift
Created August 21, 2021 21:39 — forked from OctoberHammer/Model.swift
Запрос на консультацию. Последовательное получение картинок из PFFile для массива объектов PFObject
//
// Model.swift
// KidSpace
//
// Created by October Hammer on 4/19/17.
// Copyright © 2017 Ocotober Hammer. All rights reserved.
//
import Foundation
import Parse
@YudhistherAryan
YudhistherAryan / GetCurrentDisplayCell.swift
Last active August 1, 2021 15:01
How to get the index of visible cell in the UICollectionView
//Put this function into the extension of the UICollectionVIewDelegate and you will get the index of the current cell displaying.
// This will be helpful when you will implemenet the image slider with the help of the collectionView(by default pagination of the collectionView).
func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
print("Currently visible cell is \(self.collectionView.indexPathsForVisibleItems)")
}
@atrinh0
atrinh0 / pluraliser_issues.swift
Last active June 1, 2024 20:38
Foundation Pluraliser Potential Issues
import SwiftUI
struct ContentView: View {
// sample of data was compiled using the following sources:
// https://birdgei.com/2011/08/30/list-of-100-irregular-plural-nouns-in-english/
// https://www.grammarly.com/blog/plural-nouns/
// https://www.thoughtco.com/irregular-plural-nouns-in-english-1692634
// https://www.ef.co.uk/english-resources/english-grammar/singular-and-plural-nouns/
// google
@vibrazy
vibrazy / Toggle.swift
Created May 10, 2021 10:56
Toggled - Simpler way to deal with hardcoded ViewModifers values in SwiftUI
struct ToggledExampleView_Previews: PreviewProvider {
static var previews: some View {
DebuggingToggledExampleView()
}
}
// MARK: - Toggled Source
protocol ToggleInterface {
associatedtype ValueType
@vibrazy
vibrazy / ColorPickerStorageExample.swift
Last active January 28, 2023 18:19
SwiftUI `ColorPicker` load and save values to disk using `AppStorage`
//
// ContentView.swift
// Shared
//
// Created by Dan Tavares on 01/07/2022.
// More Info: https://nilcoalescing.com/blog/EncodeAndDecodeSwiftUIColor/
import SwiftUI
#if os(iOS)
@ANSCoder
ANSCoder / FileUtility.swift
Last active November 1, 2022 05:24
Read and Write Codable Models from the JSON file inside FileManager. 🎉
//
// FileUtility.swift
// TravelApp
//
// Created by Anand Nimje on 13/04/20.
// Copyright © 2020 Anand. All rights reserved.
//
import Foundation
@shial4
shial4 / DateField.swift
Last active June 4, 2021 14:55
SwiftUI text field with date picker as keyboard accessory view and toolbar with done button
//
// DateField.swift
//
// Created by Szymon Lorenz on 22/2/20.
// Copyright © 2020 Szymon Lorenz. All rights reserved.
//
import SwiftUI
struct DateTextField: UIViewRepresentable {