Skip to content

Instantly share code, notes, and snippets.

View ehpc's full-sized avatar
💾

Eugene Maslovich ehpc

💾
View GitHub Profile
@ehpc
ehpc / move.js
Created October 12, 2021 07:45
JS animate movement with requestAnimationFrame and transition
function move(el, distance, duration) {
let startTime;
function recur() {
window.requestAnimationFrame((time) => {
if (startTime === undefined) {
startTime = time;
}
const elapsed = time - startTime;
const fraction = elapsed / duration;
const dx = Math.min(distance, distance * fraction);
@ehpc
ehpc / ts-any-to-lines.sh
Created August 3, 2022 11:21
Get metric of how many `any`'s are there compared to line count for TypeScript codebase (in percents)
#!/bin/sh
# Calculates a metric of how many `any`'s are there compared to line count for TypeScript codebase (in percents)
# Basically we count all `any` occurences, then count all lines in the codebase, and lastly divide one by another
echo "scale = 4; $(find -name "*.ts?" -not -path "./node_modules/*" | xargs grep -o '\bany\b' | wc -l) * 100 / $(find -name "*.ts?" -not -path "./node_modules/*" | xargs wc -l | tail -1 | awk '{print $1}')" | bc