Skip to content

Instantly share code, notes, and snippets.

View pddkhanh's full-sized avatar
🎯
Focusing

Khanh Pham pddkhanh

🎯
Focusing
  • Singapore
View GitHub Profile
@pddkhanh
pddkhanh / 5000-dummy-contacts.vcf
Created August 24, 2021 06:46
5000 dummy contacts
BEGIN:VCARD
VERSION:4.0
N:Schurig;Donny;;;
FN:Donny Schurig
TEL;type=HOME:+86 279 743 6473
END:VCARD
BEGIN:VCARD
VERSION:4.0
N:Ambrogiotti;Louella;;;
FN:Louella Ambrogiotti
@pddkhanh
pddkhanh / PriorityQueue.swift
Last active May 3, 2021 02:14
PriorityQueue
struct PriorityQueue<Element>: CustomDebugStringConvertible {
typealias PriorityFunc = (Element, Element) -> Bool
private let priorityFunc: PriorityFunc
private var elements: [Element]
init(priorityFunction: @escaping PriorityFunc) {
priorityFunc = priorityFunction
elements = []
}
@pddkhanh
pddkhanh / SimpleAutoWrapView.swift
Created September 25, 2019 16:47
Simple custom view that auto wrap subviews to new rows
final class SimpleAutoWrapView: UIView {
private var arrangedSubviews: [UIView] = []
private var calculatedIntrinsicContentSize = CGSize.zero {
didSet {
if oldValue != calculatedIntrinsicContentSize {
invalidateIntrinsicContentSize()
}
}
}
@pddkhanh
pddkhanh / UIControl+touchAreaEdgeInsets.swift
Created April 19, 2019 04:57
Extend touch area of UIControl
import UIKit
private var pTouchAreaEdgeInsets: Int = 0
extension UIControl {
var touchAreaEdgeInsets: UIEdgeInsets {
get {
if let value = objc_getAssociatedObject(self, &pTouchAreaEdgeInsets) as? NSValue {
var edgeInsets: UIEdgeInsets = .zero
public class RoundedShadowView: UIView {
public var cornerRadius: CGFloat = 2.0 {
didSet {
setNeedsLayout()
}
}
public var fillColor: UIColor = .white {
didSet {
@pddkhanh
pddkhanh / khanh.plugin.zsh
Last active September 10, 2018 07:32
My oh-my-zsh plugin
alias xcdd='rm -rf ~/Library/Developer/Xcode/DerivedData/*'
alias xctp='xcbuild_time_profiling'
function xcbuild_time_profiling {
local fileToOpen='';
local is_workspace=true;
local scheme=$1;
if [ -n "$scheme" ]
then
@pddkhanh
pddkhanh / SnapingCollectionViewFlowLayout.swift
Created May 18, 2018 14:09
Snaping CollectionViewFlowLayout like AppStore
/**
Support snaping to the left as AppStore layout
*/
class SnapingCollectionViewFlowLayout: UICollectionViewFlowLayout {
override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint,
withScrollingVelocity velocity: CGPoint) -> CGPoint {
guard let collectionView = collectionView else {
return super.targetContentOffset(forProposedContentOffset: proposedContentOffset,
withScrollingVelocity: velocity)
}
platform :ios, '9.0'
target 'Photos' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
inhibit_all_warnings!
# Pods for Photos
pod 'RxCocoa'
pod 'RxSwift'