Skip to content

Instantly share code, notes, and snippets.

View dmtrKovalenko's full-sized avatar
🐢
Making things faster

Dmitriy Kovalenko dmtrKovalenko

🐢
Making things faster
View GitHub Profile
// @ts-check
const crypto = require('crypto')
const start = Date.now()
const captureHash = i => {
crypto.pbkdf2("test", "test", 100000, 512, "sha512", () => {
console.log(`capture ${i} at ${Date.now() - start}`)
})
}
@dmtrKovalenko
dmtrKovalenko / reasonml-2-rescript.sh
Last active March 27, 2021 21:25
Bash script migrating reasonml+bucklescript project < 8 version to rescript syntax
# make sure to update this glob for your poject
for file in ./**/src/**/*.{re,rei}; do
[ -f "$file" ] || break
FILENAME=$(basename -- "$file")
BASENAME=${FILENAME%%.*}
DIRNAME=$(dirname $file)
echo "$file"
if [ ${file: -3} == ".re" ]; then
@dmtrKovalenko
dmtrKovalenko / caml_compare.js
Created April 18, 2020 19:42
Benchmark displaying slowness of `caml_compare`
const Benchmark = require("benchmark");
const Caml_obj = require("bs-platform/lib/js/caml_obj.js");
const Belt_SortArray = require("bs-platform/lib/js/belt_SortArray.js");
const Js_math = require("bs-platform/lib/js/js_math.js");
const suite = new Benchmark.Suite("arrays", {
minSamples: 1000,
});
const data: any = []
export async function imageToPixels(buffer: Buffer) {
const resizedBuffer = await sharp(buffer)
.resize(64, 64)
.toBuffer()
const image = jpeg.decode(resizedBuffer, true)
const numChannels = 3;
const numPixels = image.width * image.height;
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',