Skip to content

Instantly share code, notes, and snippets.

View obaixii's full-sized avatar
🐢
Slow and Steady wins the race

Obaid Awan obaixii

🐢
Slow and Steady wins the race
View GitHub Profile
@obaixii
obaixii / semantic-commit-messages.md
Last active February 16, 2024 18:22 — forked from joshbuchea/semantic-commit-messages.md
Semantic Commit Messages

Semantic Commit Messages

By following Git commit messages Standard, See how a minor change to your commit message style, can make you a better programmer.

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

<scope> is optional

Example

@obaixii
obaixii / strictInput.js
Created March 18, 2023 15:48
Input field - Strict Mode
const handleInputChange = (e) => {
const value = e.target.value;
const pageNumber = parseInt(value);
setInputValue(pageNumber);
if (
!isNaN(pageNumber) // checks if the entered pageNumber is a valid number
&& pageNumber > 0 // checks if the entered pageNumber is greater than 0
&& pageNumber <= pageCount // checks if the entered pageNumber is less than or equal to the pageCount- (total number of pages)
) {
setCurrentPage(pageNumber);
@obaixii
obaixii / utils.js
Last active March 18, 2023 15:45
Utility Functions
// Utility Functions
// TRUNCATES(SHORTENS) LONG STRINGS
function truncate(str, n){
return (str.length > n) ? str.slice(0, n-1) + '...' : str;
};
e.g truncate(title,30)
// CONVERTS DOB FORMAT FROM ISO 8601 to DD-MMM-YYYY
export const timeConverter = (UNIX_timestamp) => {