Skip to content

Instantly share code, notes, and snippets.

View cedricmillet's full-sized avatar

Cédric MILLET cedricmillet

  • Somewhere on earth
View GitHub Profile
@cedricmillet
cedricmillet / Dockerfile
Created November 20, 2024 10:44
Install redis-cli on amazonlinux distro docker image
FROM public.ecr.aws/amazonlinux/amazonlinux:2023
RUN dnf install -y wget tar gzip make gcc
RUN wget http://download.redis.io/redis-stable.tar.gz && \
tar -xvzf redis-stable.tar.gz && \
cd redis-stable && \
make && \
cp src/redis-cli /usr/local/bin/ && \
chmod 755 /usr/local/bin/redis-cli
@cedricmillet
cedricmillet / grc.sh
Last active January 3, 2025 10:09
AWS GRC (Git Remote CodeCommit) install
# 0. Install git/python3/last pip version (requires 9.0.3 or later)
sudo yum install -y git python3
curl -O https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py --user
pip --version
# 1. Install GRC from pip
pip install git-remote-codecommit
# 2. Setup AWS service account credentials
@cedricmillet
cedricmillet / install.sh
Last active July 11, 2024 17:55
Bypass builtin vscode server installation AMZNLINUX 2023
# Manually install vscode server when the remote EC2 is off-network.
commit="f1e16e1e6214d7c44d078b1f0607b2388f29d729" # Version: 1.91.1 (Help > About)
mkdir -p /home/$USER/.vscode-server/bin/$commit
wget https://update.code.visualstudio.com/commit:$commit/server-linux-x64/stable
tar -xvf stable -C /home/$USER/.vscode-server/bin/$commit
# Optional - CLI
#wget https://update.code.visualstudio.com/commit:$commit/cli-linux-x64/stable -O vscode-cli-$commit.tar.gz
@cedricmillet
cedricmillet / parse-java-files-with-typescript.ts
Last active June 30, 2024 17:46
Parse .java files with typescript using chevrotain CST (Concrete Syntax Tree)
/**
* package.json : "type": "module" / "java-parser": "^2.3.0"
* tsconfig.json: "esModuleInterop": true / "target": "es2020" / "esModuleInterop": true
*/
import { readFileSync } from 'fs';
import { BaseJavaCstVisitorWithDefaults, ClassDeclarationCtx, ClassMemberDeclarationCtx, CstNode, EnumDeclarationCtx, MethodDeclarationCtx, ModularCompilationUnitCtx, OrdinaryCompilationUnitCtx, PackageDeclarationCtx, TypeDeclarationCtx, parse } from 'java-parser';
import { Utils } from './utils';
export enum ElementType {
PACKAGE = "package",
@cedricmillet
cedricmillet / stack.ts
Created June 14, 2024 08:44
Create a VPC interface endpoint for SecretsManager / AWS TypeScript CDK
// Create a new VPC endpoint for Secrets Manager
const vpcEndpoint = vpc.addInterfaceEndpoint(`${id}SecretsManagerEndpoint`, {
service: ec2.InterfaceVpcEndpointAwsService.SECRETS_MANAGER,
subnets: {subnets: [...allSubnets]} as ec2.SubnetSelection,
securityGroups: [yourSecurityGroup],
});
vpcEndpoint.applyRemovalPolicy(cdk.RemovalPolicy.DESTROY);
cdk.Tags.of(vpcEndpoint).add(`Name`, `endpoint-secretsmanager`); // Not fixed https://github.com/aws/aws-cdk/issues/19332
@cedricmillet
cedricmillet / readSecretAwsSDK.ts
Last active May 12, 2024 13:08
Use typescript aws-sdk and SecretManager client to read secret value in aws lambda
import * as SecretManager from "aws-sdk/clients/secretsmanager";
import { AWSError } from 'aws-sdk/lib/error';
const [region, accessKeyId, secretAccessKey, sessionToken] = [
process.env.AWS_REGION,
process.env.AWS_ACCESS_KEY_ID || "",
process.env.AWS_SECRET_ACCESS_KEY || "",
process.env.AWS_SESSION_TOKEN || ""
];
const client = new SecretManager({
@cedricmillet
cedricmillet / connect.js
Created May 5, 2024 13:55
nodeJS - Test PostgreSQL database connection
/**
* Test connection on any PostgreSQL-like database
*/
const pg = require('pg');
const username="XXX";
const password="XXX";
const hostname="XXX";
const dbname="XXX";
const port=5432;
@cedricmillet
cedricmillet / install.sh
Created March 3, 2024 14:56
(RHEL/CENTOS) Install python + autogluon + jupyter lab
# Last test on RHEL 6.11 (with 4 Gb, 2vCPU)
sudo yum update -y
sudo yum install -y python3 python-pip python3-devel
# Inscrease /tmp directory size (3.5 G is required to run "pip install autogluon")
sudo mount -o remount,size=5G,noexec,nosuid,nodev,noatime /tmp
df -h /tmp
# Install autogluon
@cedricmillet
cedricmillet / isntall_docker_amzlnx2.sh
Created January 9, 2024 10:40
Docker installation EC2 Amazon Linux 2
sudo yum update
sudo yum install docker
sudo usermod -a -G docker ec2-user
newgrp docker
# Optional: docker-compose
wget https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)
sudo mv docker-compose-$(uname -s)-$(uname -m) /usr/local/bin/docker-compose
sudo chmod -v +x /usr/local/bin/docker-compose
@cedricmillet
cedricmillet / db2_rtcl_install.sh
Last active January 4, 2024 16:34
Install IBM Data Server Runtime Client on Amazon Linux 2
# ibm_data_server_runtime_client_linuxx64_v11.5.tar.gz can be downloaded here:
# https://www.ibm.com/support/pages/node/6830885
INSTALL_DIR="$HOME/data-server-runtime-client" && mkdir -p $INSTALL_DIR
tar -xvf ibm_data_server_runtime_client_linuxx64_v11.5.tar.gz -C $INSTALL_DIR
# (root) prevent error "The db2prereqcheck utility was unable to determine the Linux distribution level"
cp /etc/os-release /etc/lsb-release
yum install -y gcc gcc-g++ libxcrypt-compat