View bitpacker.js
function bitpacker(bytes=[]) { | |
return { | |
bytes: bytes, | |
bitcursor: 0, | |
write(bitcount, value) { | |
if(typeof value === 'string') value = value.charCodeAt(0) | |
else if(typeof value === 'boolean') value = value?1:0 | |
else if(value > 2**bitcount-1) value = 2**bitcount-1 // overflow will stay at max value instead of wrapping |
View myfloat.js
function tomyfloat(mbits, ebits, value) { | |
if(mbits + ebits > 31) throw new Error('no support for > 31 bits') | |
if(value < 0) throw new Error('no support for negative numbers') | |
if(Math.floor(value) !== value) throw new Error('no support for decimal numbers (lol)') | |
if(value >= (2**mbits-1)*2**(2**ebits-1)) return 2**(mbits+ebits)-1 | |
const bitstr = value.toString(2) | |
const len = bitstr.length | |
let m = parseInt(bitstr.substr(0, mbits), 2) | |
let e = Math.min(2**ebits-1, Math.max(0, len - mbits)) | |
if( (m < 2**mbits-1 || e < 2**ebits-1) && Math.abs(value - (m+1)*2**e) < Math.abs(value - m*2**e)) m++ |
View fighter.ahk
#SingleInstance force | |
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. | |
SendMode Event ; Recommended for new scripts due to its superior speed and reliability. | |
SetTitleMatchMode RegEx | |
#MaxHotkeysPerInterval 1000 | |
!F11::Suspend | |
; reload script | |
^!+s:: | |
Reload |
View colemak_developer.ahk
#SingleInstance force | |
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. | |
SendMode Event ; Recommended for new scripts due to its superior speed and reliability. | |
SetTitleMatchMode RegEx | |
#MaxHotkeysPerInterval 10000 | |
; reload script | |
^!+s::Reload | |
; capslock is another escape | |
Capslock::Esc |