Skip to content

Instantly share code, notes, and snippets.

@Om4ar
Om4ar / changeTheme.jsx
Created June 21, 2018 11:40
change the theme of material ui without injecting new theme in the theme object
import React, { Component } from "react";
import "react-dates/initialize";
import "react-dates/lib/css/_datepicker.css";
import PropTypes from "prop-types";
import moment from "moment";
import { withStyles } from "@material-ui/core/styles";
import { DateRangePicker } from "react-dates";
import FontAwesome from "react-fontawesome";
import DefaultTheme from "react-dates/lib/theme/DefaultTheme";
@Om4ar
Om4ar / version_compare.js
Created June 26, 2018 17:45 — forked from pc035860/version_compare.js
Function to compare two version strings (e.g. "1.6.1" is smaller than "1.7"). Developed in order to answer http://stackoverflow.com/a/6832721/50079.
/**
* Compares two software version numbers (e.g. "1.7.1" or "1.2b").
*
* This function was born in http://stackoverflow.com/a/6832721.
*
* @param {string} v1 The first version to be compared.
* @param {string} v2 The second version to be compared.
* @param {object} [options] Optional flags that affect comparison behavior:
* <ul>
* <li>
@Om4ar
Om4ar / hash change.jsx
Created July 23, 2018 22:57
how to deal with hash change in react
componentDidMount() {
window.addEventListener("hashchange", this.props.ShowTabWithHash, false);
}
componentWillUnmount() {
window.removeEventListener("hashchange", this.props.ShowTabWithHash, false);
}
@Om4ar
Om4ar / workbox.md
Created July 24, 2018 15:17 — forked from addyosmani/workbox.md
Workbox recipes

Workbox runtime caching recipes

Your Service Worker script will need to import in Workbox and initialize it before calling any of the routes documented in this write-up, similar to the below:

importScripts('workbox-sw.prod.v1.3.0.js');
const workbox = new WorkboxSW();

// Placeholder array populated automatically by workboxBuild.injectManifest()

This describes the common mistake with using closures in JavaScript.

A function defines a new environment

Consider:

function makeCounter()
{
  var obj = {counter: 0};
@Om4ar
Om4ar / cors.md
Created July 29, 2018 01:12 — forked from liamgriffiths/cors.md
How CORS works

Guide to CORS

CORS (cross origin resource sharing) is a mechanism to allow client web applications make HTTP requests to other domains. For example if you load a site from http://domainA.com and want to make a request (via xhr or img src, etc) to http://domainB.com without using CORS your web browser will try to protect you by blocking the response from the other server. This is because browsers restrict responses coming from other domains via the Same-Origin-Policy.

CORS allows the browser to use reponses from other domains. This is done by including a Access-Control headers in the server responses telling the browser that requests it is making is OK and safe to use the response.

Header Description
Access-Control-Allow-Origin: Allow requests from `` to access t
@Om4ar
Om4ar / commit-emoji.md
Created September 22, 2018 00:48 — forked from silencesys/commit-emoji.md
List of emoji for git commits.

Git Commit Message

All Git Commit Messages MUST meet with this Text Format:

:emoji: Subject
(Only One NewLine)
Message Body
(Only One NewLine)
Ref &lt;###&gt;
@Om4ar
Om4ar / axios-configure.js
Created November 27, 2018 19:57 — forked from wisetc/axios-configure.js
Configuration of axios instance to make POST requests.
import axios from 'axios'
import { Message } from 'element-ui'
export const baseUrl = 'http://example.com/api';
const transformRequest = (data={}) => {
if (typeof data === 'string') return data;
if (!data.oauth)
data.oauth = localStorage.getItem("token")? localStorage.getItem("token"): (sessionStorage.getItem("token") || "");
@Om4ar
Om4ar / update-golang.md
Created December 1, 2018 19:22 — forked from nikhita/update-golang.md
How to update the Go version

How to update the Go version

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

@Om4ar
Om4ar / .gitignore
Created December 5, 2018 14:19 — forked from initlove/.gitignore
How to Readline - an example and the beginnings of the docs
node_modules/