Skip to content

Instantly share code, notes, and snippets.

@UmairJibran
UmairJibran / no-multi-space-in-strings.js
Created June 10, 2025 11:05 — forked from Farhan-Haseeb/no-multi-space-in-strings.js
Custom ES Lint rule to avoid and fix two or more spaces in string or className.
export default {
meta: {
type: 'problem',
docs: {
description: 'Disallow multiple consecutive spaces in string literals',
category: 'Possible Errors',
recommended: true,
},
fixable: 'code',
schema: [],
@UmairJibran
UmairJibran / video-creator.bash
Created April 8, 2025 11:18
video for random colors via ffmpeg
mkdir -p frames
# Generate 120 solid-color frames (30 seconds @ 4 fps = 0.25s per frame)
for i in {1..120}; do
COLOR=$(openssl rand -hex 3)
FRAME_NUM=$(printf %03d $i)
magick -size 640x480 xc:"#${COLOR}" \
-gravity center \
-fill white \
-pointsize 72 \
@UmairJibran
UmairJibran / Policy
Created February 14, 2024 19:41
Allow Public Access to s3 bucket
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::bucket-name/*"
}
function isIsogram(str){
const usedChars = []
for(let i = 0; i < str.length; i+=1) {
if(!usedChars.includes(str[i].toLowerCase())){
usedChars.push(str[i].toLowerCase())
}
}
return usedChars.length === str.length
}
/*
Post With Explanation: https://www.linkedin.com/posts/umairjibran_javassript-activity-7031246560059379712-hPp4
*/
const flattenArray = array => {
return array.reduce((acc, val) => {
return Array.isArray(val)
? acc.concat(flattenArray(val))
: acc.concat(val);
}, []);
@UmairJibran
UmairJibran / revert-head.txt
Last active October 27, 2022 11:08
Rollback accidentally made (and pushed) commits
git checkout -b new-branch # new-branch or branch name where you actually wanted to make commit
git checkout master # master or any branch where you have accidentally made commit
git reset --hard HEAD~1 # replace 1 with number of commits you want to go back
git push --force # forces the remote to accept the <local> HEAD as new <remote> HEAD
const isValidEmail = (email) => {
return String(email)
.toLowerCase()
.match(
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
);
};
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"POST",
"PUT"
],
2xx Success
200 OK
201 Created
3xx These are not errors, just something that does not meet the business logic
300 Multiple Choices
4xx Client side errors
400 Bad Request
401 Not Authorised
1×× Informational
100 Continue
101 Switching Protocols
102 Processing
2×× Success
200 OK
201 Created