Skip to content

Instantly share code, notes, and snippets.

View manishoo's full-sized avatar
🌃
Working from home

Mani Shooshtari manishoo

🌃
Working from home
View GitHub Profile
@armand1m
armand1m / Dockerfile
Last active March 10, 2024 14:54
Yarn cache compatible Dockerfile
FROM alpine
RUN apk add --update --no-cache nodejs
RUN npm i -g yarn
ADD package.json yarn.lock /tmp/
ADD .yarn-cache.tgz /
RUN cd /tmp && yarn
RUN mkdir -p /service && cd /service && ln -s /tmp/node_modules
@zhenwenc
zhenwenc / buildSchema.js
Last active November 3, 2021 22:48
Generate Apollo API based on remote GraphQL schema merging with schemas for local state
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const https = require('https');
const yargs = require('yargs');
const fetch = require('node-fetch');
const { parse, execute, buildSchema } = require('graphql');
const { makeExecutableSchema } = require('graphql-tools');
@mostafa-hz
mostafa-hz / run-for-at-least.ts
Last active April 15, 2022 12:28
This function execute the another function and return the result or throw the error in the least given time, one of the use case is to protect agains timing-attack
export async function runForAtLeast<T>(fn: (...args: any[]) => Promise<T>, ms?: number, ...args: any[]): Promise<T> {
const [res] = await Promise.allSettled([
fn(...args),
new Promise(resolve => setTimeout(resolve, ms)),
]);
switch (res.status) {
case 'fulfilled':
return res.value;
case 'rejected':
throw res.reason;