Skip to content

Instantly share code, notes, and snippets.

View mikesmullin's full-sized avatar
🛴
woot!

Mike Smullin mikesmullin

🛴
woot!
View GitHub Profile
@mikesmullin
mikesmullin / promiseBatch.js
Created February 18, 2024 05:13
javascript parallel async promise races in batches
const promiseBatch = async function* (concurrency, list, fn) {
for (let p = [], i = 0, l = list.length; i < l || p.length > 0;) {
if (i < l) {
let _p;
_p = fn(list[i]).then(r => [_p.__id, r]);
_p.__id = i++;
if (p.push(_p) < concurrency) {
continue;
}
}
@mikesmullin
mikesmullin / PureRef.md
Created January 2, 2023 18:17
PureRef for artists

PureRef

It's good software.

https://www.pureref.com/

Description

All your reference images in one place. Organize your inspiration and speed up your creative process with PureRef.

@mikesmullin
mikesmullin / nc_reverse_tcp.rb
Created September 27, 2021 00:03
Metasploit: Payload: TTY Command Shell, Reverse TCP (Netcat) w/ AutoVerifySession=false to prevent echo test on connect
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
# /usr/share/metasploit-framework/modules/payloads/singles/generic/nc_reverse_tcp.rb
# usage:
# # launch hostile listener
# $ sudo nc -vlp 80 -ns 192.168.119.198
@mikesmullin
mikesmullin / solitare.js
Created November 9, 2019 16:46
Solitare Solver for MOLEK-SYNTEZ game
(async () => {
const orderedSet = ['6','7','8','9','10','V','D','K','T'];
const nextAbove = c =>
orderedSet[orderedSet.indexOf(c) + 1];
let moveHistory = [];
const analyze = (state) => {
let moves = [];
@mikesmullin
mikesmullin / saml-x509-pki-parsing.js
Created July 18, 2018 04:38
Parsing SAML x.509 Certificate in pure-Javascript
const _idpX509Cert = _.get(resp, ['samlp:Response', 'Assertion', 0,
'ds:Signature', 0, 'KeyInfo', 0, 'ds:X509Data', 0, 'ds:X509Certificate', 0]);
const asn1js = require('asn1js');
const pkijs = require("pkijs");
const Certificate = pkijs.Certificate;
const buf = new Buffer(_idpX509Cert, 'base64').buffer;
console.log('_idpX509Cert', _idpX509Cert);
const asn1 = asn1js.fromBER(buf);
@mikesmullin
mikesmullin / wrap.js
Created July 14, 2018 07:20
sort of looks like a regexp parser; will use regexp instead
var wrap = (list, test, cb) => {
const stack = [];
let start, end, lastTest, result, lastItem, item, out;
for (let i=0,len=list.length; i<len; i++) {
item = list.splice(i,1)[0];
result = test(item, lastItem);
if ((!result && lastTest !== result) || (i === list.length-1 && lastTest === result)) {
out = cb(item, i, start, end, stack, lastItem);
if (null != out) {
list.splice(i, 0, ...out);
@mikesmullin
mikesmullin / beacon.asm
Last active February 13, 2021 23:03
ctf wargame beacon.asm Windows 32-bit Winsock API (static; no dependencies) 2,560 bytes
; compile with MASM32
; C:\masm32\bin\ml /c /Zd /coff beacon.asm
; C:\masm32\bin\Link /SUBSYSTEM:WINDOWS beacon.obj
; beacon.exe
;
.386
.model flat, stdcall
option casemap :none
include C:\masm32\include\windows.inc
include C:\masm32\include\kernel32.inc
@mikesmullin
mikesmullin / trace.js
Created November 24, 2017 23:21
Node.JS print filename and line number prefixed to console log output
const path = require('path');
function trace(s) {
const orig = Error.prepareStackTrace;
Error.prepareStackTrace = (_, stack) => stack;
const err = new Error();
Error.captureStackTrace(err, arguments.callee);
Error.prepareStackTrace = orig;
const callee = err.stack[0];
process.stdout.write(`${path.relative(process.cwd(), callee.getFileName())}:${callee.getLineNumber()}: ${s}\n`);
@mikesmullin
mikesmullin / rpn_calc.coffee
Last active March 25, 2017 17:05
Reverse Polish Notation Calculator (in CoffeeScript)
# Reverse Polish Notation Calculator (in CoffeeScript)
# authored by Mike Smullin <mike@smullindesign.com>
#
# see also:
# https://en.wikipedia.org/wiki/Polish_notation
# http://www.calculator.org/rpn.aspx
# http://blog.reverberate.org/2013/07/ll-and-lr-parsing-demystified.html
# http://stackoverflow.com/questions/5975741/what-is-the-difference-between-ll-and-lr-parsing
# https://www.amazon.com/Definitive-ANTLR-4-Reference/dp/1934356999
@mikesmullin
mikesmullin / loop.sh
Created June 21, 2014 21:18
Bash Process Loop
#!/bin/bash
# Process Loop
# Author: Mike Smullin <mike@smullindesign.com>
# License: MIT
# Usage:
#
# ./loop node --debug app.js
#
# Ctrl+C Restarts
# Ctrl+\ Quits