Skip to content

Instantly share code, notes, and snippets.

View debabrata100's full-sized avatar
🤡
Dethinking

Debabrata debabrata100

🤡
Dethinking
  • Bangalore
View GitHub Profile
@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 / 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 / .dockerignore
Created August 28, 2018 18:55
dockerignore file for create-react app
.git
node_modules
build
@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
/* 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;
/******/ (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;
const config = {
entry: ['./app/index.js'],
output: {
path: __dirname + '/build',
filename: 'game-lib.js'
},
module: {
loaders: [
{
loader:'babel-loader',
<!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">