Q: Rotate Object About a Point With Crank Mechanism I am trying to figure out how to create this physics simulation but I need some guidance on how to go about calculating it. Below is an image of the system I am working to solve.

Here I am trying to find out how to calculate the angle at which to rotate the black triangle in order to maintain the length of 111 for the blue linkage as the circle crank rotates continuously. I have used the law of cosines to calculate all the angles and the changing length (x). What I am stuck on is how to take all the variables and put them together to calculate the proper triangle rotation to maintain the 111 length.
Any help would be greatly appreciated and if I can give any more information please let me know.

A: You were right to think of the Law of Cosines in this problem.
We will need to use the center point of the circle for reference. Since you have not labeled it, I will call that point $d$.
The first step is to find $x$, which is given by the Pythagorean Theorem
$$x=\sqrt{(94.017+38.4\cos\theta)^2+(38.4\sin\theta)^2}\approx\sqrt{10313.8+7220.51\cos(\theta)}$$
Where $\theta$ is the angle between $\overline{dc}$ and the rightward horizontal.
Next, use the Law of Cosines to solve for $\angle{abc}$.
$$111^2=100^2+x^2-2(100)x\dot{}\cos\angle{abc}\implies
\angle{abc}=\cos^{-1}\left(\frac{x^2-2321}{200x}\right)$$
Then use the Law of Sines to find $\angle{cbe}$. Notice that $\angle{bdc}=\pi-\theta$
$$\frac{\sin\angle{cbd}}{38.4}=\frac{\sin{(\pi-\theta)}}{x}\implies
\angle{cbd}=\sin^{-1}\left(\frac{38.4\sin{(\pi-\theta)}}{x}\right)$$
Finally, we find $\angle{abd}$ (the angle between $\overline{ba}$ and the rightward horizontal)
$$\angle{abd}=\angle{abc}+\angle{cbd}=\cos^{-1}\left(\frac{x^2-2321}{200x}\right)+\sin^{-1}\left(\frac{38.4\sin{(\pi-\theta)}}{x}\right)$$
Solve the above equation numerically; substituting the expression for $x$ does not simplify nicely and will lead to rounding errors.
Knowing $\angle{abd}$ should be sufficient information to translate the other points in the image.
Check out this beautiful giraffe


Q: Trying to create composite unique index with partialFilterExpression I'm trying to create an unique index for my collection with composite keys, but some documents might have null on the fields of the index. Going by the documentation it seems I should be able to do it with partialFilterExpression.
I tried it as following:
db.collection.createIndex(
 { a: 1, b: 1, c: 1 },
 {
   "background":true,
   "unique": true,
   "partialFilterExpression": {
     "a": { "$exists": true },
     "b": { "$exists": true },
     "c": { "$exists": true }
   }
 })

but that gave me the following error:

exception: E11000 duplicate key error collection: schema.collection index: a_1_b_1_c_1 dup key: { : null, : null, : null }

I even tried changing the partial filter criteria to this:
db.collection.createIndex(
  { a: 1, b: 1, c: 1 },
  {
    "background":true,
    "unique": true,
    "partialFilterExpression": {
      "a": { "$exists": true, "$ne": null  },
      "b": { "$exists": true, "$ne": null  },
      "c": { "$exists": true, "$ne": null  }
    }
  }
)

But still returned the same error.
Did I misunderstand the use or am using it wrongly?

A: Just figured out what was my issue. The version of my monogo is 3.0.12 and partialFilterExpression was introduced in version 3.2


Q: Помогите растянуть высоту картинки в div'е Добавил в div картинку, наложил поверх текст, ещё блоки, но вот сама картинка отображается не во всю высоту. height: 100%; не помогает.

.bg {
  color: #fff;
  display: block;
  text-align: center;
  background-image: url(/images/bg.jpg);
  background-position: center;
  background-color: #333;
  background-size: cover;
  padding-top: 9em;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>

dukascopy is looking for world

virtuosos

A: Попробуйте
background-size: cover


Q: Why does Crashlytics go into an infinite loop for an unhandled exception? I have just updated to the latest Crashlytics. I tried testing it by throwing an unhandled exception.
It did not send a bug report.
The app simply froze.
Checking the debugger, it appears to be in an infinite loop.
If I pause threads in the debugger, it looks like the picture.
enter image description here
That is absolutely unacceptable. I can't ship an app like this.
This is in build.gradle at the app level.
 // Recommended: Add the Firebase SDK for Google Analytics.
    implementation 'com.google.firebase:firebase-analytics:17.1.1'

    // Add the Firebase Crashlytics SDK.
    implementation 'com.google.firebase:firebase-crashlytics:17.1.1'

This in build.gradle at the project level:
    // Add the Crashlytics Gradle plugin.
    classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'


Q: Checkbox with PHP and MYSQL I have two checkboxes
<form action="" method="post" enctype="multipart/form-data">
<input type="checkbox" name="file_type" value="1"> Filer

<input type="checkbox" name="file_type" value="1"> Statistik
</form>

and i have two rows on my database table das_custermer_files.
row 1 = files
row 2 = statistic
how can i check one of them an put the value into my rows.
i have try with this code
if($_POST['file_type'] == 1){
            mysql_query("INSERT INTO das_custermer_files (url, das_file_categories_id, das_custermers_id, name)
                         VALUE('$fileurl', 1, $user_custermers_id, '$name')"
                    ) or die(mysql_error());
            }

            elseif($_POST['statistik_type'] == 1){
                mysql_query("INSERT INTO das_custermer_files (url, das_custermer_upload_id, das_custermers_id, name)
                         VALUE('$fileurl', 1, $user_custermers_id, '$name')"
                    ) or die(mysql_error());
            }
            else{
                echo "no choices";
            }

But if i only check one of them it stil put value 1 in both of my rows.
Hope people understand. If not. ask

i have done it.
the finel code:
html
<form action="" method="post" enctype="multipart/form-data">
    <input type="radio" name="file_type" value="1"> Filer

    <input type="radio" name="file_type" value="2"> Statistik
</form>

PHP
$field = false;

            switch($_POST['file_type'])
            {
                case 1:
                    $field = 'das_file_categories_id';
                break;
                case 2:
                    $field = 'das_custermer_upload_id';
                break;
                default:
                $field = false;
            }
            if($field)
            {
               mysql_query("INSERT INTO das_custermer_files (url, $field, das_custermers_id, name)
                         VALUE('$fileurl', 1, $user_custermers_id, '$name')"
                    ) or die(mysql_error());
            }

A: My approach would be like this:
I would use radio buttons instead, to ensure a type is selected.
Form Bits:
    <input type="radio" name="file_type" value="0" checked="checked"> None

    <input type="radio" name="file_type" value="1"> Filer

    <input type="radio" name="file_type" value="2"> Statistik

PHP Bits:
$field = false;

 // set the field name based on the file type selected in the form
switch($_POST['file_type'])
{
    case 1:
        $field = '`das_file_categories_id`';
    break;
    case 2:
        $field = '`das_custermer_upload_id`';
    break;
    default:
    $field = false;
}

// if a field has been set ( i.e file_type != 0 ) then build and run the query
if($field)
{

    $query  =   "INSERT INTO `das_custermer_files` (`url`, " . $field . ", `das_custermers_id`, `name`) ";
    $query .=   "VALUES ('" . $fileurl . "', 1, " . $user_custermers_id . ", '" . $name . "')";
    mysql_query($query);
    echo "Inserting to db: " . $query;
} else {
    echo "No field set: ";
    print_r($_POST);
}

Things worth noting

*

*You're using mysql_query which is outdated, see here: http://php.net/manual/en/function.mysql-query.php

*Even though you are using $fileurl, $user_custermers_id,$name i cannot see these being set, so i am assuming they are set somewhere higher in the file

A: your check_box names should be different. yours the same.
<input type="checkbox" name="file_type" value="1"> Filer

<input type="checkbox" name="file_type" value="1"> Statistik

A: Html code :
<form action="test.php" method = 'post'>
<input type="checkbox" name="file_type[]" value="1"> Filer

<input type="checkbox" name="file_type[]" value="2"> Statistik
<input type="submit" value="submit" />

checkbox will contain its value in array $_POST['file_type']
and you may inter its value to db as follows :-
if(isset($_POST['file_type'])){
 foreach($_POST['file_type'] as $keys)
   {
     mysql_query("INSERT INTO das_custermer_files (url, das_file_categories_id,     das_custermers_id, name)
                 VALUE('$fileurl', $keys, $user_custermers_id, '$name')"
            ) or die(mysql_error());
    }
 }
    else if(isset($_POST['statistik_type'])){
        mysql_query("INSERT INTO das_custermer_files (url, das_custermer_upload_id, das_custermers_id, name)
                 VALUE('$fileurl', 1, $user_custermers_id, '$name')"
            ) or die(mysql_error());
    }
    else{
        echo "no choices";
    }

this maybe your requirement...

A: Try this .Should work.
 if(isset($_POST['file_type'])){
        mysql_query("INSERT INTO das_custermer_files (url, das_file_categories_id, das_custermers_id, name)
                     VALUE('$fileurl', 1, $user_custermers_id, '$name')"
                ) or die(mysql_error());
        }

        else if(isset($_POST['statistik_type'])){
            mysql_query("INSERT INTO das_custermer_files (url, das_custermer_upload_id, das_custermers_id, name)
                     VALUE('$fileurl', 1, $user_custermers_id, '$name')"
                ) or die(mysql_error());
        }
        else{
            echo "no choices";
        }

A: You approach is totally wrong. You should follow this structure
<form action="test.php" method = 'post'>
    <input type="checkbox" name="file_type" value="1"> Filer

    <input type="checkbox" name="file_type" value="2"> Statistik
    <input type="submit" value="submit" />
</form>

Now with php
$query  =   '';
if($_POST['file_type'] == 1){
    $query  =   "INSERT INTO das_custermer_files
                (url, das_file_categories_id, das_custermers_id, name)
                VALUE
                ('$fileurl', 1, $user_custermers_id, '$name')";
}else if($_POST['file_type'] == 2){
    $query  =   "INSERT INTO das_custermer_files
                (url, das_custermer_upload_id, das_custermers_id, name)
                VALUE
                ('$fileurl', 1, $user_custermers_id, '$name')";
}

mysqli_query($query);

A: You probably forgot to <form action = "..." method = "POST"> </form>.
First step, you should do the test:
print_r($_POST);

What you get by this test?
If the first step is correct (not empty array), we can finish:
if (isset($_POST['file_type'])) {
   ...
};

// OR use alternative
if ($_POST['file_type'] == 1) {
   ...
};

A: Clicking on a checkbox doesen't change the value attribute but adds "checked" in the dome like this:
<input type="checkbox" name="file_type" value="1" checked> Filer

So the submitted value of the checked box will stay forever at "1"
EDIT
When you replace the values with strings you can check against it in php.
HTML
<form action="" method="post" enctype="multipart/form-data">
<input type="checkbox" name="file_type" value="Filer"> Filer

<input type="checkbox" name="file_type" value="Statistik"> Statistik
</form>

PHP
if($_POST['file_type'] == "Filer"){
            mysql_query("INSERT INTO das_custermer_files (url, das_file_categories_id, das_custermers_id, name)
                         VALUE('$fileurl', 1, $user_custermers_id, '$name')"
                    ) or die(mysql_error());
            }

            elseif($_POST['file_type'] == "Statistik"){
                mysql_query("INSERT INTO das_custermer_files (url, das_custermer_upload_id, das_custermers_id, name)
                         VALUE('$fileurl', 1, $user_custermers_id, '$name')"
                    ) or die(mysql_error());
            }
            else{
                echo "no choices";
            }


Q: File upload validation - to unlink from tmp or not Just a quick question on best practice.
If my website visitors are uploading files that fail file validation (too large, wrong filetype etc.) is it safer/ more efficient to programatically delete the file from the servers tmp directory? Or do I just let the purge cycle performed by the server take care of it?
Many thanks
Phill

A: From the manual:

The file will be deleted from the temporary directory at the end of the request if it has not been moved away or renamed.

So, you could omit it, however:

Whatever the logic, you should either delete the file from the temporary directory or move it elsewhere.

... it's always nice to be explicit in your script. In short: you don't have to, but I would.


Q: Scrapping memory issue (Out Of Memory) Good day,
I have cameras that are saving videos by clips on a cloud service, with a limit on N clips. In order to save more clips, I made a scrapping script that gets all my video links from the website where I can preview them. (to be executed on page load with a JS extension)
Note that these are M3U8 files.
Here is my script:
var cameraScrapper = {
    playerReady: false,
    videos: {},

    cameraCurrent: 0,
    cameras: [
        'cid1', // #1
        'cid2', // #3
        'cid3', // #2
    ],

    gui: function()  {
        return {
            calendarPreviousMonth: document.getElementById( 'event_calendar_section' ).getElementsByClassName( 'navigation' )[0].getElementsByClassName( 'prev' )[0],
            calendarNextMonth: document.getElementById( 'event_calendar_section' ).getElementsByClassName( 'navigation' )[0].getElementsByClassName( 'next' )[0],
            calendarSelectedDate: document.getElementById( 'event_selected_date' ),
            calendarMonthDays: document.getElementById( 'event_calendar_section' ).getElementsByClassName( 'month' )[0].children,
            cameras: document.getElementById( 'camera_list_dropdown' ).children,
            dayClips: document.getElementById( 'event_clips_wrap' ).children,
            noRecords: document.getElementsByClassName( 'no_recording' )[0]
        };
    },

    init: function() {
        document.getElementById( 'hls_player' ).addEventListener( 'canplay', function() { this.playerReady = true; }.bind( this ) );

        for( let i = 0; i < this.cameras.length; i++ ) {
            if( window.location.href.includes( '=' + this.cameras[i] + '&' ) ) {
                this.cameraCurrent = i;
                break;
            }
        }

        while( !this.gui().calendarPreviousMonth.children[0].classList.contains( 'disabled' ) ) {
            this.gui().calendarPreviousMonth.click();
        }

        this.scrap();
    },

    getVideo: function( pCamera, pTimeStamp ) {
        let performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance || {};
        let requests = ( performance.getEntries() || {} );

        for( let i = 0; i < requests.length; i++ ) {
            if( requests[i].name.includes( '.ts?' ) ) {
                if( this.videos[encodeURIComponent( requests[i].name )] === undefined ) {
                    this.videos[encodeURIComponent( requests[i].name )] = { 'camera': pCamera, 'timestamp': this.formatDate( pTimeStamp ) };
                }
            }
        }

        if( Object.entries( this.videos ).length > 25 ) {
            this.save();

            this.videos = {};
            performance.clearMarks();
            performance.clearMeasures()
            performance.clearResourceTimings();
        }
    },

    formatDate( pTimestamp ) {
        let date = pTimestamp.split( ' ' )[0];
        let time = pTimestamp.split( ' ' )[1];

        let month = {
            JAN: '01',
            FEB: '02',
            MAR: '03',
            APR: '04',
            MAY: '05',
            JUN: '06',
            JUL: '07',
            AUG: '08',
            SEP: '09',
            OCT: '10',
            NOV: '11',
            DEC: '12'
        }

        return date.split( '.' )[2] + '-' + month[date.split( '.' )[1]] + '-' + date.split( '.' )[0] + ' ' + time;
    },

    sleep: function( pMs ) {
        return new Promise( resolve => setTimeout( resolve, pMs ) );
    },

    scrap: async function() {
        let scrapDays = true;

        while( scrapDays ) {
            for( let i = 0; i < this.gui().calendarMonthDays.length; i++ ) {
                if( !this.gui().calendarMonthDays[i].classList.contains( 'is-disabled' ) && !this.gui().calendarMonthDays[i].classList.contains( 'is-expired' ) && !this.gui().calendarMonthDays[i].classList.contains( 'is-future' ) ) {
                    // console.log( 'day ' + this.gui().calendarMonthDays[i].innerText );

                    this.gui().calendarMonthDays[i].click();

                    let clipsLoaded = false;

                    if( this.gui().noRecords !== undefined ) {
                        clipsLoaded = !this.gui().noRecords.classList.contains( 'displayOff' )
                    }

                    while( !clipsLoaded && ( this.gui().dayClips.length == 0 ) ) {
                        await this.sleep( 99 );

                        if( this.gui().noRecords !== undefined ) {
                            clipsLoaded = !this.gui().noRecords.classList.contains( 'displayOff' )
                        }
                    }

                    // console.log( 'clips ' + this.gui().dayClips.length );

                    for( let j = 0; j < this.gui().dayClips.length; j++ ) {
                        this.playerReady = false;
                        this.gui().dayClips[j].children[0].click();

                        while( !this.playerReady ) {
                            await this.sleep( 99 );
                        }

                        this.getVideo( ( '' + this.cameraCurrent ), this.gui().calendarSelectedDate.innerText + ' ' + this.gui().dayClips[j].children[0].children[1].children[1].innerText );
                    }
                }
            }

            if( !this.gui().calendarNextMonth.children[0].classList.contains( 'disabled' ) ) {
                this.gui().calendarNextMonth.click();
            } else {
                scrapDays = false;
            }
        }

        this.save();

        this.sleep( 4999 );

        let cameraNext = this.cameraCurrent + 1;
        if( this.cameras.length >= cameraNext ) {
            cameraNext = 0;
        }

        window.location.href = 'https://cloudcamerasservice.com/camera?no=' + this.cameras[cameraNext] + '&model=CAM';
    },

    save() {
        let xhr = new XMLHttpRequest();
        xhr.open( 'POST', 'http://localhost/videomonitoring/stack.php', true );
        xhr.setRequestHeader( 'Content-type', 'application/x-www-form-urlencoded' );

        xhr.onload = ( e ) => { /* console.log( 'saved' ); */ };
        xhr.onerror = ( e ) => {};
        xhr.send( 'stack=' + encodeURIComponent( JSON.stringify( this.videos ) ) );
    }
};

setTimeout( function() { cameraScrapper.init() }.bind( this ), 4999 );

stack.php will handle file download from provided list, my script is mainly about getting the video links and date of recording.
But when launching my script, my browser run out of memory after 75-100 clips saved. Can you help me with this?
Not sure if it's comming from my script, indeed, I have the feeling this is due to preloading many videos on the same page.


Q: Scrollbar in textarea Css is like:
::-webkit-scrollbar,::-moz-scrollbar {
    -webkit-appearance: none;
    width: 6px;    /* for vertical scrollbars */
    height: 8px;    /* for horizontal scrollbars */
}
::-webkit-scrollbar-track,::-moz-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius:4px;
}
::-webkit-scrollbar-thumb,::-moz-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.5);
    border-radius:4px;
}

but it works only in chrome ..in other browser it display default scrollbar and second doubt is it start appears in ipad after I scrolldown..how to display vertical scroll if it has max text on hover of the textarea?
jsfiddle

A: You can use mouseout and mouseover events to hide or show the scroll bar using css.

A: For a cross browser solution you should use javascript/jquery. There are many successful scrollbar plugins that you can use


Q: GRASS r.in.lidar projection error I'm trying to import a laz file in GRASS using the command:
r.in.lidar input=3dm_32_322_5593_1_nw.laz output=count_1 method=n resolution=1 -o -e -n
and get:

ERROR 6: EPSG PCS/GCS code 7837 not found in EPSG support files. Is this a valid EPSG coordinate system?

The projection is 25832 and I can open the file in QGis with LAStools without any problem.
Here a metadata snippet from the lasinfo tool:

GeoKeyDirectoryTag version 1.1.0 number of keys 5
key 1024 tiff_tag_location 0 count 1 value_offset 1 - GTModelTypeGeoKey: ModelTypeProjected
key 3072 tiff_tag_location 0 count 1 value_offset 25832 - ProjectedCSTypeGeoKey: ETRS89 / UTM 32N
key 3076 tiff_tag_location 0 count 1 value_offset 9001 - ProjLinearUnitsGeoKey: Linear_Meter
key 4099 tiff_tag_location 0 count 1 value_offset 9001 - VerticalUnitsGeoKey: Linear_Meter
key 4096 tiff_tag_location 0 count 1 value_offset 7837 - VerticalCSTypeGeoKey: Deutsches Haupthoehennetz 2016

To me it seems that GRASS confuses the projected and vertical CRS. Has anyone an idea how to fix the error or a workaround? Is there a way to skip the projection check (-o flag doesn't seem to work in this case) or to define the EPSG code any other way?
The dataset can be found here:
https://www.opengeodata.nrw.de/produkte/geobasis/hm/3dm_l_las/3dm_l_las/


Q: Button isn't displayed in RelativeLayout below GridView I have the next problem: when a gridview content doesn't fit into device display and scrolling begins then a button below the gridview is not shown.
Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:paddingLeft="16dp"
 android:paddingRight="16dp">

  <GridView
    android:id="@+id/generated_number_gridview"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:columnWidth="90sp"
    android:horizontalSpacing="10sp"
    android:stretchMode="columnWidth"
    android:verticalSpacing="10sp" />

  <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/generated_number_gridview"
    android:layout_centerHorizontal="true"
    android:onClick="proceed"
    android:text="@string/proceed"
    android:textSize="25sp" />
</RelativeLayout>

Would be very thankful for your help !

A: Remove this line from Button Layout properties.
        android:layout_below="@id/generated_number_gridview"

This means that It should be below the GridView. And your GridView size is not fixed. Since the renderer shows the GridView with multiple elements it fills the screen and your Button goes below that. That's why it's not visible.
I hope this is the UI that you are looking for.
 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="16dp"
    android:paddingRight="16dp">

    <GridView
        android:id="@+id/generated_number_gridview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:columnWidth="90sp"
        android:horizontalSpacing="10sp"
        android:stretchMode="columnWidth"
        android:verticalSpacing="10sp"
        android:layout_above="@+id/proceedButton"
        />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        android:id="@+id/proceedButton"
        android:onClick="proceed"
        android:text="proceed"
        android:textSize="25sp" />
</RelativeLayout>

Hope it helps.

A: Try this.
Just replace this with your XML code.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="16dp"
    android:paddingRight="16dp">

    <GridView
        android:id="@+id/generated_number_gridview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/btnProceed"
        android:layout_centerHorizontal="true"
        android:columnWidth="90sp"
        android:horizontalSpacing="10sp"
        android:stretchMode="columnWidth"
        android:verticalSpacing="10sp" />

    <Button
        android:id="@+id/btnProceed"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:onClick="proceed"
        android:text="Proceed"
        android:textSize="25sp" />
</RelativeLayout>

Here is the Screen shot.

A: You can use this layout..
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:paddingLeft="16dp"
     android:paddingRight="16dp">

  <GridView
        android:id="@+id/generated_number_gridview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        **android:layout_above="@+id/btn_proceed"**
        android:layout_centerHorizontal="true"
        android:columnWidth="90sp"
        **android:horizontalSpacing="10dp**"
        android:stretchMode="columnWidth"
        **android:verticalSpacing="10dp"** />

 <Button
        android:id="@+id/btn_proceed"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:onClick="proceed"
        android:text="@string/proceed"
        android:textSize="25sp" />
    </RelativeLayout>


Q: How to ignore code when data does not contain necessary values? I'm very new to R and here as well and need some help fixing my code because sometimes my data gets weird
So I have data similar to this
Random  Price
11.23   0.68
66.77   0.51
68  0.46
78  0.51
88  0.32
89  0.51
90  0.27
91  0.65

This is my code so far:
newdata <- data[ which(data$Random>=30
& data$Random < 50), ]
Pvalue<- lapply(1:length(dat), function(i){
if(length(dat[[i]][[4]])>1){
t.test(newdata$Price,dat[[i]][[4]])$p.value
}else 'not enough observation'
})

My code basically does a t.test between the data from 'newdata' and another set of data called 'dat'
But there are times when I don't have data from 30 to 50 similar to my example data above.
So instead of my code returning an error, how could I change it so that it just returns NA .

A: You already know how to use the if/else construct. All you have to do is add one testing nrow(newdata), or maybe combine both as follows:
newdata <- subset(data, Random >= 30 &
                        Random < 50)
Pvalue <- lapply(dat, function(x){
  if (length(x[[4]]) > 1 & nrow(newdata) > 1) {
    t.test(newdata$Price, x[[4]])$p.value
  } else NA
})

You could also replace lapply(...) with sapply(...) or vapply(..., numeric(1)) to get a numeric vector instead of a list. For that, it is recommended to replace 'not enough observation' with NA like I did, or you could end up with a character vector.


Q: Left invariant metric on $SL(n,\mathbb{R}$) I'm vaguely familiar with the concept of invariant Riemannian metrics on Lie groups. I am mainly interested in $SL(n,\mathbb{R})$ but I guess the following is more general.
To the best of my knowledge, for any Lie group $G$ there can always be chosen a left-invariant (or right) Riemannian metric (but usually not bi-invariant). Moreover, this Riemannian metric induces a left-invariant ("standard", non Riemannian) metric $d_G$ on $G$.
My questions are:

*

*Are my statements above correct? I don't know any canonical reference for these, so I would appreciate any.

*Is the (non Riemannian) left invariant metric $d_G$ on $G$ unique in some sense (maybe up to equivalence or something)?

*$SL(n,\mathbb{R})$ is naturally embedded in $\mathbb{R}^{n^2}$, on which all metrics are equivalent. How is the (non Riemannian) metric $d_{SL(n,\mathbb{R})}$ on $SL(n,\mathbb{R})$ relates to the metrics on $\mathbb{R}^{n^2}$? Is there any relation at all? Are there any interesting inequalities? Even the $n=2$ case is a starting point. I vaguely remember some identities somewhat looking like $\|M\|^2\approx \cosh d(M,I)$

A: If $G$ is a Lie group with Lie algebra $\mathfrak{g}$ of left-invarant vector fields, then the left-invariant Riemannian metrics on $G$ correspond to inner products on $\mathfrak{g}$ by defining
$ \langle \mathrm{d}l_g X, \mathrm{d}l_g Y \rangle_g = \langle X, Y \rangle $ for $X,Y \in T_eG \cong \mathfrak{g}$. Any connected Riemannian manifold inherits a "standard" metric  by setting the distance between a pair of points $p,q$ to be the infimum of lengths of paths from $p$ to $q$.
I can't tell what uniqueness statement you're gunning for in your second question. Already the set of inner products on $\mathfrak{g} \cong \mathbb{R}^n$ is $\frac{n(n+1)}{2}$-dimensional. These are all equivalent. There can be other left-invariant "standard" metrics which are not induced by Riemannian metrics. For example, if a metric is not a path metric, it is not induced by a Riemannian metric. (E.g. the inclusion of a unit sphere into Euclidean space and just restricting the metric, so that antipodal points are at distance $2$.)
One convenient choice of left-invariant Riemannian metric on $\mathrm{SL}(n,\mathbb{R})$ corresponds to the Frobenius inner product $\langle X, Y \rangle = \mathrm{trace}(X^TY)$ at the identity. This metric is also right-invariant for the subgroup $\mathrm{SO}(n)$. Every traceless symmetric matrix $X$ defines a geodesic $c(t) = \exp(tX)$ where $\exp$ is the matrix exponential. Then $\lVert \exp(tX) \rVert^2 = \sum_{i=1}^n e^{2t\lambda_i} $ where $\{ \lambda_i \}$ are the eigenvalues of $X$, while $d(e^{tX},I) = \lVert tX \rVert$. For $\mathrm{SL}(2,\mathbb{R})$ we have $\lambda_2 = - \lambda_1$ so we get
$$ \lVert \exp(tX) \rVert^2 =  e^{2t\lambda} + e^{-2t\lambda} = 2 \cosh(2 t \lambda) $$
while $d(e^{tX},I)=\lVert tX \rVert = t \sqrt{\lambda^2 + \lambda^{-2}}$. This looks pretty close to what you wrote.
There's a reason I restricted to symmetric matrices: if you want to look at the distance from the identity to a general matrix $A$, then you can factor it into $A=SK$ where $S$ is symmetric and $K$ is orthogonal. The distance from $A$ to $S$ is uniformly bounded by the diameter of $\mathrm{SO}(n)$ (this bound exists because the subgroup is compact). The symmetric matrices are easier to understand while still capturing the large-scale geometry. If you want to better understand all the geodesics, I recommend these notes by Robert Bryant:
https://services.math.duke.edu/~bryant/GroupGeodesicsNotes.pdf

A: There is an old article of Milnor on invariant metrics on Lie groups, you can find it
here


Q: SQLITE: SELECT between timestamps doesnt work my goal is it to search between two time stamps of a certain time span  all of this is stored in an array of an dynamic amount of time stamps depending on how much days i want to search in the past. Originally they looked like that 2020-07-30T08:41:22.164Z but i removed the unimportant parts of it and now it looks like that 07-30. So i just filtered the time stamp to its month and day. Now to my problem: I am trying to bring that command to work: "SELECT status FROM database WHERE timeStamp BETWEEN '%datesStored[datesStored.length -1]%' AND '%datesStored[0]%'".
Ignore the fact that i used JS where the time stamps should be. The whole SQLite statement is in fact a String I've built that i am trying to send to SQLite node in nore-red. But that is not important. They only thing i need is the certain command that would work.
Thank you for any responses.

var datesSaved = msg.payload;
var daysBack = global.get("maxDaysBack");
var min = datesSaved[0];
var max = datesSaved[datesSaved.length-1];

msg.topic = "SELECT status, dateTime FROM database WHERE dateTime BETWEEN '%07-28%' AND '%07-29%';";

msg.labels = msg.payload;
msg.payload = [];
return msg;

A: I don't know exactly what your search strategy is here, but if you want to see all records going back 7 days to the past, you may use:
SELECT status, dateTime
FROM database
WHERE dateTime >= date('now', '-7 day');


Q: How do I safely lock an ASP.NET MVC3 Session? I want to modify the Session variable in an ASP.NET MVC3 Controller (that has SessionState required) in a thread-safe manner. What object should I lock on?


Q: Mail migration from old hosting provider to dovecot Unable to find a decent tutorial on this and the dovecot wiki doesn't seem to specify much other than the command line parameters for doveadm sync.
I need to move emails from a hosting provider to a new server I've set-up (time-bound on this before the old hosting provider charges for another year).  The new server has been set-up with postfix and dovecot. These have been configured in the following manner.
Dovecot does authentication
Dovecot file holds users and passwords
2 x domains set-up (example.com and example2.com)

This set-up works for inbound and outbound for example.com and example2.com.
Old hosting provider with domain oldexample.com holds several mailboxes to be migrated. While I can access the server via SSH it is extremely locked down so no root access or even access to install anything. If I've understood correctly I can use dovecot on the new email server to pull the accounts using the dsync utility via IMAP.
The questions I have (before I start) are

*

*Do I need to create the users from oldexample.com on the new server before I attempt the sync?

*Do I need to add the domain oldexample.com to the new server config before or after I attempt the sync?

*When should the MX records etc for oldexample.com be updated - presumably after the sync?

Any help appreciated or if there is a tutorial out there with this information (and any other relvant info) that I've missed please point me in that direction.

A: After a bit of playing around I managed to figure it out - details below for anyone who comes across this (presuming your postfix and dovecot is set-up as detailed above - which was setup as per https://www.binarytides.com/install-postfix-dovecot-debian/).

*

*Add the domain to be migrated to /etc/postfix/virtual_mailbox_domains

*Add the users to be migrated to the user auth file (/etc/dovecot/dovecot-users)

*Add migration config to /etc/dovecot/conf.d/migrate.conf (taken from https://wiki2.dovecot.org/Migration/Dsync)

*For each user run the below command (updating the username)

    doveadm -D -v -o mail_fsync=never backup -R -u user@oldexample.com imapc:

*Update DNS/MX records


Q: Where do I start with developing a Silverlight app using Windows Workflow Foundation? We are starting out with the development of a Silverlight app that will make use of Windows Workflow Foundation (WF4). Our workflows are long-running. We plan to use the tracking and persistence functionality of WF. We will probably need to also store data related to each workflow instance in another DB (I suspect running reporting against the workflow persistence store would be tricky). Our workflows may change with time so we would probably also need some strategy to implement versioning on them.
So specifically, are there any resources you can point me to or direction you can give me on where to start, taking into account that we need to implement tracking, persistence and versioning of workflows?

A: Based on your question, I'm assuming that you already have experience with WWF and are really just asking about how it interacts with Silverlight.  The short answer is that it would not be noticeably different from how you would implement a WWF-enabled application in traditional ASP.NET.  Remember that Silverlight is only a UI client that usually lives on top of a traditional ASP.NET web application.  Your WWF-related logic and code would live in the ASP.NET layer -- not in Silverlight at all.
So if you already know how to make a WWF-enabled application in ASP.NET, all you really need to learn is how to wire up a shiny Silverlight interface to an ASP.NET web app.  For that, you of course only need to hit up http://silverlight.net/, which you're probably already doing.
Good luck!


Q: Why is Serilog(.Extras.)Web's ApplicationLifecycleModule.Init() called twice? I'm hosting a Web API in IIS (7.5) as an Application under "Default Web Site", and am using several of the Enrichers from Serilog.Extras.Web (I'll be upgrading soon to the SerilogWeb.Classic package). I noticed in my logs that ApplicationLifecycleModule.LogRequest() was being called twice for each request, and I'm trying to understand why.
What I noticed is that ApplicationLifecycleModule.Init() is being called twice, thus registering two event handlers.
The first callstack:
Serilog.Extras.Web.dll!Serilog.Extras.Web.ApplicationLifecycleModule.Init(System.Web.HttpApplication context)
System.Web.dll!System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(System.IntPtr appContext, System.Web.HttpContext context, System.Reflection.MethodInfo[] handlers)
System.Web.dll!System.Web.HttpApplication.InitSpecial(System.Web.HttpApplicationState state, System.Reflection.MethodInfo[] handlers, System.IntPtr appContext, System.Web.HttpContext context)
System.Web.dll!System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(System.IntPtr appContext, System.Web.HttpContext context)
System.Web.dll!System.Web.Hosting.PipelineRuntime.InitializeApplication(System.IntPtr appContext)
[AppDomain Transition]

And the second:
Serilog.Extras.Web.dll!Serilog.Extras.Web.ApplicationLifecycleModule.Init(System.Web.HttpApplication context)
System.Web.dll!System.Web.HttpApplication.InitModulesCommon()
System.Web.dll!System.Web.HttpApplication.InitInternal(System.Web.HttpContext context, System.Web.HttpApplicationState state, System.Reflection.MethodInfo[] handlers)
System.Web.dll!System.Web.HttpApplicationFactory.GetNormalApplicationInstance(System.Web.HttpContext context)
System.Web.dll!System.Web.HttpApplicationFactory.GetApplicationInstance(System.Web.HttpContext context)
System.Web.dll!System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest wr, System.Web.HttpContext context)
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(System.IntPtr rootedObjectsPointer, System.IntPtr nativeRequestContext, System.IntPtr moduleData, int flags)
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(System.IntPtr rootedObjectsPointer, System.IntPtr nativeRequestContext, System.IntPtr moduleData, int flags)

Am I doing something wrong? Or is this a bug in the ApplicationLifecycleModule?


Q: Insert to all cells when records are more than one PHP here is my big program!

note: all codes are in one page.

freinds, all thing is ok but problem is in 'while' line and when i have more than one record.

here we connect to database and fetch information about users that got service of another users.

<form name="form2" method="post" action="" accept-charset='UTF-8'>
<?php
$id=$fgmembersite->UserID();
echo "$id"; ?>

<?php
$db_host = 'localhost';
$db_name= 'site';
$db_table= 'action';
$db_user = 'root';
$db_pass = '';

$con = mysql_connect($db_host,$db_user,$db_pass) or die("خطا در اتصال به پايگاه داده");
$selected=mysql_select_db($db_name, $con) or die("خطا در انتخاب پايگاه داده");
mysql_query("SET CHARACTER SET  utf8");

$dbresult=mysql_query("SELECT tablesite.name,
                          tablesite.family,
                          tablesite.username,
                          tablesite.phone_number,
                          tablesite.email,
                          action.service_provider_comment,
                          action.price,
                          action.date,
                          job_list.job_name,
                          relationofaction.ind
                   FROM  $db_table
                   INNER JOIN job_list
                   on job_list.job_id=action.job_id
                   INNER JOIN relationofaction
                   on relationofaction.ind=action.ind
                   INNER JOIN tablesite
                   on tablesite.id_user=action.service_provider_id AND action.customer_id='$id'",$con);

here prints all times that current user got service of another user. it may be 0 or n.
problem is here. when services are more that 1 and when i am trying to insert informations to table, first choose of vote and explain inserts to all cells.
each button must send information to a seprated field not all fileds!

                   while($amch=mysql_fetch_assoc($dbresult))
{?>
<?php
echo'
';
echo "نام خدمت دهنده: "."&nbsp&nbsp&nbsp".$amch["name"]." ".$amch["family"]."&nbsp&nbsp&nbsp"."شماره تماس: ".$amch["phone_number"]."&nbsp&nbsp&nbsp"."ایمیل: ".$amch["email"].'
'.

"شغل انجام شده: ".$amch["job_name"].'
'
."تاریخ انجام عملیات: ".$amch["date"].'
'
."هزینه ی کار: ".$amch["price"]." تومان".'
'
.$amch["service_provider_comment"].'
';

   echo'اگر توضیحاتی برای ارائه در این باره دارید، ارائه دهید
';
   echo'<textarea name="explain" id="explain" cols="" rows="" style="width:300 ;height:300"></textarea>'.'
';

echo'امتیاز این عملیات را ثبت نمایید:
';
echo '<select name="vote">';
echo '<option value="عالی">عالی</option>';
echo '<option value="عالی">خوب</option>';
echo '<option value="عالی">متوسط</option>';
echo '<option value="عالی">بد</option>';
echo '</select>';
echo'
';
echo '<input type="submit" name="submit" value="ارسال نظر شما"/>';

echo'
';
echo'
';
echo'
';

}

?>

here we say if user clicked on button, send informations to table. once again i say all thing for one record is ok, problem when occure that we have more than one record and i now problem is in 'while' but i do not know how fix this problem.

<?php
if(isset($_POST['submit']))
{

$db_host = 'localhost';
$db_name= 'site';
$db_table= 'action';
$db_user = 'root';
$db_pass = '';

$con = mysql_connect($db_host,$db_user,$db_pass) or die("خطا در اتصال به پايگاه داده");

mysql_query("SET NAMES 'utf8'", $con);
mysql_query("SET CHARACTER SET 'utf8'", $con);
mysql_query("SET character_set_connection = 'utf8'", $con);

$selected=mysql_select_db($db_name, $con) or die("خطا در انتخاب پايگاه داده");
$ins ="UPDATE $db_table
SET
customer_comment='" . mysql_escape_string($_POST['explain']) . "',
vote='" . mysql_escape_string($_POST['vote']) . "'
WHERE ind=ind";
$saved=mysql_query($ins );
mysql_close($con);

echo '';
echo '';
}
?>

this is a forms of a person that have 3 forms

and here is my table after sending

as you see we have repetetive records but where customer_id=37 there is not a problem because that user hasve just a record.
tables:

tablesite:

1   id_user     int(11)
2   name    varchar(128)    utf8mb4_persian_ci
3   family  varchar(128)    utf8mb4_persian_ci
4   email   varchar(64)     utf8mb4_persian_ci
5   phone_number    varchar(16)     utf8mb4_persian_ci
6   username    varchar(16)     utf8mb4_persian_ci
7   password    varchar(32)     utf8mb4_persian_ci
8   confirmcode     varchar(32)     utf8mb4_persian_ci

relation

1   user_name   varchar(255)    utf8mb4_persian_ci
2   job_id  int(255)
3   comments    varchar(255)
4   user_id     int(255)

RelationOfaction

1   service_provider_id     int(20)
2   customer_id     int(20)
3   ind     int(20)

action

1   job_id  int(11)
2   service_provider_id     int(10)
3   customer_id     int(10)
4   date    date
5   price   int(255)
6   vote    varchar(255)    utf8mb4_persian_ci
7   service_provider_comment    varchar(255)    utf8mb4_persian_ci
8   customer_comment    varchar(255)
9   ind     int(10)

A: I would advise wrapping each portion in its own form:
<?php
$id = $fgmembersite->UserID();
echo "$id";
$db_host = 'localhost';
$db_name= 'site';
$db_table= 'action';
$db_user = 'root';
$db_pass = '';

$con = mysql_connect($db_host,$db_user,$db_pass) or die("خطا در اتصال به پايگاه داده");
$selected=mysql_select_db($db_name, $con) or die("خطا در انتخاب پايگاه داده");
mysql_query("SET CHARACTER SET  utf8");

$dbresult=mysql_query("SELECT tablesite.name,
    tablesite.family,
    tablesite.username,
    tablesite.phone_number,
    tablesite.email,
    action.service_provider_comment,
    action.price,
    action.date,
    job_list.job_name,
    relationofaction.ind
    FROM $db_table
    INNER JOIN job_list
    ON job_list.job_id=action.job_id
    INNER JOIN relationofaction
    ON relationofaction.ind=action.ind
    INNER JOIN tablesite
    ON tablesite.id_user=action.service_provider_id
    AND action.customer_id='$id'", $con);
$i = 1;
while($amch=mysql_fetch_assoc($dbresult)){
    echo "<form id='form_$i' method='post' action='{$_SERVER['PHP_SELF']}' accept-charset='UTF-8'>\r\n";
    echo '
';
    echo "نام خدمت دهنده: "."&nbsp&nbsp&nbsp".$amch["name"]." ".$amch["family"]."&nbsp&nbsp&nbsp"."شماره تماس: ".$amch["phone_number"]."&nbsp&nbsp&nbsp"."ایمیل: ".$amch["email"].'
'
    ."شغل انجام شده: ".$amch["job_name"].'
'
    ."تاریخ انجام عملیات: ".$amch["date"].'
'
    ."هزینه ی کار: ".$amch["price"]." تومان".'
'
    .$amch["service_provider_comment"].'
';
    echo 'اگر توضیحاتی برای ارائه در این باره دارید، ارائه دهید
';
    echo '<textarea name="explain" id="explain" cols="" rows="" style="width:300 ;height:300"></textarea>'.'
';
    echo 'امتیاز این عملیات را ثبت نمایید:
';
    echo '<select name="vote">';
    echo '    <option value="عالی">عالی</option>';
    echo '    <option value="عالی">خوب</option>';
    echo '    <option value="عالی">متوسط</option>';
    echo '    <option value="عالی">بد</option>';
    echo '</select>';
    echo '
';
    echo '<input type="submit" name="submit" value="ارسال نظر شما"/>';
    echo '
';
    echo '
';
    echo '
';
    echo "</form>\r\n";
    $i++;
}
?>

You will find a number of little fixes in this code. This will result in a number of forms, each with a unique ID, posting to the same place.

A: With respect to @Twisty answer, I would like to come with my final solution to your submission problem.
First of all we need to define which raw to be updated, therefore you need to tell your update statement which ind to be updated.
To do that we need to pass ind in out submission form to out update statement, we added a hidden input field and pass out ind value like this.
<input type="hidden" name="ind" value="' . $amch["ind"] . '">;

Next we need to fetch the value and update our data by adding following:
($_POST['ind'])

So the final solution will look like this:
echo '</select>';
echo '<input type="hidden" name="ind" value="' . $amch["ind"] . '">'; //new line
echo '
';
echo '<input type="submit" name="submit" value="ارسال نظر شما"/>';
echo '
';
echo '
';

and in your update statement:
$ins = "UPDATE $db_table
        SET
        customer_comment='" . mysql_escape_string($_POST['explain']) . "',
        vote='" . mysql_escape_string($_POST['vote']) . "'
        WHERE ind=".($_POST['ind']); // to define the ind value

And wala, it works.
NOTE:
Just be a ware of, I used the updated code of @Twisty and the final solution on it.


Q: Symfony, How to pass a variable to the path? I need to pass the var 'busqueda' for the path, if instead of using the var I put text if it works, but to shove the variable tells me there.
JavaScript code in twig.
var busqueda = document.getElementById('search_keywords').value;

xmlhttp.open("GET","{{path('searchCorreos', {'page': thisPage, 'search': busqueda } )}}",true);
xmlhttp.send();

A: Since it's a GET request, this should work:
var busqueda = document.getElementById('search_keywords').value;

xmlhttp.open("GET","{{ path('searchCorreos', {'page': thisPage}) }}&search=" + busqueda,true);
xmlhttp.send();

A: If you run into this problem more often (needing to append javascript variables to symfony generated paths/urls) you can make use of the FOSJsRoutingBundle: https://github.com/FriendsOfSymfony/FOSJsRoutingBundle
This allows you to do the following in your javascript source:
var busqueda = document.getElementById('search_keywords').value;
var path = Routing.generate('searchCorreos', { page: 'thisPage', search: busqueda });

xmlhttp.open("GET", path, true);
xmlhttp.send();


Q: Casting DataRow value into float I'm working with DataRow and I want to divide every value in the row with a number(taken from a cell from the same row). I've been searching ways to convert the values into float, like from this thread, but casting gives me "Specified cast is not valid" error.
List<DataTable> tblsol = new List<DataTable>();
DataTable now = tblsol.Last();

while (true)
        {
            DataRow fb = now.Rows[v];
            DataRow fb2 = now.Rows[w];
            float akun = (float)fb[fb.Table.Columns.Count - 1] /
            (float)fb[u];
            if (akun > (float)fb2[fb2.Table.Columns.Count - 1] /
            (float)fb2[u])
            {
                if (w == now.Rows.Count - 1) { v = w; break; }
                else { v++; w++; }
            }
            else
            {
                if (w == now.Rows.Count - 1) { break; }
                else { w++; }

            }
        }

        DataRow bk = now.Rows[v];

        float angkun = Convert.ToSingle(bk[u]);
        for (int dc = 1; dc < now.Columns.Count;dc++)
        {
            bk[dc] = Convert.ToSingle(bk[dc]) / angkun;
        }

I used 2 methods to convert the value into float (using Convert.toSingle and casting), but both ways gave me error. Is there anything else I can do? Or maybe is there something wrong in my code?
p.s. tblSol is not empty and all variables are already declared.

A: try float.Parse, but you need to convert the datarow to dynamic/string type for it to be compatible:
var test = (dynamic)fb[fb.Table.Columns.Count - 1];
float boat = float.Parse(test);

Or something similar using float.Parse

A: You can try after converting it to String like this,
float akun = float.Parse(fb[fb.Table.Columns.Count - 1].ToString()) /
        float.Parse(fb[u].ToString());

A: As noted in my comment, try casting the relevant columns to Decimal first. It is one of the explicitly supported DataTypes when accessing data from columns of DataRow instances; the valid types are listed in the MSDN DataColumn Reference page


Q: Pdf file in Asymptote I know that some tags do not correspond but I wanted to draw your attention to this question. I made two graphics in asymptote.ualberta.ca/, but I want to download them as pdf file, but it keeps loading infinitely, that does not happen if I try to download it as png. Does anyone else have this problem or is it that maybe the problem is my machine? Any way to solve this problem in case the problem is located in my code?
First:
settings.render=8;
import graph3;
import palette;

currentprojection=orthographic(1,1,0.3);
//currentlight.background = gray(0.7);

typedef triple newtriple(pair);
// https://en.wikipedia.org/wiki/Hyperboloid
newtriple f(real a, real b, real c)
{
  return new triple(pair k){
    real u=k.x,v=k.y;
    real x,y,z;
    x=a*cosh(v)*cos(u);
    y=b*cosh(v)*sin(u);
    z=c*sinh(v);
    return (x,y,z);
  };
}
triple F(pair z){ return f(1,1,1)(z); }

// Gauss map
triple g(pair z)
{
  real u=z.x, v=z.y;
  triple U=(-cosh(v)*sin(u),cosh(v)*cos(u),0);
  triple V=(sinh(v)*cos(u),sinh(v)*sin(u),cosh(v));
  return 1.5*cross(U,V)/abs(cross(U,V));
}

// https://trecs.se/hyperboloidOfOneSheet.php
path3 vector(pair z) {
  real u=z.x, v=z.y;
  real a=1, b=1, c=1;
  real x,y,z;
  x=-b*c*cosh(v)^2*cos(u);
  y=-a*c*cosh(v)^2*sin(u);
  z=a*b*sinh(v)*cosh(v);
  return O--(-(x,y,z)/sqrt(x^2+y^2+z^2));
}

size(13cm);

surface sf=surface(F,(0,-1.5),(2pi,1.5),40,Spline);
//sf.colors(palette(sf.map(zpart),Rainbow()));
draw(sf,RGB(0,153,216),render(merge=true));
label("$(\mathcal{H})$",(-1,2.2,2.7),dir(45));
add(vectorfield(vector,F,(0,-1.5),(2pi,1.5),10,0.5,red,render(merge=true)));
xaxis3(Label("$x$",EndPoint),0,3.5,Arrow3);
yaxis3(Label("$y$",EndPoint),0,3.5,Arrow3);
zaxis3(Label("$z$",EndPoint),0,3,Arrow3);
pair z=(pi/3,1);
dot("$P$",F(z),dir(-10),white+3bp);
draw(Label("$N(P)$",EndPoint,LeftSide),shift(F(z))*vector(z),white,Arrow3);

transform3 t=shift(5*(Y-X));
surface sg=surface(g,(0,-1.5),(2pi,1.5),20,Spline);
//sg.colors(palette(sg.map(zpart),Rainbow()));
draw(t*sg,RGB(231,76,60),render(merge=true));
label("$N\left(\mathcal{H} \right)$",t*(-.5,0.5,1.2),dir(45));
dot(t*(0,0,1.5/sqrt(2)),white+3bp);
draw(Label("$x$",EndPoint),t*((0,0,0)--(3.5,0,0)),Arrow3);
draw(Label("$y$",EndPoint),t*((0,0,0)--(0,3.5,0)),Arrow3);
draw(Label("$z$",EndPoint),t*((0,0,0)--(0,0,3)),Arrow3);

draw(Label("$N$",Relative(.5),N),subpath((0,0,0)--t*(0,0,0),0.4,0.6),Arrow3);

label("$\frac{1}{\sqrt{2}}$",t*(0.9,0,1.4),dir(45));

Second:
settings.render=8;
import graph3;
import palette;

currentprojection=orthographic(1,1,0.3);
//currentlight.background = gray(0.7);

typedef triple newtriple(pair);
// https://en.wikipedia.org/wiki/Hyperboloid
newtriple f(real a, real b, real c)
{
  return new triple(pair k){
    real u=k.x,v=k.y;
    real x,y,z;
    x=-a*u;
    y=b*v;
    z=c*exp(u)*sin(v);
    return (x,y,z);
  };
}
triple F(pair z){ return f(1,1,1)(z); }

// Gauss map
triple g(pair z)
{
  real u=z.x, v=z.y;
  real x,y,z;
  x=exp(u)*sin(v);
  y=exp(u)*cos(v);
  z=sqrt(1+exp(2*u));
  return -7*(x,y,-1)/z;
}

// https://trecs.se/hyperboloidOfOneSheet.php
path3 vector(pair z) {
  real u=z.x, v=z.y;
  real a=1, b=1, c=1;
  real x,y,z;
  x=-b*c*exp(u)*sin(v);
  y=-a*c*exp(u)*cos(v);
  z=a*b*sqrt(1+exp(2*u));
  return O--(-(x,y,-1)/z);
}

size(480,400,false);

surface sf=surface(F,(-10,-12),(3,6),40,Spline);
//sf.colors(palette(sf.map(zpart),Rainbow()));
draw(sf,RGB(0,153,216),render(merge=true));
add(vectorfield(vector,F,(-10,-12),(3,6),10,2.5,red,render(merge=true)));
//xaxis3(Label("$x$",BeginPoint),0,7,Arrow3);
draw(Label("$x$",EndPoint),(12,0,0)--(-12,0,0),Arrow3);
yaxis3(Label("$y$",EndPoint),0,12,Arrow3);
zaxis3(Label("$z$",EndPoint),-18,22,Arrow3);
label("$\mathcal{H}$",(-.5,5.5,18),dir(45));

transform3 t=shift(20*(Y-X));
surface sg=surface(g,(-2.7,-12),(3,6),20,Spline);
//sg.colors(palette(sg.map(zpart),Rainbow()));
draw(t*sg,RGB(231, 76, 60),render(merge=true));
label("$N\left(\mathcal{H} \right)$",t*(-.5,6,6),dir(45));
draw(Label("$x$",EndPoint),t*((0,0,0)--(12,0,0)),Arrow3);
draw(Label("$y$",EndPoint),t*((0,0,0)--(0,12,0)),Arrow3);
draw(Label("$z$",EndPoint),t*((0,0,0)--(0,0,13)),Arrow3);
//dot(Label("$(0,0,1)$",black),t*(0,0,7),dir(135),white+5bp);
label("$(0,0,1)$",t*(.5,0,7),dir(135));

draw(Label("$N$",Relative(.5),N),subpath((0,0,0)--t*(0,0,0),0.4,0.6),Arrow3);

A: I just updated asymptote.ualberta.ca to the latest development version
(which will soon released as Asymptote 2.71) and confirmed that your first example works fine.


Q: What is the scope of a namespace alias in C++? Does a C++ namespace alias defined inside a function definition have a block, function, file, or other scope (duration of validity)?

A: It's a block duration of validity. E.g If you define a namespace alias as below, the namespace alias abc would be invalid outside   {...} block.

 {
    namespace abc = xyz;
    abc::test t;  //valid
 }
  abc::test t;  //invalid

A: The scope is the declarative region in which the alias is defined.

A: It would have the scope of the block in which it was defined - likely to be the same as function scope unless you declare the alias inside a block within a function.

A: I'm fairly certain that a namespace alias only has scope within the block it's created in, like most other sorts of identifiers. I can't check for sure at the moment, but this page doesn't seem to go against it.

A: As far as I know, it's in the scope it's declared. So, if you alias in a method, then it's valid in that method, but not in another.

A: Take a look at http://en.wikibooks.org/wiki/C++_Programming/Scope/Namespaces

A: It is valid for the duration of the scope in which it is introduced.
Take a look at http://en.cppreference.com/w/cpp/language/namespace_alias, I trust the explanation of cppreference, it's much more standard.


Q: Find position of a node using xpath using attributes How can I get the position of a node based on a certain attribute value?  The following post shows how to do this with elements:
Find position of a node using xpath
So if we change the example xml in the post mentioned above to:
<a>
    <b val="zyx" />
    <b val="wvu" />
    <b val="tsr" />
    <b val="qpo" />
</a>

How would I get the position of a/b[@val = 'tsr']?

A: Should be almost exactly the same:
count(a/b[@val='tsr']/preceding-sibling::*)+1

Example usage...
XSLT 1.0
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="/">
    <xsl:value-of select="count(a/b[@val='tsr']/preceding-sibling::*)+1"/>
  </xsl:template>

</xsl:stylesheet>

Output:
3


Q: get_the_terms issue on foreach loop I want to show taxonomy name in post. I use foreach loop but it does not show any thing to me.
here is my code.
<?php

    global $post;
        $foo_home_url = site_url();

        $url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

        if(strpos($url, 'foo_cat')){
            $foo_bc_cat = get_the_terms( $post->ID , FOO_POST_TAXONOMY );
    ?>

<a href="<?php echo $foo_home_url; ?>">Home

    <?php
                    foreach($foo_bc_cat as $foo_tax_cat){
    ?>

<a href="<?php echo get_term_link($foo_tax_cat->slug, FOO_POST_TAXONOMY) ?>"><?php echo $foo_tax_cat->name ?>

    <?php
                    }
    ?>

    <?php
        }
    ?>

Any idea.

A: use this code
<?php
global $post;
    $foo_home_url = site_url();

    $url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

    if(strpos($url, 'foo_cat')){
        $foo_bc_name = get_queried_object()->name;
?>

<a href="<?php echo $foo_home_url; ?>">Home

<a href="<?php echo get_term_link($foo_tax_cat->slug, FOO_POST_TAXONOMY) ?>"><?php echo $foo_bc_name; ?>

<?php
    }
?>

instead of this code
<?php

    global $post;
        $foo_home_url = site_url();

        $url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

        if(strpos($url, 'foo_cat')){
            $foo_bc_cat = get_the_terms( $post->ID , FOO_POST_TAXONOMY );
    ?>

<a href="<?php echo $foo_home_url; ?>">Home

    <?php
                    foreach($foo_bc_cat as $foo_tax_cat){
    ?>

<a href="<?php echo get_term_link($foo_tax_cat->slug, FOO_POST_TAXONOMY) ?>"><?php echo $foo_tax_cat->name ?>

    <?php
                    }
    ?>

    <?php
        }
    ?>


Q: Expo thows error that I need to run pod install I get an error message when trying to " import Realm from "realm" "
The error message:

Error: Missing Realm constructor. Did you run "pod install"? Please
see
https://realm.io/docs/react-native/latest/#missing-realm-constructor
for troubleshooting

Running on Android 13 SDK (latest from Android Studio) through the command "expo start". I get the error, but I cant fix it since im not on Mac, and it also shouldnt require pods, since Im also running it on Android and not iOS. (iOS throws the same error).
The error message also refers to a non-existing website which is very helpful :) Thank you MongoDB team...
Expo SDK v. 44.0.0
realm v. 10.17.0 (latest?)
My goal is to make an offline-first database application and its not going so well...


Q: Problems-solving in Equations The distance between the two cities A and B is 300 km, set off a car from the city a toward the city b by speed 90 km/h and set off from the city b bicycle toward a by speed of 10km/h.  if you knew that the car and the bike were based in nine in the morning. Select the time that the car and the bike are going to met ?
Equation for the 8th grade !
Please help i need to get a formulation of this equation

A: Hint:
$$ v = \frac{\mathrm{d} x}{\mathrm{d} t} = 100 $$
Integrating, you get a very simple equation of x. If you set x(0) = 0, the equation simplifies to remove the constant.
Now, x = 300. Solve for t.

A: To find the answer you are looking for in a more visual way, consider this diagram.

After 1 hour, the car (red line) traveled 90km from city A, and the bike (green line) traveled 10km from city B. Now, draw another red line that is 90 km long, right after the red one. It will go from 90km to 180km. Then, draw another green line that is 10km long, right after the green one. It will go from 290km to 280km. Having two lines will tell you how far they traveled after 2 hours. Keep this up until the red and green lines meet.

A: Here are two ways of tackling this:
1)
Let $e_1$ be the distance traveled by the car in $t_1$ hours.
Let $e_2$ be the distance traveled by the bike in $t_2$ hours.
When the car and the bike meet, the will have been traveling for the same amount of time (since they set off at the the same time). Then, $t_1=t_2$.
$$e_1+e_2=300km$$
$$v_{car} \, t_1 +  v_{bike} \, t_2 = 300km$$
$$90\frac{km}{h} \, t_1 +10\frac{km}{h} \, t_1  = 300km$$
$$100\frac{km}{h} \, t_1 =300km$$
$$t_1=3h$$
2) Notice that the distance between the car and the bike gets shortened by $100 \frac{km}{h}$ and you get again $100 \frac{km}{h} \, t = 300km$.
If they set off at nine, they will meet at twelve.

A: Let $d_{car}$ the distance that the car will run until it meets the bike, $d_{bike}$ the distance that the bike will run until it meets the car.
We get $d_{car}+d_{bike}=AB=300km$.
But we have $d=v\times t$ where $d$ is the distance, $v$ the velocity (speed), and $t$ the time.
Can you continue like this?


Q: Images (inside divs) stacking instead of being inline I'm trying to place a series of images on my website, and I want them to flow side by side and automatically wrap to the width of the container div. I made a separate div for each image, because I also need text to stay with each image. However, my image divs are stacking (as if there were a hard return between each one, though there isn't), rather than flowing.
I've been searching for the answer, and everything I've read says that the default positioning for a div is static, which means flow will be automatic.  But... it's not seeming to work.
Here's my HTML:

Everything Changed

 A reflection on life's contingencies.

Forever Amen

 A wedding song, written for my brother and his wife.

Friends With You

 Warm, caring friendships often happen without trying.

And here's my CSS:
#contentArea {
    margin-top: 5px;
    margin-left: 45px;
    margin-right; 45px;
    overflow: auto;
    width: 540px;
    height: 590px;
    position: relative;
    background: rgba(255, 255, 255, 0.3);
    font-family:Cambria, "Avenir Black", Futura, "Gill Sans", sans-serif;
    font-size: 0.8em;
}
#frame1 {
    background-image:url(images/frame1thumb.png);
    width:250px;
    height:217px;
}
#f1title {
    width:140px;
    height:188px;
    margin-left:55px;
    margin-right:auto;
    margin-top:70px;
    font-size:14px;
    text-align:center;
    overflow:auto;
    position:absolute;
}

(And so on for the other frames. There's styling for frame 2, 3, and so on, and the only thing that changes is the width and positioning of the text inside the frame.)
I tried typing position:static; into my CSS, under the #frame1 and it doesn't affect anything.
Thanks!

A: Okay, well first of all, here is a link to a working fiddle: jsfiddle
What you need to do is, to give every element, you want to float a float: left;
I would also give every #frame a position: relative; so that the #title's can position themselves according to their parent element.
As @Antony also pointed out, you made a syntax error with margin-right; 45px;, the first semicolon should be a regular colon!

A: I would first rethink your structure a bit. Here's how I would do it. You can use the link element itself for the thumbnail wrapper - and I would suggest you define the importance of the headings etc with heading tags. Search engines read sites like newspapers. If you don't declare importance, they wont know how to structure your site. I wouldn't use underline tag or italic tag because they are deprecated and I wouldn't use br linebreak because it's unnecessary and it's not really a line break. You can declare that in your .css file.
jsfiddle HERE
The magic is basically the float: left; but this will set you up with a more solid foundation. You see, for example - if you decided that you didn't want italics anymore - you would have to go remove all of those tags from the html. This way you only declare it in one place. Further more, styles that all of the blocks share need not be repeated. All blocks are the same I'm imagining. Mabybe they have different background-images.. but the rest is the same. Think modular.
HTML

Song Title

Tag line etc I'm guessing

Song Title

Tag line etc I'm guessing

CSS
/* moves padding inside the box -
   start your project off right */
* {
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

.content {
    padding: 1em;
}

.link-wrapper {
    position: relative;
    display: block;
    float: left;
    width:250px;
    height:217px;
    text-align: center;
    margin-right: 1em;
    text-decoration: none;
}

.link-wrapper h2 { /* heiarchy of text importance is how SEO works */
    font-weight: normal;
    text-decoration: underline;
    padding-top: 1em;

}

.link-wrapper h3 { /* heiarchy of text importance is how SEO works */
    font-weight: normal;
    font-style: italic;
}

/* to differentiate + unique classes for thumbnails */

.one {
    background-image:url(http://placehold.it/250x217/ff0066);
}

.two {
    background-image:url(http://placehold.it/250x217/99edee);
}

I hope this helps. -nouveau


Q: How to configure filebeat to read log files from multiple linux servers I need to know how to configure filebeat to read log files from multiple linux servers. I tried this for multiple windows computers and it works fine. Following is the used paths to access multiple log files from multiple windows computers in the network.
paths:
 - \\192.168.8.101\path\to\log\log.log
 - \\192.168.8.102\path\to\log\log.log
 - \\192.168.8.103\path\to\log\log.log

I want to do the same for multiple linux hosts. What is the recommended way to do that?


Q: Reading the default namespace through Roslyn API Is there a way to read the default namespace setting from the IProject interface or any other Roslyn interface? I know that I can parse the project's file but I think this should be possible using Roslyn API but I cannot find how to do that. Thanks in advance for information.

A: Unfortunately, Roslyn does not expose a way to do that at the moment, but I agree that it is something we will probably need eventually.

A: The library Microsoft.Build.Evaluation, which is, I believe, the successor of Roslyn does have this feature, but it is not easy to find.
I use the code below to obtain the default namespace.
My tests have shown that it matches the RootNamespace, stored in the .csproj file.
        private string GetDefaultNamespace(Microsoft.Build.Evaluation.Project p)
    {
        string rtnVal = "UNKNOWN_NAMESPACE";

        foreach (ProjectItemDefinition def in p.ItemDefinitions.Values)
        {
            if (def.ItemType == "ProjectReference")
            {
                foreach(ProjectProperty prop in def.Project.AllEvaluatedProperties){
                    if(prop.Name == "RootNamespace"){
                        rtnVal = prop.EvaluatedValue;
                    }
                }
            }
        }

        return rtnVal;
    }


Q: Change ganache Owner Account in WEB3J from account[0] to account[1]or account[2] I'm looking for a way to change owner of the smart contracts in java web3j as we do in web3 javascript using from:
 getMetaskAccountID: function () {
        web3 = new Web3(App.web3Provider);

        // Retrieving accounts
        web3.eth.getAccounts(function(err, res) {
            if (err) {
                console.log('Error:',err);
                return;
            }

            App.metamaskAccountID = res[0];
            if (res.length > 1){
            document.getElementById("divType").innerText = "Ganache Address"
            console.log("Using Ganache");
            App.FirstID = res[1];
            document.getElementById("account1").value = App.account1;
            App.secondID = res[2];
            document.getElementById("account2").value = App.account2;
          }else{
            document.getElementById("divType").innerText = "Using MetaMask Address"
            App.account1 = document.getElementById("account1").value;
            App.account2 = document.getElementById("account2").value;
          }

        })
    }

//using account for transaction in javascript
await contract.function(param1, param2, {from: account1});
await contract.function(param1, param2, {from: account2});

I can't find any solution regarding this for java web3j to change account for transaction.
contract.function(param1, param2).sendAsync();

It uses default account[0] for all the transactions. I want to change the owner for various transctions.
Would be nice to get a suitable answer for web3j to change account, thanks.


Q: SQL How to find which customer has rented the most films? I'm struggling with a question that said Which customer has rented the
most films?
I am doing this using the Seikila sample database in MySQL. I have something that joins my tables together and attempts to give me a count but I know its wrong just looking at the actual data in the rental table.
my code is as below
SELECT r.rental_id, cust.customer_id, count(*) as Total_Rentals
FROM rental as r
INNER JOIN customer AS cust on r.customer_id = cust.customer_id
GROUP BY cust.customer_id;

but it tells me for example customer 1 has rented 32 movies, which I know is wrong. what am I doing wrong?
since I was asked for clarification, the database I am using is:
https://dev.mysql.com/doc/sakila/en/
And I am trying to find which customer has rented the most films, I am not entirely sure what my script is actually returning.

A: Remove the column rental_id from the select list and sort the result by count(*) descending to return the top 1 row:
SELECT cust.customer_id, cust.name, count(*) as Total_Rentals
FROM rental as r
INNER JOIN customer AS cust on r.customer_id = cust.customer_id
GROUP BY cust.customer_id, cust.name
ORDER BY Total_Rentals DESC LIMIT 1

But if you only need the customer's id then there is no need for  a join:
SELECT customer_id, count(*) as Total_Rentals
FROM rental
GROUP BY customer_id
ORDER BY Total_Rentals DESC LIMIT 1

A: You need to join customer and rental, group by customer id (without rental id) and count it:
SELECT cust.customer_id, count(*) as Total_Rentals
FROM rental as r
INNER JOIN customer AS cust on r.customer_id = cust.customer_id
GROUP BY cust.customer_id;

So this code should work. If it doesn't work, that probably means that you have duplicates or other nonconventional issues.


Q: CSS: Overlay two images perfectly on all screen sizes I have two images. One is a picture that has rounded edges, the other is a picture of a round frame. I want to place the frame over the picture so that it looks like it is a single image.
I am struggling with the CSS to do this because on different screen sizes, it does not remain constant.
Here is my HTML:

My CSS:
div.image   {position: relative;}

img#profile {width: 250px;
            border-radius: 50%}

img#frame   {width: 250px;
            position: absolute;
            z-index: 100;}

I want the result to look like this (the blue is the picture #profile and the orange is the frame #frame:

In addition, this needs to stay this way regardless of the screen size so using left values does not really work.
With the above markup, the images are doing this:

How do I solve this?

A: You didn't provide any pictures. So, I used css styles. You can remove the background color and add your pic urls.
div.image {
    position: relative;
}
img#profile {
    width: 250px;
    height: 250px;
    background: blue;
    border-radius: 50%;
    z-index: 100;
    left: 10px;
    top: 10px;
    position: absolute;
}
img#frame {
    width: 270px;
    height: 270px;
    background: tomato;
    border-radius: 50%;
    z-index: -1;
}

JSFIDDLE

A: You need to fix it yourself whenever you change the size.
div.image {
position: fixed;
margin: 100px;
}
img#profile {
width: 250px;
height: 250px;
background: skyblue;
border-radius: 100%;
z-index: 100;
position: absolute;

}
img#frame {
width: 270px;
height: 270px;
background: orange;
border-radius: 100%;
z-index: -1;
position: absolute;
top:-10px;
left:-10px;
}


Q: How exactly does thermodynamic pressure relate to mechanical pressure? I would have liked to get some details on the relation between the mechanical and thermodynamical definitions of pressure. I have read that $p_\mathrm{mech}=p_\mathrm{therm}-\operatorname{div}\left(\mathbf v\right)\cdot\left(\frac2 3\cdot\mu+\lambda\right)$ (let us only consider newtonian fluids), where $\mathbf v$ is the fluid velocity field, $\mu$ is the dynamic viscosity and $\lambda$ is the bulk viscosity. To the best of my knowledge, I understand this equation and how it is derived. The problem I have with it is that the derivation I've seen (on this StackExchange question) just called $p_\mathrm{therm}$ the expression $\frac1 3\cdot\operatorname{Tr}\left(\mathbf\sigma\right)$, where $\mathbf\sigma$ is the stress tensor of the fluid. I understand $p_\mathrm{therm}$ as defined by $p_\mathrm{therm}=-\left(\frac{\partial U}{\partial V}\right)_{S,\,N=\mathrm{cst}}$ or by some other equivalent formula (using another thermodynamic potential than the internal energy $U$).
But what is the proof that $-\left(\frac{\partial U}{\partial V}\right)_{S,\,N=\mathrm{cst}}=\frac1 3\cdot\operatorname{Tr}\left(\sigma\right)$?
I find this particularly interesting as on the left hand side are only quantities that can be defined through a statistical physics approach, and on the right hand side is a quantity defined in continuum mechanics.
Usually, in introductory classes on thermodynamics, you learn the $-p\cdot\mathrm dV$ term in the thermodynamic identity $\mathrm dU=-p\cdot\mathrm dV+T\cdot\mathrm dS$ (for a number $N=\mathrm{cst}$ of particles) through the following proof: you write out the first principle for a infinitesimally small transformation ($\mathrm dU=\delta W+\delta Q$, where $\delta W$ is the work and $\delta Q$ the heat) and you state that $\delta W$ is the work of pressure forces. Thoses forces act on each surface element $\mathrm d\mathbf\Sigma$ of the system on a length $\mathrm d\mathbf l\left(\mathrm d\mathbf\Sigma\right)=\mathbf r_{\mathrm d\mathbf\Sigma}\left(t+\mathrm dt\right)-\mathbf r_{\mathrm d\mathbf\Sigma}\left(t\right)$, where $\mathbf r_{\mathrm d\mathbf\Sigma}\left(t\right)$ is the position of the surface element $\mathrm d\mathbf\Sigma$ a time $t$ relative to an arbitrary origin. Integrating, you get: $\delta W=\iint_\mathbf\Sigma-p\mathrm d\mathbf l\cdot\mathrm d\mathbf\Sigma=-p\cdot\left(\iint_\mathbf\Sigma\mathbf r_{\mathrm d\mathbf\Sigma}\left(t+\mathrm dt\right)\cdot\mathrm d\mathbf\Sigma-\iint_\mathbf\Sigma\mathbf r_{\mathrm d\mathbf\Sigma}\left(t\right)\cdot\mathrm d\mathbf\Sigma\right)=-p\cdot\left(V\left(t+\mathrm dt\right)-V\left(t\right)\right)=-p\cdot\mathrm dV$. I have several problems with this proof:

*

*It appears $p$ in this proof refers to the thermodynamical pressure, as the result $\mathrm dU=-p\cdot\mathrm dV+\dots$ indicates. In the proof though, should $p$ not be the one in $p=\frac F S$, that is, the mechanical pressure? I get that they are equal if the fluid doesn't move, but here it necessarily moves as the volume changes. I expect complications because of the out of equilibrium situation due to the transformation.

*What allows you to take $p$ out of the integral?

*You are considering a transformation where the volume changes. What if you cannot do that, because you study a system occupying a box of given volume (for example in the canonical ensemble)? In those cases, how should you make sense of the derivative $\left(\frac{\partial U}{\partial V}\right)_{S,\,N=\mathrm{cst}}$?

*This is more of an open question, but what if your system does not actually have a given bounding surface (for instance if your system is the set of all molecules of one particular type in a mix of several types of molecules) or volume? Can you still define pressure in that case, for this particular system?

That was a big question, huge thanks to anyone who can give an answer to one of the four questions or give another proof for the identity $-\left(\frac{\partial U}{\partial V}\right)_{S,\,N=\mathrm{cst}}=\frac1 3\cdot\operatorname{Tr}\left(\sigma\right)$.

A: OK.  For a Newtonian fluid, the extensive stress tensor is expressed as $$\tau_{i,j}=-p\delta_{ij}+\mu(u_{i,j}+u_{j,i})+\delta_{ij}\lambda u_{k,k}$$where p is the thermodynamic pressure $p=p_{therm}$.  The viscous stress term can be rewritten as follows:  $$\mu(u_{i,j}+u_{j,i})=2\mu\frac{(u_{i,j}+u_{j,i})}{2}=2\mu \left[\frac{(u_{i,j}+u_{j,i})}{2}-\frac{u_{k,k}}{3}\delta_{i,j}+\frac{u_{k,k}}{3}\delta_{i,j}\right]$$where $u_{k,k}$ is the divergence of the velocity vector (and also the trace of the rate of deformation tensor), and where $(u_{i,j}+u_{j,i})){2}-\frac{u_{k,k}}{3}\delta_{i,j}=\epsilon^*_{i,j}$ is the deviatoric (traceless) rate of deformation tensor.  So the equation for the viscous stress then becomes:$$\mu(u_{i,j}+u_{j,i})=2\mu \epsilon^*_{i,j}+\frac{2\mu}{3}u_{k,k}\delta_{i,j}$$So the original equation now becomes:$$\tau_{i,j}=-\left(p-\frac{2\mu}{3}u_{k,k}-\lambda u_{k,k}\right)\delta_{i,j}+2\mu \epsilon^*_{i,j}$$ The term in brackets is the isotropic part of the stress tensor and the term involving the deviatoric rate of deformation tensor is the anisotropic part.  In this equation, the term in parenthesis is called the (isotropic) mechanical pressure $$p_{mech}=p-\frac{2\mu}{3}u_{k,k}-\lambda u_{k,k}$$


Q: How can we fliter data from header's TextInput on onChangeText in react native? I have custom header which has TextInput for searching in StackNavigator.How can i get result on onChangeText of TextInput on particular class,
  here is demo:
const StackNavigator = createStackNavigator({
 TABS: {
    screen: TabNav,
    navigationOptions: ({ navigation }) => {
      return {
        header:
          <View style={{ backgroundColor: '#025281', flexDirection:
         'row', alignItems: 'center', height: 60 }}>
            <TouchableOpacity
              style={{ paddingLeft: 5 }}>
              <Image source={require(back_arrowimg)} style={{
                width: 25, height: 25, resizeMode: 'contain' }}/>
            </TouchableOpacity>
    <TextInput
              style={{ color: 'white', paddingLeft: 15, }}
              type='text'
              placeholder={headerTitle}
              onChangeText={this.loadUsers}
            />
          </View>,
      }
    }   },

  [ConstFile.SCREEN_TITLES.WELCOME_SEARCH]: {
    screen: WELCOMESEARCH,
    navigationOptions: {
      header: null
    }   }, } )

A: from navigationOption you can not do anything to other screen,
so what you can do is, move your header code into another file and use it as component in TabNav
something like this,
let say Header.js
<View style={{ backgroundColor: '#025281', flexDirection:
         'row', alignItems: 'center', height: 60 }}>
    <TouchableOpacity
              style={{ paddingLeft: 5 }}>
          <Image source={require(back_arrowimg)} style={{
                width: 25, height: 25, resizeMode: 'contain' }}/>
    </TouchableOpacity>
    <TextInput
              style={{ color: 'white', paddingLeft: 15, }}
              type='text'
              placeholder={headerTitle}
              onChangeText={this.props.loadUsers} // see this change
            />
</View>

and in your TabNav.js use header as component,
<Header
  loadUsers={(...your params)=>{
    //do your necessary stuffs to display data in this file
  }) />


Q: How to make a  as a new row using external css? I am new to stack overflow and I'm trying to make a mobile webpage from the existing desktop version webpage someone else created. Basically, I have to use same webpage for both mobile and desktop. For this specific page with table, I am trying to change the pattern of table for mobile using external style sheet.I had attached the html skeleton and css with this post. Initially, there is only one row with two  s.  I want to bring ".td2" to new  in next line. I tried a basic table in which I was able to bring down all  converted to tr worked but in this case, second  containing a table is making me hard. I tried all the way I could. I will be helpful if someone help me.

tr{
    display:table;
    width:100%;
}
.lfttbl .td1, .td2{
    display:table-row;
    border-bottom: solid 1px #2b9ed5 !important;
}

 hihi hii

A: There are a lot of bugs in your code:

*

*
 not closed!

*Using tables for layout.

*More worse: Using nested tables.

Going ahead with your layout, I was able to make these corrections to make it work in CSS.

tr{
    display:table;
    width:100%;
}
.lfttbl .td1, .td2{
    display:table-row;
    border-bottom: solid 1px #2b9ed5 !important;
}

.td1 {
  display: block;
  background: #f00;
}

 hihi hii

A: You must close your
hihi hi and use display: block; on the td.
Check this:

tr{
    display:table;
    width:100%;
}
.lfttbl .td1, .td2{
    display:block;
    border-bottom: solid 1px #2b9ed5 !important;
}

 hihi hii

Lorem ipsum

A: So, here is what I was struggling on. After several trials and errors, I came to know it works in desktop version now but not in mobile devices. I had attached my code and css on which I was working (Initially "edit" and "delete" were in different td). Now I don't know why its not working on mobo device. I know I can't use if else statement in css (either for desktop or for mobile).

#shipIMtd, #shipIMrighttd1, #shipIMrighttd2{display:block;}
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0;">
    <link href="mno.css" rel="stylesheet" type="text/css" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<META Name="Robots" Content="noindex">

           Addresses

<input id="shipIMtitlebtn" type="button"  value="+ Add">

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi.

    <form name="editship" action="abc.asp" method="post" />
     <input type="hidden" name="shipID" value="shpid">
     <input id="shipIMeditbtn" type="submit" value="Edit">

    </form>

    <form name="deleteship" action="xyz.asp" method="post">
     <input type="hidden" name="shipID" value="shpid" />
     <input type="hidden" name="asktype" value="firstask">
     <input id="shipIMdelbtn" type="submit" value="Delete">
    </form>

.


Q: Introductive section at the beginning of a chapter I am writing my thesis and at the beginning of each chapter I would like to make a general overview and come up with a page as shown in the attached image. Does anyone know what is the right command to use?
Thank you all for your help :)


Q: SQL Server : Join from multiple table references Forgive me for adding yet another JOIN question, but I've been stumped all day and haven't been able to find a good answer for this.
I'm trying to join 4 tables, such that they look like below:
QuarterID    ReviewID    SaleID    PotentialID
    1           1           1          1
    1           2           2         null
    1           3         null         2
    1           4         null        null

The relevant info from the tables is below
Sale:
  QuarterID
  ReviewID
  IsArchived

Potential:
  QuarterID
  ReviewID
  IsArchived

Quarter:
  ID

Review:
  ID

We can have multiple Sales and Potentials associated with one Quarter-Review pairing, but only one Sale and one Potential will have IsArchived = 0 for the given Quarter-Review pairing.
SELECT
    quarter.id    AS QID,
    review.id     AS RID,
    Sales.id      AS SID,
    Potentials.id AS PID
FROM
    dbo.quarter
JOIN
    (SELECT *
     FROM dbo.sale
     WHERE isarchived = 0) AS Sales ON Sales.quarterid = quarter.id
JOIN
    (SELECT *
     FROM dbo.potential
     WHERE isarchived = 0) AS Potentials ON Potentials.quarterid = quarter.id
JOIN
    dbo.review ON dbo.review.id = Sales.reviewid
               AND dbo.review.id = Potentials.reviewid
ORDER BY
    quarter.id, rid

Using the above (there are some unnecessary columns, I know), I've managed to get the joins so that they get the 1st condition (where its all the Sales and Potentials that are in the same Quarter and Review combination, but I also want to see if there is a Quarter/Review combo with only a Sale and no Potential, if there is a Q/R combo with only a Potential and no Sale, and just every Quarter and Review combo, since there are only a few Q/R combos that have both a Sale and Potential, with almost all of the Q/R combos only having a Sale or Potential.
I guess overall the difficulty comes from needing to get the join from two intermediate tables. I can join Quarter, Sale, and Review easily, but having the Potential table joining on the same fields (ReviewID, QuarterID) as Sale is making me only get the AND, and I can't figure out an OR. I've been throwing around ORs for hours trying to get the right sequence without any luck. Help?
--Edit to include sample data--
Quarter
  ID
  1
  2

Review
  ID     (Other fields, not relevant to join)
  1
  2
  3
  4
  5

Sale
  ID    ReviewID    QuarterID    isArchived (Other fields, not relevant)
  1        1           1            0
  2        2           1            1
  3        2           1            0
  4        1           2            0
  5        5           1            0
  6        5           2            0

Potential
  ID    ReviewID    QuarterID    isArchived (Other fields, not relevant)
  1        1           1            0
  2        3           1            0
  3        4           2            1
  4        4           2            0
  5        5           2            0

Joining the above sample data, I would expect the output to look like:
QuarterID    ReviewID    SaleID    PotentialID
    1           1          1           1
    1           2          3          null
    1           3         null         2
    1           4         null        null
    1           5          5          null
    2           1          4          null
    2           2         null        null
    2           3         null        null
    2           4         null         4
    2           5          6           5

But the problem I am having is I am only returning the rows like the first and last row, where there is both a Sale and Potential for a given Quarter/Review combo, and not the ones where one or many may be null.

A: Not sure if I understood your question correctly (some sample data will help) but I think you mean that you need all the combinations of Quarter and Review and then any related Sale and Potential data for each combination of Quarter and Review. If that is what you need, then try the below query:
SELECT [Quarter].ID AS QID, Review.ID AS RID, Sales.ID AS SID, Potentials.ID AS PID FROM [Quarter]
CROSS JOIN [Review]
LEFT JOIN (SELECT * FROM Sale WHERE IsArchived = 0) Sales ON [Quarter].ID = Sales.QuarterID AND [Review].ID = Sales.ReviewID
LEFT JOIN (SELECT * FROM Potential WHERE IsArchived = 0) Potentials ON [Quarter].ID = Potentials.QuarterID AND [Review].ID = Potentials.ReviewID


Q: Finding the points of contact between two convex polygons Okay, so I am trying to create a simple 2d polygon physics engine for the experience. Here is what I already know (plus sources for those who want to find out:
-How to determine if polygons are intersecting using the SAT method (http://elancev.name/oliver/2D%20polygon.htm)
-How to find the normal of the collision by finding the minimum translation axis
-How to respond to a collision via implulse
(http://chrishecker.com/Rigid_Body_Dynamics#articles)
There is one thing however that keeps eluding me. That is, how to find the points of contact between two intersecting polygons. I was going to upload a simple picture to help illustrate what I mean, but it seems like I am not able to do that yet.
Specifically what I would like help on is:
-Determining which sides and/or points are colliding
-This includes when the polygons are intersecting
-Getting a vector location of each contact point
I would really appreciate anything on this because I have been searching for a good while with no luck.
Thanks.

A: After doing some more digging I found what I was looking for. I found a rather well written example (in C#) of a technique called polygon clipping. This method finds the contact points in world coordinates. It goes through all the steps and code implementation for multiple different situations.
Here is the url: http://www.codezealot.org/archives/394


Q: -libraryjars has no effect on resulting apk, proguard
using the tools dex2jar and Java Decompiler I examined two versions of an apk file that was built in eclipse with proguard enabled.  One version of the apk was made with this command as part of proguard-project.txt file
  -libraryjars /libs/GraphView-3.1.1.jar

and in the other verson of the apk has this line commented out
looking at the resulting apk files after conversion from apk to jar and viewing them. both of the apk files are obfuscated however they are exactly the same.  so the -libraryjars command is having no effect at all?   why is the obfuscated code exactly the same in both cases?
in comparison I make two versions of apk files with other modifications and they result in different looking files.  for example I added this line to the proguard-project.txt file
  -keep class com.example.proguardwithgson.MainActivity$TestObject { *; }

and it changed the resulting code for the apk, the TestObject inner class is no longer obfuscated and is clearly readable.
if the -keep command is working, then why does the -libraryjars command not do anything?

A: The Android build process already specifies all the necessary -injars/-libraryjars/-outjars options for you. You should never specify them in your configuration file; you'd only get lots of warnings about duplicate classes.
You can find an explanation of their purpose in the ProGuard manual > Introduction.


Q: Trying to code the points on a circle I am trying to understand this:
I wrote a code for points on a circle of radius 1. Note that the first and last point intentionally coincide.
do i=1,imax
X(i,1) = COS(-2*4.0*ATAN(1.0)*(i-1)/(imax-1))
Y(i,1) = SIN(-2*4.0*ATAN(1.0)*(i-1)/(imax-1))
print *, X(i,1)**2 + Y(i,1)**2
end do

The code is supposed to be a circle, but the following figure demonstrates the plot in Mathematica. It looks to me like an ellipse. Am I doing something wrong? Or is this just the way Mathematica plots it?

The command for the plot is
ListPlot[a, PlotLabel -> "MeshPoints", AxesLabel -> {"x", "y"}, PlotRange -> {{-2, 2}, {-2, 2}}]

A: When you do ListPlot[] in Mathematica, it uses an "Auto" aspect ratio, which is something like the Golden Mean. You can see that in your plot (the ticks are closer together on the Y axis than on the X axis).
To get what you are looking for, use the option AspectRatio->1, e.g.:
ListPlot[Points, AspectRatio -> 1]
I'd post a picture for you, but stack exchange won't let me.
In any case, if you use AspectRatio in your plot, you'll see that you have a circle.
As far as the expressions you list go, why are you using -2*4.0*ATAN(1.0) rather than 2 * Pi ?
-2*4.0*ATAN(1.0) = - 2 Pi

A: It's simply a matter of your two axes not visually being the same size.  You can see that they go out to a radius of 1 in all 4 directions, which is 5 marks, but the distance between marks is different between the x axis and y axis.  Mathematically, your result is in fact a circle, it's how you're rendering it that is the problem.

A: Without seeing your plot (see my comment on your question), I would assume that mathematica hasn't given you square axes, so it is distorting the circle.  Your parameters do describe a circle.


Q: Can an SKSpriteNode Object be Searched by Name I am creating a game using Apple's SpriteKit, and I am wondering what is the most efficient way to find an SKSpriteNode object after creating it.
In one method I initialize a sprite node and assign a name to it:
SKSpriteNode* playerBody = [SKSpriteNode spriteNodeWithImageNamed:@"playerBody.png"];
playerBody.name = @"player";

Later on inside the touchesBegan:withEvent: method I want to find the previously defined sprite node again and store it so I can run actions on it. First I attempted to do this:
SKSpriteNode* body = [self childNodeWithName:@"player"];

However, I have realized that childNodeWithName: is only available in the SKNode class, not SKSpriteNode. So this does not work. What I am thinking now is that I can create an SKNode object and place my SKSpriteNode inside of it. This way I can search for the SKNode using the above method. This seems a bit convoluted, however. Is there a better way?

A: SKSpriteNode inherits from SKNode. You can use childNodeWithName.
SKSpriteNode *someSprite = [SKSpriteNode node];

[someSprite childNodeWithName:@"someChildOfSprite"];

Code for comment below asking how to cast SKNode as an SKSpriteNode:
SKSpriteNode *theChildYouWant = (SKSpriteNode*)[someSprite childNodeWithName:@"someChildOfSprite"];


Q: Python tuple duplication with * This works just fine and straight-forward:
>>> ('a',) * 3
    ('a', 'a', 'a')

But I was experimenting with tuple a little and came across this:
>>> 'a', * ('b', 'c')
    ('a', 'b', 'c')

>>> ('a',) * ('b', 'c')
    Traceback (most recent call last):
      File "<pyshell#2>", line 1, in <module>
        ('a',) * ('b', 'c')
    TypeError: can't multiply sequence by non-int of type 'tuple'

Can anybody explain how did the * make the tuple concatenate in the line 'a', * ('b', 'c')?

A: In this expression
'a', * ('b', 'c')

You have two primary things going on

*

*'a', creates a tuple with a single element 'a'

** ('b', 'c') uses extended iterable unpacking (PEP 3132)

So the result of #2 is used to continue the tuple definition from #1. To show a more intuitive example this is the same idea
>>> 'a', *range(5)
('a', 0, 1, 2, 3, 4)