Skip to content

Instantly share code, notes, and snippets.

@sean3z
sean3z / server.js
Last active May 30, 2018 01:04
Restify JWT example skeleton
"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, () => {
@sean3z
sean3z / config.json
Created May 29, 2018 23:45
Restify JWT example
{
"jwt": {
"secret": "&@$!changeme!$@&"
}
}
@sean3z
sean3z / user.js
Last active May 30, 2018 01:14
Restify JWT example
"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) => {
@sean3z
sean3z / server.js
Created May 29, 2018 23:54
Restify JWT example
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);
})
});
@sean3z
sean3z / server.js
Last active May 30, 2018 01:13
Restify JWT Sign example
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
@sean3z
sean3z / index.js
Last active May 29, 2021 08:16
Get around CourseHero preview limit
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';
@sean3z
sean3z / index.js
Last active November 1, 2021 12:28
Get around Quizlet paywall
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';
@sean3z
sean3z / apgar.php
Created December 29, 2022 23:25
WOL Apgar routine in PHP
<?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);
@sean3z
sean3z / apgar.js
Created December 29, 2022 23:27
WOL Apgar routine in Javascript
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);
}
@sean3z
sean3z / apgar.cpp
Created December 29, 2022 23:29
WOL Apgar routine in CPP (RenegadeProjects.com)
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;