welcome
I’m Ulysses. Sr. Cloud Engineer.
about this website
This sit was based on Hugo.
I’m Ulysses. Sr. Cloud Engineer.
This sit was based on Hugo.
How to look for an access key in AWS. Find the account. $ aws sts get-access-key-info --access-key-id AKIA8XXXXXXXXXXXXXXX { "Account": "XXXXXXXXXXXX" }
How to create service account in GCP via Terraform. provider "google" { project = "your_project_id" } resource "google_service_account" "service_account" { account_id = "your-service-account-name" display_name = "test service account built by terraform" }
Here’s a script to convert date to epoch time on Mac OS. #!/bin/bash if [[ -z $1 ]]; then echo "Format: date2epoch.sh 2022/01/01-04:58:06" else echo "$1"; date -j -f date -j -f "%Y/%m/%d-%T" "$1" +"%s" fi Result $ ./date2epoch.sh 2022/08/31-22:00:00 2022/08/31-22:00:00 1661997600
Connect to your CloudShell environment from your terminal. $ gcloud cloud-shell ssh Welcome to Cloud Shell! Type "help" to get started. first.last@cloudshell $ first.last@cloudshell $ Once logged in, you can set your project. first.last@cloudshell $ gcloud config set project $PROJECT_ID
Here’s how to move a VM to another VPC. Stop VM. gcloud compute instances stop $INSTANCE_NAME \ --zone $ZONE_NAME \ --project $PROJECT_ID Move VM to another VPC. gcloud compute instances network-interfaces update $INSTANCE_NAME \ --zone $ZONE_NAME \ --network-interface=nic0 \ --network $YOUR_NETWORK \ --subnetwork $YOUR_SUBNETWORK \ --project $PROJECT_ID Start VM. gcloud compute instances start $INSTANCE_NAME \ --zone $ZONE_NAME \ --project $PROJECT_ID
How to describe a GCP bucket. gsutil ls -L -b gs://my-bucket
Here’s how to reset a file from the master branch. git checkout origin/master test.py This will undo your changes and matches what’s in the master repo.
Just implemented an Ajax live search on a website. Here’s the search page. Results are displayed in div output. <script src="https://code.jquery.com/jquery-3.4.1.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#search").keyup(function(){ var query = $(this).val(); if (query != "") { $.ajax({ url: 'links-ajax.php', method: 'POST', data: {query:query}, success: function(data){ $('#output').html(data); $('#output').css('display', 'block'); $("#output a").on("click", function(){ $("#output").val($(this).html()); }); $("#search").focusout(function(){ window.setTimeout(function() { $('#output').css('display', 'none'); }, 500); }); $("#search").focusin(function(){ $('#output').css('display', 'block'); }); } }); } else { $('#output').css('display', 'none'); } }); }); </script> <div class="form-row"> <div class="col"> <input autocomplete="off" class="form-control form-control-success" id="search" name="search" placeholder="Search here...." type="text"></input> </div> </div> <div id="output"></div> Here’s the links-ajax.php which display the search results with links. ...
Here’s a quick way to start a web server using Python (not recommended for production). If you want to use python3, you may have to use explicitly use python3. Check what versions you have first. python --version python3 --version Start web server using port 8080 in the current directory. python -m http.server 8080 If you want an alternate directory, use this -d option. python -m http.server 8080 -d /tmp It’s a great tool for quick downloads.
How to find a boot disk from an instance. gcloud compute instances describe servername \ --format='get(disks[0].source)' \ --zone=us-central1-c \ --project project-id Result https://www.googleapis.com/compute/v1/projects/project-id/zones/us-central1-f/disks/servername-boot