Skip to content

Instantly share code, notes, and snippets.

@Apaisal
Apaisal / float32encoding.js
Created October 8, 2020 07:27 — forked from Jozo132/float32encoding.js
JavaScript (Node.js) IEEE 754 Single precision Floating-Point (32-bit) binary conversion from and to both Hex and Bin
// Forked 'toFloat' from https://gist.github.com/laerciobernardo/498f7ba1c269208799498ea8805d8c30
// Forked 'toHex' from stackoverflow answer https://stackoverflow.com/a/47187116/10522253
// Modifyed by: Jozo132 (https://github.com/Jozo132)
const Float32ToHex = (float32) => {
const getHex = i => ('00' + i.toString(16)).slice(-2);
var view = new DataView(new ArrayBuffer(4))
view.setFloat32(0, float32);
return Array.apply(null, { length: 4 }).map((_, i) => getHex(view.getUint8(i))).join('');
}
@Apaisal
Apaisal / nginx.conf
Last active September 6, 2015 04:05 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048