Skip to content

Instantly share code, notes, and snippets.

View jamalhassouni's full-sized avatar
🎯
Focusing

jamal hassouni jamalhassouni

🎯
Focusing
View GitHub Profile
@codediodeio
codediodeio / index.js
Created June 28, 2017 15:54
Firebase Cloud Functions image thumbnail generator using Sharp for 4x faster resizing
const functions = require('firebase-functions');
const gcs = require('@google-cloud/storage')();
const sharp = require('sharp')
const _ = require('lodash');
const path = require('path');
const os = require('os');
exports.generateThumbnail = functions.storage.object('uploads/{imageId}').onChange(event => {
const object = event.data; // The Storage object.
@select
select / objectsToCsv.js
Last active December 19, 2022 18:17
Convert an Array of non uniform Objects to a CSV string with JavaScript
function getKeys(obj, prefix = '') {
if (typeof obj === 'undefined' || obj === null) return [];
return [
...Object.keys(obj).map(key => `${prefix}${key}`),
...Object.entries(obj).reduce((acc, [key, value]) => {
if (typeof value === 'object') return [...acc, ...getKeys(value, `${prefix}${key}.`)];
return acc;
}, []),
];
}
@edPratt
edPratt / mac-osx-node-npm.md
Last active December 19, 2019 21:56
Fixing npm On Mac OS X; When npm install -g does not work

Nuke Everything node/npm related

(If you have setup another prefix)
rm -rf .npm-global

sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf ~/.npm
brew uninstall node --ignore-dependencies node
rm -rf /usr/local/lib/node_modules