Skip to content

Instantly share code, notes, and snippets.

View anLpk's full-sized avatar
🏡
Working from home

Anıl Pak anLpk

🏡
Working from home
View GitHub Profile
@anLpk
anLpk / helpers.ts
Last active November 9, 2025 22:19
MiddleTruncate component
export const measureText = (container: HTMLElement) => {
const span = document.createElement('span');
span.style.opacity = '0';
span.style.position = 'absolute';
span.style.top = '-1000px';
span.style.left = '-1000px';
span.style.whiteSpace = 'nowrap';
span.style.pointerEvents = 'none';
container.appendChild(span);
@anLpk
anLpk / npm-cheetsheet.md
Created July 5, 2021 05:27 — forked from ipekt/npm-cheetsheet.md
npm cheetsheet

NPM Cheetsheet

INSTALL

Interactive package.json generation

npm init

Install packages listed in package.json

{
"data": [
{
"Adana": [
"01",
"0322",
"2.220.125",
"Akdeniz",
"13.844",
"49.15%",
// // console.log("Hello from inside"); // Always check, JS working or not
const input = document.querySelector("#results");
const search = document.querySelector("#btn");
const url = "data.JSON";
async function loadJSON(url) {
const res = await fetch(url);
return await res.json();
}
body {
display: flex;
height: 100vh;
justify-content: center;
align-items: center;
background-color: tomato;
}
#container {
display: flex;
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Turkey Population App</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="container">
<input
"use strict";
const toggleTextColor = document.querySelector(".darktext");
const switchBtn = document.querySelector(".switch");
const bodyColorChanges = document.querySelector("body");
const cardBgColorChanges = document.querySelector(".dark");
const changeTextColor = function () {
toggleTextColor.classList.remove("darktext");
/* Default Settings */
* {
box-sizing: border-box;
margin: 0;
}
html {
scroll-behavior: smooth;
}
body {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- displays site properly based on user's device -->
<link
rel="icon"
type="image/png"
/* Default */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: 'Montserrat', sans-serif;
scroll-behavior: smooth;