Friday, October 12, 2018

Polling

https://techoctave.com/c7/posts/60-simple-long-polling-example-with-javascript-and-jquery

Saturday, October 6, 2018

PHP: SSH to Remote Server

Install phpseclib into the specified location :

# cd /path/to/install/phpseclib
# composer require phpseclib/phpseclib
or
# composer require phpseclib/phpseclib:~2.0


http://phpseclib.sourceforge.net/ssh/2.0/examples.html



<?php
require __DIR__ . '/../vendor/autoload.php';

use phpseclib\Net\SSH2;
use phpseclib\Crypt\RSA;

$ssh = new SSH2('web.goweekend.ca');
$key = new RSA();
$key->loadKey(file_get_contents('/home/apache/.ssh/id_rsa'));

if (!$ssh->login('dboard', $key)) {
    exit('Login Failed');
}

$deploymentScript = 'sudo /autoDeployment/deployApplication.sh uat install ETFTrade server1 /path/to/earFiles/ETFTrade.ear 100 true';
$ssh->setTimeout(1800);
$ssh->exec(
    $deploymentScript, function ($str) {
        echo $str;
        flush();
        ob_flush();
});

?>




Thursday, September 13, 2018

Xcode Programing

Display Position
https://ivomynttinen.com/blog/ios-design-guidelines

https://developer.apple.com/library/archive/qa/qa1686/_index.html

https://developer.apple.com/design/human-interface-guidelines/ios/overview/themes/

https://youtu.be/QyjyWUrHsFc




Thursday, July 26, 2018

PHP Mongodb Insert/Update Document with Array

http://php.net/manual/en/class.mongodb-driver-manager.php
$conn = new Mongo();
$q = $conn->server->gameQueue;
$id = new MongoId("4d0b9c7a8b012fe287547157");
$q->update(array("_id"=>$id),array('$push' => array("done_by","2")));
There is a problem with your $push statement, you are not pushing "done_by" with a value of "2" you are actually sending "done_by" and "2" ...
Here is the issue ...
array('$push' => array("done_by","2"))
This should have a => not a ,
array('$push' => array("done_by" => "2"))
However, note that every time you run this it will insert another "2" if you want MongoDB to only inset "2" if it doesn't already exist in "done_by" then you should use $addToSet ...
array('$addToSet' => array("done_by" => "2"))
This statement won't add 2 everytime, only the first time.

Credit:
https://stackoverflow.com/questions/4638368/push-new-value-to-mongodb-inner-array-mongodb-php

Tuesday, January 23, 2018

Setup PHP environment

wget https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm

wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm


yum install composer

composer require phpmailer/phpmailer

Tuesday, April 11, 2017

Jquery Validate, Form and tbody

The order of tbody, td, form and table, if they are not in order, it might not work.
===================================================================
<html>
<head>
  <script src="//code.jquery.com/jquery-1.9.1.js"></script>
  <script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
<script>

$(function(){

    $("#changePWDForm").validate({
        rules:{
            currentPwd: "required",
            newPwd:{
                required:true,
                minlength: 8
            },
            checkPwd:{
                required:true,
                minlength: 8
            },
        },
        messages:{
                currentPwd: "Please enter your current password.",
                newPwd: {
                        required: "Please enter your new password.",
                        minlength: "Your password must be at least 8 characters long"
                        },
                checkPwd: {
                        required: "Please enter your new password.",
                        minlength: "Your password must be at least 8 characters long"
                        },
                }
    });

        $(document).on('click', "#submitChange", function (e) {
alert('A');

    });
});


</script>
</head>
<body>
<table border=0 id="embededLoginTable" class="outLineTable">
  <tr>
      <tbody id="oraPWDDiv">
    <td align="center">
        <form id="changePWDForm" method="post" class="ora_form" action="#">
          <table border=0 class="centreTable">
          <fieldset>
          <tr>
            <td><userLable><userLable>Current Password:</userLable></td><td><input type="password" name="currentPwd" id="currentPwd" class="ora_pwd"/></td>
          </tr>
          <tr>
            <td><userLable>New Password:</userLable></td><td><input type="password" name="newPwd" id="newPwd" class="ora_pwd" /></td>
          </tr>
          <tr>
            <td><userLable>Confirm New Password:</userLable></td>
            <td><input type="password" name="checkPwd" id="checkPwd" class="ora_pwd"/> </td>
          </tr>
          <tr>
            <td align="right"><input type="submit" name="submit" value="Change Password" id="submitChange" /></td>
            <td align="left"><input type="reset" name="reset" value="Reset" id="resetinputs" /></td>
          </tr>
          </fieldset>
          </table>
        </form>
    </td>
      </tbody>
  </tr>
  <tr>
    <td align="center">
      <div id="messageDiv" class="mssgDiv"><md></md> </div>
    </td>
  </tr>
</table>


</body>
</html>

Wednesday, April 5, 2017

PHP oci_connect: ORA-01017: invalid username/password; logon denied

Symptom:

In browser, user click button to search Oracle Database by the username typed in input field. It works once, then complain:ORA-01017: invalid username/password; logon denied , click again it works, if click again, it pops up the error message again.

What I did:

1. Double quoted the connection password (in wallet in my case.)
2. creating a file called "20-oci8.ini" in directory "/etc/php.d" with the following content.

; Enable oci8 extension module
extension=oci8.so
3. Disable the extension=oci8.so in /etc/php.ini