Skip to content

Instantly share code, notes, and snippets.

View oldtrafford91's full-sized avatar
🔍
Job Seeking

Hai Tran oldtrafford91

🔍
Job Seeking
View GitHub Profile
extension UserDefaults {
static func resetDefaults() {
if let bundleID = Bundle.main.bundleIdentifier {
UserDefaults.standard.removePersistentDomain(forName: bundleID)
}
}
}
@oldtrafford91
oldtrafford91 / libdispatch-efficiency-tips.md
Created February 21, 2020 08:59 — forked from tclementdev/libdispatch-efficiency-tips.md
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

I suspect most developers are using the libdispatch inefficiently due to the way it was presented to us at the time it was introduced and for many years after that, and due to the confusing documentation and API. I realized this after reading the 'concurrency' discussion on the swift-evolution mailing-list, in particular the messages from Pierre Habouzit (who is the libdispatch maintainer at Apple) are quite enlightening (and you can also find many tweets from him on the subject).

My take-aways are:

@oldtrafford91
oldtrafford91 / xcode-downloader.rb
Created November 23, 2019 11:29 — forked from iandundas/xcode-downloader.rb
Script for reliably downloading binaries (e.g. Xcode) from Apple's CDN
#!/usr/bin/env ruby
print "What is the URL of your Apple Downloads resource?\nURL:"
url = gets.strip
print "What is the ADCDownloadAuth cookie token:\nADCDownloadAuth: "
token = gets.strip
command = "aria2c --header \"Host: adcdownload.apple.com\" --header \"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\" --header \"Upgrade-Insecure-Requests: 1\" --header \"Cookie: ADCDownloadAuth=#{token}\" --header \"User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 10_1 like Mac OS X) AppleWebKit/602.2.14 (KHTML, like Gecko) Version/10.0 Mobile/14B72 Safari/602.1\" --header \"Accept-Language: en-us\" -x 16 -s 16 #{url} -d ~/Downloads"
@oldtrafford91
oldtrafford91 / remove_tumblr_redirect_link.js
Created November 9, 2019 11:38
Remove tumblr redirect link
@oldtrafford91
oldtrafford91 / StackViewController.swift
Last active August 28, 2019 00:36
Base containment view controller with UIStackView embedded in UIScrollView to manage dynamic child view controller
import UIKit
class StackViewController: UIViewController {
private let scrollView = UIScrollView()
private let stackView = UIStackView()
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(scrollView)
scrollView.addSubview(stackView)
https://www.ashamaluevmusic.com
<script src="//static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script>
<script type="text/javascript">
$(function() {
$("a[href]").each(
function(index, element) {
if ( $(element).text().indexOf('gist.github.com') > 0 ) {
var divElement = $('<div></div>');
$(element).after(divElement);
writeCapture.html(divElement, '<script src="'+$(element).text()+'.js"></'+'script>');
$(element).remove();
@oldtrafford91
oldtrafford91 / Kill process by `lsof` command
Last active November 18, 2018 06:37
Bash command to free the port using by another process. Change PORT by port number need to free.
kill -kill $(lsof -t -i : PORT)
@oldtrafford91
oldtrafford91 / DIVI API Key
Last active March 20, 2021 19:11
DIVI API Key
User: cabhal
API: ea3688a183314df46706ab1f87d457d61acc8d54
@oldtrafford91
oldtrafford91 / .gitignore
Created October 26, 2018 19:22 — forked from pepasflo/.gitignore
Scripts for encrypting / decrypting secrets (to prevent them from being accidentally checked into git)
secrets/