Skip to content

Instantly share code, notes, and snippets.

View florianpasteur's full-sized avatar

Florian PASTEUR florianpasteur

View GitHub Profile
@florianpasteur
florianpasteur / filterSplit.ts
Last active February 19, 2024 14:12
Filter an array and split the array into 2 arrays, one with the elements matching the predicate and one with the elements rejected by the predicate
// const filteredArray = myArray.filter(str => str.length > 255);
// becomes
// const [filteredArray, rejectedArray] = myArray.filterSplit(str => str.length > 255);
declare global {
interface Array<T> {
filterSplit(predicate: (item: T, index: number, array: T[]) => boolean): [T[], T[]];
}
}
@florianpasteur
florianpasteur / console.js
Created December 6, 2023 11:58
Find response in articulate training
console.log(parse(base64ToString(window.courseData)).course.lessons.reduce((acc, l) => acc.concat(l.items), []).filter(b => b.type === "knowledgeCheck").map(kc => kc.items[0].answers.filter(a => a.correct).map(a => kc.items[0].title.substr(0, 30) + '... : ' + a.title).join('\n')).join('\n---\n'))
@florianpasteur
florianpasteur / depchecks.sh
Created June 23, 2023 10:01
Simple & straight forward dependecy check for npm projects
# Do not use project root folder as it would catch the package.json file
SRC_LOCATION=apps
PACKAGE_JSON_LOCATION=package.json
for dep in $(jq -r '.dependencies | keys[]' $PACKAGE_JSON_LOCATION)
do
if grep -R -m 1 $dep $SRC_LOCATION > /dev/null;
then
echo "✅ " $dep
@florianpasteur
florianpasteur / extract.sh
Created October 20, 2022 09:44
Extract commit diff as markdown
printCodeFileAsMarkdown() { for filepath in "$@"; do
filename=$(basename -- "$filepath")
dir=$(dirname -- "$filepath")
extension="${filename##*.}"
if [ -f "$filepath" ]; then
echo "\`$filename\` under \`$dir\`:"
echo ""
echo "\`\`\`$extension"
cat "$filepath"
echo "\`\`\`"
@florianpasteur
florianpasteur / gist:268c0eabf5704b6c4eb9e5fcdfd70fac
Created September 27, 2022 10:07
highlight html Element for screenshots
function highlightElement(selector) {
function createOverlay() {
const overlayStyle = {
position: 'fixed',
width: 100,
height: 100,
top: 0,
left: 0,
right: 0,
bottom: 0,
@florianpasteur
florianpasteur / post-commit
Last active September 27, 2022 09:09
Post commit hook to auto tag commits based on commit message
#!/bin/bash
# Install command:
# curl https://gist.githubusercontent.com/florianpasteur/649f735ea786130922dbdd8308e547a2/raw -o .git/hooks/post-commit && chmod +x .git/hooks/post-commit
echo "POST COMMIT HOOK"
COMMIT_HASH=HEAD
echo "commit hash: $COMMIT_HASH"
@florianpasteur
florianpasteur / README.md
Created July 5, 2022 12:16
File to base64 string CLI

File to base64 string CLI on MacOsx and Linux

openssl base64 -in IN_FILE -out OUT_FILE -A

-A: to inline the result in the outfile

@florianpasteur
florianpasteur / index.html
Last active June 24, 2022 14:49
Bootstrap table flexbox only. Based on: https://jsfiddle.net/lowrey/yc4xzx4q/
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<title>Bootstrap 5 Flexbox table</title>
<style>
/* Css not used, as reference only */
.table {
display: flex;
flex-flow: column nowrap;
## FINDER
# show file extension
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
# quit options
defaults write com.apple.finder QuitMenuItem -bool true;
@florianpasteur
florianpasteur / post-commit
Last active September 27, 2022 09:10
Post commit hook to increment version of JSON file
#!/bin/bash
# Install command:
# curl https://gist.githubusercontent.com/florianpasteur/f1cc272815f08d133ead0ddd2c21e421/raw -o .git/hooks/post-commit && chmod +x .git/hooks/post-commit
IS_AMEND=$(ps -ocommand= -p $PPID | grep -e '--amend');
if [ -n "$IS_AMEND" ]; then
exit 0;