Skip to content

Instantly share code, notes, and snippets.

@trungnguyen1791
trungnguyen1791 / dusort.sh
Created September 14, 2024 01:12 — forked from smontanaro/dusort.sh
I got this du postprocessing script from "the net" in the dark ages (probably from Usenet in the 80s or 90s). I have no idea who the original author was. I've never modified it **at all**. It has always just worked.
#!/bin/sh
#
# sort a "du" listing by directory size
# usage: du | dusort
FILES=
TFORM=0
while test $# -ge 1; do
case $1 in
-t) TFORM=1; ;;
import CryptoSwift
import Foundation
// Combined from https://github.com/lachlanbell/SwiftOTP/blob/master/SwiftOTP/Generator.swift and https://raw.githubusercontent.com/vapor/open-crypto/3.3.3/Sources/Crypto/MAC/OTP.swift
// MARK: TOTP
/// Generates Time-based One-time Passwords using HMAC.
///
@trungnguyen1791
trungnguyen1791 / README.md
Created February 28, 2024 07:33 — forked from tomas789/README.md
OpenCV <-> Objective-C++ (UIImage) conversion

OpenCV -> UIImage

cv::Mat mat /* = ... */;
UIImage* image = [UIImage fromCvMat:mat];

UIImage -> OpenCV

extension BoardCollectionViewCell: UITableViewDropDelegate {
func tableView(_ tableView: UITableView, performDropWith coordinator: UITableViewDropCoordinator) {
if coordinator.session.hasItemsConforming(toTypeIdentifiers: [kUTTypePlainText as String]) {
coordinator.session.loadObjects(ofClass: NSString.self) { (items) in
guard let string = items.first as? String else {
return
}
var updatedIndexPaths = [IndexPath]()
@trungnguyen1791
trungnguyen1791 / Readme.markdown
Created August 12, 2022 08:01 — forked from mat/Readme.markdown
apple-app-site-association —with examples

“apple-app-site-association” file

One file for each domain, both www.example.com and example.com need separate files:

{
    "applinks": {
        "apps": [],
        "details": {
 "9JA89QQLNQ.com.apple.wwdc": {
@trungnguyen1791
trungnguyen1791 / resetAllSimulators.sh
Created May 20, 2021 05:38 — forked from ZevEisenberg/resetAllSimulators.sh
Reset all iOS simulators with this one weird trick
osascript -e 'tell application "iOS Simulator" to quit'
osascript -e 'tell application "Simulator" to quit'
xcrun simctl erase all
@trungnguyen1791
trungnguyen1791 / yolo.sh
Created February 26, 2021 09:56 — forked from nlutsenko/yolo.sh
Fast Xcode builds
defaults write xcodebuild PBXNumberOfParallelBuildSubtasks 4
defaults write xcodebuild IDEBuildOperationMaxNumberOfConcurrentCompileTasks 4
defaults write com.apple.xcode PBXNumberOfParallelBuildSubtasks 4
defaults write com.apple.xcode IDEBuildOperationMaxNumberOfConcurrentCompileTasks 4
@trungnguyen1791
trungnguyen1791 / Realm+CascadeDeleting.swift
Created October 9, 2019 10:37 — forked from krodak/Realm+CascadeDeleting.swift
Cascade deletion for RealmSwift
import RealmSwift
import Realm
protocol CascadeDeleting: class {
func delete<Entity>(_ list: List<Entity>, cascading: Bool)
func delete<Entity>(_ results: Results<Entity>, cascading: Bool)
func delete<Entity: Object>(_ entity: Entity, cascading: Bool)
}
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@trungnguyen1791
trungnguyen1791 / DashboardNode.swift
Created March 15, 2019 07:56 — forked from Eke/DashboardNode.swift
ASCollectionNode show footer only for some sections
import AsyncDisplayKit
class DashboardNode: ASDisplayNode {
private let collectionNode: ASCollectionNode
init() {
let collectionFlow = UICollectionViewFlowLayout()
collectionNode = ASCollectionNode(collectionViewLayout: collectionFlow)
super.init()