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
//jetty.version 8.1.7.v20120910 | |
public static void main(String[] args) throws Exception { | |
Server server = new Server(3000); | |
WebAppContext context = new WebAppContext(); | |
context.setDescriptor(context+"/WEB-INF/web.xml"); | |
context.setResourceBase("./src/main/webapp"); | |
context.setContextPath("/"); | |
context.setParentLoaderPriority(true); |
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
/** | |
* Given we have a regex with one more matching groups. | |
* The regex should capture those groups from an 'input' | |
* string and replace the matched values in an 'template' | |
* string. | |
* | |
* Example: | |
* regex: /([1-9]{8})/([1-9]{8})?/ | |
* input string: '/some-magic/path/12122211/22112211' | |
* template string: 'http://someurl?adId=$1&adId=$2' |
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
'use strict'; | |
function start () { | |
const startTime = process.hrtime(); | |
return () => { | |
const elapsed = process.hrtime(startTime); | |
return elapsed[0] * 1e9 + elapsed[1]; | |
}; | |
} |
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 {User, AuthenticationRequired) = require('unleash-server'); | |
const passport = require('passport'); | |
const GoogleOAuth2Strategy = require('passport-google-auth').Strategy; | |
passport.use( | |
new GoogleOAuth2Strategy( | |
{ | |
clientId: process.env.GOOGLE_CLIENT_ID, | |
clientSecret: process.env.GOOGLE_CLIENT_SECRET, |
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
'use strict'; | |
const auth = require('basic-auth'); | |
const User = require('../user'); | |
function basicAuthentication(app) { | |
app.use('/api/admin/', (req, res, next) => { | |
const credentials = auth(req); | |
if (credentials) { |
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
// Create and add EventListner | |
const func = ev => {console.log(ev.detail)}; | |
const listner = window.addEventListener('demo', func); | |
// Publish custom event | |
const event = new CustomEvent('demo', {detail: 'hello world'}); | |
window.dispatchEvent(event); | |
// Remove EventListner |
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 xhrBase = document.getElementById("showInterest").getAttribute('data-xhr-path'); | |
const adId = document.getElementById("showInterest").getAttribute('data-ad-id'); | |
fetch(`${xhrBase}save?adId=${adId}`).then(() => console.log('fetch')); |
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 http = require('http'); | |
const fetch = require('node-fetch'); | |
const async_hooks = require('async_hooks'); | |
const context = new Map(); | |
const middleware = (req, res) => { | |
const id = async_hooks.executionAsyncId(); | |
const headers = req.headers; | |
context.set(id, headers); |
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 async_hooks = require('async_hooks'); | |
const fs = require('fs'); | |
const http = require('http'); | |
const fetch = require('node-fetch'); | |
const asyncHook = async_hooks.createHook({ | |
init: (asyncId, type, triggerAsyncId, resource) => { | |
if(type === 'TCPCONNECTWRAP') { | |
process.nextTick(() => { | |
console.log('TCPCONNECTWRAP'); |
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 unleashContext = {}; | |
var fallbackVariant = { | |
enabled: false, | |
name: "disabled", | |
} | |
const varinat = getVariant('toggleName', unleashContext, fallbackVariant); | |
switch(variant.name) { |
OlderNewer