Skip to content

Instantly share code, notes, and snippets.

View kientux's full-sized avatar
🎯
Focusing

Kien Nguyen kientux

🎯
Focusing
  • Appfactory
  • Hanoi, Vietnam
View GitHub Profile
@kientux
kientux / cropping_samplebuffer.swift
Created February 7, 2023 08:52
Cropping CMSampleBuffer from AVCaptureVideoDataOutputSampleBufferDelegate
import Accelerate
func cropSampleBuffer(_ sampleBuffer: CMSampleBuffer) -> CMSampleBuffer? {
guard let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else {
return nil
}
CVPixelBufferLockBaseAddress(imageBuffer, .readOnly)
defer { CVPixelBufferUnlockBaseAddress(imageBuffer, .readOnly) }
@kientux
kientux / remove_xcode_archives.swift
Last active March 30, 2022 08:05
Remove old Xcode archives. Can be set up to run every day to free up CI machine disk. Default will remove all development/staging archives.
import Foundation
extension FileManager {
typealias FileExistResult = (exist: Bool, isDirectory: Bool)
func checkExists(at path: String) -> FileExistResult {
var fileIsDirectory: ObjCBool = false
let exist = fileExists(atPath: path, isDirectory: &fileIsDirectory)
return (exist, fileIsDirectory.boolValue)
}
@kientux
kientux / uicollectionview+centerPaging.md
Last active November 25, 2021 10:13 — forked from vinhnx/uicollectionview+centerPaging.md
Centered Paging with Preview Cells on UICollectionView

Centered Paging with Preview Cells on UICollectionView

The proposed offset is where the collection view would stop without our intervention. We peek into this area by finding its centre as proposedContentOffsetCenterX and examine our currently visible cells to see which one’s centre is closer to the centre of that area.

class CenterItemPagingCollectionViewLayout: UICollectionViewFlowLayout {
    
    private var mostRecentOffset: CGPoint = .zero {
        didSet {
            notifyPageChanged()
protected Map<String, String> buildRequestParameters(Const.HttpMethod httpMethod, String requestPath,
SyncStore store) {
TreeMap<String, String> params = new TreeMap<String, String>();
params.put("oauth_consumer_key", store.getConsumerKey());
params.put("oauth_nonce", generateOAuthNonce(32));
params.put("oauth_signature_method", "HMAC-SHA1");
params.put("oauth_timestamp", String.valueOf(System.currentTimeMillis() / 1000L));
String signature = buildOAuthSignature(httpMethod.name(), requestPath, params, store.getConsumerSecret());
params.put("oauth_signature", signature);
@kientux
kientux / frameworks_blogpost_merge_script.sh
Last active July 27, 2023 17:17 — forked from brett-stover-hs/frameworks_blogpost_merge_script.sh
Merge simulator and device dynamic frameworks into one
# Merge Script
# 1
# Set bash script to exit immediately if any commands fail.
set -e
# 2
# Setup some constants for use later on.
FRAMEWORK_NAME="${PROJECT_NAME}"
@kientux
kientux / ioslocaleidentifiers.csv
Last active February 23, 2017 13:38 — forked from jacobbubu/ioslocaleidentifiers.csv
iOS Locale Identifiers
om_KE Oromo (Kenya)
om_KE Oromo (Kenya)
mr Marathi
bs Bosnian
ee_TG Ewe (Togo)
ms Malay
kam_KE Kamba (Kenya)
mt Maltese
ha Hausa
es_HN Spanish (Honduras)
@kientux
kientux / AES256Cryptor.java
Last active January 16, 2021 10:50
Encrypt and decrypt AES-256 (in CryptoJS way)
/**
* Created by kientux on 3/20/15
*/
import android.util.Base64;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Arrays;