Skip to content

Instantly share code, notes, and snippets.

@trungnguyen1791
trungnguyen1791 / UILabel with Countdown
Created February 18, 2017 19:36 — forked from dokun1/UILabel with Countdown
UILabel as countdown timer given NSTimeInterval
-(void) updateCountdown {
NSTimeInterval timeToClosing = [_deleteDate timeIntervalSinceDate:[NSDate date]];
div_t h = div(timeToClosing, 3600);
int hours = h.quot;
div_t m = div(h.rem, 60);
int minutes = m.quot;
int seconds = m.rem;
NSString *hoursStr, *minutesStr, *secondsStr;
@trungnguyen1791
trungnguyen1791 / BeaconResearch.md
Created February 6, 2018 16:23
iBeacon / Beacon Research
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
mr Marathi
bs Bosnian
ee_TG Ewe (Togo)
ms Malay
kam_KE Kamba (Kenya)
mt Maltese
ha Hausa
es_HN Spanish (Honduras)
ml_IN Malayalam (India)
ro_MD Romanian (Moldova)
@trungnguyen1791
trungnguyen1791 / kernel_task_cpu_fix
Created September 25, 2018 06:07
Fix kernel_task high CPU usage on OS X
# Boot to recovery mode and disable system integrity protection
csrutil disable
# Reboot to regular mode and purge these motherfuckin plists
sudo rm -f /System/Library/Extensions/IOPlatformPluginFamily.kext/Contents/PlugIns/ACPI_SMC_PlatformPlugin.kext/Contents/Resources/*.plist
# Reboot to recovery mode and enable system integrity protection
csrutil enable
# Reboot
@trungnguyen1791
trungnguyen1791 / trilateration.js
Created March 12, 2019 03:54 — forked from kdzwinel/trilateration.js
Simple trilateration algorithm implementation in JavaScript.
function getTrilateration(position1, position2, position3) {
var xa = position1.x;
var ya = position1.y;
var xb = position2.x;
var yb = position2.y;
var xc = position3.x;
var yc = position3.y;
var ra = position1.distance;
var rb = position2.distance;
var rc = position3.distance;
@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()
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 / 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)
}
@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 / 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