Skip to content

Instantly share code, notes, and snippets.

View snatvb's full-sized avatar
👹
Maybe monads, maybe not :)

Andrew Avsenin snatvb

👹
Maybe monads, maybe not :)
  • Wargaming
  • Vilnius
View GitHub Profile
@snatvb
snatvb / ImmutableArray.res
Created July 15, 2021 22:24
ReScript immutable array
module ImmArr: {
/* Put this in the interface file */
type t<'a>
let make: array<'a> => t<'a>
let isEmpty: t<'a> => bool
let head: t<'a> => option<'a>
let tail: t<'a> => t<'a>
let toArray: t<'a> => array<'a>
let map: (t<'a>, 'a => 'b) => t<'b>
let cons: (t<'a>, 'a) => t<'a>
@snatvb
snatvb / memorySizeOfObject.js
Created May 21, 2020 14:07
calculate memory size of javascript object, it is not a accurate value!
function memorySizeOf(obj) {
var bytes = 0;
function sizeOf(obj) {
if(obj !== null && obj !== undefined) {
switch(typeof obj) {
case 'number':
bytes += 8;
break;
case 'string':
find ./ -name "*.js" -exec sh -c 'mv "$0" "${0%.js}.ts"' {} \;
@snatvb
snatvb / rename_js_files.sh
Created August 8, 2017 09:11 — forked from afternoon/rename_js_files.sh
Rename .js files to .ts
find app/src -name "*.js" -exec sh -c 'mv "$0" "${0%.js}.ts"' {} \;