Saturday, 7 January 2017

Going offline for a few days.

I am taking a leave of absence from social and online activities for a while. This may be a long while. Gotta go.

Stay sharp. Stay classy. Keep learning.

Thanks for the support.

Thursday, 5 January 2017

Idea - Making mobiles understand the positional, situational, environmental context

Situation and Environment aware mobile devices.

Suppose as soon as you walk into an air plane, your phone will receive a signal from air plane to take it automatically to airplane mode. There will be nothing that you could do with it.

If phone is active, air planes would be able to sniff out the mode your phone is in.

This will save airliners from headache of telling users to not use mobile devices while inside.

But some planes already have connectivity available.

That’s fine. Those airplanes will not send the go to airplane mode signal.

What’s the benefit

Government offices, highly sensitive places would be able to enforce the mobile usage policy via device’s OS.

Think about it. A museum doesn’t want users to take photographs, so what it should do?

Send mobile devices message no camera and done!

No mobile device will be able to take photographs.

But what about other cameras.

Cameras are also mobile devices. You can move around while holding that picture taking device, thus mobile.

What else

There are infinitely many possibilities available. No more corporate espionage. No more security detail leak. No more distractions at work.

~FIN~

No more automatic ads

Google Ads suck. I am not going to put automatic advertisements from now. This strategy really sucked. Ads were shit.

 If you want your ads on this blog, contact directly. We can talk arrangements.


Base plate for mobile devices.

Think: what if mobile devices don’t have any port

This sounds weird. But really, what if mobile devices, laptops, smart phones, android phone, tablets etc do not have any port to connect to.

Envision a flat plate

This is of the size a little bigger than the 15 inches laptop. This plate has following features:
  1. Wireless power distribution.
  2. Data transfer via NFC
  3. High speed internet connection via NFC.
You connect your LAN wire, Gigabit wire, power cord, desktop monitor HDMI/VGA connector to it.
You attach headphones to it. Your device, be it a phone, tab or laptop, only has WiFi and bluetooth. You device doesn’t have any port. Let that sink in.
Your external hard disks are connected with home/base plate. Your router is connected to the plate. You put your device on the plate, and it charges it; transfers data, sync devices etc.

No wires.

Yes, there will be wires but not connected to your device ever!
You become completely mobile. You want to hear music, use bluetooth headphones. Bose has exceptional devices.
You want to watch videos from your external hard disk and cast it to TV? Put your hard disk on the plate and just cast.

No patents

That I know of. I am giving you this idea as it came to me. There is no ulterior motive other than sharing of a futuristic idea.
~FIN~

Monday, 26 December 2016

My public key

My public key




    -----BEGIN PGP PUBLIC KEY BLOCK-----
    Comment: GPGTools - https://gpgtools.org

    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
    =rk7H
    -----END PGP PUBLIC KEY BLOCK-----

Fingerprint


    9CB0 65E7 E6B9 138A AF8A  99F7 AEC3 943A F209 55EB

~Fin~

Sunday, 25 December 2016

Temperature conversion in JavaScript - KNRJS Series

Temperature conversion in JavaScript


    function fahrenheitToCelsius (fahr) {
        var celsius = 5 * (fahr - 32) / 9
        return celsius
    }

    function tableForFahrenheitToCelsius () {
        var start = -100
        var end = 100
        var step = 10
        for(var fahrenheit = start; fahrenheit < end; fahrenheit += step) {
            console.log(fahrenheit, fahrenheitToCelsius(fahrenheit))
        }
    }

    tableForFahrenheitToCelsius()

enter image description here

We can provide start, end and step range


    function tableForFahrenheitToCelsius (start, end, step) {
        for(var fahrenheit = start; fahrenheit < end; fahrenheit += step) {
            console.log(fahrenheit, fahrenheitToCelsius(fahrenheit))
        }
    }

    tableForFahrenheitToCelsius(-1000, 1000, 250)

enter image description here

Fix the number of digits shown after decimal


    function tableForFahrenheitToCelsius (start, end, step) {
        for(var fahrenheit = start; fahrenheit < end; fahrenheit += step) {
            console.log(fahrenheit.toFixed(1), fahrenheitToCelsius(fahrenheit).toFixed(1))
        }
    }

enter image description here

More conversion functions


    function fahrenheitToCelsius (fahr) {
        var celsius = 5 * (fahr - 32) / 9
        return celsius
    }


    function celsiusToFahrenheit (celsius) {
        var fahr = 9 * celsius / 5 + 32
        return fahr
    }

    function celsiusToKelvin (celsius) {
        return celsius + 273.15
    }

    function kelvinToCelsius (kelvin) {
        return kelvin - 273.15
    }

    function conversionTable () {
        console.log('Fahrenheit', '  in Celsius  ', '  back to Fahrenheit  ', '   kelvin   ')
        for(var i = -100; i < 101; i += 10) {
            var fahr = i
            var cel = fahrenheitToCelsius(fahr)
            var conFahr = celsiusToFahrenheit(cel)
            var kelvin = celsiusToKelvin(cel)
            console.log(fahr.toFixed(1), '        ', cel.toFixed(1), '        ', conFahr.toFixed(1), '                ', kelvin.toFixed(1))
        }
    }

enter image description here

We can organize code a bit better


    function celToKel (celsius) {
        return celsius + 273.15
    }
    function celToRan (celsius) {
        return (celsius + 273.15) * 9 / 5
    }
    function celToFah (celsius) {
        return 9 * celsius / 5 + 32
    }
    function kelToCel (kelvin) {
        return kelvin - 273.15
    }
    function kelToFah (kelvin) {
        return celToFah(kelToCel(kelvin))
    }
    function kelToRan (kelvin) {
        return celToRan(kelToCel(kelvin))
    }
    function ranToCel (rankine) {
        return 5 / 9 * rankine - 273.15
    }
    function ranToFah (rankine) {
        return celToFah(ranToCel(rankine))
    }
    function ranToKel (rankine) {
        return celToKel(ranToCel(rankine))
    }
    function fahToCel (fahrenheit) {
        return 5 * (fahrenheit - 32) / 9
    }
    function fahToKel (fahrenheit) {
        return celToKel(fahToCel(fahrenheit))
    }
    function fahToRan (fahrenheit) {
        return celToRan(fahToCel(fahrenheit))
    }

    var conversions = {
        celsius: {
            to: {
                kelvin: celToKel,
                rankine: celToRan,
                fahrenheit: celToFah
            },
            from: {
                kelvin: kelToCel,
                rankine: ranToCel,
                fahrenheit: fahToCel
            }
        },
        fahrenheit: {
            to: {
                celsius: fahToCel,
                kelvin: fahToKel,
                rankine: fahToRan
            },
            from: {
                celsius: celToFah,
                kelvin: kelToFah,
                rankine: ranToFah
            }
        },
        rankine: {
            to: {
                celsius: ranToCel,
                kelvin: ranToKel,
                fahrenheit: ranToFah
            },
            from: {
                celsius: celToRan,
                kelvin: kelToRan,
                fahrenheit: fahToRan
            }
        },
        kelvin: {
            to: {
                celsius: kelToCel,
                fahrenheit: kelToFah,
                rankine: kelToRan
            },
            from: {
                celsius: celToKel,
                fahrenheit: fahToKel,
                rankine: ranToKel
            }
        }
    }

A simple usage example

enter image description here

A temperature table of important tempratures


    // in Kelvin
    var absoluteZeroK = 0
    var brineFreezingPointK = 255.37
    var waterFreezingPointK = 273.15
    var waterTriplePointK = 273.16
    var waterBoilingPointK = 373.1339

    // in rankine
    var absoluteZeroR = conversions.rankine.from.kelvin(absoluteZeroK)
    var brineFreezingPointR = conversions.rankine.from.kelvin(brineFreezingPointK)
    var waterFreezingPointR = conversions.rankine.from.kelvin(waterFreezingPointK)
    var waterTriplePointR = conversions.rankine.from.kelvin(waterTriplePointK)
    var waterBoilingPointR = conversions.rankine.from.kelvin(waterBoilingPointK)


    // in celsius
    var absoluteZeroC = conversions.celsius.from.kelvin(absoluteZeroK)
    var brineFreezingPointC = conversions.celsius.from.kelvin(brineFreezingPointK)
    var waterFreezingPointC = conversions.celsius.from.kelvin(waterFreezingPointK)
    var waterTriplePointC = conversions.celsius.from.kelvin(waterTriplePointK)
    var waterBoilingPointC = conversions.celsius.from.kelvin(waterBoilingPointK)


    // in fahrenheit
    var absoluteZeroF = conversions.fahrenheit.from.kelvin(absoluteZeroK)
    var brineFreezingPointF = conversions.fahrenheit.from.kelvin(brineFreezingPointK)
    var waterFreezingPointF = conversions.fahrenheit.from.kelvin(waterFreezingPointK)
    var waterTriplePointF = conversions.fahrenheit.from.kelvin(waterTriplePointK)
    var waterBoilingPointF = conversions.fahrenheit.from.kelvin(waterBoilingPointK)

    console.log('absolute zero (in K, R, C, F)', absoluteZeroK.toFixed(2), absoluteZeroR.toFixed(2), absoluteZeroC.toFixed(2), absoluteZeroF.toFixed(2))
    console.log('freezing point of brine (in K, R, C, F)', brineFreezingPointK.toFixed(2), brineFreezingPointR.toFixed(2), brineFreezingPointC.toFixed(2), brineFreezingPointF.toFixed(2))
    console.log('freezing point of water (in K, R, C, F)', waterFreezingPointK.toFixed(2), waterFreezingPointR.toFixed(2), waterFreezingPointC.toFixed(2), waterFreezingPointF.toFixed(2))
    console.log('triple point of water (in K, R, C, F)', waterTriplePointK.toFixed(2), waterTriplePointR.toFixed(2), waterTriplePointC.toFixed(2), waterTriplePointF.toFixed(2))
    console.log('boiling point of water (in K, R, C, F)', waterBoilingPointK.toFixed(2), waterBoilingPointR.toFixed(2), waterBoilingPointC.toFixed(2), waterBoilingPointF.toFixed(2))

enter image description here

Compare it with values on this table given on Wiki

enter image description here

References

  1. https://en.wikipedia.org/wiki/Rankine_scale
  2. https://en.wikipedia.org/wiki/Fahrenheit
  3. https://en.wikipedia.org/wiki/Absolute_zero
  4. https://en.wikipedia.org/wiki/Celsius
  5. https://en.wikipedia.org/wiki/Kelvin
  6. https://en.wikipedia.org/wiki/Triple_point
  7. https://en.wikipedia.org/wiki/Boiling_point
  8. https://en.wikipedia.org/wiki/Brine

~Fin~

Hello World in JavaScript - KNRJS Series

Hello World in JavaScript


    function sayHello () {
        console.log('Hello, World!')
    }

To get Hello, World! printed we would need to call this function as sayHello().

Try this in browser console.

We can return from a function too


    function returnHello () {
        return 'Hello, World!'
    }

Call this function as returnHello() in your browser console or node console.

We can make greetings generic


    function hello (greet) {
        console.log('Hello, ' + greet + '!')
    }

Call this function with hello() first and then with hello('World').

Errors

Remove quotation marks


    function sayHello () {
        console.log(Hello, World!)
    }

This function should fail with a syntax error.

enter image description here

It did! This is because Hello, World! has no meaning in JavaScript till now. Also, ! will create a problem too.

Define Hello and World


    function sayHello () {
        var Hello = 'Hello'
        var World = 'World'
        console.log(Hello, World!)
    }

This again will be same error, even though we have solved some issues.

enter image description here

Let’s solve this bug.


    function sayHello () {
        var Hello = 'Hello'
        var World = 'World'
        console.log(Hello, World)
    }

This works!

enter image description here

Let’s remove only one quotation mark


    function sayHello () {
        var Hello = 'Hello
        var World = 'World'
        console.log(Hello, World)
    }

That’s a syntax error too.

enter image description here

We can continue lines by putting \ at end


    function sayHello () {
        var Hello = 'Hello\
        var World = 'World'
        console.log(Hello, World)
    }

But this still will be error as now Hello becomes Hello var World =

enter image description here

But you will notice that the error is subtly different. It’s still of the type SyntaxError but now it is complaining about Unexpected Identifier; earlier it was about Invalid or unexpected token.

Let’s try removing () from function call


    function sayHello () {
        var Hello = 'Hello'
        var World = 'World'
        console.log(Hello, World)
    }

    sayHello

enter image description here

If you notice, removing () doesn’t cause an issue but doesn’t do anything. All it does on console is that it prints the function definition.

sayHello() however calls the function.

~Fin~