Category: tech

How to get a random number in bash

Use the $RANDOM. $RANDOM returns a number between 0 and 32767. To get a random number between 0 and 50 you can use $ echo $[RANDOM%50] $ # or $ echo $((RANDOM%50)) To get a random number between 1 and 50 you can use $ echo $[RANDOM%50+1] $ # or $ echo $((RANDOM%50+1)) Read more...

How to solve Outlook cannot parse the property 'TRIGGER'

This errors is due to what seems to be an incompatibility between Google calendar reminders and Outlook. I guess that Google uses some proprietary content in the iCal that Outlook does not manage. Result: I do not have reminders in Outlook :( but the otherwise the calendar works well. Read more...

How to implement the AWS recommended exponential backoff and jitter in JavaScript (and Observable)

Also known as Solving “ThrottlingException: Rate exceeded” in Javascript with Exponential backoff + Jitter The ThrottlingException: Rate exceeded error is a frustrating one, mainly because it has a series of bad habits: it happens mostly in production, randomly (or so it seems), and often in the middle of a critical loop in the code. The error is an AWS protection mechanism to avoid being flooded with requests from buggy code, like an infinite loop, yet the responsibility is left to us, developers in the coding trenches, to get around the error. Read more...

How to create a multi-line string in JavaScript (and Observable)

While this post is triggered by working with Observable the solution works for Javascript ES6+. I use Observable to connect to the AWS pricing data, stored on a PostgreSQL instance on AWS. So far so good, Observable allows for easy connection to databases. When trying to write the code to query the database from Javascript data = db.query("SELECT * FROM amazonec2 LIMIT 10 ") I would get the error message “Unterminated string constant”. Read more...

How to get today and yesterday in PosgreSQL

Very useful dates functions for PostgreSQL. The official documentation is here. Getting the current date and time SELECT NOW() Getting the current day, no time SELECT date_trunc('day', NOW())::date; One hour later SELECT (NOW() + interval '1 hour') AS one_hour_later; One day later SELECT NOW()+1 The day before SELECT NOW()-1 For more complex calculations you can use intervals For example: SELECT (NOW() + interval '1 day') AS now_but_tomorrow; Other articles for databases geeks Using Athena from the AWS CLI on Linux Getting today in Athena Getting today in PostgreSQL How to get the metadata of AWS Athena tables Get the number of columns in an AWS Athena table Read more...

When to choose Cloud SQL and when to choose Spanner in Google Cloud

One of the most challenging parts of using the cloud is to choose the right product. Often, the cloud vendors, in this case, Google Cloud, will provide two or more services that seem to provide exactly the same functionalities. Cloud SQL and Cloud Spanner are in that category. Both services allow to store and interrogate data with SQL, both are fully managed, and both provide ACID transactions – no drugs involved. Read more...

learning in public - Google Cloud -Professional Cloud Architect

I will be learning in public, my notes - few for now but more to come - are available here Now with the following documentation Cloud resource hierarchy Steaming API Dataflow Pub/Sub Google Cloud Compute Engine - VMs Google Kubernetes Engine Google Operations Suite (formerly Stackdriver) Cloud Storage Deployment manager Cloud Shell Transfer Appliance Spinnaker Cloud Logging Cloud Monitoring Anthos [Cloud Run](https://zt.frankcontrepois.com/Left-side/Certifications/Google+-+Professional+Cloud+Architect/Anthos#Cloud Run) App Engine Cloud Functions Databases Cloud SQL - relational Cloud Spanner 30TB+ SQL Big Table - wide column Cloud Firestore - document BigQuery - analytics Read more...

How to download all the AWS pricing in bash

Hello, this bash one-liner needs bash, a correctly configured AWS CLI, wget, jq and that’s it. The script will: Download the master file Parse the json file with jq extracting, for each product, the url of the current version Create a folder hierarchy with the name of the product (done by the settings of wget) Save the pricing, in that directory For example the pricing of AmazonQLDB will be in the folder AmazonQLDB/current/ Read more...

An article about time and FinOps get all the AWS prices from one line in bash

This one-liner downloads the AWS pricing master file, parse it and download all the files listed in it. wget -q -O - https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/index.json | jq -r '.offers[].currentVersionUrl' | wget -x \-\-base="https://pricing.us-east-1.amazonaws.com" \-\-no-host-directories \-\-cut-dirs=3 -i - A new page about Interesting numbers related to time Read more...