Mixing an AMD script loading solution with a traditional script loading solution with UMD modules causes a conflict.
The traditional way to load a script is to manually add a script tag on the page like this:
<script> | |
if (typeof define === 'function' && define.amd) { | |
window.noConflictAMD = define.amd; | |
define.amd = null; | |
} | |
</script> | |
<script src="/module.js"></script> | |
<script> | |
if (typeof define === 'function') { | |
define.amd = window.noConflictAMD; |
(function (con) { | |
'use strict'; | |
function dummy() {} | |
['error','info','log','warn'].forEach(function (func) { | |
con[func] = con[func] || dummy; | |
}); | |
}(window.console = window.console || {})); |
(function () { | |
'use strict'; | |
var userRegex = /(^|\s)(@(\w){1,15})/gi; | |
var urlRegex = /(^|\s)(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*))/gi; | |
var linkUsers = function (tweet) { | |
return tweet.replace(userRegex, function ($m, $1, $2) { | |
return $1 + '<a href="https://twitter.com/' + $2 + '" target="_blank">' + $2 + '</a>'; | |
}); |
var host = "127.0.0.1"; | |
var port = 1337; | |
var express = require("express"); | |
var app = express(); | |
app.use('/', express.static(__dirname + '/')); | |
app.listen(port, host); | |
console.log('Running server at http://localhost:' + port + '/'); |
SET EX="C:\Program Files\IIS Express\iisexpress.exe" | |
if not "%1" == "" ( | |
CALL %EX% /path:%CD% /port:%1 | |
) else ( | |
CALL %EX% /path:%CD% | |
) |
This is a bookmarklet to wrap code in a textarea with the appropriate highlight.js elements. Simply select the code in a text field then activate the bookmarklet. There will be a prompt to enter the language. This will only work on sites that have highlight.js installed.
(function (d) {
var a = d.activeElement,
t = a.value,
s = a.selectionStart,
(function (exports, $) { | |
"use strict"; | |
var defaults = { | |
regexAttr: 'data-regex', | |
maxAttr: 'data-max' | |
}, | |
allowedKeys = "Backspace Enter Tab Left Right Down Up", | |
runRegex = function () { | |
var value = this.$el.val(), | |
array = value.match(this.regex), |
// Submit Web Form on Enter Key | |
(function (exports, $) { | |
var submitAnchor = function (anchor) { | |
if (anchor.onclick) { | |
if (!anchor.onclick()) return; | |
} | |
var href = $(anchor).attr('href'); | |
if (href.indexOf('javascript') >= 0) { | |
eval(unescape(href.replace(/^javascript:/i,""))); | |
} |