This file contains hidden or 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 person = { | |
name: 'lewis', | |
otherNames: ['paul', 'fairweather'], | |
prop: function () { | |
this.otherNames.forEach(n => console.log(this.name + ' ' + n)); | |
} | |
}; |
This file contains hidden or 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
import Foundation | |
extension String { | |
func matches(_ expression: String) -> Bool { | |
if let range = range(of: expression, options: .regularExpression, range: nil, locale: nil) { | |
return range.lowerBound == startIndex && range.upperBound == endIndex | |
} else { | |
return false | |
} | |
} |
This file contains hidden or 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 express = require('express'); | |
const app = express(); | |
// Enable CORS | |
app.use(function (req, res, next) { | |
res.header('Access-Control-Allow-Origin', '*'); // USE actual URL for the webserver instead of * in production | |
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept'); | |
res.header('Access-Control-Allow-Methods', '*'); // Limit the methods to actually used in produciton | |
next(); |
This file contains hidden or 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
// TypeScript | |
import * as express from 'express'; | |
import * as fs from 'fs'; | |
import * as https from 'https'; | |
const port = process.env.MY_HTTPS_PORT || 443; | |
const certPath = process.env.MY_CERT_PATH || './'; // wherever the certificate is | |
const keyFile = certPath.concat('cert.key'); |