Skip to content

Instantly share code, notes, and snippets.

View rajatdua's full-sized avatar
Yo

Rajat Dua rajatdua

Yo
View GitHub Profile
@rajatdua
rajatdua / loaders.txt
Created April 3, 2020 08:07
Order for webpack loaders
['css-loader', 'postcss-loader', 'sass-loader', 'resolve-url-loader']
@rajatdua
rajatdua / AutoMulti.js
Created May 8, 2020 18:48
Material-UI - Autocomplete - MultiSelect
import React, { useState, useEffect } from 'react';
import Autocomplete from '@material-ui/lab/Autocomplete';
import TextField from '@material-ui/core/TextField';
const top100Films = [
{ title: 'The Shawshank Redemption', year: 1994 },
{ title: 'The Godfather', year: 1972 },
{ title: 'The Godfather: Part II', year: 1974 },
{ title: 'The Dark Knight', year: 2008 },
{ title: '12 Angry Men', year: 1957 },
@rajatdua
rajatdua / regex.js
Created August 17, 2020 17:19
Width and Height Regex
let reg = /(width\s*:\s*(.*?)(\d+)px)|(height\s*:\s*(.*?)(\d+)px)/ig;
// height:96px width:246px; height:96px width:246px height=96px width=246px height=96px width=246px
@rajatdua
rajatdua / DynamicRef.js
Last active September 2, 2020 16:05
Example for applying style on a dynamic list coming from an API using useRef hook
import React, {useState, useEffect, useRef} from 'react';
const DynamicRef = () => {
const ref = useRef();
const [api, setApi] = useState({});
useEffect(() => {
setApi(prev => ({...prev, loading: true}));
fetch('https://reqres.in/api/unknown', {method: 'GET'}).then(res => res.json()).then(response => setApi(prev => ({
...prev,
response,
@rajatdua
rajatdua / deleteMessages.js
Created October 14, 2020 08:28
Find and delete all your discord messages
const userInformation = {
author_id: 'your_auth_id',
token: 'your_token',
'x-super-properties': 'your_x_super_properties',
};
const deleteMessages = (messages, callback) => {
for(let i = 0; i < messages.length; i++){
(function(ind) {
let middleObj = messages[ind][2];
let channelId = middleObj.channel_id;
@rajatdua
rajatdua / automaticMessages.js
Last active September 11, 2022 16:05
Discord - Send messages automatically
(function execute() {
const keyDownEvent = (event) => {
if (event.ctrlKey && event.key === "l") {
start();
}
if (event.ctrlKey && event.key === "o") {
stop();
}
if (event.ctrlKey && event.key === "m") {
console.log("clearing previous script");