text:
Q: In fragment I want to click back how to show alert dialog I am using navigation menu in an Activity. When I click menu, it goes to particular fragment that time I give addtobackstack(null). I want to fix these 2 issues:

*

*I want to show do you want to exit app through a popup In the back fragment

*Assume that I traverse from Fragment A to B and then B to C. If I give back in the Fragment C I want to come the main page, without showing the Fragment B.

This is my Home Activity:
package school.wyse.app.activities;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;

public class ParentHomeActivity extends AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener {
    ServerUtils servutil;
    GridLayoutManager grid;
    Toolbar toolbar;
    private View navHeader;
    LinearLayout profile;
    ImageView msglist;
    ArrayList<StudentProfile> lang_list_new;
    public RecyclerView studentsListRecyclerView;
     public ParentMenuDashoard mStudAdapter;
    StudentProfile[] profiles;
    private StudentProfile[] studentCachedData;
    Context ctx;
   DrawerLayout drawer;
    ImageView imageViewstaff;

    String tenent_id,profilename,image,userphone;

    Integer id,roleid;
    String backStateName;
    TextView profile_phone,profile_name;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        try {
            setContentView(R.layout.activity_parent_home);
           backStateName = this.getClass().getName();
            ctx=this;
         Toast.makeText(ctx, "backStateName--"+backStateName, Toast.LENGTH_SHORT).show();
            toolbar = (Toolbar) findViewById(R.id.toolbar);
            setSupportActionBar(toolbar);

            drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
            ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                    this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
            drawer.setDrawerListener(toggle);
            toggle.syncState();

            NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
            navigationView.setNavigationItemSelectedListener(this);
            navHeader=navigationView.getHeaderView(0);
            studentsListRecyclerView = (RecyclerView) navHeader.findViewById(R.id.messageWindowRecycler);

            ParentDashboard parentDashboard = new ParentDashboard();
            FragmentManager manager = getSupportFragmentManager();
            manager.beginTransaction().replace(R.id.content_frame, parentDashboard, parentDashboard.getTag()).commit();
            toolbar.setTitle("Dashboard");

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    @Override
    public void onBackPressed() {
        try {

          DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
            if (drawer.isDrawerOpen(GravityCompat.START)) {
                drawer.closeDrawer(GravityCompat.START);
            } else {

                super.onBackPressed();
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.home, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
  /*  if (id == R.id.action_msg) {
            return true;
        }*/

        return super.onOptionsItemSelected(item);
    }

    @SuppressWarnings("StatementWithEmptyBody")
    @Override
    public boolean onNavigationItemSelected(MenuItem item) {
        // Handle navigation view item clicks here.
        int id = item.getItemId();

        if (id == R.id.nav_dashboard) {
            ParentDashboard parentDashboard = new ParentDashboard();
            FragmentManager manager = getSupportFragmentManager();
            manager.beginTransaction().replace(R.id.content_frame, parentDashboard, parentDashboard.getTag()).addToBackStack(null).commit();
            //toolbar.setTitle("Dashboard");

        } else if (id == R.id.nav_teachers) {
            TeacherList teacherList = new TeacherList();
            FragmentManager manager = getSupportFragmentManager();

          //  manager.beginTransaction().replace(R.id.id_content_frame, accountsMenuListFragment, "AccountsMenu").addToBackStack(" ").commit();
            manager.beginTransaction().replace(R.id.content_frame, teacherList, teacherList.getTag()).addToBackStack(null).commit();
          //  toolbar.setTitle("Teachers");

        } else if (id == R.id.nav_attendance) {
            AttendanceFragment attendanceFragment = new AttendanceFragment();
            FragmentManager manager = getSupportFragmentManager();
            manager.beginTransaction().replace(R.id.content_frame, attendanceFragment, attendanceFragment.getTag()).addToBackStack(null).commit();
           // toolbar.setTitle("Attendance");

        } else if (id == R.id.nav_consumablity) {
            ParentConsumablityFragment parentConsumablityFragment = new ParentConsumablityFragment();
            FragmentManager manager = getSupportFragmentManager();
            manager.beginTransaction().replace(R.id.content_frame, parentConsumablityFragment, parentConsumablityFragment.getTag()).addToBackStack(null).commit();
            // toolbar.setTitle("Attendance");

        }
        else {

        }

        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        drawer.closeDrawer(GravityCompat.START);
        return true;
    }

}

A: Okay, sorry for late reply
This part goes in onBackPressed() of your activity, which basically check if you have fragments attached (so it won't perform the native back, which closes the app)
if (childFragments.size() > 0) {
        if (childFragments.get((childFragments.size() - 1)) != null) {
            childFragments.remove(childFragments.size() - 1);
            return;
        }
    }

All you have to do is add/remove items to this array every time you attach / detach fragments :)
For your particular case when you are on fragment C and want to go back to fragment A without showing fragment B, I suggest you make a public function that remove all fragments from ArrayList except last one (from position 0)

A: *

*Use below code in mainactivity where you want to show appexit:
     @Override
public void onBackPressed() {

if (doubleBackToExitPressedOnce) {
    super.onBackPressed();
    finish();
    return;
}
this.doubleBackToExitPressedOnce = true;
Toast.makeText(this, "Please click BACK again to exit", Toast.LENGTH_SHORT).show();

new Handler().postDelayed(new Runnable() {

    @Override
    public void run() {
        doubleBackToExitPressedOnce = false;
    }
}, 2000);

}

*When moving fragment A to B do not add "addbackstack". When moving fragment B to C add "addbackstack("C")"

A: first of all, you have to take care of your second issue as it will lead to easy handle for the first issue, hence you have to take care of how to initiate the fragments in order to always coming to the first fragment while hitting back regardless the flow of fragments that lead to the current fragment, to do so, just initiate the fragments like the following:
/**
 * To initiate any fragment
 */
private void showAnyFragment(Fragment fragmentToShow) {
    getSupportFragmentManager().popBackStack();
    FrameLayout frameLayout = (FrameLayout) findViewById(R.id.content);
    frameLayout.setVisibility(View.VISIBLE);

    getSupportFragmentManager().beginTransaction()
            .replace(R.id.content, fragmentToShow)
            .addToBackStack(null)
            .commit();
}

/**
 * When (for a reason) you want to initiate the main fragment (FragmentA)
 */
private void homeClicked() {
    getSupportFragmentManager().popBackStack();
}

Now, fragmentA is your main fragment, when going from A to B to C to D and click back button it will go back to A directly.
Coming to your second issue, it will be straight forward as you already keeping only fragmentA always in the back stack, so onBackPressed() function of the Activity will not be called unless there are No other fragment other than FragmentAis being displayed(e.g if you are in fragmentC and you click back button, the onBackPressed() function will not be called), so you are sure that when you come inside onBackPressed() function of the activity that the currently running fragment is FragmentA which is your main page fragment.
so if you want to display a popup while the user trying to exit the app (he would be in FragmentA and hiitting Back), all you have to do is to override the onBackPressed() method of the MainActivity that holds the fragments:
@Override
public void onBackPressed() {
  // the user here is in FragmentA(main page),
          and he is clicking back to exit the app.
  // TODO show popup here or do whatever you want
}


text:
Q: Append first column to file I have a file that looks like this:
Heading1,Heading2
value1,value2

And another one that looks like this:
Row1
Row2

How can I combine the two to become:
Row1,Heading1,Heading2
Row2,value1,value2

Effectively appending a column in the place of the first column?

A: Job for paste:
paste -d, f2.txt f1.txt

*

*-d, sets the delimiter as , (instead of tab)

With awk:
awk 'BEGIN {FS=OFS=","} NR==FNR {a[NR]=$0; next} {print a[FNR], $0}' f2.txt f1.txt

*

*BEGIN {FS=OFS=","} sets the input and output field separators as ,

*NR==FNR {a[NR]=$0; next}: for first file (f2.txt), we are saving the record number as key to an associative array (a) with values being the corresponding record

*{print a[FNR], $0}: for second file, we are just printing the record with the value of record number-ed key from a prepended

Example:
% cat f1.txt
Heading1,Heading2
value1,value2

% cat f2.txt
Row1
Row2

% paste -d, f2.txt f1.txt
Row1,Heading1,Heading2
Row2,value1,value2

% awk 'BEGIN {FS=OFS=","} NR==FNR {a[NR]=$0; next} {print a[FNR], $0}' f2.txt f1.txt
Row1,Heading1,Heading2
Row2,value1,value2

A: Another short awk approach.
awk '{getline x<"file1"; print $0","x}' file2

*

*getline x<"file1" reads the entire line from file1 and holds into x variable.

*print $0","x prints the whole line from file2 by using $0 then x which is the saved line of file1 with comma between.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Git over ngrok tunnel forwarding I have a git repo on my local instance. I want to access this from outside my home network. Should I create a git server and ssh server on my local instance for this? Also what is the port I should tunnel using ngrok.
Any inputs are greatly appreciated.

A: As illustrated in issue 193 or issue 145, and ngrok usage, you can directly expose your ssh port (22), with authencation (authtoken).

First, you need register a ngrok account, go to the dashboard will get a token, then execute command like this in you linux server

./ngrok -authtoken as80YQhzsxIIMkMFF8gI -proto=tcp 22

In that case, no git server would be needed, you could clone directly your repo with:
git clone ssh://user@ip.of.local.host:/path/to/repo.git

('repo.git' because you should use a bare repo to push back to)
The only git "server" which comes with git is the git daemon (nothing to do with ssh)
You would use ngrok to redirect http only if you had an http server in front of your Git, using the smart http protocol.
In that case, you could configure Apache to call git-http-backend.


text:
Q: Disable/Enable Comment Block With Macro? Is there a way to make a macro within a LaTeX document, which would enable or disable a comment block?  I do this sort of thing in C and C++, but am not sure about LaTeX.
For example, near the top of the document I would like some sort of line(s) which have a 0 or a 1.  I would change between the 0 and 1 at my discretion.  If 0, then my later portion would look like:
\begin{comment}
\begin{figure}[ht]
    \centering
    \includegraphics[width=0.5\textwidth]{BLARG.jpg}
    \caption{\label{fig:}HONK.}
\end{figure}
\FloatBarrier
\end{comment}

But if the macro number were 1, it would disable the comment function, so it would effectively leave the document with:
\begin{figure}[ht]
    \centering
    \includegraphics[width=0.5\textwidth]{BLARG.jpg}
    \caption{\label{fig:}HONK.}
\end{figure}
\FloatBarrier

Is this possible?

A: Yes... if you write your own comment environment using environ:

\documentclass{article}

\usepackage{environ,graphicx}

\NewEnviron{comment}{%
  \ifnum\keepcomment=1
  \else
    \BODY
  \fi
}

%\newcommand{\keepcomment}{1}% Keep comment
\newcommand{\keepcomment}{0}% Remove comment

\begin{document}

Some text before the figure.

\begin{comment}
  \begin{figure}[ht]
    \centering
    \includegraphics[width=0.5\textwidth]{example-image}
    \caption{\label{fig:example}Example image.}
  \end{figure}
\end{comment}

Some text after the figure.

\end{document}

If you're using the comment package you can do something similar:
\usepackage{comment}

%\newcommand{\keepcomment}{1}% Keep comment
\newcommand{\keepcomment}{0}% Remove comment

\AtBeginDocument{\ifnum\keepcomment=1
  \excludecomment{comment}
\else
  \includecomment{comment}
\fi}


text:
Q: Limit of the derivative of a function Under what conditions is true:
If
$$\lim_{x\rightarrow\pm\infty}\Phi(x,y)\rightarrow 0$$
then
$$\lim_{x\rightarrow\pm\infty}\frac{\partial}{\partial x}\Phi(x,y)\rightarrow 0$$
Some time ago I studied this, however I do not remember this theorem, could someone tell me what the conditions. In advance, thank you very much.

A: If for all $y$, the function $f:x\mapsto \Phi(x,y)$ has a horizontal asymptote of equation $z=0$ it work (in the plan $y=cste$). I hope I have helped you.


text:
Q: `type *var = (int)0`, legal or not? The following example:
char *var = (int)0;

Compiles on gcc and cl.exe, but causes an error in clang:

cannot initialize a variable of type 'char *' with an rvalue of type 'int'

Who is correct here?

For what it's worth, C++11 says (emphasis mine)

4.10/1
A null pointer constant is an integral constant expression (5.19) prvalue of integer type that evaluates to zero or a prvalue of type std::nullptr_t. A null pointer constant can be converted to a pointer type; the result is the null pointer value of that type and ...

And

5.19/3
An integral constant expression is a literal constant expression of integral or unscoped enumeration type. [ Note: Such expressions may be used as array bounds (8.3.4, 5.3.4), as bit-field lengths (9.6), as enumerator initializers if the underlying type is not fixed (7.2), as null pointer constants (4.10), and as alignments (7.6.2). — end note ]

From what I understand, the above code should be illegal. cl.exe notoriously violates the standard (so I don't trust it a bit), but gcc also accepts the above code. Are there other parts of the standard relevant that I'm missing or is that outright a gcc bug?

A: Originally, in C++11, this was legal because the wording was:

A null pointer constant is an integral constant expression (5.19) prvalue of integer type that evaluates to zero

But, as of CWG defect 903, which is a defect against C++11, it became not legal:

A null pointer constant is an integer literal (2.13.2 [lex.icon]) with value zero

(int)0 is an integral constant expression prvalue of integer type that evalutes to zero, but it's not literally an integer literal with value 0.
As this is a defect against C++11, the code itself should be ill-formed in C++11.


text:
Q: Composite heuristic for the 8-puzzle While reading Artificial Intelligence a Modern Approach I came across the concept of deriving a heuristic from the solution cost of a sub-problem of a given problem.
For example, the following puzzles shows a sub problem of the 8-puzzle instance where the goal is to place tiles 1, 2, 3, 4 into their correct positions.
Start State = [ * 2 4 ]    Goal State = [   1 2 ]
              [ *   * ]                 [ 3 4 * ]
              [ * 3 1 ]                 [ * * * ]

Then, the author expand this concept by saying that these heuristics derived from the sub-problems can be combined by taking the maximum value.
h(n)= max{ h1(n), . . , hm(n) }

Moreover, by using this approach the performance is improved greatly when compared to a simple heuristic like Manhattan distance.
I have been trying to wrap my head around the composite heuristics and the reasoning behing them. Let's say we have two heuristics derived from the solution cost of the following sub-problems:
h1234(n) = [   1 2 ]     h5678(n) = [   * * ]
           [ 3 4 * ]                [ * * 5 ]
           [ * * * ]                [ 6 7 8 ]

Will a composite heuristic like:
h1...8(n)= max{ h1234(n), h5678(n) }

*

*Really work in finding a solution for the complete 8-puzzle problem?

It seems to me that using a heuristic like h1...8(n) we will end up alternating between heuristics h1234(n) and h5678(n) which in turn might lead to one heuristic messing up the work of the other and never reaching a solution.

*Or will the heuristics help each other towards the complete solution?

Honestly, I do no see how this could work...

A: First I will give you a brief overview of the idea behind the heuristic and why solving a subproblem, also called relaxed problem, helps to find the solution. Then, I will cast the following general considerations to the 8-puzzle problem and thus answer to your specific question. For more detailed information, you can start, as you already did, reading carefully Chapter 3 of Artificial Intelligence: a Modern Approach, by Stuart and Russell; if you want to deepen the topic about best-first search strategies and heuristics, you can start from one of the seminal papers by Dechter and Pearl, 1984, ACM, and look at the cited papers and those who cite it.
Overview of heuristics and informed search
The idea behind using a heuristic is to guide the search through the search space (usually exponential size) and carefully selecting nodes to be expanded (this type of search algorithms are also called informed search algorithms). If the heuristic is good (namely, close to the actual cost to the goal, starting from an initial state), then the number of nodes expanded during the search is greatly reduced, and actually that number is optimal -- namely no other search algorithm can expand less nodes guaranteeing optimality of the solution. Remember that the heuristic should be admissible -- its value of a given node should not exceed the actual cost to the goal. This is the only property required if an open list is used, namely not eliminating duplicate states. If duplicate states are eliminated, the heuristic should be also consistent -- i.e., the heuristic of a given node should be less or equal than the sum of the cost to get to a successor node and the heuristic in that successor node.
Usually, finding a solution for a relaxed problem can be done in less computation time. A heuristic can be extracted from that solution and is typically more informative than a heuristic coming from just an estimate on the whole problem, as the solution provides actual actions that should be performed. Notice that when defining a subproblem, it is fundamental to check whether the heuristic that can be derived from the solution of the subproblem is still admissible for the general problem, in order to have an optimal solution.
8-puzzle problem
In the specific case of 8-puzzle, the heuristic coming from the subproblem is still intuitively admissible for the original problem. Specifically, the optimal solution in the original problem is also a solution to the relaxed problem and satisfies in addition all the relaxed
constraints. So, the solution cost matches at most the original
optimal solution. Second, the relaxed problem has fewer constraints. Therefore, the search algorithm can find less expensive solutions and provide a lower cost, thus admissible, relaxed solution.
Given this analysis and answering to your question, using the heuristic that you mention works in finding a solution for the complete 8-puzzle problem. Taking the max allows to have an estimate closer (and admissible) to the actual cost to the solution and thus helping expanding less number of nodes.


text:
Q: Can I count the occurences for postgres array field? I have a table postgres that uses the array type of data, it allows some magic making it possible to avoid having more tables, but the non-standard nature of this makes it more difficult to operate with for a beginner.
I would like to get some summary data out of it.
Sample content:
CREATE TABLE public.cts (
    id serial NOT NULL,
    day timestamp NULL,
    ct varchar[] NULL,
    CONSTRAINT ctrlcts_pkey PRIMARY KEY (id)
);

INSERT INTO public.cts
(id, day, ct)
VALUES(29, '2015-01-24 00:00:00.000', '{ct286,ct281}');
INSERT INTO public.cts
(id, day, ct)
VALUES(30, '2015-01-25 00:00:00.000', '{ct286,ct281}');
INSERT INTO public.cts
(id, day, ct)
VALUES(31, '2015-01-26 00:00:00.000', '{ct286,ct277,ct281}');

I would like to get the totals per array member occurence totalized, with an output like this for example:
name | value
ct286 | 3
ct281 | 3
ct277 | 1

A: Use  Postgres function array unnest():
SELECT name, COUNT(*) cnt
FROM cts, unnest(ct) as u(name)
GROUP BY name

Demo on DB Fiddle:
| name  | cnt |
| ----- | --- |
| ct277 | 1   |
| ct281 | 3   |
| ct286 | 3   |


text:
Q: Using sets in a list comprehension what I am trying to do:
Create and print a list of words for which the reverse of the word is in the set of lower-case words.  For example, "timer" and its reverse, "remit", are both in the lower-case word list.
what i have so far:
     s = set(lowers)
     [word for word in s if list(word).reverse() in s]

i just get an empty list.

A: just use [::-1], using list() is unnecessary here and list(word).reverse() returns None as it changes the list in-place . You can also use "".join(reversed(word)), but I guess just word[::-1] is simple enough:
[word for word in s if word[::-1] in s]
In [193]: word="timer"

In [194]: print list(word).reverse()
None

In [195]: word[::-1]
Out[195]: 'remit'

In [196]: "".join(reversed(word))
Out[196]: 'remit'

A: The list.reverse() method reverses a list in place.  Its return value is None.  If you want to reverse a string just use word[::-1].

A: list.reverse() reverses the list in place and returns nothing. You need "".join(reversed(list)).

A: Try this:
s = set(lowers)
[word for word in s if word.lower()[::-1] in s]

A: You should be using [::-1] for reversing the string -
[word for word in s if word[::-1] in s]


text:
Q: CAP file contains the main applet class & all other class file details when dumped in ASCII format Am using javacard 3.0.4 development kit to build the cap file. The class files are generated using 'javac -g -classpath %JC_HOME%\lib\api.jar;%JC_HOME%\lib\installer.jar PATH_TO_THE_JAVA_FILES_OF_THE_PROJECT' command.
Am using converter to convert the class files to CAP file by providing a config file.
The Config file contents :
-out EXP JCA CAP
-classdir PATH_TO_CLASS_FILES
-exportpath PATH_TO_EXPORT_API_FILES
-applet 0xa0:0x00:0x00:0x00:0x62:0x12:0x34 MyWallet.Wallet
MyWallet 0xa0:0x00:0x00:0x00:0x62:0x12:0x34 1.0

The cap is generated successfully. But when i see the ascii format of the cap(using capdump.bat) i see it contains all the applet class files info which is a security issue.
When i generate cap file using eclipse (which has the JCOP plugin installed), the CAP file doesn't contain any class file info.
So please someone help me to get rid of class file info in CAP file when generated using CONVERTER.bat on command line.

A: Decompilation can always take place, in the end Java is targeting the JVM after all, using a subset of Java byte code. So I would not put too much trust on measures such as hiding the class / methods name.
However, if you don't want to have such information generated then simply remove the EXP options, which is required to link against your applet and the JCA option, which according to the Oracle documentation is

... a text representation of the contents of a CAP file. To mask a Java Card applet into a smart card, you need to convert the applet class and all the classes in its package to a JCA file. You then specify the JCA file and the JCA files for any other packages to be included in the mask as input to the mask generator.

So you only need to use this file when ROM masking is required. If you just want to upload it yourself, then the JCA file is not required.

A: Thanks Maarteen for the explanation, it did help me to understand masking concept.
My issue got resolved after setting up ant task for cap file building. The class file information in the cap file did got removed by ant build.


text:
Q: korean and alphabet regex returning false I have been having trouble validating a form input for my website. Im looking the accept both english characters and korean characters for the name field. I had no trouble with inputting korean characters but at soon as I added the korean regex, the function has been returning false while without it returns true.
var recommend_coffee_your_name_field = $('#coffee_recommend_your_name_field');

recommend_coffee_your_name_field.keyup(function(e) {
  var $th = $(this);
  $th.val( $th.val().replace(/[^a-zA-Z0-9\u{3130}-\u{318F}\u{AC00}-\u{D7AF}]/g, function(str) {
    alert('You typed " ' + str + ' ".\n\nPlease use only letters and numbers.'); return '';
  } ) );

  if(e.keyCode !== 8 || e.keyCode !== 9 ) {
    var recommend_coffee_your_name_field_length = recommend_coffee_your_name_field.val().length;
    //console.log("Your Name Field Length: " + your_name_field_length);

    if( recommend_coffee_your_name_field_length > 0 ){
      //recommend_coffee_your_name_field.removeClass("error").addClass("success");
      recommend_coffee_shop_your_name_value = true;
    }
    else{
      //recommend_coffee_your_name_field.removeClass("success").addClass("error");
      recommend_coffee_shop_your_name_value = false;
    }
    if (!recommend_coffee_shop_your_name_value) {
      alert("The name field is missing");
      e.preventDefault();
    }
});

A: In your case, it is enough to remove the curly braces from the Unicode escape sequences:
/[^a-zA-Z0-9\u3130-\u318F\uAC00-\uD7AF]/g

Note that \u{3130} is only possible in ECMAScript 6 compatible browsers, please refer to ECMAScript 6 Compatibility Table.
The JavaScript String Literals Guide calls \uXXXX Unicode escape sequences:

The Unicode escape sequences require at least four characters following \u.
Example: \u00A9 = ©

And \u{XXXXX} are called Unicode code point escapes:

New in ECMAScript 6. With Unicode code point escapes, any character can be escaped using hexadecimal numbers so that it is possible to use Unicode code points up to 0x10FFFF. With simple Unicode escapes it is often necessary to write the surrogate halves separately to achieve the same.
Example:\u{2F804} // The same with simple Unicode escapes: \uD87E\uDC04


text:
Q: How to make a square sized HTML table fill screen in Android webview Hope someone can help me with this.
In my Android app I have a fragment with a webview (and some other views). The webview displays a page with a HTML table. This table is a game board, with 8 x 8 cells (like a Chess board).
The problem is that I want the table to fill the screen as much as possible. But at the same time it also needs to be perfectly squared (width and height must stay the same).
How can I do that? Setting width and height to 100% in the HTML wont't make it square. And if I set them to fixed numbers they don't resize on different screen sizes. I also tried to use WebView.getWidth() to get the size of the webview, and then scale the table to fill it. But I can't know the size of the webview until the page is loaded, and I can't load the page until I know the size of the webview...

A few other details (I don't know if they are relevant):
The layout in the fragment is inflated from a layout file in Fragment.onCreateView. Then, in Fragment.onActivityCreated I add the webview to the fragment by Java code. The HTML is also created dynamically by Java code.

A: I finally found a soloution to this:

*

*Instead of trying to get the size of the webview, I take the size of the fragment and subtract the size of the other views. This gives me the remaining space available for the webview.

*Even in onResume all the dimensions are zero, though. So in onResume I create a Handler which runs after half a second. Here I create the HTML document to be displayed.

*I set the size of the HTML document to be half the size of the space available in the fragment. (I have no idea why I need to half it.)
This is an ugly soloution, but it works both in landscape and portrait mode on both my phone and tablet.


text:
Q: I don't want to store passwords in an unencrypted file I'm using Ubuntu 12.04 LTS on my developer machine and just realized that psql stores passwords in '~/.pgpass'. Furthermore this file is unencrypted. So anyone who has super user rights (i.e. is in group sudo) can access this file and read stored passwords. That's the worst case it could be.
Instead I'm wondering that psql does not ask for a password (just modified a pg_hba.conf on a postgresql server) and began to doubt about my administration skills.
The documentation just tells us how to create the file and how it should look like.. I want to disable this file as soon as possible. But how?
NO SOLUTION
The problem is pgadmin creates this file when I want to store my passwords. It is a GUI and to use a GUI I'm already logged in and mostly the window manager has something like a keyring that is decrypted when I log in. It would be wonderful if pgadmin could use this but as discussed in the answer: it's a feature request for pgadmin.

A: Delete it. .pgpass is just a file. Enter the passwords on the command line if you don't want to store them. psql will never create or modify .pgpass, so you must've set it up yourself.
It makes no sense to store .pgpass encrypted; you'd need a password to decrypt it, and the whole point of .pgpass is for automating password logins.
The solution here is don't use a .pgpass file if you don't really need the passwordless login and aren't willing to accept the security compromises it imposes. Since it sounds like your .pgpass was created by PgAdmin-III, tell it not to save passwords and it won't create .pgpass. It gave you a big warning the first time you told it to save a password, telling you that it would store the password in clear text, for exactly this reason.
If you need strong and secure passwordless logins, use Kerberos / GSSAPI.
That said, anyone who has super-user rights can get your passwords no matter what you do. They can capture your typing with a keylogger. They can modify libpq to save the passwords to a file as they're entered. Lots of options. If you don't trust the superuser(s) on your machine, find somewhere else to work from, because you've already lost.


text:
Q: PHPMailer issue - Email appears to send with no errors The following code worked before I added the $_POSTs and populated the email variables manually but doesn't work now I've added them. Looking at the output, it appears that everything is OK, but I do not receive an the email (I've tried two different "To" addresses just incase it's an inbound server issue. Any thoughts?
`
`<?php
  require("PHPMailer-master/src/PHPMailer.php");
  require("PHPMailer-master/src/SMTP.php");
  require_once 'PHPMailer-master/src/Exception.php';

  if(isset($_POST['submit'])){
   $name=$_POST['name'];
   $email=$_POST['email'];
   $phone=$_POST['phone'];
   $date=$_POST['date'];
   $p_name=$_POST['p_name'];
   $dob=$_POST['dob'];
   $gender=$_POST['gender'];
   $height=$_POST['height'];
   $weight=$_POST['weight'];
   $oxygen=$_POST['oxygen'];
   $message=$_POST['message'];

  $mail = new PHPMailer\PHPMailer\PHPMailer();
    $mail->IsSMTP(); // enable SMTP

    $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
    $mail->SMTPAuth = true; // authentication enabled
    $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
    $mail->Host = "smtp.xxxx.co.uk";
    $mail->Port = 465; // or 587
    $mail->IsHTML(true);
    $mail->Username = "website@pxxxxxxxx.com";
    $mail->Password = "xxxxxxxxxxxxxxxxxxx";
    $mail->SetFrom($email, $name);
    $mail->Subject = "Website Repatriation Form";
    $mail->Body = "Contact Name: ".$name."\n"."Contact Phone No: ".$phone."\n"."Patient's Name: ".$p_name."\n"."Date of Birth: ".$dob."\n"."Gender: ".$gender."\n"."Height: ".$height."\n"."Needs Oxygen? :".$oxygen."\n"."Message:"."\n".$message;
    $mail->AddAddress("xxxxxxxxxxxxxxxxx");

     if(!$mail->Send()) {
        echo "Mailer Error: " . $mail->ErrorInfo;
     } else {
        echo "Message has been sent";
     }
   }
?>`

`
With logging turned on, I get the following output:
2022-11-21 11:24:17 CLIENT -> SERVER: EHLO xxxxxxxx.com
2022-11-21 11:24:17 CLIENT -> SERVER: AUTH LOGIN
2022-11-21 11:24:17 CLIENT -> SERVER: [credentials hidden]
2022-11-21 11:24:17 CLIENT -> SERVER: [credentials hidden]
2022-11-21 11:24:17 CLIENT -> SERVER: MAIL FROM:<name@domain.com>
2022-11-21 11:24:17 CLIENT -> SERVER: RCPT TO:<name@domain.co.uk>
2022-11-21 11:24:17 CLIENT -> SERVER: DATA
2022-11-21 11:24:17 CLIENT -> SERVER: Date: Mon, 21 Nov 2022 12:24:17 +0100
2022-11-21 11:24:17 CLIENT -> SERVER: To: name@domain.co.uk
2022-11-21 11:24:17 CLIENT -> SERVER: From: Name <name@domain.com>
2022-11-21 11:24:17 CLIENT -> SERVER: Subject: Website Repatriation Form
2022-11-21 11:24:17 CLIENT -> SERVER: Message-ID: <WANZgAlHnYVPWwcMaFO7zyV8AXyiFTzo@domain.com>
2022-11-21 11:24:17 CLIENT -> SERVER: X-Mailer: PHPMailer 6.6.5 (https://github.com/PHPMailer/PHPMailer)
2022-11-21 11:24:17 CLIENT -> SERVER: MIME-Version: 1.0
2022-11-21 11:24:17 CLIENT -> SERVER: Content-Type: text/html; charset=iso-8859-1
2022-11-21 11:24:17 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
2022-11-21 11:24:17 CLIENT -> SERVER:
2022-11-21 11:24:17 CLIENT -> SERVER: Contact Name: Webform name
2022-11-21 11:24:17 CLIENT -> SERVER: Contact Phone No: xxxxxxxxxxx
2022-11-21 11:24:17 CLIENT -> SERVER: Patient's Name: Eric Sprognasty
2022-11-21 11:24:17 CLIENT -> SERVER: Date of Birth: 1956-01-01
2022-11-21 11:24:17 CLIENT -> SERVER: Gender: Male
2022-11-21 11:24:17 CLIENT -> SERVER: Height: 5'11"
2022-11-21 11:24:17 CLIENT -> SERVER: Needs Oxygen? :No
2022-11-21 11:24:17 CLIENT -> SERVER: Message:
2022-11-21 11:24:17 CLIENT -> SERVER: Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorem aspernatur magnam sapiente dicta, harum quae iure, labore tenetur cumque odio nostrum nesciunt quos tempora maiores animi id et soluta vitae.

2022-11-21 11:24:17 CLIENT -> SERVER:
2022-11-21 11:24:17 CLIENT -> SERVER: .
2022-11-21 11:24:18 CLIENT -> SERVER: QUIT
Message has been sent

Running out of ideas. Ran the form with manually set email variables and it worked


text:
Q: For-loop that creates objects from dataset So I need a for-loop to create data (Ref_Date ~ Value) that can be used for time series analysis. For each (Value) its EST is the type, and PRI, SEAS need to be specified. However the code doesn't generate the desired result. First of all the name of each object has only the first letter however I wanted a conversion from "Non-profit institutions serving households' final consume" to "NISHFC". Second the observations are not added to the objects.
csv data
Ref_Date,GEO,PRI,SEAS,EST,Vector,Coordinate,Value
1981/03,Canada,Chained (2007) dollars,Seasonally adjusted at annual rates,"Final consumption expenditure (x 1,000,000)",v62305723,1.1.1.1,604670.000
1981/06,Canada,Chained (2007) dollars,Seasonally adjusted at annual rates,"Final consumption expenditure (x 1,000,000)",v62305723,1.1.1.1,603745.000
1981/09,Canada,Chained (2007) dollars,Seasonally adjusted at annual rates,"Final consumption expenditure (x 1,000,000)",v62305723,1.1.1.1,603415.000
1981/12,Canada,Chained (2007) dollars,Seasonally adjusted at annual rates,"Final consumption expenditure (x 1,000,000)",v62305723,1.1.1.1,604700.000
1982/03,Canada,Chained (2007) dollars,Seasonally adjusted at annual rates,"Final consumption expenditure (x 1,000,000)",v62305723,1.1.1.1,596566.000
1982/06,Canada,Chained (2007) dollars,Seasonally adjusted at annual rates,"Final consumption expenditure (x 1,000,000)",v62305723,1.1.1.1,594937.000
1982/09,Canada,Chained (2007) dollars,Seasonally adjusted at annual rates,"Final consumption expenditure (x 1,000,000)",v62305723,1.1.1.1,594907.000
1982/12,Canada,Chained (2007) dollars,Seasonally adjusted at annual rates,"Final consumption expenditure (x 1,000,000)",v62305723,1.1.1.1,593993.000
1983/03,Canada,Chained (2007) dollars,Seasonally adjusted at annual rates,"Final consumption expenditure (x 1,000,000)",v62305723,1.1.1.1,596617.000
1983/06,Canada,Chained (2007) dollars,Seasonally adjusted at annual rates,"Final consumption expenditure (x 1,000,000)",v62305723,1.1.1.1,604931.000
1983/09,Canada,Chained (2007) dollars,Seasonally adjusted at annual rates,"Final consumption expenditure (x 1,000,000)",v62305723,1.1.1.1,611881.000

data displayed in R
  Ref_Date    GEO                    PRI                                SEAS                                         EST    Vector Coordinate      Value
1  1981/03 Canada Chained (2007) dollars Seasonally adjusted at annual rates Final consumption expenditure (x 1,000,000) v62305723    1.1.1.1 604670.000
2  1981/06 Canada Chained (2007) dollars Seasonally adjusted at annual rates Final consumption expenditure (x 1,000,000) v62305723    1.1.1.1 603745.000
3  1981/09 Canada Chained (2007) dollars Seasonally adjusted at annual rates Final consumption expenditure (x 1,000,000) v62305723    1.1.1.1 603415.000
4  1981/12 Canada Chained (2007) dollars Seasonally adjusted at annual rates Final consumption expenditure (x 1,000,000) v62305723    1.1.1.1 604700.000
5  1982/03 Canada Chained (2007) dollars Seasonally adjusted at annual rates Final consumption expenditure (x 1,000,000) v62305723    1.1.1.1 596566.000
6  1982/06 Canada Chained (2007) dollars Seasonally adjusted at annual rates Final consumption expenditure (x 1,000,000) v62305723    1.1.1.1 594937.000

code:
library(zoo);

require(ggplot2);
require(xts);
require(tseries);
require(timeDate);
require(forecast);

GDP = read.csv(
  "~/Desktop/GDP.csv"
  );

attach(GDP);

for (est in unique(EST)) {
  if (!grepl("(x 1,000,000)", est)) {
    string_list = strsplit(est, " ");
    name = "";
    for (string in string_list) {
      name = paste(substr(string,1,1), name, " ");
    }
    assign(toupper(name), GDP[which(EST==est &
                             PRI=="Current prices" &
                             SEAS=="Seasonally adjusted at annual rates"),
                     c(1,8)]);
  }
}

warnings:
Warning messages:
1: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
2: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
3: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
4: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
5: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
6: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
7: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
8: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
9: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
10: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
11: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
12: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
13: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
14: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
15: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
16: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
17: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
18: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
19: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
20: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
21: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
22: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
23: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
24: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
25: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
26: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name
27: In assign(toupper(name), GDP[which(EST == est & PRI ==  ... :
  only the first element is used as variable name

A: Parsing the data in the format that you have included it in the question is actually harder than answering your question.
library(dplyr)
library(readr)

# test for the question
text_so = "1  1981/03 Canada Chained (2007) dollars Seasonally adjusted at annual rates Final consumption expenditure (x 1,000,000) v62305723    1.1.1.1 604670.000
2  1981/06 Canada Chained (2007) dollars Seasonally adjusted at annual rates Final consumption expenditure (x 1,000,000) v62305723    1.1.1.1 603745.000
3  1981/09 Canada Chained (2007) dollars Seasonally adjusted at annual rates Final consumption expenditure (x 1,000,000) v62305723    1.1.1.1 603415.000
4  1981/12 Canada Chained (2007) dollars Seasonally adjusted at annual rates Final consumption expenditure (x 1,000,000) v62305723    1.1.1.1 604700.000
5  1982/03 Canada Chained (2007) dollars Seasonally adjusted at annual rates Final consumption expenditure (x 1,000,000) v62305723    1.1.1.1 596566.000
6  1982/06 Canada Chained (2007) dollars Seasonally adjusted at annual rates Final consumption expenditure (x 1,000,000) v62305723    1.1.1.1 594937.000"

# read in fixed width format file
df_foo = readr::read_fwf(
  text_so,
  fwf_positions(
    start = c(1, 4, 12, 19, 42, 78, 122, 135, 143),
    end = c(2, 11, 18, 41, 77, 121, 134, 142, 152),
    col_names = c("Serial #", "Ref_Date", "GEO", "PRI", "SEAS", "EST", "Vector", "Coordinate", "Value")
  )
)

Your problem (as I understand it) can be easily solved using abbreviate -- you appear to want to abbreviate EST uniquely within groups formed by PRI and SEAS:
# abbreviate EST uniquely within groups formed by PRI and SEAS
df_foo %>%
  group_by(PRI, SEAS) %>%
  mutate(
    abbreviated_est =
      toupper(
        abbreviate(gsub("\\(x 1,000,000\\)", "", EST),
                   use.classes = TRUE
        )
      )
  )

Which yields this:
Source: local data frame [6 x 10]
Groups: PRI, SEAS [1]

  Serial # Ref_Date    GEO                    PRI                                SEAS                                         EST    Vector Coordinate  Value abbreviated_est
     <int>    <chr>  <chr>                  <chr>                               <chr>                                       <chr>     <chr>      <chr>  <dbl>           <chr>
1        1  1981/03 Canada Chained (2007) dollars Seasonally adjusted at annual rates Final consumption expenditure (x 1,000,000) v62305723    1.1.1.1 604670            FNCE
2        2  1981/06 Canada Chained (2007) dollars Seasonally adjusted at annual rates Final consumption expenditure (x 1,000,000) v62305723    1.1.1.1 603745            FNCE
3        3  1981/09 Canada Chained (2007) dollars Seasonally adjusted at annual rates Final consumption expenditure (x 1,000,000) v62305723    1.1.1.1 603415            FNCE
4        4  1981/12 Canada Chained (2007) dollars Seasonally adjusted at annual rates Final consumption expenditure (x 1,000,000) v62305723    1.1.1.1 604700            FNCE
5        5  1982/03 Canada Chained (2007) dollars Seasonally adjusted at annual rates Final consumption expenditure (x 1,000,000) v62305723    1.1.1.1 596566            FNCE
6        6  1982/06 Canada Chained (2007) dollars Seasonally adjusted at annual rates Final consumption expenditure (x 1,000,000) v62305723    1.1.1.1 594937            FNCE


text:
Q: Wrong Environment in Trac SVN post-commit-hook I use a the SVN post-commit-hook script from the official Trac website to update tickets the tickets. (This is the script) If a user commits something into SVN, the ticket gets the update and an E-Mail is generated. This works fine with one exception:
It seems the environment in the post-commit-hook is different from the website. If I change something in a ticket, the email looks like this:
[bla bla]
--
Ticket URL: <https://host/trac/projectname/ticket/100#comment:2>
projectname <https://host/trac/projectname>
My example project

If I change the ticket from the post-commit-hook, the amil looks like this:
[bla bla]
--
Ticket URL: </ticket/100#comment:2>
projectname <>
My example project

I manage several trac instances on this server with a global configuration in /etc/trac/trac.ini and a local configuration on the project folders. It seems like the post-commit-hook gets a wrong environment without set the right project url. How can I set this right?

A: As of version 0.11, you need to set base_url under [trac] to the same value as url under [project]. Ticket #3965 has some more information.


text:
Q: check all checkboxes I have a table with checkboxes and I want to do the "check all" and "un-check all" checkboxes but I could not find the way to check all the checkboxes.
Here is my code:
<form>
    <?php foreach ($this->entries as $entry): ?>

            <input type="checkbox" class="chk_boxes1" name="to_delete[<?PHP echo $entry['id'] ?>]"  />
            <?php echo $entry['user_name'] ?>
            <?php echo $entry['date_created'] ?>
            <?php echo $entry['user_type_name'] ?>

    <?PHP endforeach; ?>

    <input type="checkbox" class="chk_boxes" label="check all"  />check all
    <input type="checkbox" class="unchk_boxes"   /> un-check all
</form>

A: $(function() {
    $('.chk_boxes').click(function() {
        $('.chk_boxes1').prop('checked', this.checked);
    });
});

This only affects the check all box. But why would you want to use two checkboxes anyway? One to check all and one to uncheck all, but not mutually exclusive. That's got to be the recipe to confuse users :)

A: Try using true|false. Like so:
$('.chk_boxes1').attr('checked',true);

Additional comment:
In addition, it appears your un- and check all checkboxes are redundant.
<input type="checkbox" class="chk_boxes" label="check all"  />check all
<input type="checkbox" class="unchk_boxes"   /> un-check all

Rather than doing that, you can just have one checkbox that does both. Thus, your jQuery will look like:
$(document).ready(function() {
    $('.chk_boxes').click(function(){
            $('.chk_boxes1').attr('checked',$(this).attr('checked'));
    })
});

With HTML:
<input type="checkbox" class="chk_boxes" label="check all"  />check all

A: See the working solution here http://jsfiddle.net/HBGzy/
you don't need to use the "uncheck all" checkbox :)
$('.chk_boxes').click(function(){
    var chk = $(this).attr('checked')?true:false;
    $('.chk_boxes1').attr('checked',chk);
});

A: You forgot about quotes:
$('.chk_boxes1').attr('checked','checked')

fiddle: http://jsfiddle.net/8ZHFn/

A: Try this
 $(".chk_boxes").click(function()
   {
   var checked_status = this.checked;
   $(".chk_boxes1").each(function()
     {
      this.checked = checked_status;
     });
  });

So, if the class name of all the checkboxes you want to affect when checking or unchecking the checkbox with class chk_boxes,is chk_boxes1 this will get all the elements and set the checked property accordingly.

A: Check-uncheck all / select-unselect all checkboxes
Follow the following code , its really simple with the following code
inside your html form add the following line of code
<input type="checkbox" id='checkall' /> Select All

and than add the following  script

keep in mind that .checkbox in script code is the class name from other checkboxes of html form
for example if you have input checkbox as following
<input class="checkbox" name="emailid[]" type="checkbox" value="<?php echo $email;?>" />

A: i think you should use the true or false for the checkbox attribute.

A:

A: An advice about check all/uncheck all..
As my think after selecting check all, if user clicks any of checkbox1s, the check all checkbox should be unchecked and also without clicking check all box, if user selects all checkbox1s one by one the checkbox should be selected. So i suggest you to try this when using check all/uncheck all..
$(document).ready(function() {
    $('.chk_boxes').click(function(){
        $('.chk_boxes1').attr('checked',$(this).attr('checked'));
    })
    $('.chk_boxes1').click(function(){
        if($('.chk_boxes1').length == $('.chk_boxes1:checked').length)
              $('.chk_boxes').attr('checked',checked)
        else
             $('.chk_boxes').attr('checked',false)
    })
});


text:
Q: Installing VLC 3.0.1 in Ubuntu 16.04 I am trying to install VLC in Ubuntu 16.04. By default, the version being provided from Ubuntu universe repositories is VLC version 2.2.2. But I checked the official website of VLC ( Videolan ), there I saw the latest version is 3.0.1.
I searched online on how to install latest VLC version, I got two solutions, either use a third-party PPA or use snaps. I searched for PPA, got ppa:videolan/stable-daily which installs version 2.2.2 and ppa:videolan/master-daily which installs version 4.0.0 rc1 (please correct me if I have gone wrong anywhere here).
So, finally, I resorted to snaps, installed VLC from it using sudo snap install vlc --classic. But the interface looked very weird to me, moreover, it downloaded 189 MB!
So is there any way to install the latest version using apt-get, the regular way?

A: There is no official release of latest VLC 3.0.2 for Ubuntu 16.04 LTS. However, you can get the latest VLC from the third party packager. To install VLC 3.0.2 in your system (Ubuntu 16.04 LTS) write the following commands in your terminal:
sudo add-apt-repository ppa:jonathonf/ffmpeg-3
sudo add-apt-repository ppa:jonathonf/vlc-3
sudo apt-get update
sudo apt-get install vlc

Now you are done! But, please note that according to the statement by the  packager, there is no Chromecast support for this particular package of VLC Media Player on Ubuntu 16.04 LTS. If you want that, then please upgrade to Ubuntu 18.04 LTS.

A: In case that you had problems with unmet dependencies like I did, there is solution to add PPA ffmpeg-4 and then you will be able to install it properly:
sudo add-apt-repository ppa:jonathonf/ffmpeg-4
sudo add-apt-repository ppa:jonathonf/vlc-3
sudo apt-get update
sudo apt-get install vlc

Source: https://launchpad.net/~jonathonf/+archive/ubuntu/vlc-3

A: There is no possibility yet to install VLC 3.0.1 via the APT package management system. There will be on Ubuntu 18.04 (Bionic Beaver).
The newest VLC version is indeed 4.0, but it is still unstable.
The snap download has a large size, but why do you consider the interface to look weird?

A: I had some trouble with installing some dependencies, which got resolved after I added this repository to the list that Blackcoat77 posted:
sudo add-apt-repository ppa:videolan/master-daily

I'm a noob, so please correct this with the stable release, if you think it also contains the dependencies. My understanding is that there is little to no quality control on this release, so use with caution.


text:
Q: PHP Query Issue I have this query which I would like to insert data into two tables.
It inserts into the first but not the second, any ideas why?
$result1 = mysql_query("INSERT INTO entries (UserID, FirstName, LastName, EmailAddress, TelephoneNumber, Image, Status) VALUES ('NULL', '$FirstName', '$LastName', '$EmailAddress', '$TelephoneNumber', '$ran2$ext', '0')") ;

$newid = mysql_insert_id($result1);

$result2 = mysql_query("INSERT INTO voting (id, EntryID, item, vote, nvotes) VALUES ('NULL', $newid, 'vt_img353', '0', '0')") ;

A: If you are trying to insert a null, don't use quotes around it:
INSERT INTO voting
    (id, EntryID, item, vote, nvotes)
    VALUES (NULL, $newid, 'vt_img353', '0', '0')

As juergen d correctly points out, if you don't want to insert a column you can just skip it, but this will only work if you name the columns you are inserting first. It won't work in:
INSERT INTO voting
    VALUES (NULL, $newid, 'vt_img353', '0', '0')

A: $result2 = mysql_query("INSERT INTO voting (EntryID, item, vote, nvotes) VALUES ($newid, 'vt_img353', '0', '0')") ;

If you don't want to set a column you can leave it. Your id column is probably an auto-increment column. If you leave it from your insert statement it will be filled automatically.
And if you want to set it explicitly  to NULLthen leave the quotes. Otherwise you would set the column to the string NULL

A: Not an answer per se, but very useful all the same. To make your code more readable - both in your IDE and on forums such as this - bear in mind you can indent it. Try this:
$result1 = mysql_query("
    INSERT INTO entries (
        UserID, FirstName, LastName,
        EmailAddress, TelephoneNumber, Image,
        Status
    )
    VALUES (
        NULL, '$FirstName', '$LastName',
        '$EmailAddress', '$TelephoneNumber', '$ran2$ext',
        '0'
    )
");

This helps keep to a reasonable line length (I use 120 chars) and helps reduce bugs that lurk off the right-hand side of your screen.


text:
Q: Can't get Google App Engine OAuth2-sample (for Python) to work - 400 Error: redirect_uri_mismatch I need to use OAuth2 so I wish to develop through App Engine and Python since Google offers sample-code that should make the process easy:
https://developers.google.com/api-client-library/python/guide/aaa_oauth
https://code.google.com/p/google-api-python-client/downloads/list
It should be simple; just download the files, set the application name in app.yaml and the id/secret in the client_secrets.json. Then run/upload through Google App Engine Launcher.
However, I get the Error 400: Error: redirect_uri_mismatch.
The redirect URI in the request: {localhost or appspot.com}/oauth2callback did not match a registered redirect URI.
Request Details
scope=https://www.googleapis.com/auth/plus.me
response_type=code
access_type=offline
redirect_uri={local/appspot}/oauth2callback
state={local/appspot}/:gP-pigwbwB3IBwMjafPlPToxNDE0NTA4ODYy
client_id={id-stuff}.apps.googleusercontent.com

I doubt that the problem lies in the code (since it's a working sample), but what more can it be, what am I missing?

A: Go to the API Console: https://code.google.com/apis/console/
In your project, check the API Access settings and make sure that URL is one of the Redirect URIs. If not, add it.


text:
Q: List of OpenXmlAttributes name qualifiers? Where can I find a list of OpenXML OpenXmlAttribute valid qualifiers for writing to Excel in C#? For example - new OpenXmlAttribute("t", null, "str") sets the data type to string. The 't' being the type of attribute that I want to edit.
Where can I find the keywords for example bold/fontsize/fill, etc? I can't find any good documentation on this.


text:
Q: Prev_permutation vs Next_permutation difficulty I was trying out a sample program to grasp the difference between prev and next permutation. However, my program doesn't seem to work properly. I start the program by asking the number of elements in the array and I build the array with a simple for loop
for(i = 0; i < x; i++)
        ptr[i] = i;

cout << "Possible permuations using prev_permutation: " << endl;
    do{
        for(i = 0; i < x; i++)
            cout << ptr[i] << " ";
        cout << endl;
    } while(prev_permutation(ptr, ptr+x));

cout << "Possible permuations using next_permutation: " << endl;
do{
    for(i = 0; i < x; i++)
        cout << ptr[i] << " ";
    cout << endl;
} while(next_permutation(ptr, ptr+x));

When I run the code with a sample of 3 elements, (0, 1, 2). The prev_permutation gives me (0, 1, 2 and thats it). Then next_permutation gives me (2, 1, 0). However, when I comment the code for the prev_permutation part, I get a proper 6 different permutations of the set (0, 1, 2) when only next_permutation is running. I can't seem to understand what is going on.

A: prev_permutation and next_permutation generate all permutations in lexicographical ("alphabetical") order and they return false once the cycle has been completed (i.e. if after calling prev_permutation on the first permutation or after calling next_permutation on the last one).
What happens is that you prepare the array with the first permutation in lexicographical order, then you call prev_permutation. This is however the first, so prev_permutation sets the array to the last permutation and the returns false, so you exit the loop.
Now you enter the next_permutation loop, but the current content of the array is the last permutation in lexicographical order, so next_permutation will set the first one and will return false.
If you remove the prev_permutation part however the loop for next_permutation will start from the first and so it will generate correctly all 6 permutations before returning false.
You can visualize the effect considering all permutations listed in order and with the current configuration as a pointer in this list:
0-1-2 << you start here
0-2-1
1-0-2
1-2-0
2-0-1
2-1-0

when calling next_permutation you are moving down, when calling prev_permutation you are moving up. When going outside the list both function will move the pointer to the other end and will return false to inform you of this fact.
If you start with prev you move to 2-1-0 and function returns false, then you call next and the function move to 0-1-2 and returns false again.
Using for example instead of 0, 1 and 2 the permutations of two zeros and three ones the lexicographical ordering is:
0-0-1-1-1
0-1-0-1-1
0-1-1-0-1
0-1-1-1-0
1-0-0-1-1
1-0-1-0-1
1-0-1-1-0
1-1-0-0-1
1-1-0-1-0
1-1-1-0-0

So to enumerate all of them you need to start from 0-0-1-1-1 and use next_permutation or you need to start from 1-1-1-0-0 and use prev_permutation.
In this case calling next_permutation on the last one 1-1-1-0-0 will change to the first 0-0-1-1-1 and will return false; in a similar way calling prev_permutation on 0-0-1-1-1 will change to 1-1-1-0-0 and will return false because of the flip.

A: All the permutations considered by both prev_permutation and next_permutation have a well-defined lexicographical order.  The array you provided to them has some position in that order.
That's why neither function is guaranteed to provide all permutations.
If you provide the first possible permutation to prev_permutation, which you did, there will be no permutations before it.  Likewise, if your array were defined as (2, 1, 0), next_permutation would not provide any new permutations.
If you need all the permutations of some collection, you would want to sort the collection first and then use next_permutation.


text:
Q: How to scrape table from a web using Python (BeautifulSoup)? I am trying to extract table from a website. I've been using BeautifulSoup, but in the end I got the empty rows on the table I scraped.
#import package
from urllib.request import Request, urlopen
from bs4 import BeautifulSoup

#to get the html of the page
req = Request('https://covid19.go.id/peta-risiko', headers={'User-Agent': 'Mozilla/5.0'})
html = urlopen(req).read()
soup = BeautifulSoup(html, 'lxml')
type(soup)

# Get the title
title = soup.title
print(title)

# Print out the text
text = soup.get_text()
print(soup.text)

#to extract all the hyperlinks within the webpage
soup.find_all('a')

#use a for loop and the get('"href") method to extract and print out only hyperlinks
all_links = soup.find_all("a")

#To print out table rows only, pass the 'tr' argument in soup.find_all()
for link in all_links:
    print(link.get("href"))

# Print the first 10 rows for checking
rows = soup.find_all('tr')
print(rows[:10])

I get [] when I print the first 10 rows. I don't know it could happen. Is it because of the table consists multiple page (page 1, 2, 3, next page, etc)?.
Any solutions for scraping this table on this web? Web page. I want to get a table with columns : PROVINSI, KOTA/KABUPATEN, STATUS


text:
Q: Excel VBA: Highlight textbox value after error occurs I am trying to highlight entered value in TextBox. TextBox value is representing date value in date forma DD-MM-YYYY. I wrote some code to validate if inserted date is ok (in example 31 of April).
Hightlight itself is not a problem, however I want to do this right after an error occurs. So when I insert 31-04-2014, I should get the message "You have inserted wrong date" and the date value should hightlighted. For now it shows me message, highlights value and focus is set to another CommandButton
So far I made something like this:
Private Sub data_faktury_AfterUpdate()

Dim dzien As Byte, miesiac As Byte
Dim rok As Integer

On Error GoTo blad:

dzien = Mid(data_faktury.Value, 1, 2)
miesiac = Mid(data_faktury.Value, 4, 2)
rok = Right(data_faktury.Value, 4)

Call spr_date(dzien, miesiac, rok)

Exit Sub

blad:
If Err.Number = 13 Then
    If data_faktury <> "" Then
        If Len(data_faktury) < 10 Then: MsgBox ("Źle wpisana data faktury.")
    End If
End If

End Sub

And code for 2nd procedure:
Sub zle()

MsgBox ("Wybrałeś zły dzień")

With Faktura.data_faktury
        .SetFocus
        .SelStart = 0
        .SelLength = Len(.Text)
End With

End Sub

A: This is a bit long for a comment so here goes. The basic principle is to use the exit event and cancel when necessary. To prevent this being fired when you close the form, you need to use a flag variable - example userform code:
Private bSkipEvents As Boolean
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    If bSkipEvents Then Exit Sub

    With TextBox1
        If Not IsValidDate(.Text) Then
            Cancel = True
            MsgBox "Invalid date"
            .SelStart = 0
            .SelLength = Len(.Text)
        End If
    End With
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    bSkipEvents = True
End Sub


text:
Q: Which .sh will run first: base image or the .sh present in the Dockerfile? Suppose I have a base image:
FROM ubuntu:trusty
.
.
COPY ./temp1.sh /sbin/entrypoint.sh

ENTRYPOINT ["/sbin/entrypoint.sh"]
CMD ["start-service"]

I called the image on my Dockerfile
FROM letsdoit/baseimage
.
.
COPY ./temp2.sh /sbin/entrypoint.sh
ENTRYPOINT ["/sbin/entrypoint.sh"]
CMD ["start-service"]

So what will be the order of execution?

A: Your settings for ENTRYPOINT and CMD overwrite the ones of the base image. This means the base script will not run at all.
Furthermore, you even have overwritten the /sbin/entrypoint.sh file with your own version. So the original script is not even available in the file system of the container.

A: When you launch the image, unless you change settings on the docker run command, it will run (only) /sbin/entrypoint.sh, and that will receive a single command-line argument start-service.
The CMD and ENTRYPOINT in the derived image totally overwrite the corresponding settings in the base image.  A container only runs one command and that's the most recent ENTRYPOINT (or the docker run --entrypoint if you manually set that).


text:
Q: ActiveRecord retrieve items by own attribute I want to retrieve specific items from my DB using and ActiveRecord Model in my Rails 5 application. The table looks like this:
create_table :my_models do |t|
  t.datetime :seen_at
  t.integer :some_number

  t.timestamps
end

Now, in the model I wanna specify a scope to get all entries where the following condition matches:
scope :test, -> { where("seen_at > ?", some_number.hours.ago) }

But that raises the following error:
NameError: undefined local variable or method `some_number'

I've also tried my_models.some_number.hours.ago, but that doesn't fix my issue. What am I doing wrong?

A: If you're using Postgres you can do
scope :test, -> { where("seen_at > now() - (interval '1 hour' * some_number)") }


text:
Q: How to add alias for extension namespace in wikimedia? I am trying to create my custom copy of italian wikipedia from the dump.
I encounter the problem with some of extensions.
I have got the error:

Lua error in package.lua at line 80: module 'Modulo:String' not found.

The problem is that there is no 'Modulo:String' in my copy, but there is 'Module:String'.
I have tried to add alias for this namespace in my LocalSettings.php, as I did for categories, but for modules it didn't help.
$wgNamespaceAliases['Categoria'] = NS_CATEGORY; //this helped for categories
$wgNamespaceAliases['Modulo'] = NS_MODULE; //this does not work

Module namespace is part of Scribunto default namespace.
https://www.mediawiki.org/wiki/Extension_default_namespaces
How to solve the Lua error with loading modules?

A: The actual set of namespace aliases for Italian Wikipedia is (1); Categoria and Modulo are translations. To use them, just set $wgLanguageCode to it.
(I'm not sure why setting Modulo as an alias does not work; in theory it should. But it's not the easy way to set up a mirror.)


text:
Q: make a custom event for addEventListener in Javascript What I would like to do is register a custom event in Javascript (I'm working with Html + Css + Javascript + jQuery)
But this "custom event" is not a predefined event. What I'm looking for is something like this:
document.addEventListener($(#div1).css("width") == "35px" (OR, another example condition:) $(#div1).css("left") == "20px" (OR, another example condition:) $(#div1).css("color") == "#FF0000", function(););

Is this possible?.
How is the correct syntax?, inside and if? I mean:
    document.addEventListener(if ($(#div1).css("width") == "35px"), function(););
I have no idea of how get this "customized daemon" working!.

A: The browser does not have an event that will trigger when a particular div reaches a width of exactly 35px or a specific color so the type of code you are trying to write is not directly possible.
There are events for some of the other types of things that might cause that div to change it's width such as the window being resized.  If you can tell us what operations are causing the div to change its width, then we might be able to offer other ideas for how to capture the situation you are trying to capture.
What you will likely have to do is to either register event handlers for other events (such as window resize) and then check to see if any of your conditions have been met or call your code that checks if any of these conditions have been met after your code has made other DOM modifications that might change one of these properties or using a polling timer to check if any of these conditions have been met (not recommended as it is inefficient).


text:
Q: Oracle ORA-01839: date not valid for month specified Leap Year Oracle 11g
here is a quick one hopefully.
Below is part of a script that gets date only from from the next month
 first day of next month to last day. But today 29th feb it thrown an error of
ORA-01839: date not valid for month specified
M.MS_DATE between trunc(sysdate + interval '1' month,'MM') and last_day(sysdate + interval '1' month)

Is there a way round this. Many thanks

A: I have seen this as well and I consider this a bug in Oracle.
The workaround is to use add_months() instead :
between trunc(add_months(sysdate,1),'MM') and last_day(add_months(sysdate,1));

A: I would probably use add_months() as a_horse_with_no_name suggests, but just as an alternative if you want to use intervals, you can move the point you do the truncation in the first expression, and include the same truncation in the second expression:
select trunc(sysdate, 'MM') + interval '1' month as first_day,
  last_day(trunc(sysdate, 'MM') + interval '1' month) as last_day
from dual;

FIRST_DAY  LAST_DAY
---------- ----------
2015-02-01 2015-02-28

This works because all months have a first day, so you don't trip over the documented caveat.

When interval calculations return a datetime value, the result must be an actual datetime value or the database returns an error


text:
Q: PHP - First Time Installation of Laravel 4 on VPS Hey so I am completely new to Laravel 4 and have some basic questions regarding my first time installation that I was unable to find answers to anywhere else on-line.  I am planning of hosting a standard website with a fully dynamic web back end and a RESTful API using the framework.  I have been following this installation guide and am essentially at the part where I type laravel new projectDir and it creates a new instance of Laravel in the provided directory.
Now my main public directory is public_html, is it recommended to install Laravel 4 directly into that directory.  So is something like laravel new public_html recommended? I have found many other questions here that seem to suggest that this is not the safest solution.  Should I make a separate directory inside public_html, is it necessary for what I am planning on doing with laravel?
Also, I would like to keep my URL's as neat as possible and would like them primarily to be www.domain-name.com/pagename for the website.  Will creating a directory inside of public_html disable me from doing so?
Lastly I had some issues with routing my URL's when I tried to install a different framework on this server.  Are there any server/Apache settings that would impact how URL's are routed with laravel that I should disable/enable before I install Laravel into a directory?

A: you would not put the base Laravel folder in public_html.
In a Laravel directory structure, which gets created when you do the laravel new command, there is a directory called public.  This is what you map your web root to.  So on my vps, I have a folder called /var/site/mywebapp which was created by the command:
laravel new mywebapp

In nginx (which I much prefer over Apache), I map my server root to:
/var/sites/mywebapp/public

In the public folder is an index.php that Laravel uses to run your whole app/site.  The rest of the framework is outside of the web root and is not accessible by HTTP.
As for your URL issues, consult the documentation for how to properly configure your mod_rewrite (assuming Apache).
Also, Dayle Rees, a prominent member of the Laravel community (and core contributor), has a github of sample web server configs here:
https://github.com/daylerees/laravel-website-configs

A: When you install Laravel it will create a public folder, along with app, bootstrap and vendor folders.
The public folder is essentially your public_html folder where you want your host/apache to point to when viewing the root of your website. So mydomain.com should land directly within the public folder.
You can rename the public folder to public_html just be sure to also update bootstrap/paths.php paths value
'public' => __DIR__.'/../public',
// change to
'public' => __DIR__.'/../public_html',

Laravel will create a .htaccess file for you, which will grab URLs and redirect them to public/index.php which will process Laravel accordingly.
So to answer the question, you install Laravel one folder back from public_html and then you can rename public to public_html if your host requires.


text:
Q: Switching between flash and iframe version of live streaming Ustream with javascript in wordpress I'm tryng to make a button for switching between  flash version and iframe version of a ustream live channel that i have embed in my personal site
flash code:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="640" height="392" id="utv786564"><param name="flashvars" value="autoplay=false&brand=embed&cid=3064708"/><param name="allowfullscreen" value="true"/><param name="allowscriptaccess" value="always"/><param name="movie" value="http://www.ustream.tv/flash/viewer.swf"/><embed flashvars="autoplay=false&brand=embed&cid=3064708" width="640" height="392" allowfullscreen="true" allowscriptaccess="always" id="utv786564" name="utv_n_665786" src="http://www.ustream.tv/flash/viewer.swf" type="application/x-shockwave-flash" /></object>

iframe code:

Broadcast live streaming video on Ustream

For this scope i'm using following code:
javascript:
var newHTML = 'html2';
var oldHTML = document.getElementById('divtabone').innerHTML;

function changeText3(){
    var currentHTML = document.getElementById('divtabone').innerHTML;
if (currentHTML!=newHTML)
       {
     document.getElementById('divtabone').innerHTML = newHTML;
}
else
  {
document.getElementById('divtabone').innerHTML = oldHTML;
}
}

html:

html1

<input type='button' onclick='changeText3()' value='change Html'/>

replacing html1 and html2 with flash and iframe code reported above
working demo:
https://jsfiddle.net/nqj2L07j/2/
I have inserted this code in my test site wordpress:
http://www.grigione.5gbfree.com/test/
but how can see when i click change html button i can change video from flash version to iframe version one time only because if i reclick
and i want return to flash version it remain in iframe version
i have made a demo with codes here:
https://jsfiddle.net/z36e77ru/1/
the code that i have inserted in functions.php file of wordpress is following:
function mia_on_load_script()
{
    // Not our page, do nothing
    if( !is_page( 'test' ) )
        return;
?>

    <?php
    };
add_action( 'wp_head', 'mia_on_load_script' );

?>

html in page http://www.grigione.5gbfree.com/test/ :

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="640" height="360" id="utv786564"><param name="flashvars" value="autoplay=false&brand=embed&cid=3064708"/><param name="allowfullscreen" value="true"/><param name="allowscriptaccess" value="always"/><param name="movie" value="http://www.ustream.tv/flash/viewer.swf"/><embed flashvars="autoplay=false&brand=embed&cid=3064708" width="640" height="360" allowfullscreen="true" allowscriptaccess="always" id="utv786564" name="utv_n_665786" src="http://www.ustream.tv/flash/viewer.swf" type="application/x-shockwave-flash" /></object>

<input type='button' onclick='changeText3()' value='click to change'/>

Why in wordpress don't work ? Cold be a problem of caching? Any other solution to resolve problem?
thanks

A: Hi So I had another look into your Problem. What happens if you try it this way?
Try this fiddle:
https://jsfiddle.net/nqj2L07j/6/
var flash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="640" height="392" id="utv786564"><param name="flashvars" value="autoplay=false&brand=embed&cid=3064708"/><param name="allowfullscreen" value="true"/><param name="allowscriptaccess" value="always"/><param name="movie" value="http://www.ustream.tv/flash/viewer.swf"/><embed flashvars="autoplay=false&brand=embed&cid=3064708" width="640" height="392" allowfullscreen="true" allowscriptaccess="always" id="utv786564" name="utv_n_665786" src="http://www.ustream.tv/flash/viewer.swf" type="application/x-shockwave-flash" /></object>';
var iframe = '
Broadcast live streaming video on Ustream';
var is_flash = true;

$(document).ready(function () {
    $('#btn1').click(function () {
        if (is_flash) {
            $('#divtabone').html(iframe);
            is_flash = false;
        } else {
            $('#divtabone').html(flash);
            is_flash = true;
        }
    });
});


text:
Q: Is it possible to make an automatic search through the web to retrieve links? Iḿ looking to make an automatic search through the web or websites to retrieve links. This is for the purpose of retrieving shared IP tv links in order to create a media library to watch Tṽ online using VLC. The point is, I don't know even what's the best solution, like a web page using script or a mini program... well I'm starting in the world of terminals and stuff, just installed xubuntu, so please... have some patience :D
Thanks to all!

A: Yes, it is possible. You will have to write a Web Crawler.
JavaScript Node.JS Web Crawlers:

*

*https://scotch.io/tutorials/scraping-the-web-with-node-js

*http://www.netinstructions.com/how-to-make-a-simple-web-crawler-in-javascript-and-node-js/
If you want to find specific links on the whole internet it is going to be time consuming, your crawlers needs to jump from site to site and follow each link it finds.

A: Besides Neils answer if you want a PHP library have look at the PHP Simple DOM parser
Some considerations ;

*

*First build your database. List of target Websites / URLs you want to scrape

*Using the PHP DOM parser ( Or any alternative ) create a script for each web page. This may be time consuming if you have multiple web pages with different layouts.

*Run the script and save your links into a Database

*Create a Cron job to run regularly and update your database.

Scrapy
is also a solid alternative written in Python


text:
Q: Not all Attributes are available for changing programmatically in Android Studio I have a TextView object on which I want to change the style to Bold and few other  attributes. I am not able to do it. It just doesn't show that option, while I can do it in the xml file. Not sure what I am doing wrong.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:paddingLeft="20dp"
  android:paddingTop="20dp">

  <TableLayout
    android:id="@+id/table_data"
    android:layout_width="300dp"
    android:layout_height="wrap_content"
    android:stretchColumns="1"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.497"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.037">

    <TableRow
      android:id="@+id/table_row"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content">

      <TextView
        android:id="@+id/nameRow"
        android:layout_width="200dp"
        android:gravity="center"
        android:text="Name"
        android:textColor="#000000"/>

      <TextView
        android:id="@+id/moneyRow"
        android:gravity="center"
        android:text="Karma"
        android:textColor="#000000" />
    </TableRow>
  </TableLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

For example, name.text = key works, but name.textStyle doesn't work.

A: Thanks to the @CommonsWare's comment, I used Typeface to solve the problem.
name.setTypeface(null, Typeface.NORMAL)  //removes the style.
name.setTypeface(null, Typeface.BOLD)  //make it bold.


text:
Q: Popup menu in Android 1.5 I need something that looks like a popup menu in Android 1.5 that I can trigger from a button press.
(the version number is a hard limit, by the way)
According to the documentation, an ordinary popup menu is supported, but only in Android 3.x and higher.
I'd prefer to do it without adding another Activity, but can if that's the best option.
I already have the menu defined in XML, I just need to figure out how to make it display.

A: I think you are looking for a Dialog. I recommend you to use AlertDialog, as it is easier to use through its Builder class. You will be able to use your custom XML to define the layout for the Dialog.
It is available since API level 1, so you would not have problems. Here you have doc info AlertDialog

A: If you want that pop up menu to display more options, I suggest using the QuickAction. It is not available in Android SDK so you're gonna have to build it manually
          //Add action item
 ActionItem addAction = new ActionItem();

   addAction.setTitle("Add");
   addAction.setIcon(getResources().getDrawable(R.drawable.ic_add));

//Accept action item
 ActionItem accAction = new ActionItem();

 accAction.setTitle("Accept");
  accAction.setIcon(getResources().getDrawable(R.drawable.ic_accept));

 //Upload action item
 ActionItem upAction = new ActionItem();

 upAction.setTitle("Upload");
 upAction.setIcon(getResources().getDrawable(R.drawable.ic_up));

Looks like this

More information on how to implement it is  available here


text:
Q: Yii2: custom validation for multiple attributes using OR not working I am trying to write a rule that validates if attribute_a or attribute_b is set;
one of the following attributes must be set : licitatii_publice or licitatiile_atribuite
The following code does not work;
<?php

namespace common\models;

use yii\base\Model;

class AbonamentValidare extends Model {

    public $licitatii_publice;
    public $licitatiile_atribuite;
    public $zone;
    public $judete;
    public $tari;
    public static $targetAttribute = [];

    public function rules() {
        return [
            [['zone'], 'required'],
            [['licitatii_publice', 'licitatiile_atribuite', 'tari', 'judete'], 'safe'],
            ['licitatii_publice', 'validate_tip_licitatie', 'targetAttribute' => ['licitatii_publice', 'licitatiile_atribuite']],
        ];
    }

    function validate_tip_licitatie($attribute, $param) {
        print_r($attribute);
        $this->addError($attribute, 'eroarea');
    }

    public function attributeLabels() {
        return array(
            'licitatii_publice' => 'lp',
            'licitatiile_atribite' => 'la',
            'tari' => 'tari',
            'judete' => 'judete',
            'zone' => 'zone',
        );
    }

    public function save() {
        return false;
    }

}

?>

A: Just wanted to update this answer for Yii2 case.
In Yii2 the validators have a skipOnEmpty attribute which is by default set to true. This implies custom validators will not be called if the field is empty, which might not be the required behavior, especially in this case where either of one attribute is mandatory. In order to fix this issue we need to set the skipOnEmpty to false as shown below.
[['licitatii_publice, licitatiile_atribuite'], 'validate_tip_licitatie', 'skipOnEmpty'=> false],

A: Well what I have done in a case like this is to create the validator like this:
................
    return [
                [['zone'], 'required'],
                [['licitatii_publice', 'licitatiile_atribuite', 'tari', 'judete'], 'safe'],
                [['licitatii_publice, licitatiile_atribuite'], 'validate_tip_licitatie'],
            ];
............
    function validate_tip_licitatie($attribute, $param) {
        if(!$this->licitatii_publice && $this->licitatiile_atribuite)
        $this->addError($attribute, 'eroarea');
    }

In this way you show both fields with an error.
However I have done this in Yii1, but from what I read Yii2 should be the same. The logic is the same.
If you want to show error only for 1 attribute you can always just use
return [
            [['zone'], 'required'],
            [['licitatii_publice', 'licitatiile_atribuite', 'tari', 'judete'], 'safe'],
            [['licitatii_publice'], 'validate_tip_licitatie'],
        ];

What you are trying to do is more fancy :), I get that. If you really want to use targetAttribute you might have to do it like this
https://github.com/yiisoft/yii2/blob/master/framework/validators/ExistValidator.php
Just build your own validator class.
Well. After reading about the exist validator i believe that is exactly what you need. It has examples on how to use it.


text:
Q: simple way to know the updates in table hi just wanted to know is there any way to know if any update happens in column like Ex:Author ID, and once its update happen in column is there any simple way so that all the managers should know that new author update happen in Database or via email, i am a newbie, if anyone help me step by step on this it will be really greatful for me at the appraisel time please help on this..
Thanks
aaru

A: You need to create a trigger
CREATE TRIGGER reminder2
ON Sales.Customer
AFTER INSERT, UPDATE, DELETE
AS
   EXEC msdb.dbo.sp_send_dbmail
        @profile_name = 'AdventureWorks Administrator',
        @recipients = 'danw@Adventure-Works.com',
        @body = 'Don''t forget to print a report for the sales force.',
        @subject = 'Reminder';

However, using the sp_send_dbmail is not appropriate from within a stored procedure as it will slow down the update of a row. Meaning that everytime an update is done to the row, it will have to wait until the email is sent.
Instead, you should use another table to store the action on the row, have a batch job or a service scan the table and send the email itself.
For example:
CREATE TRIGGER SendEmailOnUpdate
    ON Author
    AFTER UPDATE
    AS
       INSERT INTO Notification(AuthorId) VALUES(updated.AuthorId);

The create a Windows Service that scan the table Notification and take one row at a time and send an email against the data it contains.
See MSDN for more information about triggers.

A: You might want to use a Sql Trigger to create a log of all the updates that occur on certain tables and fields.

A: You may want to use the UPDATE() function (lookup in books on-line) within the trigger to test just for changes to the field you are interested in (i.e. Author)

A: Actually, using sp_send_dbmail inside a trigger isn't so bad. Unlike the MAPI xp_sendmail days, sp_send_dbmail just queues up the email (essentially writing a record into a table). It will not cause the trigger to wait for the email to be sent. While SQL BOL says the sp "sends an email message", the result of a successful call is the message "Mail queued."
I am still not sure I would call it from a trigger, but I'd now consider it with dbmail.


text:
Q: can you write 1.0 as number in JavaScript (there are only zeros after the decimal point)? I'm trying to solve a challenge involving finding the mean of an array but the output must be a number with a decimal point (4.0) Is it possible to do this in JavaScript? if the answer is no is there a programming language that can do it

A: you can use this
var num= 5;

num.toFixed(1);

it will return 5.0


text:
Q: date diff, including time I have database table whose structure is as follows:
id  int
name varchar(20)
dob  datetime

I need to find out those records whose datetime difference is greater than 1 days
I know that datediff() can work, but I also want to include time (Hours, Mins, Seconds) in calculation
Example:
  2011-02-14 13:05:06 (is one day from 2011-02-15 13:05:06)
  but
2011-02-14 13:05:06 (is NOT one day from 2011-02-15 13:04:06)
any suggestions?

A: Use TIME_TO_SEC
SELECT TIME_TO_SEC(TIMEDIFF('2011-02-14 13:05:06','2011-02-15 13:06:06'))/86400;

A: You can compare your dates in another way:
date1 < date_sub(date2, interval 1 day)

this comparison will be true, if the difference between date2 and date1 is more than 1 day

A: SELECT * FROM `table`
WHERE `dob` NOT BETWEEN
    '2011-02-14 13:05' - INTERVAL 1 DAY
    AND
    '2011-02-14 13:05' + INTERVAL 1 DAY

A: select concat(TIMESTAMPDIFF(day,concat(small_date,' ',small_time),concat(big_date,' ',big_time))%24 ,' day ' ,
sec_to_time((TIMESTAMPDIFF(second,concat(small_date,' ',small_time),concat(big_date,' ',big_time))) -(
TIMESTAMPDIFF(day,concat(small_date,' ',small_time),concat(big_date,' ',big_time))%24*86400))) `datetimediff`
from tmp

A: SELECT TIME_TO_SEC(TIMEDIFF('2011-02-14 13:05:06','2011-02-15 13:06:06'))/86400;

Not every day has 86400 seconds! So this will return wrong answer twice a year, when summer/winter time changes and day is one hour longer or shorter.


text:
Q: jquery bootstrap typeahead cannot bind event I am using twitter typeahead and I can't bind select event. I've seen almost everything related to this but it doesn't work yet.
var subjects = ['PHP', 'MySQL', 'SQL', 'PostgreSQL', 'HTML', 'CSS', 'HTML5', 'CSS3', 'JSON'];
$('#search').typeahead({
    source: subjects
});

$('#search').bind('typeahead:select', function (ev, suggestion) {
    console.log('Selection: ' + suggestion);
});

A: I have fixed this issue by updating typeahead and the code above works well after updating.


text:
Q: Wordpress: How to make random posts excluding current and from chosen date I need to have 5 random posts on post page (http://7cuteoutfits.com/2015/07/08/suits-rachel-z-office-fashion/) excluding current post. Random posts should be on chosen dates (for example posts from last 2 months until yesterday )
I added a few lines of code to single.php of my wordpress and now have 5 random posts. So I need to modify the code so that it will meet my requirements (above). I think it's 2 more lines, I'll be very thankful if you help.

<?php
 $currentID = get_the_ID();
 $args = array(  'posts_per_page' => 5, 'orderby' => 'rand' );
$rand_posts = get_posts( $args);
foreach ( $rand_posts as $post ) :
  setup_postdata( $post ); ?>

<a href="<?php the_permalink(); ?>"><?php the_title(); ?>

<?php endforeach;
wp_reset_postdata(); ?>

A: You can use WP_Query for that.
global $post;
$args = array(
'post__not_in' => array($post->ID)
'orderby'   => 'rand'
'date_query' => array(
    array(
        'after'     => 'January 1st, 2015',
        'before'    => array(
            'year'  => 2015,
            'month' => 07,
            'day'   => 9,
        ),
        'inclusive' => true,
    ),
),
'posts_per_page' => 5,
);
$query = new WP_Query( $args );

This query orders randomly posts between today (inclusive) and Jan. 1st 2015
I haven't tested the snippet here, so please let me know if it does not work for you.
More info on WP_query and its usage (also for date parameters) here
Once you query with WP_Query, you have to
wp_reset_postdata();

just as you are already doing.
EDIT:
To show the post content, you can call
the_content()

to print it directly, or
get_the_content()

to get it as a return value. Then you can handle the printing later with the HTML markup you desire.


text:
Q: jQuery executing script multiple times I'm doing a little project and got a small problem. I'm printing out a table from MySQL database data.
One of the fields is image. I print it out and I want it to pop up when clicked but all I can do is execute the script only once, meaning only the first picture on the page will pop up when clicked.

    .......

        <?php do { ?>

    ........

                <img src="<?php echo $row_ManageUsers['preview_thumb']; ?>" width="130px" height="130px" class="img-thumbnail" $nbsp;>

    .......
          <?php } while ($row_ManageUsers = mysql_fetch_assoc($ManageUsers)); ?>
    .......

The script is copied and it gets a proper value every time but it will not execute.
Any advice?

A: If you're outputting  for every , that is your issue. IDs need to be unique, so jQuery only finds the first instance of #img when the click happens.
Change id="img" to class="img" and change this:
$('#img').on('click','.btn', function ()...

to this:
$('.img').on('click','.btn', function ()...

That should do the trick.
Also, here is info regarding IDs and the HTML5 spec:
http://www.w3.org/TR/html5/elements.html#the-id-attribute

The id attribute specifies its element's unique identifier (ID). The
  value must be unique amongst all the IDs in the element's home subtree
  and must contain at least one character. The value must not contain
  any space characters.

A: Try to give your code a little bit more structure and separate the HTMl and the JS part.
Output your table rows  by looping or what ever AND remove the ID's and use CLASSES. ID's have to be unique in the document. Also remove width and heigth and do that in CSS. Your row should look something like that:

         <img src="<?php echo $row_ManageUsers['preview_thumb']; ?> />"

Test the above code, you should see the images. Next step is to write the jQuery part.

This part you put in the HEAD of your HTML after the part, where you are loading jQuery.
I have not tested the code.
TIPP: If you are unsure with solving a problem, then cut it into small pieces, write the code and test is. In the end put all the small parts together.


text:
Q: Android get json elements I am implementing the moethod to get json cel l content through google spreadsheet
The below is the part of my content
    [{"scheme":"http://schemas.google.com/spreadsheets/2006","term":"http://schemas.google.com/spreadsheets/2006#list"}],"title":{"type":"text","$t":"traditional"},
"content":{"type":"text","$t":"ridicule: http://hkgalden.com/face/hkg/369.gif, adore: http://hkgalden.com/face/hkg/adore.gif, agree: http://hkgalden
.com/face/hkg/agree.gif, angel: http://hkgalden.com/face/hkg/a
ngel.gif, angry: http://hkgalden.com/face/hkg/angry
.gif, ass: http://hkgalden.com/face/hkg/ass.gif, banghead: http://hkgalden.com/face/hkg/
banghead.gif, biggrin: http://hkgalden.com/face/hkg/biggrin.gif

When it comes to using the following methods to extract link as follows
from
biggrin: http://hkgalden.com/face/hkg/biggrin.gif

to
http://hkgalden.com/face/hkg/biggrin.gif

Using
                        link = data[0].split(": ")[1];

It sometimes cannot get the values and hence insert the data record using ORMLite
and found empty data link
What should I follow afterwords?
Is using substring with lastOfIndex can help ?


text:
Q: How can I submit only two form elements?
I seem to be stuck on a small problem, I am trying to create a "Quick Search" box for an ASP system, but I don't have code-behind access.
How can I submit only the text box value and the submit button value without submitting the ASP or other form elements on the page?
I have tried:
$('#aspnetForm').submit(function() {
    var $inputs = $('#aspnetForm :input');
    $inputs.each(function() {
        if ($("this:not(#QuickSearchBox, #quicksearch-submit)"))
        $(this).remove();
    });

});

And:
var $inputs = $('#aspnetForm :input');
$inputs.each(function() {
    if ($(this).not($("#QuickSearchBox, #quicksearch-submit")))
    $(this).remove();
});

But neither of them seem to work.
I am trying to have everything backwards compatible to IE 6 so HTML5 form actions are not an option, and I can't use nested forms because they don't validate and do cause some problems.
Is there any way for me to do this?

A: Disable all the elements that you don't want submitted.
$('#aspnetForm :input:not(#QuickSearchBox, #quicksearch-submit)')
    .prop('disabled', true);

A: Can you just wrap the two inputs that you want to submit in their own form tag?


text:
Q: Storing price in PHP. What is better double or string? I've been making "Product Object" for my app and I've been setting attributes, when suddenly I got to price attribute and stumbled upon it with question what type better to choose? I understand, that for PHP it doesn't matter so much, but lets say for MySQL it does.
Any suggestions?

A: There's a detailed explanation of the "best practices" solutions for this question in this SO question.  Using integers is also an acceptable alternative.  Regardless, it's best to use the same solution throughout your application to facilitate comparison and arithmetic.
Remember that you can always change the way the data looks before presenting it to the user, using number_format() or something else.

A: Real number types are better for numbers because you can do proper comparisons with them (e.g., price < 10.0). However, they do introduce problems with precision (things like 3.0 = 2.9999999999). It's best to use a native Decimal type in this case, but lacking that, I would store the prices as an integer number of cents (e.g., 6.77 => 677), then divide by 100 before presenting the number to the user. That way you get the number operations in the database, and you get the precision (assuming that precision of 1 cent is enough).

A: The question I always ask myself when considering string or numeric (int, double, etc.) datatypes is, "Am I going to do math with them?"  If the answer is yes, which I must assume it is in your case, I go with the numeric value.  If the answer is no, I choose the string value.

A: Neither is appropriate.
Prices should be stored as DECIMAL or INT, because they have a fixed number of decimal points. Using floats is not a good idea as values will get rounded. Strings are problematic because you won't be able to do comparisons.

A: With the information you give, it seems better to just use an integer, so you can sort and query with numerical values instead of string values. An int would be better than a floating point as it wont have weird half cent problems.
ie, you don't want 6.77 to be greater than 12.54, nor do you want something with the price 6.4312313141.

A: I personally prefer integers to store it as cent value, 650 instead of 6.50.
Easy sorting, no rounding problems and easy to display in whatever format to your users.

A: You might want to check out the Time and Money project on sourceforge. Full disclosure: I haven't actually looked through the project much, but it seems like it would give you some good ideas about handling such things.


text:
Q: Is this definition of group isomorphism correct? Definition : $(G,\circ)$ and $(H,\circ)$  and suppose that their underlying set is $\Omega = \{1,2,\cdots,n\}$. We say that $G$ and $H$ are isomorphic if there exists a bijection from $\phi : \Omega \mapsto \Omega$ such that $\forall a,b \in G,\phi(a\circ b) = \phi(a) \circ \phi(b) $
Question : Is this definition of group isomorphism correct? Is according to my definition $G$ is always going to isomorphic to $H$?