Skip to content

Instantly share code, notes, and snippets.

View raohmaru's full-sized avatar

Raúl Parralejo raohmaru

View GitHub Profile
@raohmaru
raohmaru / pre-commit
Last active April 27, 2023 09:46
Git pre-comit hook to lint files using npm
#!/usr/bin/env sh
# This loads nvm
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
# Bypass if a merge is happening
function skipIfMerging() {
local isMerge="$(git rev-parse -q --verify MERGE_HEAD)"
# If isMerge is a hash, a merge is ongoing
@raohmaru
raohmaru / requestAnimationFrame.js
Last active January 28, 2024 19:04
requestAnimationFrame() in node.js
const callbacks = [];
const fpsInterval = 1000 / 60;
let time = performance.now();
function requestAnimationFrameLoop() {
const now = performance.now();
const delta = now - time;
if (delta >= fpsInterval) {
// Adjust next execution time in case this loop took longer to execute
time = now - (delta % fpsInterval);
@raohmaru
raohmaru / create_symlinks.bat
Created January 31, 2016 09:52
Create symbolic links in Windows from the subdirectories of a given directory