Skip to content

Instantly share code, notes, and snippets.

View Grubba27's full-sized avatar
:shipit:

Gabriel Grubba Grubba27

:shipit:
View GitHub Profile
@Grubba27
Grubba27 / toplevel.js
Created April 26, 2023 14:16
error when building docs
// Log error:
// ERROR: Unable to parse /Users/grubba/Desktop/work/meteor/meteor/packages/accounts-password/password_server.js: await is a reserved word (1133:39)
// ERROR: Unable to parse /Users/grubba/Desktop/work/meteor/meteor/packages/webapp/webapp_server.js: await is a reserved word (1496:0)
/// password_server.js:
async function __initAccountsIndexes() {
await Meteor.users.createIndexAsync(
"services.email.verificationTokens.token",
{ unique: true, sparse: true }
@Grubba27
Grubba27 / retry.js
Created April 6, 2023 00:09
simple example with retry + custom errors
class RetryError extends Error {
constructor(message, err) {
super(message);
this.kind = 'RetryError';
// work here with the error
this.rawError = err;
}
}
@Grubba27
Grubba27 / build.md
Created March 27, 2023 15:31
Making Meteor build better
theme
./styles.json

Making Meteor build better.

How?

We have two options ahead, the first one is being trying replace babel with swc, the second one is to try to improve the current build process.

import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import {
useReducer,
useMemo,
useEffect,
Reducer,
DependencyList,
useRef,
} from 'react';
@Grubba27
Grubba27 / suspensify.ts
Last active March 13, 2023 21:31
making any promise suspendable in react.
const cacheMap = new Map<string, Entry>()
interface Entry {
deps: EJSON[]
promise: Promise<unknown>
result?: unknown // here is what your T should be
error?: unknown
}
// you can use isEqual from lodash in this case
function arraysEqual<T>(a: T[], b: T[]): boolean {
@Grubba27
Grubba27 / isAsyncCall.js
Last active March 7, 2023 19:00
Meteor 3 know if call is async or not
// server/server.js
Meteor.methods({
'someMethod': async function() {
if (Meteor.isAsyncCall()) {
// here is a when a callAsync
} else {
// when is just call
}
return Meteor.isCallAsync();
})
@Grubba27
Grubba27 / godocs.go
Last active February 22, 2023 05:00
new godocs in the terminal (TUI)
package main
import (
"fmt"
md "github.com/JohannesKaufmann/html-to-markdown"
"github.com/PuerkitoBio/goquery"
"github.com/charmbracelet/glamour"
"log"
"net/http"
"os"
@Grubba27
Grubba27 / fn.ts
Created February 17, 2023 21:52
arrow vs function declaration
const Module = {
value: 0,
someFn: () => {
return this.value;
},
okayFn() {
return this.value;
}
}
class Module2 {
@Grubba27
Grubba27 / get_url_params.ts
Created January 30, 2023 21:09
Get url params
type GetParams<
Text extends string,
Result extends string = ''
> =
Text extends `${ infer L }${ infer R }`
? L extends '/'
? Result
: GetParams<R, `${ Result }${ L }`>
: Result
@Grubba27
Grubba27 / concat.ts
Created January 30, 2023 20:41
concat until
type ConcatUntil
<
Text extends string,
Delimiter extends string,
Result extends string = ''
> =
Text extends `${infer L}${infer R}`
? L extends Delimiter
? Result
: ConcatUntil<R, `${Result}${L}` >