Skip to content

Instantly share code, notes, and snippets.

View thegeorgenikhil's full-sized avatar
👾

Nikhil George thegeorgenikhil

👾
View GitHub Profile
@thegeorgenikhil
thegeorgenikhil / formatCurrency.ts
Created July 3, 2022 12:39
Currency Formatter
const CURRENCY_FORMATTER = new Intl.NumberFormat(undefined, {
currency: "INR",
style: "currency",
});
export function formatCurrency(number: number) {
return CURRENCY_FORMATTER.format(number);
}
@thegeorgenikhil
thegeorgenikhil / bash.sh
Last active November 8, 2023 17:08
Move between commits - Helpful while exploring new codebases!
# Move backward one commit back
alias gitbwd='git log --all --decorate --oneline | grep -A 1 $(git rev-parse --short HEAD) | awk "{print \$1}" | tail -1 | xargs -I {} git checkout {}'
# Move forward one commit up
alias gitfwd='git log --all --decorate --oneline | grep -B 1 $(git rev-parse --short HEAD) | awk "{print \$1}" | head -1 | xargs -I {} git checkout {}'
# See the files names that got changed between the commit
alias cdiff='git diff --name-only HEAD~1 HEAD'
@thegeorgenikhil
thegeorgenikhil / timeAgo.ts
Created January 28, 2024 14:46
Returns a string with the time difference between the current time and the time passed as a parameter.
export function timeAgo(value: string) {
const seconds = Math.floor((new Date().getTime() - new Date(value).getTime()) / 1000)
let interval = seconds / 31536000
const rtf = new Intl.RelativeTimeFormat("en", { numeric: 'auto' })
if (interval > 1) { return rtf.format(-Math.floor(interval), 'year') }
interval = seconds / 2592000
if (interval > 1) { return rtf.format(-Math.floor(interval), 'month') }
interval = seconds / 86400
if (interval > 1) { return rtf.format(-Math.floor(interval), 'day') }
interval = seconds / 3600
@thegeorgenikhil
thegeorgenikhil / webm-to-mp4.sh
Last active February 6, 2024 14:55
Converting webm to mp4 using ffmpeg
ffmpeg -fflags +genpts -i input.webm output.mp4
@thegeorgenikhil
thegeorgenikhil / README.md
Last active May 7, 2024 16:19
Git Commit Message Guide
Type Description
feat A new feature
fix A bug fix
docs Changes in documentation
style Everything related to styling
refactor Code changes that neither fix a bug nor add a feature
test Everything related to testing
chore Updating build tasks, package manager configs, etc
perf Performance improvements