Skip to content

Instantly share code, notes, and snippets.

@gitexec
gitexec / package.json
Created July 26, 2018 01:32
script example to run webpack on prod and dev
"scripts": {
"build": "npm run clean && npm run compile",
"compile": "NODE_ENV=production webpack --config ./webpack.config.js --progress",
"clean": "rm -rf ./build/bundle*.js",
"sass-compile": "node-sass dist/scss -o dist/css",
"webpack": "webpack-dev-server --config ./webpack.dev.config.js --watch --open",
"start": "yarn run sass-compile && concurrently --kill-others \"yarn run sass-compile --watch\" \"yarn run webpack\"",
"test": "eslint **/*.js"
},
@gitexec
gitexec / webpack.base.config.js
Created July 26, 2018 01:30
Simple Production ready webpack file
'use strict';
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
module.exports = function (env) {
let outputFile = 'bundle';
const plugins = [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.DefinePlugin({
@gitexec
gitexec / webpack.config.js
Last active December 12, 2017 18:54
moving from gulp to webpack
//Support plugins/Libraries
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
//Files/libraries paths
const webroot = "./wwwroot/";
const libraryPath = "./Libraries/";
const webBundlesPath = webroot + "Bundles/";
const webScriptsPath = webroot + "Scripts/";
@gitexec
gitexec / symbolit.js
Created November 27, 2017 14:50
Iteration with symbol
var randoms = {
[Symbol.iterator]: function() {
return {
next: function() {
return { value: Math.random() };
}
};
}
};
@gitexec
gitexec / transform-dashed-strings-to-Caps.js
Created November 1, 2017 17:39
transform-dashed-strings-to-Caps.js
function buildReactExternals(dependenciesArray){
let externals = dependenciesArray.reduce((dependencies, curr, index, array) => {
let secondCapIndex = curr.indexOf('-');
let lastCapIndex = curr.lastIndexOf('-');
let firstCap, secondCap, middleCap, valueCap = curr, key, lastCap;
firstCap = curr.charAt(0).toUpperCase();
if (secondCapIndex !== -1) {
secondCapIndex++;
secondCap = valueCap.charAt(secondCapIndex).toUpperCase(); //curr.substring(1, secondCapIndex + 1) + curr.charAt(secondCapIndex+1).toUpperCase() + curr.substring(secondCapIndex + 2);
}
@gitexec
gitexec / create-react-redux-asp-net-core.sh
Last active October 26, 2017 14:18
Create a react-redux app with asp.net core
//* Install netcoreapp2.0 in Linux https://www.microsoft.com/net/download/linux
//* Open terminal and create project as
//* dotnet new reactredux -o helloworld
cd helloworld
npm install
dotnet run
@gitexec
gitexec / compareAnyNumberOfObjects.js
Last active October 11, 2017 15:55
compare Any Number Of Objects
import {fromJS} from 'immutable';
public compareObjects(...compareArguments): boolean {
//For now just two arguments
if (!compareArguments)
return false;
if (compareArguments.length < 2)
return false;
compareArguments.forEach((curr, index) => {
if ((fromJS(curr).equals(fromJS(compareArguments[index + 1]))) == false){
@gitexec
gitexec / working-react-router.js
Created September 22, 2017 00:17
working-react-router.js
import {
BrowserRouter as Router,
Link,
Route,
Switch,
} from 'react-router-dom';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
//import { Provider } from 'react-redux';
//import { createStore, applyMiddleware } from 'redux';
import {
BrowserRouter as Router,
Link,
Route,
Switch,
} from 'react-router-dom';
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
@gitexec
gitexec / basic-react-redux-router.js
Last active September 21, 2017 21:51
Simple example of React, Redux, and Router
import {
BrowserRouter as Router,
Link,
Route,
Switch,
} from 'react-router-dom';
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';