This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.getProducts = async (req, res, next) => { | |
const docs = await Product.find() | |
.select('_id price productImage') | |
const response = { | |
count: docs.length, | |
docs: docs.map(doc => ({ | |
_id: doc._id, | |
price: doc.price, | |
request: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import request from '@ejnshtein/smol-request' | |
const startTime = Date.now() | |
request('https://google.com', { responseType: 'headers' }) | |
.then(() => { | |
const endTime = Date.now() | |
console.log(`My latency is ~${endTime - startTime}ms`) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Express = require('express') | |
const app = Express() | |
const sleep = timeout => new Promise(resolve => setTimeout(resolve, timeout)) | |
async function getData () { | |
await sleep(400) | |
return 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Spotify ad skipper | |
// @version 1.0 | |
// @namespace http://tampermonkey.net/ | |
// @description Detects and skips ads on spotify | |
// @match https://*.spotify.com/* | |
// @grant none | |
// @run-at document-start | |
// @downloadURL https://gist.githubusercontent.com/Simonwep/24f8cdcd6d32d86e929004013bd660ae/raw | |
// @updateURL https://gist.githubusercontent.com/Simonwep/24f8cdcd6d32d86e929004013bd660ae/raw |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Spotify ad skipper | |
// @version 1.0 | |
// @namespace http://tampermonkey.net/ | |
// @description Detects and skips ads on spotify | |
// @match https://*.spotify.com/* | |
// @grant none | |
// @run-at document-start | |
// @downloadURL https://gist.githubusercontent.com/Simonwep/24f8cdcd6d32d86e929004013bd660ae/raw | |
// @updateURL https://gist.githubusercontent.com/Simonwep/24f8cdcd6d32d86e929004013bd660ae/raw |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// docs: https://nodejs.org/dist/latest-v10.x/docs/api/https.html#https_https_request_url_options_callback | |
// all methods working, but post only with x-form-urlencoded. return promise with resolved object on line 64. | |
// extra options parameters: json=[bool], params=[object] | |
const querystring = require('querystring') | |
const https = require('https') | |
const http = require('http') | |
const cleanObject = (object, filterKeys) => Object | |
.keys(object) | |
.reduce((acc, key) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ua = require('useragent-generator') | |
const querystring = require('querystring') | |
const https = require('https') | |
const userAgent = ua.chrome({ | |
version: '72.0.3626.121', | |
os: 'Windows NT 10.0' | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sleep = timeout => new Promise(resolve => setTimeout(resolve, timeout)) | |
!(async () => { | |
for (chapter of array1) { | |
for (article of array2) { | |
console.log(`i=${chapter}, j=${article}`) | |
await sleep(5000) | |
} | |
} | |
})() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const FormData = require('form-data') | |
async function uploadFile (file) { | |
const form = new FormData() | |
form.append(`data`, file.file, { | |
filename: file.name | |
}) | |
const res = await new Promise((resolve, reject) => { | |
form.submit('https://telegra.ph/upload', (err, res) => { | |
let data = '' | |
res.on('data', chunk => data += chunk ) |
NewerOlder