Skip to content

Instantly share code, notes, and snippets.

View bietkul's full-sized avatar

Kuldeep Saxena bietkul

View GitHub Profile
@bietkul
bietkul / animation.gif
Last active July 10, 2019 21:01
Animated Gif for voice search
animation.gif
@bietkul
bietkul / movies-store-dataset.json
Created June 6, 2019 13:43
DataSet for Movies Store App
This file has been truncated, but you can view the full file.
[
{
"id": 76203,
"imdb_id": "tt2024544",
"original_language": "English",
"original_title": "12 Years a Slave",
"overview": "In the pre-Civil War United States, Solomon Northup, a free black man from upstate New York, is abducted and sold into slavery. Facing cruelty as well as unexpected kindnesses Solomon struggles not only to stay alive, but to retain his dignity. In the twelfth year of his unforgettable odyssey, Solomon’s chance meeting with a Canadian abolitionist will forever alter his life.",
"popularity": 30.316249,
"score": 30.31,
@bietkul
bietkul / selectors.js
Created February 15, 2019 02:32
Redux selector to get the total price
import { createSelector } from 'reselect';
import get from 'lodash/get';
const items = state => get(state, 'checkout.items', []);
const calcTotalPrice = ($items = []) => {
let total = 0;
$items.forEach((element) => {
total += get(element, '_source.price') || get(element, 'price');
});
@bietkul
bietkul / cart.js
Last active February 15, 2019 02:23
Cart Page to list down the cart items
import React from 'react';
import { Card, Button } from 'antd';
import { connect } from 'react-redux';
import get from 'lodash/get';
import { array, number, func } from 'prop-types';
import {
Content, Footer, Header, Container,
} from '../components/Layout';
import Page from '../components/Page';
import { removeToCart } from '../modules/actions';
@bietkul
bietkul / PurchaseButton.js
Created February 15, 2019 02:08
Purchase button component
import React from 'react';
import PropTypes from 'prop-types';
import StripeCheckout from 'react-stripe-checkout';
const onToken = (token) => {
console.log('Stripe Token', token);
};
const Purchase = ({
price, title, children, ...props
import some from 'lodash/some';
import AppConstants from '../utils/constants';
const initialProductState = {
items: [],
totalPrice: 0,
};
const addItems = (items = [], payload) => {
const newItems = items.map(item => item);
import React from 'react';
import { connect } from 'react-redux';
import { Button } from 'antd';
import {
object, func, string, oneOfType, number, array,
} from 'prop-types';
import {
Content, Footer, Header, Container,
} from '../components/Layout';
import Page from '../components/Page';
@bietkul
bietkul / Mixpanel.Container.js
Created February 14, 2019 22:08
Container with Mixpanel
import Head from 'next/head';
import React from 'react';
import { css } from '@emotion/core';
import {
node, string, oneOfType, object
} from 'prop-types';
import { ReactiveBase } from '@appbaseio/reactivesearch';
import mixpanel from 'mixpanel-browser';
import { MixpanelProvider } from 'react-mixpanel';
import { Layout } from 'antd';
const express = require('express');
const next = require('next');
const port = parseInt(process.env.PORT, 10) || 3000;
const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });
const handle = app.getRequestHandler();
const Cache = require('lru-cache');
const ssrCache = new Cache({
max: 20, // not more than 20 results will be cached
@bietkul
bietkul / next.config.js
Last active January 15, 2022 13:08
Custom Next.js Config
if (typeof require !== 'undefined') {
require.extensions['.css'] = () => null;
}
const NextWorkboxPlugin = require('next-workbox-webpack-plugin');
const withCSS = require('@zeit/next-css');
const WebpackPwaManifest = require('webpack-pwa-manifest');
const path = require('path');
module.exports = withCSS({
webpack(config, { isServer, buildId, dev }) {
config.node = {