Skip to content

Instantly share code, notes, and snippets.

View levantAJ's full-sized avatar
💭
🌵🌵🌵

levantAJ levantAJ

💭
🌵🌵🌵
View GitHub Profile
@levantAJ
levantAJ / ScrollingDecelerator.swift
Last active March 7, 2024 00:42
Transfer the decelerating between multiple UIScrollViews
//
// ScrollingDecelerator.swift
// ShopBack
//
// Created by Tai Le on 6/5/20.
// Copyright © 2020 levantAJ. All rights reserved.
//
final class ScrollingDecelerator {
weak var scrollView: UIScrollView?
@levantAJ
levantAJ / extract-scheme-url.sh
Created August 7, 2019 03:20
Extract *.ipa file to looking for all scheme URLs
#!/bin/sh
RESET=`tput sgr0`
RED=`tput setaf 1`
GREEN=`tput setaf 2`
if [ "$1" ]; then
if ! [ -e "$1" ]
then
@levantAJ
levantAJ / auto-fill-getting-form.js
Created October 15, 2022 05:56
Auto Fill - Getting Form Input Values
// Method use for logging for debugging
function autoFillGettingLog(message) {
window.webkit.messageHandlers.autoFillGettingShippingInfoLog.postMessage(message);
}
autoFillGettingLog("Beginning....");
/// The configuration xpath will be replace before injected to IAB
/// format: [{xPath, key, value}]
var autoFillGettingConfigurationXPathsString = "checkout-configuration-xpaths";
@levantAJ
levantAJ / auto-fill-filling-form.js
Last active October 15, 2022 05:55
Auto Fill - Filling Form
function autoFillFillingLog(message) {
window.webkit.messageHandlers.autoFillFillingShippingInfoLog.postMessage(message);
}
autoFillFillingLog("Beginning....");
/// The configuration xpath will be replace before injected to IAB
/// format: [{xPath, key, value}]
var autoFillFillingConfigurationXPathsString = "checkout-configuration-xpaths";
@levantAJ
levantAJ / UIImageToCMSampleBuffer
Last active October 12, 2022 03:02
Create CMSampleBuffer from UIImage
import ImageIO
import AVFoundation
var cvPixelBuffer: CVPixelBuffer? {
var pixelBuffer: CVPixelBuffer? = nil
let options: [NSObject: Any] = [
kCVPixelBufferCGImageCompatibilityKey: false,
kCVPixelBufferCGBitmapContextCompatibilityKey: false,
]
let status = CVPixelBufferCreate(kCFAllocatorDefault, Int(size.width), Int(size.height), kCVPixelFormatType_32BGRA, options as CFDictionary, &pixelBuffer)
@levantAJ
levantAJ / String+AES256ECBPKCS5.swift
Last active June 22, 2022 19:29
Encrypt a String with AES256/ECB/PKCS5 with a password
// MARK: - String
extension String {
func aes256ECBPKCS5(hexKey: String) throws -> Data {
let keyData: NSData = try Data(hex: hexKey) as NSData
let data: NSData = Data(utf8) as NSData
guard let cryptData: NSMutableData = NSMutableData(length: Int(data.length) + kCCBlockSizeAES128) else {
throw NSError(domain: "", code: 1234, userInfo: [NSLocalizedDescriptionKey: "Prepare crypt data failed"])
@levantAJ
levantAJ / improve_pre_main_time_loading.rb
Last active November 4, 2021 12:20
⏳Improve the Pre-main time by using `staticlib` for the libraries in CocoaPods
#!/usr/bin/env ruby
def supported_staticlib_pods
return ['YouTubeVideoPlayer']
end
# Improve Pre-main Time
# Using `staticlib`
# Removing the `staticlib` from `[CP] Embed Pods Frameworks`
def improve_pre_main_time_loading(installer, project_name)
@levantAJ
levantAJ / USDZNode.swift
Last active October 20, 2021 15:01
Create SCNNode from USDZ file
class USDZNode: SCNReferenceNode {
init?(
name: String,
position: SCNVector3? = nil,
scale: SCNVector3? = nil,
pivot: SCNMatrix4? = nil
) {
guard let usdzURL: URL = Bundle.main.url(forResource: name, withExtension: "usdz") else { return nil }
super.init(url: usdzURL)
if let scale: SCNVector3 = scale {
@levantAJ
levantAJ / payload.json
Created June 1, 2021 03:27
Testing push notifications on the iOS simulator
{
"Simulator Target Bundle": "com.yourapp.YourAppName",
"aps": {
"alert": {
"body": "Testing Message",
"title": "Test Notification"
}
}
}
@levantAJ
levantAJ / UIViewController+Reactive.swift
Last active June 1, 2021 02:22
Observe presented UIViewController is dismissed with UIModalPresentationStyle is custom
extension Reactive where Base: UIViewController {
var presenting: Observable<UIViewController> {
return sentMessage(#selector(Base.present(_:animated:completion:)))
.compactMap({ args -> UIViewController? in
return args.first as? UIViewController
})
.do(onError: { error in
assertionFailure("\(error)")
})
}