Skip to content

Instantly share code, notes, and snippets.

View ricardodantas's full-sized avatar
👋
hi!

Ricardo Dantas ricardodantas

👋
hi!
View GitHub Profile
@ricardodantas
ricardodantas / install-docker-compose.sh
Created November 1, 2021 14:48
Install docker-compose
#!/bin/bash
if ! [ -x "$(command -v docker-compose)" ]; then
curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-\$(uname -s)-\$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
fi
docker-compose --version
@ricardodantas
ricardodantas / check-servers-ready.sh
Last active October 27, 2021 12:36
Bash Script utility to check if the services are up and running.
#!/bin/bash
SERVICES_LIST=(http://localhost:3001/healthcheck http://localhost:3000/healthcheck)
isServiceReady(){
ping=$(curl -s -f -LI $1)
if [ -z "$ping" ]; then
false;
else
true;
@ricardodantas
ricardodantas / googleapis-fetch-user-groups.js
Created August 25, 2021 08:17
Fetch user groups using an impersonated Service Account from Google Admin drectory.
/*
* Fetch users groups through an impersonated Service Account
*/
const { google } = require('googleapis');
const credentials = require('../service-account-credentials.json')
const scopes = [
'https://www.googleapis.com/auth/admin.directory.user.readonly',
'https://www.googleapis.com/auth/admin.directory.group.readonly',
]
@ricardodantas
ricardodantas / Dockerfile
Created June 2, 2021 10:41
Dockerfile for a Nginx + React app
# Multi-stage
# 1) Node image for building frontend assets
# 2) nginx stage to serve frontend assets
# Name the node stage "builder"
FROM node:10 AS builder
# Set working directory
WORKDIR /app
# Copy all files from current directory to working dir in image
COPY . .
@ricardodantas
ricardodantas / my-favorite-dev-resources.md
Last active November 3, 2021 08:14
My favorite dev resources

My favorite tools and resources

🚧 Still in progress

Languages

  • Javascript/NodeJs/TypeScript

Databases

  • PostgreSQL
@ricardodantas
ricardodantas / lazy-load-image.html
Created April 2, 2021 18:01
Native lazy loading attribute
<img src="image.png" loading="lazy" alt="…" width="200" height="200"/>
@ricardodantas
ricardodantas / webp.html
Created April 2, 2021 16:03
Using WebP format
<!--
The browser uses the first listed source that's in
a format it supports. If the browser does not support
any of the formats listed in the <source> tags, it
falls back to loading the image specified by the <img> tag.
-->
<picture>
<source type="image/webp" srcset="green-environment.webp">
<source type="image/jpeg" srcset="green-environment.jpg">
<img src="green-environment.jpg" alt="">
@ricardodantas
ricardodantas / gif-to-video.html
Last active April 2, 2021 15:35
Switch from GIFs to video
<video autoplay loop muted playsinline>
<source src="/saving-energy.webm" type="video/webm">
<source src="/saving-energy.mp4" type="video/mp4">
</video>
@ricardodantas
ricardodantas / transpose_2d_array.js
Created March 22, 2021 14:56
Transpose 2D array (ES6)
const transpose = a => a[0].map((_, c) => a.map(r => r[c]));
@ricardodantas
ricardodantas / onclick.jsx
Created March 16, 2021 08:27
React: Passing event with parameter onClick
// ES6
const clickHandler = (parameter) => (event) => {
// Do something
alert('Here is your parameter:', parameter);
};
// -----
// Standard JS