Windows 10 App :Host Defined Policy: Inline Script. Resource will be blocked.

I recently ported one of my java script projects to Windows store app and got the error as following CSP14321: Resource violated directive ‘script-src ms-appx: ‘unsafe-eval’ blob:’ in Host Defined Policy: inline script, in ms-appx://13bdc914-5111-4c95-a5e6-82029c5105ec/index.html at line 21 column 12. Resource will be blocked. If you have something like the following, it won’t work <a href=”javascript:void(0)” id=”somelink” onclick=”callMethod();”>Link</a> Since I was using jQuery in the project, I simply used jQuery to bind click event to the element $(“#somelink”).click(function () { callMethod(); }); and Voila, everything works but I had many pages which had this reference and I had to make this change to all pages. After some research I found that there is an alternate way which is much faster to change. By default ms-appx:/// protocol is used in store apps to fetch the content. For web apps specify a specific protocal ms-appx-web which is then used for the app. This can be done[…]

Error: An invalid APK was received. Not a signed jar file.

When I tried to upload APK file to Aptoide store which was built using cordova and signed for the release version, I got this error An invalid APK was received, does not seem to have all files correctly signed. Please verify apk signature and try again. Signature error: Not a signed jar file The same APK was fine when uploaded on Google Play Store. In order to fix this problem I had to create an unsigned release version of the APK using cordova and then sign it using jarsigner utility. In order to create unsigned release version of the APK, following command can be used cordova build android –release Jarsigner utility comes with java sdk and can be found @ your JDK bin folder (for ex, C:\Program Files\Java\jdk1.8.0_131\bin). The command which can be used to sign the APK is as following jarsigner -verbose -tsa http://timestamp.comodoca.com -keystore android.keystore -storepass password mygame.apk alias[…]

URL Rewrite SEO in IIS

Since the advent of search engines URL rewriting has become mandatory. It makes URLs look nicer and clearer in terms of what content to expect at the given URL. Recently I uploaded few static HTML files to an IIS site. I wanted a nice looking URL without .html extension which was quite straight-forward to achieve in ASP.NET site. You can install URL Rewrite Module in IIS 7 or above versions and a few configuration steps is all that is required to achieve the desired results. Read this article from Microsoft to get in-depth understanding of the steps. Below is the sample web.config entry I had to make to achieve the results <configuration> <system.webServer> <rewrite> <rules> <rule name=”Rewrite to .html Rule”> <match url=”^games/([_0-9a-z-]+)” /> <action type=”Rewrite” url=”games/{R:1}.html” /> </rule> </rules> </rewrite> </system.webServer> </configuration> You will need some understanding of the regular expressions to create a matching pattern for your URL (match tag in[…]

Disable Comments in a Single Post in WordPress

Recently I started getting hundreds of spam comments to a specific post and for a couple days I kept deleting it assuming it was a one time flood but those spam comments kept coming in hundreds everyday. I did not want to delete the post since it had a decent views so decided to look for ways to disable comments in only that specific post. The solution came pretty quickly and was already built-in the WordPress. All I had to do was to go to the posts and then click Quick Edit link which opened an inline edit box and there it was; the option to disable comments. Check for highlighted section below for the same

Path must be a string. Received undefined

It has been a couple months since I last used Intel XDK and a lot has changed since. I just tried to compile a demo HTML5 + Cordova Android app which was exported using Intel XDK version 3987 and got the following error while trying to add android platform to the app using cordova command line. To see how compiling is done, check this blog post. Discovered plugin “cordova-plugin-whitelist” in config.xml. Adding it to the project Installing “cordova-plugin-whitelist” for android This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in. Saved plugin info for “cordova-plugin-whitelist” to config.xml Error: Path must be a string. Received undefined After this error you wont be able to compile the APK. Some research on google got me to this thread which eventually worked. https://stackoverflow.com/questions/46730465/can-not-add-cordova-platform-on-cordova-7-1-0-path-must-be-a-string To fix[…]

Failed to remove a plugin from Intel XDK

In the latest Intel XDK version 3987 I was not able to remove the third-party plugins from HTML5 + Cordova app. Whenever I try to remove a plugin, it failed with the error message Uh oh! Path much be a string. Received undefined I found a workaround @ https://software.intel.com/en-us/forums/intel-xdk/topic/733620 Since Intel XDK is no more into development phase, I think this is the only way as long as this works. Steps are simple. Go to development tab and expand plugins folder there. Delete the third-party plugin and all dependent plugins. Also, delete fetch.json. Then go to Projects tab and delete the plugin from there under Plugin Management. Finally restart XDK.  

How to Move WhatsApp Data to SD Card

With the increase of Video and Photo sharing on WhatsApp there has been a sudden requirement for more data storage space in phones. Phones have limited internal storage which fills up pretty soon with the amount of data being shared on WhatsApp. WhatsApp does not support storing data on SD card as specified on their FAQ page. This has more to do with technical limitations which leaves us only with the option to copy data from WhatsApp Media folders to SD card and then delete the data from the original location which in other words is a simple data backup task. Also, remember once you move the data from WhatsApp Media folder to SD card, the working link to those files in WhatsApp message history is not going to work anymore. You will need to access those files from other Video and Photo Viewer apps. In order to move data from WhatsApp we will need a File Explorer[…]

Repeating or Tiled Background in Phaser

Creating tiled or repeating background is pretty straight forward in Phaser by using tileSprite. Let say we have an image or a texture such as  which we want to use to create a background by repeating it in entire game area. Check out the highlighted line in the example below which is all that is required to create a nice tiled background in Phaser. var TheGame = { }; TheGame.Params = { baseWidth: 200, baseHeight: 200 }; TheGame.Boot = function (game) { }; TheGame.Boot.prototype = { init: function () { this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; this.game.scale.pageAlignHorizontally = true; this.game.scale.pageAlignVertically = true; }, preload: function () { this.load.image(“background”, “repeatxy.png”); this.load.image(“loading”, “loadingback.png”); }, create: function () { this.state.start(“Loading”); } }; TheGame.Loading = function (game) { }; TheGame.Loading.prototype = { init: function () { }, preload: function () { var loadingBar = this.add.sprite(this.world.centerX, this.world.centerY, “loading”); loadingBar.anchor.setTo(0.5); this.load.setPreloadSprite(loadingBar); }, create: function () { this.state.start(“TheGame”); } }; TheGame.MyGame =[…]

How to Embed Google AdSense Code inside a WordPress Post without Any Plugin

WordPress does not let you embed PHP code inside the posts but uses a feature to create Shortcode functions which are executed whenever they are encountered within a post. This is pretty handy feature since this gives you capability to add some PHP code in your WordPress files and then call it from your posts. The PHP code can be added to Theme’s functions.php file. We can use this to load ads from within the posts. Go to WordPress administration -> Appearance -> Editor -> By default style.css is opened for editing. Open functions.php by clicking on the file name on right hand side listing. Now copy the following code at the end of the file and change the return string to your Adsense code. Shortcode is defined by calling add_shortcode function and passing two parameters to it. The first one is a given name which will be used in the posts to call this[…]

Cannot find type: verify that the assembly containing this type is loaded. (Exception from HRESULT: 0x80131515)

Downloaded  HtmlAgilityPack.dll and loaded in Windows Powershell by running the following command Add-Type -Path ‘c:\Temp\PS\Net40\HtmlAgilityPack.dll’ Got the following error.. Add-Type : Could not load file or assembly ‘file:///C:\Temp\PS\Net40\HtmlAgilityPack.dll’ or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) At C:\Temp\PS\script.ps1:12 char:1 + Add-Type -Path ‘c:\Temp\PS\Net40\HtmlAgilityPack.dll’ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Add-Type], FileLoadException + FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.AddTypeCommand   HtmlAgilityPack.dll does not have any dependency for the .Net version I was on (use the command $psversiontable to get the .Net version used by Powershell) It turned out that the file was blocked since it was downloaded from the internet. All I needed to do was to go to DLL’s properties and unblock it.