- Ubuntu 14.04, 16.04, or 16.10
- Open up terminal
- Install core deps:
sudo apt-get install clang libicu-dev git
export const getThumbnail = (id, size = 300) => | |
`https://drive.google.com/thumbnail?id=${id}&sz=${size}`; | |
export const getIcon = (mimeType) => | |
`https://drive-thirdparty.googleusercontent.com/256/type/${mimeType}`; | |
export const getFile = (id) => `https://drive.google.com/uc?id=${id}`; | |
const downloadFile = (id) => |
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 | |
} |
// 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")) |
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 ) |
// 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 | |
} | |
} |