Skip to content

Instantly share code, notes, and snippets.

View jordihm9's full-sized avatar
🎯
Focusing

Jordi Hernàndez i Magí jordihm9

🎯
Focusing
  • Kave Tech
  • Girona
View GitHub Profile
@jordihm9
jordihm9 / force-update-changed-files-in-merge.bash
Created June 15, 2023 21:32
Add an empty line at the end of every file changed in every merge commit from the current branch compared to the main branch of the repository
#!/usr/bin/env bash
commit_hashes=$(git log --merges origin/$(git_main_branch)..${git_current_branch} --format="%H")
for commit_hash in ${commit_hashes}; do
files=$(git show ${commit_hash} --name-only --pretty=format: | sort | uniq | grep -E '\.(ts|tsx|js|jsx)$')
for file in ${files}; do
if [[ -e $file ]]; then
echo "Processing ${file}"
@jordihm9
jordihm9 / demo.ts
Last active October 9, 2022 20:38
Async Queue - TS
// Some utils
const _promise = <T>(value: T, ms: number): PromiseFunction<T> =>
() => new Promise<T>(resolve => setTimeout(resolve, ms, value));
const _addToqueue = <T>(queue: Queue<T>): AddToQueueFunction<T> =>
(value: T) => queue.enqueue(value);
(async () => {
const promise1 = _promise('[1] This takes 1s', 1000);
const promise2 = _promise('[2] This takes 3s', 3000);
@jordihm9
jordihm9 / init.vim
Last active February 14, 2022 18:59
Nvim Configuration File
set number
set relativenumber
set nowrap " lines do not wrap
set mouse=a
set numberwidth=1
set autoindent " intelligent autoindent when creating a new line
set expandtab " force the use of spaces
set shiftwidth=2
"set scrolloff=8 " always keep at least 8 lines above and below the cursor
set clipboard+=unnamedplus " use system clipboard
@jordihm9
jordihm9 / TicTacToe.test.ts
Last active September 5, 2021 18:27
Tic Tac Toe TDD
const TicTacToe = require('./TicTacToe');
describe('Tic Tac Toe', () => {
const player1 = {'color': '#000'};
const player2 = {'color': '#fff'};
let moves;
test('should create a new board', () => {
const board = TicTacToe.createBoard();
const expectedBoard = [