Category Archives: Blog

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