Skip to content

Instantly share code, notes, and snippets.

View florianpasteur's full-sized avatar

Florian PASTEUR florianpasteur

View GitHub Profile
@florianpasteur
florianpasteur / post-commit
Last active May 7, 2024 23:31
Post commit hook to increment version of npm package
# Install command:
# curl https://gist.githubusercontent.com/florianpasteur/c9764ddc56042a075662e1adcfbcc0b4/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;
fi
if git diff package.json package-lock.json; then
@florianpasteur
florianpasteur / README.md
Created March 30, 2022 07:32
Enable touch id for sudo

Enable touch for to sudo

In a terminal run:

cd /etc/pam.d/
sudo vim sudo

Append the following line to the file

@florianpasteur
florianpasteur / README.md
Created January 17, 2022 14:09
Force AAC bluetooth on mac
@florianpasteur
florianpasteur / 01-start.gcode
Last active January 14, 2022 08:15
CR-10S Pro Start/End Gcodes
M201 X500.00 Y500.00 Z100.00 E5000.00 ;Setup machine max acceleration
M203 X500.00 Y500.00 Z10.00 E50.00 ;Setup machine max feedrate
M204 P500.00 R1000.00 T500.00 ;Setup Print/Retract/Travel acceleration
M205 X8.00 Y8.00 Z0.40 E5.00 ;Setup Jerk
M220 S100 ;Reset Feedrate
M221 S100 ;Reset Flowrate
M140 S60 ; Preheat bed
M104 S210; Preheat head
" URL: https://vim.wikia.com/wiki/Example_vimrc
" Authors: https://vim.wikia.com/wiki/Vim_on_Libera_Chat
" Description: A minimal, but feature rich, example .vimrc. If you are a
" newbie, basing your first .vimrc on this file is a good choice.
" If you're a more advanced user, building your own .vimrc based
" on this file is still a good idea.
"------------------------------------------------------------
" Features {{{1
"
@florianpasteur
florianpasteur / .bashrc
Last active May 22, 2024 09:29
Bash profile
#!/bin/bash
# START=$(perl -MTime::HiRes=time -e 'printf "%.9f\n", time')
#######################################################
# EXPORTS
#######################################################
# Expand the history size
@florianpasteur
florianpasteur / browser-automation-toolbox.js
Last active September 21, 2021 14:36
Browser Automation Toolbox
// Sources: https://gist.github.com/florianpasteur/118d0e29313c3fb052f944bc001cde88
function findElementByText(text, searchStart = document.body, _document = document, ignoreSpace = false) {
return _document
.evaluate(
`//*[${ignoreSpace ? 'normalize-space' : 'text'}()="${text}"]`,
searchStart,
null,
XPathResult.ANY_TYPE,
null
@florianpasteur
florianpasteur / optional.ts
Last active March 16, 2021 09:34
Typescript Optional
// Example type
type UserInfo = {
username: string,
email: string
};
type Present<T> = {
exists: true,
value: T
};
@florianpasteur
florianpasteur / optional.ts
Created March 1, 2021 16:13
Null-safe Optional with Typescript
// Example type
type UserInfo = {
username: string,
email: string
};
type Present<T> = { exists: true, value: T };
type Absent = {exists: false};
type Optional<T> = Present<T> | Absent;
@florianpasteur
florianpasteur / search_and_reaplce.js
Created February 3, 2021 15:16
Surprising Search & Replace in JS
tag = "Some value";
replacetag = '<span class="hightlighttag">' + tag + '</span>';
console.log(textarea.value.split(tag).join(replacetag))