Friday, April 02, 2021

What have I done wrong

Although I have quite a few achievements (see my other blog), there were quite a few incidents in my life that is against me. The following are the incidents.

I worked for a textile company. My work attitude caused the management to promote me to a group leader. I was transferred from department to department in increasing importance area. Obviously I become a sore eye to other group leaders. I have no friends in the company but since I am a loner (I am a bit autistic), I really don't care.

During my BMT in the military, I was a temporary IC. Everybody ignored me just because I am a loner that don't mix around. I am sure I did not use my position to boss over them.

At the end of BMT I was told by platoon sergeant to give up the position of "Best Trainee" to a NS men because I am a regular. I don't mind that. But in my heart, I was wondering why the bias. Anyhow, since the NS men is quite close to me (being a fellow jogger), I don't make noise. Even then, I wonder why they ask me. I have no idea that I was nominated "Best Trainee".

While attached to a military school as a temporary lecturer, There were other lecturers that vows to fail me in my next upgrade. I am just doing my job trying to teach the students in my own way. Maybe it is due to me not mixing around that makes them think that I am arrogant. Also I prepared the training material all by myself without consulting the seniors because the old training materials I had is quite lacking and ambiguous on some area. I left the military after my terms of service completed because of this hatred towards me.

In the military camp that I was assigned to and is a IC in a department, I was targeted by a logistics officer who placed bad comments on my military record. I suspects that it was a subordinate of mine that bad mouthed me. There were nothing wrong in my department. No errors, no faults, no complaint yet I was told I did not do my job properly. The reason is probably due to the following paragraph.

For three years I was a "damned" Private who did not get a promotion even though my training qualifies me to be promoted to Lance Corporal.  It was probably due to the Captain (logistics officer) that was condemned so the rest of the camp under him also being condemned. I was subsequently duly prompted to Lance Corporal after a letter was sent to my officer (Captain)  asking for a reason why I was not promoted (as was told by a clerk in the HQ). Surely it is not me who try to pull a string in the higher echelon. Suddenly from a Lance Corporal I was promoted to a Corporal within three months of last promotion while in the training camp. I wasn't due for promotion before I finished my training. This cause the whole training camp to be jealous of me because I was the one and only Corporal in the class. Have I done anything to deserve this?

While attached to an oversea base, I was targeted by an Officer who happened to be be the head of logistics that I am under. I was doing my job properly and did nothing to invoke him. He even orders me to fix telephone lines alone in the middle of a hurricane storm. I guess its the logistics officer back in my military camp in Singapore that is the one who instigated the oversea officer's hatred towards me. He even say right in front of me "You are a Christian, I am a Buddhist. I don't like you". Anyhow, the officer was not able to do any other harm because he probably can't. I did my job properly and watched my back.

In my last year of reservist, I was made a vehicle commander transporting field camp materials back to the camp. All the people assigned to me suddenly deserted me after reaching the camp. I could have put all of them on charge of insubordination but since it is already my last year, I just do the unloading myself and one by one the others creep back to help me unload. At the beginning of my military career and at the end of the career I have people who just ignore me. Well, such is a life of a IC. Pathetic and a total failure because I don't mix around? It probably is because it is an anti-human behavior. I am not a good leader.

While in a technical firm, I was a QA Technician in the QA department. The QA officer find faults with me on the floor being dirty. There was a cleaner that was doing the cleaning. Why complain to me? He was trying to find fault with me because I foolishly pointed out the error (in front of the customer) that he made in a QA inspection level. He placed the level way too high that it is certain that every batch of delivery have to be inspected 100%. I have to voice out immediately before customer accepts the inspection level. Luckily the customer is a military officer that was my superior who rely on me to handle the QA department in the military before it was handed over to the same civilian company that I was in. She accepted my rejection of the inspection level because she knew that it is not feasible to set such a high level. In the end the QA manager steps in to support me because there seems to be problem between the QA officer and QA manager. 

Life was then smoother after the QA officer give up my department totally. I could handle the department myself because I was the IC before it was handed over to the civilian company. Ultimately I left the QA department because of this and that the life is very stale doing QA work.

I was transformed from a Customer Relations Officer to be a supervisor (in an outsourced company). In the process of maintaining the group, I began to write programs that could help the department work more smoothly. It worked so well that the manager began to use the opportunity to boast to the corporate world. Many people follow suit in the same type of work so much so that the corporate IT clamps down on the "shadow IT" work. I ended up being just a shadow in a outsourced company doing the same work. I was still doing the same thing just that officially I am the outsourced company tech that is doing technical work to enhance the company's work not the outsourcing company doing "shadow IT" work. Was it my fault that caused the clampdown?

In the same corporate company I was assigned to set up a whole new Customer Relation Management system including a full fledge web based program to handle customer equipment repair. I worked hard on it but failed on the LED display because my design just could not drive the LED. Luckily I quickly switched over to a TV display using the web method. It was completed just one day before the official launch of the whole program. I was told that my own boss says that "I ask for it". What have I done wrong? I was trying to save the outsourcing company lots of money by doing the whole project in house. This is what I get for doing something that is good for the outsourcing company?

It is strange that quite a number of people volunteer to keep me informed of what is happening around me. I am a loner so I really don't mix around well but I guess it is my no-harm nature that makes them want to talk to me about people wanting to harm me. Also there are people who helped me without reason. I thank God for that.

Now that I am "officially" retired, I looked back and see all the things that happened to me. I compared with those martial art stories' hero. It is exactly the same thing that happens to me. I shined too well that caused jealousy in others so they try to silent me. In other instances, I am just a innocent victim who did not deserve the hatred/dislike.  Well, it is already history so it does not matter anymore.



 

Sunday, March 21, 2021

Javascript Listening for a specific Key press

 If you want to know what key was press in a web page, you will normally do a document.addEventListener('keydown',myFunc) function. However, if you only want to act upon s specific key then the situation is slightly different becauses addEventListener does not have function to return anything.

Fortunately, there is a "bind" function in the event listener. by defining the event listener as

document.addEventListener('keydown',myFunc.bind(event))

In myFunc then you could use event.keyCode to determine which key was pressed and bypass any other.

There is an issue here. You can't capture key combinations. Keys like Alt-s will be passed as two event instead of one thus the function is triggered twice. But for just a simple key press like pressing the space-bar, the script works quite well.





Tuesday, February 16, 2021

Filemaker Making Progressive Limits

 It is not unusual for performing progressive limits. Basically it is just to limit the search by selecting various attributes of the item. For example, in a electronic product, you would want to limit to hand phone, Xiaomi, 4 GB Memory, 256 GB storage to find the price of item that match the criteria. Its like setting filters as you browse the products. 

Most on-line product sellers would allow for filters. Here, the idea is to do it in FileMaker which does not have dynamic content and have difficulty in doing paging without resorting to web based techniques.

Doing filters in FileMaker is not that easy. as lists are not set dynamically according to selected fields. Using SQL to filter is also not that easy as user select different options in various fields.

Below is a simple method of doing progressive filtering. The key in doing that is to force user to select various options in a fixed sequence/

Using the model mentioned above, there are three filters. 1. Model, 2. RAM, 3. Storage. Obviously, in real products there are much more options to choose but for simplicity, only 3 options are shown here.

STRUCTURE

One main table where the filters are set.

One product price table where the Model, Ram and Storage are set.

METHOD

Create a field for each filter in the main table.

Create a list based on Model on the product price table and set "Model" field to select from this list.

In the database Relations tab, create a duplicate product price table. Set the "Model" field of main table to the "Model" field of the price table. Create a list from this duplicate and set it as select list to "RAM" field of the main table. Hide the "RAM" field if "Model" is not selected.

In the database Relation tab again create a second duplicate of the price table. This time Set the "Model" and "RAM" field of the main table to the "Model" and "RAM" field of the price table. Create a list from the second duplicate. Hide the "Storage" field if any of the "Model" or "RAM" is not selected.

In the database Relation tab again create a third duplicate of the price table. This time Set the "Model", "RAM" and "Storage" field of the main table to the "Model", "RAM" and storage field of the price table. Create a script to set the "Price" field of the main table to the "Price" field of the third price table.

In this way the fields are chosen progressively according to the order of the available fields. This relation setting allows user to change various options easily. You only need to ensure that the "Price" field of the main table is blank first every time user make changes on any of the fields unless you want to make the field as the "Price" in the third price table without the script.





Sunday, December 13, 2020

Communicating with Apple Web Services (GSX) via Filemaker 3

 My previous blog talks about communicating with GSX using JSON. There is one area which is not mentioned. This area concerns with security. GSX requires client certificate issued by them and a white-listed IP. They require user to be certified and communicating from an approved IP address.

The white-listing is easy to achieve. Just designate your server/computer as the channel to communicate with GSX. All API requests have to be send from the server/computer. This means that if you require multiple user access, then you must provide a means for all of them to communicate with GSX from the white-listed server/computer from Filemaker using the "Insert from URL" function.

Getting a cert from GSX is done by sending a properly filled CSR to GSX. Note that the Common Name is defined by GSX. It is used to identify user according to GSX format. With the cert, you need to prepare it for use by the server/computer so that you can use it. The following is example done in PHP. The method used is via CURL in PHP.  It is not advisable to use Filemaker to communicate directly with GSX as each "execute from server" means one connection used. You may soon find out you run out of connection on your server. By using "Insert from URL" and calls a PHP server, there is no limit.

Before you could start coding the PHP, you need to prepare your cert for use in CURL. CURL works best with certs in the PEM format. You need to combine the cert and private key into one file by copying and pasting the cert and key into a single pem file.

The following is a typical CURL setting

$ch = curl_init();

curl_setopt($ch, CURLOPT_HEADER, false);

curl_setopt($ch, CURLOPT_VERBOSE, true);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);

curl_setopt($ch, CURLOPT_VERIFYHOST, 0);

curl_setopt($ch, CURLOPT_VERIFYPEER, 0);

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

curl_setopt($ch, CURLOPT_HEASDER_OUT, true);

curl_setopt($ch, CURLOPT_SSSLCERTTYPE, 'pem');

curl_setopt($ch, CURLOPT_SSLKEYTYPE, 'pem');

curl_setopt($ch, CURLOPT_SSLCERT, 'your cert');

curl_setopt($ch, CURLOPT_SSLKEY, 'your key');

curl_setopt($ch, CURLOPT_SSLKEYPASSWD, 'your pass');

You will have to check the documents to see what are the headers required to be sent to GSX. I suggest you send the header settings from your user to the server/computer as JSON then convert the JSON as array with variable name as $headers as shown above. In addition, not all GSX API calls are POST. You need to get user to indicate whether the request is POST or GET.

If it is post then you will need to set the following

curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch, CURLOPT_POSTFIELDS, $content);

curl_setopt($ch, CURLOPT_URL, 'your url');

Since a GET requires CURL GET request, you need to define it with the following.

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');

Each API requires the API to be defined as part of the URL. You need to define the URL for each API call. Compose the URL from the user side and send it as a parameter to the server.

curl_setopt($ch, CURLOPT_URL, 'your url');

Finally execute the CURL

$output = curl_exec($ch);

It is a good practice to always close the CURL after every thing is done.

Now CURL may return two different errors. One from CURL itself, the other is from GSX. Your error message have to distinguish between the two.

Before you even start to test the PHP coding, you need to obtain an initial ID from GSX. Therefore, you have to visit https://gsx2.apple.com/gsx/login to sign in and get the ID. This id will be used to obtain the proper ID for subsequent GSX API request by calling the "authenticate token" api then copy the ID returned for subsequent use.

A final oddities is that if you, or your users, use more than one app or one computer that access GSX. Please be reminded that only one ID is provided at anytime. You need to use the same ID for all requests. It is up to you and your user to store such ID in one secure place and use it to consume APIs.







Monday, December 07, 2020

Internet Download Speed is Crawling

 Quite some time ago my win10 browser loading suddenly become sluggish. I check with Ookla Speed Test shows that the download speed is just 6 mbps whereas I subscribed to 1 Gbps. The upload speed is very much faster but still well below the 1 G bit as subscribed.

Tried various methods of finding out why the download is slow but to no avail. Checking the speed on my handphone proved that the router is OK thus not service provider problem. It is only the laptop that has the problem. It really puzzles me as it is not due to browser issue since Ookla has a app that could perform the test without using browser.

After a month or so of intermittent attempts to find the fault, I finally found a clue. Netizens mentioned that SmartByte Network Services could slow down network.

I uninstalled SmartByte and the speed went up to almost 1 Gbps. SmartByte come pre-installed with Dell laptops. There are instructions in the internet that teaches you how to uninstall it. One such example is https://windowsreport.com/smartbyte-services/.




Monday, November 09, 2020

Getting the distance from a QR code with known dimension

 In working towards an app that guide VI to navigate indoors (Blind Navigation System Using QR Code), I am working out the distance of a QR code from the navigator. This will allow the app to works like iBeacon that could tell the distance of navigator from the device.

OpenCV already have methods that could measure object dimension from a known reference. The first step is to convert the known dimension to pixel ratio. This will allow for different camera with different megapixel count. The formula is simple. ratio=pixle/real size of object.

With this constant, I will need to determine the distance from the navigator to the QR code. First I find the QR code then measure the QR Code size. The QR code most likely have to be enclosed within a rectangle so as to allow the measurement of the rectangle. Convert this size (in pixles) by the formula size=pixle*ratio. Viola, we get the distance from the QR code.

Measuring the position of the QR code is an essential metric. This will allow navigator to know the direction towards the QR code. This is easily done by getting the center point of the camera view then get the relative position of the QR code to the center point. We can inform the user whether it is to the right or left. Calculating the distance from the center point is quite meaningless as it is not useful to the navigator.

Unless navigator has a perfect memory of the position of all the QR code, there is a need for a map of the location with precise point of all the QR codes. The app should also allow the plotting of routes from one QR code to another so as to provide a voice guided navigation for the VI.

Deviating from the QR code will be an issue. Unlike iBeacon, once the QR code is not in the camera view, VI is practically lost. A facility to turn VI back to the track has to be made by approximating the last known point.




Tuesday, October 27, 2020

digiKam Used for Managing Flora and Fauna Photos

 I need to use an application that could manage those photos of flora and fauna so that I could easily refer to them or search for specific specie. After the demise of Picasa, I found an application called digiKam that could perform most of the functionalities like Picasa. 

digiKam has lots of functionalities that are available. Here I will only talk about those I would use to manage flora and fauna photos.

Showing photos that are stored in directories grouped by directories is the basic requirement. It won't work if I have to go to individual directory to show the photos inside. digiKam did a good job by showing an entire directory with subdirectory as a selectable list.

In addition to directory aka Album, digiKam is able to show lists by Maps, Tags and Dates. It also have a search by title. Other list types are available but is of little use to me. Tags list is mentioned together with Tag editing below.

Maps listing is an interesting feature. You can show a list of photos that is defined by a square selection or select a group of photos that is grouped by digiKam. I find it extra useful to identify flora pictures. It all goes by memory. If you have seen the flora before and remembers a rough location, you could list the photos in the area and try to find the flora. For fauna, it is a bit difficult as they don't stay in the same place unless they are territorial.

I also contributes to iNaturalist. The location can match with digiKam map to show a list of photos in the same area. It helps if I have already identify the flora and have a picture of it. Inversely, I could use my photo's location and find in iNaturalist to see if there are any observation of the same kind. iNaturalist have the same map area list like digiKam.

GPS, Tags and Title are the most important information that is stored in a picture. digiKam allows the editing of these tags as individuals and group editing. 

Tags are usually done as a list. digiKam stored hierarchical tags in its database. It did not store the data in the pictures because other applications only look at tags as a list. This feature is best suited for me as I normally set the taxon family and Gender as separate tags. digiKam is able to use tags to show the list of photos that has the same tag. Now I could use the hierarchical listing to see the gender in a family instead of seeing the whole list of photos in the same family. 

Tag editing also benefits from the hierarchical arrangement. When adding tags I had to find the family and gender separately before adding them. Now I just need to find the gender and the family will also show up if it already exists. This save me from having to find the family name for the gender.  A time saving feature.

Zooming is a very useful tool. digiKam allow list photo to be zoomed to a size comfortable. I zoomed to a level that shows 5 photos in a row. That is most comfortable to see enough details of the photo. 

By double clicking a photo you could see a zoomable view of the photo. It even have a full screen zoomable view of the photo. You could set it to full screen when you double click. This is very useful to see clear details of the photo so that I could find the specific character of the flora and fauna.

Rotation. Sometimes the camera does not automatically store the rotation thus digiKam showed the photo in the wrong position. digiKam has a rotation setting so that you could view it properly. However, I am not sure if the information is stored in the picture after that. 

Photo editing. Not the usual kind of editing feature is available. It is just a set of enhancement that allows photos to be adjusted. I usually use auto color to adjust the photo. Other adjustment features may be useful but is of less interest to me.

Grouping in a list. It is a unique feature but it does help if you go for a tour and need to group the photos by the day. You could group the photos in anyway. I find it useful to avoid seeing those photos that are not related to flora and fauna.

Panorama is not part of the feature required for flora fauna management. But it is useful for people who does not have a panorama camera to stitch few photos together to make a panorama view/ However panorama is not a digiKam application. It has to be installed from outside. Luckily when you select panorama in digiKam, it allows you to download hugin (pto2mk) and GnuWin (make) from internet. Download and install, the panorama feature will be activated.

In conclusion, it is useful to me to manage my photos in the flora and fauna sense. This application is available for Windows, Mac and Linux.