Skip to content

Instantly share code, notes, and snippets.

View andreialecu's full-sized avatar

Andrei Alecu andreialecu

View GitHub Profile
@andreialecu
andreialecu / use-number-formatter.tsx
Created May 15, 2024 08:32
use-number-formatter hook for react native
import {useCallback} from 'react';
import {millify} from '../millify';
import {useAppLanguage} from './use-app-language';
const cachedFormatters = new Map<string, Intl.NumberFormat>();
const cachedResults = new Map<Intl.NumberFormat, Map<number, string>>();
/**
* We cache Intl.NumberFormat instances because creating them is slow.
@andreialecu
andreialecu / azure-app.stack.ts
Last active February 27, 2024 12:13
aws-cdk terraform
import * as cdk from "aws-cdk-lib";
import { TerraformSupport } from "./terraform-support";
import * as azureApp from "@cdk-cloudformation/tf-azuread-application";
export class AzureApplicationStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props: cdk.StackProps) {
super(scope, id, props);
// First deploy step 1, then change to 2 and deploy again
let step = 1;
@andreialecu
andreialecu / README.md
Last active April 6, 2023 17:44
Sentry NestJS GQL instrumentation
@andreialecu
andreialecu / dtf-perf.diff
Last active June 26, 2021 01:08
performance patch for @formatjs/[email protected]
diff --git a/src/abstract/FormatDateTimePattern.js b/src/abstract/FormatDateTimePattern.js
index 47fd27397f6fff014af1c4b8862e26fea11e7aab..8d0d1234d9a5dcbd6131bbe206d4655a6c153726 100755
--- a/src/abstract/FormatDateTimePattern.js
+++ b/src/abstract/FormatDateTimePattern.js
@@ -32,6 +32,28 @@ function offsetToGmtString(gmtFormat, hourFormat, offsetInMs, style) {
}
return gmtFormat.replace('{0}', offsetStr);
}
+var numberFormatsCache = new Map();
+function getNumberFormatsForLocale(locale, fractionalSecondDigits) {
@andreialecu
andreialecu / create-collapsible-navigator.tsx
Created April 21, 2021 15:42
react-navigation support for react-native-collapsible-tab-view
import {
createNavigatorFactory,
DefaultNavigatorOptions,
ParamListBase,
TabActionHelpers,
TabActions,
TabNavigationState,
TabRouter,
TabRouterOptions,
useNavigationBuilder,
@andreialecu
andreialecu / @apollo+client+3.3.14.patch
Created April 6, 2021 10:20
@apollo/client patch for fast-refresh
diff --git a/node_modules/@apollo/client/react/hooks/hooks.cjs.js b/node_modules/@apollo/client/react/hooks/hooks.cjs.js
index a0acfe8..68d0b08 100644
--- a/node_modules/@apollo/client/react/hooks/hooks.cjs.js
+++ b/node_modules/@apollo/client/react/hooks/hooks.cjs.js
@@ -56,8 +56,25 @@ function useBaseQuery(query, options, lazy) {
var queryResult = lazy
? result[1]
: result;
+ var _maybeFastRefresh;
+ if (__DEV__) {
diff --git a/deps/v8/src/base/platform/platform-posix.cc b/deps/v8/src/base/platform/platform-posix.cc
index 68d651b15fe..d5624cb8ace 100644
--- a/deps/v8/src/base/platform/platform-posix.cc
+++ b/deps/v8/src/base/platform/platform-posix.cc
@@ -415,6 +415,16 @@ bool OS::SetPermissions(void* address, size_t size, MemoryPermission access) {
int prot = GetProtectionFromMemoryPermission(access);
int ret = mprotect(address, size, prot);
+
+ // MacOS 11.2 on Apple Silicon refuses to switch permissions from
@andreialecu
andreialecu / selection-set.decorator.ts
Created May 19, 2020 17:48
selection set decorator
/**
* EXPERIMENTAL auto populator for mongo using graphql selections set
*/
import { createParamDecorator, ExecutionContext } from "@nestjs/common";
import { Model, DocumentQuery, Document, QueryPopulateOptions } from "mongoose";
import {
FieldNode,
ArgumentNode,
@andreialecu
andreialecu / @types+mongoose+5.7.18.patch
Last active May 14, 2020 16:03
types mongoose patch
diff --git a/node_modules/@types/mongoose/index.d.ts b/node_modules/@types/mongoose/index.d.ts
index 7da3af8..636f644 100644
--- a/node_modules/@types/mongoose/index.d.ts
+++ b/node_modules/@types/mongoose/index.d.ts
@@ -41,6 +41,7 @@
// Richard Simko <https://github.com/richardsimko>
// Marek Tuchalski <https://github.com/ith>
// Jeremy Bensimon <https://github.com/jeremyben>
+// Andrei Alecu <https://github.com/andreialecu>
// The Half Blood Prince <https://github.com/tHBp>
@andreialecu
andreialecu / @types+mongoose+5.7.15.patch
Last active May 8, 2020 11:45
@types/mongoose typed model.create()
diff --git a/node_modules/@types/mongoose/index.d.ts b/node_modules/@types/mongoose/index.d.ts
index c430d7b..639365e 100644
--- a/node_modules/@types/mongoose/index.d.ts
+++ b/node_modules/@types/mongoose/index.d.ts
@@ -83,8 +83,14 @@ declare module "mongoose" {
// We can use TypeScript Omit once minimum required TypeScript Version is above 3.5
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
+ type NonFunctionPropertyNames<T> = {
+ [K in keyof T]: T[K] extends Function ? never : K;