Friday, November 19, 2021

Passing a URL to a PHP to Call GSX

 GSSX requires user site to be white listed before allowing access. Since our customer are using multiple applications that access GSX. The whitelisted server is not on the same server as our web program. User need to post data to the web server which in turn send a request to a central server which then send the request to GSX. 

Sending normal requests is simple but since GSX has many APIs that have a mix of "GET and POST"., The sending of data to GSX become complex as we have to send specific URL to get the right result. Now sending a POST/GET that contains URL as parameter is not that simple especially when the URL is mixed with other parameters. It need to be url-encoded properly.

PHP CURL uses query method to do both POST/GET thus the query works on both.

Luckily, there is a PHP function that could compose the post parameters. It is called HTTP_BUILD_QUERY. You just need to send an array of the parameters and it will compose the parameters properly. This including sending a URL as data.

The following is an example 

$data= array(

"id" => "1234567"

,"address" => "https://gsxserver.com/returns"

);

$params = http_build_query($data);

In your CURL request you simply use 

curl_setopt($ch, CURLOPT_POSTFIELDS, $param);

The central server PHP just need to get $_POST['xx'] to get the specific parameters.





Tuesday, November 02, 2021

Divorce for Christian

Marriage is a serious event  for a Christian. Gen 2:24 "Therefore a man shall leave his father and his mother and hold fast to his wife, and they shall become one flesh." Mark 10:9 Therefore what God has joined together, let no one separate."

Unfortunately, things can get sour between husband and wife. Divorce between Christian is even more serious as Jesus says “I say to you: whoever divorces his wife, except for sexual immorality, and marries another, commits adultery.” (Matthew 19:9 ESV)

Divorce for Christians thus becomes a taboo. Is there no way out? 

Paul mention that “To the married I give this command (not I, but the Lord): A wife must not separate from her husband. But if she does, she must remain unmarried or else be reconciled to her husband. And a husband must not divorce his wife. To the rest I say this (I, not the Lord): If any brother has a wife who is not a believer and she is willing to live with him, he must not divorce her.  And if a woman has a husband who is not a believer and he is willing to live with her, she must not divorce him.  For the unbelieving husband has been sanctified through his wife, and the unbelieving wife has been sanctified through her believing husband. Otherwise your children would be unclean, but as it is, they are holy.  But if the unbeliever leaves, let it be so. The brother or the sister is not bound in such circumstances; God has called us to live in peace." (1 Cor 7:10-15)

This means that separation is allowed. It also means  that divorce between Gentile and Christian is still possible. 

However, that classification is not that easy to achieve. Paul said “The husband should give to his wife her conjugal rights, and likewise the wife to her husband. For the wife does not have authority over her own body, but the husband does. Likewise the husband does not have authority over his own body, but the wife does. Do not deprive one another, except perhaps by agreement for a limited time, that you may devote yourselves to prayer; but then come together again, so that Satan may not tempt you because of your lack of self-control.” (1 Corinthians 7:3–5 ESV)

Paul also mentioned that "But if anyone does not provide for his own, and especially for those of his household, he has denied the faith and is worse than an unbeliever. (1 Timothy 5:8). Therefore a Christian who does not care for his wife, he is as good as a Gentile.

Jesus said “If your brother sins against you, go and tell him his fault, between you and him alone. If he listens to you, you have gained your brother.  But if he does not listen, take one or two others along with you, that every charge may be established by the evidence of two or three witnesses.  If he refuses to listen to them, tell it to the church. And if he refuses to listen even to the church, let him be to you as a Gentile and a tax collector." (Matt 18:15-17)

In conclusion, if a husband does not care for his wife and does not treat her well, separation or divorce is still possible after mediation fails to turn back the one who erred. This also applies to the wife who does not treat the husband well. Paul said "Wives, submit to your husbands as to the Lord." Eph 5:22

Again this blog does not sanction divorce. It is only after all efforts to make the marriage good then it is accepted.  Jesus said "Moses, because of the hardness of your hearts, permitted you to divorce your wives, but from the beginning it was not so" (Matthew 19:8).





Monday, September 13, 2021

Bible The temptation tests of Jesus

Matthew 4:1-11 describes the temptation that Jesus is being put into. Jesus is being led into the wilderness to be tempted by the devil. Obviously, Jesus is being tested like a human and not God.

The first test is the personal desire out of need. Jesus was fasting for 40 days and 40 nights. He was hungry Matt 4:2. The tempter is trying to induce Jesus to get the easy way out by acting as God instead of suffering as a human. Jesus answer is "Man shall not live on bread alone, but on every word that come from the mouth of God." How many of us could overcome our personal desire and not waver?

The second test is the pride in man. The test is on the attempt to show off that God is his backer. Nothing wrong? Many people pray to God for protection but they forget that they put themselves in center of focus instead of God. Moses made the mistake of striking on the stone instead of speaking to the stone as commanded by God. He forgets that he is not the one that is glorified in the act. The penalty is that he can only see the promised land but can never enter it Num 20:10-11. Job has done better Job 2:10. Jesus has the right perspective. He said "do not put God to the test" matt 4:7.

The third test is on power and greed. This test is a bit confusing but based on the standpoint that Jesus is tested as a human, it explains everything. How many can resist the kind of power and glamour of being in control. Jesus answer "Worship your God and serve him only" Matt 4:10 This is similar to what Jesus said in Matt 16:26 "What good is it for man to gain the whole world and lost his soul?"

If you looked carefully the three test are based on human self-centered behavior. 1. Provide for self. 2. Putting glory on self. 3. Get power for self. Jesus' answer put God before all. He has gone through the test and prevailed as a human.

Actually there is a ultimate test. A test which he was betrayed, abandoned by all and hanged between two convicted criminals. As a human he has to bear all the humility, being mocked and left to die forsaken even by God.  He prayed three times to be spared the agony but to no avail. 




Saturday, September 11, 2021

Bible and the Origin of Scam

 Origin of Scam is usually referred to as Origin of Sin. The latter concentrates on the wrong doings and the punishment given. This post concentrates on the scam itself.

God created man and put him to work in Garden of Eden. He gave the specific command "You are free to eat from any tree in the garden but you must not eat from the tree of the knowledge of good and evil, for when you eat it you will surely die. (Gen 2:16-17).

After giving the command, God then created animals before forming Eve out of Adam's rib. It showed that Eve did not receive direct command from God about the tree of knowledge of good and evil.

The serpent first step is create confusion. He asked "Did God really say you must not eat from any tree in the garden." (Gen 3:1)

Eve's reply is typical of a person who received second hand information. "We may eat fruits from the trees in the garden. but God did say 'you must not eat fruit from the middle of the garden, and you must not touch it, or you will die.'" (Gen: 3:2) That is not exactly what God's command. She has totally missed the fact about tree of knowledge of good and evil instead she only knows that the tree in the middle of the garden is forbidden to eat and she even added "you must not touch it".

The serpent said "you will not certainly die." (Gen 3:4) The serpent deny the fact about dying after eating the fruit. His next phrase seduces Eve about the good effects of eating the fruit. Surely, this is one fact that neither Eve or Adam is told. It directs away the fact about dying and concentrates on the benefit. 

By first creating confusion then sideline the fact with additional facts as incentive, Eve is seduced to do the wrong thing. Although Adam did not say anything, he is with her all the while (Gen 3:6) and is probably being seduced too.

Did the serpent say anything that is false? Not at all. Even the fact about dying after eating the fruit is also muddled and diluted by his first phrase. He made use of the fact that Eve probably don't know that the "tree in the middle of the garden" is actually the tree of knowledge of good and evil that is specifically forbidden to be eaten. So eating the fruit from the middle of the garden should be allowed because they are given permission to eat from any tree in the garden. Even if that tree in the middle of the garden is forbidden to be eaten, it is God that selfishly hides the benefits of eating the fruit by saying that they will die after eating the fruit. Sadly to say Adam and Eve did not die after eating the fruit. So the serpent is right about the not dying after eating the fruit.

Modern scam basically use the same tactic of confusion, and incentive. Most people don't know the true fact about things around them. They will willingly accept any one's word as fact without checking. Furthermore greed is one incentive that few escapes from it. Who to blame when they fell for the scam?





Friday, July 16, 2021

Setting up a Broadlink SP4L-UK Smart Plug

 SP4L-UK is a smart switch that can be controlled by hand phone via WIFI. It is compatible to Google Home. This model is suitable for Singapore home because it uses the same 3 pin plug configuration commonly used in Singapore. 

Now before you could do anything, make sure that your home wifi is set at 2.4G because this device is not a 5G compatible device. Most home network have both 2.4G and 5G wifi connection. You handphone will auto switch between two wifi connection automatically anyway. Only problem is that you need to specifically connect to your 5G network manually. While setting up, you must turn on bluetooth and use a 2.4G network on your phone.

Download BroadLink-Universal TV Remote app. Android users need to make sure no screen overlay app is running when setting up the app. You cannot turn on/off screen overlay if one is already running.

After setting up user login, follow the following steps.

  1. Plug the smart switch into the power socket. You will notice the LED on the switch blinks continuously.
  2. Click add device. 
  3. Choose "Wi-Fi Devices" 
  4. Select "Other Wi-Fi Devices". 
  5. Choose "Smart Setup" and click "Next". 
  6. Click "Done" ignoring all the information on the screen. 
  7. It will prompt you to enter your wifi login information. The SSID will be automatically chosen. Just enter password accordingly.
  8. After a while your device will be set up properly. The LED on the switch should go off.
  9. Set up the Name and room information for the device and you will be done.
In the even of error the LED blinking rate will go much slower. You need to reset it by pressing and hold the button near the IR sensor at the end furthest from the three pin socket. Wait till it blinks at a faster rate. It will be ready for you to try again. 

You may wonder why I choose a smart plug that is using only 2.4G wifi. Actually, there is not much choise. Furthermore, the range of the wifi is wider than a 5G wifi. Most manufacturer choose to use 2.4G wifi over 5G wifi. 

You can use your 5G connection to control the devices as they are all on the same router connection.







Thursday, July 15, 2021

Android Screen Overlay Switching Greyed Out

Screen Overlay is one facility on Android to have some app hovering over all apps so that user can quickly access the app anytime.

One thing Google never tell you is that once an app is run with Screen Overlay, You cannot turn on Screen Overlay mode. To turn on or off you need to go to to Settings then click on the wheel on top left of the screen then choose "Draw over other apps" after that slide on "Permit drawing over other apps". The selection is greyed out.

The only way to enable the "Permit drawing over other apps" setting is to completely close the app that does Screen Overlay then make the changes before enabling the Screen Overlay app again.





Thursday, June 17, 2021

An Open Letter to the Chairman of the AGM SAVH

I do not agree with the process of AGM which I am required to send in a proxy form appointing you as the trustee to attend the meeting on my behalf.

  1. Why should I appoint you to attend, speak, and vote on my behalf as a proxy. Proxy is someone who I can trust to conduct matters on my behalf. I don't even know you so how could I trust you to conduct on my behalf?
  2. I don't see how the process is fairly handled. A security company is appointed to receive the proxy form. The company collects and submits the form to you. Who can guarantee that they do it fairly and faithfully although sending the letters directly to SAVH is even less secure.
  3. Who can verify the integrity and correctness of the forms. I believe you won't do it by yourself. So if there are no independent witnesses. Who can guarantee the fairness of verification and ensure that there are no alterations to the form?
  4. Who can verify the correctness of vote count or the resolutions when there is no independent witness? 
  5. There is no independent witness while the counting is done. The tally is also not verifiable and is authentic when presented to the AGM since there is no witness to note the tally during the count.
  6. Although submitting questions in advance is constitutional. Since we make you as the proxy, we lost the ability to query during the AGM on the answers given by the relevant party neither do we have the ability to raise issues on matters arising.
  7. Since the votes are submitted in advance, can you be absolutely confident that the resolutions and votes are not leaked to interested parties there by allowing them to manipulate the votes by getting more people to influence the vote count?
  8. The online submission of the proxy form require signature but no instruction on signing the PDF. It requires a Serial number too. Where is the serial number? I don't receive it. Can you be sure that the serial numbers cannot be obtained by interested parties to vote by someone else?
  9. Due to the complex process of signing the adobe PDF, How could a VH able to sign it properly without help? Even a sighted have problem unless they know how to do a signature on a PDF. There is no proper documentation on how it can be done.
  10. Registration online requires an email address. Can you be sure that all your clients have email addresses?
  11. Letters sent to the totally blind cannot be handled by them. Who will help them go through the process? You expect them to find their own helping hand?
  12. You don't have online client login access before so how could you ensure that those who register are really who they say they are? 
  13. You being the president of the Executive Committee is deemed to have vested interest as we are voting in committee members who in turn selects the president. How can you be the one handling the votes singlehanded? Those people whom you engaged are engaged by you. Are they acting honestly? Who can guarantee that? You?
  14. Why is there no option for a group of us to appoint our own proxy who could summarize our resolution decisions and voting choices? At least we could be sure that our forms reach you on the AGM day and submit the forms on the spot accordingly? 
  15. I could be wrongly misled. I heard that the voting process is decided by you alone without the Executive Committee's understanding.  Is it not a process agreed by all members of the committee?
  16. Voting is supposed to be confidential. The proxy form has our names and signature. It is no longer confidential.



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.