Posts

Showing posts from May, 2021

Meaning of `{}` for return expression

15 1 I found by accident that the following compiles: #include <string> #include <iostream> class A{ int i{}; std::string s{}; public: A(int _i, const std::string& _s) : i(_i), s(_s) { puts("Called A(int, const std::string)"); } }; A foo(int k, const char* cstr){ return {k, cstr}; // (*) } int main(){ auto a = foo(10, "Hi!"); return 0; } The line of interest is (*). I guess the function foo is equivalent to: A foo(int k, const char* str){ return A(k, cstr); } However, is there a special name for this mechanism in (*)? Or is it just the simple fact that the compiler knows which constructor to call due to the return type? ...

cannot import name '_endpoint_from_view_func' from 'flask.helpers' in python

7 I ran the same code on Ubuntu with no problem, but ran it on Windows10 with problems. I also installed Flask. My windows environment is configured as follows: $ pip --version pip 21.1.1 from c:\users\min\appdata\local\programs\python\python37\lib\site-packages\pip (python 3.7) $ pip show flask Name: Flask Version: 2.0.0 Summary: A simple framework for building complex web applications. Home-page: https://palletsprojects.com/p/flask Author: Armin Ronacher Author-email: armin.ronacher@active-4.com License: BSD-3-Clause Location: c:\users\min\appdata\local\programs\python\python37\lib\site-packages Requires: Werkzeug, itsdangerous, Jinja2, click Required-by: Flask-RESTful, Flask-API $ pip show flask-restful Name: Flask-RESTful Version: 0.3.8 Summary: Simple framework ...

How to set initial custom variable date upon datepicker opening in Materialize

7 0 I use two Materialize datepickers. Upon opening the date picker I want the date that in already in html input field to be displayed / used by the date picker. I was thinkig of onOpen callback and there use native .setDate() function. But I got two date pickers and did not find if onOpen accepts any arguments. var datepickerOptions ={ format: 'yyyy-mm-dd', autoClose : "true", firstDay : 1, onOpen : function(arg) { console.log(arg) } } document.addEventListener('DOMContentLoaded', function() { var elems = document.querySelectorAll('.datepicker'); var instances = M.Datepicker.init(elems, datepickerOptions); }); I am using Materialize v1.0. and working jsFiddle is here ...

How do I create a Field from a value T in jOOQ, explicitly?

16 1 In jOOQ, it is easy to use bind variables in expressions like: MY_TABLE.COL.eq(1); MY_TABLE.COL.in(1, 2, 3); MY_TABLE.COL.between(1).and(10); All of the above methods accept both T and Field<T> types, e.g. Field.eq(T) or Field.eq(Field<T>) . But what if I want to put the bind variable on the left side of the expression? These obviously don't work: 1.eq(MY_TABLE.COL); 1.in(MY_TABLE.COL1, MY_TABLE.COL2, MY_TABLE.COL3); 1.between(MY_TABLE.COL1).and(MY_TABLE.COL2); How can I turn those 1 or "xyz" into Field<Integer> or Field<String> , etc.? (This is such a popular question on the jOOQ mailing list, etc., so I'm documenting it here) java sql jooq ...

403 Response code - Request Blocked when using Cowin setu APIs

6 1 I was just trying to make covid vaccine alert using Cowin Setu API (India) in nodejs. But I am facing some strange thing, whenever I hit get request I got 403 response code from cloudfront says 'Request Blocked' but the same is working from postman as well as from browser. Please help me in this Getting this error:- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <TITLE>ERROR: The request could not be satisfied</TITLE> </HEAD><BODY> <H1>403 ERROR</H1> <H2>The request could not be satisfied.</H2> <HR no...

Is openJdk upgrading to 8u292 break my aosp build system?

4 Software environment: Ubuntu 20.04 LTS server; Android AOSP 8.0; OpenJDK 8; It works very well util yesterday I upgraded my OpenJDK from 8u282 to 8u292. Now the broken building log says: Ensuring Jack server is installed and started FAILED: setup-jack-server /bin/bash -c "(prebuilts/sdk/tools/jack-admin install-server prebuilts/sdk/tools/jack-launcher.jar prebuilts/sdk/tools/jack-server-4.11.ALPHA.jar 2>&1 || (exit 0) ) && (JACK_SERVER_VM_ARGUMENTS=\"-Dfile.encoding=UTF-8 -XX:+TieredCompilation\" prebuilts/sdk/tools/jack-admin start-server 2>&1 || exit 0 ) && (prebuilts/sdk/tools/jack-admin update server prebuilts/sdk/tools/jack-server-4.11.ALPHA.jar 4.11.ALPHA 2>&1 || exit 0 ) && (prebuilts/sdk/tool...

yo @microsoft/sharepoint fails on TypeError: lookups.flatMap is not a function

4 1 After installation of Node v10.16.1 and installation of gulp and yo (Everything looks alright !) it fails on command yo @microsoft/sharepoint with TypeError: lookups.flatMap is not a function C:\Users\MYNAME\AppData\Roaming\npm\node_modules\yo\node_modules\yeoman-environment\lib\resolver.js:70 filePatterns: lookups.flatMap(prefix => [`${prefix}/*/index.ts`, `${prefix}/*/index.js`]), ^ TypeError: lookups.flatMap is not a function at Environment.resolver.lookup (C:\Users\MYNAME\AppData\Roaming\npm\node_modules\yo\node_modules\yeoman-environment\lib\resolver.js:70:27) at init (C:\Users\MYNAME\AppData\Roaming\npm\node_modules\yo\lib\cli.js:130:7) at pre (C:\Users\MYNAME\AppData\Roaming\npm\node_modules\yo\lib\cli.js:89:3)...

AWS Fargate ResourceInitializationError: unable to pull secrets or registry auth: pull command failed: : signal: killed

4 1 Slightly tearing my hair out with this one... I am trying to run a Docker image on Fargate in a VPC in a Public subnet. When I run this as a Task I get: ResourceInitializationError: unable to pull secrets or registry auth: pull command failed: : signal: killed If I run the Task in a Private subnet, through a NAT, it works. It also works if I run it in a Public subnet of the default VPC. I have checked through the advice here: Aws ecs fargate ResourceInitializationError: unable to pull secrets or registry auth In particular, I have security groups set up to allow all traffic. Also Network ACL set up to allow all traffic. I have even been quite liberal with the IAM permissions, in order to try and eliminate that as a possibility: The task execution role has: ...

Java-VSCode error:Cannot resolve the modulepaths/classpaths automatically, please specify the value in the launch.json

2 first of all I read all the questions about the problem, but I could not find the answer. The compiler sent me an error "Cannot resolve the modulepaths/classpaths automatically, please specify the value in the launch.json." but i don't know how i will solve this problem. Is there any know how i solve this? java visual-studio-code Share Improve this question Follow ...

Gunicorn ImportError: cannot import name 'ALREADY_HANDLED' from 'eventlet.wsgi' in docker

7 1 I had a working code running flask with gunicorn (eventlet worker) in docker. It's also working in production, but on my machine, it started doing this. I can't find anything on google about this thing. What meight be the problem? Error: class uri 'eventlet' invalid or not found: web_1 | web_1 | [Traceback (most recent call last): web_1 | File "/root/.local/lib/python3.7/site-packages/gunicorn/util.py", line 99, in load_class web_1 | mod = importlib.import_module('.'.join(components)) web_1 | File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module web_1 | return _bootstrap._gcd_import(name[level:], package, level) web_1 | File "<froz...

How to count the number of matched strings in R, when the string pattern to match is a column from another dataframe?

4 I have got two extremely large dataframes, the first data frame consists of a column body , which is a list of comments and the second one consists of names . I want to count how many elements in body contain each element of names . Here's a small reproducible dataset (the original dataset has about 2000 names, where each name is a name of the car): df1 <- tibble(body = c("The Tesla Roadster has a range of 620 miles", "ferrari needs to make an electric car", "How much does a tesla cost?", "When is the new Mercedes releasing?", "Can't wait to get my hands on the new Tesla")) df2 <- tibble(names = c("FORD...

Pip 21.1 can't import InvalidSchemeCombination

13 At work, we use Github actions to build and test our Pull Requests before they can be approved. On Friday afternoon, everything was working just fine. On Monday morning, all tests were failing pretty early, with an error showing that pip could no longer find its own exceptions. Did something change with the newest Pip? As you can see in the errors below, our own code isn't referenced, and I'm fairly certain nothing in our flow changed between Friday and Monday (we're a small team and the approved PRs don't have anything surprising there). Error Traceback: Traceback (most recent call last): File "/opt/hostedtoolcache/Python/3.7.9/x64/bin/pip", line 5, in <module> from pip._internal.cli.main import main File "/opt/h...