Skip to content

Instantly share code, notes, and snippets.

View MikeLuDev's full-sized avatar

Michael Lu MikeLuDev

View GitHub Profile
@MikeLuDev
MikeLuDev / sortStack.js
Created October 11, 2019 22:12
CTCI 3.5
function sortStack(stack, sorted = false, inOrder = true) {
if (sorted) return stack;
const stackTwo = new Stack();
let isSorted = true;
while (stack !== null) {
const top = stack.pop();
if (stack.isEmpty()) {
@MikeLuDev
MikeLuDev / example_empty.xml
Created June 3, 2019 21:56
Example .xml file for a bio-tagging operation with required data fields empty. For use with an Eden endpoint.
<?xml version="1.0" encoding="UTF-8"?>
<epcis:EPCISDocument
xmlns:epcis="urn:epcglobal:epcis:xsd:1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sbdh="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader"
schemaVersion="0"
creationDate="2001-12-17T09:30:47Z"
xsi:schemaLocation="urn:epcglobal:epcis:xsd:1 http://www.gs1si.org/BMS/epcis/1_2/EPCglobal-epcis-1_2.xsd">
<EPCISHeader>
<sbdh:StandardBusinessDocumentHeader>
@MikeLuDev
MikeLuDev / example_filled.xml
Last active June 3, 2019 21:53
Example .xml file for a bio-tagging operation pre-populated with data. For use with an Eden endpoint.
<?xml version="1.0" encoding="UTF-8"?>
<epcis:EPCISDocument
xmlns:epcis="urn:epcglobal:epcis:xsd:1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sbdh="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader"
schemaVersion="0"
creationDate="2001-12-17T09:30:47Z"
xsi:schemaLocation="urn:epcglobal:epcis:xsd:1 http://www.gs1si.org/BMS/epcis/1_2/EPCglobal-epcis-1_2.xsd">
<EPCISHeader>
<sbdh:StandardBusinessDocumentHeader>
@MikeLuDev
MikeLuDev / recovery.js
Last active March 29, 2018 17:31
Password recovery implementation
//===============================================================================
// RECOVERY CALLS
//===============================================================================
const express = require('express');
const app = express();
const crypto = require('crypto');
app.get('/recovery', (req, res) => {
let messages = req.session.flash;
@MikeLuDev
MikeLuDev / utility.js
Last active March 29, 2018 17:31
Waves address validation script
const blake2b = require("blake2b");
const keccak = require('keccak');
validWavesAddress(address) {
console.log(`Checking address validity...`)
let bytes = this.fromBase58(address);
const _blake2b = (data) => {
return blake2b(32).update(data).digest();
}