If you own a website, then it is good to check their performance now and then. Various factors affect the site speed, and it’s better to use some tools to do the job for you.
YSlow is a similar tool from Yahoo!, that analyzes web pages for performance. It is available as a browser extension and has one for all popular ones. It provides a grade for the web page based on a predefined ruleset or a user-defined ruleset. The grade is calculated based on the YSlow Ruleset Matrix.
I have been implementing some of the recommendations from the above tools on this blog, but as you can see from the above results, there is still more to be done. Hope you find this helpful for your sites.
At one of my recent clients, we had a requirement to generate a PDF dynamically based on the contents of the website. The website is a Content Management System (CMS) built on top of Umbraco. The content is grouped into different categories and sub-categories. Each category and sub-category had different sections/sub-sections under that. Some sections are optional for certain categories, and all of these are dynamic. In this post, I will walk through at high level the approach taken to solve the problem.
The user selects the categories/sub-categories and the sections that they wish to export as PDF. On submit, a PDF needs to be generated based on the website content.
1 2 3 4 5 6 7 8 9 10 11 12
The actual site had one more level of options (say sub-sections), so you can imagine the number of possible combinations to generate the content. The site content was huge as well, and a PDF with all options selected would be around 4000-5000 pages. So creating the PDF every time some one clicks the button was out of the question. We had to cache the generated PDF’s and serve them as the request comes in. But the challenge was how to manage the cache so that we can build up the PDF based on the options selected.
Below is the flow diagram of the complete process of generating the PDF as a request comes. The request specifies the categories/sub-categories along with the sections that need to be in the generated PDF.
We decided to create a PDF file for each section per category/subcategory selection. Once all the sections are ready, all the PDF files will be merged into one. While merging we also build up the bookmark tree and the table of contents. Inserting the table of contents page at the start of the PDF requires pushing all the page numbers to match the new ones.
The PDF layout for individual sections per category/subcategory is in HTML. The application exposes endpoints for the HTML content for the different sections. We used Essential Object HTML to PDF Converter to convert the HTML to PDF files. Bookmarks for the associated section are embedded in HTML. While converting to PDF, the bookmarks get added to the PDF, which later gets merged into the full bookmark tree. The generated PDF file is cached for any new requests.
Since we have around forty categories/sub-categories, twelve section, and ten sub-sections, generating the full PDF take a while. So we generate the cache at fixed intervals and as required (when content is updated in the CMS). The above approach of generating PDF files has been working fine for us. Since the individual PDF sections are generated in isolation, it gives us the flexibility to scale the generation process as required. Combining the generated PDF files is often fast and can be cached at a different level as well to speed up the whole process.
Chocolatey is a package manager for Windows. Chocolatey is a central store of applications, tools, and other packages. It allows you to install them on your computer from the command line. Let’s look at an example to make things more clear. Let’s say I want to install the Google Chrome Browser on my system. Below is how I would go about installing it.
Installing Google Chrome (Without Chocolatey)
- Bing for Google Chrome (Assuming that you are on Windows and open up Internet Explorer and search for Google Chrome)
- Click the relevant link from the Search Results
- Hit the Download Chrome button
- Wait for the installer to download and open that to install.
Installing Google Chrome (With Chocolatey)
- Run ‘choco install googlechrome’ from command line
Installing with Chocolatey is quick and easy. You no longer need to go around searching the web for the software that you want to install. If you are unsure of the package name (e.g. googlechrome), you can search the entire packages library. This is possible from the command line using ‘choco search.’ Or you can also search on their website.
Run the below script from the command line to install Chocolatey Package Manager. Once installed you can start managing applications through the command line using Chocolatey.
Other than installing and searching packages, Chocolatey also supports a lot of other commands to manage applications including un-installation. The entire commands supported are available here. Instead, you can get the details in your command line using ‘choco -h.’
Hope that helps you save some time when you next want to install something.
Australia is known for its beaches, and there are a plenty of them all around. Sydney is no different for that, and it’s known for some of the world famous beaches including the Bondi beach. But at times it’s also good to try places other than beaches. Here is a list of such places around Sydney that is perfect for a day trip and not just limited to beaches.
The Grand Pacific Drive makes a perfect day out with one of the best drives and perfect scenery along the route. It starts from Royal National Park through Wollongong, Shellharbour, Kiama, Shoalhaven, Southern Highlands, Eurobodalla and ending at Sapphire Coast. Each one of those places have things enough to spend a whole day. You can either choose to do the entire drive or do each of these places on separate day trips. The Grand Pacific Drive site has all the details that you need to plan your trip. It also has a trip planner that makes planning easier.
Do make it one day for the sun rise at the Sea Cliff bridge. It’s amazing and worth waking up early enough to make it up there on time.
As the name suggests, the Fitzroy Falls spots a magnificent waterfall with a nice walking track along the sides. There are various lookouts to the waterfall along the walking track. There is also a cycling track from the falls to Kangaroo Valley for those interested.
Kangaroo Valley is a two-hour drive from Sydney and is popular for kayaking, canoeing, golf and wine tasting. You can take a break and play on the banks of the Kangaroo River. Do check out the Fudge House if you have a sweet tooth and the pie shop for a quick snack.
Situated in the Royal National Park, Audley boating provides a great experience along the Kangaroo Creek. You can hire a boat or ride a bike and enjoy the magnificent views.
If you want to see Kangaroos, then this is the place you should be. You can get close up with kangaroos and hundreds of them. It’s an experience that no zoo can provide. One of the Kangaroo spotting points is near the Morriset Hospital. Even on a rainy day, there were plenty of them so I am sure you would not miss out on it. There are a few other parks and places as well nearby where you can take a stroll and stand a chance of spotting one.
Situated on the banks of Hawkesbury River at Wisemans Ferry there are a couple of farms where you can go picking mandarins. I had been to the Watkins Family Farm and enjoyed every bit of it. It’s great fun for kids and equally for adults. We ended up going back there twice in the same season. Make sure you check the farm sites for details on timing and months they are open.
There are a few other picnic spots as well around the area. There is a vehicle ferry service to take your vehicle across the river and explore that side as well.
If you have kids, then a day out at one of the animal farms around Sydney is an excellent way to spend your day. Google should help you find the farms around you. The Calmsley Hill animal farm is a family friendly environment with daily shows, picnic and BBQ area. They often run some online offers so make sure you check that out before you head off.
The zoo is always a great place to spend time. The Taronga Zoo experience is no different. If you have not taken the Sydney Ferries before this is a good excuse to do that. It’s really big, and there are a lot of shows as well. Do check out the show times prior and plan for it upfront. It can be crowded at times. If you have kids getting an annual pass to the zoo might be worth.
Escape into the trees at the Illawarra Fly Treetops and enjoy the stunning views and the zipline experience. It is a perfect place for a day trip and equal fun for families. It offers a breath taking views and a great experience. Check out for online offers!
The Nan Tien Temple is the largest Buddhist temple in the Southern Hemisphere. It’s a calm and peaceful place and a nice spot to take your day off and relax. The temple offers many services including a guided tour. They run various retreats and meditation classes if you are interested. You can either choose to spend a whole day here or spend a few hours on the way to Illawarra Fly Tree Tops.
Ku-ring-gai Chase National Park combines important history with scenic beauty, making it perfect for a day out for families and kids. There are great picnic areas, heritage walks, lighthouse, boating, etc. There are not many shops around so get all that you need on the way.
Even though the main attraction here is a beach, there still are enough things other than that to make your trip worth while. Tuggerah Lakes Cycleway is an off-road, scenic 12-kilometre ride and is perfect to spend some time. Don’t miss out on the Pelican Feeding which happens at 3:30 pm every day all round the year.
These places make a perfect getaway for a day. Mix it up with some of the awesome beaches - Bondi, Palm, Wattamolla, La Perouse, Coogee, Ramsgate, Cronulla, etc. and it should be enough to keep all your weekends busy. What places did I miss? Sound off in the comments.
Have great weekends ahead!
With the blazing fast internet speeds at work (and at home) it might be hard to imagine how sites would work for people with a lower bandwidth. When developing for the Web, it is good to keep in mind that people from various regions across the globe might access your site. Internet speeds are not that fast around the world. So it is essential to test how your website performs for people on a lower bandwidth.
There are a lot of plugins and external tools that can simulate a lower bandwidth scenario and makes testing on slower bandwidth easier. If you are using Google Chrome, then you already have one such tool under your belt. The Network tab under Google Chrome Developer Tools has an option to set different bandwidth profiles. Setting this to a profile that you want, and launching the site forces the site load on the set bandwidth.
There are many default bandwidth profiles in there, and it also allows you to add custom profiles if required. There is also an option to simulate offline mode, to test how the application behaves without an internet connection (if that applies to you). However such testing is mostly restricted to manual testing, and for automating this, you might have to look for external tools.
Hope this helps optimize your site for lower bandwidth!
At one of my clients, we faced a strange issue recently. The Azure Web application restarted automatically very often. The event log in the Kudu console showed the below error message.
2017-07-13 00:09:50,333 [P45516/D4/T171] INFO Umbraco.Core.UmbracoApplicationBase - Application shutdown. Details: HostingEnvironment
_shutDownMessage=Directory rename change notification for ’D:\home\site\wwwroot’.
Overwhelming Change Notification in wwwroot
HostingEnvironment initiated shutdown
Directory rename change notification for ’D:\home\site\wwwroot’.
Overwhelming Change Notification in wwwroot
HostingEnvironment caused shutdown
As you can tell from the logs, the website is an Umbraco CMS hosted as an Azure Web application. We noticed that the restarts were happening more when the content was getting updated through backoffice. The error also states that the restart was caused due to Overwhelming Change Notification in wwwroot. This hints that there are changes that are happening under the wwwroot folder, where the site is hosted.
A quick search got me to the fcnMode.aspx)setting under httpRuntime.aspx) section. An ASP.net application monitors certain files and folders under the wwwroot folder and will restart the application domain whenever it detects changes. This likely look looks the reason why the web site is restarting.
- Default: For each subdirectory, the application creates an object that monitors the subdirectory. This is the default behavior.
- Disabled: File change notification is disabled.
- NotSet: File change notification is not set, so the application creates an object that monitors each subdirectory. This is the default behavior.
- Single: The application creates one object to monitor the main directory and uses this object to monitor each subdirectory.
1 2 3 4 5 6 7 8 9 10
FCNMode creates a monitor object with a buffer size of 4KB for each folder. When FCNMode is set to Single, a single monitor object is created with a buffer size of 64KB. When there are file changes, the buffer is filled with file change information. If the buffer gets overwhelmed with too many file change notifications an “Overwhelming File Change Notifications” error will occur and the app domain will recycle. The likelihood of the buffer getting overwhelmed is higher in an environment where you are using separate file server because the folder paths are much larger.
You can read more about fcnMode setting and how it affects ASP.Net applications here.
What’s causing file changes?
Default reaction when you come across such a setting or configuration value might be to turn that off and fcnMode does allow that as well - Disabled. But first, it is better that we understand what is causing file changes under the wwwroot folder and see if we can address that. The FCN Viewer helps visualize how many files and folders are being watched in as ASP.Net application.
In the Umbraco website, we are using a third party library ImageProcessor that helps to process images dynamically. The ImageProcessor caches images and the cache location is configurable. By default, it caches files under the App_Data/cache folder, which also happens to be one of the folders that the ASP.Net application monitors for changes. So anytime there are lots of files changing in the cache folder it causes the single monitor object monitoring the folders. This causes a buffer overflow and triggers an application restart due to Overwhelming file change notifications. However, ImageProcessor does allow moving the cache folder outside of the wwwroot folder. This causes the file not to be monitored and still work fine with the application. Since the library does not create the cache folder automatically, we need to make sure that the folder specified in the config file exists.
Having moved the cache folder outside of the wwwroot, I no longer need to update the fcnMode setting and can leave it as intended. If you are facing application restarts as well due to overwhelming change notification in wwwroot see what is likely causing the file changes and then try and fix that instead of just setting the fcnMode to disabled.
Hope that helps fix your application restarting problem!
Writing is hard work. A clear sentence is no accident. Very few sentences come out right the first time, or even the third time. Remember this in moments of despair. If you find that writing is hard, it’s because it is hard.
– William Zinsser, On Writing Well
Editing is the hardest part of writing and one that I skip the most. I try hard not to skip editing, but often I end up being lazy to do the hard work. I try to cover this up with some tools to make it faster. It is hard for one tool to get it all right. So it’s best if you have a range of tools under your belt to support you with writing.
The Hemingway Editor highlights hard to read sentences, adverbs, complicated phrases, etc. The writing app uses different colors to highlight the various issues as shown below. The editor also shows a summary of the text including the reading time, total words, sentences etc. The app also shows a Readability Grade using Automated Readability Index.
The Hemingway Editor is available for free on the web with lesser features. The web application does not let you save your work. You are always at risk of loosing the work if you are authoring on the site.
The Windows/Mac applications supports a larger set of features but for a price. The desktop application works without an internet connection, allows publishing to Wordpress/Medium. It also supports to exporting to different formats (word, pdf, html, markdown etc.).
I use the Hemingway Editor (on the web) occasionally and find it useful at times. It’s good to double check for any issues before publishing the post. Hope this helps you as well in your writing.
How to sign a PDF using Azure Key Vault? - This is one of the questions that I often get regarding Azure Key Vault. In this post, we will explore how to sign a PDF using a certificate in Azure Key Vault. Signing a PDF has various aspects to it which are covered in depth in the white paper - Digital Signatures for PDF Documents. We will be using the iText library to sign the PDF. iText is available as a Nuget package library. The below image shows the elements that composes a digital signature on the left and actual contents on the right.
Signing with a Local Certificate
When the certificate (along with the private key) is available locally, signing the PDF is straightforward. You can load the certificate as an X509Certificate from the local certificate store using the thumbprint. Make sure that the certificate is installed with the Exportable option as shown below.
The PrivateKeySignature is an implementation of IExteralSignature that can be used to sign the PDF when the private key is available. The below code signs the Hello World.pdf using the certificate from the local store and saves that as Local Key.pdf.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
Certificates in Azure Key Vault
You can manage certificates in Azure Key Vault as a first class citizen. Azure Key Vault supports creating new or uploading existing certificates into the vault. Key Vault provides an option to specify whether the private portion of the certificate is exportable or not. Let us see how we can use the certificate from the vault in both these scenarios.
To create a self-signed certificate in the vault use the below PowerShell script. In this case, the private key is exportable. Executing the below script adds a self-signed certificate into the vault.
Creating a certificate, in turn, creates three objects in the vault - Certificate, Key, and Secret. The certificate represents the certificate just created, the Key represents the private part of the certificate, and the Secret has the certificate in PFX format (just as if you had uploaded a PFX as a Secret). Since the certificate created above is exportable, the Secret contains the Private portion of the key as well. To recreate the certificate locally in memory, we use the below code
1 2 3 4 5 6 7 8 9 10 11 12
The certificate is encoded as Base64String in the Secret. We create an in-memory representation of the certificate and mark it as Exportable. This certificate can be used the same way as the local certificate. Since the private key is part of it, the PrivateKeySignature can still be used to sign.
Non Exportable Certificate
To create a non-exportable certificate when creating the certificate use KeyNotExportable flag flag as below.
Executing this creates three objects in the vault as above. But since we marked the secret as non-exportable, the Secret will not have the private part of the key. We can create an in-memory representation of the certificate, but we cannot use the PrivateKeySignature as the certificate does not have the private key. We need to use the Key created along with the certificate to Sign the PDF bytes. For this we need a custom implementation of IExternalSignature - KeyVaultSignature.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
KeyVaultSignature uses the key vault library to connect to the vault and use the specified key to sign the passed in PDF bytes. Since the key is the private part of the certificate, it will be validated by the public key. Below code shows how to use the KeyVaultSignature in the signing process.
1 2 3 4 5 6 7 8 9 10 11
Once you install and trust the public portion of the certificates, you can see the green tick, indicating that the PDF is verified and signed.
The sample code for all three scenarios is available here. I have used ClientId/Secret to authenticate with Key Vault for the sample code. If you are using this in a production environment, I will recommend using certificate to authenticate with Key Vault. iText supports creating PDF stamps and more features in the signing process, which is well documented. Hope this helps you to secure your PDF files.
Merging conflicts can be a pain when working in large teams and code bases change fast. Every time you sync with the main code base you need to make sure that you integrate the updates with your work in progress. It’s great when the changes get automatically merged by the source control systems. But when things need to be manually merged is where a good tool can be of help.
Beyond Compare allows you to quickly and easily compare your files and folders. By using simple, powerful commands, you can focus on the differences you’re interested in and ignore those you’re not. You can then merge the changes, synchronize your files, and generate reports for your records.
The Text Compare viewer is the one that I use most frequently to compare or merge different versions of code. Beyond Compare makes it easy to spot the code differences and gives the capability to copy the code from one version to another. One can also copy portions of changes and merge just that instead of all the changes. The 3-Way Text Merge feature is also useful, especially when you are using Git.
Beyond Compare is one of the tools that I use almost daily. Check it out if you have not already.
When it comes to mobile phones, I used to be a gadget freak and buy the latest phone as soon as it arrives in the market. But not after I got the Nexus 5. It’s been well over three years now and not even once did I want to switch over to something else. The phone never slowed down over these years, and the battery lasted enough for the day. I broke the Nexus screen a couple of months back and was forced to switch over to a new phone. I didn’t have to do much market research or phone comparisons this time; as I just knew which one to pick up.
The Pixel is the first phone in the Google Pixel hardware line and is a successor to the Nexus range of devices. The Pixel runs Android-Nougat with some features exclusive to it. The Pixel is very much comparable to the Nexus, with improved hardware and latest software. Below are some of the key features that I like about the phone.
Fingerprint sensor The fingerprint sensor on the back allows you to unlock the phone and specific apps and also authorize purchases. 1Password is integrated with the sensor which enables me to unlock it using the sensor. I no longer need to type in my long master password every time I use 1Password.
Camera Pixel takes brilliant photos in bright light, low light, and any light. The camera is awesome and at times is a good replacement for your DSLR. With Pixel, Google also provides unlimited original quality storage for all photos and videos.
Google Assistant Pixel is the first phone with the Google Assistant built-in. It helps you manage tasks, find content on phone and the internet, perform actions, etc. just like Siri or Cortana. I have not used the assistant much and yet to find some valid use cases.
Some of the apps that I use regularly are
- Todoist: My ToDo List
- Feedly: For all my RSS feeds
- Pocket: For offline reading and read later
- 1Password: Password Manager
- Buffer: To schedule articles to all social networks
- Rescue Time: Automatically tracks where I spent time on mobile
- Strava, Runtastic & Garmin Connect: Tracking my runs and exercises
- Kindle: Reading kindle books
- Twitter, Whatsapp, Messenger, Instagram, Skype & Yammer :Social Networking apps
- JotterPad: Write articles for blog in markdown format
- Google Indic Keyboard: Writing in my native language
- Gmail & Outlook: Emails
- Youtube: Videos
I am using the Spigen Neo Hybrid case for Pixel. It adds extra weight to the phone, but I am used to it from my Nexus as well. The Neo Hybrid provides military grade protection and protects the phone from most falls.
Overall I have found the Pixel a good phone and recommend it to anyone looking out for a new phone now. The Samsung Galaxy S8 is also of the same range (slightly costlier) and worth considering if you are not too particular about having a vanilla Android experience. Which phone do you use?