Skip to content

Instantly share code, notes, and snippets.

View ejnshtein's full-sized avatar
🦍
Oug Developer

岡部 倫太郎 ejnshtein

🦍
Oug Developer
View GitHub Profile
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: {
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`)
})
const Express = require('express')
const app = Express()
const sleep = timeout => new Promise(resolve => setTimeout(resolve, timeout))
async function getData () {
await sleep(400)
return 1
// ==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
// ==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
// 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) => {
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'
})
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)
}
}
})()
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 )