Skip to content

Instantly share code, notes, and snippets.

View farzher's full-sized avatar
🌸
ヽ◕◡◕✿ノ

ヽ◕◡◕✿ノ farzher

🌸
ヽ◕◡◕✿ノ
  • Pitchbox
  • Philadelphia, PA
View GitHub Profile
@farzher
farzher / colemak_developer.ahk
Last active August 30, 2017 21:38
Colemak For Developers
#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
@farzher
farzher / fighter.ahk
Created May 16, 2013 00:52
Fighting Game Shortcuts
#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
@farzher
farzher / myfloat.js
Last active June 27, 2020 22:43
floating precision positive whole numbers using arbitrary mantissa / exponent sizes
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++
@farzher
farzher / bitpacker.js
Last active September 18, 2020 13:39
for writing data to a compact custom binary format. serialize / save / send data over the network using the minimal amount of bits.
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