I got to know about a job in Malaysia in the month of March while I was working at Virtusa. At that point I didn't know in which company I would be working in, but I wanted to work in a foreign country so applied. Days later I got a call from an agent in Sri Lanka that some people would be coming down from Malaysia for the interview and I would be called within 2 weeks time. To be honest I wasn't sure of what he said but kept my fingers crossed.
Right after two weeks I did get a call from the agent saying I have an interview on 4th of April at Galadari Hotel Colombo. I went there and there were three people from Malaysia from the company MIMOS including the CTO.
MIMOS is Malaysia's National Research and Development Institute for ICT. It comes directly under the purview of MOSTI, Ministry of Science, Technology and Innovation. It seemed a really good offer for me and I did quite well in the interview due to my preparedness. The CTO was impressed of my little Arduino Projects and during the interview I knew that I had at least 70% chance of getting in.
After two more weeks I got the news that I have been selected out of 14 interviewees as one of the potential employees. I was over the moon and started preparing to come to Malaysia. After more than one month of preparing I finally landed in Malaysia on 02nd of June 2013 at 7:15 a.m.
Now I am temporarily residing at Bukit Jalil which is closed to Technology Park Malaysia which is where MIMOS is located.
All thanks to god for giving me such a wonderful opportunity.
In a previous post I showed the RC Car I bought and the internals of it. As I mentioned, there was a RX 2 Chip inside the Car but the pin layout was not exactly same as it is mentioned in the datasheet. So I had to ask my wife for help in controlling the car from the remote control and used a multimeter to find out which pins are being activated for each command. The datasheet mentioned that;
Pin No 11 = Forward
Pin No 12 = Backward
Pin No 6 = Right
Pin No 7 = Left
But as it turns out
Pin No 6 is Left and Pin No 7 is Right. So after finding those out I soldered required wires to the Circuit and hoping to work more on that.
Web Services are everywhere and so widely used today. There are several types of Web Services but most widely used ones are SOAP based, REST based web services. I am not going to defferentiate the two here but SOAP based Web Services are much more widely used than REST based mainly because of their reliability and security.
I am not going to implement a fully fledged web service here but just to provide some additional security measures that can be implemented to secure your web services. Nope this not about Authentication and Authorization. Those needs to be implemented anyhow.
According to the famous US based Internet Application security vulnerability testing company Veracode, web services must only expose their WSDL, XSD only to their intended and authorized consumers. This enables the information web services expose to be really limited to people who are intended to use those. But by default web services allow to see the WSDL and XSD by calling the below url.
This can be restricted by writing a Servlet Filter similar to the below one which Expects Query Strings to be Base64 Encoded and have the format like below
ServiceDefinition#1234567890
1234567890 can be replaced with a timestamp in milli seconds so that the Encoded string will be different each time.
Restricts the exposure of the Web Service WSDL to intended consumers only. But for this to work the web services must use HTTPS. If not just Base64 encoding wouldn't suffice. Then it needs to be encrypted before Base64 encoded.
Few weeks ago I wrote my first Android Jelly Bean App named ColorChanger. Since then I wanted to integrate it with Arduino and Control a physical RGB LED Light from the ColorChanger Android App. I finally managed to get it done using the following Items.
Arduino Mega 2560 Rev 3
DFRobot USB Host Shield
Arduino IDE 0023
ADK Library
1 RGB LED
1 1k Resistor
Few Jumper Cables
One USB to Micro USB Cable
Few things changed from the original ColorChanger App starting from the AndroidManifest.xml where I had to allow my MainActivity to listen for USB_ACCESSORY_ATTACHED intent action and when my Accessory connects open the ColorChanger App.
jqgrid plugin is one of the most famous jquery plugins to display tables in web pages which enables searching, sorting and filtering etc.
I wanted to integrate jqgrid with Struts2 but there was little to no proper documentation on how to do it. I wanted to use JSON format and no website has clearly mentioned (or atleast I didn't find any) the format of the JSON and how it needs to be created using Struts2. So after some trial and error I managed to get this to work.
There are two Actions getUserList which will return the JSON result and ListUsers which will render the JSON into the jqgrid.
Following is the source code for GetUsersListAction and since this object is directly used to serialize the result into JSON it needs to have the instance variable names as it is with getters and setters.
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import com.opensymphony.xwork2.Action;
import com.shazin.struts2hello.model.User;
import com.shazin.struts2hello.service.UserService;
import com.shazin.struts2hello.service.impl.UserServiceImpl;
public class GetUsersListAction {
private String page;
private Double total;
private String records;
private List rows;
public String execute() {
page = "1";
total = 1.0;
UserService userService = new UserServiceImpl();
List<User> usersList = userService.getAllUsers(); // Retrieves users from database
records = usersList.size()+"";
rows = new ArrayList();
int id = 1;
for(User u:usersList) {
rows.add(new Row(String.valueOf(id),
new String[] { String.valueOf(id), u.getFirstName() , u.getLastName(), u.getUsername(), u.getEmail() }));
id++;
}
return Action.SUCCESS;
}
public String getPage() {
return page;
}
public void setPage(String page) {
this.page = page;
}
public Double getTotal() {
return total;
}
public void setTotal(Double total) {
this.total = total;
}
public String getRecords() {
return records;
}
public void setRecords(String records) {
this.records = records;
}
public List getRows() {
return rows;
}
public void setRows(List rows) {
this.rows = rows;
}
public class Row implements Serializable {
private String id;
private String[] cell;
public Row() {
}
public Row(String id, String[] cell) {
setId(id);
setCell(cell);
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String[] getCell() {
return cell;
}
public void setCell(String[] cell) {
this.cell = cell;
}
}
}
The JSON output will be like this and it should be in this format to work with jqgrid.
If you develop Android applications which has multiple locales, you might face an error similar to the below one
"<Value Name>" is not translated in <Locales> ...
This is because some names which you don't want to be translated are also taken as translatable names. The easiest fix for this is to mark the error cause name tag as
<string name="myname" translatable="false">
<string-array name="myname" translatable="false">
in string, string-array element.
Or you can define all your non-translatable strings in a resource file called donottranslate.xml. Or, you can ignore the issue with a tools:ignore="MissingTranslation" attribute.