Monday, April 6, 2020

mac node mysql apache





cd /usr/local/var/www/json2tree










cd /Users/nicole/node/arcgis_viewer

nodemon --exec npm start








cd /Users/nicole/node/world





mac show hidden file
    CMD + SHIFT + .
 or terminal run:
 defaults write com.apple.finder AppleShowAllFiles YES
https://ianlunn.co.uk/articles/quickly-showhide-hidden-files-mac-os-x-mavericks/








mac exit full screen
    cmd + ctrl + f

















---------------

mac visual studio code, show tabs
you need edit setting.json file, and change from false to true

settings.json, located at

    Windows %APPDATA%\Code\User\settings.json
    macOS $HOME/Library/Application Support/Code/User/settings.json
    Linux $HOME/.config/Code/User/settings.json


{
    "workbench.editor.showTabs": true
}
---------------











*********  mac install nodemon *************



  // terminal, must use root , otherwise, failed install nodemon Global

    sudo -s



  // Must install Global

  sudo npm i -g nodemon




//local install will failed to start later
//Do not use:   npm install --save-dev nodemon



nodemon --exec npm start

*********  mac install nodemon *************











=================== bookmark =======================

cpanel
https://104.238.125.233:2083/cpsess6948351829/frontend/paper_lantern/index.html?login=1&post_login=48187625039743


WHM
https://104.238.125.233:2087/cpsess8149350323/?login=1&post_login=43362710941285



goDaddy, product
https://myservers.godaddy.com/208989







................. install mysql on mac with Homebrew .......................

Using Homebrew service to download

Homebrew is a package manager for Mac which greatly simplifies the process of installing command line software and tools on a Mac. It’s one of the most common ways to install an app on Mac.

To install Homebrew, open Terminal and run:

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Note: Homebrew will download and install Command Line Tools for Xcode as part of the installation process. This might take a lot of time since those apps are not lightweight.

Then install MySQL using Homebrew:

$ brew install mysql
Install brew services:

$ brew tap homebrew/services

Load and start the MySQL service:

$ brew services start mysql

Expected output: Successfully started mysql (label: homebrew.mxcl.mysql)

Open Terminal and execute the following command to set the root password:

mysqladmin -u root password 'yourpassword'
Now your MySQL server is ready.

              


        **** DO NOT FORGET ****
        
        reset root password:   4a41
        
        in order for node.js connect to mysql, must run following sql at sql-workbench
        
        ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '4a41'


          without run this sql, will get error, when node.js connect mysql client.
          
          Client does not support authentication protocol requested by server; consider upgrading MySQL client


................. install mysql on mac with Homebrew .......................





------------------- install NodeJS and NPM on Mac using Homebrew -------------------

https://medium.com/@hayasnc/how-to-install-nodejs-and-npm-on-mac-using-homebrew-b33780287d8f


Step 1: Install Homebrew

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"



Step 2: Install Node via Homebrew
$ brew install node



   check node and npm version

$node -v
v12.7.0

$npm -v
6.10.0

------------------- install NodeJS and NPM on Mac using Homebrew -------------------
















****************** ******************* **********************

Installing Git on a Mac
Open a terminal window.

Step 1 – Install Homebrew
Homebrew […] simplifies the installation of software on the Mac OS X operating system.

– Homebrew – Wikipedia

Copy & paste the following into the terminal window and hit Return.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor
You will be offered to install the Command Line Developer Tools from Apple. Confirm by clicking Install. After the installation finished, continue installing Homebrew by hitting Return again.

Step 2 – Install Git
Copy & paste the following into the terminal window and hit Return.

brew install git
You can use Git now.
****************** ******************* **********************

Thursday, April 2, 2020

centOS SSL 2022


Note: must have private.key and public.cer file, missing any one will cause error when npm start









2022 comodo SSL 


1). on comodo, need  Input CSR (Certificate Signing Request)

     cpanel > SSL / TLS > click  SSL certificate signing request

      fill out:  

Generate a New Certificate Signing Request (CSR)


      key:  choose generate a new key
      domains:   type "transparentgov.net"



click "generate" button at bottom


copy CSR
                      -----BEGIN CERTIFICATE REQUEST-----
                      -----END CERTIFICATE REQUEST-----







2). on comodo,  select your server

                     apache-modSSL






4) select approver email

                  admin@transparentgov.net


5) check email,  admin@transparentgov.net

             copy validation code
 
             click 'validation' link,



6) click re-check status, button

          download certificate






7)  cpanel > SSL / TLS >CERTIFICATES (CRT)
 Generate, view, upload, or delete SSL certificates

Upload a New Certificate
or just copy past here

   Now a new certificate save on server. next step, install it.



8)  cpanel > SSL / TLS > INSTALL AND MANAGE SSL FOR YOUR SITE (HTTPS)
 Manage SSL sites.

      browse to the newly saved certificate

      click "install"  button

Done. apache. 

  next step do 2 node.js apps.

9) warning: if  arcgis_viewer node.js crash on localhost
that means, private key and public certificate does not match.
I must go to cpanel, SSL check both private key and certificate.

When I renew or install a new certificate, maybe a new private key was generated as well. I must copy paste that private key into node.js app. 

10) arcgis_viewer,  bin folder,  public.cert is from email downloaded 
private key is from cpanel,  > 

CERTIFICATES (CRT)

click 'edit' for the new installed certificate expire in next year.

now scroll down to bottom,  click  that private key

This certificate uses the following key:


This is the private key, I must copy past in node.js Bin folder, private.key file.

----------------------------------------------------------------------------







https://huguowen.blogspot.com/2018/07/centos-ssl.html



centOS putty log in:

      arcgis_viewer:
                                                           
                                    **** Do NOT use sudo su - hoogw2000, use hoogw for 'node' folder, if use hoogw2000, node will not run or run error.
                                    cd /home/hoogw2000/node/arcgis_viewer/



                                    *******  must sudo su, access folder public_html, without this will access deny, node should not in public_html folder, because should hide private.key from public access
                                    sudo su - hoogw2000
                                    cd /home/hoogw2000/public_html/arcgis_viewer/



                                    Must rename .env to windows.env and centos.env to .env

                                    pm2 start npm -- start




      cors-anywhere:
                       

                            **** Do NOT use sudo su - hoogw2000, use hoogw for 'node' folder, if use hoogw2000, node will not run or run error.
                            cd /home/hoogw2000/node/cors-anywhere/


                            *******  must sudo su, access folder public_html, without this will access deny, node should not in public_html folder, because should hide private.key from public access
                            sudo su - hoogw2000
                            cd /home/hoogw2000/public_html/cors-anywhere/

                            pm2 start server.js









++++++++++++ re-key +++++++++++++++++

first skip re-key
if SSL does't work, or change domain, or change server,  always should re-key

     --------------- re-key -------------------

     ON godaddy

            my product ------------ SSL certificate ----- click manage button


            you should see your ssl certificate, click it.

            Re-Key

            Top menu, click repository,

            3 big button, download, re-key,  xxx.  click re-key

            3 plus + sign, click first +,  past your CSR here. ( how to get CSR? ---- go to cpanel, search SSL,  click Certificate Signing Requests (CSR) )

             copy the Encoded Certificate Signing Request, and past on goDaddy re-key page, then submit.
            REMEMBER:
                everytime you creat a new Certificate Signing Request, you auto create a new private key saved at Private Keys (KEY) page
                you will use this as private.key file later


             wait a few minutes

             you get email from godaddy(certificate authority)



      Download crt, choose apache only. for both apache and node.js
      (if you choose 'other' for node and 'apache' for centOS, the node.js app will not work)

      !!! must use same certificate for both apache and node. !!!!!!!!




+++++ node.js   +++++


    1 . public key:
    copy c1b82dd3af7660ec.crt from cpanel or downloaded.zip to node.js , (do NOT use gd_bundle-g2-g1.crt)
    rename c1b82dd3af7660ec.crt to  public.cert   at  /bin/www/public.cert


    2 . private key: (if renew, still use old private key, no change here)
    you should download from godaddy product page, click SSL certificate, download private key.
    rename generated-private-key.txt to private.key (optional, whatever name you like,you will use same name in WWW file)




 ++++++++ centOS SSL apache    +++++++++++

     godaddy cpanel  --------- click SSL/TLS


1) click Private Keys (KEY), delete old private key, upload a new private key.(renew, private key, no change skip this )



2) click Certificate Signing Requests (CSR)
   skip this, since godaddy already put certificate crt file on download zip.
   If you want to re-key, you do want send Certificate Signing Requests (CSR)
   and wait until get crt file



3) click Certificates (CRT), this is where you need upload your crt(certificate) file to centOS apache server.
   click to Upload a New Certificate, choose the 6e1dce9c9beeeed6.crt file(publick.cert) you downloaded from godaddy.
   you may want to choose apache version one.

   Once upload,you should see a new certificate saved on server.




4) click Install and Manage SSL for your site (HTTPS)
     I. uninstall all old certificate (see expiratin date)

     II. click browse certificates, choose the one you saved on last step certificate(CRT)
         click install certificate



5) Do not forget  re-upload node.js (with new certificate), arcgis_viewer and cors-anywhere



********* only renew ***********

1) download certificate zip file from godaddy,
     only 6e1dce9c9beeeed6.crt is we need.

2) upload crt file to cpanel.  cpanel -- ssl , click certificate(CRT)

      upload a new certificate, click choose file, choose xxx.crt(just downloaded).

3) install new crt, by click install.


---------------------------



******************** full steps ***********************

godaddy SSL

ON Server

1) cpanel  --------- click SSL/TLS

2) click
Certificate Signing Requests (CSR)

    click Generate


3) copy first part:  encoded CSR



ON godaddy

my product ------------ SSL certificate ----- click manage button


you should see your ssl certificate, click it.

Re-Key

Top menu, click repository,

3 big button, download, re-key,  xxx.  click re-key

3 plus + sign, click first +,  past your CSR here.


Click Save button

at bottom, click "generate certificate" button.


Wait ..................  hours? days?.........................


You got a email from godaddy,  follow download link to download zip file.

zip file has 2 crt file.


Upload 2 crt file at cpanel.  click SSL/STL

click
Certificates (CRT)

Upload a New Certificate


choose file, 2 crt.

then you upload crt.



at SSL/STL   click
Manage Installed SSL Websites

click

Browse certificate, choose the new one you just uploaded.

then install.

Done





****** check certificate ******

https://ssltools.godaddy.com/views/certChecker








node express add SSL



1)
download private key file from cpanel ----- ssl/STL ---- private key---
click edit, copy encoded part into a new file. Save to /bin/www/private.key

2)
download certificate file, from godaddy, my product, SSL,
click download button, choose other type.

Only 1 file xxxx.crt is the one we need, copy to  /bin/www/public.cert

 you can copy past encoded certificate from cpanel---ssl , click Certificate(CRT),   click edit,
copy encoded certificate


3)
/bin/www  file add https code.

// readFileSync function must use __dirname get current directory


// require use ./ refer to current directory.















Sunday, March 29, 2020

egpu


https://github.com/mayankk2308/purge-wrangler/wiki/Beginner's-Guide

1) disable SIP by restart and hold command + R until see apple logo

     in recovery mode, utility > terminal 
     run : csrutil disable


      restart



2)navi card, must manually do AMD patch

https://github.com/mayankk2308/purge-wrangler/issues/44

   open terminal run: 
 
curl -qLs $(curl -qLs https://bit.ly/2WtIESm | grep '"browser_download_url":' | cut -d'"' -f4) > purge-wrangler.sh; sh purge-wrangler.sh; rm purge-wrangler.sh

choose "Setup eGPU" by pressing 1

   For Nvidia card, you have have Nvida web driver already installed, otherwise, not find epu 

   For AMD, native supported card, power on egpu, will auto detect.

    For AMD navi card, do not power on egpu, if you power on, Mac will crash to white error screen and reboot and crash loop.

     Instead you should press ESC to cancel auto detect 

      then press 1. AMD (vendor) to manually patch 


      restart


3) Enforce both external and Internal display use egpu by set-ogpu
 https://github.com/mayankk2308/set-egpu

    terminal run:
curl -q -s "https://api.github.com/repos/mayankk2308/set-egpu/releases/latest" | grep '"browser_download_url":' | sed -E 's/.*"browser_download_url":[ \t]*"([^"]+)".*/\1/' | xargs curl -L -s -0 > set-eGPU.sh && chmod +x set-eGPU.sh && ./set-eGPU.sh && rm set-eGPU.sh

future use, just
set-eGPU

choose 1. all application

will enforce all application include internal display use egpu

Done

Friday, February 28, 2020

centOS CORS on Apache


cpanel, top right corner, click setting, make sure show hidden files.


go to The folder you wish CORS, in our case, it is /data/ 

add .htaccess file

add one line at   .htaccess  file.

done
 Header set Access-Control-Allow-Origin "*"

Monday, January 6, 2020

adsense



/includes/qa-theme-base.php
1 file, 2 place need add adsense, 


header_script add adsense for home page, 
public function head_script()
    {
        if (isset($this->content['script'])) {
            foreach ($this->content['script'] as $scriptline) {
                $this->output_raw($scriptline);
            }
        }



/* header
google adsense added
*/
        $this->output('');



    }




Do not need this one, if add this one, every post will have error duplicate tag, second tag will be ignored.

this is for each post add adsense




public function q_view_main($q_view)
    {
        $this->output('
'
);

        if (isset($q_view['main_form_tags'])) {
            $this->output('
. $q_view['main_form_tags'] . '>'); // form for buttons on question
        }

        $this->view_count($q_view);
        $this->q_view_content($q_view);


/**
google adsense added
*/
        $this->output('');


        $this->q_view_extra($q_view);






https://www.question2answer.org/qa/14080/where-to-insert-custom-html-code-adsense-etc


Ok. I got it. Open includes/qa-theme-base.php and go down find see code under function q_view_main($q_view) on or around line # 1672. I wanted to put the adsense banner direcly below the question text/content and before the tags. So I inserted a new line $this->output('my adsense code
');
 right under the line that says $this->q_view_content($q_view);   . It worked great. Now I'll probably go about learning how to implement this using advanced themes by creating a custom q_view_main($q_view) function to override the default code. Any tips/example for newbies for creating function overrides would be appreciated from more experienced users. Thanks.

Monday, September 2, 2019

delete OEM system partition win 10

Windows Disk Management tool will not let you delete/merge the OEM partition. You will have to use the built-in command line tool called Diskpart.
Be careful before you decide to run the commands, lest you mess up – you should know what you are doing:
  • Open the Run prompt, type diskpart, and hit Enter.
  • Type, and enter list disk to list the disks.
  • Select the disk you want to manage – say it is Disk Z
  • Then type select disk z and hit Enter.
  • Enter list partition and hit Enter to display all the volumes.
  • Type select partition x and hit Enter. Here x stands for the partition you want to delete.
  • Finally, type delete partition override and hit Enter to delete it.
  • Now type Extend to merge the OEM partition with the adjoining value.
If you want only to merge part of the partition, then use extend [size=]  command. To extend size by 5GB, type-
Extend size=5000
Here size is the size you choose from the OEM partition.  It will extend the selected volume by size in megabytes (MB). So like you can see, delete and merge partition commands work hand to hand. You need first to delete it and then merge it existing partition.

Tuesday, August 6, 2019

siteSucker setting



https://github.com/microsoft/USBuildingFootprints

download zip file only, all default, except path constraint, setting customzied path.

file type choose zip archive not works