Javascript for loop variable is strange when writing on a file

Advertisements I have this code in ‘./utils/url.js’. it basically makes the application/x-www-form-urlencoded content form: const ContentForm = ()=>{ let params = new URLSearchParams() const randomString = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15); params.append(’email’, `${randomString}@gmail.com`) return params; } module.exports = ContentForm; The email parameter is a random string. and index.js: const axios = require(‘axios’).default; const fs =… Read More Javascript for loop variable is strange when writing on a file

Express – Cannot access 'Database' before initialization

Advertisements const express = require(‘express’); const upload = require("express-fileupload"); const editJsonFile = require("edit-json-file"); const fs = require(‘fs’); const app = express(); app.use(upload()) app.use(express.urlencoded({ extended: true })) const playlist = editJsonFile(`${__dirname}/playlist.json`); app.post("/upload", (req, res) => { //Save file from the html form to ./mp3 var file = req.files.file; req.pipe(fs.createWriteStream("./mp3/" + file.name)); res.send("File uploaded"); playlist.append("playlist", file.name) playlist.save()… Read More Express – Cannot access 'Database' before initialization

SQL Join Using REGEXP_SUBSTR and Wildcard

Advertisements I’m trying to join two tables in Snowflake using REGEX_SUBSTR and a wildcard but having no luck. Here is what I have: SELECT P.NAME, ACL.CONTENT_NAME, REGEXP_SUBSTR(CONTENT_NAME, ‘/([^/]+(\\.pdf))$’, 1, 1, ‘e’, 1) AS PDFS FROM ACTIVITY_DOWNLOAD AD JOIN PROGRAM P ON P.NAME LIKE ‘%’ || REGEXP_SUBSTR(CONTENT_NAME, ‘/([^/]+(\\.pdf))$’, 1, 1, ‘e’, 1) || ‘%’ Running the… Read More SQL Join Using REGEXP_SUBSTR and Wildcard

Dynamic top 3 and percentage total using pandas groupby

Advertisements I have a dataframe like as shown below id,Name,country,amount,qty 1,ABC,USA,123,4500 1,ABC,USA,156,3210 1,BCE,USA,687,2137 1,DEF,UK,456,1236 1,ABC,nan,216,324 1,DEF,nan,12678,11241 1,nan,nan,637,213 1,BCE,nan,213,543 1,XYZ,KOREA,432,321 1,XYZ,AUS,231,321 sf = pd.read_clipboard(sep=’,’) I would like to do the below a) Get top 3 based on amount for each id and other selected columns such as Name and country. Meaning, we get top 3 based… Read More Dynamic top 3 and percentage total using pandas groupby