Skip to main content


Showing posts from 2018

Ionic 4 HTTP CORS Issue

Ionic 4 is a major upgrade to previous version of Ionic . One of the primary differences between Ionic 4 and its previous incarnations is that Ionic 4 uses web components , which are custom HTML elements written using web standards (as opposed to using a slap-on framework such as Angular). Ionic 4 also makes a fundamental change in how the created app is rendered (I use rendered as apps are essentially HTML which is rendered using the native WebView control of the device's UI framework) in a device. While earlier versions used to refer to the top level index.html using file:// URI scheme, Ionic 4 internally spins up an HTTP server on localhost (yes for each app) and then loads the index.html through a standard HTTP request such as http://localhost:port/index.html. Problem I'm not sure what necessitated this change, but I reckon it probably had something to do with native API restrictions, which in turn was prompted by need for improved security. This, however, introduc

Notes of the day

A recent project requirement from a customer for a cross-platform solution prompted me to look into viable frameworks for this. Based on my knowledge of languages (C++, Python & Javascript), I narrowed the potential solutions to wxWidgets & Git Electron. Since I have been spending some time with Python over the last two years and given its ease of use, I through I'll look into wxPython, the Python projection of wxWidgets framework. Here are my notes from this research today morning: wxPython provides a genuine means to build cross platform GUI apps (installed through PyPi pip install wxpython ). Python code can be compiled into distributable binaries using cx_Freeze , another cross-platform tool that can generate binaries for Windows, Mac & Linux. cx_Freeze can provide executable files as well as installable binaries such as MSI or DMG files. cx_Freeze source repo has sample code for various deployment scenarios. One of them is wxPython based application. Py2Ex

Downloading & opening a file in an Ionic app

If you search the Internet for examples to achieve the above, you'll get a number of resources that suggest using the cordova-file-transfer plugin. However, with Ionic 3+ and its native API, you can do this directly using a mix of Angular and Ionic  File API. Essentially, you need to use Angular HttpClient to download a URL as a Blob using the responseType option and then save the resultant Blob to a file on the device using the File API. Finally, open the saved file using the Ionic native FileOpener API. Here's the method in a provider that is used to download files from a website. Note that  this.http is an instance of HttpClient . /** * Download a file from the given url. * * Params: * url - the URL to download the file from * Returns: * A promise which upon resolution returns a dictionary * { * fileEntry: FileEntry, * type: The content-type string for the file * } */ download(url): Promise<{ fileEntry: Fi

Cordova build errors

Had this unusual errors crop up when building a cordova app for android. This started appearing after I installed cordova-plugin-file-opener2. ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontVariationSettings ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:ttcIndex Going through platforms/android/ file, I realized that there was something quite odd about it. cordova.system.library.2=me.leolin:ShortcutBadger:1.1.17@aar There were multiple versions of the same library being defined. I removed the last three lines -- library.4, library.5 & library.6, ensuring that t

Celery on Windows

Running celery on Windows, shows the following error when tasks are queued to be executed: ValueError: not enough values to unpack (expected 3, got 0) The way to fix this is to add --pool=solo to the celery daemon command line. This makes celery run as a solo process and without concurrency, which for development purposes shouldn't be a big deal. So the entire daemon command would look something like this: python -m celery -A config worker --pool=solo -l info Taken from this Github thread .