how obfuscat entire folder js file using gulpfile.js
"Here is my gulpfile.js please let me know what should i have to add in this file to obfuscat all js files"
const gulp = require("gulp");
const minify = require("gulp-minify");
const JavaScriptObfuscator = require("javascript-obfuscator");
gulp.task("js", function () {
return gulp
.src("js/*.js")
.pipe(gulp.dest("output/"));
});
See also questions close to this topic
-
How to devise this solution to Non-Constructible Change challenge from Algoexpert.io
I'm working through algoexpert.io coding challenges and I'm having trouble undersatnding the suggested solution to one of the questions titled Non-Constructible Change
Here's the challenge question:
Given an array of positive integers representing the values of coins in your possession, write a function that returns the minimum amount of change (the minimum sum of money) that you cannot create. The given coins can have any positive integer value and aren't necessarily unique (i.e., you can have multiple coins of the same value).
For example, if you're given coins = [1, 2, 5], the minimum amount of change that you can't create is 4. If you're given no coins, the minimum amount of change that you can't create is 1.
// O(nlogn) time, O(n) size. function nonConstructibleChange(coins) { coins = coins.sort((a, b) => a - b); // O(nlogn) time operation let change = 0; for (coin of coins) { if (coin > change + 1) return change + 1; change += coin; } return change + 1; }
My problem
I am not completely sure how did the author of the solution come up with the intuition that
if the current coin is greater than `change + 1`, the smallest impossible change is equal to `change + 1`.
I can see how it tracks, and indeed the algorithm passes all tests, but I'd like to know more about a process I could use to devise this rule.
Thank you for taking the time to read the question!
-
My document is not defined because of lost context
Working with vanilla.js and my code looks like this:
class Restaurant { constructor() { this.menu = []; this.categories = ['all']; } handleSearch(event) { const searchInput = document.querySelector('.search-input'); const minPriceInput = document.querySelector('.min-price'); const maxPriceInput = document.querySelector('.max-price'); if (event.target.matches('.search-btn')) { event.preventDefault(); const keyword = searchInput.value.toLowerCase(); const minPrice = minPriceInput.value || 0; const maxPrice = maxPriceInput || Infinity; let category = docuemnt.querySelector(".filter-active").dataset.id; let filteredMenu = []; if (category === this.categories[0]) { // categories[0] is "all"; filteredMenu = menu.filter(item => { return item.title.includes(keyword) && item.price >= minPrice && item.price <= maxPrice; }) this.renderMenu(filteredMenu); } else { filteredMenu = menu.filter(item => { return item.category === selectedCategory && item.title.includes(keyword) && item.price >= minPrice && item.price <= maxPrice; }) this.renderMenu(filteredMenu); } } } render() { const buttonsContainer = document.querySelector('.btn-container'); const searchButton = document.querySelector('.search-btn'); buttonsContainer.addEventListener('click', this.handleFilter.bind(this)); searchButton.addEventListener('click', this.handleSearch.bind(this)); this.setCategories(); this.renderButtons(); this.renderMenu(this.menu); } }
my document object is undefined inside the handleSearch method. Is it possible to solve this problem without placing all element variables outside the method? Even if I do so I have another variable "categories" which is using document object.
-
React-dnd multiple elements
I can make react-dnd drag easily having a single element to drag over however I have array of 4 fields I'd like to make draggable. In my example code down below it creates four boxes from mapping the array and each box has a className of 'element'. Which should make them all draggable however they won't move.
Here is my drag code:
const ELEMENT = 'element'; const [{ isDragging }, drag, dragPreview] = useDrag(() => ({ type: ELEMENT, collect: (monitor) => ({ isDragging: monitor.isDragging() }) }))
Here is my draggable element:
{FieldDetail.map((e,i) => <div key={i} ref={dragPreview} style={{ opacity: isDragging ? 0.5 : 1}}> <div className='element' ref={drag}></div> </div> )}
Any ideas? Do I need to do something more within the type or className?
-
Make Query With having, count and join in Sequelize
I have two tables in MySQL, joined with a Many to Many relationship. They are as follows:
Equipments:
Field Type Id PK, Integer name Varchar description Varchar createdAt datetime Instructions:
Field Type id FK, integer name Varchar And the table that joins them as a pivot:
EquipmentInstructions:
Field Type equipmentId FK, integer instructionId FK, integer The query I'm trying to do is this, but getting all the fields, not just the name and description.
SELECT P.equipmentId, E.name, E.description FROM EquipmentInstructions P JOIN Equipments E ON P.equipmentId=E.id WHERE P.instructionId IN (1,2,3) GROUP BY P.equipmentId HAVING COUNT(*)=3;
This query returns:
equipmentId, name, description '8', 'ESPATULA', 'Espátula de cocina' '7', 'PARRILLA', 'Para asar la carne' '4', 'CUCHARÓN', 'Cuchara grande'
I am trying to pass said query to Sequelize, so far I have achieved this:
Equipment.findAndCountAll({ include: [ { model: Instruction, as: "instructions", through: { where: { instructionId: { [Op.in]: [1,2,3], }, }, }, attributes: { include: ["id"], }, }, ], group: ["id"], having: Sequelize.where(Sequelize.fn("COUNT", "*"), "=", recipeIds.length), }) .then((result) => { console.log(result); res.json(result); })
The result is correct, however, I only get the id of the equipment:
{ count: [ { id: 4, count: 3 }, { id: 7, count: 3 }, { id: 8, count: 3 } ], rows: [] }
I need to show the complete information of the equipment and additionally count how many records exist in total (by pagination issues).
-
How to ssr Svelte and pass data from express in node js
I am trying svelte and I might use it for my future website, but there is on thing that has stopped me from suing many js frameworks/compilers. It is server side rendering (one reason is I use server-less so it would be easier then prerendering). Is there a way to use express to server-side-render svelte on every request and also pass data from my node js app too so I don't have to make a bunch of other request? For example the App.svelte might be:
<script> export let data let count = 0 </script> <main> <button on:click={count++}>Increase Count BY 1</button> <h1>{data}<h1> </main>
and main.js:
import App from './App.svelte'; const app = new App({ target: document.body, props: { } }); export default app;
I want to get the data value from the server and use it in the svelte code and also sever-side-render it. Is there a way I can do this?
-
how to send long complex array with socket.io?
I have complex an array containing lots of base64 data. and I send this array to server with socket.io. If I send an array containing one or two base64 data. the function is working successfully. but if I send an array containing lots of base64 data. function does not react.
my purpose
- client will prepare templates.
- When the client clicks the save button, it sends this template to the server with socket.io.
- templates sent to the server will be saved to hdd with nodejs.
my array template
const MyArray = [ { div_id:div.id, div_innerhtml:div.innerHTML, //<img src=base64... div_backgroundimage : div.backgroundimage //base64... } ]
client-side code
const MyArray=[],SaveBtn = document.queryselector("#save_div"); const SendArray = (ARRAY)=>{ socket.emit("div_data",ARRAY); } SaveBtn.onclick = ()=>{ SendArray(MyArray); }
server-side code
socket.on("div_data",(data)=>{ console.log(data) // function does not react. let JSON_DATA = JSON.stringify(data) console.log(JSON_DATA) // function does not react. });
Is this socket.io error? What should I do or how should I research this issue?
UPDATE
network tab in devtools
for two base64 image : (function work successfully)
for four base64 image : (function does not react)
-
Gulp ReferenceError: let is not defined
I enter
gulp
into the terminal and this problem arises. what is the essence of the problem and how to solve it? -
Coursera course's Gulp Issue
I took a Coursera course where there is no follow up with instructor nor TA... and the course is very out dated
I've been looking everywhere there seems to be no answer
I had to uninstall and install node v14.16.1 and then upgraded gulp to latest v4.0.2
I've done what it says
rebuilt dependencies successfully
but when I run gulp after it still gives me the same message to run 'npm rebuild node-sass'.....
---------script file------------- 'use strict';
var gulp = require('gulp'), sass = require('gulp-sass'), browserSync = require('browser-sync'); gulp.task('sass', function () { return gulp.src('./css/*.scss') .pipe(sass().on('error', sass.logError)) .pipe(gulp.dest('./css')); }); gulp.task('sass:watch', function () { gulp.watch('./css/*.scss', ['sass']); }); gulp.task('browser-sync', function () { var files = [ './*.html', './css/*.css', './img/*.{png,jpg,gif}', './js/*.js' ]; browserSync.init(files, { server: { baseDir: "./" } }); }); // Default task gulp.task('default', ['browser-sync'], function() { gulp.start('sass:watch'); }); ---------command prompt------------ C:\Users\Jie Eun Lee\Desktop\FEWUIFT\Bootstrap4\Bootstrap4\conFusion>gulp Error: Missing binding C:\Users\Jie Eun Lee\Desktop\FEWUIFT\Bootstrap4\Bootstrap4\conFusion\node_modules\node-sass\vendor\win32-x64-83\binding.node Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 14.x Found bindings for the following environments: - Windows 64-bit with Node.js 6.x This usually happens because your environment has changed since running `npm install`. Run `npm rebuild node-sass` to download the binding for your current environment. at module.exports (C:\Users\Jie Eun Lee\Desktop\FEWUIFT\Bootstrap4\Bootstrap4\conFusion\node_modules\node-sass\lib\binding.js:15:13) at Object.<anonymous> (C:\Users\Jie Eun Lee\Desktop\FEWUIFT\Bootstrap4\Bootstrap4\conFusion\node_modules\node-sass\lib\index.js:14:35) at Module._compile (internal/modules/cjs/loader.js:1063:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10) at Module.load (internal/modules/cjs/loader.js:928:32) at Function.Module._load (internal/modules/cjs/loader.js:769:14) at Module.require (internal/modules/cjs/loader.js:952:19) at require (internal/modules/cjs/helpers.js:88:18) at Object.<anonymous> (C:\Users\Jie Eun Lee\Desktop\FEWUIFT\Bootstrap4\Bootstrap4\conFusion\node_modules\gulp-sass\index.js:166:21) at Module._compile (internal/modules/cjs/loader.js:1063:30)
-
Redirect request coming from IP/$url to IP:port using GULP
I need to modify a working GULP task that someone else wrote:
gulp.task('webserver', gulp.series(async function() { server = connect.server({ port: 1234, https: false, }); }));
I would like to redirect requests coming from Nginx let's say
/mywebapp
url tolocalhost:1234
in GULP, and I have never done such thing before. I have tried to insertmiddleware
code, but I haven't succeded yet. Can anyone please help me with this? -
Unsupported platform for inotify@1.4.6 on Mac while npm install
I'm trying to set up a project for react. however, while I run npm install, it throws this error:
npm ERR! code EBADPLATFORM npm ERR! notsup Unsupported platform for inotify@1.4.6: wanted {"os":"linux","arch":"any"} (current: {"os":"darwin","arch":"x64"}) npm ERR! notsup Valid OS: linux npm ERR! notsup Valid Arch: any npm ERR! notsup Actual OS: darwin npm ERR! notsup Actual Arch: x64
Apparently, It looks like this library is not supported on my mac. I hope some workaround can resolve this issue instead of removing this library. kindly suggest how can I resolve this issue.
-
Error while installing mobileui npm install -g mobileui
I install
npm i -g cordova
(install successfully and working)
but while in installing
npm install -g mobileui
I am using node 10.24.1 npm -v 6.14.12
it shows following error
C:\Users\shakeel\Desktop\myapp3>npm install -g mobileui npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm WARN deprecated har-validator@5.1.5: this library is no longer supported npm WARN deprecated natives@1.1.6: This module relies on Node.js's internals and will break at some point. Do not use it, and update to graceful-fs@4.x. > mobileui@1.1.20 preinstall C:\Users\shakeel\AppData\Roaming\npm\node_modules\mobileui > npx npm-force-resolutions npx: installed 6 in 4.623s Error: ENOENT: no such file or directory, open './package-lock.json' at Object.openSync (fs.js:443:3) at Object.fs [as readFileSync] (fs.js:343:35) at npm_force_resolutions$core$node_slurp (C:\Users\shakeel\AppData\Roaming\npm-cache\_npx\3924\node_modules\npm-force-resolutions\out\npm_force_resolutions\core.cljs:15:20) at npm_force_resolutions$core$read_json (C:\Users\shakeel\AppData\Roaming\npm-cache\_npx\3924\node_modules\npm-force-resolutions\out\npm_force_resolutions\core.cljs:22:23) at switch__2144__auto__ (C:\Users\shakeel\AppData\Roaming\npm-cache\_npx\3924\node_modules\npm-force-resolutions\out\npm_force_resolutions\core.cljs:151:3) at C:\Users\shakeel\AppData\Roaming\npm-cache\_npx\3924\node_modules\npm-force-resolutions\out\npm_force_resolutions\core.cljs:151:3 at npm_force_resolutions$core$update_package_lock_$_state_machine__2145__auto____1 (C:\Users\shakeel\AppData\Roaming\npm-cache\_npx\3924\node_modules\npm-force-resolutions\out\npm_force_resolutions\core.js:648:4) at cljs.core.async.impl.ioc-helpers/FN-IDX (C:\Users\shakeel\AppData\Roaming\npm-cache\_npx\3924\node_modules\npm-force-resolutions\out\npm_force_resolutions\core.js:664:88) at cljs.core.async.impl.ioc-helpers/run-state-machine (C:\Users\shakeel\AppData\Roaming\npm-cache\_npx\3924\node_modules\npm-force-resolutions\out\cljs\core\async\impl\ioc_helpers.cljs:35:23) at cljs$core$async$impl$ioc_helpers$run_state_machine_wrapped (C:\Users\shakeel\AppData\Roaming\npm-cache\_npx\3924\node_modules\npm-force-resolutions\out\cljs\core\async\impl\ioc_helpers.cljs:39:6) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.1 (node_modules\mobileui\node_modules\chokidar\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! mobileui@1.1.20 preinstall: `npx npm-force-resolutions` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the mobileui@1.1.20 preinstall script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\shakeel\AppData\Roaming\npm-cache\_logs\2021-04-14T07_02_43_849Z-debug.log
-
Node Red. Create a dashboard that plots the x and y coordinates of the mouse real time
I'm not too sure where to start. I haven't been able to find any nodes which can help check the coordinates of the mouse.