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 / 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 });
@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.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 / 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 / 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 / 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)

How to reset root MySQL password on Ubuntu 18.04 Bionic Beaver Linux

sudo service mysql stop
sudo mkdir -p /var/run/mysqld
sudo chown mysql:mysql /var/run/mysqld
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
mysql -u root
@omar-dulaimi
omar-dulaimi / install-docker.md
Created May 19, 2021 06:19 — forked from npearce/install-docker.md
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
@omar-dulaimi
omar-dulaimi / log.txt
Created May 5, 2021 20:46
k6 panic error
This file has been truncated, but you can view the full file.
/\ |‾‾| /‾‾/ /‾‾/
/\ / \ | |/ / / /
/ \/ \ | ( / ‾‾\
/ \ | |\ \ | (‾) |
/ __________ \ |__| \__\ \_____/ .io
execution: local
script: loadtest.js
output: -
@omar-dulaimi
omar-dulaimi / paramDecorator.ts
Created April 11, 2021 15:52
TypeGraphQL with PrismaSelect from Pal.js
import { PrismaSelect } from '@paljs/plugins';
export function Fields(): ParameterDecorator {
return createParamDecorator(({ info }) => {
const fieldsMap = new PrismaSelect(info).value;
return fieldsMap;
});
}