Skip to content

Instantly share code, notes, and snippets.

Avatar

Joshua Jung joshjung

View GitHub Profile
View 2048 Web Game Class
window.Game2048 = function () {
this.cells = [];
this.boardValues = [
[0, 0, 0, 0],
[2, 0, 0, 0],
[0, 0, 0, 0],
[0, 2, 0, 0]];
this.board = [[{}, {}, {}, {}],
[{}, {}, {}, {}],
View 2048 Problem Solving
/**
* In the game 2048, the board consists of a 2-dimensional array of values.
*
* Every tile will always be a power of 2, starting with 2.
*
* The player can swipe left, up, right, or down. When this happens the numbers
* "collapse" in that direction. Duplicate values merge into a single tile and
* after swiping all non-zero values should have shifted in that direction.
*
* NOTE! A maximum of 2 tiles can merge at a time! So if you have a row of [4, 4, 2, 2]
View gist:6675c6963f3a9c782bfe49fc9f4a63b6
import DebugInspector from 'ringa-fw-react/src/components/debugInspector/DebugInspector';
import Theme from 'ringa-fw-react/src/components/containers/Theme';
...
render() {
return <Theme>
{this.props.children} // The rest of your application...
<DebugInspector />
</Theme>;
}
View webpack.config.prod.bad.js
const webpack = require('webpack');
const path = require('path');
const ROOT_PATH = path.resolve(process.env.PWD);
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const UGLIFY_WHITELIST = require('./uglifyWhitelist.json');
require('babel-polyfill');
View webpack.config.prod.bad.js
const webpack = require('webpack');
const path = require('path');
const ROOT_PATH = path.resolve(process.env.PWD);
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const UGLIFY_WHITELIST = require('./uglifyWhitelist.json');
require('babel-polyfill');
View webpack.config.prod.analyze.js
let BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const prodBuild = require('./webpack.config.prod.js');
module.exports = new Promise(resolve => {
prodBuild.then(build => {
build.plugins.push(new BundleAnalyzerPlugin());
resolve(build);
});
});
@joshjung
joshjung / webpack.config.prod.js
Created Nov 14, 2017
Asynchronous Webpack Configuration
View webpack.config.prod.js
...
// Build your configuration object, and then return a Promise
let finalConfig = {
devtool: 'eval',
output: { /* your configuration */ },
plugins: [ /* your configuration */ ]
};
You can’t perform that action at this time.