Skip to content

Instantly share code, notes, and snippets.

View rluvaton's full-sized avatar
:octocat:
Programming

Raz Luvaton rluvaton

:octocat:
Programming
View GitHub Profile
@rluvaton
rluvaton / type-check.mjs
Created January 31, 2024 16:44
TypeCheck only on typescript project files
import ts from 'typescript';
import path from 'node:path';
import Debug from 'debug';
const debug = Debug('type-check-only-project-files');
// ----------------------------------------------------------------
// This file is a helper file that can be used to run type check
// only for the files that in the project and not for any other file
@rluvaton
rluvaton / README.md
Last active September 17, 2024 11:27
Bundle install for mac that temporarly disable IPv6 for network interface while downloading

Fixed bundle install for MacOS

This is a zx script that fix bundle install

How to run:

The bundle-install file should be without extension (but not required) added the extension to make GitHub syntax highlighting work

So from now we just gonna use bundle-install instead of bundle-install.mjs

@rluvaton
rluvaton / README.md
Last active October 9, 2023 15:14
v8 embedding benchmark creating 1M of objects

Benchmarks

  • cpp-creating-objects.cpp: 2000ms
  • js-creating-objects.cpp: 17ms
  • js-creating-object-in-cpp.cpp: 1800ms

❯ jest --coverage=true
  console.log
    test

      at log (index.js:12:21)

 PASS  ./index.test.js
 work
@rluvaton
rluvaton / nock-allow-single-port.ts
Created June 4, 2023 15:34
Nock allow connections to servers that the current process start them
import nock from 'nock';
import { Server } from 'http';
const kHttpServerListen = Symbol('kHttpServerListen');
const openServerPorts = new Set<number>();
function allowRemoteHttpRequestsOnlyToOurServer() {
nock.disableNetConnect();
nock.enableNetConnect(host => {
@rluvaton
rluvaton / README.md
Created November 16, 2022 19:23
Vitests vs Jest with workers

Jest vs Vitest

Results:

Max Workers Jest (time) Jest (max heap) Vitest (time) Vitest (max heap)
1 29.329 s 1244 MB 13.29s 149 MB
2 18.383 s 944 MB 7.58s 190 MB
4 12.914 s 832 MB 7.40s 203 MB
9 (max) 15.830 s 545 MB 8.80s 119 MB
@rluvaton
rluvaton / typebox-helpers.ts
Created August 21, 2022 18:26
EnumWithSwaggerSupport for TypeBox
import { SchemaOptions, TEnum, Type } from '@sinclair/typebox';
import { EnumValues } from 'enum-values';
function getEnumDescription(e: any, name?: string): string | undefined {
const enumValuesDesc = EnumValues.getNamesAndValues(e)
.map(({ name, value }) => `\`${value}\` - ${name}`)
.join('\n');
if (!name) {
return enumValuesDesc;
@rluvaton
rluvaton / Dockerfile
Created August 21, 2022 06:59
Elastic Search Testing
# If in AMD than use the regular image
FROM docker.elastic.co/elasticsearch/elasticsearch-oss:6.8.23 as AMD
COPY elasticsearch.yml /usr/share/elasticsearch/config/
COPY jvm.options /usr/share/elasticsearch/config/
RUN mkdir -p /usr/share/elasticsearch-data-and-logs/data /usr/share/elasticsearch-data-and-logs/logs
RUN chmod 777 /usr/share/elasticsearch-data-and-logs/data /usr/share/elasticsearch-data-and-logs/logs
# If on ARM we build it ourselves

Added the logs of the commands by adding to execa options this:

await execa("npm", ["install"], {
      cwd: targetDirectory,
      stdout: process.stdout,
      stderr: process.stderr,
    });
@rluvaton
rluvaton / error.md
Created August 12, 2022 14:55
Error in practicajs generate app
DEBUG=* npx @practica/create-node-app interactive

npx: installed 368 in 14.066s
(node:25262) UnhandledPromiseRejectionWarning: Error: Command failed: npx turbo run build
 WARNING  cannot find a .git folder. Falling back to manual file hashing (which may be slower). If you are running this build in a pruned directory, you can ignore this message. Otherwise, please initialize a git repository in the root of your monorepo
@practica/jwt-token-verifier:build: ERROR: command finished with error: command (libraries/jwt-token-verifier) npm run build exited (1)
command (libraries/jwt-token-verifier) npm run build exited (1)

• Packages in scope: @practica/configuration-provider, @practica/error-handling, @practica/jwt-token-verifier, @practica/logger, @practica/validation, order-service