text:
Q: php floor precision incorrect I want chop my float number, I found php doc. First I want my value always division 10000, so my function will do it.
function floorDec($value = 0, $decimals = 2) {
        $c = pow(10, $decimals);

        $a1 = $value / 10000;

        printf("a1: %lf, type: %s\n", $a1, gettype($a1));

        $a2 = $a1 * $c;

        printf("a2: %lf, type: %s\n", $a2, gettype($a2));

        $a3 = floor($a2);

        printf("a3: %lf, type: %s\n", $a3, gettype($a3));

        $a4 = $a3 / $c;

        printf("a4: %lf, type: %s\n", $a4, gettype($a4));

        return $a4;
}

$a =  96684700;

var_dump(floorDec($a, 2));

Result
a1: 9668.470000, type: double
a2: 966847.000000, type: double
a3: 966846.000000, type: double
a4: 9668.460000, type: double
float(9668.46)

The variable $a3 is not I want. I have no idea why. Thanks your help.

A: PHP is behaving correctly. This is just a side effect of the way floating point numbers behave.
They are sometimes just a little bit inaccurate:
printf("%.99f", $a2);

prints

966846.99999999988358467817306518554687500000000000000000000

so of course if you floor() that it'll be 966846.
Perhaps (int)round($a2); does what you want:

966847.00000000000000000000000000000000000000000000000000000

If you need absolute precision up to a certain decimal point, have a look at these functions: https://secure.php.net/manual/en/ref.bc.php


text:
Q: How can I customize vehicles I can't customize? I've recently acquired a Crusader tank for my garage:

It is very oppressive and white, and I would like to give it a paint job. However, like many authority vehicles it is apparently "not customizable". I'd leave it at that, if I were not previously able to customize a different kind of "not customizable" vehicle:

I can assure you that the Challenger tank does not usually come in purple, but I can't for the life of me remember just how I managed to get it looking like that. Any advice would be most welcome.

A: If you're playing on the PC, you can install the Extended Customization mod which will allow you to customize all vehicles (including planes and helicopters) - even those not allowed to be customized by the vanilla game. Note that this mod is already part of the Things To Do In Steelport mod compilation (which I recommend you install, instead of the standalone version). That mod compilation also contains other game fixes and improvements.
Screenshots of vehicles customized with Extended Customization:

A: There is a glitch you can abuse that will allow you to customise vehicles that are tagged as non-customisable.
First, leave the vehicle you wish to customise in a garage. Then, take any customisable vehicle to a Rim Jobs. Once you get into the customisation menu, press Garage and highlight the vehicle you want to customise. Without actually selecting the vehicle, exit the menu, and answer in the affirmative when it asks you for confirmation. You will now be in the customisation menu for the vehicle you highlighted.
Edit: According to this video, this glitch will not work with all vehicles driven into the Rim Jobs; only some will work for each, with the exception of the Gat Mobile, which will allow you to customise any vehicle.

A: Get a gatmobile and go to a rim jobs and go to garage in the menu and click on a non customizable car press back and press up and then press ok.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Android - Layout with images I've been working on this for few days but I couldn't get the layout I need.
I would like to have a layout similar to the image below.
Can anyone guide me with this ? What kind of layout and view should I use ?

Thanks :)

A: Ive added some code generated by drawing what you want in the layout editor in eclipse.
Looks like this

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.81" >

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight="1.00"
            android:src="@drawable/ic_launcher" />

        <LinearLayout
            android:id="@+id/linearLayout3"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:orientation="vertical" >

            <ImageView
                android:id="@+id/ImageView02"
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:layout_weight="1.00"
                android:src="@drawable/ic_launcher" />

            <ImageView
                android:id="@+id/ImageView01"
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:layout_weight="1.00"
                android:src="@drawable/ic_launcher" />

            <ImageView
                android:id="@+id/imageView3"
                android:layout_width="fill_parent"
                android:layout_height="0dp"
                android:layout_weight="1.00"
                android:src="@drawable/ic_launcher" />

        </LinearLayout>

    </LinearLayout>

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher" />

</LinearLayout>

</LinearLayout>

A: You could use a LinearLayout. In the first row you can add another two LinearLayouts with horizontal orientation. So: LinearLayout container (orientation horizontal). In the first row add two LinearLayouts with vertical orientation. First coloumn image1, second column LinearLayout with horizontal orientation (every row image 2,3,4). Return to container, on the second row add image 5 :)

A: Use TableLayout for your views.

A: i am giving only prototype of layout may be it will help you
look at that
<linearLayout main android;orientation="vertical">
<linearlayout "sub1" android;orientation="horizontal">
<linearlayout android:layout_wight="1" "take first lesthand side image in it" >
<linearlayout android:layout_wight="1" "sub2" android:orientation="vertical" >
"take three linearlayout and set three images in that take a weight as 1 for all three linearlayout "
<close sub2 linear layout>
<close sub1 linear layout>

take another linear layout and set last bottom image in it

A: Try this:
<!-- Root layout -->
<LinearLayout android:id="@+id/container"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical">
    <!-- Layout for img1,2,3,4 -->
    <LinearLayout android:id="@+id/img1234
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:orientation="horizontal">
        <!-- ImageView for img1 -->
        <LinearLayout android:id="@+id/img234"
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"
                      android:orientation="vertical">
            <!-- ImageView for img2 -->
            <!-- ImageView for img3 -->
            <!-- ImageView for img4 -->
        </LinearLayout>

    </LinearLayout>
    <!-- Here should be ImageView for img5. Either use weight (to ensure proportions)
         or set an absolute height in dp -->
</LinearLayout>

Excuse me for possible typos.


text:
Q: hg transplant fails - how do I 'fix up the merge' as it suggests? My branch2274 was branched from default. Rev. 415 was the first commit and it shares an ancestor with the rev. 412 on the default branch.
Branch2274 is a bug fix which needs merging into default soon BUT I did a very silly thing - I merged in changes from a feature branch (at rev. 418)
In simple terms, I need to undo whatever changes were brought in by rev. 418. There seems to be a lot of ways to attempt this but I'm struggling to get any of them to work:
Mercurial queues attempt:
I've tried importing revs 415, 416, 417, (skipping 418), 421, 428 into a patch queue so I can apply it to rev 425.
Problem: tortoisehg will only allow me to import revs 428, 421 but importing 417 is greyed out but importing 418 just gives me the error "abort: cannot import merge revision 418"
Transplant attempt:
patching file Portal/Instructor/Login.aspx.vb
Hunk #1 FAILED at 18
1 out of 1 hunks FAILED -- saving rejects to file Portal/Instructor/Login.aspx.vb.rej
applying 66b6b089ee01
abort: Fix up the merge and run hg transplant --continue
patch failed to apply

[command interrupted]

Login.aspx.vb has been changed on default and I understand why the merge has failed.
How do I 'fix up' the merge?
Alternatively, is there a simpler way for me to take rev. 418 and tell mercurial to undo the changes it brought in with a new commit on case2274?

A: In the interests of not leaving a question unanswered (!), I managed to resolve this and the ultimate answer is that there's no simple way to resolve it automatically. Transplant deals in patches, differences between two files but doesn't take into account the common ancestry of the two files so struggles to know what to do when a file has been changed by two people in the same place.
The solution is to load the file in your text editor and load the .rej file which lists the failed parts of the patch. I just had to put my additions in a sensible place in the code file.
Running:
hg transplant --continue

..allowed me to apply the other patches.
If anyone cares to spend some time expanding this answer with a little insight or a few relevant links, then the answer is theirs.


text:
Q: MongoDB: Get documents depending on a search term for array field and string field I need to perform a search on my mongoDB collection based on two fields: title, which is a string, and tags, which is an array.
Assume this is a sample data for the collection:
{
  title: 'A tornado article',
  tags: [
    'nature',
    'storm'
  ]
},
{
  title: 'Just another article',
  tags: [
    'hurricane',
    'type I'
  ]
},
{
  title: 'Different article',
  tags: [
    'tornado',
    'type II'
  ]
}

and my search string is const term = 'tornado type I', then I should get all documents as

*

*the first one has tornado in the title

*the second one has an tag type I

*the third one has an tag tornado
I tried to start with this to perform the search:
Collection.find(
  {
    $or: [
      { 'meta.title': new RegExp(term, 'i') },
      { 'meta.tags': term }
    ]
  }
)

So with this I would get the first document if the search term would be just tornado. With my sample term string I don't get any result.

A: If you wish to return an object that contains any of the tags you need to the the $in operator, it selects the documents where the value of a field equals any value in the specified array.
However to do so you need to pass it an array of your terms, to do so I've splitted your terms on
" "  and passed that variable along to the $in like so
var term = 'tornado type I nature';
var splitted = term.split(' ');

    Collection.find({
        $or: [{
                'title': new RegExp(term, 'i')
            }, {
                "tags": {
                    $in: splitted
                }
            }
        ]
    })

Or if you also use to wish the regex to search through the tags you could join the array with | to build a regex statement after which you can pass it along like this.
var term = 'tornado type I nature';
var splitted = term.split(' ');
var splittedRegex = new RegExp(splitted.join('|'), 'i');

Colleciton.find({
    $or: [{
            'title': new RegExp(term, 'i')
        }, {
            "tags": {
                $in: [splittedRegex]
            }
        }
    ]
})


text:
Q: ctx.render doesn't redirect the page I'm pretty sure It's because ctx.render function is just for rendering page, but I have no idea what to do to do what I'm tryna do.
Basically, I'm trying to redirect user to user's mypage after login, with jwt token in the header so I used axios to send get request to server, and the server router function renders dynamic pug file with given data.  I want to put jwt data into pug file but when I send get request, the page only just refreshes itself and doesn't actually redirect to mypage.
Here's code
client
try {
    let res = await axios(loginOpt)
    await store.set('jwtToken', res.data.token)
    let mpOpt = {headers: {"Authorization": 'Bearer ' + store.get('jwtToken')}}
    axios.get(`/u/${payload.email}`, mpOpt)
} catch (e) {
    console.error("failed to send login request", e)
}

router
router.get('/:userName', async (ctx, next) => {
    console.log("jwt TOKEN IS", ctx.header.authorization)

    let renderData = {
        userName: userName,
        profilePic: "../images/1.mesege_1.png",
        itemCount: itemCount.data,
        contentCount: itemCount.data,
        joinedDate: m(dateString).format('LL'),
        lastVisited: m(dateString).format('LL') // gotta add
    }

    await ctx.render('form/form4', renderData)
})


text:
Q: Understanding mongod log entries Can anyone explain the numbers in the % column, in this mongod log snippet ?
It is building a new index but I'm not sure I understand why the numbers look like that
Tue Nov 20 11:38:08 [initandlisten] connection accepted from 127.0.0.1:49299 #8 (2 connections now open)
Tue Nov 20 11:38:08 [conn8] build index xx.yyyy { source: 1 }
Tue Nov 20 11:38:19 [conn8]         2921300/243339  1200%
Tue Nov 20 11:38:29 [conn8]         4109600/243339  1688%
Tue Nov 20 11:38:39 [conn8]         4400100/243339  1808%
Tue Nov 20 11:38:49 [conn8]         4676600/243339  1921%
Tue Nov 20 11:38:59 [conn8]         4939700/243339  2029%
Tue Nov 20 11:39:09 [conn8]         5217800/243339  2144%
Tue Nov 20 11:39:19 [conn8]         5439300/243339  2235%
Tue Nov 20 11:39:29 [conn8]         5659700/243339  2325%

Thanks

A: As you can see from Eliot's comment here:
https://jira.mongodb.org/browse/SERVER-6333
This can happen if dupes are being deleted and possibly other reasons.  Basically it's an odd, but valid thing to see in certain circumstances and the index build should complete successfully.


text:
Q: How AS3 class files.as work together with FLA file? I have two questions: Can i write app using just *.as files, and then compile them somehow in SWF? (i am making myself a webpage now)

Secondly, please look at the code, my problem is the same - I can't render text field onto stage, to be visible.
Flash say's 'undefined method addChild.' and 'Access of undefined property tekstuKaste through a reference with static type Class.'
This is a constructor type class inic which kinda serves for initialization, cos all i do is, I make an instance OF THIS class in FLA file by ActionScript, and expect, all application to work.
package {
import pacinas.visuals.*;

    import pacinas.visuals.AE_kanva;

    public class inic {

        public function inic() {
            trace("===========");
            trace("inicializēt un izsaukt visu no Kanvas klases");
            trace("===========");
            trace(" ");
            var kanvas:AE_kanva = new AE_kanva();
            trace(" ");
            kanvas.varis();
            trace(" ");
            trace("===========");
            trace("inicializēt un izsaukt visu no Lauki klases");
            trace("===========");
            trace(" ");
            var laukiTxt:BE_tekstaLaukiPrimitive = new BE_tekstaLaukiPrimitive();
            trace("");
            laukiTxt.simpleText();
                addChild(BE_tekstaLaukiPrimitive.tekstuKaste);
            }

    }

}

There is another EXTERNAL CLASS By whom i hoped to place a rectangles - that does not work too. Example:
package pacinas.visuals
{
    import flash.display.Sprite;
    public class AE_kanva extends Sprite
    {
        public function AE_kanva()
        {
        var kvad:Shape = new Shape();
        kvad.graphics.beginFill(0xFF0000);
        kvad.graphics.drawRect(0, 0, 100,100);
        kvad.graphics.endFill();
        addChild(kvad);
        trace("konstruktors - zīmē kanvu");
        }
        public function varis()
        {
            trace("te glabaas variaabljus");
            var ff:int = 4;
            var dd:int = 8;
        }
    }

}

And here is class i hoped will make text box for me (to fill it with XML later)
package pacinas.visuals

{
import flash.text.*;
import flash.display.Sprite;

    public class BE_tekstaLaukiPrimitive extends Sprite
    {
        public var tekstuKaste:TextField = new TextField();
        private var kontinents:String = new String ("XML SATURU CMON! a123");

        public function BE_tekstaLaukiPrimitive():void
        {
            trace("teksta rāmis = konstruktora klase");
            addChild(tekstuKaste); <--CAN'T GET THIS TO WORK!!!
            tekstuKaste.text = kontinents;
        }
        public function simpleText()
        {
            trace("nekonstruktora f-cija no Teksta lauki");
        }
}}

p.s. I do not use document Class. Ok I will if it's needed. But how?

A:
Can I write app using just *.as files, and then compile them somehow into a SWF?

Yes - using the Flex SDK you can write pure ActionScript and compile it down into a working SWF. FlashDevelop is a good IDE that takes advantage of this.
You will however need to understand how the document class works.

Flash says undefined method addChild. and Access of undefined property tekstuKaste through a reference with static type Class.

In your code, this line is causing your issue:
addChild(BE_tekstaLaukiPrimitive.tekstuKaste);

The first error undefined method addChild is because your class inic does not extend a class that implements the method addChild(). DisplayObjectContainer defines this method, so you'll want to extend that as a minimum, like this:
public class inic extends DisplayObjectContainer

The second error is because you're attempting to access a property of the class BE_tekstaLaukiPrimitive as if it were static. I suspect what you actually wanted to do was this:
addChild(laukiTxt); // laukiTxt is the instance you created.


text:
Q: is there any way to get to know about database updates without querying /less queries? I ran into a weird problem looking for the best solution that i can get here. I'm developing a rails application which displays data from a common database that is being used by another application(nodejs). All CRUD operations happens at the other platform. In the rails app, we just query and display the data.
In rails app, I need to auto update views without refreshing. for example
def index
    @states = State.page(params[:state_page])
    @level_one_companies = Company.includes(:state)
                                  .where(level: 1)
                                  .order('created_at DESC').limit(20)

    @level_two_companies = Company.includes(:state)
                                  .where(level: 2)
                                  .order('created_at DESC').limit(20)
end

On the index page i will have tables for each of these and I need to refresh tables when new data is added to the state, (or) Level 1 (or) Level 2 companies.
I know i can go with two ways to auto update views i.e

*

*Action Cable.

*Data pooling at a time interval using Jquery.

Usually while using Action Cable we will broadcast data from server after a record is created in the db(after .save in create action (or) after_save callback from model). However, I'm not creating any records through rails app.
My first question is, is there any way use action cable in this case?.
So i went with the second option and it's working fine. But it making too many db calls after every X seconds.
is there any way to reduce queries to update views?
What is the best way i can go with here? Any help highly appreciated. Thanks.

A: if your tags are set correctly, you are using postgres as a database.
postgres offers a publish-subscribe machanism that you could use in combination with action-cable in order to listen to changes in your database.
in this gist, you can find an example for postgres-pubsub with server-sent-events. it should be simple to translate this into action-cable compatible code.

A: You can create a trigger on a table (creates/updates/deletes) that fires a notification on a "channel", and you can listen to said channel for events. I use socketcluster, listen from workers and broadcast to consumers (browsers and mobile apps).
First you create the trigger:
CREATE FUNCTION deletes_notify_trigger() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
DECLARE
BEGIN
  PERFORM pg_notify('deletes_channel',  ('DELETED' || ';;' || OLD.id )::text );
  RETURN new;
END;
$$;

and
CREATE TRIGGER deletes_trigger AFTER DELETE ON events FOR EACH ROW EXECUTE PROCEDURE deletes_notify_trigger();

You can add any stuff you want in the data packets being broadcast, in my case I just need the ID of the record. For creates and updates you could send the full row or only some selected columns. You can also send it as JSON in PG 9.2 (I think) and higher. I use 9.1 so I concat with ;; separators.
Make sure your code takes at most 10% of the time between your queries otherwise if you do complex joins or updates or other operations you will notice significant drops in performance. You want this to be as simple and fast as possible, keep it down to basic operations and do any heavy-lifting on the application layer.
Then, the watcher and broadcasting to consumers (in my case node, socketcluster and the pg gem, in your case you can use JS, Python, Ruby, whatever you like)
var global_deletes = socket.subscribe('deletes_channel');
pg.connect(connectionString, function(err, client) {
      client.on('notification', function(dbmsg) {
        console.log(dbmsg.payload);
        var payload = dbmsg.payload.split(";;"); // you can use JSON instead

        if (payload[0] == "DELETED") { // when a DELETE is received...
            global_deletes.publish(dbmsg.payload);
            var tchannel = socket.subscribe('events-'+ payload[1]); // join the channel we want to broadcast
            setTimeout( () => tchannel.publish(dbmsg.payload), 50); // send the update to all consumers
            setTimeout( () => tchannel.unsubscribe(), 100);
        }
       );
    var query = client.query("LISTEN deletes_channel"); // turn on notifications from the server
});


text:
Q: How to get value from the given object response from Twinfield in Laravel/Lumen? This is the response when I call the login method from twinfield API. It given the session id and cluster namespace, but the problem is how to get the value from it.
$customerApiConnector = new \PhpTwinfield\ApiConnectors\CustomerApiConnector($login);
print_r($customerApiConnector);die;

Output:
  PhpTwinfield\ApiConnectors\CustomerApiConnector Object
    (
        [service:protected] => PhpTwinfield\Services\ProcessXmlService Object
            (
                [trace] => 1
                [compression] => 32
                [_stream_context] => Resource id #153
                [_soap_version] => 1
                [sdl] => Resource id #154
                [__default_headers] => Array
                    (
                        [0] => SoapHeader Object
                            (
                                [namespace] => http://www.twinfield.com/
                                [name] => Header
                                [data] => Array
                                    (
                                        [SessionID] => f7b4c213-1a01-4c7c-87cb-7de80b1583fe
                                    )

                                [mustUnderstand] =>
                            )

                    )

            )

    )

This is the other object.
Array
(
    [1] => PhpTwinfield\CustomerAddress Object
        (
            [ID:PhpTwinfield\CustomerAddress:private] => 1
            [type:PhpTwinfield\CustomerAddress:private] => invoice
            [default:PhpTwinfield\CustomerAddress:private] => true
            [name:PhpTwinfield\CustomerAddress:private] => Anand
            [contact:PhpTwinfield\CustomerAddress:private] =>
            [country:PhpTwinfield\CustomerAddress:private] => IN
            [city:PhpTwinfield\CustomerAddress:private] => Indore
            [postcode:PhpTwinfield\CustomerAddress:private] => 452001
            [telephone:PhpTwinfield\CustomerAddress:private] =>
            [fax:PhpTwinfield\CustomerAddress:private] =>
            [email:PhpTwinfield\CustomerAddress:private] => anand@comfisoft.com
            [field1:PhpTwinfield\CustomerAddress:private] =>
            [field2:PhpTwinfield\CustomerAddress:private] => lig
            [field4:PhpTwinfield\CustomerAddress:private] =>
            [field5:PhpTwinfield\CustomerAddress:private] =>
            [field6:PhpTwinfield\CustomerAddress:private] =>
        )

)

A: Try this it will work ;)
function accessProtectedProperty($obj, $prop)
{
    $reflection = new \ReflectionClass($obj);
    $property = $reflection->getProperty($prop);
    $property->setAccessible(true);
    return json_decode($property->getValue($obj));
}


text:
Q: How can I convert an unnamed function to a named one? I made the function below. Basically, if a player types /port and the name of another player the function returns true, I believe.
    mp.players.forEach(_player => {
        if(_player.name === name)
            return true;
    });

I want to name the function above so I can do something like:
if (functionName) [code]

So, how can I name  the function above? Or is there any other way to check if it's true. I'm trying to list it on the try...catch statement below:
try {
        if (player.adminLevel < 8)  throw "Error 1";
        if (!targetPlayer) throw "Error 2";
        if (player.adminLevel <= targetAdminLevel) throw "Error 3";
        //AND THE NEW ONE HERE
        if (functionName) throw "Error 4";
    }

A: Just write it as a normal function, then pass the function name instead of the lambda expression.
function myFunction(player) {
    if(_player.name === name)
        return true;
}

mp.players.forEach(myFunction);

Now you can use myFunction elsewhere by its name... no "conversion" necessary.

A: You have not created any function. forEach is a named function for Array prototype which you are invoking for your array. You can either directly write the forEach logic in your try block, or declare a named function and use it like below:
    function functionName(players, name){
            return players.some(_player => _player.name === name);
        };

    try {
           if (player.adminLevel < 8)  throw "Error 1";
           if (!targetPlayer) throw "Error 2";
           if (player.adminLevel <= targetAdminLevel) throw "Error 3";
           //AND THE NEW ONE HERE
           if (functionName(mp.players, player.name)) throw "Error 4";
     }


text:
Q: how to go to the certain column or part of the line using "sed" command? Permissions   links  Owner  Group  Size   Date        Time    Directory or file
-rwxr--r--     1     User1  root    26    2012-04-12  19:51    MyFile.txt
drwxrwxr-x     3     User2  csstf  4096   2012-03-15  00:12     MyDir

Note that each space is a tab space.
I need to go to the size column. How can I do that using sed command. Because I cannot continue my work due to that. I don't know how to split and take certain part of the line using sed command.

A: awk suites it better:
awk -F'\t' '{print $5}' file

Using sed:
sed -r 's/^([^\t]+\t){4}([^\t]+).*$/\2/' file
Size
26
4096


text:
Q: I short circuited my iPhone 5 through audio jack Long story short, I short circuited my second most expensive asset through a usb-male-audio-male. I'm devastated. I'm not rich. I was still giddy about saving a dozen dollars during black friday sales.
I understand basic elements of circuits. So I want to fix it myself.
I suspect that the battery is down. And I suspect some excessive current protection mechanism was triggered.
The battery can be replaced easily.
So my question is that what might have been broken, and how to fix them.
If you can kindly share your knowledge, I will be grateful.

A: a reset solved the problem

Try a reset, press the top and and home button at the same time

I found this solution by sarri at fixit


text:
Q: Pass a parameter from parent to child ASP GridView (C# codebehind) I am nesting three GridViews where each is dependent on the one before. I have the asp structure done and each is pulling from their respective data sources (asp:SqlDataSource in the aspx page). However, I can't figure out how to build the relationship so each pulls only the data related to the row that grid is nested on.
Examples:
Similar but I don't need the drill downs
Also very like what I'm looking for but this uses EntityDataSource
These examples have helped me to understand I will need the RowDataBound event to make this work. Great! But I can't figure out how to get the RowDataBound event to give me the unique parameter per row that must be run through my datasource that generates the data in the next GridView.
Codebehind:
    protected void CategoryGrid_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
    //need to set my @catlinkulink parameter here
}

protected void CategoryGrid_SelectedIndexChanged(object sender, EventArgs e)
{

}

protected void CategoryOnRowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        GridView CategoryGridFC = DomainGrid.Rows[e.Row.RowIndex].FindControl("CategoryGrid") as GridView;
        string catlinkulink = CategoryGridFC.DataKeys[e.Row.RowIndex].Values["catlinkulink"].ToString();

        TargetLinks.SelectParameters[0].DefaultValue = catlinkulink;
    }
}

Here is the data source from the aspx. This is for the grid that depends on the parameter pulled from each row of the category grid previous.
    <asp:SqlDataSource ID="TargetLinks" runat="server"
ConnectionString="<%$ ConnectionStrings:MyDB %>"
SelectCommand="SELECT t.ULink AS targetlinkulink, TargetDE
               FROM targetLink t
                  INNER JOIN IntTargets it ON t.TargetULink = it.ULink
                  INNER JOIN IntCategoryLink cl ON t.CatLinkULink = cl.ULink
                  WHERE t.CatLinkULink = @catlinkulink"
>
<SelectParameters>
   <asp:Parameter Name="catlinkulink" DefaultValue="0" Type="Empty" Size="0" ConvertEmptyStringToNull="False" DbType="Object" />
</SelectParameters>

</asp:SqlDataSource>

I apologize for how long this is, but I want to make sure I provide enough info to give a clear idea of what I'm trying to do. Thanks for any input you may have. I always learn a lot here--even if it's a different or better way to accomplish something.
I added the TargetLinks bit according to a suggestion below. I've also changed the FindControl for the CategoryGrid to look in the rows of the DomainGrid (its parent), but that's not working either.

Error: Index was out of range. Must be non-negative and less than the size of the collection.
  Parameter name: index

Here is the code for the nested GridViews.
    <asp:GridView ID="DomainGrid" runat="server"
    onselectedindexchanged="DomainGrid_SelectedIndexChanged"
    DataSourceID="DomainLinks" AutoGenerateColumns="False" DataKeyNames="domainlinkulink">
    <Columns>

        <asp:BoundField DataField="DomainDE" ShowHeader="False"
                SortExpression="DomainDE" HeaderStyle-Width="125">
        </asp:BoundField>

        <asp:TemplateField ShowHeader="False">
            <ItemTemplate>
                <asp:DropDownList ID="IntervCatDrop" runat="server" DataSourceID="IntervCatDD"
                 DataValueField="ulink" DataTextField="IntCategories">
                </asp:DropDownList> <asp:Button ID="AddIntCat" runat="server" Text="+" />
            </ItemTemplate>
        </asp:TemplateField>

        <asp:TemplateField ShowHeader="False">
            <ItemTemplate>
                <asp:GridView ID="CategoryGrid" runat="server" DataKeyNames="catlinkulink"
                DataSourceID="IntCategoryLinks" AutoGenerateColumns="false"
                onselectedindexchanged="CategoryGrid_SelectedIndexChanged"
                onrowdatabound="CategoryOnRowDataBound">
                <Columns>

                    <asp:BoundField DataField="IntCategories" ShowHeader="False"
                        SortExpression="Categories" HeaderStyle-Width="125"></asp:BoundField>

                    <asp:TemplateField ShowHeader="False">
                         <ItemTemplate>
                              <asp:DropDownList ID="TargetDrop" runat="server" DataSourceID="TargetsDD"
                               DataValueField="ulink" DataTextField="TargetDE">
                               </asp:DropDownList> <asp:Button ID="AddTarget" runat="server" Text="+" />
                         </ItemTemplate>
                   </asp:TemplateField>

                  <asp:TemplateField ShowHeader="false">
                    <ItemTemplate>
                            <asp:GridView ID="TargetGrid" runat="server" DataSourceID="TargetLinks" AutoGenerateColumns="False"
                            DataKeyNames="targetlinkulink" onselectedindexchanged="TargetGrid_SelectedIndexChanged"
                            >
                                <Columns>
                                    <asp:BoundField DataField="TargetDE" ShowHeader="false" SortExpression="TargetDE" />
                                </Columns>
                            </asp:GridView>
                        </ItemTemplate>
                  </asp:TemplateField>

                </Columns>
                </asp:GridView>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>

</asp:GridView>

A: First, I would suggest to change Parameter, which looks wrong. Assuming CatLinkULink is a string field, I would change SelectParameters to this:
<SelectParameters>
    <asp:Parameter Name="catlinkulink" Type="String" DefaultValue=""  />
</SelectParameters>

And move the SqlDataSource inside the CategoryGrid, add a hidden field. Here's how the markup of CategoryGrid may look:
<asp:gridview id="CategoryGrid" runat="server" datakeynames="catlinkulink"
    datasourceid="IntCategoryLinks" autogeneratecolumns="false"
    onselectedindexchanged="CategoryGrid_SelectedIndexChanged"
    onrowdatabound="CategoryOnRowDataBound">
    <Columns>
        <asp:BoundField DataField="IntCategories" ShowHeader="False"
            SortExpression="Categories" HeaderStyle-Width="125"></asp:BoundField>
        <asp:TemplateField ShowHeader="False">
            <ItemTemplate>
                <asp:DropDownList ID="TargetDrop" runat="server" DataSourceID="TargetsDD"
                    DataValueField="ulink" DataTextField="TargetDE">
                </asp:DropDownList> <asp:Button ID="AddTarget" runat="server" Text="+" />
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField ShowHeader="false">
            <ItemTemplate>
                <asp:GridView ID="TargetGrid" runat="server" DataSourceID="TargetLinks" AutoGenerateColumns="False"
                    DataKeyNames="targetlinkulink" OnSelectedIndexChanged="TargetGrid_SelectedIndexChanged">
                    <Columns>
                        <asp:BoundField DataField="TargetDE" ShowHeader="false" SortExpression="TargetDE" />
                    </Columns>
                </asp:GridView>
                <asp:HiddenField ID="hdnCatlinkulink" runat="server" Value='<%#Eval("catlinkulink") %>' />
                <asp:SqlDataSource ID="TargetLinks" runat="server"
                ConnectionString="<%$ ConnectionStrings:MyDB %>"
                SelectCommand="SELECT t.ULink AS targetlinkulink, TargetDE
                                FROM targetLink t
                                    INNER JOIN IntTargets it ON t.TargetULink = it.ULink
                                    INNER JOIN IntCategoryLink cl ON t.CatLinkULink = cl.ULink
                                    WHERE t.CatLinkULink = @catlinkulink">
                    <SelectParameters>
                        <asp:Parameter Name="catlinkulink" Type="String" DefaultValue=""  />
                    </SelectParameters>
                </asp:SqlDataSource>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:gridview>

And in the code I would set the parameter:
protected void CategoryOnRowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        GridView TargetGrid = e.Row.FindControl("TargetGrid") as GridView;
        HiddenField hdnCatlinkulink = e.Row.FindControl("hdnCatlinkulink") as HiddenField;
        SqlDataSource TargetLinks = e.Row.FindControl("TargetLinks") as SqlDataSource;

        if (TargetGrid != null && hdnCatlinkulink != null && TargetLinks != null)
        {
            string catlinkulink = hdnCatlinkulink.Value;
            TargetLinks.SelectParameters[0].DefaultValue = catlinkulink;
        }
    }
}

Disclaimer: I did not test the code above, it may needs to tweak.

A: you can set a textbox in a hiden div to get the value when grid selected event fired.
and then you can set parameter to this textbox.text in sqldatasource.
This is what I done for this situation


text:
Q: Python Dataframe Merge for matching I wish to make matching pairs from two dataframes such that no two pairs aree same and even the individual values also don't repeat in any other  pairs. The key to use in matching is 'cntr-size' and 'carrier'.
Eg:
import_v = pd.DataFrame({
    'cntr_no':[1,2,3,4,5,6,7,8],
    'cntr_size':[40,40,20,40,40,20,20,20],
    'carrier': ['MSK', 'MSK', 'MSC','MSK', 'MSK', 'MSC','CMA', 'MSK']
})

export_v = pd.DataFrame({
    'cntr_no':[9,10,11,12,13,14,15,16,17,18,19,20],
    'cntr_size':[40,40,20,40,40,20,20,20,40,40,20,20],
    'carrier': ['MSK', 'MSK', 'MSC','MSK', 'MSK', 'MSC','MSK', 'MSK','MSK', 'HLL','MSK', 'MSK']
})

if I merge with -
potential = pd.merge(import_v,export-v,on=['cntr_size','carrier'])

Output I'm getting -
[Out I Get][1]
cntr_no_x   cntr_size   carrier cntr_no_y
0   1   40  MSK 9
1   1   40  MSK 10
2   1   40  MSK 12
3   1   40  MSK 13
4   1   40  MSK 17
5   2   40  MSK 9
6   2   40  MSK 10
7   2   40  MSK 12
8   2   40  MSK 13
9   2   40  MSK 17
10  4   40  MSK 9
11  4   40  MSK 10 .... so on
12  4   40  MSK 12
13  4   40  MSK 13
14  4   40  MSK 17

Output I want -
cntr_no_x   cntr_size   carrier cntr_no_y
0   1   40  MSK 9
1   2   40  MSK 10
2   4   40  MSK 12

So cntr_no_x and cntr_no_y both should be unique and not repeat itself

A: The solution came from -
cntr_list_i=[]
cntr_list_e=[]
match_scale['status']=""
for ind in match_scale.index:
    if (match_scale.loc[ind,'container_no_x']) not in cntr_list_i and (match_scale.loc[ind,'container_no_y']) not in cntr_list_e:
        match_scale.loc[ind,'status']=True
        cntr_list_i.append(match_scale.loc[ind,'container_no_x'])
        cntr_list_e.append(match_scale.loc[ind,'container_no_y'])


text:
Q: How to calculate the percentage using facet in MongoDB? I am calculating the notification percentage in my app for tracking some statistics.
My Collection:
[
  {
    _id: "123",
    status: "seen",
    userId: "589"
  },
  {
    _id: "223",
    status: "seen",
    userId: "589"
  },
  {
    _id: "474",
    status: "unseen",
    userId: "589"
  },
  {
    _id: "875",
    status: "seen",
    userId: "112"
  },
  {
    _id: "891",
    status: "unseen",
    userId: "112"
  }
]

Expected Result:
Here we can see that, UserId - 589 has received 3 notifications out of which 2 are seen. So the calculation is (totalNumOfSeen/totalNumOfNoticationsSent) * 100
[{
    userId: "589",
    notificationPercentage : 66.66
},{
    userId: "112",
    notificationPercentage : 50
}]

I am using a facet for grouping and matching but that is returning me an array of object and I am not getting how to perform divide on this.
My Query:
db.collection.aggregate([
  {
    $facet: {
      totalNumOfSeen: [
        {
          $match: {
            userId: "589",
            status: "seen"
          }
        },
        {
          $group: {
            _id: "$userId",
            totalNumOfSeen: {
              $sum: 1
            }
          }
        }
      ],
      totalNumOfNoticationsSent: [
        {
          $match: {
            userId: "589",

          }
        },
        {
          $group: {
            _id: "$userId",
            totalNumOfNoticationsSent: {
              $sum: 1
            }
          }
        }
      ]
    }
  }
])

The Above Query is giving me the below Result:
[
  {
    "totalNumOfNoticationsSent": [
      {
        "_id": "589",
        "totalNumOfNoticationsSent": 3
      }
    ],
    "totalNumOfSeen": [
      {
        "_id": "589",
        "totalNumOfSeen": 2
      }
    ]
  }
]

MongoPlayground - https://mongoplayground.net/p/jHn2ZlshgDL
Now I need to add one more field as notificationPercentage and calculate the notification percentage based on the above facet result. Really appreciate the help.

A: You can try,

*

*$group by userId and get totalSeen count using $cond if status is seen, get total count of notification using $sum,

*$project to show required fields, and calculate percentage using $divide and $multiply
db.collection.aggregate([
  {
    $group: {
      _id: "$userId",
      totalSeen: {
        $sum: { $cond: [{ $eq: ["$status", "seen"] }, 1, 0] }
      },
      total: { $sum: 1 }
    }
  },
  {
    $project: {
      _id: 0,
      userId: "$_id",
      notificationPercentage: {
        $multiply: [{ $divide: ["$totalSeen", "$total"] }, 100]
      }
    }
  }
])

Playground


text:
Q: python, fix broken npy file. ValueError: total size of new array must be unchanged I run a program that saves data in a npy file every 20 seconds, but overwrites the old one, to update the file.
Yesterday after a day of data colection the program crashed, beacuse of a human error of somebody doing a keyboardinterupt at the wrong moment.
Now after loading the npy file I get the error message
ValueError: total size of new array must be unchanged
I already tried the
with open("test.npy", "rb") as npy:
    a = np.load(npy)
solution but the error remains.
What I think is going on is that there are lines missing in the npy file, but I don't know how to fix it. The npy file still has the size in MB it should have so there is defenitely something saved.
Does anyone have any idea how to fix my file and get the data that is in there?
Otherwise I loose a day of data.
Any help is very much appreciated!
Edit: Here one can find the broken file and an example of a good one that should be exactly the same except the numbers are different. http://perswww.kuleuven.be/~u0077049/
The shape is (1024, 3649)
The dtype is dtype('float64')

A: The npy format is very simple. It starts with an ascii description of the data (data type, array size), followed by a flat binary dump. The header data is always a multiple of 16 bytes, which happens to be a multiple of the size of a float64 (8 bytes) as well.
In this example, the header is 80 bytes. In your case, you have to try.
import numpy as np

# write npy file
a = 10**np.array(np.linspace(-10, 10, 51), dtype=np.float64)
np.save('foo.npy', a)

# read back
b = np.fromfile('foo.npy', dtype=np.float64)
print(b[10:])

You have to use reshape to get in it in the correct (Fortran) array order.
I had a brief look at your files; the problem seems to be that the file is supposed to be 29892688 bytes but the broken file is 29892609, i.e. 79 bytes too short. If you pad the file (or the array that you read with the procedure above) with 79 bytes of zeros, it's likely that you can read it again.


text:
Q: in Django sql table with dots as a decimal separator but in the admin are displayed with commas I have this error in Django
error during template rendering .... argument must be int or float

I wonder if it's because in my sql table I have columns with coordinates that have dots as a separator but when I look at the display in the admin these coordinates are displayed with commas
my models :
class VilleStation(models.Model):
    nomVille = models.CharField(max_length=255)
    adresse = models.CharField(max_length=255)
    cp = models.CharField(max_length=5)
    latitude = models.DecimalField(max_digits=9, decimal_places=6)
    longitude = models.DecimalField(max_digits=9, decimal_places=6)

    def __str__(self):
        return self.nomVille

in my settings
LANGUAGE_CODE = "fr-fr"

TIME_ZONE = "UTC"

USE_I18N = True

USE_TZ = True

DECIMAL_SEPARATOR = True

thank

A: sorry for my mistake, it was an error in a field of the table. There's no more problem.


text:
Q: Custom TableViewCell with Core Data I have a Destination View Controller that allows you to edit information displayed in the TableViewController..I am attempting to set this up in a custom cell..I have my UITableViewCell file with the custom property class and I also have my Model Class for the Core Data with the attributes.  I managed to get my root table view controller to show the custom label when I add a NEW player but once I click on the cell and edit it in the new view controller it goes back to the default on the table view.  I believe it has something to do with this code but I can not figure it out.
my NsManagedObject Subclass
@property (nonatomic, retain) NSString *playerFirstName;

I have a pointer to my Player Class of currentPlayer in my viewcontroller.h file and the firstnameTextfield is my UITextField
-(IBAction)doneEditing:(id)sender {

_currentPlayer.playerFirstName = firstnameTextField.text;

AppDelegate *myApp = (AppDelegate *) [[UIApplication sharedApplication]delegate]'
[myApp saveContext];

}

Update
I believe this is my line of code that is the problem after messing with it
_currentPlayer.playerFirstName = firstnameTextField.text;

how do I get the currentPlayer pointer to go to my playerNameCell property in my customcell class

A: You should do something like:
- (IBAction)newPlayer {
  _currentPlayer = (Player*) [NSEntityDescription insertNewObjectForEntityForName:@"Player" inManagedObjectContext:_managedObjectContext];
}

The _managedObjectContext should be passed to the view controller from the app delegate or some other view controller.


text:
Q: Z-index of ::before changing on hover? I am creating a simple CSS Button and having issues with its z-index.
My Code:

body { /* Ignore Body Styling */
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

button {
  padding: 0.7em 1em;
  font-size: 25px;
  text-transform: uppercase;
  font-weight: 600;
  border: 5px solid #191919;
  border-radius: 0;
  background-color: rebeccapurple;
  color: #fff;
  position: relative;
}

button:hover {
  cursor: pointer;
  transform: translate(-10px, -10px);
}

button::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 10px;
  width: 100%;
  height: 100%;
  z-index: -1;
  background-color: rgb(147, 103, 190);
}

button:hover::before {
  transform: translate(15px, 15px);
  z-index: -1;
}
<button>Click Me</button>

Just run the code once and you will understand.
While :hover, I don't want the ::before to cover over my main element (<button>)
Thank You!

A: Transforming an element alters the stacking context.
Instead of a translate you could move the element with negative margins.
UPDATE: and compensate for this (so that the following content doesn't move) by adding margin to right and bottom on hover while taking it away at the top and left.

body {
  /* Ignore Body Styling */
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

button {
  padding: 0.7em 1em;
  font-size: 25px;
  text-transform: uppercase;
  font-weight: 600;
  border: 5px solid #191919;
  border-radius: 0;
  background-color: rebeccapurple;
  color: #fff;
  position: relative;
}

button:hover {
  cursor: pointer;
  margin-top: -10px;
  margin-left: -10px;
  margin-bottom: 10px;
  margin-right: 10px;
}

button::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 10px;
  width: 100%;
  height: 100%;
  z-index: -1;
  background-color: rgb(147, 103, 190);
}

button:hover::before {
  transform: translate(15px, 15px);
  z-index: -1;
}
<button>Click Me</button>

A: Just to suggest an alternative approach, you could play with box shadows to create the effect without creating a pseudo-element.

body {
  height: 80vh;
  display: grid;
  place-items: center;
}

button {
  font-size: 1rem;
  transition: all 0.2s;
  color: white;
  padding: 0.5em 1em;
  text-transform: uppercase;
  background-color: rebeccapurple;
  border: 3px solid black;
  position: relative;
  box-shadow: 5px 5px 0px 0px orchid;
  -webkit-box-shadow: 5px 5px 0px 0px orchid;
  -moz-box-shadow: 5px 5px 0px 0px orchid;
}

button:hover {
  cursor: pointer;
  transform: translate(-5px, -5px);
  box-shadow: 12px 12px 0px 0px orchid;
  -webkit-box-shadow: 12px 12px 0px 0px orchid;
  -moz-box-shadow: 12px 12px 0px 0px orchid;
}
<button>Click Me</button>

A: code issues   top: 2px;
left: 2px;

<style>
body { /* Ignore Body Styling */
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

button {
  padding: 0.7em 1em;
  font-size: 25px;
  text-transform: uppercase;
  font-weight: 600;
  border: 5px solid #191919;
  border-radius: 0;
  background-color: rebeccapurple;
  color: #fff;
  position: relative;
}

button:hover {
  cursor: pointer;
  transform: translate(-10px, -10px);
}

button::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 100%;
  height: 100%;
  z-index: -1;
   background-color: rgb(147, 103, 190);
}
</style>
<button>Click Me</button>


text:
Q: PHP Slim 3 Framework - where can I put my controller file? I registering a controller with the container, but it seems not working because it doesn't match to the correct location.
\slim\src\routes.php
<?php
// Routes
$app->get('/dd', 'App\controllers\HomeController:home');

\slim\App\controllers\HomeController.php
<?php
class HomeController
{
   protected $container;

   // constructor receives container instance
   public function __construct(ContainerInterface $container) {
       $this->container = $container;
   }

   public function home($request, $response, $args) {
        // your code
        // to access items in the container... $this->container->get('');
        return $response;
   }

   public function contact($request, $response, $args) {
        // your code
        // to access items in the container... $this->container->get('');
        return $response;
   }
}

My project folder structure:
\slim
  \public
    index.php
    .htaccess

  \App
    \controllers
      HomeController.php

  \src
    dependencies.php
    middleware.php
    routes.php
    settings.php

  \templates
    index.phtml

  \vendor
    \slim

Maybe I should to setting \slim\src\settings.php?
Because it show Slim Application Error:

Type: RuntimeException Message: Callable
  App\controllers\HomeController does not exist File:
  D:\htdocs\slim\vendor\slim\slim\Slim\CallableResolver.php Line: 90

Last, I also refer to these articles:
https://www.slimframework.com/docs/objects/router.html#container-resolution
PHP Slim Framework Create Controller
PHP Slim Framework Create Controller
How can i create middleware on Slim Framework 3?
How can i create middleware on Slim Framework 3?

A: Add psr-4 to your composer file so that you're able to call your namespaces.
{
    "require": {
        "slim/slim": "^3.12
    },
    "autoload": {
        "psr-4": {
            "App\\": "app"
        }
    }
}

This PSR describes a specification for autoloading classes from file paths. Then in your routes.php file add this at the top :
<?php
    use app\controllers\HomeController;
    // Routes
    $app->get('/dd', 'App\controllers\HomeController:home');

and finally in your HomeController.php file add :
<?php
    namespace app\controllers;
    class HomeController
    {
    //.. your code
    }

hope this helps...:)


text:
Q: Averaging blocks of cells in a pandas dataframe For reasons that are difficult to explain, I want to average blocks of cells in a pandas dataframe which is sparsely populated with random values. The dataframe will always have sqrt(number of columns x number of indices) values -- and all the rest will be NaN. The values are approximately uniformly distributed so that if I average the right sized block of cells I expect to have one value within each block.
Here's my example. For 100 columns and 100 indices, I have 100 values randomly distributed throughout the dataframe. I expect there to be ~1 value per 10x10 block, with all the others being NaN. How can I turn each 10x10 block into one cell (averaging the 10 columns, 10 indices, and value(s) within it?
My code:
import pandas as pd
import numpy as np
import math

number_of_planes = 100

thicknesses = np.empty(number_of_planes)
cos_thetas = np.empty(number_of_planes)
phis = np.empty(number_of_planes)
for i in range(0,number_of_planes):
    r = 1
    phi = np.random.uniform(0,2*math.pi)
    theta = math.acos(2*np.random.uniform(0.5,1) - 1)
    thickness = np.random.uniform(0,0.4)

    phis[i] = phi
    cos_thetas[i] = math.cos(theta)
    thicknesses[i] = thickness

thick_df = pd.DataFrame(columns=phis, index=cos_thetas)

for i in range(0, len(thicknesses)):
    thick_df.set_value(cos_thetas[i], phis[i], thicknesses[i], takeable=False)

thick_df = thick_df.sort_index(axis=0, ascending=False)
thick_df = thick_df.sort_index(axis=1)

A: IIUC you can reshape into a 4D array splitting each axis into two axes of length sqrt(len of each axis) and compute average along the second and fourth axes ignoring the NaNs with np.nanmean -
arr = thick_df.values.astype(float)
n = int(np.sqrt(number_of_planes))

out = np.nanmean(arr.reshape(n,n,n,n),axis=(1,3))

indx = thick_df.index.values.reshape(-1,n).mean(1)
coln = thick_df.columns.values.reshape(-1,n).mean(1)
df_out = pd.DataFrame(out, index=indx, columns= coln)

Sample run -
In [174]: thick_df # number_of_planes = 4
Out[174]:
          4.550477  5.138694  5.411510 6.123163
0.981987       NaN       NaN  0.393233      NaN
0.565861  0.186647       NaN       NaN      NaN
0.193190       NaN       NaN       NaN  0.11626
0.088382       NaN  0.166189       NaN      NaN

In [175]: df_out
Out[175]:
          4.844586  5.767337
0.773924  0.186647  0.393233
0.140786  0.166189  0.116260

A: m, n = 10, 10
row_groups = np.arange(len(thick_df.index)) // m
col_groups = np.arange(len(thick_df.columns)) // n

grpd = pd.DataFrame(thick_df.values, row_groups, col_groups)

val = pd.to_numeric(grpd.stack(), 'coerce').groupby(level=[0, 1]).mean().unstack().values
idx = thick_df.index.to_series().groupby(row_groups).mean().values
col = thick_df.columns.to_series().groupby(col_groups).mean().values

pd.DataFrame(val, idx, col)


text:
Q: Python: how to round an indexed number? I have the following code snippet (from part of a Class):
def __init__(self):
    self.data_end = self.datas[0].end
    self.data_start = self.datas[0].start

Then, the following code:
def next_trans(self):
    if not self.position:
        if self.buy_signal > 0:
            size = int(self.getcash() / self.datas[0].start)
            self.log(f'BUY - Size: {size}, Cash: {self.getcash():.2f}, Start: {self.data_start[0]}, End: {self.data_end[0]}')
            self.start(size=size)

The problem I have is that the "Start" and "End" values are printing as long floating point numbers (e.g. 89.12999725341797).
I tried various ways to use round(), but with no success.  I get errors such as:
AttributeError: 'LineBuffer' object has no attribute 'round'

and
TypeError: type LineBuffer doesn't define __round__ method

How do I round the output to two decimal places (e.g. 89.13)?
Thanks in advance!

A: The solution is to append ":.2f":
self.log(f'BUY - Size: {size}, Cash: {self.getcash():.2f}, Start: {self.data_start[0]:.2f}, End: {self.data_end[0]:.2f}')

Originally, I had appended ".2f" (missing the preceding ":"), which threw one of the error messages I saw.
Thanks @Błotosmętek!


text:
Q: convert all xlsx files in directory to txt with for loop I have a list of 150 .xlsx files in a directory that I am trying to convert to txt.  After all the files are converted I am going to combine each of the file (data only) to one large text file (all.txt), but the below command runs though the files remain as .xlsx.  Is this not the way to do this? Thank you :).
for i  in *.xlsx; do  libreoffice --headless --convert-to txt "$i" ; done

A: There is probably a better way, but in dos:
Copy *.xlsx *.txt

did the trick.  Thank you :).


text:
Q: How to use a tab widget in Android? Can anyone show me how to make a tab widget in Android?

A: There is a developer guide showing how to implement tabbed activities/fragments http://developer.android.com/guide/topics/ui/actionbar.html
It's very important to follow new solution, because the method using TabActivity is deprecated since API level 13.


text:
Q: How to see all tags in a git repository in command line Is there something like "git show tags"?

A: git tag to list tags used in the repo.
git tag -l if you use the -l option you can pass a search pattern to filter out tags.

A: git tag -l
git tag

-l <pattern>

List tags with names that match the given pattern (or all if no pattern is given).
  Typing "git tag" without arguments, also lists all tags

See also GitHub tagging.
And I mentioned in "How to sort git tags by version string order of form rc-X.Y.Z.W?" to sort order used for listing tags.

A: Use:
git ls-remote --tags YOUR_REPOSITORY_NAME


text:
Q: aligning checkbox in HTML 5 I'm trying to create a login page in HTML.
no matter what i do, the checkbox and its text are not aliening together in a same line.
I want it to look like that: "[] text" instead of:
"[](going down a line) text".
I tried a lot of suggestions i saw in similar posts but nothing seems to works.
This is my code:

* {
    box-sizing: border-box;
}

*:focus {
    outline: none;
}
body {
    font-family: Arial;
    background-color: #3498DB;
    padding: 50px;
}
.login {
    margin: 20px auto;
    width: 300px;
}
.login-screen {
    background-color: #FFF;
    padding: 20px;
    border-radius: 5px
}

.app-title {
    text-align: center;
    color: #777;
}

.login-form {
    text-align: center;
}
.control-group {
    margin-bottom: 10px;
}

input {
    text-align: center;
    background-color: #ECF0F1;
    border: 2px solid transparent;
    border-radius: 3px;
    font-size: 16px;
    font-weight: 200;
    padding: 10px 0;
    width: 250px;
    transition: border .5s;
}

input:focus {
    border: 2px solid #3498DB;
    box-shadow: none;
}

.btn {
    border: 2px solid transparent;
    background: #3498DB;
    color: #ffffff;
    font-size: 16px;
    line-height: 25px;
    padding: 10px 0;
    text-decoration: none;
    text-shadow: none;
    border-radius: 3px;
    box-shadow: none;
    transition: 0.25s;
    display: block;
    width: 250px;
    margin: 0 auto;
}

.btn:hover {
    background-color: #2980B9;
}

.errorMsg{
    font-size: 12px;
    color: red;
}
.LabeledCheckboxGroup label, .LabeledCheckboxGroup input {
    float: none; /* if you had floats before? otherwise inline-block will behave differently */
    display: inline-block;
    vertical-align: middle;
}
<!DOCTYPE html>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Login</title>

    <link rel="stylesheet" type="text/css" href="css/Login.css">

Gridler

                <input type="text" class="login-field" value="" placeholder="username" id="login-name">

                <input type="checkbox" checked name ="IsHuman"> Human Player

            login

Thanks,
Maor

A:

* {
    box-sizing: border-box;
}

*:focus {
    outline: none;
}
body {
    font-family: Arial;
    background-color: #3498DB;
    padding: 50px;
}
.login {
    margin: 20px auto;
    width: 300px;
}
.login-screen {
    background-color: #FFF;
    padding: 20px;
    border-radius: 5px
}

.app-title {
    text-align: center;
    color: #777;
}

.login-form {
    text-align: center;
}
.control-group {
    margin-bottom: 10px;
}

input {
    text-align: center;
    background-color: #ECF0F1;
    border: 2px solid transparent;
    border-radius: 3px;
    font-size: 16px;
    font-weight: 200;
     width: auto;
    padding: 10px 0;
    transition: border .5s;
}

input:focus {
    border: 2px solid #3498DB;
    box-shadow: none;
}

.btn {
    border: 2px solid transparent;
    background: #3498DB;
    color: #ffffff;
    font-size: 16px;
    line-height: 25px;
    padding: 10px 0;
    text-decoration: none;
    text-shadow: none;
    border-radius: 3px;
    box-shadow: none;
    transition: 0.25s;
    display: block;
    width: 250px;
    margin: 0 auto;
}

.btn:hover {
    background-color: #2980B9;
}

.errorMsg{
    font-size: 12px;
    color: red;
}
.LabeledCheckboxGroup label, .LabeledCheckboxGroup input {
    float: none; /* if you had floats before? otherwise inline-block will behave differently */
    display: inline-block;
    vertical-align: middle;
}
<!DOCTYPE html>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Login</title>

    <link rel="stylesheet" type="text/css" href="css/Login.css">

Gridler

                <input type="text" class="login-field" value="" placeholder="username" id="login-name">

                <input type="checkbox" checked name ="IsHuman"> Human Player

            login

A: Add
input.login-field {
    display: block;
    margin: 0 auto;
}

A: Put the checkbox and its text inside a div.
Remove the width property from the checkbox.
Move the text into its own label.
set display: inline-block for both the checkbox and the label.

A: You've set the width for ALL inputs to 250px simply change
input {
text-align: center;
background-color: #ECF0F1;
border: 2px solid transparent;
border-radius: 3px;
font-size: 16px;
font-weight: 200;
padding: 10px 0;
width: 250px;
transition: border .5s;
}

To
#login-name {
text-align: center;
background-color: #ECF0F1;
border: 2px solid transparent;
border-radius: 3px;
font-size: 16px;
font-weight: 200;
padding: 10px 0;
width: 250px;
transition: border .5s;
}

A: I have edited your code snippet, please have a look.

* {
    box-sizing: border-box;
}

*:focus {
    outline: none;
}
body {
    font-family: Arial;
    background-color: #3498DB;
    padding: 50px;
}
.login {
    margin: 20px auto;
    width: 300px;
}
.login-screen {
    background-color: #FFF;
    padding: 20px;
    border-radius: 5px
}

.app-title {
    text-align: center;
    color: #777;
}

.login-form {
    text-align: center;
}
.control-group {
    margin-bottom: 10px;
}

input {
    text-align: center;
    background-color: #ECF0F1;
    border: 2px solid transparent;
    border-radius: 3px;
    font-size: 16px;
    font-weight: 200;
    padding: 10px 0;
    width: 250px;
    transition: border .5s;
}

input:focus {
    border: 2px solid #3498DB;
    box-shadow: none;
}

input[type="checkbox"]
{
  width: 30px;
}

.checkbox {
   text-align: left;
  font-size: 14px;
  margin-top: 5px;
  }

.checkbox label {
   vertical-align: top;
  }

.btn {
    border: 2px solid transparent;
    background: #3498DB;
    color: #ffffff;
    font-size: 16px;
    line-height: 25px;
    padding: 10px 0;
    text-decoration: none;
    text-shadow: none;
    border-radius: 3px;
    box-shadow: none;
    transition: 0.25s;
    display: block;
    width: 250px;
    margin: 0 auto;
}

.btn:hover {
    background-color: #2980B9;
}

.errorMsg{
    font-size: 12px;
    color: red;
}
.LabeledCheckboxGroup label, .LabeledCheckboxGroup input {
    float: none; /* if you had floats before? otherwise inline-block will behave differently */
    display: inline-block;
    vertical-align: middle;
}
<!DOCTYPE html>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Login</title>

    <link rel="stylesheet" type="text/css" href="css/Login.css">

Gridler

                <input type="text" class="login-field" value="" placeholder="username" id="login-name">

                <input type="checkbox" checked name ="IsHuman"> Human Player

            login


text:
Q: Is there a conflict, or is there not a conflict between the Pusey-Barrett-Rudolph (PBR) theorem and the information theory interpretation? In the wikipedia article, it says that the PBR theorem sort of rules out the psi epistemic interpretations. I want to know, is this the end of the information theory interpretation and relational interpretation?
I am thinking that there is no conflict. The statement of this theorem says that one physical reality is not consistent with multiple pure states. But psi epistemic models do not
attribute different pure states to the same physical situation, do they?
For example, in the Wiger's friend experiment, the information theory/relational interpretation says that the friend observes a collapsed state, say $|\text {spin up}\rangle$. But Wigner will describe the experiment using something like $|\text{spin up, friend measured up}\rangle +|\text{spin down, friend measured down}\rangle$.
So it is true that Wigner and Wigner's friend are using different states, but they're not describing the same physical situation. Wigner's friend is only describing the state of the particle. But Wigner is describing the joint system of his friend and the particle.
Is this correct? Is there a conflict or not, between the PBR theorem and the information theory/ relational interpretation?

A: As with all such results, understanding this requires a careful consideration of the underlying mathematical framework and a knowledge of how it relates to the intuitive concepts under discussion. In particular, while it makes statements like "$\psi$-epistemic views are inconsistent with the probabilities described by QM", the term "$\psi$-epistemic" does not mean a mere equation of the wave function with "knowledge" or "information" but rather a specific mathematical model of that intuitive idea, and that mathematical model is not closed to objection. Indeed, I'll outline an objection here, that I am not sure has been raised before (but if someone has, I'd gladly accept the citation!).
PBR bascially starts from the following idea, which is a sort of extension of the setup used in Bell's Theorem. Suppose that a quantum system has associated to it some "objective" characteristics, or state, $\lambda$, drawn from a possibility set $\Lambda$. In Bell's theorem, the idea being tested is that $\lambda$ determines each measurement result - that is, for each (for simplicity) yes/no projector operator $\hat{\Pi}$ representing an elementary question to be asked about the system, $\lambda$ directly determines it answer, i.e. there is a function from the cross product of $\Lambda$ and the set of all such projectors to $\{ 0, 1 \}$, such that if we knew $\lambda$, we would know what every measurement would give in advance.
PBR softens this a bit. It doesn't presume that $\lambda$ necessary determines the measurement results by itself, but does nonetheless presume that each $\lambda$, together with a question $\hat{\Pi}$, will determine a probability for that question to be "yes", i.e. $P(\hat{\Pi}|\lambda)$, to use a notation evocative of conditional probability. It then assumes $\lambda$ is wholly set by the preparation procedure, and moreover that two different procedures set to prepare the same pure quantum state $|\psi\rangle$ prepare $\lambda$ in the same way, i.e. to each such $|\psi\rangle$, we can associate a different preparation probability measure $\mu_\psi$ on $\Lambda$, viz. the probability of getting a "yes" to some $\hat{\Pi}$ is
$$P(\text{$\hat{\Pi}$ gives "yes"}) = \int_{\lambda \in \Lambda} P(\hat{\Pi}|\lambda)\ d\mu_\psi$$
where the integral is meant in the sense of Lebesgue. Note that if the inner probability is definitive for all questions (i.e. either $0$ or $1$), then the probability to get an answer is simply that that the preparer prepared the system with that answer, i.e. the same as the setup of Bell's Theorem.
The argument then goes from there to consider a joint measurement on two independently prepared systems, and moreover shows how this measurement can be realized with real quantum systems, and shows that distinct quantum states must "partition"(*) the putative set $\Lambda$. The "$\psi$-epistemic" view is specifically defined here as the view that there could exist a pair of quantum states $|\psi_1\rangle$ and $|\psi_2\rangle$ such that the objective state $\lambda$ could belong to both, that is, knowing one or the other would be consistent with the same $\lambda$, by analogy with classical ignorance-interpreted probability distributions, where that you can assign two different probability distributions despite only 1 given state of reality being the case at a given time.
So does this rule out an informational interpretation? It depends: If you take P, B, and R's setup above as defining what you mean by "informational interpretation", then yes, it does. However, is that the only consistent informational interpretation? I would argue it does not, and will give you two reasons to think this below.
For one thing, and as I pointed out in a comment here: there are other, and arguably better-behaved, mathematical quantum formalisms in which a distinction between pure and mixed states does not have to be drawn so explicitly as in the Hilbert formalism, but instead emerges naturally from a common description. In particular, the system of $C^{*}$-algebras reveals that pure states are essentially extreme points on a convex hull of mixed quantum states. This exists in Hilbertian QM as well, if you just stick entirely to density operators and pretend vectors don't exist. Here, the vectors go away and thus we just have one set of "states". As I said before, an "informational interpretation", most generally, simply means assigning the semantic value of "agent knowledge" to the quantum state. In this case, then it follows both mixed and pure states represent knowledge. It is just that, under the PBR setup, pure states represent enough knowledge to separate at least different classes of real states of the system. There is no reason an "information" referent cannot become coincident in some sense with actual reality.
The second, more subtle, objection is the one I'm not so sure has been made before. It concerns a step that is easy to miss within the PBR argument, and that is that the move from the individual systems to the joint system assumes a passage from individual objective state spaces $\Lambda_1$ and $\Lambda_2$ to a total joint space of $\Lambda_1 \times \Lambda_2$. Besides providing another attack vector on the theorem by itself (though I believe some have followed at least direct approaches down that line and not found them very fruitful), the more interesting line of objection is what it says regarding the assumptions underlying the Bell-like framework I just described. In particular, to what extent can we consider the "state" $\lambda$, or even for that matter, $|\psi\rangle$, to truly belong solely to the system? Indeed, here's a simple thought experiment as to why we should think that frameworks of the kind P, B, and R use shouldn't be used, and it requires us to remember, as seem strangely often forgotten, that quantum mechanics, as the name suggests, is a theory of mechanics - in all this, let's not lose sight of basic physics principles! In particular, we can shift physical reference frames - for all this stuff about talking about "agents", "knowledge" and "observer effects" and what not, it seems often ignored is the question of a simple change of coordinates of the kind you learn about in your first course in Newtonian mechanics.
Suppose we have a setup located far out in the depths of space, away from gravity and other perturbing forces. There is a single electron, surrounded by some probing apparatus which, depending on how it's oriented, will measure a different component of the electron's spin angular momentum vector. We consider this apparatus to include enough capabilities it can be treated as a quantum agent, e.g. maybe it's running an AI program. The whole thing is prepared so that it regards the electron it has as being in a state like $\left|\uparrow\right\rangle$.
Now, here's something. This agent has reaction wheels attached to it. It can rotate - change its orientation - without influencing the electron. Suppose it uses them to execute a 90-degree repositioning maneuver around it. Presumably, $\lambda$ for the electron should not change, right? Yet in order to calculate the correct probabilities for the measurement, it must now assign it the Hadamard state
$$|+\rangle = \frac{\left|\uparrow\right\rangle + \left|\downarrow\right\rangle}{\sqrt{2}}$$
and will obtain $\uparrow$ or $\downarrow$ with probability $\frac{1}{2}$. Yet nothing changed about $\lambda$! This situation cannot easily be accounted for in the PBR framework! Either we have to assume that $\lambda$ is somehow strangely altered "spookily" by the rotation, or we have to assume the set of questions the agent is asking is changing. The trouble with the second option is that it violates fundamental physical symmetry laws: namely, it tells us there is a preferred orientation in space, against which those questions are defined, because no such transformation appears in the PBR framework itself - the operators all remain the same, only the quantum state $\left|\psi\right\rangle$ changes.
Hence, the thesis I would suggest is that, in fact, our quantum pure state assignment $|\psi\rangle$ actually does not just capture the "state of the system" alone, but instead reflects also some stuff about the situation of our agent viz. that system. In particular, there is no reason that $P(\hat{\Pi}|\lambda)\ d\mu_\psi(\{ \lambda \})$ should be considered sufficient to generate the probability given by QM to begin with, because it also needs conditioning upon some further aspects of the world external to the system! And that is tacitly stamped out because the movement to the Cartesian product when considering the joint systems is in effect to limit the referents solely to the systems themselves.
And indeed, Rovelli's relational interpretation is very natural for dealing with this scenario, and cannot be given an ontology in the PBR framework, because it does not assign objective states $\lambda$ to single systems alone, but instead to pairs of systems. In particular, relational ontology might look something like this: if we have three systems, $a$, $b$, and $c$ where $b$ and $c$ can act as agents observing $a$, then we would say the pairs $(b, a)$ and $(c, a)$ (where I've written it in the form $(\text{agent}, \text{system})$) have (different!) objective states $\lambda$, but not $a$ itself, nor presumably $b$ or $c$ by themselves (very interesting metaphysical implications). (Note that we could add a "self-state" to pairs like $(a, a)$, but it will not be the one observed by any external measurer.) Most particularly, in the PBR setup we have the systems $a$ and $b$, individual measurers $m_a$ and $m_b$, and joint measurer $m_j$. Then the pairs $(m_a, a)$, $(m_b, b)$, $(m_j, a \otimes b)$ could (and will!) all have different states, too. But also note that Rovelli doesn't say $\Lambda$ is distinct from the Hilbert space $H$ of any of the systems - they could, in fact, be one and the same.
Going back to our example, the mechanical rotation process I described would then be understood as changing the state of the relational pair involving the measuring agent and measured system, but changes nothing about the state of that measured system individually.

A: OKay so PBR is solely a statement about hidden variable theories, i.e. theories which say that the pure state is an incomplete description of physical reality, and that a hidden state provides the complete description.
Since the relational interpretation and the information theoretic interpretation do not assert the existence of any hidden variables, I think PBR is indeed not in any conflict with them

A: The PBR theorem essentially says that different quantum states have different observable consequences. One ontological reality cannot be correctly described by two distinct quantum states - one of them must be false in a way that can be experimentally demonstrated.
In the case of Wigner's friend, this is fairly obvious. Wigner's friend says the quantum state contains only one outcome, $\left| \uparrow \right>$ say, Wigner says it contains both. If Wigner's state is correct, then $\left| \downarrow \right>$ is still possible with non-zero probability, even after his friend has asserted that $\left| \uparrow \right>$ is the only possibility. The two quantum states make different physical predictions about what will be observed.
(Your suggestion that Wigner's friend only asserts the state of the particle and Wigner asserts the state of particle and friend doesn't work. Wigner's friend knows his own state, too. So Wigner sees the complete state as $\left| \uparrow | O_\uparrow \right>$ and Wigner sees it as $\alpha\left| \uparrow , O_\uparrow \right>+\beta\left| \downarrow , O_\downarrow \right>$. The friend can choose to leave the observer part out, but it is still a part of his full knowledge of the state of the world.)
Epistemic interpretations say that these differences merely reflect the different state of knowledge of each observer. An observer might have only partial information, the quantum state they assert on the basis of what they know may be different from the true ontological state. So if Wigner's friend has already collapsed the wavefunction, then Wigner is simply wrong in thinking both options are still open.
There is a distinction between versions that suggest there is no 'true' ontology behind the scenes, only the epistemic information from observations - like a game of 20 questions where the world answers 'yes' or 'no' at random, consistent with previous answers - and interpretations where there is an ontological truth behind it all but it is something forever inaccessible to observers.
Since the PBR theorem assumes there is a single ontological state of the world, I don't think the former are directly invalidated. PBR contradicts non-realist interpretations, but only by prior assumption. It depends on whether you think PBR's assumption is reasonable. Tastes may differ!
And since an epistemic interpretation allows that an epistemic estimate based on partial information may be wrong about the true state, and the probabilities that arise, adherents are not too distressed to discover that this is so.
The relational interpretations, on the other hand, get round the problem by asserting that ontological reality is observer-dependent. Quantum states describe the relation between observer and observed. A system does not have to show the same face to all observers. So again, the assumption of a single ontological reality and the need for a single set of consistent predictions is challenged.
But I think there is a simpler viewpoint, which is to recognise that quantum mechanical interpretations are by their nature not subject to confirmation or refutation. The unitary evolution of quantum mechanics predicts that interaction between systems will lead to a superposition of mutually-invisible alternative outcomes. Since these other outcomes are unobservable even in principle, we can have no observational evidence that they are there, (or not there). They might all continue to exist, unobserved and unobservable (many worlds), or they might all instantly disappear (Copenhagen), or some of them might partially disappear for some observers and not others (relational), or anything else (explode into showers of unicorns and party balloons...). So long as you make all the same predictions about the bits you can see, there is no way to experimentally distinguish the hypotheses about what you can never see.
The only grounds on which you can pick or dismiss one are aesthetic. Does it have nice properties, like being realist, deterministic, local, causal, parsimonious, simple, complete, materialist, non-mystical, etc.? Does it explain things that other hypotheses simply have to assert as axioms? Does it explain when, how, and why the other alternatives disappear? Is it easy to imagine? Easy to calculate with? Easy to explain?
So really, something like the PBR theorem can never refute any particular interpretation (except by refuting quantum mechanics itself), but you can reasonably ask whether, given the consequences, the assumptions it makes and the reasons for them have more or less aesthetic merit than those of particular interpretations.

A:
psi epistemic models do not attribute different pure states to the same physical situation, do they?

For better or worse, it seems to be standard to use "$ψ$-ontic" to describe models where the quantum state vector is a function of the state of the world, and "$ψ$-epistemic" to describe models where it is not. So $ψ$-epistemic models do have physical states that are shared by more than one quantum state, by definition.
It's a little hard to say whether a given model is $ψ$-epistemic or not, because we don't know the correct $ψ$. If a system starts in the state $|{\rightarrow}\rangle|\text{experimenter}\rangle$, and according to the many-worlds interpretation evolves from there to $$\frac{|{\uparrow}\rangle|\text{experimenter saw }{\uparrow}\rangle + |{\downarrow}\rangle|\text{experimenter saw }{\downarrow}\rangle} {\sqrt2}$$
but according to an explicit-collapse model evolves to either the state $|{\uparrow}\rangle|\text{experimenter saw }{\uparrow}\rangle$ or the state $|{\downarrow}\rangle|\text{experimenter saw }{\downarrow}\rangle$, then presumably at most one of those models can be $ψ$-ontic, but we don't know which one.
The argument in the PBR paper nominally applies to any model that is $ψ$-epistemic, but it assumes that the measurements needed to obtain a contradiction can actually be carried out. Measurements involving superpositions of experimenter states can't be done, so the argument doesn't really rule out anything involving states of experimenters. Even if treated as a purely theoretical argument about consistency with QM, it still doesn't, because the many-worlds and explicit-collapse models mentioned above are both considered to be "consistent with QM" by many people.
The relational interpretation goes much farther in denying that there even is a correct $ψ$ in these situations, so I'm not sure it can even be fit into the $ψ$-ontic/epistemic classification, but in any case there's no way it can be said to be ruled out by PBR's argument.


text:
Q: Measurement with structure and searching for least, largest and average temperature I have to write a program for recording the measured temperatures,
into which new measurements can be entered, or display statistics calculated from previous measurements. In the case of printing statistics, it is necessary to find and display the lowest and highest recorded temperature and calculate the average temperature.
#include <stdio.h>

int least_in_array(int array[], int n)
{
    int i, least=array[0];
    for(i=0; i<n; i++)
    {
        if(array[i]<least)
        {
            least=array[i];
        }
    }
    return least;
}

int largest_in_array (int array[], int n)
{
    int i, largest=array[0];
    for(i=0; i<n; i++)
    {
        if(array[i]>largest)
        {
            largest=array[i];
        }
    }
    return largest;
}

float average_array(int array[], int n)
{
    int amount=0, i;

    for(i=0; i<n; i++)
    {
        amount+=array[i];
    }
    return (1.0*amount)/n;
}

int main() {

    int choose;

    struct Data1 {
        int dayInMonth;
        int month;
        float temperature;
    } da;

    printf("New measurement(1) or statistic(2)?\n");
    scanf("%d", &choose);

    if(choose==1) {

        printf("Enter the day in month : ");
        scanf("%d", &da.dayInMonth);
        printf("Enter month : ");
        scanf("%d", &da.month);
        printf("Enter temperature (*C) : ");
        scanf("%f", &da.temperature);

        printf("Data saved!");
        printf("-----------\n");

        return 0;
    }

    if(choose==2) {

        //printf("Least temperatures in quarter: %d",   least_in_array(dayInMonth) );

        return 0;
    }

    else {

        printf("----------------\n");
        printf("Wrong choose!\n");

    }

    return 0;
}

In case 2, I commented line where I get an error. Can anyone give me any advice to fix this problem?
|71|error: 'dayInMonth' undeclared (first use in this function)
|71|error: too few arguments to function 'least_in_array'

A: Since it is Christmas Eve, lets help out fellow man... who obviously is badly in need. For code that is supposed to pass an array to least_in_array, largest_in_array and average_array -- you have no array! That somewhat puts you behind the eight-ball from the word "Go!".
Your thought to use a stuct to capture and coordinate dayInMonth, month and temperature is 100% correct. (but note: C-style generally avoids camelCase variable names in favor of all lowercase). Also, defining struct Data1 within main() prevents your functions above that point from knowing what struct Data1 is, so you need to move your struct definition to the top of the file. (or provide a forward declaration, but we will save that for later) For now, let's just move your Data1 to the top (I used a typedef to alleviate having to prefix each use with stuct and renamed Data1 data:
#define NDAYS 365

typedef struct {
    int day,
        month;
    double temperature;
} data;

Note the defined constant NDAYS. Since you are going to need an array, and since a dynamically allocated and reallocated approach seem well beyond your needs here, let's just define a constant, a maximum, for the number of elements we will have in our array.
Now, before we go further, let's think about our array. If we are going to use a struct to hold the associated date and temperature measurement, then we are going to need an array of... what?? An array of struct. And with our constant NDAYS, we will declare a maximum of 365 elements in our array. So how would this work? We have our stuct typedeffed to data, so if we want an array of data we need:
    data da[NDAYS] = {{0, 0, 0.0}};

Note: the older initializer format initializing each field was used as it is unclear whether you could be using a C89 compiler. C99 and later added named initializers , e.g. {{.day = 0}} and any uninitialized elements are implicitly initialized to zero.
Now we have an array of data and can capture measurements. Of course you are responsible for keeping track of the indexes you fill. A simple counter, incremented each time a successful measurement in entered is all you need (ndx is used below)
How do we make least_in_array, largest_in_array and average_array work with an array of data? Recall, we moved the definition of the struct to the beginning of the source file, so now each function knows what data is. We simply need to pass our array of data as a parameter, e.g.
float least_in_array (data *array, int n)
{
    int i;
    float least = INT_MAX;   /* sufficiently high temp */

    for (i = 0; i < n; i++)
        if (array[i].temperature < least)
            least = array[i].temperature;

    return least;
}

(note, each of the quantities of least_in_array, largest_in_array and average_array refer to the temperature values and therefore need to return type float.)
The remainder of putting together largest_in_array and average_array follows the same pattern.
The crux of your remaining problems relate to handling user input, and the particular pitfalls associated with taking user input with scanf. It can be done, but you must always validate the return, and test for user cancellation of input by testing for EOF (the result of the user pressing Ctrl+d (or Ctrl+z on windoze)).
You must validate that the number of expected conversions did in fact take place, or you must handle the error, and most importantly, you must account for any characters left in the input buffer (e.g. stdin), otherwise, if an invalid entry is made and you don't remove it from stdin, you will loop forever... (with scanf if a matching or input failure occurs -- no additional character are processed -- leaving them where? (oh, in stdin)
You can make this fairly easy on yourself if you declare a few helper functions to empty stdin, and make the normal process of getting an integer or float from the user relatively safe. For example, to empty stdin, you simply read all remaining characters until a '\n' or EOF is encountered, e.g.
/** simple function to empty all characters that remain
 *  in stdin. Needed when using scanf for user input.
 */
void empty_stdin()
{
    int c = getchar();

    while (c != '\n' && c != EOF)
        c = getchar();
}

To ask the user for an int or float, you simply validate the return, check the number of successful conversion (what scanf returns), check whether EOF was generated by the user, and finally handle the error if invalid input was given and empty_stdin as required. You generally want to loop until the user either provides valid input, or cancels. (an invalid input does you no good).
For example, getting integer input can be handled as follows. (note: I put it in a function to keep from repeating this block of code for each input you take in the main body of your code...
/** abbreviated function to read integer value from user.
 *  returns value on success, exits if user cancels.
 *  empties stdin after call to scanf.
 */
int getint ()
{
    int n = 0;

    for (;;) {              /* loop until valid input or EOF */
        int rtn = 0;        /* variable to capture return of scanf */
        rtn = scanf ("%d", &n);
        if (rtn == 1) {     /* we got an integer */
            empty_stdin();
            break;
        }
        else if (rtn == EOF) {  /* if user cancels, exit */
            fprintf (stderr, "user canceled input.\n");
            exit (EXIT_FAILURE);
        }
        if (rtn == 0)       /* handle error */
            fprintf (stderr, "getint() error: invalid integer input.\n");

        empty_stdin();      /* empty all chars remaining in stdin */
    }

    return n;
}

(taking input for a float works the same way).
Lastly, you generally want to avoid using float in most cases, using double instead, just due to loss of precision and limitations for representing floating-point numbers with a 23-bit mantissa. However, here we are taking temperature, and float will suffice for this code.
Putting it altogether, you could do something like the following. Note, I have left your functions before main() as you had them, and added the helper function definitions after main(), but provided declarations before main() so they are visible to main() :
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

#define NDAYS 365

typedef struct {
    int day,
        month;
    double temperature;
} data;

float least_in_array (data *array, int n)
{
    int i;
    float least = INT_MAX;   /* sufficiently high temp */

    for (i = 0; i < n; i++)
        if (array[i].temperature < least)
            least = array[i].temperature;

    return least;
}

float largest_in_array (data *array, int n)
{
    int i;
    float largest = INT_MIN; /* sufficiently low temp */

    for (i = 0; i < n; i++)
        if (array[i].temperature > largest)
            largest = array[i].temperature;

    return largest;
}

float average_array (data *array, int n)
{
    int i;
    float sum = 0.0;

    for (i = 0; i < n; i++)
        sum += array[i].temperature;

    return sum / (float)n;
}

void empty_stdin();
int getint();
float getfloat();

int main (void) {

    int ndx = 0;
    float max = 0.0, min = 0.0, avg = 0.0;
    data da[NDAYS] = {{0, 0, 0.0}};

    for (;;) {

        int choose = 0;

        printf ("\n  (1) New measurement\n"
                "  (2) Statistics\n"
                "  (3) Exit\n\n"
                "  choice: ");
        choose = getint();
        putchar ('\n');

        switch (choose) {
            case 1: if (ndx == NDAYS) {
                        fprintf (stderr, "error: array full.\n");
                        break;
                    }
                    printf ("    Enter day in month : ");
                    da[ndx].day = getint();
                    printf ("    Enter month        : ");
                    da[ndx].month = getint();
                    printf ("    Enter temperature  : ");
                    da[ndx].temperature = getfloat();
                    printf ("  da[%3d] saved\n"
                            "  ----------------------------\n", ndx++);
                    break;
            case 2: if (ndx == 0) {
                        fprintf (stderr, "error: no measurements taken.\n");
                        break;
                    }
                    min = least_in_array (da, ndx);
                    max = largest_in_array (da, ndx);
                    avg = average_array (da, ndx);
                    printf ("  minimum temp : %.2f\n"
                            "  maximum temp : %.2f\n"
                            "  average temp : %.2f\n"
                            "  ----------------------------\n",
                            min, max, avg);
                    break;
            case 3:
                    goto done;
                    break;
            default:
                    fprintf (stderr, "error: invalid choice.\n");
                    empty_stdin();
                    break;
        }
    }
    done:;

    return 0;
}

/** simple function to empty all characters that remain
 *  in stdin. Needed when using scanf for user input.
 */
void empty_stdin()
{
    int c = getchar();

    while (c != '\n' && c != EOF)
        c = getchar();
}

/** abbreviated function to read integer value from user.
 *  returns value on success, exits if user cancels.
 *  empties stdin after call to scanf.
 */
int getint ()
{
    int n = 0;

    for (;;) {              /* loop until valid input or EOF */
        int rtn = 0;        /* variable to capture return of scanf */
        rtn = scanf ("%d", &n);
        if (rtn == 1) {     /* we got an integer */
            empty_stdin();
            break;
        }
        else if (rtn == EOF) {  /* if user cancels, exit */
            fprintf (stderr, "user canceled input.\n");
            exit (EXIT_FAILURE);
        }
        if (rtn == 0)       /* handle error */
            fprintf (stderr, "getint() error: invalid integer input.\n");

        empty_stdin();      /* empty all chars remaining in stdin */
    }

    return n;
}

/** abbreviated function to read float value from user.
 *  returns value on success, exits if user cancels.
 *  empties stdin after call to scanf.
 */
float getfloat ()
{
    float v = 0.0;

    for (;;) {              /* loop until valid input or EOF */
        int rtn = 0;        /* variable to capture return of scanf */
        rtn = scanf ("%f", &v);
        if (rtn == 1) {     /* we got an float */
            empty_stdin();
            break;
        }
        else if (rtn == EOF) {  /* if user cancels, exit */
            fprintf (stderr, "user canceled input.\n");
            exit (EXIT_FAILURE);
        }
        if (rtn == 0)       /* handle error */
            fprintf (stderr, "getint() error: invalid float input.\n");

        empty_stdin();      /* empty all chars remaining in stdin */
    }

    return v;
}

Note: how the array bounds are limited to 365 or less in your take measurement part of the code, and how a check is made that there is at least one measurement present before any statistics can be provided. You always need to validate each step of the process. Look for corner-cases, think about what could go wrong with input (what if a cat stepped on the keyboard), and then go provide validations and checks to handle each case. The validations above are just the bare minimum, there are always more you can add to more fully report and handle each error condition.
Example Use/Output
$ ./bin/tempmxmnavg

  (1) New measurement
  (2) Statistics
  (3) Exit

  choice: 2

error: no measurements taken.

  (1) New measurement
  (2) Statistics
  (3) Exit

  choice: 1

    Enter day in month : 8
    Enter month        : 2
    Enter temperature  : 20.0
  da[  0] saved
  ----------------------------

  (1) New measurement
  (2) Statistics
  (3) Exit

  choice: 1

    Enter day in month : 9
    Enter month        : 2
    Enter temperature  : 30.0
  da[  1] saved
  ----------------------------

  (1) New measurement
  (2) Statistics
  (3) Exit

  choice: 1

    Enter day in month : 10
    Enter month        : 2
    Enter temperature  : 70.0
  da[  2] saved
  ----------------------------

  (1) New measurement
  (2) Statistics
  (3) Exit

  choice: 2

  minimum temp : 20.00
  maximum temp : 70.00
  average temp : 40.00
  ----------------------------

  (1) New measurement
  (2) Statistics
  (3) Exit

  choice: 3

Look things over and let me know if you have any further questions (although given the evening, I won't be here much longer...)


text:
Q: how to store data in specific format? in WYSWYG? I am using WYSIWYG window 4 taking input from user, so he can enter font Bold, Italic etc. How to store such data, so that when I display on some other page, same font styles and formats comes back??

A: The WYSIWYG is nothing but a Div tag with "Contenteditable" attribute, which will help capture bold, italic etc. and the content you see is rendered version of the html.
if you want to get the HTML just get the innerHTML of the contenteditable div it will give you html code. let me know if you need more help.

A: You can make a class called FontMetadata, and store the data in a tuple like
Tuple<Data, DataStyle>