Wednesday, May 1, 2019

Ansible - Create User with Password

To Create User with Password, the password must be encrypted.
 
Reference: https://docs.python.org/3/library/crypt.html 
 

   # created with:
   # python -c 'import crypt; print crypt.crypt("sesame", "$1$opendoor$")'
   - name: check if group exists
     shell: /usr/bin/getent group $group | /usr/bin/wc -l | tr -d ' '
     register: group_exist

   - name: check if user exists
     shell: /usr/bin/getent passwd $user | /usr/bin/wc -l | tr -d ' '
     register: user_exist

 
   - name: Add user "aniu" to the remote server
     remote_user: root
     user:
       name: apple
       password: $1$opendoor$oFO4rBXnUmwP3W3rK859N.
       comment: "Orange Sales"
       uid: 5571
       group: users
       append: yes
       shell: /bin/bash
       generate_ssh_key: yes
       ssh_key_bits: 2048
       ssh_key_file: .ssh/id_rsa
     only_if: ${user_exist.stdout} == 0
 

Thursday, February 21, 2019

Saturday, October 13, 2018

xcode programming resources

The Swift 4 Programming Language Guide from Apple
Section 8, Lecture 77

Swift Programming Language Guide

You can download The Swift Programming Language Guide from Apple for free here:
Read in iBooks:

StackOverflow

Apple Developer Forum

https://forums.developer.apple.com/

Apple API Reference

Apple Guides and Sample Code


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