For a 2n-bit binary number, how many possible values are there such that half the bits are set to 1 (including leading zeros)??

So for n = 1 you’d have 01 and 10. (2 possibilities)

For n = 2 you’d have 0011, 0101, 0110, 1001, 1010, 1100. (6 possibilities)

How do I find the general formula for any positive integer value of n?

Random Number for Transaction Signatures In R Values , how It is created?

I wonder about the random Number used in signatures that result in R values ?
xcoridnate R = G(k)
how it is created ? does it have specific chars length ?
Is there a specific Random generator Used ? or restriction Arguments ?
I saw A Python Code online and found It is limited to max number of field points
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
but as it is in hex format i didn’t know what does it mean
so wat is the max number to be used as it will processed as an integer

php – Filter Gallery Images based on dropdown selection values

I currently making a “visual plan builder” with php-mysql, ajax and jquery
Using multiple layers (z-index) I generate a visual plan with the following dropdown list values:

  • Base Product – images from db
  • Design category – list it from db
  • Design – list it from db
  • Design colour – list it from db

This is working fine so far.
What I try to achive:

I have many real life photos and I would like to list them automatically in a separate section based on the selected dropdown values (visual plan).

I have 2 solutions on my mind:

Solution 1:

All the images stored in the db and list them from there.
I think is pretty straight forward with db SELECT
However would involve more time to add new photos to the list in a future.

Solution 2:

The idea is upload all the photos into a folder and use a specific name for each one
eg. designname_productcolor_designcolor.jpg

Advantage of this would be if any new photos needed to add, simply upload to a folder.

How could I achieve this? Also would this be a good solution performance wise?

Thanks!

bitcoind – Bitcoin RPC – Returning values in bytes, should I display in gibibytes or gigabytes?

I’m using Python and the requests library to get some data from Bitcoin using RPC. For example, from the getblockchaininfo call:

 "size_on_disk" : n,                     (numeric) the estimated size of the block and undo files on disk

Right now, this call returns 366080268200 bytes:

"size_on_disk": 366080268200,

Dividing by 1024*3 gives me 340.938817896 gibibytes (GiB).

Dividing by 1000*3 gives me 366.0802682 gigabytes (GB).

What is the “best” way to display this size to users? I’m leaning towards using gigabytes (GB), but isn’t this technically “wrong”? Every online dashboard I check currently shows the blockchain around 366GB, so they must be dividing by 1000*3, right?

Why are int values compared using ==, whereas String values are compared using .equals?

Why are int values compared using ==, whereas String values are compared using .equals?
What i have said about a String is that (b) String values are compared using .equals because its used to see if two objects are the same meaning they have identical values.

accessibility – I am looking for the mathematical equation that converts luminance values into Y Tristimulus values, or the other way around?

I am looking for the mathematical equation that converts luminance values into Y Tristimulus values, or the other way around?

Also, Tristimulus values are used to match paint or inks under a controlled light source. This CIE system is very accurate in matching the human visual experience. Are the luminance values just as accurate? If not, why are they used? If so, where can I read more information on the comparison of the two systems? Are they related to each other in their mathematical equations?

query performance – MySQL compare multiple values in WHERE clause, find subset

I have a table segments with column comp_id, segment_id.

comp_id: 1
segment_id: 23,11,223,3331;
comp_id: 2
segment_id: 231,11,223,3331;

I have another table: comps with segment_id as well.

comp_id: 1
segment_id: 11, 3331
comp_id: 3
segment_id: 7, 63

I need to filter out rows from comp where all segment_id values are inside segment_id from segments table.

This is a simplified version of what I need to do. simple JOIN statements wouldn’t help, I need to do this inside WHERE clause.

i.e.

WHERE
comp.segment_id = ALL (SELECT segment_id FROM segments)

this won’t work because this compares single “comp.segment_id”, I need all “comp.segment_id”s compared.

Is there any function or some method of doing this? And btw performance is crusial.
Is there any intersect methods to do so?
To simplify I need to find subsets of data.
Actual query is very big and I won’t post it here, don’t give me JOIN examples, please.

Creating a regex to get multiple values and print

I'm looking for any help with the code below. Basically the ip:port string keeps changing and may contain more than one true value in str and i wonder if is possible to use a regex using the search function to get the all ip:port and print in demo.


<p id="demo"></p>

<script>
var str = "Please 127.0.0.1:80 locate where 127.0.0.2:80 occurs!";
var pos = str.search("b(?:(?:25(0-5)|2(0-4)(0-9)|(01)?(0-9)(0-9)?).){3}(?:25(0-5)|2(0-4)(0-9)|(01)?(0-9)(0-9)?):d{1,5}b");...
Code (markup):

Creating a regex to get multiple values and print

language design – Why do “checked exceptions”, i.e., “value-or-error return values”, work well in Rust and Go but not in Java?

From a scientific point of view, checked exceptions can be seen as alternative return values, e.g.

Exactly. They can be seen that way, and they should be but they aren’t.

Using an Error type like is common in Rust, Elm, Haskell, and in some sub-communities in Scala or a special error value as in Go is just an alternative return value indicated in the type system. A checked exception is like an alternative return value, but it doesn’t use the normal way of returning values, it is a completely separate, very different way of “returning values”. It also sits outside of the type system, and bolts on a completely separate “checked exception” system onto the type system.

But most importantly, it is not just an alternative return value, it is also an alternative control flow.

Another problem with the specific way checked exceptions are implemented in Java, is that they are anti-modular. That is, however, not a fundamental problem of checked exceptions, unlike the ones I mentioned above. There is an idea of Modular Anchored Exceptions, for example, where you can specify something like

int foo() throws like bar { return bar(); }

And you don’t have to know (and leak!) which precise exceptions bar can throw. You can even do something like throws like bar except ArrayOutOfBoundsException when you are handling some errors yourself.

7 – Unlimited values for 2 combined fields

I want to add 3 fields to my articles:

  • repeatable (boolean)
    • unlimited values for repeat_date and repeat_comment

I created the fields and with fields dependency I made the it possible that repeat_date and repeat_comment only appear if repeatable is checked. I can also create an unlimited number of values for repeat_date and repeat_comment.

But these 2 fields are independet of another. I could create 2 values of repeat_date entries and 4 values of repeat_comment. Also those fields appear separate when editing articles.

How can I combine those 2 fields and have unlimited values for this combined fields?