This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string.replace(/\s{2,}/g, ' '); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isMobile = { | |
Android: function() { | |
return navigator.userAgent.match(/Android/i); | |
}, | |
BlackBerry: function() { | |
return navigator.userAgent.match(/BlackBerry/i); | |
}, | |
iOS: function() { | |
return navigator.userAgent.match(/iPhone|iPad|iPod/i); | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-webkit-text-decoration-skip: ink; | |
text-decoration-skip: ink; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ajaxGet(url) { | |
return new Promise(function(resolve, reject) { | |
let req = new XMLHttpRequest(); | |
req.open("GET", url); | |
req.onload = function() { | |
if (req.status === 200) { | |
resolve(req.response); | |
} else { | |
reject(new Error(req.statusText)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const PageLinks = (function() { | |
const linkSuffix = 'index.html'; | |
const animationTime = 300; | |
const parser = new DOMParser(); | |
const content = document.querySelector('.content'); | |
const title = document.querySelector('title'); | |
function render(response) { | |
let doc = parser.parseFromString(response, 'text/html'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
font-family: -apple-system, | |
BlinkMacSystemFont, | |
Segoe UI, | |
Roboto, | |
Oxygen, | |
Ubuntu, | |
Cantarell, | |
Fira Sans, | |
Droid Sans, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
py -m http.server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var app = express(); | |
app.set('port', (process.env.PORT || 3000)); | |
app.use('/', express.static(__dirname)); | |
app.listen(app.get('port'), function() { | |
console.log('Server started: http://localhost:' + app.get('port') + '/'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function compareNumeric(a, b) { | |
if (a > b) return 1; | |
if (a < b) return -1; | |
} | |
var arr = [ 1, 2, 15 ]; | |
arr.sort(compareNumeric); | |
alert(arr); // 1, 2, 15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p Text | |
| | |
a(href='#') link | |
| | |
b bold text |