Skip to content

Instantly share code, notes, and snippets.

🤡
Dethinking a lot

Debabrata debabrata100

🤡
Dethinking a lot
Block or report user

Report or block debabrata100

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@debabrata100
debabrata100 / FinalLocaleApp.js
Created Oct 18, 2019
Final App component for implementation of react localization
View FinalLocaleApp.js
import React, { useState } from 'react';
import './App.css';
import { IntlProvider, FormattedMessage } from 'react-intl';
const en = require('react-intl/locale-data/en');
const zh = require('react-intl/locale-data/zh');
const ru = require('react-intl/locale-data/ru');
const fr = require('react-intl/locale-data/fr');
const addLocaleData = require('react-intl').addLocaleData;
@debabrata100
debabrata100 / LocaleApp.js
Created Oct 18, 2019
On Change of locale save to react state and store locale value to localStorage
View LocaleApp.js
import React, { useState } from 'react';
import './App.css';
const defaultLocale = localStorage['locale'] ? localStorage['locale'] : 'en'; // English is default locale if none is set
const localeList = [
{ name: 'English', code: 'en', lang: 'English' },
{ name: '中文', code: 'zh', lang: 'Chinese' },
{ name: 'русский', code: 'ru', lang: 'Russian' },
{ name: 'Française', code: 'fr', lang: 'French' }
];
@debabrata100
debabrata100 / infix_to_postfix.py
Created Sep 15, 2018
This python program illustrates how to write a python program to convert infix expression to postfix using python list as stack
View infix_to_postfix.py
def getOperatorWeight(op):
weights = {
'+': 1,
'-': 1,
'*': 2,
'/': 2,
'^': 3
}
return weights.get(op)
def isRightAssociative(op):
@debabrata100
debabrata100 / shallow-deep-copy-explained.js
Created Sep 2, 2018
It explains how shallow copy and deep copy achieved using JavaScript array
View shallow-deep-copy-explained.js
const a = [true,false,undefined,null,NaN,"array",5];
console.log('---------Original Array-----------');
console.log(a); // [ true, false, undefined, null, NaN, 'array', 5 ]
/*-------Shalow copy-----------*/
console.log('---------Shalow Copying-----------');
//slice
console.log('---------Shalow Copying with slice()-----------');
const b = a.slice();
console.log(b); // [ true, false, undefined, null, NaN, 'array', 5 ]
@debabrata100
debabrata100 / nginx.conf
Created Aug 29, 2018
This file is to be used while deploying react js application with docker and nginx
View nginx.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri /index.html;
@debabrata100
debabrata100 / .dockerignore
Created Aug 28, 2018
dockerignore file for create-react app
View .dockerignore
.git
node_modules
build
@debabrata100
debabrata100 / Dockerfile
Created Aug 28, 2018
Dockerfile for create-react-app
View Dockerfile
# Stage 1
FROM node:8 as react-build
WORKDIR /app
COPY . ./
RUN yarn
RUN yarn build
# Stage 2 - the production environment
FROM nginx:alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
View webpack.config.js
/* global __dirname, require, module*/
const webpack = require('webpack');
const UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
const path = require('path');
const env = require('yargs').argv.env; // use --env with webpack 2
let libraryName = 'game-lib';
let plugins = [], outputFile;
View game-lib.js
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
View webpack.config.js
const config = {
entry: ['./app/index.js'],
output: {
path: __dirname + '/build',
filename: 'game-lib.js'
},
module: {
loaders: [
{
loader:'babel-loader',
You can’t perform that action at this time.