Skip to content

Instantly share code, notes, and snippets.

View sharjeel619's full-sized avatar
🎯
Focusing

Sharjeel Imtiaz sharjeel619

🎯
Focusing
View GitHub Profile
@sharjeel619
sharjeel619 / index.css
Created May 14, 2019 22:33
Line Truncate with ellipses at the end.
/* Simple css way to truncate line with ellipses at the end. Doesn't work with IE & Firefox*/
:root {
--lines-to-show: 3;
--line-height: 18px;
--font-size: 16px;
}
.element-to-truncate {
display: block;
display: -webkit-box;
max-width: 100%;
@sharjeel619
sharjeel619 / index.html
Created May 20, 2019 20:00
Display items in a grid using display: grid, without any media queries
<html>
<head>
<title>CSS Grid</title>
<style>
.grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
grid-gap: 15px;
}
.grid div {
@sharjeel619
sharjeel619 / index.html
Last active December 24, 2020 21:50
Implementing simple custom circular mouse pointer
<html>
<head>
<style>
body {
background: #111;
cursor: none;
}
.cursor {
width: 30px;
height: 30px;
//https://stackoverflow.com/questions/2218999/remove-duplicates-from-an-array-of-objects-in-javascript?page=2&tab=oldest#tab-top
const things = [
{place:"here",name:"stuff"},
{place:"there",name:"morestuff"},
{place:"there",name:"morestuff"}
];
const filtered = things.filter(function({place, name}) {
const key =`${place}${name}`;
ipconfig /release; ipconfig /flushdns; ipconfig /renew; netsh winsock reset; netsh interface ipv4 reset; netsh interface ipv6 reset; netsh interface ip delete destinationcache;
import "./styles.css";
import { Suspense, useState, useEffect, Component } from "react";
class ErrorBoundary extends Component {
constructor(props) {
super(props);
this.state = { hasError: false };
}
static getDerivedStateFromError(error) {
@sharjeel619
sharjeel619 / index.js
Created August 31, 2021 14:40
Async/Await in a Loop | Javascript
// sequentially get data from API while waiting for previous call to finish
for (let temp of arr) {
const res = await fetch('https://jsonplaceholder.typicode.com/users/' + temp).then(res => res.json()).then(res => res);
}
// sequentially get data from API asynchronously
const promises = Array(10).fill(null).map((item, index) => fetch(`https://jsonplaceholder.typicode.com/users/${index + 1}`).then(res => res.json()).then(res => res));
for await (const item of promises) {
console.log(await item)
}
@sharjeel619
sharjeel619 / gist:98f5b2cff5eef14fd39cbd399b8df6b2
Last active September 9, 2021 11:54
Powershell command for windows 10 to rename multiple mp3(can be any type of file, just replace the .mp3 extension name) files
get-childitem *.mp3 | foreach { rename-item $_ $_.Name.Replace("string to be replaced", "string to replace") }
Below link consists of all of the avatars you see on netflix inlcuding Squid Game, Lucifer, The crown, Money Heist and more..
https://drive.google.com/file/d/1C0Il2a9g-l2RaELFDkMk7NTF7SqrM53Q/view?usp=sharing
@sharjeel619
sharjeel619 / index.js
Created January 5, 2022 22:06
Deep compare two objects in javascript
// https://www.30secondsofcode.org/articles/s/javascript-object-comparison
const equals = (a, b) => {
if (a === b) return true;
if (a instanceof Date && b instanceof Date)
return a.getTime() === b.getTime();
if (!a || !b || (typeof a !== 'object' && typeof b !== 'object'))
return a === b;
if (a.prototype !== b.prototype) return false;
const keys = Object.keys(a);
if (keys.length !== Object.keys(b).length) return false;