Skip to content

Instantly share code, notes, and snippets.

View omar-dulaimi's full-sized avatar
🎩
Top hat

Omar Dulaimi omar-dulaimi

🎩
Top hat
  • Jordan
View GitHub Profile
@omar-dulaimi
omar-dulaimi / linkedin_boolean_search.txt
Last active March 12, 2022 08:35
Nodejs developer LinkedIn Boolean Search Query
(node OR nodejs OR "node js" OR "Node.js" OR nestjs OR expressjs) AND (remote OR remotely) NOT (ruby OR php OR go OR rust OR asp OR asp.net OR c# OR rails OR Selenium OR WebDriver OR "Java" OR "java" OR CyberCoders OR Revelo OR 10Clouds OR Manara)
@omar-dulaimi
omar-dulaimi / yup-validate-alternatives.js
Last active August 28, 2022 00:46
Yup validate multiple schemas for the same field (Joi alternatives)
// First you define a method called `oneOfSchemas`
yup.addMethod(yup.MixedSchema, "oneOfSchemas", function (schemas) {
return this.test(
"one-of-schemas",
"Not all items in ${path} match one of the allowed schemas",
(item) =>
schemas.some((schema) => schema.isValidSync(item, { strict: true }))
);
});
@omar-dulaimi
omar-dulaimi / example.js
Created December 23, 2022 06:20
How to make a GET request query params for tRPC
const query = { where: {} };
const queryString = encodeURIComponent(JSON.stringify(query));
const finalUrl = `http://127.0.0.1:3001/trpc/user.listUsers?${queryString}`;
@omar-dulaimi
omar-dulaimi / code.ts
Created December 31, 2022 07:42
Read a class using ts-morph
import { project } from './project';
const sourceFile = project.addSourceFileAtPath(
path.join(cwd(), 'src', './file.ts'),
);
const resolverClass = sourceFile.getClass('otherFile');
for (const method of resolverClass.getMethods()) {
const decorators = [];
for (const decorator of method.getDecorators()) {
@omar-dulaimi
omar-dulaimi / code.js
Created January 1, 2023 12:35
How to use Buffers/Bytes with tRPC and Prisma
superjson.registerCustom<Buffer, number[]>(
{
isApplicable: (v): v is Buffer => v instanceof Buffer,
serialize: v => [...v],
deserialize: v => Buffer.from(v)
},
"buffer"
);
@omar-dulaimi
omar-dulaimi / code.js
Created January 5, 2023 19:34
Generate download URL for a Firebase function
const { google } = require("googleapis");
const cloudfunctions = google.cloudfunctions("v1");
async function main() {
const auth = new google.auth.GoogleAuth({
scopes: ["https://www.googleapis.com/auth/cloud-platform"],
});
const authClient = await auth.getClient();
google.options({ auth: authClient });