See how a minor change to your commit message style can make you a better programmer.
Format: <type>(<scope>): <subject>
<scope> is optional
| 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 |
| 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; |
| 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: |
| 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) |
| 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; |
| 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, |
| 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% |