- Ubuntu 14.04, 16.04, or 16.10
- Open up terminal
- Install core deps:
sudo apt-get install clang libicu-dev git
func abbreviateNumber(num: NSNumber) -> String { | |
// less than 1000, no abbreviation | |
if num < 1000 { | |
return "\(num)" | |
} | |
// less than 1 million, abbreviate to thousands | |
if num < 1000000 { | |
var n = Double(num); | |
n = Double( floor(n/100)/10 ) |
// define a variable to store initial touch position | |
var initialTouchPoint: CGPoint = CGPoint(x: 0,y: 0) | |
@IBAction func panGestureRecognizerHandler(_ sender: UIPanGestureRecognizer) { | |
let touchPoint = sender.location(in: self.view?.window) | |
if sender.state == UIGestureRecognizerState.began { | |
initialTouchPoint = touchPoint | |
} else if sender.state == UIGestureRecognizerState.changed { | |
if touchPoint.y - initialTouchPoint.y > 0 { |
extension Int { | |
func formatUsingAbbrevation () -> String { | |
let numFormatter = NSNumberFormatter() | |
typealias Abbrevation = (threshold:Double, divisor:Double, suffix:String) | |
let abbreviations:[Abbrevation] = [(0, 1, ""), | |
(1000.0, 1000.0, "K"), | |
(100_000.0, 1_000_000.0, "M"), | |
(100_000_000.0, 1_000_000_000.0, "B")] |
// You have a very very large video file you need to upload to a server while your app is backgrounded. | |
// Solve by using URLSession background functionality. I will here use Alamofire to enable multipart upload. | |
class Networking { | |
static let sharedInstance = Networking() | |
public var sessionManager: Alamofire.SessionManager // most of your web service clients will call through sessionManager | |
public var backgroundSessionManager: Alamofire.SessionManager // your web services you intend to keep running when the system backgrounds your app will use this | |
private init() { | |
self.sessionManager = Alamofire.SessionManager(configuration: URLSessionConfiguration.default) | |
self.backgroundSessionManager = Alamofire.SessionManager(configuration: URLSessionConfiguration.background(withIdentifier: "com.lava.app.backgroundtransfer")) |
I was chasing down another issue (slow "Save As") and thought these two issues may have been related (with QuickLook being the common broken link). Unfortunately, my "Save As" dialog is still miserably slow on the initial load; but IconServicesAgent hasn't gone above 30MB and he rarely makes an appearance in the Console!
Some of these steps may not be necessary, but here are all of the steps I took that inadverdently put IconServicesAgent back in its place. Note: all commands are a single-line, if they appear to be multiple that's just the forum formatting.
Check for any QuickLooks related .plist files. In a terminal: mdfind com.apple.quicklook. -name .plist
I only had files at the system level (specifically within /System/Library/LaunchAgents/). If you have others, modify the directions below to take that into account (re-introducing plist files from the system level back up to the user).
Make some temporary directories to store these plist files, just in case: mkdir ~/tmp-quicklook
// Does not work on iOS 14.0 or later, keeping the gist just for reference. | |
extension UITabBar { | |
override open func sizeThatFits(size: CGSize) -> CGSize { | |
super.sizeThatFits(size) | |
var sizeThatFits = super.sizeThatFits(size) | |
sizeThatFits.height = 71 | |
return sizeThatFits | |
} | |
} |
import { useNotificationService } from './hooks'; | |
function App() { | |
useNotificationService(); | |
... | |
} |
import Foundation | |
extension Data { | |
var prettyPrintedJSONString: NSString? { /// NSString gives us a nice sanitized debugDescription | |
guard let object = try? JSONSerialization.jsonObject(with: self, options: []), | |
let data = try? JSONSerialization.data(withJSONObject: object, options: [.prettyPrinted]), | |
let prettyPrintedString = NSString(data: data, encoding: String.Encoding.utf8.rawValue) else { return nil } | |
return prettyPrintedString | |
} |
Problem: When linking to the raw version of a gist, the link changes with each revision.
Solution:
To return the first file from a gist: https://gist.github.com/[gist_user]/[gist_id]/raw/
To get a file from multi–file gist: https://gist.github.com/[gist_user]/[gist_id]/raw/[file_name]