Skip to content

Instantly share code, notes, and snippets.

View sahilrajput03's full-sized avatar
💭
I'm happy these days.

Sahil Rajput sahilrajput03

💭
I'm happy these days.
View GitHub Profile
@sahilrajput03
sahilrajput03 / mongo.js
Last active January 21, 2021 13:29
mongoose general usage methods #mongoose #mongodb #database #mongo
// Playground: https://mongoplayground.net/
// Documentation: https://mongoosejs.com/docs/
// Cheatsheet1: https://kb.objectrocket.com/mongo-db/the-mongoose-cheat-sheet-225
// Cheatsheet2: https://github.com/azat-co/cheatsheets/blob/master/mongodb-mongoose/readme.md
const {Schema, model, connect} = require("mongoose");
let log = console.log;
function connectMongoDb() {
@sahilrajput03
sahilrajput03 / norest, graphql
Last active October 22, 2020 18:15
mongoose with graphql #graphql #mongoose #mongodb
const { v1: uuid } = require("uuid");
const { ApolloServer, gql, UserInputError } = require("apollo-server");
const mongoose = require("mongoose");
// const { books, authors } = require("./data");
//models of collections in mongodb
const BookSchema = require("./models/bookSchema");
const AuthorSchema = require("./models/authorSchema");
@sahilrajput03
sahilrajput03 / GitCommitEmoji.md
Created July 13, 2020 14:48 — forked from parmentf/GitCommitEmoji.md
Git Commit message Emoji
const theme = {
colors: {
textPrimary: '#24292e',
textSecondary: '#297',
primary: '#0366d6',
},
fontSizes: {
body: 14,
subheading: 16,
},
@sahilrajput03
sahilrajput03 / OpenWithSublimeText3.bat
Created August 27, 2020 16:33 — forked from roundand/OpenWithSublimeText3.bat
Open folders and files with Sublime Text 3 from windows explorer context menu (tested in Windows 7)
@echo off
SET st3Path=C:\Program Files\Sublime Text 3\sublime_text.exe
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
@sahilrajput03
sahilrajput03 / storm catpuring
Created September 12, 2020 09:37
exception catpuring with closures.
noExcepttion(() =>
new Promise((res, rej) => {
rej('error occured due to storm');
})
);
function noExcepttion(cb) {
cb().catch((t) => console.log(`::INFO::NOEXCEPTION:: ${t}`));
};
@sahilrajput03
sahilrajput03 / mutable.js(from FUTURE).js
Last active October 5, 2020 09:25
A function which helps easying up un mutating state objects when we need to dispatch new unmutated states to `dispatch` calll. # unmutate
const getMutable = (state) => JSON.parse(JSON.stringify(state)); // This is doer.
const mutableState = getMutable(state);
mutableState.books[0].section[2] = 'Things to be learned in august.';
mutableState.books[1].section[4] = 'Things to be learned in november.';
dispatch(mutableState);
// ----------------------------------------------------------------------------------------------------------
// Antoher simple approach is using closures like immer.js does(but it does some depth comparisons too), for e.g. below is my
@sahilrajput03
sahilrajput03 / youtube hide classes.css
Last active October 7, 2020 10:03
To be used with chrome's extension - Stylish
/* `Set Applies` to `www.youtube.com` */
/* URLs on the domain www.youtube.com */
.ytp-chrome-bottom {
visibility: hidden;
}
/* above is for player controls hiding. */
.caption-window.ytp-caption-window-bottom{
margin-bottom: 0px
}
@sahilrajput03
sahilrajput03 / Adding event handler to execut on key press events.js
Last active September 17, 2020 09:41
Its made for `Custom Javascript for website` chrom'e extension, to be able to click `edit` and`update` buttons with ctrl+y hotkey.
// ctrl+shift+e => Edit Button
// ctrl+shift+s => Update Gist Button
// ctrl+shift+k => Preview Button
// ctrl+shift+; => Write Button
// To get keycodes visit: "https://keycode.info/"
// To get chrome extension visit: "https://chrome.google.com/webstore/detail/custom-javascript-for-web/poakhlngfciodnhlhhgnaaelnpjljija?hl=en"
// BELOW CODE IS TO GET EDIT BUTTON AND REGISTER EVENT HANDLER FOR IT.
let elements1 = document.getElementsByClassName("btn btn-sm");
let idEditButtonExists = elements1[0].textContent.includes("Edit");
@sahilrajput03
sahilrajput03 / Formik notorious HOC revelation.md
Last active September 17, 2020 17:53
Dealing curiosity with <Formik> {<ComponentHere/> /* is bad thing */}.md

CHECK IF WE GET AUTOTYPING, AUTOCOMPLETE WHEN WE PASS FORM COMPONENT EXPLICITLY TO <Formik> Component

const MyFormComponent = () => (<Form> </Form>)

<Formik> {MyFormComponent} </Formik>`

instead of passing inplicityly passing component as

const FomikComponent = () => (<Formik>{() => 	(<Form> and other bullshit.. <<<here..refer formik site...>>>)})