Author Archives: Alexander Shakhov

Disable ReadyBoost encryption and compression

By default Microsoft Windows uses compression and encryption for ReadyBoost caches. It’s fine unless your CPU resources are very limited. There is a way to create ReadyBoost cache that is not compressed nor encrypted to save some CPU cycles. According to Microsoft docs encryption cannot be disabled on removable devices, only on fixed internal ones. There are ways to make USB drive appear as fixed drive instead of removable drive that worked for me.

If you are trying to create persistent ReadyBoost cache that can survive restart your are out of luck this will not allow this. In case you use Windows 10, ReadyBoost cache can survive shutdown but not the restart.

This is undocumented behavior, please consider that this can have some side effects and use it on your own risk.

  1. Disable ReadyBoost on target device if you have enabled it before
  2. Open regedit
  3. Create registry key HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\UnattendSettings\Microsoft-Windows-SystemMaintenanceService\CacheList\Cache1
  4. Create 5 DWORD values in HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\UnattendSettings\Microsoft-Windows-SystemMaintenanceService\CacheList\Cache1
    1. CacheSizeMB = 500 (Size of your cache in megabytes, make sure to use decimal value not heximedical)
    2. DiskID = 1 (ID of the disk where cache will be placed, use diskpart.exe to find correct disk id)
    3. PartitionID = 1 (Partition id where cache will be placed, use diskpart.exe to find correct partition id, most USB flash drives have only one partition so in 99% of the cases it will be 1)
    4. EnableCompression = 0 (1 – enable cache compression, 0 disable cache compression)
    5. EnableEncryption = 0 (1 – enable cache encryption, 0 disable cache encryption)
  5. Execute this command in administrative command prompt –
    “%WINDIR%\SYSTEM32\RUNDLL32.EXE” sysmain.dll,PfSvUnattendCallback specialize
  6. ReadyBoost.sfcache cache file is created on Disk 1, Partition 1. EMD.dat hidden system protected file is created near the ReadyBoost.sfcache file. EMD.dat files contains compression and encryption settings. Because EMD.dat is system protected file it’s not visible by default in explorer. You can show all files by changing view settings.

To verify that your cache has disabled compression you can check ReadyBoost performance counters:

  1. Press Win+R and type perfmon than click Ok
  2. Click on red cross to remove all existing performance counters
  3. Click on green plus to add new counters
  4. Select ReadyBoost and click Add
  5. Click OK
  6. Find “Compression Ratio” performance counter and observer its value
  7. If compression is disabled that “Compression Ratio” will be greater or equal to 100, for me it’s now 103.25 

 

 

Use Android GPS on Chromebook

Most of the Chrome OS based devices don’t have GPS hardware and none of them have GPS software support. This is lacking when you traveling with you laptop and would like to use it for navigation instead of your phone. Imagine your are the driver and your friend uses full version of Google Maps to check nearby places and sightseeing spots while your are traveling.

GPS Link is created to solve this. It allows you to share data from GPS receiver inside your Android device with Chrome browser running any platform. All you need is to install GPS Link Chrome extension, GPS Link Android app and pair them together. Both required internet connection to work. After pairing GPS Link Chrome extension  transparently redirects all location requests from Google Maps or any other mapping application running in your browser to your Android device.

Most of the popular mapping services are supported by GPS Link:

To get started:

  1. Install GPS Link Chrome extension and GPS Link Android application. You can get them from Chrome Web Store and Google Play. Instruction are on GPS Link home page.
  2. Open your favorite maps web page in Chrome and click on the GPS Link extension button.
  3. Pairing screen with pairing link should popup. Open URL on your Android device with GPS Link app installed.
  4. Now “My Location” button on maps webpage will fetch location from Android device.

Minify inline JavaScript in ASP.NET MVC with WebGrease

ASP.NET 4.5 comes with great new feature to make web faster – JavaScript bundling and minification. It allows to bundle multiple js file into one and minfiy them.

This works great for external JavaScript files but what about inline scripts? There is library BundleMinifyInlineJsCss to do this but it has two downsides:

  1. It has to parse whole page to find all scripts so some unncessary overhead is added.
  2. It bundles all inline scripts into single script before body closing tag and does not respect script dependecies on external scripts.

Here is solution to minify inline JavaScript that work with ASP.NET MVC Razor View engine with less overhead and more granular control.

  1. If you are using System.Web.Optimization and Bundles you are all set  beacuse it comes with WebGrease.dll that we will use for minification otherwise you can get it here – WebGrease NuGet package.
  2. We will use this helper
    using Microsoft.Ajax.Utilities;
    using System;
    
    namespace System.Web.Mvc
    {
        public class HtmlHelperExtensions
        {
            public static MvcHtmlString JsMinify(
                this HtmlHelper helper,
                Func<object, object> markup)
            {
                string notMinifiedJs =
                    (markup.DynamicInvoke(helper.ViewContext) ?? "").ToString();
    
                var minifier = new Minifier();
                var minifiedJs = minifier.MinifyJavaScript(notMinifiedJs, new CodeSettings
                {
                    EvalTreatment = EvalTreatment.MakeImmediateSafe,
                    PreserveImportantComments = false
                });
                return new MvcHtmlString(minifiedJs);
            }
    
        }
    }
  3. And inside your Razor view:
     <script type="text/javascript">
               @Html.JsMinify(@<text>
            window.Yk = window.Yk || {};
            Yk.__load = [];
            window.$ = function (f) {
                Yk.__load.push(f);
            }
            </text>)
    </script>
  4. When view is rendered you get minified version:
        <script type="text/javascript">
               window.Yk=window.Yk||{},Yk.__load=[],window.$=function(n){Yk.__load.push(n)}
        </script>

You can fine tune minification using CodeSettings object passed to minifier. As far as performace in concerned on average development machine it usually takes less that 1 millesecond to minify single inline script.

Debugging Android applications remotely

In this article we will try to setup Android device for remote debugging over the Internet. This will allow you to connect to your development machine from anywhere and debug your android apps on your device as it would be connected to your development machine using USB – run applications from IDE, debug and stop on breakpoints, view log cat output and basically everything that Android Debug Bridge allows. Continue reading

Wake on LAN for Google Apps

Google Apps logoGoogle Apps is great framework for your business and provides ready-to-use application to cover most of the business flows in your organization. However there is no way to fulfill every single need of even small organization and custom solutions are often required.

Most of business face two questions when using Google Apps:

  • How we can integrate Google Apps with our organization internal systems?
  • How we can add custom features to Google Apps services to better suite our need?

The answer to both of the questions  is Google Apps Script. Continue reading

Hosting a website on a Raspberry Pi

Raspberry PIThis website is hosted on small ARM based computer called Raspberry PI. Raspberry Pi is Linux based PC with 800 MHz ARM CPU and 512 MB of RAM. Its performance can be compared to the modest smartphone available in 2013. The most interesting thing about Raspberry Pi is its price – 35$ for the board, and almost no power consumption.

Despite that CleanSoft in specialized in .NET development we decided to try out this idea and dive into Linux, PHP, MySQL world. Our goal was to create web server with as little maintenance required as possible and with full control over environment. Shared hosting environments are cheap but doesn’t provide control over operating system, cloud based hosting or dedicated server is too expensive to run website like this. Continue reading