Skip to content

Instantly share code, notes, and snippets.

@sidevesh
sidevesh / xdg-open
Created January 10, 2023 01:01
Replacement for xdg-open copy in "open" node dependency, to help login into Google account for MagicMirror's MMM-GoogleCalendar module over Slack for headless systems
#!/usr/bin/env node
const { spawn } = require('child_process');
const fs = require('fs');
const http = require('http');
const https = require('https');
const { basename } = require('path');
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
@sidevesh
sidevesh / fetchHandler.js
Last active April 30, 2020 11:54
fetchHandler - handle api calls to your Backend with fetch api in a simple and unified way
const responseParserTypes = {
json: (response) => response.json(),
text: (response) => response.text(),
blob: (response) => response.blob(),
formData: (response) => response.formData(),
arrayBuffer: (response) => response.arrayBuffer(),
};
const parseResponse = (response, type) => {
if (!Object.keys(responseParserTypes).includes(type)) {