Skip to content

Instantly share code, notes, and snippets.

View sdesalas's full-sized avatar
🕹️

Steven de Salas sdesalas

🕹️
View GitHub Profile
const util = require('util');
setTimeout(async () => {
db.getData = util.promisify(db.getData);
db.processData = util.promisify(db.processData);
db.saveData = util.promisify(db.saveData);
try {
@sdesalas
sdesalas / docker.alpine.install.awscliv2.sh
Last active March 26, 2024 14:50
Install AWSCLIv2 in `docker:latest` alpine image for running docker-dn-docker depoyments in Gitlab
# `docker:latest` image uses base alpine linux
# This script allows installing awscliv2 which requires
# gcc buildtools (instead of default `musl` in alpine)
# https://stackoverflow.com/questions/60298619/awscli-version-2-on-alpine-linux
GLIBC_VER=2.31-r0
# install glibc compatibility for alpine
apk --no-cache add \
binutils \
jq \
@sdesalas
sdesalas / gitlab-runner-install.sh
Last active January 24, 2022 17:36
Gitlab Runner in Ubuntu 18/20 with TLS enabled (for docker:dind)
# 0. SET YOUR GROUP REGISTRATION TOKEN
# @see https://gitlab.com/groups/mygroup/-/settings/ci_cd#runners-settings
export GITLAB_REGISTRATION_TOKEN=abc123def456
# 1. INSTALL GITLAB RUNNER
# @see https://docs.gitlab.com/runner/install/linux-repository.html
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
export GITLAB_RUNNER_DISABLE_SKEL=true; sudo -E apt-get install gitlab-runner
@sdesalas
sdesalas / parse_dotenv.bash
Created March 30, 2020 11:11 — forked from judy2k/parse_dotenv.bash
Parse a .env (dotenv) file directly using BASH
# Pass the env-vars to MYCOMMAND
eval $(egrep -v '^#' .env | xargs) MYCOMMAND
# … or ...
# Export the vars in .env into your shell:
export $(egrep -v '^#' .env | xargs)
@sdesalas
sdesalas / md5.js
Created February 6, 2020 18:28
Native MD5 in node.js
var crypto = require('crypto');
module.exports = function(data) {
return crypto.createHash('md5').update(data).digest("hex");
};
@sdesalas
sdesalas / Async.gs
Last active May 9, 2024 07:02
Asynchronous execution for Google App Scripts (gas)
/*
* Async.gs
*
* Manages asyncronous execution via time-based triggers.
*
* Note that execution normally takes 30-60s due to scheduling of the trigger.
*
* @see https://developers.google.com/apps-script/reference/script/clock-trigger-builder.html
*/
@sdesalas
sdesalas / .index.html
Last active July 11, 2019 07:43
Promises Mini-Dojo
<html>
<head>
<title>Frogmore High School - Fetch array, combine and reorder</title>
<script>
// Step 1: Copy this html file locally as index.html
// Step 2: Edit the <script> section to fetch data from these 2 urls
// - Students: https://api.myjson.com/bins/vm1oz
// - Marks: https://api.myjson.com/bins/fjccz
// Step 3: Combine it into one single array by student id
<html>
<head>
var students = [
{"id":"905126","firstname":"Bob","lastname":"Smith","maths":9.9,"english":3.3},
{"id":"739559","firstname":"Harry","lastname":"Talbot","maths":5.6,"english":6.1},
{"id":"878999","firstname":"Pradosh","lastname":"Brown","maths":4.7,"english":8.1},
{"id":"421848","firstname":"Anna","lastname":"Ashley","maths":4.7,"english":5.5},
{"id":"073342","firstname":"Melanie","lastname":"Brown","maths":7.8,"english":4.2},
{"id":"503297","firstname":"Andrew","lastname":"Kimber","maths":8.3,"english":8.9},
{"id":"318977","firstname":"Peter","lastname":"Johnson","maths":9.3,"english":2.3},
@sdesalas
sdesalas / index.js
Created July 3, 2019 08:20
Time Ago Dojo
const moment = require('moment')
// TRABAJAR AQUI
module.exports = function timeago(date){
return moment(date).fromNow()
}
module.exports = function gcd(a, b) {
let arra = [];
let arrb = []
for (let i=0; i<= a; i++){
if (a%i ===0) {
arra.push(i);
}
}
for (let j=0; j<= b; j++){