Skip to content

Instantly share code, notes, and snippets.

View eeslom's full-sized avatar
🏚️
Rest for a while

Islom Murodov eeslom

🏚️
Rest for a while
View GitHub Profile
@eeslom
eeslom / phone-input.ts
Created January 12, 2025 19:17 — forked from ramziddin/phone-input.ts
Uzbekistan phone number input component
import { ComponentProps, useState } from "react"
function PhoneInput(props: ComponentProps<"input">) {
const [value, setValue] = useState<string>("+998")
const formattedValue = value
.replaceAll(" ", "") // remove whitespace
.slice(4) // strip the country code
.match(/(\d{1,2})?(\d{1,3})?(\d{1,2})?(\d{1,2})?/)! // split into multiple components
.toSpliced(0, 1, "+998") // replace global match with country code
@eeslom
eeslom / index.js
Created January 12, 2025 19:17 — forked from ramziddin/index.js
Check if hex color dark or light
const isColorDark = color => {
const c = color.substring(1); // strip #
const rgb = parseInt(c, 16); // convert rrggbb to decimal
const r = (rgb >> 16) & 0xff; // extract red
const g = (rgb >> 8) & 0xff; // extract green
const b = (rgb >> 0) & 0xff; // extract blue
const luma = 0.2126 * r + 0.7152 * g + 0.0722 * b; // per ITU-R BT.709
const isDark = luma < 40;
@eeslom
eeslom / youtube.txt
Created December 27, 2024 22:06 — forked from iredun/youtube.txt
Youtube API get thumbnail image
Each YouTube video has 4 generated images. They are predictably formatted as follows:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg
The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg
For the high quality version of the thumbnail use a url similar to this:
@eeslom
eeslom / download.js
Created September 14, 2024 21:00 — forked from antfu/download.js
[JS] Download file
function download(data, filename, type) {
var a = document.createElement('a')
var file = new Blob([data], { type: type })
if (window.navigator.msSaveOrOpenBlob) // IE10+
window.navigator.msSaveOrOpenBlob(file, filename)
else { // Others
var url = URL.createObjectURL(file)
a.href = url
a.download = filename
document.body.appendChild(a)
@eeslom
eeslom / get_style.js
Created September 14, 2024 20:58 — forked from antfu/get_style.js
[JS] Getting All CSS Properties of a DOM
function get_style( dom ) {
var style;
var returns = {};
// FireFox and Chrome way
if(window.getComputedStyle){
style = window.getComputedStyle(dom, null);
for(var i = 0, l = style.length; i < l; i++){
var prop = style[i];
var val = style.getPropertyValue(prop);
returns[prop] = val;
@eeslom
eeslom / semantic-commit-messages.md
Created September 14, 2024 20:57 — forked from joshbuchea/semantic-commit-messages.md
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@eeslom
eeslom / html2pdf.js
Created September 14, 2024 20:42 — forked from antfu/html2pdf.js
HTML to PDF
import puppeteer from 'puppeteer'
import fs from 'fs'
async function buildPDF(htmlString) {
const browser = await puppeteer.launch({ headless: true })
const page = await browser.newPage();
await page.setContent(htmlString, { waitUntil: 'networkidle0' })
const pdf = await page.pdf({
format: 'A4',
displayHeaderFooter: false,
@eeslom
eeslom / πŸ“Š Weekly development breakdown
Last active December 25, 2024 21:00
πŸ“Š Weekly development breakdown
Other 23 hrs 9 mins β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘ 70.8%
Vue.js 6 hrs 44 mins β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ 20.6%
TypeScript 1 hr 47 mins β–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ 5.5%
PHP 45 mins β–ˆβ–ˆβ–ˆβ–’β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ 2.3%