Skip to content

Instantly share code, notes, and snippets.

View ihpr's full-sized avatar
🧘
Meditating

Ihor Pronin ihpr

🧘
Meditating
  • Ukraine
View GitHub Profile
package main
import (
"fmt"
)
func Sqrt(x float64) float64 {
guess := float64(1)
attempts := 20
previous := float64(0)
@ihpr
ihpr / truncate.ts
Last active December 25, 2020 13:25
JS Truncate
const truncate = (className: string, requiredHeight: number): void => {
const elementsCollection = Array.from(document.getElementsByClassName(className));
for (const element of elementsCollection) {
let wordArray = element.innerHTML.split(' ');
while(element.scrollHeight > requiredHeight) {
wordArray.pop();
element.innerHTML = wordArray.join(' ') + '...';
}
}
};