Google+(chromecast, android) like wallpapers for your mac desktop

Donwload and install Google’s Featured Photos Screensaver on your mac first and select that from your Change Desktop Background > Screensaver.

Run this command from your terminal.

nohup /System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background > /dev/null 2>&1 &

You can create shell or application out of this command and run it at the time of startup.

In order to run this script at startup, create an app with Mac Automator application as given below (Library > Run Shell Script)

Save that as an application and run it on startup as given below, goto System Preferences > Users & Groups.

And you will have all google+ wallpapers for your mac on startup.

Google Apps Script, How to import gs functions across other Google docs

Go to .gs file/project(Tools>Script editor..) which you want to use as a library.

Save file with the version at File>>Manager versions.

Copy project key from this menu location File>>Project properties>>Project key

Go to your second .gs file/project and add previous project key as a library at menul Resources>>Libraries…

“Add a library” -> click on Add button -> click on Save

Add identifier for this library once library is added with Resources>>Libraries… menu.

Now you can use functions from previous project/library with this identifier inside your local function.

Identifier.functionFromImportedLibrary();

REST Mock API Server Example

Integration projects require APIs contract and implementation to carry out integration work. Once contract is defined you need API end point from other project/service to finish your work.
If you dont get it on time, you are kind of stuck, what can you do? Create your own API end point and finish your side of implementation by changing your url end point to something local. That local service should be your mock service which gives you desire results same as like actual APIs.

MockServer is one of such library which can allow you to mock your thirdparty or dependent APIs.

Take a look of below easy example.

import org.mockserver.client.server.*;
import org.mockserver.model.*;
import static org.mockserver.integration.ClientAndServer.*;
import static org.mockserver.model.HttpRequest.*;
import static org.mockserver.model.HttpResponse.*;
import static java.util.concurrent.TimeUnit.*;

public class DummyPOSTService {
	public static void main(String[] args) {
		MockServerClient mockServer = startClientAndServer(1100);

		mockServer
	        .when(
	        		request()
                    .withMethod("POST")
                    .withPath("/test")
                    .withHeader("authorization", "dummy")
	        )
	        .respond(
	        		response()
	        		.withStatusCode(200)
                    .withHeaders(
                            new Header("Content-Type", "application/json; charset=utf-8"),
                            new Header("Cache-Control", "public, max-age=86400")
                    )
                    .withBody("{ 'test': 'abc' }")
                    .withDelay(new Delay(SECONDS, 1))
	        );
	}
}

You need this jar in order to run above class.

<a href="http://search.maven.org/remotecontent?filepath=org/mock-server/mockserver-netty/3.10.4/mockserver-netty-3.10.4-jar-with-dependencies.jar">mockserver-netty-3.10.4-jar-with-dependencies</a>

mock-api-server

RestEasy 3.0.x implementation with your existing servlet based web application

Web.xml entry:

<context-param>
		<param-name>resteasy.servlet.mapping.prefix</param-name>
		<param-value>/rest</param-value>
	</context-param>
 <context-param>
		<param-name>resteasy.resources</param-name>
		<param-value>com.abc.xyz.UserREST</param-value>
	</context-param>
    <servlet>
        <servlet-name>resteasy-servlet</servlet-name>
        <servlet-class>
            org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
        </servlet-class>
    </servlet>  
    <servlet-mapping>
		<servlet-name>resteasy-servlet</servlet-name>
		<url-pattern>/rest/*</url-pattern>
	</servlet-mapping>

Your REST class:

package com.abc.xyz;

import javax.ws.rs.*;

@Path("/Users")
public class UserREST {

	@GET
	@Path("/getUserById")
	public String doGet(@QueryParam("userId") String userId, @HeaderParam("authorization") String sessionToValidate)
			throws Exception {
			return "SomeString";
	}
}

Minimum jar files needed from jboss resteasy 3.0.19 bundle:

resteasy-jaxrs-3.0.19.Final.jar
jboss-jaxrs-api_2.0_spec-1.0.0.Final.jar
jboss-logging-3.1.4.GA.jar

And call : http(s)://yourhost:port/yourapplication/rest/Users/getUserById?userId=xx
You may choose to pass your own authorization in header, use Postman, but you can ignore it also.

Angularjs code to display dynamic fields binding in html

  	<div ng-repeat="field in questionElements">    
  	  	<ng-form name="form">
  			<label>{{field.question}}</label>
    			<!-- TEXT FIELDS -->
    			<div ng-if="field.type=='textfield'" class="form-group" >
        			<input type="{{field.type}}" dynamic-name="field.id" id="{{field.id}}" data-ng-model="field.answer" class="form-control"/>
      			</div>
      			
      			<!-- SELECT FIELDS -->
			    <div ng-if="field.type=='dropdown'" class="form-group" >
			        <select data-ng-model="field.answer" dynamic-name="field.id" class="form-control" />
			        	<option ng-repeat="option in field.options" value="{{option.key}}">{{option.value}}</option>
			        </select>
			    </div>
      			
      			<!-- RADIO FIELDS -->
			    <div ng-if="field.type=='radio'" class="form-group">
			    	<div class="form-control" ng-repeat="option in field.options" >
			            <input type="radio" data-ng-model="field.answer" id="{{option.key}}" name="{{option.key}}" value="{{option.key}}" >{{option.value}}<br/>
			      	</div>
			    </div>
			    
			    <!-- CHECKBOX FIELDS -->
			    <div ng-if="field.type=='checkbox'" class="form-group">
			    	<div class="form-control" ng-repeat="option in field.options" >
			            <input type="checkbox" data-ng-model="option.answer" id="{{option.key}}" name="{{option.key}}" value="{{option.value}}" >{{option.value}}<br/>
			      	</div>
			    </div>
      			
      		</ng-form>
      	</div>

RallyDev rule based reminder for team

If your project is rally based and your team constantly needs reminder to put information for defects they have fixed, you can use this tool.
Tool goes through your rally defects and check each defect against configured set of rules. If it falls under one or more case it will send notification to project team and owner of the defect to fix those issues in Rally.
You can define as many custom rules you want for as many rally defect fields. There is no limitation for rule condition size as well.

For example:

If defect state is fixed made and resolution description is not filled by developer of that work, he will get this in notification as a reminder.

DEFECT_STATE == FixMade AND (RESOLUTION == BLANK OR RESOLUTION_DESCRIPTION == BLANK), Resolution should not be blank when state is fix made 
DEFECT_STATE == FixMade AND FIXED_IN_BUILD == BLANK,Found In Build should not be blank when state is fix made

For more you can download opensource tool from below github.

https://github.com/dharmeshb/RallyRuleBasedReminder/wiki

A Raspberry PI – DC motor, stepper motor, ultra sonic sensor project

I was in Cloudera Hadoop Developer training recently and there was interesting discussion on how low cost computer like raspberry PI can be used to setup Hadoop cluster for developer testing and proof of concepts. I started digging into that but in parallel i’ve decided to use such low configured CPU to do some robotics projects.

Here is the first project i recently finished with Raspberry PI.
A self-trajectory motor vehicle. It has its own brain(not remote controlled) coded in python language to make all decisions.
It runs on two external power sources, 12V and 5V. 12V to rotate main DC motors while 5V for CPU processing, stepper motor movements and for obstacle sensing(ultrasonic sensor). PI is operating those motors through two L298N circuit board.

Scroll for code below.

Raspberry_PI_motor1

Raspberry_PI_motor2

Raspberry_PI_motor3

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)

#GPIO.cleanup()

wheel1A=27
wheel1B=10
wheel2A=17
wheel2B=22

eye1A=7
eye1B=8

eyeWA=6
eyeWB=13
eyeWC=19
eyeWD=26

GPIO.setup(wheel1A, GPIO.OUT)
GPIO.setup(wheel1B, GPIO.OUT)
GPIO.setup(wheel2A, GPIO.OUT)
GPIO.setup(wheel2B, GPIO.OUT)
GPIO.setup(eye1A, GPIO.IN)
GPIO.setup(eye1B, GPIO.OUT)

#eyes
GPIO.setup(eyeWA,GPIO.OUT)
GPIO.setup(eyeWB,GPIO.OUT)
GPIO.setup(eyeWC,GPIO.OUT)
GPIO.setup(eyeWD,GPIO.OUT)

def spinRight():
        print('SR')
        GPIO.output(wheel1A,1)
        GPIO.output(wheel1B,1)
        GPIO.output(wheel2A,0)
        GPIO.output(wheel2B,0)
def spinLeft():
        print('SL')
        GPIO.output(wheel1A,0)
        GPIO.output(wheel1B,0)
        GPIO.output(wheel2A,1)
        GPIO.output(wheel2B,1)
def goForward():
        GPIO.output(wheel1A,1)
        GPIO.output(wheel1B,0)
        GPIO.output(wheel2A,0)
        GPIO.output(wheel2B,1)
def goBackward():
        GPIO.output(wheel1A,0)
        GPIO.output(wheel1B,1)
        GPIO.output(wheel2A,1)
        GPIO.output(wheel2B,0)
def stop():
        GPIO.output(wheel1A,0)
        GPIO.output(wheel1B,0)
        GPIO.output(wheel2A,0)
        GPIO.output(wheel2B,0)

##stepper_motor_start
delay = 0.015
cSteps=0
def setStep(w1, w2, w3, w4):
        GPIO.output(eyeWA, w1)
        GPIO.output(eyeWB, w2)
        GPIO.output(eyeWC, w3)
        GPIO.output(eyeWD, w4)
def rotateLeft(steps,check):
        global cSteps
        for i in range(0, steps):
                print('L'+str(cSteps))
                setStep(1,0,1,0)
                time.sleep(delay)
                setStep(0,1,1,0)
                time.sleep(delay)
                setStep(0,1,0,1)
                time.sleep(delay)
                setStep(1,0,0,1)
                time.sleep(delay)
                cSteps=cSteps-1
                if(check==True and checkDistance()!=-99):
                        return 1
        return 0

def rotateRight(steps,check):
        global cSteps
        for i in range(0, steps):
                print('R'+str(cSteps))
                setStep(1,0,0,1)
                time.sleep(delay)
                setStep(0,1,0,1)
                time.sleep(delay)
                setStep(0,1,1,0)
                time.sleep(delay)
                setStep(1,0,1,0)
                time.sleep(delay)
                cSteps=cSteps+1
                if(check==True and checkDistance()!=-99):
                        return 1
        return 0
##stepper_motor_end

##eye_start
def checkDistance():
        GPIO.output(eye1B,1)
        time.sleep(0.00001)
        GPIO.output(eye1B,0)
        while GPIO.input(eye1A)==0:
                pass
        start = time.time()
        while GPIO.input(eye1A) == 1:
                pass

        stop=time.time()
        distanceCM = (stop - start) * 170 * 100
        #print distanceCM
        #if distanceCM < 50 and (distanceCM <5 or distanceCM > 8):
        if distanceCM < 50:
                return -99

arrow = 'F'
findPath ='F'
skip='F'
maxRotate=6 #must be even number
while(1==1):
        #print(arrow)
        if(arrow=='SL'):
                spinLeft()
        if(arrow=='SR'):
                spinRight()
        if(arrow=='B'):
                goBackward()
        if(arrow=='F'):
                goForward()
        if(arrow=='X'):
                stop()
                if(findPath=='T'):
                        skip='T'
                        cSteps=0
                        found=rotateLeft(maxRotate, True)
                        if(found==0):
                                print('No left')
                                found=rotateRight((maxRotate*2) + 1, True)
                                if(found==1):
                                        rotateLeft(cSteps, False) #return eye to the front
                                        spinRight()


                        else:
                                print('Found something in left')
                                if(cSteps<0):
                                        cSteps = cSteps * -1
                                rotateRight(cSteps, False) #return eye to the front
                                spinLeft()
                        print('done........')
                        arrow='F'
                        findPath=''
                        setStep(0,0,0,0)
                        time.sleep(0.1)
                time.sleep(0.5)
        else:
                time.sleep(0.125)
        #arrow=raw_input("")

        if skip=='F' and checkDistance()==-99:
                arrow='X'
                findPath='T'
        else:
                skip='F'
        #if distanceCM > 200:
        #       arrow='F'

Magicjack 42 connection error

When you connect your magicjack with your router, you may face this problem where it says connection 42 error when you try to make a call.

You need to setup port forwarding for your magicjack with your router so that connection can be established outside.

What details do you need?
– External Static IP
– MAC address of magicjack device
– Router configuration access(credentials)

Please note this is vary depends on your router. I use Motorola.

1> Assign your magicjack with unique IP within your home/business network. You can do that with your DHCP router configuration. In my case it like below.

Mack
Mack

2> Once your magicjack is assigned with unique internal static IP, you will require to setup port forwarding with your outside static IP as given below for two ports 5060 and 5070.

MJG_PF

Big Data vs RDBMS

Two years back, i was preparing some MapReduce code to satisfy my curiosity towards algorithm and big data technologies like Apache Hadoop.
I knew this is something really required. At that time, trend for big data technologies was picking up and we started hearing about more on it. I was reading some article and facts that 90% of world total data was added in last two years, i am sure by this time it is more towards mid or late 90s.

Here is the trend of last few years of big data technologies and RDBMS. Of course, i can not compare it with Oracle or MS databases but trend is spiked up and it will continue like this.

Good time to invest in those technologies for developer like us.

bigdata_technologies

Apache HTTP Server Configuration For ProxyPassReverseCookiePath

Working with SOA project, there was requirement to keep web UI interfaces, i.e. angular JSs and htmls, and APIs decoupled physically for development and for deployment.
Presentation implementation calls micro services to authenticate users. This requires special care at Apache Server, aka load balancer. Once authenticated, UI project should get coockies generated by web server so that it does not go in authentication loop.

This is what i did:

ProxyPass /service ajp://localhost:8088/service

ProxyPass /projectname/service ajp://localhost:8088/service
ProxyPassReverseCookiePath /service /projectname

ProxyPass /projectname ajp://localhost:8088/ui