text:
Q: comparing list1 and list2, remove duplicate from list2 (not working with removeAll() ) I am trying to compare two lists where I want to check for duplicates. If list1 and list2 contains the same duplicate then the duplicate from list2 should be removed.
I've been able to solve the problem if I compare two .txt file or where list1 is a .txt file while list2 is hardcoded. Thus, if:
list1 contains stuff from a .txt file (which is like a template) and list2 is fetched from another place my code won't work.
Below you can see my code:
public static String removeLinesFromTemplate(String text) throws IOException{
    final List<String> list = new ArrayList<String>();
    final List<String> list2 = new ArrayList<String>();

    // New BufferedReader.
    final BufferedReader reader = new BufferedReader(new FileReader("testing"));

    //Add all lines from the file testing to the arraylist.
    String row;
    while ((row = reader.readLine()) != null) {
       list.add(row.toLowerCase());
    }
    // Close it.
    reader.close();

    System.out.println(list);

    list2.add(text.toLowerCase());

    //If two lines matches between list2 and list, then that line will be removed from list2.
    list2.removeAll(list);

    System.out.println(list2);

    // Convert the list into string
    String listString = "";
    for (String s : list2){
        listString += s ;
    }

    return listString;
}

It seems like my list2.removeAll(list) won't work and remove the duplicates. Any ideas why, and how do I solve
I tried @SeniorJD's option3
String[] parts = text.split("\\s+");
for(String item : parts){
  list2.add(item.toLowerCase());
}

The problem still stays, example:
list1: 1 monkey, -------, (input of list1)
list2: 1 monkey, -------, asdf, (input of list2)
Issue here right now is that 1 monkey is not being removed, while "------" gets removed.
So the output of list2 is: 1 monkey, asdf,

A: Seems U don't understand how String and Collections work.
List<String> list1 = new ArrayList<>();
List<String> list2 = new ArrayList<>();

list1.add("a");
list1.add("b");

// #way1 - would not work
list2.add("a b c");
list2.removeAll(list1);

// #way2 - would work
list2.add("a");
list2.add("b");
list2.add("c");
list2.removeAll(list1);

// #way3 - would work as well
String text = "a b c";
String[] parts = text.split("\\s+");
for (String part: parts) {
    list2.add(part);
}
list2.removeAll(list1);

Why?
String is a set of chars, List is a set of Objects (in our example - String Objects). When U try #way1, the list2 looks for the equal object it already has. "a b c" not equals to "a", or "b". So it is not working as U expected. Try #way2 and debug it, and learn the Java Core first.

A: Your list2 contains only one element(the whole text). The elements of list are lines from the parsed file. So in order for the removeAll to work you need to transform the the text variable into a list of lines.


text:
Q: How to increase brightness in smaller steps? Is there a way to adjust lighting step ? I have Lenovo L520, and Fn + Light Up or Down adjusts by 20%, how can I adjust the step to 10% ? it will help me fine tune lighting at my dark room.

A: There is a file in Ubuntu which stores numerical integer value of brightness.
you will find 3 files in the directory /sys/class/backlight/<VGA>directory
replace directory with intel_backlight for intel cards.
You will find the max brightness value in max_brightness file and according to that value set the brightness in brightness file.

A: For Xubuntu LTS
Firstly, install xbacklight
$ sudo apt install xbacklight

Secondly, check whether you have control over the backlight.
$ xbacklight -1
$ xbacklight +5

Should these commands result in a No outputs have backlight property error, then follow these remediating steps before proceeding.

Once xbacklight -1 and xbacklight +1 work from the command line, proceed with assigning these commands to respectively the XF86MonBrightnessDown and XF86MonBrightnessUp keys. This is done by hitting those keys when asked by the Settings → Keyboard → Application Shortcuts application.
Finally, reboot for these changes to take effect.

A: You can install xcalib and then type the command:
xcalib -co 50 -a

Use xcalib -h for help regarding it's options.

A: As Colin Ian King said, the levels of brightness are hardware related.
Some laptop screens have 8 levels of brightness and new ones have 16 levels.
On Windows OSes you can change the levels with 1% steps, but they will be rounded to the nearest hardware level. It depends on the screen type.

A: On Ubuntu 16.04, with Intel onchip graphics (i5) under LXQt, it is sufficient to assign xbacklight commands to the brightness function keys XF86MonBrightness(Down|Up) using the global key shortcut settings. These seem to override the defaults even if /sys/module/video/parameters/brightness_switch_enabled is set to Y, while the original functionality on virtual terminals is retained.

An alternative to the original xbacklight would be acpilight, but unfortunately this isn't available as Ubuntu package. As it doesn't depend on an X display running, you can also associate it with ACPI button events and use it from the console. Additionally it can store the current brightness on shutdown and restore it on boot.

A: My solution was to install 'xbacklight'
Then I created keyboard shortcuts such as

*

*ctrlshift+ with command xbacklight +5

*ctrlshift- with command xbacklight -5
So when you use those shortcuts they call the related command
however I could not replace the system inbuilt brightness buttons to use these commands
You can use almost any keyboard shortcut button combination you like with xbacklight.

A: For me xbacklight did not work (EDIT: probably because I did not reboot my machine), therefore I created my own script which uses the built-in gsd-backlight-helper.
This script uses smaller steps, especially when the screen is quite dark already.
Step 0: check if it works (optional)
To see if it works you could try:
pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper --get-brightness

This should output a number.
Step 1: save script
Save the following script in an .sh file, for instance in /home/me/scripts/brightness.sh.
#!/bin/bash

max=$(pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper --get-max-brightness)
cur=$(pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper --get-brightness)
if [ $(($max/$cur)) -ge 25 ]
then
    step=$((max/300+1))
else if [ $(($max/$cur)) -ge 5 ]
    then
        step=$((max/50+1))
    else
        step=$((max/20+1))
    fi
fi
case "$1"
in
+) new=$((cur+step));;
-) new=$((cur-step));;
esac
pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper --set-brightness $new

Step 2: assign shortcuts
Open Keyboard Shortcuts from the Settings menu and assign shortcuts:
name:     Darker
command:  sh /home/me/scripts/brightness.sh -
shortcut: Super + F5

name:     Brighter
command:  sh /home/me/scripts/brightness.sh +
shortcut: Super + F6

A: Install xbacklight by opening a terminal with Ctrl+Alt+T shortcut and type this:
sudo apt-get install xbacklight

then after installation, type these commands in terminal:
xbacklight = 10
xbacklight = 20
xbacklight = 5

this may help.

A: The brightness levels are generally under ACPI control with the levels defined in firmware. For example the ACPI control method _BCL  "Query List of Brightness Control Levels Supported" informs the kernel how many brightness levels are supported.  You can't realistically change this.

A: In my case (Lenovo T500) the problem is, that the brightness regulating key-press is applied twice - once by using the Xwindows, but also independently in the lower level, by kernel's graphic driver itself. So the brightness steps are twice as big as usual.
The working solution is to deny the low-level functionality, by adding this line to /etc/rc.local (just before the line with 'exit 0'):
echo -n 0 > /sys/module/video/parameters/brightness_switch_enabled

This way it will perfectly work in logged-in X session, unfortunately it will remove the key-press brightness regulation functionality in all other cases (console terminal, X login screen etc).

A: Official documentation:
https://www.x.org/archive/X11R7.5/doc/man/man1/xbacklight.1.html

inc percent
Increases brightness by the specified amount.
dec percent
Decreases brightness by the specified amount.

Example:
xbacklight -inc 10%
xbacklight -dec 10%

A: Brightness cannot controlled with large precision. I'm afraid that you're stuck with those brightness levels. To be sure, try controlling the brightness using these terminal commands.

A: You could try setting it manually. First you have to get the PCI-ID of the VGA device:
lspci

Then try this (in my case the PCI-Device is 00:02.0)
sudo setpci -s 00:02.0 f4.b=FF

The 2 letters at the end of the Line set the new brightness ranging from 00-FF (0-255)

A: If you are using Nvidia Graphic card..you can easily use my new method of brightness changing,and edit values in Code.. theres two files and two options within each one.
find these two lines:
if ( $value > 0.0) { $value = $value - 0.30 };
if ( $value2 > 1.1) { $value2 = $value2 - 0.08 };

change values of ($value > 0.0) & ( $value2 > 1.1)
and see whats happens!
meanwhile if you dont want to change values and wish to use my method originally you can
change brightness in a wide range and 5 steps.
wish you like it
link of method: https://askubuntu.com/a/179063/82136

A: If you're on KDE, you can simply hover your cursor over the "Battery and Brightness" menu from your system tray and try to slowly scroll upwards or downwards to increment or decrement the brightness.

A: On modern Gnome environment you can achieve fine-control effect with mouse scroll:
If you have smooth-scroll touchpad, position mouse pointer over brightness slider from top-right menu and perform fine two-finger scroll to adjust brightness with tiniest steps.

A: Hold down Ctrl while increasing/decreasing the brightness. Increases in steps of 1.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How can I correctly display all the elements of 2D array that have even neighbors? I wrote a program that finds and displays all the elements in the 2D array, which have all neighbors(left, top, right, bottom) - even. I tried to put in an if, but the result is wrong. I think because it checks for non-existent elements, if the current element is on the edge. How can I fix it? Thank you in advance.
#include <stdio.h>
#define n 5
#define m 9

int main()
{
    int i, j;

    int array[n][m] = {
            {-1, 4, 12, 2, 10, -1, 8, 7, 6},
            {18, 3, 2, 0, 0, 10, 10, 0, 0},
            {9, 18, 3, 12, 5, 18, 4, 7, 0},
            {6, 3, 11, 5, 11, 1, 1, 1, 22},
            {8, 7, 46, 20, 1, 2, 3, 4, 5},
    };

    // int m,n;
    // printf("Rows and Columns: \n");
    // scanf("%d %d", &n, &m);

    // int array[n][m];

    // printf("Enter elements: \n");
    // for (i = 0; i < n; i++)
    //   {
    //           for (j = 0; j < m; j++)
    //           {
    //                scanf("%d", &array[i][j]);
    //            }
    // }
    printf("Matrix: \n");
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            printf(" %3d", array[i][j]);
        }
        printf("\n");
    }

    printf("Elements with all neighbors even are: \n");
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            if ((array[i-1][j] % 2) == 0 && (array[i+1][j] % 2) == 0 && (array[i][j-1] % 2) == 0 && (array[i][j+1] % 2) == 0)
            {
                printf("a[%d][%d]= %2d\n",i,j, array[i][j]);}
        }
    }
}

A: first, you have to check for particular element of array that neighbor exists or not by applying condition as shown in below code and then you have to check for the even number.
#include <stdio.h>
#define n 5
#define m 9

int main()
{
    int i, j;

    int array[n][m] = {
            {-1, 4, 12, 2, 10, -1, 8, 7, 6},
            {18, 3, 2, 0, 0, 10, 10, 0, 0},
            {9, 18, 3, 12, 5, 18, 4, 7, 0},
            {6, 3, 11, 5, 11, 1, 1, 1, 22},
            {8, 7, 46, 20, 1, 2, 3, 4, 5},
    };

    // int m,n;
    // printf("Rows and Columns: \n");
    // scanf("%d %d", &n, &m);

    // int array[n][m];

    // printf("Enter elements: \n");
    // for (i = 0; i < n; i++)
    //   {
    //           for (j = 0; j < m; j++)
    //           {
    //                scanf("%d", &array[i][j]);
    //            }
    // }
    printf("Matrix: \n");
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            printf(" %3d", array[i][j]);
        }
        printf("\n");
    }

    printf("Elements with all neighbors even are: \n");
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            if( n==1 && m==1 ){
                printf("No neighbour exist");
            }

            else if( i==0 && j ==0 ){
                if ((array[i+1][j] % 2) == 0 && (array[i][j+1] % 2) == 0)
                printf("a[%d][%d]= %2d\n",i,j, array[i][j]);

            }
            else if( i==0 && j == (m-1) ){
                if ((array[i+1][j] % 2) == 0 && (array[i][j-1] % 2) == 0)
                printf("a[%d][%d]= %2d\n",i,j, array[i][j]);
            }

            else if( i== (n-1) && j==0 ){
                if ((array[i-1][j] % 2) == 0 && (array[i][j+1] % 2) == 0)
                printf("a[%d][%d]= %2d\n",i,j, array[i][j]);
            }

            else if( i== (n-1) && j==8 ){
                if ((array[i-1][j] % 2) == 0 && (array[i][j-1] % 2) == 0)
                printf("a[%d][%d]= %2d\n",i,j, array[i][j]);
            }

            else if( i == 0 ){
                if ((array[i+1][j] % 2) == 0 && (array[i][j-1] % 2) == 0 && (array[i][j+1] % 2) == 0)
                printf("a[%d][%d]= %2d\n",i,j, array[i][j]);
            }

            else if ( j == 0 ){
                if ((array[i+1][j] % 2) == 0 && (array[i-1][j] % 2) == 0 && (array[i][j+1] % 2) == 0)
                printf("a[%d][%d]= %2d\n",i,j, array[i][j]);
            }

            else if ( j == ( m-1 ) ){
                if ((array[i+1][j] % 2) == 0 && (array[i-1][j] % 2) == 0 && (array[i][j-1] % 2) == 0)
                printf("a[%d][%d]= %2d\n",i,j, array[i][j]);
            }

            else if ( i == (n-1) ){
                if ((array[i-1][j] % 2) == 0 && (array[i][j-1] % 2) == 0 && (array[i][j+1] % 2) == 0)
                printf("a[%d][%d]= %2d\n",i,j, array[i][j]);
            }

            else
            {
                if ((array[i-1][j] % 2) == 0 && (array[i+1][j] % 2) == 0 && (array[i][j-1] % 2) == 0 && (array[i][j+1] % 2) == 0)
                printf("a[%d][%d]= %2d\n",i,j, array[i][j]);
            }
        }
    }
}


text:
Q: Permission denied for view beyond its own schema There are two schemes rohdaten_fiat and staging_fiat. I have created a view in the latter one based on the first one.
CREATE VIEW staging_fiat.udz_odx_dtcs AS
SELECT * FROM rohdaten_fiat.udz_odx_relational_dtcs;

While keeping the database connection alive I can access the view, e. g.
SELECT * FROM staging_fiat.udz_odx_dtcs;

It runs under the following parameters:
SELECT current_user, current_setting('search_path'::text) AS search_path
     , relowner::regrole, relnamespace::regnamespace, relname, relacl
     , pg_get_viewdef(c.oid) AS view_definition
FROM   pg_class c
WHERE  relname = 'udz_odx_dtcs' OR relname = 'udz_odx_relational_dtcs';

See: https://pastebin.com/Hn7jAUat
However, after closing the connection and reconnect to the database, I can not:
SELECT * FROM staging_fiat.udz_odx_dtcs;

ERROR:  permission denied for relation view

The environmental parameters are the same (see https://pastebin.com/Hn7jAUat). Curiously, I can execute the query of the view manually:
SELECT * FROM rohdaten_fiat.udz_odx_relational_dtcs;

Only the view does not work. Where get the permissions lost? And why?
It's PostgreSQL 10.12. The connection including the search_path is absolutely identical.

A: To diagnose, inspect the output of this query before and after reconnecting in your question:
SELECT current_user, current_setting('search_path'::text) AS search_path
     , relowner::regrole, relnamespace::regnamespace, relname, relacl
     , pg_get_viewdef(c.oid) AS view_definition
FROM   pg_class c
WHERE  relname = 'view'  -- actual view name
OR    (relname = 'table' AND relnamespace = 'schema1');   -- actual table & schema name

You should get two or more rows each time. I omitted the schema of the view on purpose to see whether there might be others with the same name.
Oh, and make sure, your transaction is committed. Read the manual here.
This is not a direct answer, but it should enable you to get your answer.


text:
Q: Regex pattern for image (not link) Can anyone give me the pattern of the regex to get all the local images ONLY. :(
I'm using the code below but it includes the image links.
  Regex rgx = new Regex("[^\\/:*?\"<>|]+\\.(?i)(jpg|png|gif|bmp)", RegexOptions.IgnoreCase);

input:
 http://dl9.glitter-graphics.net/pub/846/846279rr8zhg26y6.gif
 images/strawberries.jpg

output:
 846279rr8zhg26y6.gif
 strawberries.jpg

I don't want the 846279rr8zhg26y6.gif

A: If your input strings are bounded somehow (e.g. inside ""s or at the start of the input string) then things are easier, and if the input has a semantic context of being a (relative or absolute) URL, and you only want relative URLs, then easier still.
I would however note that the extension part should probably be jpe?g rather than just jpg and I do wish people would never ever use a bmp on a webpage!


text:
Q: Proving that the Newton iteration is strictly monotonically decreasing. Let $p(x)$ be a polynomial with $\operatorname{deg}(f)\geq 2$ that just has real roots. The largest root of $p$ is $x^*$. I now have to show that Newton's method (Newton's iteration to find zeros) is strictly monotonically decreasing for every $x_0>x^*$.
My attempt
I somehow have to implement the information about the zeros of $p$. I figured, I could use the Fundamental theorem of algebra to write $p$ as:$$f(x)=a(x-x_1)\cdot \ldots \cdot (x-x^*)\cdot \ldots  \cdot (x-x_{n-1})$$  and than write $x_{i+1}=x_i-\frac{f(x_i)}{f'(x_i)}$ and use $x_0>x^*$. Is $f(x_0)$ negative? Can someone help me?

A: Assuming the leading coefficient is positive, you get the value and all derivatives positive for $x>x_*$. This implies that the function is monotonically increasing and convex there. Now apply what you know about tangents to convex functions. Consider the tangent at $x_0$,

*

*The tangent value at $x_*$ is below $p(x_*)=0$.

*The root $x_1$ of the tangent is above $x_*$, more precisely $x_*<x_1<x_0$.

*The value of $f$ at the tangent root is positive,...


text:
Q: Can you create a session variable without a value? My question is simply as asked in the title.
Upon login I'd like to create a token that looks like this:
 $_SESSION['token'] === true

Another page in my directory consists of an if statement that looks like this:
   if($_SESSION['token'] === false)
    {die('not logged in');}

However, even when logged in, the page dies instead of displaying appropriate HTML that would display if the token was true.

A: As another user has alluded to in the comments. You are not attempting to create a session variable with the following line:
$_SESSION['token'] === true;

This is not an assignment.  If you wanted to assign a value you'd need to do something like the following:
$_SESSION['token'] = true;

I've guessing you might have solved this issue by now but for some reason I like to dredge through unanswered questions.
Of course, you can compare the session variable just like any other variable once it is set. However, unless you set the value to false it won't match a test for false. You could certainly use isset() once you assign a value to it.


text:
Q: Small knots becoming isotopic after connect sum I am interested in the following situation:  I have two codimension-2 knots $K_1$ and $K_2$ in $S^n$ and they are not isotopic.  Furthermore, $K_1$ is not isotopic to the mirror image of $K_2$ and vice versa.  Could it be that $K_1$ and $K_2$ become isotopic after connect summing (away from the knots) another $n$-manifold $X$ (so that $K_1$ and $K_2$ are then isotopic inside of $X$)?
(In the case where say $K_2$ is the mirror image of $K_1$, we could connect sum on a nonorientable $X$ and going around a nonorientable loop would do the trick -- I don't know any other tricks.)
I would like to know the answer to this question specifically in low-dimensions (<5).  My guess: this can't happen in dimension 2 (here changing the codimension to consider curves on the surface -- say for some geometric reasons), this can't happen in dimension 3 (say by Gordon-Lueke and the fact that the fundamental group of the complement says a lot), this can happen in dimension 4 (since it's a jungle out there).

A: I believe can happen in dimension $4$, and probably in all higher dimensions. Take two inequivalent knots $K, K'$ with the same exterior (Cappell-Shaneson; Gordon). Then $K'$ is obtained from $K$ by a "Gluck twist", in other words trivialize the normal bundle of $K$ (there's only one way to do this), remove it, and glue back in using the diffeomorphism $f: S^1 \times S^2$ given by $f(\theta,z) = (\theta,$ rotation of $z$ by $\theta$).
There's a general principle that connect summing with $\mathbb{C}P^2$ undoes Gluck twists, and I think that this should prove that $K$ and $K'$ are now isotopic in $S^4 \# \mathbb{C}P^2$.  I'd have to think about the proof (or maybe someone could point to a reference).


text:
Q: Se me crearon carpetas automáticamente y no sé qué son luego de hacer un deploy Bunas a todos, les explico, hice una aplicación API utilizando ASP.NET 4.0, IIS.
Cuando quiero hacer el Pubish, hago la conexión, poniendo el Server, Site Name, user name, password, destination Url. Todo funciona perfectamente. Cuando hago clic en "Publish" y realizo el deploy de la aplicación, se abre, funciona todo perfecto, y se guarda dentro de un servidor de testing para luego pasarlo a producción .
El tema es el siguiente, en la carpeta del servidor donde estoy apuntando con ip, se me crean varias carpetas que adentro contienen .dll, también hay archivos JSON y .exe. Hay carpetas como wwwroot o Connected Services que perteneces a mi aplicación, pero hay otras como fr, es, it, etc, que aparecieron de la nada. Lo único que pienso es que son idiomas, pero se crearon luego de hacer el deploy.

Mi pregunta es, si cuando quiera pasarlo a producción, voy a tener algún error si lo desployeo en git, utilizando Jenkins? Que archivos tienen que estar indispensablemente para que funcione? Puedo borrar estas carpetas que se me generaron automáticamente luego de hacer el deploy?
Es la primera vez que hago un deploy de una aplicación, segui paso a paso lo que leí de la documentación de microsoft.

A: Al parecer no hay una documentación alguna por el momento para esto, solo pasa en .Net 6, cuando en .Net 5 no pasaba.
Se puede agregar SatelliteResourceLanguages para limitar las carpetas.
<PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup>


text:
Q: Past deleted order details being used by new orders So in the past we made the mistake of deleting orders from our Magento store.
We had an order today where a UK customer purchased a book.  They paid and received all the correct notification via email.
We then logged in to the admin to review the order.  It was completely different from the email notification.  It had a US address, a different payment method, products were added which no longer exist.  These details were from past test orders.
Another thing we noticed is that the confirmation email was also sent to other users, not in any way connected with this order.
I know we made a mistake in deleting past orders and that is undoubtedly the cause of our problem, but does anybody have any advice on how to reset things, without starting afresh.

A: If you have remember your last order # then, You can change increment id of order to solve this problem.
Suppose your last test order # was 100000367 then change it by 100000500
To do this you need to do it by phpmyadmin look for this table

eav_entity_store

And change the value of increment_last_id field where entity_type_id = 5
Please check it on demo to avoide any problem.

A: Basically Table eav_entity_store storing store wise last increment id of order=5,invoice=6,creditmemo=7,shipment=8:

For Avoiding problem you can check all of increment id you can check it maximum increment id for each above type from admin sales >> orders,sales >> shipment,Sales >> invoice,sales >> credit memo
After getting all above info you need to add those increment id entry in eav_entity_store table store wise with corresponding entity type.


text:
Q: What strategy for encrypting web.config sections should I use? I want to add automated encryption of some sections of web.config with following requirements:

*

*It should be done automatically every time application is started (I don't want to do it manually using aspnet_regiis after each config edit)

*It should automatically happen only on production environment (I need to see my values on my machine)

It's not a problem to find the code for it, my question is where to put it and how to make sure it's not executed on my localhost?
I tried to put it to Global.asax but I get Request is not available in this context exception there.
Thanks.

A: I would recommend setting this up as part of your deployment process.
Calling the encryption every time the application starts isn't a good idea because the ASP.Net App Pool will recycle itself from time to time, and that could cause problems.
Depending on your deployment process, you can do it through a batch file, powershell script, but it will need to be run on your production machine in question.


text:
Q: Phonegap 2.8.0 and Xcode 4.6.3 - Fail to install ad-hoc distribution i read all the guides, but nothing solves my problem.
In Apple Developer Center i have:

*

*1 dev cert

*1 distr cert

*all device listed

*the correct app_id -> bundle ID (in xcode)

*1 dev profile

*1 distribution profile

On my iPad 2, when i launch the application for testing, all is ok (with dev profile)
When i made an archive for create an IPA to install with iTunes, fails
I create an Build Configuration called ad-hoc with Distr Profile chosen in "code signing"
...this is the console log:
Jun 17 00:18:33 SergioiPad lockdownd[45] <Notice>: 01542000
__copy_itunes_value_block_invoke_0: com.apple.mobile.iTunes.store/PurchaseTypes -> (null)

Jun 17 00:18:37 SergioiPad installd[54] <Error>: 0x2ff7f000 handle_install: Install of "/var/mobile/Media/PublicStaging/***.ipa" requested by itunesstored

Jun 17 00:18:37 SergioiPad installd[54] <Error>: 0x2ff7f000 MobileInstallationInstall_Server: Installing app it.***.***

Jun 17 00:18:37 SergioiPad mobile_assertion_agent[101] <Notice>: service_one_connection: Connection closed for client iTunes.

Jun 17 00:18:37 SergioiPad installd[54] <Error>: Jun 17 00:18:37  SecTrustEvaluate  [leaf CriticalExtensions IssuerCommonName]

Jun 17 00:18:38 SergioiPad installd[54] <Error>: 0x2ff7f000 verify_signer_identity: MISValidateSignatureAndCopyInfo failed for /var/tmp/install_staging.66cmMz/foo_extracted/Payload/***.app/***: 0xe8008017

Jun 17 00:18:38 SergioiPad installd[54] <Error>: 0x2ff7f000 do_preflight_verification: Could not verify executable at /var/tmp/install_staging.66cmMz/foo_extracted/Payload/***.app

Jun 17 00:18:38 SergioiPad itunesstored[73] <Error>: 0x19ce000 MobileInstallationInstall: failed with -1

Jun 17 00:18:38 SergioiPad installd[54] <Error>: 0x2ff7f000 install_application: Could not preflight application install

Jun 17 00:18:38 SergioiPad installd[54] <Error>: 0x2ff7f000 handle_install: API failed

What's the problem ?


text:
Q: Scaling on Amazon EC2 I have several newbie questions about EC2, thanks for your attention,
1) why EC2 instances come with specific memory/storage quotas?  In the cloud environment, can't we just request the amount of memory/storage as we require, and the amazon infrastructure take care of the allocation?  I understand an pre-determined allocation of memory/storage is required to setup a VM image, however, is this indeed necessary ? In Google app engine, I don't see any limit on the memory, and the storage is charged in a pay-as-you-go manner.
2) Related to the first. If amazon allows instances created with a dynamic memory/storage quote, do we still need to create multiple instances and take care of load balancing, e.g.
Or, we can just create a powerful instance, and leave other scaling issues to Amazon.
3) The performance of EC2 instance, do you have experience to tell how it compares to a physical machine with similar configuration (memory/CPU)

A:
why EC2 instances come with specific memory/storage quotas? In the cloud environment, can't we just request the amount of memory/storage as we require, and the amazon infrastructure take care of the allocation?

Because EC2 emulates individual machines that you can control while you have no control over these "computers" on GAE. You cannot do things like use files on GAE.

Related to the first. If amazon allows instances created with a dynamic memory/storage quote, do we still need to create multiple instances and take care of load balancing, e.g. Or, we can just create a powerful instance, and leave other scaling issues to Amazon.

You will usually need to do this by yourself. EC2 provides on demand virtual "computers".

The performance of EC2 instance, do you have experience to tell how it compares to a physical machine with similar configuration (memory/CPU)

"One EC2 Compute Unit equals 1.0-1.2 GHz 2007 Opteron or 2007 Xeon processor."

A: Fundamentally it's because Amazon's infrastructure is based on the Xen virtualization platform, and Xen does not support dynamic reallocation of resources between VM's.
VMWare has announced support for that type of reallocation.  It will be interesting to see how Amazon reacts.


text:
Q: Realtime notifications using socket.io or any other better option ? Want instant notifications like whatsapp I am working on a travel app, notifications play a very vital role, as the app involves payments and instant verification. Please suggest how it can be achieved.
Will keeping a service for socket.io connection drain a lot of battery?
will the device kill the service when the user swipe kills the app from recent apps?

A: The socket.io connection does seem to drain a fair amount of battery in my experience. I open and close the socket connection depending on if the app is in the foreground. Otherwise, I use Firedbase Cloud Messaing to deliver the notifications. This is kind of annoying since you're delivering the Notifications twice, but if you want quick notifications and don't want to drain the phone's battery, there's not a great solution. The only other way would involve tracking the message read state on from the socket.io client and them firing off a FCM notification from there.


text:
Q: How to convert Tensorflow Simple Audio Recognition frozen graph(.pb) to Core ML model? I have been trying to implement the Tensorflow's simple audio recognition to an iphone app. After some research i found that i need to convert the Tensorflow's frozen graph .pb file to core ML model and then use it in the iOS apps. So i tried following this sample and referenced this convertor. But it looks like the convertor was mainly written to convert models that take image as input.But My model should be able to take audio .wav files as input. `
import tfcoreml as tf_converter
tf_converter.convert(tf_model_path = 'my_frozen_graph.pb',
                     mlmodel_path = 'my_model.mlmodel',
                     output_feature_names = ['labels_softmax:0'],
                     class_labels = 'classes.txt'
                     )

When i try to convert my graph to core ML model using the above code i get the following error response.
(env3) minimaci73$ python model.py
WARNING:root:Keras version 2.2.0 detected. Last version known to be fully compatible of Keras is 2.1.6 .
WARNING:root:TensorFlow version 1.8.0 detected. Last version known to be fully compatible is 1.5.0 .

Loading the TF graph...
Graph Loaded.
Traceback (most recent call last):
  File "/Users/minimaci73/anaconda3/envs/env3/lib/python3.6/site-packages/tfcoreml/_tf_coreml_converter.py", line 204, in _convert_pb_to_mlmodel
    shape_list = shape.as_list()
  File "/Users/minimaci73/anaconda3/envs/env3/lib/python3.6/site-packages/tensorflow/python/framework/tensor_shape.py", line 900, in as_list
    raise ValueError("as_list() is not defined on an unknown TensorShape.")
ValueError: as_list() is not defined on an unknown TensorShape.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "model.py", line 6, in <module>
    class_labels = 'conv_labels.txt'
  File "/Users/minimaci73/anaconda3/envs/env3/lib/python3.6/site-packages/tfcoreml/_tf_coreml_converter.py", line 586, in convert
    custom_conversion_functions=custom_conversion_functions)
  File "/Users/minimaci73/anaconda3/envs/env3/lib/python3.6/site-packages/tfcoreml/_tf_coreml_converter.py", line 206, in _convert_pb_to_mlmodel
    raise ValueError('Please provide the shape for the input {} through the argument \'input_name_shape_dict\''.format(input_name))
ValueError: Please provide the shape for the input wav_data:0 through the argument 'input_name_shape_dict'
(env3) minimaci73$

As per the last error message I need to enter the input shape of the input wav_data:0. So i created the text summary of the frozen graph as mentioned in the tutorial and looked up on the wav_data input shape. But the input shape is <unknown> for this.

I would like to know if there are any other methods to convert this file into core ML model? or Is there any way to use the frozen graph .pb file directly in an ios swift app ?
The Tensorflow-experimental Swift framework is also poorly documented. If you guys have any good resource on this, please share.
Update
As per the console log i downgraded the keras and tensorflow versions and also as per Matthijs answer i have added the input_name_shape_dict = { "import/wav_data:0" : [1, 16, 44100, 1]  Now the console shows the error in different way
(env3) minimaci73$ python model.py

Loading the TF graph...
Traceback (most recent call last):
  File "model.py", line 7, in <module>
    class_labels = 'conv_labels.txt'
  File "/Users/minimaci73/anaconda3/envs/env3/lib/python3.6/site-packages/tfcoreml/_tf_coreml_converter.py", line 586, in convert
    custom_conversion_functions=custom_conversion_functions)
  File "/Users/minimaci73/anaconda3/envs/env3/lib/python3.6/site-packages/tfcoreml/_tf_coreml_converter.py", line 153, in _convert_pb_to_mlmodel
    tf.import_graph_def(gdef, name='')
  File "/Users/minimaci73/anaconda3/envs/env3/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 316, in new_func
    return func(*args, **kwargs)
  File "/Users/minimaci73/anaconda3/envs/env3/lib/python3.6/site-packages/tensorflow/python/framework/importer.py", line 541, in import_graph_def
    raise ValueError('No op named %s in defined operations.' % node.op)
ValueError: No op named DecodeWav in defined operations.
(env3) minimaci73$ python model.py

A: You can supply an input shape to the converter:
input_name_shape_dict={ "import/wav_data:0" : [1, input_height, input_width, channels] })

If your data is 1-dimensional, then the height and width should be 1 and channels should be the length of the data.
You may run into other conversion errors too, but this is the first step. :-) (tfcoreml needs to know the input shape so that it can run the model with some fake data.)


text:
Q: How can I distinguish what type of JSON API response this is? I am new to JSON and XML. When doing a POST or GET request to an API, how can I tell the type of response given? For example, is it JSON or RAW or application? Can someone tell me what kind of response this is from a web API? Why are there quotes around every key and property?
HTTP/1.1 200 OK
{
  "audioChannels": "5.1",
  "audioCodec": "DolbyDigital",
  "container": "mkv",
  "episodeNumber": 3,
  "format": "WEBRip",
  "mimetype": "video/x-matroska",
  "releaseGroup": "NTb",
  "screenSize": "1080p",
  "season": 2,
  "series": "House of Cards",
  "title": "NF",
  "type": "episode",
  "videoCodec": "h264",
  "year": 2013
}

Is this JSON? JSONP? XML? What is this?

A: That is a plain JSON response (with some HTTP response information prepended).

A: This is an API response from GuessIt. GuessIt itself is a python library that tries to extract as much information as possible from a filename.

*

*http://guessit.readthedocs.org/

*https://github.com/wackou/guessit
Web Service API
The guessit.io server also provides a free webservice that allows you to perform filename detection, even you don't have python installed (eg: you need to use it from an Android app, or NodeJS, etc.).
You can look at the documentation for the web API here:

*

*http://api.guessit.io/


text:
Q: how to install shelled in eclipse luna I am trying to install shelled in the latest Eclipse Luna and I am getting the following error:
    An error occurred while collecting items to be installed
session context was:(profile=epp.package.cpp, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
No repository found containing: osgi.bundle,org.eclipse.egit,3.7.1.201504261725-r
No repository found containing: osgi.bundle,org.eclipse.egit.core,3.7.1.201504261725-r
No repository found containing: osgi.bundle,org.eclipse.egit.doc,3.7.1.201504261725-r
No repository found containing: osgi.bundle,org.eclipse.egit.ui,3.7.1.201504261725-r
No repository found containing: osgi.bundle,org.eclipse.jgit,3.7.1.201504261725-r
No repository found containing: osgi.bundle,org.eclipse.jgit.archive,3.7.1.201504261725-r
No repository found containing: org.eclipse.update.feature,org.eclipse.egit,3.7.1.201504261725-r
No repository found containing: org.eclipse.update.feature,org.eclipse.jgit,3.7.1.201504261725-r
No repository found containing: osgi.bundle,org.eclipse.jgit.java7,3.7.1.201504261725-r
No repository found containing: org.eclipse.update.feature,org.eclipse.jgit.java7,3.7.1.201504261725-r
No repository found containing: osgi.bundle,org.slf4j.impl.log4j12,1.7.2.v20131105-2200

I have tried to install it locally from archive and also Bash script plugin for Eclipse?, but and all of this failed.
Any ideas?

A: To solve this issue for Luna (4.4.2.M20150204-1700), I had to install dltk :
go Help => install,  new software => Add
Name: DLTK

Location: http://download.eclipse.org/technology/dltk/updates-dev/5.3.1/

I choose only the first checkbox :"Dynamic Languages Toolkit Core Frameworks"
Then I installed ShellEd by following this tutorial : how-to-install-plugin-for-eclipse-from-zip.

A: try to downlaod the plugin manually from the update site, then follow the instructions here: how-to-install-plugin-for-eclipse-from-zip

A: Finally I managed to install it by deleting eclipse luna and downloading it again from scratch... I still don't understand why I got the errors in my old eclipse... It is rather annoying since I had a lot of plugins installed in my old eclipse and I had to re-install them all over again (this time I installed shelled first to eliminate the possibility that one of the plugins interfering with shelled installation...). Looks like a bug in eclipse (or one of its plugins) to me.

A: Here is how I installed shelled on Eclipse Luna successfully.
Steps:

*

*Update site: http://sourceforge.net/projects/shelled/files/shelled/update/

*Check option: Contact all update sites during install to find required software

*Install, it will take a while to finish downloading & installation, (maybe 20 minutes eveb with a good network).

*Restart eclipse.

*Ok

Tips:

*

*The key part it to check the option mentioned above, otherwise it will fail. Even though it's slow and not necessary for most other plugins.

A: If you are looking for a good shell editor plugin for eclipse, here it is :
http://marketplace.eclipse.org/marketplace-client-intro?mpc_install=3261650

Just drag the "install" button to eclipse workspace. It will automate the installation.


text:
Q: How to convert list of images into list of numbers in python? TypeError: int() argument must be a string, a bytes-like object or a number, not 'Image' I'm writing a code to load images and resize them, after that I modified that code, splitting those resized images into three categories; train, test and validation (according to ratios). Then I got this error, "TypeError: int() argument must be a string, a bytes-like object or a number, not 'Image'" after adding this line (15): img.load() to eliminate error: ValueError: seek of closed file.
this is code.
from os import listdir
from PIL import Image as PImage
import split_folders
import os, os.path
import numpy as np
import shutil
from scipy.misc import imresize

def loadImages(path):
    imagesList = listdir(path)
    loadedImages = []
    for image in imagesList:
        with open(os.path.join(path, image), 'rb') as i:
            img = PImage.open(i)
            img.load()
            loadedImages.append(img)
    return loadedImages

path = "./Inputs/"
imgs = loadImages(path)

#resizing
imgs = [img.resize((160,80), PImage.ANTIALIAS) for img in imgs]
print(imgs)

# split folders
np.random.shuffle(imgs)  # now this list is shuffled
train, validate, test = np.split(imgs, [int(.7*len(imgs)), int(.85*len(imgs))])

print("loading images to Train folder")
print(train)
destination = "./Outputs/train/*.png"
# shutil.copy(np.array(train),destination)
# a = PImage.fromarray(train)
# a.save(destination,".png")
# train = PImage.fromarray(train).convert('RGB')
# train.save(destination,'PNG')

print("loading images to Test folder")
print(test)

print("loading images to Validation folder")
print(validate)

this is traceback:
Traceback (most recent call last):
  File "/home/thisuri/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line51, in _wrapfunc
    return getattr(obj, method)(*args, **kwds)
AttributeError: 'list' object has no attribute 'swapaxes'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/thisuri/Documents/Re-Train_OCR/retrain_script.py", line 28, in <module>
    train, validate, test = np.split(imgs, [int(.7*len(imgs)), int(.85*len(imgs))])
  File "/home/thisuri/.local/lib/python3.6/site-packages/numpy/lib/shape_base.py", line 785, in split
    res = array_split(ary, indices_or_sections, axis)
  File "/home/thisuri/.local/lib/python3.6/site-packages/numpy/lib/shape_base.py", line 702, in array_split
    sary = _nx.swapaxes(ary, axis, 0)
  File "/home/thisuri/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line549, in swapaxes
    return _wrapfunc(a, 'swapaxes', axis1, axis2)
  File "/home/thisuri/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line61, in _wrapfunc
    return _wrapit(obj, method, *args, **kwds)
  File "/home/thisuri/.local/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line41, in _wrapit
    result = getattr(asarray(obj), method)(*args, **kwds)
  File "/home/thisuri/.local/lib/python3.6/site-packages/numpy/core/numeric.py", line 501, in asarray
    return array(a, dtype, copy=False, order=order)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'Image'

Any Solution?

A: this could be one method, Keep validation set in different folder altogether. Split will happen when you will fit model (at the end of this code). An example here.
datadir = "C:/Users..."
categories = ['A','B','C']
img_size = 200
img_size_y= 420
from tqdm import tqdm
training_data = []

    def create_training_data():
        for category in categories:
            path = os.path.join(datadir, category)
            class_num = categories.index(category)
            for img in tqdm(os.listdir(path)):
                try:
                    img_array = cv2.imread(os.path.join(path,img), cv2.IMREAD_GRAYSCALE)
                    new_array = cv2.resize(img_array, (img_size,img_size_y))
                    training_data.append([new_array,class_num])
                except Exception as e:
                    pass

    create_training_data()

import random
random.shuffle(training_data)

x = []
y = []
for features, label in training_data:
    x.append(features)
    y.append(label)

x =np.array(x).reshape(-1, img_size, img_size_y, 1)

import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Dropout, Activation, Flatten, Conv2D, MaxPooling2D
from tensorflow.keras.callbacks import TensorBoard
import time

dense_layers = [0,1,2]
layer_sizes = [32,64,128]
conv_layers =[1,3,5,10]

for dense_layer in dense_layers:
    for layer_size in layer_sizes:
        for conv_layer in conv_layers:
            Name= "{}-conv-{}-nodes-{}-dense-{}".format(conv_layer, layer_size,dense_layer,
                                                       int(time.time()))
            print(Name)
            tensorboard = TensorBoard(log_dir='logs/{}'.format(name))
            model = Sequential()

            model.add(Conv2D(layer_size, (3,3), input_shape = x.shape[1:]))
            model.add(Activation('relu'))
            model.add(MaxPooling2D(pool_size=(2,2)))

            for l in range (conv_layer-1):
                model.add(Conv2D(layer_size, (3,3)))
                model.add(Activation('relu'))
                model.add(MaxPooling2D(pool_size=(2,2)))

            model.add(Flatten())
            for l in range(dense_layer):
                model.add(Dense(layer_size))
                model.add(Activation('relu'))

            model.add(Dense(1))
            model.add(Activation('sigmoid'))
            model.compile(loss = "binary_crossentropy",
                         optimizer="adam",
                         metrics=['accuracy'])

            model.fit(x,y, batch_size=2, epochs= 10, validation_split=0.3, callbacks=[tensorboard])
            #here is you split happening for test

A: You can convert PIL images into numpy arrays. Copying an example from https://pillow.readthedocs.io/en/5.3.x/reference/Image.html#PIL.Image.fromarray -
from PIL import Image
import numpy as np
im = Image.open('hopper.jpg')
a = np.asarray(im)


text:
Q: How can I sort a Map by some property of the key in the map? Lets say we have a class called Activity:
public class Activity {
    private Project project;
}

So every Activity Object will have a Project.. Also every Project has a Unit. Two different Projects can have the same unit:
public class Project {
    private String projectName;
    private Unit unit;
}

And a Unit has a name as well:
public class Unit {
    private String unitName;
}

So currently I have a TreeMap like this:
SortedMap<Project,List<Activity> myMap

One example may be:
projectOne -> [activityOne,activityTwo,activityThree]
projectTwo -> [activityThree,activityFouractivityFive]
projectThree -> [activityFour,activityFive,activitySix]

etc...
Now lets assume projectOne has the same unit with projectThree (unitAAA) and projectTwo has unitZZZ...
I want to sort my Map alphabetically by the unit of the project elements:
projectOne -> [...]
projectThree -> [...]
projectTwo -> [...]

How can I achieve this? I know in Stackoverflow the question is What have you tried so far?, well I am really stuck in this point so I have not really tried anything besides trying to come up with what I can even try..

A: A map is basically an unsorted collection but there are sorted maps as well, e.g. TreeMap. In that case provide a comparator which sorts projects based on their to the constructor:
SortedMap<Project, List<Activity>> myMap = new TreeMap<>( new Comparator<Project>() {
  public int compare( Project lhs, Project rhs) {

    int r = lhs.unit.unitName.compareTo(rhs.unit.unitName); //note that null checks etc. are omitted for simplicity, don't forget them in your code unless you know for sure that unit and unitName can't be null
    if( r == 0 && !lhs.equals(rhs)) {
      //take other properties into account for consistent behavior with equals()
      //see "Update 2" below
    }
    return r;
  }
});

Note that if you need to sort the map using a different comparator (or can't provide a comparator) you'd have to create a list using the entries of the map and sort that.
Something like this:
 List<Map.Entry<Project, List<Activity>> l = new ArrayList<>(myMap.entrySet());
 Collections.sort(l, new Comparator<Map.Entry<Project, List<Activity>>() {
   public int compare( Map.Entry<Project, List<Activity> lhs, Map.Entry<Project, List<Activity> rhs) {
    return lhs.getKey().unit.unitName.compareTo(rhs.getKey().unit.unitName);
  }
 });

Also note that it is not possible for a collection or sorted map to have different sort orders, i.e. you can only provide one comparator or natural ordering for the elements.
In any case you'd either have to change the sort order of the collection (e.g. by using Collections.sort(...) or, if you need to maintain multiple orders simultanously, use multiple collections (which can be sorted views to a base collection/map).
Update I'll add an example for a copy of the TreeMap:
//new TreeMap like above
SortedMap<Project, List<Activity>> copy = new TreeMap<>( new Comparator<Project>() { ... } );
copy.putAll( myMap );

Update 2
As for the comparator, note that it is required to be consistent with equals, i.e. the comparator must only return 0 if both objects are equal. Thus you'd need to take other properties of a Project into account if the units are equal. Without that, if two projects use the same unit, they are considered equal by the TreeMap and thus entries might get lost.
For more information see: What does comparison being consistent with equals mean ? What can possibly happen if my class doesn't follow this principle?
The compare method might look like this, if the project names are unique:
public int compare( Project lhs, Project rhs) {
  //as above null checks etc. are omitted for simplicity's sake
  int r = lhs.unit.unitName.compareTo(rhs.unit.unitName);
  if( r == 0 && !lhs.equals(rhs)) {
    r = lhs.projectName.compareTo( rhs.projectName );

    //you could also use the natural ordering of the projects here:
    //r = lhs.compareTo( rhs );
  }
  return r;
}

A: A HashMap can't be sorted, but if you want to display the contents of the map sorted, you could sort a list of your projects by unit (look for a Comparator on Project) and get the value of the corresponding project from the map.


text:
Q: Elements not where they are supposed to be (tables) I want the elements in the red boxes to be in the blue boxes

Monday 16th of december 2019
 Volume 5

the code above is for a table the pre-header is centred perfectly but the logo and logo description just don't want to go where they are supposed to

A: Try moving your styles around, specifically: treat each element like a container or a box.

Monday 16th of december 2019
 Volume 5

That may require some tweaks, but it should be pretty close. Specifically keep an eye on that 'clear'.


text:
Q: How to use a file that was created in the same script I am trying to get OSMNx map as an image and then use the same image as a pygame background image
This is what I tried:
import osmnx as ox
import pygame
from IPython.display import Image

ox.config(log_file=True,log_console=True,use_cache=True)

img_folder='image'; extension='png'; size=700

place='Prague'
point=(50.0908,14.4009)
fig,ax=ox.plot_figure_ground(point=point,filename=place,network_type='all',dpi=150)
Image('{}/{}.{}'.format(img_folder,place,extension),height=size,width=size)

SCREEN_WIDTH, SCREEN_HEIGHT = size, size
pygame.init()
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption('Top Down Car Using OOP')
pygame.image.load(Image('{}/{}.{}'.format(img_folder,place,extension)))

The script creates three folders: logs, cache, and images, I want to reach the image from the folder images, but it cannot find the path
Thank you very much

A: I am sorry, I was able to figure it out myself, just when I posted this question, it happened to me for the second time...
Here is my solution if anyone would have a similar problem in the future:
import osmnx as ox
import pygame
from IPython.display import Image

ox.config(log_file=True,log_console=True,use_cache=True)

img_folder='image'; extension='png'; size=700

place='Prague'
point=(50.0908,14.4009)
fig,ax=ox.plot_figure_ground(point=point,filename=place,network_type='all',dpi=150)
Image('{}/{}.{}'.format(img_folder,place,extension),height=size,width=size)

SCREEN_WIDTH, SCREEN_HEIGHT = size, size
pygame.init()
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption('Top Down Car Using OOP')
background_image = pygame.image.load("images\{}.{}".format(place,extension))

k = 0
Pixels = []
FPS = 24
running = True
screen.blit(background_image, [0, 0])
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):
            # The user closed the window or pressed escape
            running = False
    pygame.display.flip()
    pygame.time.Clock().tick(FPS)

pygame.quit()
print('Done!')

Sorry for bothering you, but if possible, I would like to know what Lior Cohen means by the slash\backslash notation in the comments, I have to admit that I am confused.


text:
Q: Why is mandatory the "Route" attribute on methods of a custom-routed controller? Consider a fresh Asp.Net Core 2.1 MVC Web app created via the Visual Studio 2017 template. Now, consider a custom view (MyView) and also a controller (ActualController) so that the project structure looks similar to this picture:

The MyView shows nothing special, and it's off the point. However, the page should appear when the user enters an URL like http://(domain)/desired/myview or also via a hyperlink in the home page:
MyView

Now let's focus on the controller, which is a class named differently from what the routing expects:
[Route("desired")]
public class ActualController : Controller
{
    [Route("MyView")]  //without this the method won't be called
    public IActionResult MyView()
    {
        return this.View();
    }
}

From what I know, by decorating the controller with a Route attribute tells the URL resolver to match this class. However, the mapping works only if I explicitly add a (redundant) Route attribute on the target method/action. If I remove it, the path won't be found, and the server returns a 404-error.
The question is: why should be mandatory to decorate with Route the method, even the action is implicitly defined by the method name (as usual)?
NOTE: is rather simple for me to rename the controller class, but I'd like to know what are the reasons behind this behavior.

A: You are overriding the default route of [controller]/[action] with [Route("desired")]. Since you don't define an action parameter on controller level, all other routes have to be done explicitly.
Changing the top route parameter to [Route("desired/[action]")] should solve it and the method name will be used as parameter. You can still override single actions if you want to name them differently by adding the [Route("")] attribute to them.
Also see the docs (Token replacement in route templates) for further description on the route parameters


text:
Q: Get fullpath of input type file JavaScript I have the following code:

    File :

        <input type="file" name="upload" id="upload"></input>

    Remarks*

        <textarea name="approvalremarks" cols="38" rows="4" class="field"/>

I have try this code to get the fullpath of the file but it input C:\\fakepath.
How to get the correct path?
var filename = document.getElementById("upload");
alert(filename.value);

A: JavaScript, basically, is a language running on client side and can not retrieve information above the context of your browser. For security reason, with JavaScript basically, it is not possible to get information from your System. It is a restriction.
Please read this answer to avoid System restriction https://stackoverflow.com/a/15201258/6776417

A: You can do something like this using Jquery.

Refer this answer: Get the file name after click open button in file browse dialog box using JavaScript/jQuery
Thank you


text:
Q: In Corda, can an acceptor (i.e. initiated) flow invoke subflows? I know that in Corda, initiating flows can invoke subflows to speak to other parties or automate common tasks.
Can an acceptor/initiated flow do the same?
In particular, suppose A initiates a flow with B. Can B, as part of the acceptor/initiated flow, invoke a subflow that speaks to C?

A: Yes. There are no constraints on invoking subflows in acceptor/initiated flows, regardless of whom they speak to.


text:
Q: zfs installation issue Ubuntu 12.04 on Amazon EC2 I attached Three EBS Volumes of 3GB to an Amazon EC2 Micro-instance and mounted the disks xvdd, xvdc and xvdb.
My aim was to create a zfs pool using these 3 disks.
I had updated, upgraded Ubuntu 12.04, installed the zfs-linux dependencies, added the zfs-native repo PPA  and then issued the zfs install command whhich is
sudo apt-get install ubuntu-zfs

After this, I get the console status which is as below and after the "run-parts:" status indicated below, the install process never proceeded further. I waited for 20+ minutes and got this:
Setting up zfs-dkms (0.6.0.91-0ubuntu1~precise1) ...
Loading new zfs-0.6.0.91 DKMS files...
First Installation: checking all kernels...
Building only for 3.2.0-31-virtual
Module build for the currently running kernel was skipped since the
kernel source for this kernel does not seem to be installed.
Setting up linux-headers-3.2.0-35 (3.2.0-35.55) ...
Setting up linux-headers-3.2.0-35-generic (3.2.0-35.55) ...
Examining /etc/kernel/header_postinst.d.
run-parts: executing /etc/kernel/header_postinst.d/dkms 3.2.0-35-generic /boot/vmlinuz-3.2.0-35-generic

Is this issue related to EC2 kernel for Ubuntu? or does the machine to run ZFS should be of higher capacity?

A: Usually with hosting providers the kernel is the case. My provider (ovh) delivers their own customized (and allegedly more secure) kernel (alas without sources), although reluctantly permits installing the generic kernel, which solved the problem for me. I don't know about Amazon - perhaps their customized kernel is crucial for their EC2 service. On the other hand I very much doubt any hosting provider would produce the source code of their kernel.


text:
Q: FCM not open fragment when app is in background foreground works fine hey stackoverflow devs I faced problem regarding fcm notifications. I want to open specific fragment on click of notification which works fine when app is in foreground but not working when app is in background or killed. Search so many threads to find working solution but no success. What I have done so far is mentioned below. If anyone has idea help to get rid of this problem cheers!
FCM Service Function:

    private fun sendNotification1(remoteMessage: RemoteMessage) {
        if (!isAppIsInBackground(applicationContext)) {
            //foreground app
            Log.e("remoteMessage", remoteMessage.toString())
            val title = remoteMessage.notification!!.title
            val notification_identifier = remoteMessage.data["categoryIdentifier"].toString()
            val body = remoteMessage.notification!!.body
            val click_action = remoteMessage.notification!!.clickAction

            val resultIntent = Intent(applicationContext, NotificationsFragmentUI::class.java)
            resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)

            val pendingIntent = NavDeepLinkBuilder(applicationContext)
                .setComponentName(HomeActivity::class.java)
                .setGraph(R.navigation.main_nav_graph)
                .setDestination(R.id.notificationsFragmentUI)
                .createPendingIntent()
            val defaultsound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
            val oreoNotification = OreoNotification(this)
            val builder: Notification.Builder = oreoNotification.getOreoNotification(
                title,
                body,
                pendingIntent,
                defaultsound,
                java.lang.String.valueOf(R.drawable.ic_one_network_logo)
            )
            val i = 0
            oreoNotification.manager?.notify(i, builder.build())
        } else {
            Log.e("remoteMessage", remoteMessage.data.toString())
            val notification_identifier = remoteMessage.data["categoryIdentifier"].toString()
            val title = remoteMessage.data["title"]
            val body = remoteMessage.data["body"]
            val resultIntent = Intent(applicationContext, NotificationsFragmentUI::class.java)
            val click_action = remoteMessage.notification!!.clickAction

            resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)

            val pendingIntent = NavDeepLinkBuilder(applicationContext)
                .setComponentName(HomeActivity::class.java)
                .setGraph(R.navigation.main_nav_graph)
                .setDestination(R.id.notificationsFragmentUI)
                .createPendingIntent()
            val defaultsound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
            val oreoNotification = OreoNotification(this)
            val builder: Notification.Builder = oreoNotification.getOreoNotification(
                title,
                body,
                pendingIntent,
                defaultsound,
                java.lang.String.valueOf(R.drawable.ic_one_network_logo)
            )
            val i = 0
            oreoNotification.manager?.notify(i, builder.build())
        }
    }

Notification Class :

class OreoNotification(base: Context?) : ContextWrapper(base) {
    private var notificationManager: NotificationManager? = null
    @TargetApi(Build.VERSION_CODES.O)
    private fun createChannel() {
        val channel = NotificationChannel(
            CHANNEL_ID,
            CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH
        )
        channel.description = "Fcm Test channel for app test FCM"
        channel.enableLights(true)
        channel.enableVibration(true)
        channel.vibrationPattern = longArrayOf(100, 200, 300, 400, 500, 400, 300, 200, 400)
        channel.setShowBadge(false)
        channel.lockscreenVisibility = Notification.VISIBILITY_PRIVATE
        manager!!.createNotificationChannel(channel)
    }

    val manager: NotificationManager?
        get() {
            if (notificationManager == null) {
                notificationManager =
                    getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
            }
            return notificationManager
        }

    @TargetApi(Build.VERSION_CODES.O)
    fun getOreoNotification(
        title: String?,
        body: String?,
        pendingIntent: PendingIntent?,
        soundUri: Uri?,
        icon: String?
    ): Notification.Builder {
        return Notification.Builder(applicationContext, CHANNEL_ID)
            .setAutoCancel(true)
            .setBadgeIconType(NotificationCompat.BADGE_ICON_SMALL)
            .setDefaults(Notification.DEFAULT_ALL)
            .setWhen(System.currentTimeMillis())
            .setSmallIcon(R.drawable.ic_one_network_logo)
            .setTicker("Fcm Test")
            .setNumber(10)
            .setContentTitle(title)
//            .setContentIntent(pendingIntent)
            .setContentText(body)
            .setContentIntent(pendingIntent)
            .setContentInfo("Info")
    }

    companion object {
        private const val CHANNEL_ID = "Fcm Test"
        private const val CHANNEL_NAME = "Fcm Test"
    }

    init {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            createChannel()
        }
    }
}

Override method in Home Activity

 override fun onNewIntent(intent: Intent?) {
        super.onNewIntent(intent)
        val myFragment= NotificationsFragmentUI()
        supportFragmentManager.beginTransaction().replace(R.id.notificationsFragmentUI,myFragment).addToBackStack(null).commit()
    }

OnMessageReceived Method:

    override fun onMessageReceived(remoteMessage: RemoteMessage) {
        super.onMessageReceived(remoteMessage)
        if (remoteMessage.notification != null){
            if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
                sendNotification1(remoteMessage);
            }else{
                sendNotification(remoteMessage);
            }
        }
    }


text:
Q: PyPDF2 only reading newline chars from pages I am reading text from a pdf file like so:
pdf_reader = PyPDF2.PdfFileReader(pdf_file_obj)
page_count = pdf_reader.numPages
text = ''

for i in xrange(page_count):
    text += pdf_reader.getPage(i).extractText()

However the output is a long unicode object ONLY containing the \n chars. The file is NOT encrypted.
Any explanation for not being able to read the text from this file?


text:
Q: Handle MySQL exceptions in Visual Studio The following code checks if I can connect to the MySQL database or not. It is working fine when it connects but when it can't connect it throws out an error instead of executing the 'Else' statement
    using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;

namespace MySQLConnection
{
    public partial class FrmConnection : Form
    {
        public FrmConnection()
        {
            InitializeComponent();
        }

        string connectionString = "host=192.168.0.91; database=c#1; user=test1; password=test1";
        private void button1_Click(object sender, EventArgs e)
        {
            using (MySqlConnection con= new MySqlConnection(connectionString))
            {
                con.Open();
                if(con.State==ConnectionState.Open)
                {
                    label1.Text = "Connection Established!";
                }
                else
                {
                    label1.Text = "Connection Error!";
                }
            }
        }
    }
}

I get this error

An unhandled exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll

Additional information: Unable to connect to any of the specified MySQL hosts.

A: To handle exceptions, you can do this:
using (MySqlConnection con= new MySqlConnection(connectionString))
    {
        try
        {
            con.Open();
            label1.Text = "Connection Established!";
        }
        catch(Exception ex)
        {
            label1.Text = "Connection Error!\n"+ex.Message;
        }
        finally
        {
            con.Close();
        }
    }

It's pretty explained: It will try to open the connection and set a success message.
If it fails, it will say that the connection failed and display the error message from the catched exception.
Then, on the finally block, it will close the connection, after both try and catch has finished executing.
I'm not sure but since you're using using, you wouldn't need the finally block, for the using function will close the connection automatically.
More info on the MSDN page for the try catch finally blocks.


text:
Q: Customising destruction procedure in std::vector::erase() When I call the erase function on a vector of type 'T', then the destructor of the elements following the range on which I've called the erase() is called. Is there a way to customise this behaviour? How can I ensure that the destructors of those elements which are being erased are called?
Sample Program
#include<bits/stdc++.h>

enum type {
    TYPE_DEFAULT,
    TYPE0,
    TYPE1,
    TYPE2,
    TYPE3,
    TYPE4,
};

char str[][13] = {"TYPE_DEFAULT","TYPE0","TYPE1","TYPE2","TYPE3","TYPE4"};

struct temp {
type objType;

void printInfo() const {
    std::cout<<"\nthis-->"<<this;
    std::cout<<"\nType-->"<<str[objType]<<"\n";
}

temp() {
    objType = type::TYPE_DEFAULT;
    std::cout<<"\n**Default Constructor**";
    printInfo();
}

temp(const temp& obj) = default;

temp& operator=(const temp& obj) {
    std::cout<<"\n**operator=**";
    objType = obj.objType;
    printInfo();
    return *this;
}

~temp() {
    std::cout<<"\n**Destructor**";
    this->printInfo();
    std::cout<<"\n";
}
};
int main() {

std::vector<temp> vec;
vec.resize(5);

for(int i =0;i<5;i++) {
    vec[i].objType = (type)(i+1);
}

std::cout<<"\nPrinting vector before erase. Size->"<<vec.size()<<"\n";

for(const auto&x : vec) {
    x.printInfo();
}

int start = 0;
int end = 2;
std::cout<<"\nGoing to call erase for vec["<<start<<","<<end<<")\n";

vec.erase(vec.begin()+start,vec.begin()+end);

std::cout<<"\nErase has been invoked\n";

std::cout<<"\nPrinting vector Info after erase. Size->"<<vec.size()<<"\n";

for(const auto&x : vec)
    x.printInfo();

}

Output
**Default Constructor**
this-->0xf9c010
Type-->TYPE_DEFAULT

**Default Constructor**
this-->0xf9c014
Type-->TYPE_DEFAULT

**Default Constructor**
this-->0xf9c018
Type-->TYPE_DEFAULT

**Default Constructor**
this-->0xf9c01c
Type-->TYPE_DEFAULT

**Default Constructor**
this-->0xf9c020
Type-->TYPE_DEFAULT

Printing vector before erase. Size->5

this-->0xf9c010
Type-->TYPE0

this-->0xf9c014
Type-->TYPE1

this-->0xf9c018
Type-->TYPE2

this-->0xf9c01c
Type-->TYPE3

this-->0xf9c020
Type-->TYPE4

Going to call erase for vec[0,2)

**operator=**
this-->0xf9c010
Type-->TYPE2

**operator=**
this-->0xf9c014
Type-->TYPE3

**operator=**
this-->0xf9c018
Type-->TYPE4

**Destructor**
this-->0xf9c01c
Type-->TYPE3

**Destructor**
this-->0xf9c020
Type-->TYPE4

Erase has been invoked

Printing vector Info after erase. Size->3

this-->0xf9c010
Type-->TYPE2

this-->0xf9c014
Type-->TYPE3

this-->0xf9c018
Type-->TYPE4

**Destructor**
this-->0xf9c010
Type-->TYPE2

**Destructor**
this-->0xf9c014
Type-->TYPE3

**Destructor**
this-->0xf9c018
Type-->TYPE4

Program Description
In the above program, I have a vector(size 5) of a structure named 'temp'. When I call erase on range [0,2), destructors of last 2 elements are called. What do I need to do to call the destructors of first 2 elements instead?

A: You can't do this with vector. Erase will get rid of the items you want from the vector, but it may not destroy those specific objects.
If it is absolutely necessary to call the destructors of the first two elements, consider using a deque if you are going to only insert and erase at the back and the front or a std::forward_list if you don't need random-access.
P.S. vector is horrible for insertions and erasures anywhere but the back, as it will have to move all the elements in front of the inserted or erased item.


text:
Q: CentOS7 unabe to install pdo_mysql extension I'm new to the server administration, I have dedicated server in CentOS 7. I'm trying to enabe pdo_mysql extension & my php verison is 7.2
I have php version 7.1 and 7.0 but there its installed and working properly but when i try to install pdo_mysql in my CentOS 7
yum install php-devel php-pear mysql-devel httpd-devel
pecl install pdo

But when i run this command i'm getting the error like :
executing libtool commands
running: make
/bin/sh /root/tmp/pear/pear-build-rootfJoHUo/PDO-1.0.3/libtool --mode=compile cc  -I. -I/root/tmp/pear/PDO -DPHP_ATOM_INC -I/root/tmp/pear/pear-build-rootfJoHUo/PDO-1.0.3/include -I/root/tmp/pear/pear-build-rootfJoHUo/PDO-1.0.3/main -I/root/tmp/pear/PDO -I/opt/cpanel/ea-php72/root/usr/include/php -I/opt/cpanel/ea-php72/root/usr/include/php/main -I/opt/cpanel/ea-php72/root/usr/include/php/TSRM -I/opt/cpanel/ea-php72/root/usr/include/php/Zend -I/opt/cpanel/ea-php72/root/usr/include/php/ext -I/opt/cpanel/ea-php72/root/usr/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /root/tmp/pear/PDO/pdo.c -o pdo.lo
libtool: compile:  cc -I. -I/root/tmp/pear/PDO -DPHP_ATOM_INC -I/root/tmp/pear/pear-build-rootfJoHUo/PDO-1.0.3/include -I/root/tmp/pear/pear-build-rootfJoHUo/PDO-1.0.3/main -I/root/tmp/pear/PDO -I/opt/cpanel/ea-php72/root/usr/include/php -I/opt/cpanel/ea-php72/root/usr/include/php/main -I/opt/cpanel/ea-php72/root/usr/include/php/TSRM -I/opt/cpanel/ea-php72/root/usr/include/php/Zend -I/opt/cpanel/ea-php72/root/usr/include/php/ext -I/opt/cpanel/ea-php72/root/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/tmp/pear/PDO/pdo.c  -fPIC -DPIC -o .libs/pdo.o
In file included from /root/tmp/pear/PDO/pdo.c:32:0:
/root/tmp/pear/PDO/php_pdo_driver.h: In function 'pdo_attr_lval':
/root/tmp/pear/PDO/php_pdo_driver.h:191:2: error: too many arguments to function 'zend_hash_index_find'
  if (options && SUCCESS == zend_hash_index_find(Z_ARRVAL_P(options), option_name, (void**)&v)) {
  ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/Zend/zend.h:34:0,
                 from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:35,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_hash.h:170:30: note: declared here
 ZEND_API zval* ZEND_FASTCALL zend_hash_index_find(const HashTable *ht, zend_ulong h);
                              ^
In file included from /root/tmp/pear/PDO/pdo.c:32:0:
/root/tmp/pear/PDO/php_pdo_driver.h:192:3: warning: passing argument 1 of 'zval_get_type' from incompatible pointer type [enabled by default]
   convert_to_long_ex(v);
   ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/Zend/zend.h:29:0,
                 from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:35,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_types.h:389:38: note: expected 'const struct zval *' but argument is of type 'struct zval **'
 static zend_always_inline zend_uchar zval_get_type(const zval* pz) {
                                      ^
In file included from /root/tmp/pear/PDO/pdo.c:32:0:
/root/tmp/pear/PDO/php_pdo_driver.h:192:3: warning: passing argument 1 of 'convert_to_long' from incompatible pointer type [enabled by default]
   convert_to_long_ex(v);
   ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/Zend/zend.h:328:0,
                 from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:35,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_operators.h:251:29: note: expected 'struct zval *' but argument is of type 'struct zval **'
 ZEND_API void ZEND_FASTCALL convert_to_long(zval *op);
                             ^
In file included from /root/tmp/pear/PDO/pdo.c:32:0:
/root/tmp/pear/PDO/php_pdo_driver.h: In function 'pdo_attr_strval':
/root/tmp/pear/PDO/php_pdo_driver.h:201:2: error: too many arguments to function 'zend_hash_index_find'
  if (options && SUCCESS == zend_hash_index_find(Z_ARRVAL_P(options), option_name, (void**)&v)) {
  ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/Zend/zend.h:34:0,
                 from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:35,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_hash.h:170:30: note: declared here
 ZEND_API zval* ZEND_FASTCALL zend_hash_index_find(const HashTable *ht, zend_ulong h);
                              ^
In file included from /root/tmp/pear/PDO/pdo.c:32:0:
/root/tmp/pear/PDO/php_pdo_driver.h:202:3: warning: passing argument 1 of 'zval_get_type' from incompatible pointer type [enabled by default]
   convert_to_string_ex(v);
   ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/Zend/zend.h:29:0,
                 from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:35,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_types.h:389:38: note: expected 'const struct zval *' but argument is of type 'struct zval **'
 static zend_always_inline zend_uchar zval_get_type(const zval* pz) {
                                      ^
In file included from /root/tmp/pear/PDO/pdo.c:32:0:
/root/tmp/pear/PDO/php_pdo_driver.h:202:3: warning: passing argument 1 of 'zval_get_type' from incompatible pointer type [enabled by default]
   convert_to_string_ex(v);
   ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/Zend/zend.h:29:0,
                 from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:35,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_types.h:389:38: note: expected 'const struct zval *' but argument is of type 'struct zval **'
 static zend_always_inline zend_uchar zval_get_type(const zval* pz) {
                                      ^
In file included from /root/tmp/pear/PDO/pdo.c:32:0:
/root/tmp/pear/PDO/php_pdo_driver.h:202:3: warning: passing argument 1 of '_convert_to_string' from incompatible pointer type [enabled by default]
   convert_to_string_ex(v);
   ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/Zend/zend.h:328:0,
                 from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:35,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_operators.h:250:29: note: expected 'struct zval *' but argument is of type 'struct zval **'
 ZEND_API void ZEND_FASTCALL _convert_to_string(zval *op ZEND_FILE_LINE_DC);
                             ^
In file included from /root/tmp/pear/PDO/pdo.c:32:0:
/root/tmp/pear/PDO/php_pdo_driver.h:203:3: warning: passing argument 1 of '_estrndup' makes pointer from integer without a cast [enabled by default]
   return estrndup(Z_STRVAL_PP(v), Z_STRLEN_PP(v));
   ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/Zend/zend.h:31:0,
                 from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:35,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_alloc.h:85:31: note: expected 'const char *' but argument is of type 'int'
 ZEND_API char*  ZEND_FASTCALL _estrndup(const char *s, size_t length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
                               ^
In file included from /root/tmp/pear/PDO/pdo.c:33:0:
/root/tmp/pear/PDO/php_pdo_int.h: At top level:
/root/tmp/pear/PDO/php_pdo_int.h:34:1: error: unknown type name 'zend_object_value'
 extern zend_object_value pdo_dbh_new(zend_class_entry *ce TSRMLS_DC);
 ^
/root/tmp/pear/PDO/php_pdo_int.h:39:1: error: unknown type name 'zend_object_value'
 extern zend_object_value pdo_dbstmt_new(zend_class_entry *ce TSRMLS_DC);
 ^
/root/tmp/pear/PDO/php_pdo_int.h:48:1: error: unknown type name 'zend_object_value'
 extern zend_object_value pdo_row_new(zend_class_entry *ce TSRMLS_DC);
 ^
/root/tmp/pear/PDO/pdo.c: In function 'php_pdo_get_exception_base':
/root/tmp/pear/PDO/pdo.c:68:4: warning: passing argument 2 of 'zend_hash_find' from incompatible pointer type [enabled by default]
    if (zend_hash_find(CG(class_table), "runtimeexception", sizeof("RuntimeException"), (void **) &pce) == SUCCESS) {
    ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/Zend/zend.h:34:0,
                 from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:35,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_hash.h:168:30: note: expected 'struct zend_string *' but argument is of type 'char *'
 ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key);
                              ^
/root/tmp/pear/PDO/pdo.c:68:4: error: too many arguments to function 'zend_hash_find'
    if (zend_hash_find(CG(class_table), "runtimeexception", sizeof("RuntimeException"), (void **) &pce) == SUCCESS) {
    ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/Zend/zend.h:34:0,
                 from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:35,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_hash.h:168:30: note: declared here
 ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key);
                              ^
/root/tmp/pear/PDO/pdo.c: In function 'zif_pdo_drivers':
/root/tmp/pear/PDO/pdo.c:96:2: warning: passing argument 2 of 'zend_hash_get_current_data_ex' from incompatible pointer type [enabled by default]
  while (SUCCESS == zend_hash_get_current_data_ex(&pdo_driver_hash, (void**)&pdriver, &pos)) {
  ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/Zend/zend.h:34:0,
                 from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:35,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_hash.h:205:30: note: expected 'HashPosition *' but argument is of type 'void **'
 ZEND_API zval* ZEND_FASTCALL zend_hash_get_current_data_ex(HashTable *ht, HashPosition *pos);
                              ^
/root/tmp/pear/PDO/pdo.c:96:2: error: too many arguments to function 'zend_hash_get_current_data_ex'
  while (SUCCESS == zend_hash_get_current_data_ex(&pdo_driver_hash, (void**)&pdriver, &pos)) {
  ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/Zend/zend.h:34:0,
                 from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:35,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_hash.h:205:30: note: declared here
 ZEND_API zval* ZEND_FASTCALL zend_hash_get_current_data_ex(HashTable *ht, HashPosition *pos);
                              ^
/root/tmp/pear/PDO/pdo.c:97:3: error: too many arguments to function 'add_next_index_stringl'
   add_next_index_stringl(return_value, (char*)(*pdriver)->driver_name, (*pdriver)->driver_name_len, 1);
   ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:39:0,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_API.h:451:14: note: declared here
 ZEND_API int add_next_index_stringl(zval *arg, const char *str, size_t length);
              ^
/root/tmp/pear/PDO/pdo.c: In function 'php_pdo_register_driver':
/root/tmp/pear/PDO/pdo.c:165:2: warning: passing argument 2 of 'zend_hash_exists' from incompatible pointer type [enabled by default]
  if (!zend_hash_exists(&module_registry, "pdo", sizeof("pdo"))) {
  ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/Zend/zend.h:34:0,
                 from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:35,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_hash.h:193:34: note: expected 'struct zend_string *' but argument is of type 'char *'
 ZEND_API zend_bool ZEND_FASTCALL zend_hash_exists(const HashTable *ht, zend_string *key);
                                  ^
/root/tmp/pear/PDO/pdo.c:165:2: error: too many arguments to function 'zend_hash_exists'
  if (!zend_hash_exists(&module_registry, "pdo", sizeof("pdo"))) {
  ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/Zend/zend.h:34:0,
                 from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:35,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_hash.h:193:34: note: declared here
 ZEND_API zend_bool ZEND_FASTCALL zend_hash_exists(const HashTable *ht, zend_string *key);
                                  ^
/root/tmp/pear/PDO/pdo.c:171:41: error: macro "zend_hash_add" passed 6 arguments, but takes just 3
    (void**)&driver, sizeof(driver), NULL);
                                         ^
/root/tmp/pear/PDO/pdo.c:170:9: error: 'zend_hash_add' undeclared (first use in this function)
  return zend_hash_add(&pdo_driver_hash, (char*)driver->driver_name, driver->driver_name_len,
         ^
/root/tmp/pear/PDO/pdo.c:170:9: note: each undeclared identifier is reported only once for each function it appears in
/root/tmp/pear/PDO/pdo.c: In function 'php_pdo_unregister_driver':
/root/tmp/pear/PDO/pdo.c:176:2: warning: passing argument 2 of 'zend_hash_exists' from incompatible pointer type [enabled by default]
  if (!zend_hash_exists(&module_registry, "pdo", sizeof("pdo"))) {
  ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/Zend/zend.h:34:0,
                 from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:35,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_hash.h:193:34: note: expected 'struct zend_string *' but argument is of type 'char *'
 ZEND_API zend_bool ZEND_FASTCALL zend_hash_exists(const HashTable *ht, zend_string *key);
                                  ^
/root/tmp/pear/PDO/pdo.c:176:2: error: too many arguments to function 'zend_hash_exists'
  if (!zend_hash_exists(&module_registry, "pdo", sizeof("pdo"))) {
  ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/Zend/zend.h:34:0,
                 from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:35,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_hash.h:193:34: note: declared here
 ZEND_API zend_bool ZEND_FASTCALL zend_hash_exists(const HashTable *ht, zend_string *key);
                                  ^
/root/tmp/pear/PDO/pdo.c:180:2: warning: passing argument 2 of 'zend_hash_del' from incompatible pointer type [enabled by default]
  zend_hash_del(&pdo_driver_hash, (char*)driver->driver_name, driver->driver_name_len);
  ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/Zend/zend.h:34:0,
                 from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:35,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_hash.h:160:28: note: expected 'struct zend_string *' but argument is of type 'char *'
 ZEND_API int ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key);
                            ^
/root/tmp/pear/PDO/pdo.c:180:2: error: too many arguments to function 'zend_hash_del'
  zend_hash_del(&pdo_driver_hash, (char*)driver->driver_name, driver->driver_name_len);
  ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/Zend/zend.h:34:0,
                 from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:35,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_hash.h:160:28: note: declared here
 ZEND_API int ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key);
                            ^
/root/tmp/pear/PDO/pdo.c: In function 'pdo_find_driver':
/root/tmp/pear/PDO/pdo.c:187:2: warning: passing argument 2 of 'zend_hash_find' from incompatible pointer type [enabled by default]
  zend_hash_find(&pdo_driver_hash, (char*)name, namelen, (void**)&driver);
  ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/Zend/zend.h:34:0,
                 from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:35,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_hash.h:168:30: note: expected 'struct zend_string *' but argument is of type 'char *'
 ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key);
                              ^
/root/tmp/pear/PDO/pdo.c:187:2: error: too many arguments to function 'zend_hash_find'
  zend_hash_find(&pdo_driver_hash, (char*)name, namelen, (void**)&driver);
  ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/Zend/zend.h:34:0,
                 from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:35,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_hash.h:168:30: note: declared here
 ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key);
                              ^
/root/tmp/pear/PDO/pdo.c: In function 'zm_startup_pdo':
/root/tmp/pear/PDO/pdo.c:323:3: error: too many arguments to function 'zend_register_internal_class_ex'
   pdo_exception_ce = zend_register_internal_class_ex(&ce, php_pdo_get_exception_base(0 TSRMLS_CC), NULL TSRMLS_CC);
   ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:39:0,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_API.h:303:28: note: declared here
 ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce);
                            ^
/root/tmp/pear/PDO/pdo.c: In function 'zm_info_pdo':
/root/tmp/pear/PDO/pdo.c:371:2: warning: passing argument 2 of 'zend_hash_get_current_data_ex' from incompatible pointer type [enabled by default]
  while (SUCCESS == zend_hash_get_current_data_ex(&pdo_driver_hash, (void**)&pdriver, &pos)) {
  ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/Zend/zend.h:34:0,
                 from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:35,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_hash.h:205:30: note: expected 'HashPosition *' but argument is of type 'void **'
 ZEND_API zval* ZEND_FASTCALL zend_hash_get_current_data_ex(HashTable *ht, HashPosition *pos);
                              ^
/root/tmp/pear/PDO/pdo.c:371:2: error: too many arguments to function 'zend_hash_get_current_data_ex'
  while (SUCCESS == zend_hash_get_current_data_ex(&pdo_driver_hash, (void**)&pdriver, &pos)) {
  ^
In file included from /opt/cpanel/ea-php72/root/usr/include/php/Zend/zend.h:34:0,
                 from /opt/cpanel/ea-php72/root/usr/include/php/main/php.h:35,
                 from /root/tmp/pear/PDO/pdo.c:28:
/opt/cpanel/ea-php72/root/usr/include/php/Zend/zend_hash.h:205:30: note: declared here
 ZEND_API zval* ZEND_FASTCALL zend_hash_get_current_data_ex(HashTable *ht, HashPosition *pos);
                              ^
make: *** [pdo.lo] Error 1
ERROR: `make' failed

Anyone can please save my life :)


text:
Q: make panel height match with parent div I have created an html stuff using bootstrap 2.3.2 css. The html will be having four rows with different height such as for the first row it will 10%, second row - 20%, third row - 40% and the fourth row - 40% respetively. In third row I have placed a box like panel within each cell, The html is rendering but the problem is the height of the panel is not matching with the parent. Lets say if the content of the panel body exceeds then the panel comes out of the parent like as shown below

Now If the content of the panel body is less then the panel height seems not matching with the parent like as shown below

What I am trying to achieve is that the panel should fill within the parent div no matter whats the body content. when the body content of the panel exceeds the height of the parent div then a vertical scrollbar should come for the panel body.
My code is as given below
JSFiddle
html

content1

content1

content2

content2

 Grid 3

            fgdfg dad dsd dsadsad ds adsa d das ds dsa dsad sa d ad as dsad sa d sda dsa sa das dsa da asd sad

 Grid 3

            fgdfg

content3

content4

content4

content4

content4

A: Try flexbox.
Adjustments to CSS:
.row3 {
    height: 40%;
    background: orange;
    display: flex;
}

.row3 > .row-fluid {
    display: flex;
}

.row-fluid > .span4 {
    display: flex;
}

.panel {
    display: flex;
    flex-direction: column;
}

.panel-header {
    /* padding-bottom: 10px; */
    /* min-height: 12px; */
}

.panel-content {
   overflow-y: auto;
}

DEMO

Note that flexbox is supported by all major browsers, except IE 8 & 9. Some recent browser versions, such as Safari 8 and IE10, require vendor prefixes. For a quick way to add all the prefixes you need, post your CSS in the left panel here: Autoprefixer.

A: Add this class in your css.Hope this will be work.
  .panel-content {
    border: 1px solid red;
    padding: 2px;
    background: white;
    height: 40px;
    overflow-y: scroll;

 }

Updated : Jsfiddle

A: There are two ways you an go about this.
Using JavaScript, you can set the height of the children elements to that of the parent, or to the height of another child element, see my JSFiddle example. You can click on the child-2 element and it will take the height of child-1, I added the click just so you could see it taking the other elements height, it will set the height to the same as child-1
In JavaScript
var child1Height = $('.child-1').height();
$('.child-2').height(child1Height);

Alternatively you can use CSS, specify the height of the parent, and insure that the children elements have a height of 100%, child-2 element has a height of 100%, which will take the height of it's parent div that is set to 500px, see my JSFiddle example.
In CSS
.parent{
  width:400px;
  height: 500px;
}
.child-2{
  height:100%;
  overflow-y: auto;
}


text:
Q: File isn't uploaded to the server I am trying to create a drag and drop for my Web page but I ran into a problem where the file isn't uploaded to the server because the file array is empty apparently.
This is the js script to upload when the image is dropped onto a p tag
const dropped = e => {
 e.preventDefault();
 const files = e.dataTransfer.files;

if (files.length) {
    let list = '';
    for (let f = 0; f < files.length; f++) {
        list += `The file ${files[f].name} is being uploaded`;
        list += '
<progress value=0 max=100>0%</progress>';
    }
    dataBox.innerHTML = list;
    let count = 0;

    const upload = () => {
    // bug files array is empty
        const myfile = files[count];
        const data = new FormData();
        data.append('file', myfile);
        const url = 'fileupload.php';
        //const url = '.php';
        const request = new XMLHttpRequest();
        const xmlupload = request.upload;
         xmlupload.addEventListener('progress', e => {
             if (e.lengthComputable) {
                 let child = count + 1;
                 const per = parseInt(e.loaded / e.total * 100);
                 const progressBar =
                     dataBox.querySelector(`p:nth-child(${child}) > span >
                     progress`);
                 progressBar.value = per;
                 progressBar.innerHTML = `${per}%`;
             }
         });

        request.addEventListener('load', () => {
            dataBox.innerHTML = 'The image has been uploaded!';
            count++;
            if (count < files.length) upload();
        });
        request.open('POST', url);
        request.send(data);
      };
    upload();
   }
};

PHP:
if (empty($_POST['DATA_filename'])) {
   echo "";
   echo "";
   die();
}

move_uploaded_file($_FILES['file']['tmp_name'],
'/var/www/html/helra/ProjectSolution/uploads/' . $_FILES['file']['name']);
var_dump($_FILES['file']);


text:
Q: Pop method removes random element instead of top element in Python? In Python when we use pop method to remove an element from set why does it remove any random element? Instead of removing top element as per the stack's nature.

A: Because a set is an un-ordered collection of items, by definition. There it no "first" or "last" element. So, it removes a random one. If you want order, use a list instead.


text:
Q: Insert data into mysql from sql file or using csv file I have an db.sql file and I tried inserting the data from it to my local MYSQL using the command:
mysql -u root -p chitfund < db.sql . It doesn't show any error and also doesn't print anything. But when I try to see the tables in my db, it shows now tables.  I have the data in the form of .csv also. I tried inserting using mysql.connector , but it is not installing and throws an error. Is there any other way to insert the data using the sql or csv files.

A: The problem was with my .sql file. It didn't have any insert or create statements. I assumed it has the statements and the data is not being inserted. After having all the insert statements for inserting the data, it worked properly