Skip to content

Instantly share code, notes, and snippets.

@sean3z
sean3z / cpu.rs
Last active December 30, 2022 01:29
Example nibble parsing for Chip-8 emulator
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) {
@sean3z
sean3z / apgar.mrc
Created December 29, 2022 23:30
WOL Apgar routine in mIRC Script (Frank Razenberg)
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)
@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;
@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.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 / 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 / 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 / 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 / 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 / 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) => {