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
"use strict"; | |
const restify = require('restify'); | |
const config = require('./config'); | |
const app = restify.createServer(); | |
app.use(restify.plugins.queryParser()); | |
app.use(restify.plugins.bodyParser()); | |
app.listen(8080, () => { |
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
{ | |
"jwt": { | |
"secret": "&@$!changeme!$@&" | |
} | |
} |
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
"use strict"; | |
exports.authenticate = (username, password) => { | |
return Promise.resolve({ uid: 1, name: 'Sean', admin: false }); | |
}; | |
/* | |
exports.authenticate = (username, password) => { | |
return new Promise((resolve, reject) => { | |
db.findOne({username, password}, (err, data) => { |
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 user = require('./lib/user'); | |
app.post('/auth', (req, res, next) => { | |
let {username, password} = req.body; | |
user.authenticate(username, password).then(data => { | |
res.send(data); | |
}) | |
}); |
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 config = require('./config'); | |
const rjwt = require('restify-jwt-community'); | |
const jwt = require('jsonwebtoken'); | |
// using restify-jwt to lock down everything except /auth | |
app.use(rjwt(config.jwt).unless({ | |
path: ['/auth'] | |
})); | |
// using the `req.user` object provided by restify-jwt |
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
let content = document.querySelector('main.bdp_docViewerWide_main'); | |
$('.bdp_doc-viewer_notification').after(content.innerHTML); | |
$('.mfp-bg.mfp-ready, .mfp-content').hide(); | |
document.querySelector('body').style.overflow = 'auto'; |
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
let terms = document.querySelectorAll('.SetPageTerm.has-definitionText, .SetPageTerms-termsList'); | |
for (let term of terms) term.classList.add('is-showing'); | |
document.querySelector('.SignupWallInline').style.display = 'none'; |
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
<?php | |
echo apgar('password'); //result WaIMMsbf | |
function apgar($a) { | |
if (strlen($a) == 8) { | |
$u = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; | |
for ($i = 0; $i <= 7; $i++) { | |
$r = ($i == 0) ? 0 : ord($a[8 - $i]); | |
$x = (ord($a[$i]) & 1) ? (ord($a[$i]) << 1) & $r : ord($a[$i]) ^ $r; | |
$o[] = substr($u, ($x & 0x3f), 1); |
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
function apgar(s) { | |
if (s.length != 8) return false; | |
var s = s.split(''), o = []; | |
var u = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./'; | |
for(var i = 0; i <= 7; i++) { | |
var a = s[(8 - i)], r = ((i == 0) ? 0 : a.charCodeAt(0)); | |
var j = s[i].charCodeAt(0), x = ((j & 1) ? (j << 1) & r : j ^ r); | |
var k = (x & 0x3f), f = u.substring(k, (k + 1)); | |
o.push(f); | |
} |
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
std::string apgar(std::string input) { | |
std::string lookup = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; | |
std::string out = ""; | |
int i = 0; | |
while (i < 8) { | |
unsigned char left = input[i]; | |
unsigned char right = input[input.length() - i]; | |
unsigned char x = left & 1 ? ((left << 1) ^ (left & 1)) & right : left ^ right; |