Skip to content

Instantly share code, notes, and snippets.

View trilliwon's full-sized avatar
🎯
Focusing

WonJo trilliwon

🎯
Focusing
View GitHub Profile
import UIKit
class KConfettiView: UIView {
private var emitterLayer:CAEmitterLayer!
var coefficient:Float = 0.5
var cellCount:Int = 5
var image:UIImage?
var color:UIColor?
@trilliwon
trilliwon / sync_urlsession_dataTask.swift
Created June 15, 2020 09:59
Synchronouse Request URLSession DataTask
extension URLSession {
func syncDataTask(with request: URLRequest) -> (Data?, URLResponse?, Error?) {
var data: Data?
var response: URLResponse?
var error: Error?
let semaphore = DispatchSemaphore(value: .zero)
@trilliwon
trilliwon / constrainToEdges.swift
Last active April 23, 2020 07:08
constrainToEdges, constrain
extension UIView {
@discardableResult
func constrain(constraints: (UIView) -> [NSLayoutConstraint]) -> [NSLayoutConstraint] {
let constraints = constraints(self)
self.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate(constraints)
return constraints
}
@trilliwon
trilliwon / showwifi.sh
Created April 17, 2020 02:26
How to check saved wifi password from terminal
security find-generic-password -ga "WIFI NAME" | grep "password:"
import UIKit
@IBDesignable
final class ClockFace: UIView {
var numberTextFont: UIFont = UIFont.boldSystemFont(ofSize: 11)
@IBInspectable var textColor: UIColor = .black
@IBInspectable var tickColor: UIColor = .black
@IBInspectable var fiveTickColor: UIColor = .black
@trilliwon
trilliwon / pinterestlaout.swift
Created March 3, 2020 07:01
uicollectionview pinterest layout swift
//
// PinterestLayout.swift
// Papr
//
// Created by Joan Disho on 26.05.18.
// Copyright © 2018 Joan Disho. All rights reserved.
//
import RxSwift
import RxCocoa
@trilliwon
trilliwon / activity.swift
Created January 22, 2020 01:46
RxSwift Activity Indicator
private struct ActivityToken<E>: ObservableConvertibleType, Disposable {
private let _source: Observable<E>
private let _dispose: Cancelable
init(source: Observable<E>, disposeAction: @escaping () -> Void) {
_source = source
_dispose = Disposables.create(with: disposeAction)
}
@trilliwon
trilliwon / How to turn off the shutter sound when capture? AVFoundation.swift
Created December 21, 2019 05:08
How to turn off the shutter sound when capture? AVFoundation
class PhotoCapture {
// here some stuff for capture image, such as capture session, configurations, photo output
// More detail : https://github.com/trilliwon/ArtCamera/blob/master/Camera/Controllers/PhotoCapture.swift
}
// MARK: - AVCapturePhotoCaptureDelegate
extension PhotoCapture: AVCapturePhotoCaptureDelegate {
func photoOutput(_ output: AVCapturePhotoOutput, willCapturePhotoFor resolvedSettings: AVCaptureResolvedPhotoSettings) {
AudioServicesDisposeSystemSoundID(1108)
}
import Foundation
import os.log
extension OSLog {
static var appDefault: OSLog {
return log(category: "app_default")
}
private static func log(category: String) -> OSLog {
@trilliwon
trilliwon / Reencoder.swift
Last active July 9, 2023 08:00
Reencoder ios swift
import AVFoundation
import os.log
/// https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/05_Export.html
/**
Steps
- Use serialization queues to handle the asynchronous nature of reading and writing audiovisual data
- Initialize an asset reader and configure two asset reader outputs, one for audio and one for video
- Initialize an asset writer and configure two asset writer inputs, one for audio and one for video