How rclone works

Introduction Data migration is one of the major issues nowadays, it becomes inevitable for most organization trying to scale up their business or look for better data protection. There are many ways and companies providing solutions in this field. rclone is an open source tool that manages files on cloud storage. Here will present some information on how to config rclone and cloud-to-cloud transfer. rclone installation Follow steps to install rclone. rclone configuration pre-requisites ...

September 21, 2022 · 3 min · 448 words · Ken Cho

How Yii migration script works

Comming soon! Reference yii2 migration php yii2 migration yii2 migration doc

August 17, 2022 · 1 min · 11 words · Ken Cho

How to build portainer in production

GigaDB Portainer service What is portainer? Portainer is an open-source management UI for Docker, including Docker Swarm environment. Portainer makes it easier for you to manage your Docker containers, it allows you to manage containers, images, networks, and volumes from the web-based Portainer dashboard. Pre-requisites The staging server and live server are up and running. Here and here are the details of how to provision and configure an EC2 server using Ansible and Terraform. The Let’s Encrypt certificate fallout has been fixed by getting the latest code from this PR #198. Have Docker Hub account, and store DOCKER_HUB_USERNAME and DOCKER_HUB_PASSWORD which is the access token in gitlab CI/CD variables. Steps to configure the portainer, details can be found at this PR #201 Changes to the DNS record Create an A record for access portainer on staging and on live as following: Record name Type IP portainer.$staging_url A staging server IP portainer.$live_url A live server IP Changes to the gitlab variables Create a new variable as following: Key Value Environment PORTAINER_PASSWORD “Password” All(default) DOCKER_HUB_USERNAME “User name” All(default) DOCKER_HUB_PASSWORD “Access token” All(default) Variable PORTAINER_BCRYPT (if any) could be deleted. ...

November 15, 2021 · 2 min · 327 words · Ken Cho

How to add portainer for monitoring dockers

Task Make portainer on staging and live deployment accessible with HTTPS on default port #790 Add portainer container service on staging and live deployment #791 PR #201 Steps A. Add portainer service available locally Update docker-compose.yml portainer: image: portainer/portainer-ce:latest volumes: - /var/run/docker.sock:/var/run/docker.sock - portainer_data:/data ports: - 9009:9000 - 8008:8000 command: -H unix:///var/run/docker.sock --admin-password $PORTAINER_BCRYPT volumes: le_config: le_webrootpath: portainer_data: Create PORTAINER_PASSWORD in gitlab variables Create start_portainer.sh, if-else block to avoid keep generating PORTAINER_BCRYPT in .env #!/usr/bin/env bash # bail out as soon as there is an error set -eux # Load environment variables source "./.env" source "./.secrets" # docker-compose executable if [[ $GIGADB_ENV != "dev" && $GIGADB_ENV != "CI" ]];then DOCKER_COMPOSE="docker-compose --tlsverify -H=$REMOTE_DOCKER_HOST -f ops/deployment/docker-compose.production-envs.yml" else DOCKER_COMPOSE="docker-compose" fi if ! [ -z "${PORTAINER_BCRYPT+x}" ];then echo "PORTAINER_BCRYPT value has been set in .env already" # start portainer in detached mode and make sure volume are recreated (rather than use potential previous state that my be erroneous) $DOCKER_COMPOSE up --detach --renew-anon-volumes portainer else echo "PORTAINER_BCRYPT value is empty" echo "Generate bcrypt from password" P_BCRYPT=$(docker run --rm httpd:2.4-alpine htpasswd -nbB admin $PORTAINER_PASSWORD | cut -d ":" -f 2 | sed -e 's/\$/\\\$/g') echo "PORTAINER_BCRYPT=$P_BCRYPT" >> .env # start portainer in detached mode and make sure volume are recreated (rather than use potential previous state that my be erroneous) $DOCKER_COMPOSE up --detach --renew-anon-volumes portainer fi Update up.sh to only start portainer in MacOS # start the container admin UI (not in CI) if [ "$(uname)" == "Darwin" ];then ./ops/scripts/start_portainer.sh fi; Spin up all containers kencho/gigadb-website % ./up.sh Test the http response using curl % curl -I localhost:9009 HTTP/1.1 200 OK Accept-Ranges: bytes Cache-Control: max-age=31536000 Content-Length: 6176 Content-Type: text/html; charset=utf-8 Last-Modified: Sun, 10 Oct 2021 23:45:45 GMT X-Content-Type-Options: nosniff X-Xss-Protection: 1; mode=block Date: Thu, 21 Oct 2021 08:14:01 GMT Go to http://localhost:9009/ and have fun! Reference Heavily adapted form here ...

October 21, 2021 · 2 min · 304 words · Ken Cho

How to Make Dropdown Button

Task To implement a dropdown box with different citation source, description at [Issue #83](PR #521 PR #521 Steps Create dropdown in bootstrap way <div id="dataset-block-wrapper"> <div id="dropdown-div"> <div class="dropdown-box"> <button id="CiteDataset" class="drop-citation-btn dropdown-toggle" type="button" data-toggle="dropdown">Cite Dataset<span class="caret"></span></button> <?php $text = file_get_contents('https://data.datacite.org/text/x-bibliography/10.5524/' . $model->identifier); $clean_text = strip_tags(preg_replace("/&#?[a-z0-9]+;/i", "", $text)); ?> <script> function showText() { var textWindow = window.open(); textWindow.document.write(`<?php echo $clean_text; ?>`); } </script> <ul class="dropdown-menu" aria-labelledby="CiteDataset"> <li><a id="Text" onclick="showText()" target="_blank">Text</a></li> <li><a id="citeRis" href='https://data.datacite.org/application/x-research-info-systems/10.5524/<?php echo $model->identifier;?>' target="_self">RIS</a></li> <li><a id="citeBibTeX" href='https://data.datacite.org/application/x-bibtex/10.5524/<?php echo $model->identifier;?>' target="_self">BibTeX</a></li> </ul> </div> </div> </div> Create dropdown in javascript way <div id="dropdown-div"> <div> <a id="CiteDataset" onclick="showCitation()" class="drop-citation-btn" >Cite Dataset<span class="caret"></span></a> <div id="citationDropdown" class="citation-content"> <?php $text = file_get_contents('https://data.datacite.org/text/x-bibliography/10.5524/' . $model->identifier); $clean_text = strip_tags(preg_replace("/&#?[a-z0-9]+;/i", "", $text)); textWindow.document.write(`<?php echo $clean_text; ?>`); </script> <ul> <li><a id="Text" onclick="showText()" target="_blank">Text</a></li> <li><a id="citeRis" href='https://data.datacite.org/application/x-research-info-systems/10.5524/<?php echo $model->identifier;?>' target="_self">RIS</a></li> <li><a id="citeBibTeX" href='https://data.datacite.org/application/x-bibtex/10.5524/<?php echo $model->identifier;?>' target="_self">BibTeX</a></li> </ul> </div> </div> </div> <script> /* When the user clicks on the button, toggle between hiding and showing the dropdown content */ function showCitation() { document.getElementById("citationDropdown").classList.toggle("show"); } // Close the dropdown if the user clicks outside of it window.onclick = function(event) { if (!event.target.matches('.drop-citation-btn')) { var dropdowns = document.getElementsByClassName("citation-content"); var i; for (i = 0; i < dropdowns.length; i++) { var openDropdown = dropdowns[i]; if (openDropdown.classList.contains('show')) { openDropdown.classList.remove('show'); } } } } //Write the clean text to a new window function showText() { var text = `<?php echo $clean_text; ?>` console.log(text); var textWindow = window.open(); textWindow.document.write(text); } </script> Thoughts Since html comes with bootstrap with default dropdown features, it is better use it, as it is cleaner and less code. But good to know how to implement dropdown in javascript Pass the acceptance test /** * @Then I go to new tab and should see :arg1 */ public function iGoToNewTabAndShouldSee($arg1) { $session = $this->minkContext->getSession(); $numberOfTab = $session->getWindowNames(); if (sizeof($numberOfTab) < 2) { print ("Expected to see at least 2 windows opened."); exit; } $session->switchToWindow($numberOfTab[1]); PHPUnit_Framework_Assert::assertTrue($session->getPage()->hasContent($arg1)); } /** * @When I click :arg1 * To trigger onclick event */ public function iClick($arg1) { $element = $this->minkContext->getSession()->getPage()->find('css', "a[id='$arg1']" ); $element->click(); } @ok @javascript @citation-box Scenario: To see the citation box and and the citation source Given I am not logged in to Gigadb web site And I am on "/dataset/101001" When I press "Cite Dataset" Then I should see "Text" And I should see "RIS" And I should see "BibTeX" @ok @javascript @citation-box Scenario: To show the citation text from CrossCite after clicking the Formatted Text button in the citation box Given I am not logged in to Gigadb web site And I am on "/dataset/101001" And I press "Cite Dataset" When I click "Text" Then I go to new tab and should see "Huang, Y., Li, Y., Burt, D. W., Chen, H., Zhang, Y., Qian, W., Kim, H., Gan, S., Zhao, Y., Li, J., Yi, K., Feng, H., Zhu, P., Li, B., Liu, Q., Fairley, S., Magor, K. E., Du, Z., Hu, X., … Li, N. (2013). Genome sequence of the duck (Anas platyrhynchos) [Data set]. GigaScience Database. https://doi.org/10.5524/101001" @ok @javascript @citation-box Scenario: To get RIS file after clicking the RIS in the citation box Given I am not logged in to Gigadb web site And I am on "/dataset/101001" And I press "Cite Dataset" When I click on the "RIS" button Then the response should contain "101001" # 200: the request completed successfully And the response should contain "200" @ok @javascript @citation-box Scenario: To get BibTeX file after clicking the BibTeX in the citation box Given I am not logged in to Gigadb web site And I am on "/dataset/101001" And I press "Cite Dataset" When I click on the "BibTeX" button Then the response should contain "101001" # 200: the request completed successfully And the response should contain "200" Reference What is Tabnabbing? How to solve it? here ...

May 21, 2021 · 3 min · 626 words · Ken Cho