Skip to content

Instantly share code, notes, and snippets.

View jeanlescure's full-sized avatar
🚀
Actively Contributing

Jean Lescure jeanlescure

🚀
Actively Contributing
View GitHub Profile
// Get all databases
var dbNames = db.adminCommand( { listDatabases: 1 } ).databases.map(function(dbObj) {
  return dbObj.name;
});

// Size functions
var reduceSize = function(values) {
  return Array.sum(values);
};

Fluid typograghy

body {
  font-size: calc([minimum size] + ([maximum size] - [minimum size]) * ((100vw - [minimum viewport width]) / ([maximum viewport width] - [minimum viewport width])));
}

Example

@jeanlescure
jeanlescure / buildspec.yml
Last active January 10, 2020 22:30
Script, policies, and buildspec to create an AWS CodeBuild Node.js project with access to Github
version: 0.2
phases:
install:
runtime-versions:
nodejs: 10
commands:
- export SKIP="false"
- if [[ "$(git log -1 HEAD --pretty=format:%s)" == *\[test\]* ]]; then echo "Installing yarn..." && npm install -g yarn; else export SKIP="true"; fi
pre_build:
// Given a string containing a list of dates in either format dd/mm/yyyy or mm/dd/yyyy
// where there's one date per line within the string
let a=`28/09/2019
30/09/2019
30/09/2019`;
// Reverse the date's day and month values and return a string with same input format
a = a.split("\n").map((d)=>d.split('/')).map((da)=>([da[1],da[0],da[2]]).join('/')).join("\n")
@jeanlescure
jeanlescure / headless-chrome-ec2.md
Last active September 2, 2023 07:43
How to setup an EC2 instance to run Chrome Headless for usage with Puppeteer

Chrome Headless on EC2

For puppeteer usage

How to setup an EC2 instance to run Chrome Headless for usage with Puppeteer

1. Spin up ubuntu EC2 instance and ssh into it

ssh [email protected]
@jeanlescure
jeanlescure / install-travis-cli.md
Last active October 7, 2019 22:32
How to install Travis CLI on Mac OSX and Windows

1. Install ruby 2.6+:

Mac OSX

curl -L https://get.rvm.io | bash -s stable

source /Users/myuser/.rvm/scripts/rvm

rvm install ruby-2.6.5
@jeanlescure
jeanlescure / README.md
Last active August 12, 2019 19:49
Get CloudWatch logs from AWS ECS instance and format to be easier to read the timestamps

Get CloudWatch logs from AWS

With easy to read format

CLI Package to fetch CloudWatch logs and format them with human readable datetimes

Setup

  • Download all files in this gist
  • Run $ yarn
  • Run $ chmod +x ./get-logs.sh
@jeanlescure
jeanlescure / hot-reload-http-server-one-liner.sh
Created May 26, 2019 08:10
Quickly Setup Hot Reload Environment in OSX
npx browser-sync start -s -f . --no-notify --host `ifconfig | grep "inet " | grep -v 127.0.0.1 | cut -d\ -f2` --port 8080
@jeanlescure
jeanlescure / rename-object-keys.md
Last active February 5, 2019 06:19
Javascript optimized function to rename keys of objects in an array
function renameObjectKeys(objArr, renameMap) {
  const keys = Object.keys(renameMap);

  for (let i = objArr.length - 1; i >= 0; i -= 1) {
    for (let j = keys.length - 1; j >= 0; j -= 1) {
      delete Object.assign(
        objArr[i],
        {[renameMap[keys[j]]]: objArr[i][keys[j]] }
 )[keys[j]];
apt-get update
apt-get install -y software-properties-common
add-apt-repository -y ppa:certbot/certbot
apt-get update
apt-get install -y gpp python zip unzip mariadb-server nginx python-certbot-nginx
systemctl status mariadb
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
source ~/.bashrc
nvm install 10.13
npm install -g yarn