Skip to content

Instantly share code, notes, and snippets.

View gauravsoti1's full-sized avatar
💪
Love to build things. Let's colab?

Gaurav Sobti gauravsoti1

💪
Love to build things. Let's colab?
View GitHub Profile
@gauravsoti1
gauravsoti1 / styles.jsx
Last active July 3, 2021 08:15
A wrapper over material ui's Typography component using Styled Components. Provides topGutter, leftGutter.. properties like other material components including custom color, weight and truncate properties.
// Support for custom color keys, as well as hexcode
export function getColorFromKey(colorKey) {
switch (colorKey) {
case 'primary':
return theme.palette.primary.main;
case 'secondary':
return theme.palette.secondary.main;
case 'textPrimary':
return theme.palette.text.primary;
case 'textSecondary':
@gauravsoti1
gauravsoti1 / findEntity.js
Last active June 20, 2020 20:51
A function to find DraftJS Entity
export const getEntitiesByLogic = ({ editorState, findEntity }) => {
const content = editorState.getCurrentContent();
const entities = [];
content.getBlocksAsArray().forEach(block => {
let selectedEntity = null;
block.findEntityRanges(
character => {
if (character.getEntity() !== null) {
const entityKey = character.getEntity();
const entity = content.getEntity(entityKey);
@gauravsoti1
gauravsoti1 / sendRequest.js
Last active May 6, 2020 07:01
A simple and easy to use wrapper over fetch
import { stringify } from 'query-string';
export const sendRequest = ({
url,
method,
useCredentials=false,
body,
headers = {},
queryParams = {}
}) => {
@gauravsoti1
gauravsoti1 / IconDropdown.js
Last active December 4, 2019 11:01
React Material UI modular dropdown component. This doesn't add overflow and padding style to the body when it opens.
import React, { useState } from "react";
import styled from "styled-components";
import {
MenuItem,
MenuList,
ClickAwayListener,
Paper,
Popper
} from "@material-ui/core";
import ArrowDropDownOutlinedIcon from "@material-ui/icons/ArrowDropDownOutlined";
@gauravsoti1
gauravsoti1 / avatar.js
Last active September 1, 2022 04:58
Styling Material Ui's Avatar for a project to have different size which adjusts according to screen sizes. Also, gutter spacing on left and right. Libraries: React, material ui, styled-components
import React from "react";
import styled, { css } from "styled-components";
import { Avatar } from "@material-ui/core";
// -------------------------- Defining all the css sizes ------------------------
export const SmallestSizeCSS = css`
width: 30px;
height: 30px;
${props => props.theme.breakpoints.up("lg")} {
@gauravsoti1
gauravsoti1 / 213412242421_create_shopify_orders.rb
Last active January 21, 2018 19:59
all about creating and cancelling shopify orders on delhivery
#Making a table shopify_orders to store some data which helps us keep the shopify and delhivery data in sync
class CreateShopifyOrders < ActiveRecord::Migration
def change
create_table :shopify_orders do |t|
t.string :order_id
t.string :order_name
t.string :sub_order_id
t.string :fulfillment_id
t.string :godam_status
t.string :tracking_number