Friday, May 6, 2016

Notes on Docker

In a Docker installation on Linux, your machine is both the localhost and the Docker host. In networking, localhost means your computer. The Docker host is the machine on which the containers run.

Container runs the selected OS image.


Quick Start:


  1. Download and Install Docker toolbox
  2. Make sure Virtual box is installed, it is included in Docker Toolbox
  3. For troubleshooting: http://stackoverflow.com/questions/33725779/failed-to-open-create-the-internal-network-vagrant-on-windows10
  4. Follow below steps to Create a new Docker VM


set PATH=%PATH%;"C:\Program Files\Git\bin"


docker-machine create --driver virtualbox my-default


Setting Proxy on Windows

Method-1

In Docker Toolbox install folder identify start.sh file and include following lines

#export HTTP_PROXY=http://example.com:80

#export HTTPS_PROXY=https://example.com:80
Close and open Docker Quickstart Terminal.

Method-2

  1. Connect to Docker machine
  2. Connect 
    • docker-machine ssh default
  3. sudo vi /var/lib/boot2docker/profile
    • HTTP_PROXY=http://example.com:80
    • HTTPS_PROXY=https://example.com:80
  4. Restart the docker-machine

Starting Kitematic using proxy


for /f %%i in ('docker-machine.exe ip default') do set DOCKER_HOST=%%i

SET NO_PROXY=%DOCKER_HOST%

set DOCKER_HOST=tcp://%DOCKER_HOST%:2376
cd Kitematic
Kitematic.exe

Saving and Loading images to and from file system

Saving sample:
docker export - saves a container's running or paused instance to a file

docker save - saves a non-running container image to a file
docker save -o <save image tar file> <image name>

Loading sample:
docker load -i <path to image tar file>

Docker Commit (Save Changes Locally):
sudo docker commit container_id image_name : commit changes made to a local docker container to save any changes made locally.

Thursday, May 5, 2016

Smart Accelerator

This idea is about automobiles with wrong accelerator press detection and collision prevention technology.

This leverages radar sensor's on the vehicle which provides the distance between your vehicle and vehicle's in front of you. Based on your current speed if you mistakenly pressed accelerator instead of break then based on above described acquired details it is trivial for the system to identify whether it is a wrong accelerator press. If it is a wrong press then it will be curtailed from being applied really on the vehicle and prevents a dangerous accident. 

Sky Eye - Eye in the Sky

Source: www.freedesignfile.com
Here I am talking about new technology idea which helps police and other security personal in chasing and pursuing the suspects who are trying to escape in fast moving vehicles.

Let us take a scenario where in a police officer is trying to chase and catch fast moving car which jumped the traffic checkpoint without going through the check. Let us assume there is lot of traffic on the road and police car is unable to overtake the offender car and is gradually losing it.

Now this police officer can switch on the sky eye and mark the fast moving car, from here on the sky eye also starts tracking the offender with much more speed than the offenders speed and relay the movements, coordinates and video to the pursuing police officer. 

Sky eye is an expert system running on police force's servers, it heavily leverages advanced GPS capabilities to track the vehicle direction, speed and vehicle identification marks such as color, make, model, registration number etc. It uses machine learning techniques to remember the pursuing vehicle and differentiate it from other surrounding vehicles and identify it. GPS would be feeding the video of the circular area for the given coordinates & radius provided by and to the Sky Eye. Sky Eye would estimate the next possible circular area where the vehicle would be present in the next time period based on the last scanned speed of vehicle, this coordinates are given to GPS to get the video and vehicle is identified from the video and this process continues until vehicle stops. All these identified vehicle trace coordinates and video's are relayed to ground force in real time for pursue.

This automated system could be used in unmanned check posts to track the offending vehicle and report to the nearest police station with all the trace details.

Thursday, February 11, 2016

Database 101 FAQ


  1. To get Oracle DB size in GB's:

    select sum(bytes/1024/1024/1024) from dba_data_files;
  2. Pagination in Oracle

    select * from ( select rownum rnum, a.* from (YOUR_QUERY) a where rownum <= :M ) where rnum >= :N;
  3. continued

Wednesday, February 10, 2016

Daily Life Hacks - 1

Scenario: If you are a trainer and had to be given training on a subject which is new to you or you don't have much experience. But you don't want to expose your proficiency on the subject to your audience.

Problem: In the subject there are few areas which you are not sure of or there are not clear to you.

Solution: If you are very confident on other areas of the subject and confidently accepting the unknown topics is good thing to do. But if you think this list is increasing :) then you can try below explained technique.

Order your lecture in a structured way so that you would be dealing with a single topic at time. In a particular topic when you come across with not so sure or confident areas then you can say that we will come back to this later when we deal with this. This way you escape the revelation and avoid those areas/concepts.

Thursday, January 7, 2016

Object Oriented Java Script

Below is the best sample for declaring makeCounter class and creating two objects counter1 and counter2 of the same.

Here this class returns three closure functions increment, decrement and value which share a common environment consisting of one private variable privateCounter and private method changeBy.

var makeCounter = function() {
  var privateCounter = 0;
  function changeBy(val) {
    privateCounter += val;
  }
  return {
    increment: function() {
      changeBy(1);
    },
    decrement: function() {
      changeBy(-1);
    },
    value: function() {
      return privateCounter;
    }
  }  
};

var counter1 = makeCounter();
var counter2 = makeCounter();
alert(counter1.value()); /* Alerts 0 */
counter1.increment();
counter1.increment();
alert(counter1.value()); /* Alerts 2 */
counter1.decrement();
alert(counter1.value()); /* Alerts 1 */

alert(counter2.value()); /* Alerts 0 */


Closure

It is an inner function that has access to the variables/ of outer function.

Closures can be used to allow public functions to access private methods and variables.

* Took notes from http://developer.mozilla.org