Skip to content

Instantly share code, notes, and snippets.

View adrienjoly's full-sized avatar
☺️
In the flow

Adrien Joly adrienjoly

☺️
In the flow
View GitHub Profile
@adrienjoly
adrienjoly / wait-for-js-server-ready-in-docker-container.sh
Created March 7, 2020 10:45
A script that runs a Node.js HTTP server in a container and waits until that server is ready, thanks to Docker Healthcheck.
#!/usr/bin/env bash
REPO_URL="https://gitlab.com/xxx/node_app-web.git"
PORT=3000
echo "Generate Dockerfile from ${REPO_URL}..."
cat > Dockerfile << CONTENTS
FROM node:10
WORKDIR /usr/src/app
RUN git clone ${REPO_URL} .
allHits=[];
algoliaClient
.initIndex(indexName)
.browseAll()
.on('result', ({hits}) => allHits.push(...hits))
.on('end', () => console.log(allHits));
@adrienjoly
adrienjoly / git-commit-stats-csv-without-deps-and-releases.sh
Last active June 16, 2023 12:32
Display `git diff` stats, one line per commit
git log --pretty=format:"@%ad ~~%s~~" --date=short --shortstat \
| tr "\n" " " \
| tr "@" "\n" \
| grep -v 'skip ci' \
| grep -v 'deps' \
| grep -v 'dependencies' \
| sed -En 's/ ~~.*~~ /,/p'
@adrienjoly
adrienjoly / extract-metadata-from-facebook-note-page.js
Created July 26, 2019 04:48
A script to paste into the js console of a Facebook note (i.e. blog post) in order to extract its meta-data
// copy and paste that script in the js console, from a facebook "note" url
permalink = $$('.mts a')[0];
[_, monthName, day, year] = new Date(permalink.innerText.split(' at ')[0]).toString().split(' ');
monthNum = {
Jan: 0,
Feb: 1,
Mar: 2,
Apr: 3,
May: 4,
@adrienjoly
adrienjoly / generate-html-with-colors-from-jest-test-results.sh
Created May 10, 2019 09:48
Generate HTML with colors from Jest test results
#!/usr/bin/env bash
# USAGE: ./generate-html-with-colors-from-jest-test-results.sh <file_name>
# => will create:
# - <file_name>.log (with color codes)
# - <file_name>-plain.log (without color codes)
# - <file_name>.html
FILENAME=$1
@adrienjoly
adrienjoly / list-squashed-and-merged-git-branches.sh
Last active April 2, 2020 14:54
List local git branches that were squashed and merged to master
# List local branches that were squashed and merged to master
$ comm -1 -2 \
<(git remote prune origin --dry-run | sed "s/^.*origin\///g") \
<(git branch | sed "s/^..//") \
| sed "/^$/d"
# List local branches that were squashed and merged to master
# ... then give you the opportunity to edit them before deleting them.
$ comm -1 -2 \
<(git remote prune origin --dry-run | sed "s/^.*origin\///g") \
@adrienjoly
adrienjoly / select-time-range-from-google-location-history.sh
Last active April 10, 2020 01:36
Select date/time range from Google Location History JSON, using jq
#!/usr/bin/env bash
# First, download "Location History" from https://takeout.google.com/settings/takeout?hl=en&gl=EN&expflags
# (fr: "Historique des positions" from https://takeout.google.com/settings/takeout?hl=fr&gl=FR&expflags)
#
# => Big "Location history.json" file that looks like that:
#
# {
# "locations": [
# { "timestampMs": "1546415889121" },
@adrienjoly
adrienjoly / run-in-docker-from-git.sh
Last active May 1, 2019 13:49
Start a Node.js project in Docker, by generating a Dockerfile
#!/usr/bin/env bash
# USAGE: ./run-from-git.sh https://gitlab.com/danylo.zhalkovskyy/node_app-web.git
REPO_URL="${1}" # e.g. "https://gitlab.com/danylo.zhalkovskyy/node_app-web.git"
PORT=3000
echo "Generate Dockerfile from ${REPO_URL}..."
cat > Dockerfile << CONTENTS
FROM node:10
@adrienjoly
adrienjoly / generate-qr-codes.sh
Last active January 21, 2019 08:11
a bash script to generate qr-codes to download an album from bandcamp
#!/usr/bin/env bash
echo "CSV file: $1"
NB_CODES=20
URL_PREFIX="https://harissa.bandcamp.com/yum?code="
npm install qrcode
mkdir -p qrcodes
#!/usr/bin/env bash
# inspiration: https://davidwalsh.name/pull-down-pr
# The `git pr` alias will checkout the branch associated to a given PR.
# Usage: `$ git pr 204`
git config --global --add alias.pr '!f() { git fetch -fu ${2:-origin} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f'
# The `git pr-clean` alias will delete all the `pr/*` branches kept locally.
# Usage: `$ git pr-clean`