Skip to content

Instantly share code, notes, and snippets.

Jeremy Zevin phillyDesignr

Block or report user

Report or block phillyDesignr

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
View basic-regular-expressions.js
let re = /hello/i; //insensitive
// Meta chars
re = /^h/; // Starts with lower case h => false
re = /^h/i; // Starts with any case h => true
re = /--$/i; // end with -- => true
re = /^--$/i; // must begin and end with -- => false
re = /w.rld/i; // matches any ONE char => true
re = /w*d/i; // matches any char 0 or more times => true
re = /w?rld/i; // matches optional character => true
View 8 Useful JavaScript


Each programming language has its own tricks up in its sleeve. Many of them are known to developers, and yet some of them are pretty hackish. In this article, I will show you a couple of tricks I find useful. Some of them I've used in practice and others are the new way of solving old problems. Enjoy!

1. Ensure Array Values

Ever worked on a grid where the raw data needs to be recreated with the possibility that columns length might mismatch for each row? Well, I have! For ensuring the length equality between the mismatching rows you can use Array.fill method.

let array = Array(5).fill(''); console.log(array); // outputs (5) ["", "", "", "", ""]

2. Get Array Unique Values

View .gitignore
View util.js
const log = console.log.bind(console);
const $ = document.querySelector.bind(document);
const $$ = document.querySelectorAll.bind(document);
const rnd = (()=>{
const int = (min=0,max=1) => Math.floor(Math.random() * (max - min + 1) + min);
const real = (min=0.0,max=1.0) => Math.random() * (max - min) + min;
const pick = (array) => array[int(0,array.length-1)];
return {
phillyDesignr / webpack.config.js
Created May 25, 2017
webpack 2 demo pf public path in extract
View webpack.config.js
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextWebpackPlugin = require('extract-text-webpack-plugin');
const isProd = process.env.NODE_ENV === 'production';
const options = {
entry: './src/js/app.js',
You can’t perform that action at this time.