Skip to content

Instantly share code, notes, and snippets.

View bertrandmartel's full-sized avatar
💤
👀

Bertrand Martel bertrandmartel

💤
👀
View GitHub Profile
@bertrandmartel
bertrandmartel / scantest.cpp
Last active February 22, 2024 14:03
Bluez BLE scanning example (port of https://github.com/carsonmcdonald/bluez-experiments in C++)
// g++ scantest.cpp -lbluetooth
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <iostream>
#include <signal.h>
#include <bluetooth/bluetooth.h>
@bertrandmartel
bertrandmartel / keytool_java_import.sh
Created January 16, 2024 12:34
Extract certificates from a truststore and import them into an existing keystore (jre security cacerts)
#!/bin/bash
keystore=$JAVA_HOME/lib/security/cacerts
certs=$(keytool \
-list \
-keystore generic-truststore.jks \
-storepass "" | grep trustedCertEntry | grep -Eo "^[^,]*")
while read -r cert
@bertrandmartel
bertrandmartel / gitlab-ci.yml
Last active January 4, 2024 14:18
[gitlab-ci] increment package.json version from gitlab-ci + commit & push from a specific branch (after MR). SSH_PRIVATE_KEY variable must be defined as deploy key & CI variable
stages:
- versioning
versioning:
stage: versioning
image:
name: amazonlinux:latest
entrypoint: [""]
before_script:
- yum install -y jq git
@bertrandmartel
bertrandmartel / aggregation_lookup.md
Last active December 22, 2023 13:32
MongoDB $lookup aggregation example

MongoDB $lookup aggregation

SO link

db.votes.aggregate([{
    $lookup: {
        from: "users",
        localField: "createdBy",
        foreignField: "_id",
@bertrandmartel
bertrandmartel / github_action_dispatch_runid.py
Created October 8, 2021 18:31
Get the run_id associated to a dispatch in Github actions
import random
import string
import datetime
import requests
import time
# edit the following variables
owner = "YOUR_ORG"
repo = "YOUR_REPO"
workflow = "dispatch.yaml"
@bertrandmartel
bertrandmartel / build_curl.md
Last active October 10, 2023 17:14
Build Curl for Android NDK

Build libcurl for android NDK

Libcurl requires openssl and zlib to be fully operationnal

  • Step 1 : cross compile zlib
  • Step 2 : cross compile openssl
  • Step 3 : cross compile curl with zlib/openssl external link

Prerequisites :

@bertrandmartel
bertrandmartel / stsdecode.sh
Created May 30, 2023 13:15
Script used to decode sts encoded message
#!/bin/bash
if [ -z $1 ]; then
echo "encoded message required"
exit 1
fi
aws sts decode-authorization-message --encoded-message "$1" | jq -r '.DecodedMessage' | jq '.'

Data input :

db.users.insert([{
    "_id": "1",
    "Friends": [
        { "_id": "1", "gender": "male" },
        { "_id": "2", "gender": "male" },
        { "_id": "3", "gender": "male" },
        { "_id": "1", "gender": "male" },
 { "_id": "2", "gender": "male" }
@bertrandmartel
bertrandmartel / credentials
Last active January 10, 2023 10:54
Assume role with MFA for terraform/terragrunt (https://stackoverflow.com/a/66878739/2614364)
[prod]
aws_secret_access_key = redacted
aws_access_key_id = redacted
[tf_temp]
[tf]
credential_process = sh -c 'mfa.sh arn:aws:iam::{account_id}:role/{role} arn:aws:iam::{account_id}:mfa/{mfa_entry} prod 2> $(tty)'