Skip to content

Instantly share code, notes, and snippets.

View bhubr's full-sized avatar

Benoît Hubert bhubr

View GitHub Profile
@bhubr
bhubr / pipeline-stages-stats.js
Created March 28, 2024 15:48
Extract a pipeline's jobs durations in GitLab CI
// paste & run in browser console, at:
// https://gitlab.com/<login>/<repo>/-/pipelines/<pipeline id>/builds
(() => {
const jobsTable = document.querySelector("[data-testid=jobs-tab-table]");
const rows = jobsTable.querySelectorAll("tbody tr");
const jobs = Array.from(rows)
.reverse()
.map((row) => {
const duration = row
.querySelector("[data-testid=job-duration]")
@bhubr
bhubr / psql-quickstart-macos.md
Last active March 26, 2024 20:54
PostgreSQL quickstart macOS/homebrew
@bhubr
bhubr / cart.e2e.ts
Last active March 26, 2024 09:43
Tests e2e cours CI/CD
// test/specs/cart.e2e.ts
import { expect, browser, $ } from "@wdio/globals";
import registerUser from "../helpers/register-user";
describe("Cart", () => {
// Ce test comporte plusieurs problèmes
// 1. bug de l'app qui fait qu'on ne peut ajouter des items au panier que connecté
// CORRIGÉ si vous avez mergé la dernière version de main
// 2. composante aléatoire qui fait qu'on est pas sûr qu'un produit soit dispo
it("user connected - should add items to cart", async () => {
@bhubr
bhubr / README.md
Created December 28, 2023 20:09
Sanitize WordPress SQL dump

Sanitize WordPress SQL dump

You might run into errors while injecting a WP SQL dump into a local db (say your remote db is MySQL 5+ and your local one is MySQL 8).

In this case…

1. make a copy of the dump

cp orig-dump.sql sanitized-dump.sql
@bhubr
bhubr / gist:51914d4e1030fea4e17a2b8980d9a7ec
Created December 5, 2023 02:52
Connect to GitLab with custom SSH key
Assuming I put this in `~/.ssh/config`:
```
Host gitlab-public
HostName gitlab.com
User gluser
ForwardAgent yes
IdentityFile /Users/myuser/.ssh/id_ed25519_gitlab_public
```
@bhubr
bhubr / _README.md
Last active March 15, 2023 13:08
Convert macOS colored terminal output (ANSI) to HTML

Convert macOS ANSI-colored terminal output to HTML

ansi2html is a much better solution. Why didn't I think of it before 😅🤷‍♂️?

  • Tested on macOS but should work on Linux.
  • Requires Node.js (any recent version will do).
  • Put package.json and convert.js in the same dir, and run npm i there.
  • In macOS Terminal, run shell command and redirect its stdout or stderr to a file, e.g. gls --color ~/Documents > gls-output.txt.
  • Run node convert gls-output.txt.
  • Open out.html in your browser.
@bhubr
bhubr / sonarqube.service
Created March 1, 2023 06:25 — forked from W1R3D-Code/sonarqube.service
Running SonarQube as a Service on Linux with SystemD - /etc/systemd/system/sonarqube.service
[Unit]
Description=SonarQube service
After=syslog.target network.target
[Service]
Type=forking
ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start
ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop
@bhubr
bhubr / .prettierrc.json
Last active March 1, 2023 06:11
Quick Express + TypeScript setup
{
"singleQuote": true
}
@bhubr
bhubr / README.md
Last active January 2, 2023 13:25
bzip2 progress bar with pv (Pipe Viewer)

bzip2 progress bar with pv (Pipe Viewer)

Context: I was attempting to compress a fairly big (16Gb) file with bzip2, but had no idea of how much time it would take.

The solution I came up with isn't perfect, since it doesn't show an actual percentage, but it still gives an idea of what's going on, since it prints the compressed file's current size, along with the elapsed time.

Sources

@bhubr
bhubr / VBoxManage.md
Last active December 22, 2022 09:55
VBoxManage quick cheat-sheet (run headless VMs)

VBoxManage

List VMs

VBoxManage list vms

Result: