Mindblown: a blog about philosophy.
-
Custom Sorting an Array in Swift
Let’s assume we have following Business struct And we have following data set for business with left value being businessId and right being rating We should sort businesses in descending order of rating. For the businesses that have same rating, the original order of business should remain same. To solve this, we can have following…
-
Handle Remote Control Commands
Handle playback controls for background audio mode
-
Display now playing information in Command Center
Previously, I covered an article Configure Audio Session for background audio mode (iOS Project). Next step is to show relevant information in Command Center for audio played from your iOS Application. Let’s start by importing MediaPlayer Next, place the following code to set now playing information Notice, setting the MPNowPlayingInfoPropertyIsLiveStream to true will show LIVE…
-
Configure Audio Session for background audio mode (iOS Project)
We use AVPlayer from AVFoundation to play audio in our applications. The moment we send the application to back ground mode, audio stops playing. To fix this, we will need to configure AVAudioSession properly. We start by importing AVFoundation in AppDelegate or our iOS Project. Next, add the following code in application didFinishLaunchingWithOptions: Finally, enable…
-
Strip HTML tags in Swift
There are many cases where we need to clean out text from an HTML source. Many people have solved this in their own way. But I have come across a simple solution to this problem. The solution was to use NSAttributedString with setting NSDocumentTypeDocumentAttribute to NSHTMLTextDocumentType. Let’s start with the following HTML: Below is a…
-
Working with live views in Swift Playground
Prototype faster in Swift Playground without Projects
-
Adding https support in Flask
Getting a chance to work on Python, my favorite framework is Flask (http://flask.pocoo.org/). It is a micro-framework that lets you create and deploy APIs, websites, and dashboards. When deploying Flask projects onto a production server, we need to only support HTTPS and redirect HTTP requests to HTTPS. This creates a problem with Flask url_for function, which…
-
Noto Fonts: Beautiful and free fonts for all languages
Google has provided and open-sourced Noto fonts family covering all the languages. The complete font package is over 100MB, which can be downloaded as one or individual fonts. I have recently used Noto Kufi Arabic font in Al Arabiya News (Arabic) iOS Application. Check out how neat and readable the text renders. To find out…
-
Generate Random Colors in Swift
Randomize UIColor
Got any book recommendations?