⌫
Backspace
⇪
Caps lock
⌧
Clear
⌘
Command
⌃
Control
function getQuery(s) { | |
var query = {}; | |
s.replace(/\b([^&=]*)=([^&=]*)\b/g, function (m, a, d) { | |
if (typeof query[a] != 'undefined') { | |
query[a] += ',' + d; | |
} else { | |
query[a] = d; | |
} | |
}); |
(function (global) { | |
function EventListener(parameters) { | |
var self = Object.defineProperties(this, { | |
dispatch: { | |
enumerable: true, | |
value: function (event) { return listener.call(self, event), self; } | |
}, | |
listener: { | |
enumerable: true, | |
get: function () { return listener; }, |
⌫
Backspace
⇪
Caps lock
⌧
Clear
⌘
Command
⌃
Control
String.prototype.linkify = function() | |
{ | |
var str = this.toString(); | |
str = str.replace(/(https?:\/\/[^\s]+)/gim, '<a href="$1">$1</a>', str); | |
str = str.replace(/([#|@][^\s]+)/gim, '<a href="http://twitter.com/$1">$1</a>', str); | |
return str; | |
} |
//create our "FOO" namespace | |
window.FOO = window.FOO || {}; | |
FOO.app1 = { | |
bar : 'foo', | |
init : function(){ | |
//this wont work as expected since timeout changes scope |
[ | |
{"keys":["ctrl+shift+up"], "command":"super_add_line", "args":{ "forward": false } }, | |
{"keys":["ctrl+shift+down"], "command":"super_add_line", "args":{ "forward": true } } | |
] |
/***************************************************************************** | |
* __ __ _ _ ___ _ | |
* \ \/ _\ /\/\ (_)_ __ | |_ _ _ / __\ __ ___ ___| |__ | |
* \ \ \ / \| | '_ \| __| | | | / _\| '__/ _ \/ __| '_ \ | |
* /\_/ /\ \ / /\/\ \ | | | | |_| |_| | / / | | | __/\__ \ | | | | |
* \___/\__/ \/ \/_|_| |_|\__|\__, | \/ |_| \___||___/_| |_| | |
* |___/ | |
* | |
* Identifying and Eliminating Code Smells | |
* |
Just an example of how you can make your webpack config more declarative an re-usable.
You can have a generic webpack.config.js
that includes most of your common setup (loaders, plugins and all that)
and an attribute in your project's package.json
(or anywhere you think it makes sense) containing your project's
entries or any other setup you might want to change.
npm start
- live reload, http://localhost:8000
npm run build
- build to dist foldernpm run build -- -p
- production build to foldernpm run watch
- watch to dist folder<!DOCTYPE html> | |
<!-- #include "inc_header.html" title="Example" header="Sample Title" --> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Example</title> | |
<link rel="stylesheet" href="css/main.css"> | |
</head> | |
<body> | |
<h1>Sample Title</h1> |