Skip to content

Instantly share code, notes, and snippets.

View debabrata100's full-sized avatar
🤡
Dethinking

Debabrata debabrata100

🤡
Dethinking
  • Bangalore
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tic Tac Toe</title>
<script src="game-lib.js" type="text/javascript"></script>
</head>
<body>
<div id="game_container">
const config = {
entry: ['./app/index.js'],
output: {
path: __dirname + '/build',
filename: 'game-lib.js'
},
module: {
loaders: [
{
loader:'babel-loader',
/******/ (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;
/* 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;
@debabrata100
debabrata100 / Dockerfile
Created August 28, 2018 18:53
Dockerfile for create-react-app
# 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
@debabrata100
debabrata100 / .dockerignore
Created August 28, 2018 18:55
dockerignore file for create-react app
.git
node_modules
build
@debabrata100
debabrata100 / nginx.conf
Created August 29, 2018 18:28
This file is to be used while deploying react js application with docker and nginx
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 / shallow-deep-copy-explained.js
Created September 2, 2018 07:20
It explains how shallow copy and deep copy achieved using JavaScript array
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 / infix_to_postfix.py
Created September 15, 2018 17:22
This python program illustrates how to write a python program to convert infix expression to postfix using python list as stack
def getOperatorWeight(op):
weights = {
'+': 1,
'-': 1,
'*': 2,
'/': 2,
'^': 3
}
return weights.get(op)
def isRightAssociative(op):
@debabrata100
debabrata100 / LocaleApp.js
Created October 18, 2019 18:36
On Change of locale save to react state and store locale value to localStorage
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' }
];