天道酬勤,学无止境

问答

Need to loop through 2 arrays at the same time in JSTL

I have two arrays that I need to loop through. Using foreach, I can only loop through one at a time. A regular for(i = 0; i<7; i++) Loop would be great.

2022-05-03 11:54:05   jsp   jstl

ES6/JavaScript - declaring variables without let/const

Ok, my question is simple: In JavaScript / ES6 what happens when you have something like x = 5; console.log(x); // 5 is the interpreter automatically adding "let" at runtime or why is this working without errors? Edit: Strict Mode The syntax of ES5 allowed for something called implicit globals, which have been the source of many frustrating programming errors. In short, if you forgot to declare a variable with var , JavaScript would merrily assume you were referring to a global variable. If no such global variable existed, it would create one! You can imagine the problems this caused. I see

2022-05-03 11:53:59   javascript

Explain bpe (Byte Pair Encoding) with examples?

Can somebody help to explain the basic concept behind the bpe model? Except this paper, there is no so many explanations about it yet. What I have known so far is that it enables NMT model translation on open-vocabulary by encoding rare and unknown words as sequences of subword units. But I want to get a general idea of how it works without going through the paper.

2022-05-03 11:53:49   algorithm   nlp   tokenize

Why is this MutexGuard not dropped?

In Chapter 20 of The Rust Book, an example implementation of a thread pool is built. Jobs are passed to workers via a single-producer multiple-consumer channel: each worker has an Arc<Mutex<Receiver>> to pick jobs off the queue. The first example of the worker thread body looks like this: loop { let job = receiver.lock().unwrap().recv().unwrap(); println!("Worker {} got a job; executing.", id); job(); } When I saw this my first thought was "but the mutex is held while job is run" (i.e. I did not expect the mutex to be released until the return value of lock went out of scope at the end of the

2022-05-03 11:53:38   rust   lifetime

Visual Studio Code [eslint] Delete 'CR' [prettier/prettier] on windows

Eslint error in vscode terminal Getting ESLint error of CR - even if I have the git pull code with windows line endings. This occurs on Visual Studio Code with EsLint plugin (1.7.0) This did not occur until I recently update my git to the latest version(2.20.0).windows.1 My eslintrc file { "plugins": [ "jsx-a11y", "react", "prettier" ], "extends": [ "eslint:recommended", "plugin:react/recommended", "prettier" ], "parser": "babel-eslint", "parserOptions": { "ecmaVersion": 6, "sourceType": "module", "ecmaFeatures": { "jsx": true, "generators": true, "experimentalObjectRestSpread": true } }, "env

2022-05-03 11:53:32   reactjs   git   visual-studio-code   eslint   vscode-settings

Why im getting this error Warning: Operand of null-aware operation '??' has type 'Color' which excludes null

Im using this package flutter_datetime_picker: ^1.5.1 And this is my code String _date = "Please pick Age"; Widget _buildage() { return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Enter Age', style: kLabelStyle, ), SizedBox(height: 10.0), Container( decoration: kBoxDecorationStyle, alignment: Alignment.centerLeft, height: 70.0, child: Container( child: TextFormField( initialValue: "haaas", validator: (val) { if (val.isEmpty) { return 'Enter yout Age'; } if (val.length < 4) { return 'Enter a username minimun 4 chars long'; } return null; }, onChanged: (val) {

2022-05-03 11:53:26   flutter   date   dart   datetimepicker

Buildozer Unknown command/target android_old

im very noob still in python and kivy. Anyways, I'm making a simple android app, which just showing a single label. Now I'm trying to package that python file to an apk via buildozer. The buildozer init works, but then the buildozer -v android debug doesnt and give an error Unknown command/target android_old. Anyone can help me resolve this? Thanks

2022-05-03 11:53:16   android   python   kivy   buildozer

set ip in supertest request

with supertest, I can make a resquest to test my node.js application var request = require('supertest'); var api = require('../server').app; ... it('json response', function(done){ request(api) .get('/api') .set('Accept', 'application/json') .expect('Content-Type', /json/) .end(function(err, res){ done(); }); }); how I can set a specific ip to make the test request ? it('ip access denied', function(done){ request(api) .get('/api') .set('Accept', 'application/json') .expect('Content-Type', /json/) // set specific ip .end(function(err, res){ res.body.message.should.eql('Access denied'); done();

2022-05-03 11:53:10   node.js   mocha.js   supertest

How can I use a vectorised function in R in alternate sequence?

Suppose I have a vector x with n elements. I want to use any vectorised function, say cumprod, on every alternate number of x, i.e. every 1, 3, 5 and so on and another on 2, 4, 6 and so on. I am adding a reprex and code tried. The code works, but it seems I am unnecessarily taking a long route and code can be shortened. Can it be? x <- 5:14 cumprod((x * (seq_along(x) %% 2)) + (seq_along(x)-1) %% 2) * seq_along(x) %% 2 + cumprod((x * ((seq_along(x)-1) %% 2)) + seq_along(x) %% 2) * (seq_along(x)-1) %% 2 #> [1] 5 6 35 48 315 480 3465 5760 45045 80640 Here cumprod is just an example function. I

2022-05-03 11:53:00   r   sequence   modulo

PHP unset vs array_pop?

If I want to remove the last element of an array, I can use either of these two code: array_pop($array); (the return value is not used) unset($array[count($array) -1]); Is there any performance or semantic difference between them? If not, which is preferred?

2022-05-03 11:52:51   php   arrays   unset