choose | A human-friendly fast alternative to cut | Regex library
kandi X-RAY | choose Summary
kandi X-RAY | choose Summary
This is choose, a human-friendly and fast alternative to cut and (sometimes) awk.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of choose
choose Key Features
choose Examples and Code Snippets
def _choose_a1(self):
"""
Choose first alpha ;steps:
1:First loop over all sample
2:Second loop over all non-bound samples till all non-bound samples does not
voilate kkt condition.
3:Re
def _choose_a2(self, i1):
"""
Choose the second alpha by using heuristic algorithm ;steps:
1: Choose alpha2 which gets the maximum step size (|E1 - E2|).
2: Start in a random point,loop over all non-bound samples
private static int minTrials(int n, int m) {
int[][] eggFloor = new int[n + 1][m + 1];
int result, x;
for (int i = 1; i <= n; i++) {
eggFloor[i][0] = 0; // Zero trial for zero floor.
eggFloor[i][1]
Community Discussions
Trending Discussions on choose
QUESTION
ANSWER
Answered 2022-Apr-08 at 15:31Consider a typical use case of a std::any
: You pass it around in your code, move it dozens of times, store it in a data structure and fetch it again later. In particular, you'll likely return it from functions a lot.
As it is now, the pointer to the single "do everything" function is stored right next to the data in the any
. Given that it's a fairly small type (16 bytes on GCC x86-64), any
fits into a pair of registers. Now, if you return an any
from a function, the pointer to the "do everything" function of the any
is already in a register or on the stack! You can just jump directly to it without having to fetch anything from memory. Most likely, you didn't even have to touch memory at all: You know what type is in the any
at the point you construct it, so the function pointer value is just a constant that's loaded into the appropriate register. Later, you use the value of that register as your jump target. This means there's no chance for misprediction of the jump because there is nothing to predict, the value is right there for the CPU to consume.
In other words: The reason that you get the jump target for free with this implementation is that the CPU must have already touched the any
in some way to obtain it in the first place, meaning that it already knows the jump target and can jump to it with no additional delay.
That means there really is no indirection to speak of with the current implementation if the any
is already "hot", which it will be most of the time, especially if it's used as a return value.
On the other hand, if you use a table of function pointers somewhere in a read-only section (and let the any
instance point to that instead), you'll have to go to memory (or cache) every single time you want to move or access it. The size of an any
is still 16 bytes in this case but fetching values from memory is much, much slower than accessing a value in a register, especially if it's not in a cache. In a lot of cases, moving an any
is as simple as copying its 16 bytes from one location to another, followed by zeroing out the original instance. This is pretty much free on any modern CPU. However, if you go the pointer table route, you'll have to fetch from memory every time, wait for the reads to complete, and then do the indirect call. Now consider that you'll often have to do a sequence of calls on the any
(i.e. move, then destruct) and this will quickly add up. The problem is that you don't just get the address of the function you want to jump to for free every time you touch the any
, the CPU has to fetch it explicitly. Indirect jumps to a value read from memory are quite expensive since the CPU can only retire the jump operation once the entire memory operation has finished. That doesn't just include fetching a value (which is potentially quite fast because of caches) but also address generation, store forwarding buffer lookup, TLB lookup, access validation, and potentially even page table walks. So even if the jump address is computed quickly, the jump won't retire for quite a long while. In general, "indirect-jump-to-address-from-memory" operations are among the worst things that can happen to a CPU's pipeline.
TL;DR: As it is now, returning an any
doesn't stall the CPU's pipeline (the jump target is already available in a register so the jump can retire pretty much immediately). With a table-based solution, returning an any
will stall the pipeline twice: Once to fetch the address of the move function, then another time to fetch the destructor. This delays retirement of the jump quite a bit since it'll have to wait not only for the memory value but also for the TLB and access permission checks.
Code memory accesses, on the other hand, aren't affected by this since the code is kept in microcode form anyway (in the µOp cache). Fetching and executing a few conditional branches in that switch statement is therefore quite fast (and even more so when the branch predictor gets things right, which it almost always does).
QUESTION
We have some apps (or maybe we should call them a handful of scripts) that use Google APIs to facilitate some administrative tasks. Recently, after making another client_id in the same project, I started getting an error message similar to the one described in localhost redirect_uri does not work for Google Oauth2 (results in 400: invalid_request error). I.e.,
Error 400: invalid_request
You can't sign in to this app because it doesn't comply with Google's OAuth 2.0 policy for keeping apps secure.
You can let the app developer know that this app doesn't comply with one or more Google validation rules.
Request details:
The content in this section has been provided by the app developer. This content has not been reviewed or verified by Google.
If you’re the app developer, make sure that these request details comply with Google policies.
redirect_uri: urn:ietf:wg:oauth:2.0:oob
How do I get through this error? It is important to note that:
- The OAuth consent screen for this project is marked as "Internal". Therefore any mentions of Google review of the project, or publishing status are irrelevant
- I do have "Trust internal, domain-owned apps" enabled for the domain
- Another client id in the same project works and there are no obvious differences between the client IDs - they are both "Desktop" type which only gives me a Client ID and Client secret that are different
- This is a command line script, so I use the "copy/paste" verification method as documented here hence the
urn:ietf:wg:oauth:2.0:oob
redirect URI (copy/paste is the only friendly way to run this on a headless machine which has no browser). - I was able to reproduce the same problem in a dev domain. I have three client ids. The oldest one is from January 2021, another one from December 2021, and one I created today - March 2022. Of those, only the December 2021 works and lets me choose which account to authenticate with before it either accepts it or rejects it with "Error 403: org_internal" (this is expected). The other two give me an "Error 400: invalid_request" and do not even let me choose the "internal" account. Here are the URLs generated by my app (I use the ruby google client APIs) and the only difference between them is the client_id - January 2021, December 2021, March 2022.
Here is the part of the code around the authorization flow, and the URLs for the different client IDs are what was produced on the $stderr.puts url
line. It is pretty much the same thing as documented in the official example here (version as of this writing).
ANSWER
Answered 2022-Mar-02 at 07:56steps.oauth.v2.invalid_request 400 This error name is used for multiple different kinds of errors, typically for missing or incorrect parameters sent in the request. If is set to false, use fault variables (described below) to retrieve details about the error, such as the fault name and cause.
- GenerateAccessToken GenerateAuthorizationCode
- GenerateAccessTokenImplicitGrant
- RefreshAccessToken
QUESTION
This code sample fails to compile due to ambiguous overload resolution
...ANSWER
Answered 2022-Mar-30 at 06:35The second overload is more specialized than the first one during partial ordering of function templates.
According to [temp.deduct.partial]/5 the reference on T &t
of the first overload is ignored during template argument deduction performed for partial ordering. The following paragraphs distinguish based on reference/value category only if both parameters are reference types.
Then T
of the first overload can always deduce against a type A*
invented from the parameter of the second overload, but T*
of the second overload can't deduce against a type A
invented from the parameter of the first overload.
Therefore the second overload is more specialized and is chosen.
With T (&t)[4]
argument deduction in both directions will fail because deduction of T[4]
against A*
will fail and so will deduction of T*
against A[4]
. Array-to-pointer decay of the array type is specified for template argument deduction for a function call but not for template argument deduction for partial ordering. See also active CWG issue 402.
So neither template will be more specialized in this case and the partial ordering tiebreaker does not apply.
The array-to-pointer conversion is not relevant. It is not considered any worse than the identity conversion sequence (see [over.ics.rank]/3.2.1 excluding lvalue transformations which array-to-pointer conversions are).
QUESTION
I've added a new .Net 6.0 project to my solution in VS2022. Installed the EntityFramework 6.4.4. with install-package entityframework
and now try to add a ADO.Net Entity Framework Model to the project. I get an error:
The project's target framework does not contain Entity Framework runtime assemblies. Please review the target framework information on the project's property page.
I've tried adding several other EF packages (which should not be necessary according to the documentation here: https://docs.microsoft.com/en-us/ef/ef6/fundamentals/install). I thought the problem was with my installation but I created a .Net 6.0 console application containing the problem and sent it to a colleague and he got the same message.
Also found this topic here: Adding Entity Framework Model on Visual Studio 2022 but there's no answer there.
Steps to reproduce:
- Create a .Net 6.0 Console application.
- Install the EF6 package using
install-package entityframework
from the package manager console window. - Right-click solution and choose 'Add' => 'Add item'.
- In the left pane click 'Data'.
- Choose 'ADO.Net Entity Framework Model.
- Click 'Add'.
The error appears:
...ANSWER
Answered 2022-Jan-05 at 16:33The EF 6 tooling onl works on a .NET Framework project, you must add one to your slution and then copy or link to the generated code. In addition, EDMX files in .NET Core projects are not supported, but there are workarounds
QUESTION
Today i have got this email:
Last July, we announced Advertising policy changes to help bolster security and privacy. We added new restrictions on identifiers used by apps that target children. When users choose to delete their advertising ID in order to opt out of personalization advertising, developers will receive a string of zeros instead of the identifier if they attempt to access the identifier. This behavior will extend to phones, tablets, and Android TV starting April 1, 2022. We also announced that you need to declare an AD_ID permission when you update your app targeting API level to 31 (Android 12). Today, we are sharing that we will give developers more time to ease the transition. We will require this permission declaration when your apps are able to target Android 13 instead of starting with Android 12.
Action Items If you use an advertising ID, you must declare the AD_ID Permission when your app targets Android 13 or above. Apps that don’t declare the permission will get a string of zeros. Note: You’ll be able to target Android 13 later this year. If your app uses an SDK that has declared the Ad ID permission, it will acquire the permission declaration through manifest merge. If your app’s target audience includes children, you must not transmit Android Advertising ID (AAID) from children or users of unknown age.
My app is not using the Advertising ID. Should i declare the AD_ID
Permission in Manifest or not?
ANSWER
Answered 2022-Mar-14 at 20:51Google describe here how to solve
https://support.google.com/googleplay/android-developer/answer/6048248?hl=en
Add in manifest
QUESTION
This is about the correct diagnostics when short int
s get promoted during "usual arithmetic conversions". During operation /
a diagnostic could be reasonably emitted, but during /=
none should be emitted.
Behaviour for gcc-trunk and clang-trunk seems OK (neither emits diagnostic for first or second case below)... until...
we add the entirely unrelated -fsanitize=undefined
... after which, completely bizarrely:
gcc-trunk emits a diagnostic for both cases. It really shouldn't for the 2nd case, at least.
Is this a bug in gcc?
...ANSWER
Answered 2022-Feb-19 at 16:30For a built-in compound assignment operator $=
the expression A $= B
behaves identical to an expression A = A $ B
, except that A
is evaluated only once. All promotions and other usual arithmetic conversions and converting back to the original type still happen.
Therefore it shouldn't be expected that the warnings differ between short avg1 = sum / count;
and tmp /= count;
.
A conversion from int
to short
happens in each case. So a conversion warning would be appropriate in either case.
However, the documentation of GCC warning flags says specifically that conversions back from arithmetic on small types which are promoted is excluded from the -Wconversion
flag. GCC offers the -Warith-conversion
flag to include such cases nonetheless. With it all arithmetic in your examples generates a warning.
Also note that this exception to -Wconversion
has been introduced only with GCC 10. For some more context on it, the bug report from which it was introduced is here.
It seems that Clang has always been more lenient on these cases than GCC. See for example this issue and this issue.
For /
in GCC -fsanitize=undefined
seems to break the exception that -Wconversion
is supposed to have. It seems to me that this is related to the undefined behavior sanitizer adding a null-value check specifically for division. Maybe, after this transformation, the warning flag logic doesn't recognize it as direct arithmetic on the smaller type anymore.
If my understanding of the intended behavior of the warning flags is correct, I would say that this looks unintended and thus is a bug.
QUESTION
After updating Jenkins, it is sending a warning for ambiguous permission for project base permission. I can migrate the entry to user
or group
manually, was wondering if there's an automate or batch way to do so?
Warning Messages
Some permission assignments are ambiguous. It is recommended to update affected configurations to be unambiguous. See this overview page for a list of affected configurations.
...This table contains rows with ambiguous entries. This means that they apply to both users and groups of the specified name. If the current security realm does not distinguish between user names and group names unambiguously, and if users can either choose their own user name or create new groups, this configuration may allow them to obtain greater permissions. It is recommended that all ambiguous entries are replaced with ones that are either explicitly a user or group.
ANSWER
Answered 2021-Dec-29 at 23:41I have deleted old entries and added them again, warning disappeared.
QUESTION
I know Python //
rounds towards negative infinity and in C++ /
is truncating, rounding towards 0.
And here's what I know so far:
...ANSWER
Answered 2022-Jan-18 at 21:46Although I can't provide a formal definition of why/how the rounding modes were chosen as they were, the citation about compatibility with the %
operator, which you have included, does make sense when you consider that %
is not quite the same thing in C++ and Python.
In C++, it is the remainder operator, whereas, in Python, it is the modulus operator – and, when the two operands have different signs, these aren't necessarily the same thing. There are some fine explanations of the difference between these operators in the answers to: What's the difference between “mod” and “remainder”?
Now, considering this difference, the rounding (truncation) modes for integer division have to be as they are in the two languages, to ensure that the relationship you quoted, (m/n)*n + m%n == m
, remains valid.
Here are two short programs that demonstrate this in action (please forgive my somewhat naïve Python code – I'm a beginner in that language):
C++:
QUESTION
Let's say we have these 3 classes:
...ANSWER
Answered 2022-Jan-13 at 21:04It is ambiguous because of two reasons:
- both overloads are applicable, and;
- neither overload is more specific than the other
Notice that both the f(int, A)
overload and the f(float, B)
overload can be called with the parameters (i, b)
, since there is an implicit conversion from int
to float
, and an implicit conversion from B
to A
.
What happens when there are more than one applicable method? Java is supposed to choose the most specific method. This is described in §15.12.2.5 of the language spec. It turns out that it is not the case that one of these overloads are more specific than the other.
One applicable method m1 is more specific than another applicable method m2, for an invocation with argument expressions e1, ..., ek, if any of the following are true:
m2 is generic [...]
m2 is not generic, and m1 and m2 are applicable by strict or loose invocation, and where m1 has formal parameter types S1, ..., Sn and m2 has formal parameter types T1, ..., Tn, the type Si is more specific than Ti for argument ei for all i (1 ≤ i ≤ n, n = k).
m2 is not generic, and m1 and m2 are applicable by variable arity invocation [...]
Only the second point applies to the two overloads of f
. For one of the overloads to be more specific than the other, every parameter type of one overload has to be more specific than the corresponding parameter type in the other overload.
A type S is more specific than a type T for any expression if S <: T (§4.10).
Note that"<:" is the subtyping relationship. B
is clearly a subtype of A
. float
is actually a supertype (not subtype!) of int
. This can be derived from the direct subtyping relations listed in §4.10.1. Therefore, neither of the overloads is more specific than the other.
The language spec goes on to talk about maximally specific methods, which doesn't really apply to f
here. Finally, it says:
More ExamplesOtherwise, the method invocation is ambiguous, and a compile-time error occurs.
QUESTION
Setup:
- Windows 11 Home 21H2 22000.132
- AMD Ryzen 5900X
- WSL2
- Android studio lastest build (also tried with latest beta)
Problem: As soon as I install WSL2, the emulator stops working. It's giving the following error message:
...ANSWER
Answered 2021-Aug-19 at 12:54I found and tested in shorter toggle mechanism.
The configuration for Windows Feature:
Windows Subsystem for Linux
is installed.Windows Hypervisor Platform
is installed.Hyper-V
is installed.
If you need the Emulator, you only need to turn off Hypervisor + Restart. Run: bcdedit /set hypervisorlaunchtype off
If you need the Docker back, you can run the hypervisor hence disabling Emulator. Run: bcdedit /set hypervisorlaunchtype auto
You need to restart after setting Hypervisor
You cannot run both at the same time. Another forum worth checking in How about running docker?
in my older answer below.
I think I solved this issue, tested to run from CMD / Android Studio and ran perfectly as before installing WSL. There are several step we go:
Configuring Windows Feature:- Removed
Windows Subsystem for Linux
- Removed
Windows Hypervisor Platform
- Removed
Hyper-V
Here is my current setup:
Reverting AVD setupI know after removing there are some odds because the AVD still get the same error as before and expected to get into WSL. I stumbled and found something when ran:
C:\Users\[NAME]\AppData\Local\Android\Sdk\emulator\emulator-check.exe accel
That command will check the current accel. It explains that the Hypervisor need to be set off and give specific help:
run bcdedit /set hypervisorlaunchtype off
.
After running the bcdedit, I restarted and all is reverted. Now I can run emulator both from CMD and Android Studio perfectly.
How about running docker?Sad truth, yeah you cannot run both pararel. There are several workaround in this forum:
How can I run both Docker and Android Studio Emulator on Windows?
Several option ranging from changing emulator, add & remove docker when in need using above step, created nested vm, etc. My personal choice right now is using another Emulator for the time being and removed docker for the latter.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install choose
Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page