Skip to content

Instantly share code, notes, and snippets.

View simbathesailor's full-sized avatar
🎯
Focusing

Anil Kumar Chaudhary simbathesailor

🎯
Focusing
View GitHub Profile
@simbathesailor
simbathesailor / outside-react-to-react.jsx
Created August 6, 2020 17:35
outside-react-to-react.jsx
import React from "react"
import Modal from "components/Modal"
import styled, { css } from "styled-components"
import { Button } from "components"
import PropTypes from "prop-types"
const MessageContainer = styled.div`
display: flex;
align-items: center;
justify-content: center;
@simbathesailor
simbathesailor / controlled-component-with-hooks2.jsx
Last active June 22, 2020 14:26
controlled-component-with-hooks2.jsx
function useSetUp({ initialSearch = "", initialResult = [] }) {
const [search, setSearch] = React.useState(initialSearch);
const [result, setResult] = React.useState(initialResult);
return {
search,
setSearch,
result,
setResult,
};
@simbathesailor
simbathesailor / controlled-component-with-hooks1.jsx
Last active June 21, 2020 04:50
controlled-component-with-hooks1.jsx
function SearchAndResultView({ search, setSearch, result }) {
return (
<Modal>
<SearchBox search={search} setSearch={setSearch} />
<ResultContainer result={result} />
</Modal>
);
}
function AnyofyourComponent() {
formatRFC3339
const (
ANSIC = "Mon Jan _2 15:04:05 2006"
UnixDate = "Mon Jan _2 15:04:05 MST 2006"
RubyDate = "Mon Jan 02 15:04:05 -0700 2006"
RFC822 = "02 Jan 06 15:04 MST"
RFC822Z = "02 Jan 06 15:04 -0700" // RFC822 with numeric zone
RFC850 = "Monday, 02-Jan-06 15:04:05 MST"
RFC1123 = "Mon, 02 Jan 2006 15:04:05 MST"
@simbathesailor
simbathesailor / test.jsx
Created May 16, 2020 06:54
parse html to react elements
export const parseTextAndATag = string => {
if (!string) return null;
const HtmlParser = new DOMParser();
const parsedDocument = HtmlParser.parseFromString(string, 'text/html');
const childNodes = parsedDocument.body.childNodes;
const arrHtmlNodes = [].slice.call(childNodes);
const finalHTMLString = arrHtmlNodes.reduce((acc, elem) => {
const isText = elem.nodeType === 3;
@simbathesailor
simbathesailor / processenvinjection.md
Last active April 23, 2020 09:40
PROCESS ENV DYNAMIC INJECTION

INPUT

$$_INTERNAL_MATHRANDOMSTART${Math.random()}MATHRANDOMEND$$_INTERNAL__

OUTPUT without loose

"use strict";

"$$INTERNAL_MATHRANDOMSTART".concat(Math.random(), "MATHRANDOMEND$$INTERNAL");

1) Create a branch with the tag
git branch {tagname}-branch {tagname}
git checkout {tagname}-branch
2) Include the fix manually if it's just a change ....
git add .
git ci -m "Fix included"
or cherry-pick the commit, whatever is easier
git cherry-pick {num_commit}
@simbathesailor
simbathesailor / README.md
Created March 25, 2020 07:27 — forked from iest/README.md
Setting up environment variables with various shells

What the hell are environment variables?

They're just variables you set on your system that various programs/processes can read. A fairly standard example in javascript circles would be setting your NODE_ENV variable to "production" or "development", altering how node code is executed on your system (for example showing more debug messaging when in development).

With most shells there's a way to set them for the current session, and a way to set them for all sessions. The following is meant to be a guide on how to set env vars in the various shells.

Bash (The default shell on OSX)

Setting for the session:

@simbathesailor
simbathesailor / ThingToDiveInto.md
Last active February 5, 2020 16:33
High level areas in frontend

Modern product development includes

These are the things which I know after 4 years of frontend development !!

Note: This list is not exaustive. Feel free to add anything more.

  • Setting up just the repositories.

  • Seting the project structure.