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
pub fn emulate_cycle(&mut self) { | |
self.fetch_opcode(); | |
self.execute_opcode(); | |
// okay, PCs are much faster these days | |
// threw this cheeky delay in to slow things down | |
thread::sleep(time::Duration::from_micros(500)); | |
} | |
fn fetch_opcode(&mut self) { |
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
alias apgar { | |
var %lookup = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 | |
var %out, %i = 1 | |
while (%i <= 8) { | |
var %left, %right = 0 | |
if (%i <= $len($1-)) { %left = $asc($mid($1-, %i ,1)) } | |
if ($calc($len($1-) - %i + 1) < $len($1-)) { %right = $asc($mid($1-, $calc($len($1-) - %i + 2), 1)) } | |
var %x = $iif(%left & 1, $and($calc(%left * (2 ^ $and(%left, 1))), %right), $xor(%left, %right)) | |
;# echo -a left: %left - righT: %right - x: %x | |
%out = %out $+ $mid(%lookup, $calc($and(%x, 63) + 1), 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
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; |
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 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 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 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 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 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 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 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) => { |
NewerOlder