text:
Q: Create a menu using pure css and HTML I have a menu structure like this :

    item1

subitem1

subitem2

subitem3

subitem4

        item2

subitem5

subitem6

subitem7

subitem8

My requirement is, when I hover on item1 then subitem1,subitem2,subitem3,subitem4 only need to display and subitem5 - 8 no need to display.
When I hover on item2, then only subitem5 - 8 need to display. How can I achieve this by using css?
I have tried:
ul.menu ul{
 display: none;
}
ul.menu li:hover:first-child ul {
  display:block;
}

A: Something like this? (Without changing your html)
CSS:
ul li ul {display:none;}
ul > li:hover ul{display:block;}
ul li ul > li > ul.sub-ul-2 {display:none;}
ul > li:hover ul > li:hover ul{display:block;}

DEMO 1

Update: (Without using any classes & cursos:pointer;)
ul li ul {display:none;}
ul > li:hover ul{display:block;}
ul > li > ul > li > ul > li{display:none;}
ul > li:hover ul > li:hover ul li{display:block;}

li{cursor:pointer;}  /* For the hand (cursor) while hover over the li */

DEMO 2

Or the short css, after fixing the first ul from
 to
 (By adding the = to it)
.menu ul {display:none;}
.menu li:hover > ul{display:block;}
li{cursor:pointer;}

DEMO 3

A: I've put together a working and minimalistic jsfiddle demo.
You hide all UL's inside .menu. Upon hovering any list-item, you reveal any direct descendant UL. I use display: block; and display: none; for the purpose of keeping it simple.
CSS:
/* Hide all UL's inside .menu */
.menu ul {
    display: none;
}

/* Show any UL which is a direct child of a hovered list-item */
.menu li:hover > ul {
    display: block;
}

A: fiddle: http://jsfiddle.net/Z22kH/
html:

    item1

subitem1

subitem2

subitem3

subitem4

        item2

subitem5

subitem6

subitem7

subitem8

css:
ul.menu li{
 display: none;
}
ul.menu > li{
 display: block;
}
ul.menu > li:hover > ul > li,
ul.menu ul > li:hover > ul > li{
  display:block;
}

A: HTML

    item1

subitem1

subitem2

subitem3

subitem4

        item2

subitem5

subitem6

subitem7

subitem8

CSS
.menu li > ul {
    display:none;
}

.menu li:hover > ul {
    display:block;
}

LIVE


text:
Q: firebase Cloud function transaction working sporadically I have the cloud function like so:
exports.updateNewsCount = functions.database.ref('/channels/{channelId}/news/{newsId}/')
.onWrite (event => {
    const channelId = event.params.channelId;
    const newsId = event.params.newsId;
    let CntRef = admin.database().ref('/channelDetails/' + channelId + '/newsCnt');
    if (event.data.exists() && !event.data.previous.exists()){
        return CntRef.transaction(function(current){
            if (current){
                console.log ('current is not null');
                return (current || 0) + 1;
            }
            else {
                console.log('current is null');
                return current;
            }
        },function(error, b, d){
            if (error)
                console.log(error);
            else
                console.log ('error is null');
            if (b)
                console.log('boolean is true');
            else
                console.log('boolean is false');

            if (d)
                console.log('snapshot is ' + d);
            else
                console.log ('snapshot is null');
        }).then(()=>{});
    } else if (!event.data.exists() && event.data.previous.exists()){
        return CntRef.transaction(function(current){
            if (current)
                return (current || 1) - 1;
            else
                return current;
        }, function(error, b, d){if (error) console.log(error); if (d) console.log(d);}).then(()=>{});
    }
});

It fires consistently as I can see the log entries.  However, the newsCnt field is not updated as expected.  Sometimes it gets updated and sometimes not!!! What am I doing wrong here?

A: You should expect that a transaction be called potentially multiple times, the first time with null.  That's the way transactions work.  Please read the documentation here.
In particular note the following callout in that section:

Note: Because your update function is called multiple times, it must
  be able to handle null data. Even if there is existing data in your
  remote database, it may not be locally cached when the transaction
  function is run, resulting in null for the initial value.

redpajama_set_name: RedPajamaStackExchange


text:
Q: true/false logic in exclusive gateway - camunda bpmn I am working on Generated Task Forms, I am trying to apply true/false logic in exclusive gateway. If true, end process. If false, redirect to data correction task.
<bpmn:sequenceFlow id="SequenceFlow_180tuqy" name="Yes" sourceRef="ExclusiveGateway_1gplnrv" targetRef="EndEvent_16krmz0">
  <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${approved}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:sequenceFlow id="SequenceFlow_1" name="No" sourceRef="ExclusiveGateway_1gplnrv" targetRef="stock_management">
  <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${!approved}</bpmn:conditionExpression>
</bpmn:sequenceFlow>

here ${approved} -> approved is the id of the boolean form fied, but it does not work.
what I need to mention in bpmn:conditionExpression?

A: First:

I´d like to ask if you write the BPMN-File yourself? Because there´s also a tool for it:

https://camunda.org/bpmn/tool/

Second:

On first sight I can´t see where there would be a problem. It looks ok to me. Often Camunda has problems with variables in conditions.

Try to write ${approved == true} instead of ${approved} and ${approved == false} instead of ${!approved}. If this doen´t work, maybe the problem lies elsewhere.

EDIT:

May you please explain what exactly happens, when quote "it does not work"?


text:
Q: Getting Error while implementing Fragmentation in Android I am getting error everytime when I run my Fragment API example application. It is referenced from Android Developers Guide http://developer.android.com/reference/android/app/Fragment.html.
I don't know how it returns the error and why? Please suggest anything you see that will get me the right result.
Error Stack:
01-03 11:54:55.255: E/AndroidRuntime(363): FATAL EXCEPTION: main
01-03 11:54:55.255: E/AndroidRuntime(363): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.fragment/com.example.fragment.FragmentExampleActivity}: android.view.InflateException: Binary XML file line #5: Error inflating class fragment
01-03 11:54:55.255: E/AndroidRuntime(363):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1736)
01-03 11:54:55.255: E/AndroidRuntime(363):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1752)
01-03 11:54:55.255: E/AndroidRuntime(363):  at android.app.ActivityThread.access$1500(ActivityThread.java:123)
01-03 11:54:55.255: E/AndroidRuntime(363):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993)
01-03 11:54:55.255: E/AndroidRuntime(363):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-03 11:54:55.255: E/AndroidRuntime(363):  at android.os.Looper.loop(Looper.java:126)
01-03 11:54:55.255: E/AndroidRuntime(363):  at android.app.ActivityThread.main(ActivityThread.java:3997)
01-03 11:54:55.255: E/AndroidRuntime(363):  at java.lang.reflect.Method.invokeNative(Native Method)
01-03 11:54:55.255: E/AndroidRuntime(363):  at java.lang.reflect.Method.invoke(Method.java:491)
01-03 11:54:55.255: E/AndroidRuntime(363):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
01-03 11:54:55.255: E/AndroidRuntime(363):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
01-03 11:54:55.255: E/AndroidRuntime(363):  at dalvik.system.NativeStart.main(Native Method)
01-03 11:54:55.255: E/AndroidRuntime(363): Caused by: android.view.InflateException: Binary XML file line #5: Error inflating class fragment
01-03 11:54:55.255: E/AndroidRuntime(363):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:688)
01-03 11:54:55.255: E/AndroidRuntime(363):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:724)
01-03 11:54:55.255: E/AndroidRuntime(363):  at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
01-03 11:54:55.255: E/AndroidRuntime(363):  at android.view.LayoutInflater.inflate(LayoutInflater.java:391)
01-03 11:54:55.255: E/AndroidRuntime(363):  at android.view.LayoutInflater.inflate(LayoutInflater.java:347)
01-03 11:54:55.255: E/AndroidRuntime(363):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:224)
01-03 11:54:55.255: E/AndroidRuntime(363):  at android.app.Activity.setContentView(Activity.java:1777)
01-03 11:54:55.255: E/AndroidRuntime(363):  at com.example.fragment.FragmentExampleActivity.onCreate(FragmentExampleActivity.java:11)
01-03 11:54:55.255: E/AndroidRuntime(363):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
01-03 11:54:55.255: E/AndroidRuntime(363):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1700)
01-03 11:54:55.255: E/AndroidRuntime(363):  ... 11 more
01-03 11:54:55.255: E/AndroidRuntime(363): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.example.fragment$TitlesFragment: make sure class name exists, is public, and has an empty constructor that is public
01-03 11:54:55.255: E/AndroidRuntime(363):  at android.app.Fragment.instantiate(Fragment.java:500)
01-03 11:54:55.255: E/AndroidRuntime(363):  at android.app.Fragment.instantiate(Fragment.java:468)
01-03 11:54:55.255: E/AndroidRuntime(363):  at android.app.Activity.onCreateView(Activity.java:4081)
01-03 11:54:55.255: E/AndroidRuntime(363):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:664)
01-03 11:54:55.255: E/AndroidRuntime(363):  ... 20 more
01-03 11:54:55.255: E/AndroidRuntime(363): Caused by: java.lang.ClassNotFoundException: com.example.fragment$TitlesFragment in loader dalvik.system.PathClassLoader[/data/app/com.example.fragment-1.apk]
01-03 11:54:55.255: E/AndroidRuntime(363):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:251)
01-03 11:54:55.255: E/AndroidRuntime(363):  at java.lang.ClassLoader.loadClass(ClassLoader.java:548)
01-03 11:54:55.255: E/AndroidRuntime(363):  at java.lang.ClassLoader.loadClass(ClassLoader.java:508)
01-03 11:54:55.255: E/AndroidRuntime(363):  at android.app.Fragment.instantiate(Fragment.java:490)
01-03 11:54:55.255: E/AndroidRuntime(363):  ... 23 more

layout-land/fragment_layout.xml:

<fragment class="com.example.fragment$TitlesFragment"
        android:id="@+id/titles" android:layout_weight="1"
        android:layout_width="0px" android:layout_height="match_parent" />

<FrameLayout android:id="@+id/details" android:layout_weight="1"
        android:layout_width="0px" android:layout_height="match_parent"
        android:background="?android:attr/detailsElementBackground" />

layout/fragment_layout.xml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="match_parent">
    <fragment class="com.example.fragment$TitlesFragment"
            android:id="@+id/titles"
            android:layout_width="match_parent" android:layout_height="match_parent" />
</FrameLayout>

A: Check this out.
make sure class name exists, is public, and has an empty constructor that is public
All subclasses of Fragment must include a public empty constructor. The framework will often re-instantiate a fragment class when needed, in particular during state restore, and needs to be able to find this constructor to instantiate it. If the empty constructor is not available, a runtime exception will occur in some cases during state restore.
Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.example.fragment$TitlesFragment: make sure class name exists, is public, and has an empty constructor that is public

Also make sure that your fragment class is public
public class MyFragment extends Fragment

when declaring your fragment class. Also, you shouldn't have any constructor in the class. So make sure that you don't have one.

A: You need to have the fragment name field as
<fragment
    android:name="my.package.name.classname"
    //other stuff
    />

rather than just putting the name of the class.

A: It is because the runtime is not able to find TitlesFragment while creating the activity
caused by: java.lang.ClassNotFoundException: com.example.fragment$TitlesFragment


text:
Q: QT QTreeView click event on specific column I have a quick question.  I want to intercept click events on a treeview with different behaviors based on which column is clicked.  I believe there is a signal which passes the model index... but how to identify the column? Thanks for the help.

A: Check QItemSelectionModel used in the QTreeView to handle selection or click event in a row o column. Make your treeview selectable and used one of the default signals. You have 3 different signal to handle a click event:
void    currentChanged(const QModelIndex &current, const QModelIndex &previous)
void    currentColumnChanged(const QModelIndex &current, const QModelIndex &previous)
void    currentRowChanged(const QModelIndex &current, const QModelIndex &previous)

Handle the signal with a custom slot, and use QModelIndex parameter to get the current row and index. Example:
void MainWindow::elementClicked(const QModelIndex& current, const QModelIndex& previous) {
     const int row =  current.row();
     const int column = current.column();
     qDebug() << "Clicked at " << row << column;
}


text:
Q: VB .NET Array list of MenuItems i would like to collect in VB .NET some MenuItems in a list of controls to easily manage many of them. The following code works using CheckBox for instance:
dim myMenuList() as Control
myMenuList = New Control() {MenuItem1, MenuItem2, MenuItem3, MenuItem4}

... but using it in this way, with MenuItem, Visual Studio give me this error:
It is impossible to convert from 'System.Windows.Forms.MenuItem' to 'System.Windows.Forms.Controls'

What's wrong with my code? I Thought that MenuItem is also a Control.
How can i make a list of MenuItems?
Thanks in advance,
Bye
hwktest

A:
What's wrong with my code? I Thought that MenuItem is also a Control.

MenuItem is not derived from Control. Look at the inheritance hierarchy and you'll see that the last common class is  Component..
Control:

*

*System.Object

*

*System.MarshalByRefObject

*

*System.ComponentModel.Component

*

*System.Windows.Forms.Control

MenuItem:

*

*System.Object

*

*System.MarshalByRefObject

*

*System.ComponentModel.Component

*

*System.Windows.Forms.Menu

*

*System.Windows.Forms.MenuItem

How can i make a list of MenuItems?

Like this:
Dim myMenuList As New List(Of MenuItem) From {MenuItem1, MenuItem2, MenuItem3, MenuItem4}

Or an array if you prefer:
Dim myMenuList As MenuItem() = {MenuItem1, MenuItem2, MenuItem3, MenuItem4}

A: Since MenuItem is not based on Control but on the Windows.Forms.Menu Class which is based on the Component Class, your best bet would to be to find a common ancestor, in this case it would be the Component Class.
Try something like this.
Imports System.ComponentModel

Public Class Form1

    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

        Dim MenuItem1 As New MenuItem
        Dim MenuItem2 As New MenuItem
        Dim MenuItem3 As New MenuItem
        Dim MenuItem4 As New MenuItem
        Dim button1 As New Button
        Dim myMenuList() As Component = New Component() {MenuItem1, MenuItem2, MenuItem3, MenuItem4, button1}
    End Sub
End Class


text:
Q: Braintree drop-in UI (iOS) I am trying to customize the appearance of the Braintree drop-in VC:

E.g. apply clear background color or background image to the whole thing. I can't seem to nail it. For instance, there's no backgroundView property to set an image to since it's a static UITableView.
Also, I can see there's support for themes..?
Has anyone successfully managed to customise the drop-in on top of the basic things that you can do as per Braintree's guide?

A: Full disclosure: I work at Braintree.
Theming for the Drop-in integration is not publicly supported at this time. However, this is an open source project and you can modify the Drop-in to fit your needs.

A: Themes are now supported in Braintree iOS v4 SDK:
https://developers.braintreepayments.com/guides/drop-in/customization/ios/v4


text:
Q: MS-Access 2013; Change combobox options based on record data in multi-record form I have a form with multiple records, one per row, being pulled from a table.  I have 2 ComboBox controls on each row.  The first ComboBox's options are linked to a table of Categories.  The second ComboBox's options need to be linked to the subcategories of the first ComboBox.
I have tried having the WHERE statement in the row source at design time, which produced all the subcategories.
I have tried having the WHERE statement, and a requery command, on the change event of the category ComboBox, which produced the subcategories for the last changed category.  This was an issues because all the rows would have the same options, instead of the options being based on the category for that record/row.
What I need is for each row to query the subcategory/category mapping table and filter the results based on that row's category selection.  Is this possible?  If so, how can this be done?  I am not afraid of using VBA to get the results I need.

A: In the On_Current event of the form, you can change the row source of the second combo box dynamically dependant on the value of the column of the first combo box.  You probably also need to do it on the after_update event of the first combo box to.
Something like this
    Select Case Me.cboCategory
Case "Category 1"
    Me.cboSubCategory.RowSource = "qryCat1Subclass"
Case "Category 2"
    Me.cboSubCategory.RowSource = "qryCat2Subclass"
Case Else
    Me.cboSubCategory.RowSource = ""
End Select

I don't have two combo boxes, just one, but its contents have to be based on a value in another field.  This is how I do it.


text:
Q: data.table NOT summarizing properly by two columns I have this problem with data.table which is driving me crazy recently. It looks like a bug but may be I'm missing something obvious here.
I have the following data frame:
# First some data
data <- data.table(structure(list(
  month = structure(c(1356998400, 1356998400, 1356998400,
                      1359676800, 1354320000, 1359676800, 1359676800, 1356998400, 1356998400,
                      1354320000, 1354320000, 1354320000, 1359676800, 1359676800, 1359676800,
                      1356998400, 1359676800, 1359676800, 1356998400, 1359676800, 1359676800,
                      1359676800, 1359676800, 1354320000, 1354320000), class = c("POSIXct",
                                                                                "POSIXt"), tzone = "UTC"),
  portal = c(TRUE, TRUE, FALSE, TRUE,
             TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
             TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE
  ),
  satisfaction = c(10L, 10L, 10L, 9L, 10L, 10L, 9L, 10L, 10L,
                   9L, 2L, 8L, 10L, 9L, 10L, 10L, 9L, 10L, 10L, 10L, 9L, 10L, 9L,
                   10L, 10L)),
                  .Names = c("month", "portal", "satisfaction"),
                  row.names = c(NA, -25L), class = "data.frame"))

I want to summarize it by both portal and month. Summarizing with good old tapply works as expected - I get 3x2 matrix with results for Dec-2012 and Jan-Feb 2013:
> tapply(data$satisfaction, list(data$month, data$portal), mean)
           FALSE      TRUE
2012-12-01   8.5  8.000000
2013-01-01  10.0 10.000000
2013-02-01   9.0  9.545455

Summarizing with by argument of data.table does not:
> data[, mean(satisfaction), by = 'month,portal']
   month      portal        V1
1: 2013-01-01  FALSE 10.000000
2: 2013-02-01   TRUE  9.000000
3: 2013-01-01   TRUE 10.000000
4: 2012-12-01  FALSE  8.500000
5: 2012-12-01   TRUE  7.333333
6: 2013-02-01   TRUE  9.666667
7: 2013-02-01  FALSE  9.000000
8: 2012-12-01   TRUE 10.000000

As you see, it returns a data table with 8 values, not 6 as expected; values where portal == TRUE and month == 2012-02-01 are duplicated, for example.
Interestingly enough, if I limit this just to 2013's data, everything works as expected:
> data[month >= ymd(20130101), mean(satisfaction), by = 'month,portal']
        month portal        V1
1: 2013-01-01   TRUE 10.000000
2: 2013-01-01  FALSE 10.000000
3: 2013-02-01   TRUE  9.545455
4: 2013-02-01  FALSE  9.000000

I am puzzled beyond believe :). Could somebody please help me?

A: That is a known issue that was solved in data.table 1.8.7 (not in CRAN yet as of this writing).
From data.table NEWS:

BUG FIXES

    <...>

o   setkey could sort 'double' columns (such as POSIXct) incorrectly when not the
    last column of the key, #2484. In data.table's C code :
        x[a] > x[b]-tol
    should have been :
        x[a]-x[b] > -tol  [or  x[b]-x[a] < tol ]
    The difference may have been machine/compiler dependent. Many thanks to statquant
    for the short reproducible example. Test added.

After updating to 1.8.7 with install.packages("data.table", repos="http://R-Forge.R-project.org"), everything works as expected.

A: The problem seems to be with the sorting. When I load data and do setkey:
setkey(data, "month", "portal")

# > data
#          month portal satisfaction
#  1: 2012-12-01   TRUE           10
#  2: 2012-12-01  FALSE            9
#  3: 2012-12-01  FALSE            8
#  4: 2012-12-01   TRUE            2
#  5: 2012-12-01   TRUE           10
#  6: 2012-12-01   TRUE           10
#  7: 2013-01-01   TRUE           10
#  8: 2013-01-01   TRUE           10
#  9: 2013-01-01   TRUE           10
# 10: 2013-01-01   TRUE           10
# 11: 2013-01-01   TRUE           10
# 12: 2013-01-01   TRUE           10
# 13: 2013-01-01  FALSE           10
# 14: 2013-02-01   TRUE            9
# 15: 2013-02-01   TRUE            9
# 16: 2013-02-01  FALSE            9
# 17: 2013-02-01   TRUE           10
# 18: 2013-02-01   TRUE           10
# 19: 2013-02-01   TRUE           10
# 20: 2013-02-01   TRUE           10
# 21: 2013-02-01   TRUE           10
# 22: 2013-02-01   TRUE            9
# 23: 2013-02-01   TRUE           10
# 24: 2013-02-01   TRUE            9
# 25: 2013-02-01   TRUE            9
#          month portal satisfaction

You see that the portal column is not properly sorted. When I do setkey again,
setkey(data, "month", "portal")

# I get this warning message:
Warning message:
In setkeyv(x, cols, verbose = verbose) :
  Already keyed by this key but had invalid row order, key rebuilt.
  If you didn't go under the hood please let datatable-help know so
  the root cause can be fixed.

Now, the data columns seem properly sorted by key columns:
# > data
#          month portal satisfaction
#  1: 2012-12-01  FALSE            9
#  2: 2012-12-01  FALSE            8
#  3: 2012-12-01   TRUE           10
#  4: 2012-12-01   TRUE            2
#  5: 2012-12-01   TRUE           10
#  6: 2012-12-01   TRUE           10
#  7: 2013-01-01  FALSE           10
#  8: 2013-01-01   TRUE           10
#  9: 2013-01-01   TRUE           10
# 10: 2013-01-01   TRUE           10
# 11: 2013-01-01   TRUE           10
# 12: 2013-01-01   TRUE           10
# 13: 2013-01-01   TRUE           10
# 14: 2013-02-01  FALSE            9
# 15: 2013-02-01   TRUE            9
# 16: 2013-02-01   TRUE            9
# 17: 2013-02-01   TRUE           10
# 18: 2013-02-01   TRUE           10
# 19: 2013-02-01   TRUE           10
# 20: 2013-02-01   TRUE           10
# 21: 2013-02-01   TRUE           10
# 22: 2013-02-01   TRUE            9
# 23: 2013-02-01   TRUE           10
# 24: 2013-02-01   TRUE            9
# 25: 2013-02-01   TRUE            9
#          month portal satisfaction

So, it seems to be an issue with sortting a POSIXct + logical types?
data[, mean(satisfaction), by=list(month, portal)]

#         month portal        V1
# 1: 2012-12-01  FALSE  8.500000
# 2: 2012-12-01   TRUE  8.000000
# 3: 2013-01-01  FALSE 10.000000
# 4: 2013-01-01   TRUE 10.000000
# 5: 2013-02-01  FALSE  9.000000
# 6: 2013-02-01   TRUE  9.545455

I therefore think there's a bug.


text:
Q: Exact solution to system of first order ODEs I am trying to solve a system of 1st order ODE's. $m(r)$ and $P(r)$ are real functions of $r$ and should be positive. $a$ and $b$ are just constants.
$$\frac{d m(r)}{dr}=\pi(\frac{P(r)}{a}+b)r^2\\$$
$$\frac{d P(r)}{dr}=-\frac{P(r)}{r-m(r)}\\$$
I could transform the system into one 2nd order ODE. Apparently Mathematica cannot solve this "simple" problem. Could you please advise me to literature, how to learn to solve these systems? Numerically it isn't a problem to solve them with appropriate boundary conditions.
The question I am most interested about is: How can we know, if there are "neat" closed-form solutions to this or similar systems? Is it correct to speak about transcendental ODE's? Can God with infinite intelligence write down functions $m(r)$ and $P(r)$, which solve the above system? I hope you won't attack me, for not having tried harder myself.
`

A: Regarding Mathematica's capability of solving these simple systems, I just post one exact solution of a different system, which Mathematica 7 apparently cannot solve. The solution was obtained by starting from it and then deriving the differential system, which it obeys. Literature recommendations on symbolic computation approaches to solve such systems are very welcome.
$\frac{dm(r)}{dr}=\frac{2r(-1+ar^3-r^4)(10r^2+6a^3r^3-6r^6+a^2(3-18r^4)+6ar(-2+3r^4))}{(1-3a^2r^2+6ar^3-3r^4)^2P(r)}$
$\frac{dP(r)}{dr}=\frac{-P(r)}{r-m(r)}$
with a solution:
$m(r)=\frac{-a+4a^2r^3-8ar^4+4r^5}{-1+3a^2r^2-6ar^3+3r^4}$
$P(r)=r^3+\frac{1}{r-a}$


text:
Q: How to memorize a diode's polarity in symbol? (self-answered) How to memorize a diode's polarity, such as anode and cathode in symbol?

A: Just dreamed up while reading this question and answers:

If you don't remember which is which, your A+ (anode, + voltage) will become (flow towards*) a C- (cathode, - voltage).

We'll see if that or something like it actually helps me (and/or others) remember. :)

* note: flow referring to conventional current, rather than electron flow.
(Also, I realize this is only about memorizing which name is which (which is what I was trying to remember when I found this question); I yield to other answers for getting the names and symbol mapped.)

A: In the schematic symbol, the straight line across the wire is the cathode, and on the physical part, the cathode is usually marked by a line.
The arrow in the schematic symbol for diodes and transistors points in the direction of Conventional (positive) current flow.

simulate this circuit – Schematic created using CircuitLab

A: Think of cats (felines), a lot of people think that cats are bad.  Bad is synonymous with negative and that's why the CAThode side is also the negative side.  That's the way I was taught by my professor.

A: Two mnemonic technique I'll mention. Both technique I've learnt from someone else, many-years ago.

*

*We can easily remember, anode is abbreviated as A, and Cathode as K. That is standard, and easy to remember.

Now , Write a K

Now, just fill in the blanks to make it a diode.

Now , the side of diode, where K was drawn, is Cathode (K).
By default, the opposite side is anode (A).
Now, if once we learn to recognize the K, if the diode orientate to a different direction in the diagram,  we could easily identify the anode and cathode.

-----------------------------------------------------------------

*The triangle inside the diode, makes an arrow sign. That tells the direction of allowed-direction of current.

From the second-method , we-can easily remember, the direction of current.
And ow.  A selected portion of Circuit portion(portion of interest)(here diode)'s  Cathode is the electrode that Vomits out-out positive-charge;
and the circuit's portion-of-interest(here diode)'s  Anode is the electrode that Sucks-in the positive charge.

above-table: Anode-Cathode Vs Plus-Minus Disambiguation
That is applicable not only for diodes. It is applicable for any-components like Electrochemical (Battery)-Cell, , Electrolytic-cell, Cathode-ray-Tube(CRT), etc.

Circuit's portion-of-interest(here diode)'s  Anode is to be attached with circuit-counterpart(here battery)'s Cathode.
And Circuit's portion-of-interest(here diode)'s Cathode to be attached with circuit's Counterpart(here battery)'s Anode.
Within the circuit's portion of interest (Here it is diode), Current flows in its Anode to Cathode direction.
In that selected portion's counterpart, or outer-portion of the path,  current flows from Anode(of the selected part, here diode) to Cathode ( of the selected part, here diode).

A: What I always remember is Anode - Arrow - Acceptor. The triple "A" of diodes.
The anode is the name, The arrow is the triangular bit of the symbol and the fact that it is made from acceptors means it is P-type.
All the converse parts are true then.
The bar is the cathode, which is the made from donors which is N-type.
You may not care about the acceptor and donors aspect, but that is important for me.

A: My trick to remember Anodes and Cathodes in most electrical systems is to think of a CRT, which, as you all know, stands for Cathode Ray Tube. Most of you are also familiar with how it works; namely, it shoots (negative) electrons at a screen. Thus, Cathodes are usually the negative pole of an electrical system and thus, diodes point towards them.
It's a convoluted trick but it just clicks with me.

A: Think of P as positive. Then just look for the P shape in symbol.
This makes it easy to remember.

(source: graffitialphabet.org)


text:
Q: The HTTP request is unauthorized with client authentication scheme 'Anonymous' via c# console app How to get authorized with scheme 'NTLM' via console c# app?
I try to connect to web-service (I have url with wsdl file).
So, i create service reference, add this address and press Go!
But I receive an error:
 The HTML document does not contain Web service discovery information.
Metadata contains a reference that cannot be resolved: 'http://webserver/service.php?wsdl'.
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The     authentication header received from the server was 'NTLM'.
The remote server returned an error: (401) Unauthorized.


text:
Q: .env do not work with AVA I'm receiving the following error, when I try to run my tests using ava with my project that uses dotenv-safe
{ [Error: ENOENT: no such file or directory, open '.env'] errno: -2, code: 'ENOENT', syscall: 'open', path: '.env' }
fs.js:549
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open '.env.example'

it looks like ava is not finding .env or .env.example files
is there any workaround or a solution for this?
this is a repo that u can easily reproduce the issue: https://github.com/sibelius/koa-env-ava

A: Took a quick look, here's a PR that gets things working: https://github.com/sibelius/koa-env-ava/pull/1
What was happening was that dotenv-safe did not know where to find your .env and .env.example files, so it would look in the src directory and throw an error. I rewrote your src/config.js file to automatically look in your project root directory:
const root = require('path').join.bind(this, __dirname, '..');

require('dotenv-safe').load({
  path: root('.env'),
  sample: root('.env.example')
});

export const API_URL = process.env.API_URL;
export const SERVER_PORT = process.env.SERVER_PORT;

This way dotenv-safe knows where to load your .env files from.


text:
Q: integrating Asynchronous Python code with Django I have this asynchronous python code which is given below and performs sign-up functionality:
async def add_account_endpoint(self, request: web.Request):
        """
        Adds account to the list of accounts with username and password
        : param request: Web request from the URL where the parameters will come in
        :return: WebResponse with the outcome of a request
        """
        data = await request.post()
        new_user_name = data.get('user_name')
        new_account_password = data.get('password')
        if new_user_name:
            if new_account_password:
                if new_user_name not in [account.user_name for account in self.accounts]:
                    # Create and add new account to the accounts in the exchange
                    new_account = Account(new_user_name, new_account_password, self.db_handler)
                    self.accounts.append(new_account)
                    return web.Response(content_type='text', body="Account added successfully")
                else:
                    return web.Response(content_type='text', body="Unable to add account: user_name already exists")
            else:
                return web.Response(content_type='text', body="Unable to add account: please give password")
        else:
            return web.Response(content_type='text', body="Unable to add account: please give user_name")

It is a signup code in which it is adding a user in DB.
now I want to integrate it with Django using templates.
How can I integrate it?


text:
Q: Style last children of last child I have the following HTML:

1

2

3

4

5

1

2

3

4

5

1

2

3

4

5

I have dynamically generated HTML, how do I style the above two things? Apply style to the section with id="top", and style the last 2 list-items in the last ul.

A: Something like this?
#top > ul:last-of-type li:nth-last-child(-n+2) {
    background:aqua;
}

jsFiddle here
Use a combination of selectors - :last-of-type and :nth-last-child.
Note - this is not fully supported by IE8 and down.

A: What about:
#top > ul:nth-child(3) > li:nth-child(4),
#top > ul:nth-child(3) > li:nth-child(5) {}

Working demo

A: #top {
    color:red;
}

#top ul:last-of-type li:last-of-type {
    color:green;
}


text:
Q: Resolve MainPage from IServiceProvider in Microsoft.Maui.Controls.Application I created a new dotnet maui project and want to resolve MainPage from IServiceProvider.
I added to MauiProgram.cs the line builder.Services.AddSingleton<MainPage>();. Instead of (App.xaml.cs):
    public partial class App : Microsoft.Maui.Controls.Application
    {
        public App()
        {
            InitializeComponent();
            MainPage = new MainPage();
        }
    }

I want to retrieve or somehow access MauiApp to resolve MainPage from IServiceProvider. Something like that:
    public partial class App : Microsoft.Maui.Controls.Application
    {
        public App()
        {
            InitializeComponent();
            var mauiApp = (MauiApp)this;
            MainPage = mauiApp.Services.GetService(typeof(MainPage)) as ContentPage;
        }
    }

Whats the best way to do this?

A: In MauiProgram.cs:
Add Singletons for any services you need:
   public static MauiApp CreateMauiApp()
    {
       builder.Services.AddSingleton<MainPage>();
       builder.Services.AddSingleton<IGoodbyeWorldService, GoodbyeWorldService>();
    }

in App.Xaml.cs:
Include the MainPage in the arguements of the App method and assign to MainPage:
    public App(MainPage page)
    {
        InitializeComponent();
        MainPage = page;
    }

Then in MainPage.xaml.cs include the service you need in the arguments:
    public MainPage(IGoodbyeWorldService service)
    {
     InitializeComponent();
     lblOne.Text = service.SayGoodbye();
    }


text:
Q: How to create unified clipboard Working with clipboard can be like a hell. Sometimes Ctrl+C just don't work and if you copy some text on, say, web browser you can't normally paste in somewhere else. Especially between Terminal and other programs. Sometmies you have to paste with Ctrl+Shift+Insert sometimes Ctrl+V.
Is there any way to unify handling clipboard?

A: You can bind the copy-paste to middle click using xsel and xvkbd.
First, install the packages:
sudo apt-get install xsel xvkbd

Now, run the following command:
sh -c 'xsel | xvkbd -xsendevent -file - 2>/dev/null'

You can also bind this to a keyboard shortcut from System Settings > Keyboard > Shortcuts.
More on xsel:
Taken from www.techrepublic.com:

The xsel tool, copyfree software available via the software management
  systems of most open source operating systems, is a simple utility
  meant to serve the need to copy text between the CLI environment and
  the GUI environment. It effectively acts as a pipeline-like interface
  between the CLI and the GUI clipboard.

To learn more about xsel, either visit the link above or go here.


text:
Q: How to append query string to current url using jquery Can anybody guide me how to append query string to current url using jquery but it should not get redirected to the new page. I mean it should simply get appended to the current url.
I have tried the following code but it's not working.
 $(".package-book a").click(function(){
 window.location.url = "?id=" + $(this).val(<?php the_title(); ?>);
  )};

A: Use jQuery BBQ (Back Button & Query Library) plugin - http://benalman.com/projects/jquery-bbq-plugin/
$.bbq.pushState();

A:   $(".package-book a").click(function(){
     window.location.url = "?id=" + $(this).val(<?php echo the_title(); ?>);
      )};

Either change the code as above or you should echo into your php function the_title() whatever you returning in this function.


text:
Q: How to pass params from URL to ajax request? Express web app I want to pull the params from a URL (after navigating to that URL) to use in an AJAX get request. The AJAX request will use the params in a client side function to get data specific to a user-profile.
URL example: www.website.com/user-profile/12345
Ajax request:
var theParams = // here I don't know how to access the params 12345 from above URL
var getDataWithParams = function() {
    $.ajax({
        url: '/getData/:' + theParams,
        success: function (data) {
            // process data
        }

    });
};

getDataWithParams();

A: Solution
// var url = window.location.href; if u wish to use url of page you had navigated to.

var url = 'www.website.com/user-profile/12345';

var userId = url.split('/').pop(); // pop gets last element


text:
Q: Error while inserting data into SQLiteDatabase in Android I initial object db and called its method from my current class:
        db = new DBHelper(context);
        db.addCallerInfo(FragmentCaller.iName.getText().toString(),
                FragmentCaller.sex.getSelectedItemPosition(),
                FragmentCaller.iAddress.getText().toString(),
                FragmentCaller.iTel.getText().toString(),
                FragmentCaller.callerType.getSelectedItemPosition(),
                FragmentCaller.iSpecify.getText().toString());

In DBhelper class:
public void addCallerInfo(String name,int   sex ,String address,String  tel,int  callerType_id,String  specify) {
        ContentValues values = new ContentValues();
        values.put("name", name);
        values.put("sex", sex);
        values.put("address", address);
        values.put("tel", tel);
        values.put("specify", specify);
        values.put("callerType_id", callerType_id);
        db.insert(TableHelper.TABLE_callerInfo, null, values);
    }

Then it has problem java.lang.NullPointerException:
Attempt to invoke virtual method long android.database.sqlite.SQLiteDatabase.insert(java.lang.String, java.lang.String, android.content.ContentValues) on a null object reference
Help please! Thanks.

A: Add below line in addCallerInfo() method. Then you can insert contentValues into Data Base.
   SQLiteDatabase db = this.getWritableDatabase();

A: You can't declare the Database type Writable or Readable
First declare it then inserting values like this:
 SQLiteDatabase database = this.getWritableDatabase();

And For just Readable database

 SQLiteDatabase db = this.getReadableDatabase();


text:
Q: iOS firmware incompatible with my iPad 2 GSM I have an iPad 2 GSM (know that cus it has a sim) and I am a Apple Developer. I've created an app in Swift and I need to test it. I downloaded the file called 'iPad3,1_8.0_12A4297e_Restore.ipsw' and I alt/option clicked the restore button and selected the ipsw. Then it displayed 'The ipad is not compatible with this firmware file' any fixes? I'm trying to redownload.

A: If you have an iPad2, then it will not be compatible with the iPad3 restore file.  If you do not see an iPad2 restore file, then the iPad2 will probably not be upgradable to iOS8.
Edit: I do see a restore file for the iPad2, make sure you are downloading the right file by checking the number on the back of your iPad and making sure it matches the download file number.

A: Download the link highlighted in red. I have same device and updated.
Reminder: You may want to backup SHSH before update or you can't downgrade to iOS 7


text:
Q: In Ruby, how do I make a hash from an array? I have a simple array:
arr = ["apples", "bananas", "coconuts", "watermelons"]

I also have a function f that will perform an operation on a single string input and return a value. This operation is very expensive, so I would like to memoize the results in the hash.
I know I can make the desired hash with something like this:
h = {}
arr.each { |a| h[a] = f(a) }

What I'd like to do is not have to initialize h, so that I can just write something like this:
h = arr.(???) { |a| a => f(a) }

Can that be done?

A: Did some quick, dirty benchmarks on some of the given answers. (These findings may not be exactly identical with yours based on Ruby version, weird caching, etc. but the general results will be similar.)
arr is a collection of ActiveRecord objects.
Benchmark.measure {
    100000.times {
        Hash[arr.map{ |a| [a.id, a] }]
    }
}

Benchmark @real=0.860651, @cstime=0.0, @cutime=0.0, @stime=0.0, @utime=0.8500000000000005, @total=0.8500000000000005
Benchmark.measure {
    100000.times {
        h = Hash[arr.collect { |v| [v.id, v] }]
    }
}

Benchmark @real=0.74612, @cstime=0.0, @cutime=0.0, @stime=0.010000000000000009, @utime=0.740000000000002, @total=0.750000000000002
Benchmark.measure {
    100000.times {
        hash = {}
        arr.each { |a| hash[a.id] = a }
    }
}

Benchmark @real=0.627355, @cstime=0.0, @cutime=0.0, @stime=0.010000000000000009, @utime=0.6199999999999974, @total=0.6299999999999975
Benchmark.measure {
    100000.times {
        arr.each_with_object({}) { |v, h| h[v.id] = v }
    }
}

Benchmark @real=1.650568, @cstime=0.0, @cutime=0.0, @stime=0.12999999999999998, @utime=1.51, @total=1.64
In conclusion
Just because Ruby is expressive and dynamic, doesn't mean you should always go for the prettiest solution. The basic each loop was the fastest in creating a hash.

A: I'm doing it like described in this great article http://robots.thoughtbot.com/iteration-as-an-anti-pattern#build-a-hash-from-an-array
array = ["apples", "bananas", "coconuts", "watermelons"]
hash = array.inject({}) { |h,fruit| h.merge(fruit => f(fruit)) }

More info about inject method: http://ruby-doc.org/core-2.0.0/Enumerable.html#method-i-inject

A: h = arr.each_with_object({}) { |v,h| h[v] = f(v) }

A: Ruby 2.6.0 enables a shorter syntax by passing a block to the to_h method:
arr.to_h { |a| [a, f(a)] }

A: Say you have a function with a funtastic name: "f"
def f(fruit)
   fruit + "!"
end

arr = ["apples", "bananas", "coconuts", "watermelons"]
h = Hash[ *arr.collect { |v| [ v, f(v) ] }.flatten ]

will give you:
{"watermelons"=>"watermelons!", "bananas"=>"bananas!", "apples"=>"apples!", "coconuts"=>"coconuts!"}

Updated:
As mentioned in the comments, Ruby 1.8.7 introduces a nicer syntax for this:
h = Hash[arr.collect { |v| [v, f(v)] }]

A: This is what I would probably write:
h = Hash[arr.zip(arr.map(&method(:f)))]

Simple, clear, obvious, declarative. What more could you want?

A: Another one, slightly clearer IMHO -
Hash[*array.reduce([]) { |memo, fruit| memo << fruit << f(fruit) }]

Using length as f() -
2.1.5 :026 > array = ["apples", "bananas", "coconuts", "watermelons"]
 => ["apples", "bananas", "coconuts", "watermelons"]
2.1.5 :027 > Hash[*array.reduce([]) { |memo, fruit| memo << fruit << fruit.length }]
 => {"apples"=>6, "bananas"=>7, "coconuts"=>8, "watermelons"=>11}
2.1.5 :028 >

A: in addition to the answer of Vlado Cingel (I cannot add a comment yet, so I added an answer).
Inject can also be used in this way: the block has to return the accumulator. Only the assignment in the block returns the value of the assignment, and an error is reported.
array = ["apples", "bananas", "coconuts", "watermelons"]
hash = array.inject({}) { |h,fruit| h[fruit]= f(fruit); h }


text:
Q: Compare viewbag value with string I assigned value to a ViewBag.Form in a controller
ViewBag.Form = "In";

Now, I want to compare the value with string in javascript. So I do it like this
 var form = "@ViewBag.Form";
if (form == "In")
{
//myCode
}
else
{
//myCode
}

But it always enter the else loop which mean form and ViewBag.Form doesnt match the value while it actually matched

A: please take viewbag in JavaScript in single quote
like this '@ViewBag.Form'
var form = '@ViewBag.Form';
if (form == "In")
{
//myCode
}
else
{
//myCode
}

or
assign ViewBag.Form value to hidden field
<input type="hidden" id="FormID" value="@ViewBag.Form" />

var form = document.getElementById('FormID'); //javascript
var form = $("#FormID").val(); //jQuery
    if (form == "In")
    {
    //myCode
    }
    else
    {
    //myCode
    }


text:
Q: Pybrain multi dimensional data input I have some data that has a dimension of 8x128 for each record. I wanted to train a Neural Network for this data.
Does anyone have any examples of using Multi-Dimensional Data as Input to a Pybrain Neural Network?
I've searched the documentation and found only Single Dimensional Input examples. enter link description here

A: Neural Networks don't care about the dimensionality of your input data, just serialize it (reshape([1024])) and feed that as input.


text:
Q: Spark : How to design streaming with spark? Current architecture
MySQL database with a REST API abstraction.
The problem
MySQL not scaling for various reasons that including data model design which is hard to fix.
Proposed architecture
Using Cassandra as the NoSQL backend and using Spark as the in memory computation engine along with Spark streaming.
Questions

*

*How good is cassandra's consistency ? The decision is to directly use kafka streams that carries real time information into Cassandra and then use Spark SQL to query that data.

*If the consistency above is good, then how are RDD's designed around this since they are immutable.Do they create new RDD's ?

*An alternative design is to migrate all the data from MySQL to Cassandra and then use kafka to directly send the messages to spark which handles it in real time and use downstream systems to finally hand over the data to Cassandra over time.

In points 1&2 the consistency is dependant upon Cassandra and in point 3 it is tied with Spark.
Which design is better ? Can someone throw some light on this.


text:
Q: Dependency Injection, Class requiring dictionary of same type of interfaces a good idea? Though I have asked this question in Code Review but the original code is now creeping. Yes, I am also a big fan of Clean code talks just watched those awesome videos, I have also seen this another question. This is the same problem I was originally having.
I have a class say human. Human based on some decision in its Travel method can either call Horse, Camel or Ship To Travel or It can also ask all of them(under some situation) to Travel.
All of the Horse, Camel, Ship have ITransport interface and of course this interface is having Travel method.
initial problem is that it is a possibility that during the life time of my project I may get some new Transportation such as Plane, Rocket, Submarine etc.
So I cannot just Simple pass them in constructor as ITransport ship, ITransport horse..... and so on, as my constructor parameter will keep on swelling.
So I came to a solution as suggested (I think) that HumanFactory should be having an event and that event should be passed in the constructor of Human class.
Although I have somehow removed my large Transportation list, but as You know that interfaces can have lots of methods. So now I will need to pass lots of delegates each corresponding to a method of an interface and ofcourse on a need basis.
I even tried to solve this problem by creating a Human Mapper class whose sole responsibility is to map to right transport, call the right event. This works !
Now, since this is an imaginary example, in real world example the interface's methods accept parameters, so how will I deal with it?
I think the direction in which I am going is creating a Maintenance Nightmare.
I am pasting the code for a quick reference.
interface ITransport
{
    void Travel();
}

My Transport Factory is as:
public class TransportFactory
{
....
    internal ITransport ProvideTransport(TransportTypes transportType)
    {
        switch (transportType)
        {
            case TransportTypes.Camel: return new Camel();
            case TransportTypes.Horse: return new Horse();
            case TransportTypes.Ship: return new Ship();
            default:
                return null;
        }
    }
}

My Human class after suggestion has become as:
public class Human
{
    Action<Human, string> _transportRequested;

    public Human(Action<Human, string> transportRequested)
    {
        _transportRequested = transportRequested;
    }

    public void Travel()
    {
        if (_transportRequested != null)
        {
            var ev = _transportRequested;
            ev.Invoke(this, GroundTypes.Plains.ToString());
        }
    }
}

I have a human class factory now as suggested which is as:
public class HumanFactory
{
    ITransport camel;
    ITransport ship;
    ITransport horse;
    Human _human;
    Dictionary<string, ITransport> _availableTransports;
    event Action<Human, string> transportRequested;

    public HumanFactory(TransportFactory tFactory)
    {

        horse = tFactory.ProvideTransport(TransportTypes.Horse);
        camel = tFactory.ProvideTransport(TransportTypes.Camel);
        ship = tFactory.ProvideTransport(TransportTypes.Ship);
    }

    public Human ConfigureHuman()
    {
        if (_availableTransports == null)
        {
            _availableTransports = new Dictionary<string, ITransport>();
            _availableTransports.Add(GroundTypes.Desert.ToString(), camel);
            _availableTransports.Add(GroundTypes.Sea.ToString(), ship);
            _availableTransports.Add(GroundTypes.Plains.ToString(), horse);
        }

        transportRequested += new Action<Human, string>(_human_transportRequested);
        _human = new Human(transportRequested);

        return _human;
    }

    void _human_transportRequested(Human human, string groundType)
    {
        if (_availableTransports.ContainsKey(groundType))
        {
            ITransport suitableTransport = _availableTransports[groundType];
            suitableTransport.Travel();
        }
        else
        {
            //code for handling below conditions goes here
            //I don't know what to do for this type of plain?
        }
    }
}

I talked about a Mapper class which maps correct transport to correct methods as(it looks ugly but that was the best I came up with :) ):
class Human_Transport_MethodMapper
{
    Dictionary<GroundTypes, ITransport> _availableTransports;
    List<EventTypes> _availableEvents;
    event Action<Human, GroundTypes, EventTypes> transportRequested;
    internal Action<Human, GroundTypes, EventTypes> transportRequesteddel;
    public Human_Transport_MethodMapper(Dictionary<GroundTypes, ITransport> availableTransports, List<EventTypes> availableEvents)
    {
        _availableEvents = availableEvents;
        _availableTransports = availableTransports;
        transportRequested += human_OnAnyEventReceived;
        transportRequesteddel = transportRequested;
    }
    internal void human_OnAnyEventReceived(Human human, GroundTypes groundType, EventTypes eventType)
    {
        if (_availableTransports.ContainsKey(groundType))
        {
            ITransport suitableTransport = _availableTransports[groundType];
            switch (eventType)
            {
                case EventTypes.Travel: suitableTransport.Travel();
                    break;
                default:
                    break; //meaning interface's correct method has not been mapped.
            }

        }
        else
        {
            //code for handling below conditions goes here
            //I don't know what to do for this type of plain?
        }
    }
}

Now see that in this event, For Travel method if there were two arguments, then delegate signature would had changed, If there were four or five methods in ITransport interface, then may God help me.
I hope I have explained my problem here.
Thanks
Edit: I am removing some obvious code from this question in order to make it more readable and also it is getting more verbose

A: First of all, the way you deal with standart events is confusing and overcomplicated. You dont need to pass events to constructor See my last edit in previous topic on how it can be simplified.
Also, as i mentioned in previous topic, the common way to deal with complicated event network in large applications is to implement EventsAggregator pattern (http://codebetter.com/jeremymiller/2009/07/22/braindump-on-the-event-aggregator-pattern/). There are zillions of various implenetations availible on the web, so i leave it up to you to pick one. I will use this interface for example purposes:
interface IEventsAggregator
{
    //sends message to network
    void Publish(object message);
    //adds object to the list of handlers
    void Subscribe(object listener);
    //removes object from the list of handlers
    void Unsubscribe(object listener);
}

//listeners should implement this interface
interface IListener<TMessage>
{
    //handling logic for particular message
    void Handle(TMessgae message);
}

Then your code can be refactored:
//you do not need human factory in this example
public class Human
{
    private readonly IEventsAggregator _events;

    //see Handle implementation for details
    //public ITransport Transport { get; set; }

    public Human(IEventsAggregator events)
    {
        _events = events;
    }

    public void Travel(GroundTypes type)
    {
        _events.Publish(new TransportRequest(this, type));
        //see Handle implementation for details
        //if (Transport != null) Transport.Travel();
    }
}

public class TransportRequest
{
    public Human Sender { get; set; }
    public GroundTypes Ground { get; set; }

    public TransportRequest(Human sensder, GroundTypes ground)
    {
        Sender = sender;
        Ground = ground;
    }
}

public class TravelAgency : IListener<TransportRequest>, IDisposable
{
    private readonly IEventsAggregator _events;
    private readonly TransportFactory _tFactory;

    public TravelAgency(IEventsAggregator events, TransportFactory tFactory)
    {
        _events = events;
        _events.Subscribe(this);
        _tFactory = tFactory;
    }

    public void Handle(TransportRequest request)
    {
        var transort = _tFactory.ProvideTransport(...);
        //insert the handling logic here
        //there are two ways to handle this message:
        //1) you give human no control over (and no knowledge of) Transport
        //and simply call transport.Travel(request.Sender); here
        //2) or you add ITransport property to Human class
        //and do only the assignation here
        //request.Sender.Transport = transport;
        //and then let the human manage Transport object
    }

    public void Dispose()
    {
        _events.Unsubscribe(this);
    }
}

This is probably how i would do it, if i needed to stricktly separate logic for some reason. It might be a bit too complicated for such trivial task, but i think it is a good basement for larger application. :) There are probably other approaches tho.


text:
Q: Two Android Applications is getting installed when product flavor is used I'm trying out product flavors to merge two android application code base which has different package structures into single code base. Both the flavours have two different android manifest files, which have its own Launcher activity. Both the android manifest files will be very much different, as both the flavor code is entirely different.
src

*

*main

*

*java(com.test.game.cars)

*res

*AndroidMainfest.xml

*bricks

*

*java(com.test.game.bricks)

*res

*AndroidMainfest.xml

I have added category.DEFAULT intent in the bricks android manifest file.
productFlavors {
    cars{
        applicationId "com.test.game.cars"
    }
    bricks{
        applicationId "com.test.game.bricks"
    }
}

When i try to run carsdebug, it is running fine. But when i try to run bricks, both the cars and bricks apk are getting installed into phone. Is there anyway to install only bricks app alone, when bricks debug is ran?

A: Because each flavor is merged with main flavor. This problems occurs because of manifest merging. So whenever you choose bricks flavor, one launcher comes from main (that wrongly represents cars) and another launcher comes from bricks.
So what you should do;
Try to keep shared parts of both flavors in main, and create another directory that named cars like bricks.


text:
Q: How does geolocation work on a windows PC on wired broadband connection? I'm trying to develop a web app which uses geolocation, and to begin with it worked fine on my Windows 7 PC at home, both in Chrome and Firefox.
It still works fine on mobile browsers, but has stopped working on both browsers on my PC, which made me wonder how it actually works on my PC - is it querying a geographical database of IP addresses that could now be blocking me due to overuse?
Is there any way to change the settings? The "Location and Other Sensors" control panel tells me there are no sensors installed, and nothing shows up in the event log for "Location Activity".

A:
Firefox gathers information about nearby wireless access points and
  your computer's IP address. Then Firefox sends this information to the
  default geolocation service provider, Google Location Services, to get
  an estimate of your location. That location estimate is then shared
  with the requesting website.

From: https://www.mozilla.org/en-US/firefox/geolocation/
This is also how Chrome determines location (Sending IP and nearby Wi-Fi info to Google Location Services). It seems likely that Windows 7 does about the same thing, though I couldn't find specific details other than it uses postal code if available.


text:
Q: Tomcat in memory session replication We are looking to implement in memory session replication. Before we do that our main concern is how the session objects will use the memory? and if session get large after some time will get out of memory error so how to overcome this other than increasing the memory size?
if anybody get into these please reply me.., Thanks in advance.

A: It's not a precise answer, but I strongly recommend you to read this blog. There are many useful tricks to deal with huge set of data in java.
If you deploy on linux, consider using tmpfs or ramfs. Maybe you don't need to code it at all.

A: One thing you can do is limiting the number of active sessions (maxActiveSessions): http://tomcat.apache.org/tomcat-7.0-doc/config/manager.html#Common_Attributes - so you can limit the memory used by sessions.
Another option is to use non-sticky sessions so that there are only as much sessions concurrently stored in memory as there are concurrent requests. Not sure about the details of the tomcat integrated replication of with non-sticky sessions, but at least memcached-session-manager can manage them (I must mention that I'm the author of this lib). It also provides jmx statistics that allow you to inspect the session memory size.


text:
Q: URL specification that allows internationalized domain names? I'm trying to find the current spec for URLs.  I found RFC3986, but that doesn't allow non-ASCII characters, like you might find in internationalized domain names (IDNA).
URLs are one of the key bits of the Internet; surely there must be a spec for them?  If so, where is it?

A: Internationalized Resource Identifiers (IRIs)
https://www.rfc-editor.org/rfc/rfc3987

This document defines a new protocol element, the Internationalized
Resource Identifier (IRI), as a complement to the Uniform Resource
Identifier (URI).  An IRI is a sequence of characters from the
Universal Character Set (Unicode/ISO 10646).  A mapping from IRIs to
URIs is defined, which means that IRIs can be used instead of URIs,
where appropriate, to identify resources.

Note that Anne van Kesteren edits a "new" URL specification (at WHATWG) as a "Living Standard", which states to have the goal to "Align RFC 3986 and RFC 3987 with contemporary implementations and obsolete them in the process.".


text:
Q: Best reordering of an $n \times n$ sparse matrix for LU decomposition when solving $Ax = b$ When solving a system of linear equations $Ax = b$, where $A$ is square and sparse, I've seen an almost 3x speedup in Matlab when the Approximate Minimum Degree (AMD) reordering is used before doing the LU decomposition.
I'm wondering if there has been any developments on better reordering schemes than AMD, or any "pre-processing" step in general that accelerates the LU decomposition. In my work $A$ is usually not positive definite or perfectly symmetric, so I can't just use Cholesky instead.
An example of an $A$ I'm dealing with is shown below (before and after AMD):

Thanks in advance!

A: Finding the fill-in minimizing ordering is NP-Hard, which means that it is extremely unlike that there exists an algorithm which is guaranteed to find the best reordering of a sparse matrix efficiently in every case. For nonsymmetric problems, the issue is even more severe as one has to reorder the rows and columns of the matrix both to reduce fill-in and to maintain numerical stability (as using a small pivot can significantly erode the accuracy of an $LU$ factorization). (There are some nonsymmetric problems like row-column diagonally dominant ones where this issue is less important.) There are some problems which provably don't have an ordering so that $A = LU$ can be computed in time proportional to $\operatorname{nnz}(A)$.
That said, very good software exists to find good elimination orderings for sparse matrices (e.g. Metis). Well-written sparse direct solvers like UMFPACK (which is the backend behind MATLAB's \ operation) are very efficient for most sparse problems and balance both the accuracy and fill-in reducing aspects of nonsymmetric $LU$. For any "real life computation", I would use a well-established software library as rapidly and accurately solving a sparse linear system is a delicate subject.


text:
Q: C++ check if entered value is unsigned integer I'm trying to get unsigned integer from std::cin.
When enter a char or string my program stucks
#include <iostream>
#include <climits>

using namespace std;

int main()
{
    unsigned int number;
    do
    {
        cout << "Enter a unsigned number\t";
        cin >> number;

        if (0 < number && number < 65535 && std::cin.good())
        {
            cout << "It's a number";
            break;
        }
        cout << "Not a number";
    } while (true);
}

How to do that ?

A: It seems that std::cin needs to be recovered when a failure happens(std::cin.clear() fails to restore input stream in a good state)
Then I think using unsigned int is not a solution to enforce positiveness because c/c++ allow implicit conversion between unsigned int and int, so if you do unsigned int x = -1 ,x will become 4294967295(assuming 32 bits int) due to underflow.
#include <iostream>

int main()
{
    int number;
    while (true)
    {
        std::cout << "Enter an unsigned number\n";
        std::cin >> number;

        if (std::cin.fail())
        {
            std::cout << "Please enter a number\n";
            std::cin.clear();
            std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
        }
        else if (number > 0)
        {
            std::cout << "It's an unsigned number\n";
            break;
        }
        else
        {
            std::cout << "It's an negative number\n";
        }
    }
}

A: The problem when you enter a non-numeric character is that extraction fails and that the character is still in the input stream. You need to remove it if extraction fails.
Another potential problem is your choice of type for the input, unsigned int. If that happens to be a 32 bit integer (which is very common) and the user enters -4294967295 for example, the extraction will succeed and the number will wrap around and become 1 - which is then accepted by the program. When using formatted extraction of numbers, it's safer to use a signed type (wider than needed for the target range) even if you want an unsigned number - and then check the range.
Example:
#include <cstdint>
#include <iostream>
#include <limits>

int main() {
    std::int32_t number; // enough to hold 0-65535 (and then some)

    do {
        std::cout << "Enter a number (1-65534)\t";

        // check that extraction succeeds and the number is in range [1,65534]:
        if(std::cin >> number && number > 0 && number < 65535) {
            std::cout << number << " is a valid number\n";
            break;
        } else {
            if(std::cin.eof()) {
                std::cout << "Bye bye\n";
                return 1;
            }
            std::cout << "Not a valid number\n";
            // clear error state
            std::cin.clear();

            // ignore the rest of the line
            std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
        }
    } while(true);

    // if you want to store the number in a type suited for your range:
    auto final_number = static_cast<std::uint16_t>(number);
}

A: You can use getline() function of string class and achieve it as below:
#include <iostream>
#include <climits>
#include <sstream>

using namespace std;

int main()
{
    string number;
    do
    {
        cout << "Enter an unsigned number\t";

        unsigned int num;
        while (getline(cin, number))
        {
            if(number.at(0) != '-')
            {
                stringstream ss(number);
                if (ss >> num)
                {
                    if (ss.eof())
                    {   // Success as found numbers
                        break;
                    }
                }
                cout << "Error in input!" << endl;
            }
            cout << "Error as -ve number!" << endl;
        }

        cout << "Entered num " << num << endl;
    } while (true);
}

Further you can modify this function as per your need to add constraint for accepting numbers. This solution is to avoid your infinite loop and accepting numbers.

A: When you input a string value, operator>> tries to extract your string input into variable 'number'. This fails since string cannot be converted into unsigned int. This wrong input value is then left in the buffer, while std::cin fails. Any future inputs for extraction will also fail silently. To get past this use,
#include <limits>
if (std::cin.fail()) // has input extraction failed?
{
    std::cin.clear(); // then clear cin and reset it
    std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); //clear buffer
}

std::cin.ignore() takes in two parameters - the first one is number of characters to remove and the second is the parameter until which to remove characters from the buffer.
std::numeric_limits<std::streamsize>::max() just gives the largest value that can be stored in type std::streamsize. You can just use a value like 200 or 300, but if the user has somehow input more values, using std::numeric_limits would help guard against this possibility. Add this check in the appropriate place in your code.


text:
Q: MonoTouch and supporting variant generic interfaces The below example compiles fine in regular Mono 2.10.9:
namespace covarianttest
{
    public interface ITest<out T> : IEnumerable<T>
    {
    }
}

However when I attempt compile it against MonoTouch 6.0.8 I receive this error:
Error CS1961: The covariant type parameter 'T' must be invariantly valid on 'covarianttest.ITest'
So am I to assume that MonoTouch doesn't support extending covariant/contravariant generic interfaces yet? If so what is the recommend workaround for this situation in MonoTouch?

A: This actually depend on the compiler (and profile/runtime) not the Mono version. IOW some things might work on Mono 2.10 and not with MonoTouch 6.x.
Current versions of MonoTouch ships with the smcs compiler and a 2.1 based profile (mostly Silverlight and some .NET 4.0 additions).
Newer features, like covariance, requires a full 4.0 compiler (e.g. dmcs in Mono 2.10 or mcs in Mono 3.0) and runtime.
Future versions of MonoTouch (likely this spring with alpha/beta in early 2013) will provide a 4.0/4.5 runtime and compiler.


text:
Q: Redis reliable queues for multi threaded processing For my ongoing project, I am using Redis for message distribution across several processes.  Now, I am supposed to make them reliable.
I consider using the Reliable queue pattern through BRPOPLPUSH command. This pattern suggests that the processing thread remove the extra copy of message from "processing list" via lrem command, after the job has been successfully completed.
As I am using multiple threads to pop, the extra copies of popped item go into a processing list from several threads.  That is to say, the processing queue contains elements popped by several threads.  As a consequence, if a thread completes its job, it cannot know which item to remove from the "processing queue".
To overcome this problem, I am thinking that I should maintain multiple processing queues (one for each thread) based on threadId. So, my BRPOPLPUSH will be:
BRPOPLPUSH <primary-queue> <thread-specific-processing-queue>

Then for cleaning up timedout objects, my monitoring thread will have to monitor all these thread specific processing queues.
Are there any better approaches to this problem, than the one conceived above?

A: @user779159
To support reliable queue mechanism, we take the following approach:
 - two data structures
    -- Redis List (the original queue from which items are popped regularly)
    -- a Redis z-set, which temporarily stores the popped item.

Algorithm:
-- When an element is popped, we store in z-set
-- If the task that picked the item completed its job, it will delete the entry from z-set.
-- If the task couldn't complete it, the item will be hanging around in z-set. So we know, whether a task was done within expected time or not.
-- Now, another background process periodically scans this z-set, picks up items which are timedout, and then puts them back to queue

How it is done:

*

*we use zset to store the item that we poped (typically using a lua
script).

*We store a timeout value as the rank/score of this item.

*Another scanner process, will periodically (say every minute) run
z-set command zrangebyscore, to select items between (now and last 1
minute).

*If there are items found by the above command, this means
the process that popped the item (via brpop) has not completed its
task in time.

*So, this 2nd process will put the item back to the
queue (redis list) where it originally belonged.


text:
Q: Existe algum serviço online que faz requisições em uma determinada url? Preciso que seja feita uma requisição GET em uma url a cada 5 minutos. Existe algum serviço gratuito que faça isso?

A: Para URL estática eu uso esse site: https://uptimerobot.com/
Dá pra configurar vários intervalos de 5 minutos ou mais, até 50 URLs. Menos que 5 minutos só pagando. Agora se precisa passar parâmetros dinâmicos para URL terá que procurar alguma API ou usar algum cronjob.


text:
Q: Adding a datagridview cell on button click brings up error "Collection already belongs.." I am dynamically adding a datagridview to a form. After the form is loaded, if the user wants to add a new row, I have a button with which the use can add one. On this button click I am trying to add a DataGridViewComboBoxCell:
DataGridViewRow dtRow = new DataGridViewRow();
dgv1.Rows.Add(dtRow);
int RowIndex = dgv1.Rows.IndexOf(dtRow);
int TotalRowsvailable = NPDESconfigModel.Count; // rows in database

 if (RowIndex >= TotalRowsvailable) // to see if this is the new row
{
 List<string> a = (from p in y
                   select p.Point_Name).ToList();

 DataGridViewComboBoxCell cbcell = new DataGridViewComboBoxCell();
 cbcell.DataSource = a;
 cbcell.DisplayMemeber = "Point_Name";
 dgv1.Rows[RowIndex].Cells.Add(cbcell);
}

The exception I get on the last line of the code is as below.
  Collection already belongs to a DataGridView control. This operation
  is no longer valid.

Not sure what it means.
After the exception the forms loads with a new row and empty cell.

A: You should put the new Cell into an exising Cell, not to the end the Cells collection.
Maybe like this:
 dgv1.Rows[RowIndex].Cells[yourComboboxColumnIndex] = cbcell;

The error message means that you can only add to the Cells collection of a Row as long as it is not part of a DataGridview. You can create a DataGridViewRow in code and add a suitable number of suitable Cells to it. Then you can add it to a DGV; but eventually all rows must have the same number of Cells..


text:
Q: how to bring up start menu in windows mobile 6.5 app (full screen) in vb.net compact My app is built in vb.net compact. All these years in all versions when user taps at the top or bottom of the screen (depending on where the task bar is located) it brings up the task bar and start menu fine. But now the latest OS build doesn't do it anymore. I'm thinking of having a button in my app to bring up the task bar but not sure how to do it.
However, in IE full screen there is a circular button that brings up the task bar. If I can accomplish it in my app that would be good.

A: You can use the Remote Spy tool to find out the name of your task-bar, then you can try calling FindWindow function using this name to get the handle, and finally calling ShowWindow function to get it to show. (In P/Invoke versions for FindWindow and ShowWindow use coredll.dll instead of user32.dll).


text:
Q: Button in listview with custom adapter to go to other pages.App crashes whenever button is clicked. No errors in code shown I am trying to link each button to different pages, however my app crashes everytime i click the buttons. I am relatively new to Java but Im tasked to produce an application hence any help will be greatly appreciated! Thank you.
My StackTrace error
01-03 12:44:41.659 4796-4796/com.example.npstudent.catvaccination E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                Process: com.example.npstudent.catvaccination, PID: 4796
                                                                                android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
                                                                                at android.app.ContextImpl.startActivity(ContextImpl.java:1238)
                                                                                at android.app.ContextImpl.startActivity(ContextImpl.java:1225)
                                                                                at android.content.ContextWrapper.startActivity(ContextWrapper.java:323)
                                                                                at com.example.npstudent.catvaccination.CatVaccinationListAdaptor$1.onClick(CatVaccinationListAdaptor.java:65)
                                                                                at android.view.View.performClick(View.java:4780)
                                                                                at android.view.View$PerformClick.run(View.java:19866)
                                                                                at android.os.Handler.handleCallback(Handler.java:739)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                at android.os.Looper.loop(Looper.java:135)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:5254)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Mainactivity Layout XMl(Updated)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical"
android:paddingBottom="5dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="5dp">

<TextView
    android:id="@+id/CatVaccine1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Cats"
    android:textColor="@color/black"
    android:textSize="30sp" />
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <ImageView
        android:id="@+id/CatPicture1"
        android:layout_width="171dp"
        android:layout_height="113dp"
        android:layout_weight="1"
        android:gravity="start"
        android:contentDescription="@null"
        app:srcCompat="@drawable/doggo" />

    <ImageView
        android:id="@+id/CatPicture2"
        android:layout_width="171dp"
        android:layout_height="113dp"
        android:layout_weight="1"
        android:gravity="center_horizontal"
        android:contentDescription="@null"
        app:srcCompat="@drawable/doggo" />
</LinearLayout>

<TextView
    android:id="@+id/CatVaccine2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Feline Calicivirus"
    android:textColor="@color/black"
    android:textSize="20sp" />

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/CatVaccine3"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="start"
        android:layout_toLeftOf="@+id/CatVaccine4"
        android:text="Feline Calicivirus"
        android:textColor="@color/black"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <Button android:text="Find out more..."
        android:id="@+id/BtnToClick"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >
    </Button>
</LinearLayout>

My listview layout file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#008080">

<ListView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/listview_catproduct"
    android:layout_marginTop="10dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:divider="#000000"
    android:dividerHeight="2dp">

</ListView>

My Main activity(updated):
(All values were specified but i didnt show all as it was pretty redundant)
    public class MainActivity extends AppCompatActivity {
private ListView lvcatInformation;
private CatVaccinationListAdaptor adapter;
private List<Catinformation> CatInformationList;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    CatInformationList = new ArrayList<>();

    //add sample data for list(id for the line of info, name,info, description,id set for the image resource file in drawables
    CatInformationList.add(new Catinformation(0, "Feline calicivirus", "Highly recommended vaccine", "Not a lethal disease but commonly found everywhere",c1,ic2));

    //Init adapter
    adapter = new CatVaccinationListAdaptor(getApplicationContext(), CatInformationList);
    lvcatInformation.setAdapter(adapter);

}
}

My Setter and Getter:
public class Catinformation {
private int id;
private String name;
private String info;
private String description;
private int CatImage1;
private int CatImage2;

//constructor

public Catinformation(int id, String name, String info, String description, int CatImage1, int CatImage2) {
    this.id = id;
    this.name = name;
    this.info = info;
    this.description = description;
    this.CatImage1 = CatImage1;
    this.CatImage2 = CatImage2;

}

//Setter getter

public int getId() {
    return id;

}

public void setId(int id) {
    this.id = id;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public String getInfo() {
    return info;
}

public void setInfo(String info) {
    this.info = info;
}

public String getDescription() {
    return description;
}

public void setDescription(String description) {
    this.description = description;
}

public int getCatImage1() {
    return CatImage1;
}

public void setCatImage1(int catImage1) {
    this.CatImage1 = catImage1;
}

public int getCatImage2() { return CatImage2; }

public void setCatImage2(int catImage2) {
    this.CatImage2 = CatImage2;
}
}

My adapter(updated):
public class CatVaccinationListAdaptor extends BaseAdapter {
private Context CatContext;
private List<Catinformation> CatInformationList;

//constructor

public CatVaccinationListAdaptor(Context mContext, List<Catinformation> CatInformationList) {
    this.CatContext = mContext;
    this.CatInformationList = CatInformationList;
}

@Override
public int getCount() {
    return CatInformationList.size();
}

@Override
public Object getItem(int position) {
    return CatInformationList.get(position);
}

@Override
public long getItemId(int position) {
    return position;
}

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    View v = View.inflate(CatContext, R.layout.catvaccination_list, null);
    TextView Vac1 = (TextView)v.findViewById(R.id.CatVaccine1);
    TextView Vac2 = (TextView)v.findViewById(R.id.CatVaccine2);
    TextView Vac3 = (TextView)v.findViewById(R.id.CatVaccine3);
    ImageView Image1 = (ImageView)v.findViewById(R.id.CatPicture1);
    ImageView Image2 = (ImageView)v.findViewById(R.id.CatPicture2);
    Button Button1 = (Button)v.findViewById(R.id.BtnToClick);
    //set text for text view
    Vac1.setText(CatInformationList.get(position).getName());
    Vac2.setText(CatInformationList.get(position).getInfo());
    Vac3.setText(CatInformationList.get(position).getDescription());
    Image1.setImageResource(CatInformationList.get(position).getCatImage1());
    Image2.setImageResource(CatInformationList.get(position).getCatImage2());
    //Save id to tag
    Button1.setTag(CatInformationList.get(position).getId());

    Button1.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v)
        {
            switch (position) {
                case 0:
                    CatContext.startActivity(new Intent(CatContext, Page2cat.class));break;

                case 1:
                    CatContext.startActivity(new Intent(CatContext, Page3cat.class));break;
                case 2:
                    CatContext.startActivity(new Intent(CatContext, Page4cat.class));break;
                case 3:
                    CatContext.startActivity(new Intent(CatContext, Page5cat.class));break;

                case 4:
                    CatContext.startActivity(new Intent(CatContext, Page6cat.class));break;
                case 6:
                    CatContext.startActivity(new Intent(CatContext, Page7cat.class));break;
                case 7:
                    CatContext.startActivity(new Intent(CatContext, Page8cat.class));break;
                case 8:
                    CatContext.startActivity(new Intent(CatContext, Page9cat.class));break;

            }

        }
    });

    return v;
}}

A: The problem is with your XML. In your button widget in the xml, you have android:onClick="onClick"
You can remove this property and it will work properly.
For using onClick property in xml, you need to define a function in your java/activity file with proper name and signature. You can read more about in Android Documentation.
EDITED
Add this in your getView function in Adapter class.
  Button1.setOnClickListener(new OnClickListener() {
  public void onClick(View v)
   {
    switch (position) {
            case 0:
                startActivity(new Intent(context, Page2cat.class));break;

            case 1:
                startActivity(new Intent(context, Page3cat.class));break;
            case 2:
                startActivity(new Intent(context, Page4cat.class));break;
            case 3:
                startActivity(new Intent(context, Page5cat.class));break;

            case 4:
                startActivity(new Intent(context, Page6cat.class));break;
            case 6:
                startActivity(new Intent(context, Page7cat.class));break;
            case 7:
                startActivity(new Intent(context, Page8cat.class));break;
            case 8:
                startActivity(new Intent(context, Page9cat.class));break;

        }

}
});


text:
Q: The propcedure entry point add_index_zval could not be located in the dynamic link library xampp/php/ext/php_imagic.dll I installed ImageMagick and The php_imagick.dll file is xampp>php>ext .
I  encounter this error after restarting Apache.

my OS : win10 64-bit , php version: 7.4.11
and php.ini :


text:
Q: Adding code coverage to async node.js mocha tests in WebStorm I am trying to set up code coverage for my node.js unit tests.
What I am trying to do is this:

*

*Use WebStorm for running tests

*use Mocha (and co-mocha) as a testing framework

*Use yield and generators for making my test code more readable

*See the code coverage of my source code via the WebStorm UI (hoping to see my source code files color-coded according to code coverage)

The first two points are going fine, the third one is tripping me up.

A: Unfortunately WebStorm doesn't provide coverage support for Mocha:( Please follow WEB-10373 for updates


text:
Q: How to display the users_ID on the screen with react native I made login with PHP and React Native but now I want to display the ID of the user that's logged in. The ID should be showed on the screen that appears when the user is logged in.
I tried several things but I think the way I request the props is wrong. Because the page where I want to show never requests the data that is started in the previous page.
This is the login screen:
import React from 'react';
import { StyleSheet, Text, View, TextInput, Button } from 'react-native';
import * as Expo from 'expo';

export default class App extends React.Component {
  state = {
    username: '',
    password: '',
    response: '',
    users_ID: '',
  };

  handleusers_usernameChange = (users_username) => {
    this.setState({ users_username });
  };

  handleusers_passwordChange = (users_password) => {
    this.setState({ users_password });
  };

  handleLoginPress = async () => {
    const { users_username, users_password } = this.state;

    try {
      let response = await fetch('http://IP/CodingApp/login.php', {

        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
        },
        body: JSON.stringify({
          users_username,
          users_password,
        }),
      });

      let responseJson = await response.json();
      console.log(responseJson);
      if (responseJson.loggedin) {
        this.props.setLoggedIn(true, responseJson.users_ID);
        this.setState({ users_ID: responseJson.users_ID });
      } else {
        this.setState({ response: 'tekst kwam niet overeen' });
      }
    } catch (error) {
      console.error(error);
    }
  };

  render() {
    return (
      <View style={styles.container}>
        <TextInput
          style={styles.input}
          value={this.state.users_username}
          onChangeText={this.handleusers_usernameChange}
          placeholder="users_username"
        />
        <TextInput
          style={styles.input}
          value={this.state.users_password}
          onChangeText={this.handleusers_passwordChange}
          placeholder="users_password"
          secureTextEntry
        />
        <Button title="Login" onPress={this.handleLoginPress} />
        <Text>{this.state.response}</Text>
      </View>
    );
  }
}

And this is the screen that appears after the user is logged in:
import React from 'react';
import { View, Text } from 'react-native';

const EditFamily = (props) => {
  return (
    <View>
      <Text>Your user ID is: {props.users_ID}</Text>
    </View>
  );
};

export default EditFamily;

A: Read about redux, which is a state management tool, you can save id whenever or wherever you go and use it everywhere.
https://redux.js.org/introduction/getting-started


text:
Q: How do I load a CSS style into WordPress admin area only? I'm trying to load a CSS file for my WordPress post area, but having no luck. I have read over the wp_enqueue_style function and came up with the code below, but it doesn't load up. Is there a tag or character missing from my code. I have a custom write panel when a user post that I want to style with the CSS file. Any help would be great.
Here is what I have in my themes functions.php file:
function mytheme_add_init() {
    $file_dir=get_bloginfo('template_directory');
    wp_enqueue_style("functions", $file_dir."/scripts/custom.css", false, "1.0", "all");
    wp_enqueue_script("rm_script", $file_dir."/scripts/custom.js", false, "1.0");
}

A: Just hook your callback into admin_print_styles, i.e.:
add_action( 'admin_print_styles', 'mytheme_add_init' );

Alternately, you could add an is_admin() conditional wrapper inside your callback, and hook into wp_enqueue_scripts:
function mytheme_add_init() {
    if ( is_admin() ) {
        $file_dir=get_bloginfo('template_directory');
        wp_enqueue_style("functions", $file_dir."/scripts/custom.css", false, "1.0", "all");
        wp_enqueue_script("rm_script", $file_dir."/scripts/custom.js", false, "1.0");
    }
}
add_action( 'wp_enqueue_scripts', 'mytheme_add_init' );

But the absolute best approach is to hook into your Theme's admin page, via admin_print_styles-appearance_page_{pagename}:
add_action( 'admin_print_styles-appearance_page_{pagename}', 'mytheme_add_init', 11 );

This is a custom hook specifically for your appearance page, as defined via your add_theme_page() call.

A: Late answer: As both previous answers showed old, incomplete or complicated ways, here's an updated version that works the v3.5+ way.
What's different?
Here's the list

*

*The first thing we do is using the admin_enqueue_scripts hook. This hook

*The wp_enqueue_style()s last argument is the targeted media and it's already set to all per default. No need to add it.

*We use the get_template_directory_uri() function to retrieve the URl for our stylesheet. No need to check the option value for template_directory here.

*We then use the return value of get_template_directory() to retrieve the path and wrap it into a filemtime() call to get the last time where the stylesheet was edited. This way we append a new version number as query argument and force browser to reload the stylesheet if there's a new version. No need to force hard reloads with Ctrl + F5.

*One important thing is to add the right dependencies as you don't want to have your styles overwritten with a higher specifity by wp-admin.css, ie (even worse) or the color scheme. The really tough part is to check the color scheme, as this file carries most of what is styled in the admin UI and is a user setting. We want to add this as dependency as well.

*The last thing we do is wrapping the call to add the hook into another function that is hooked to the contextual admin_head-* hook, where * is the pageslug. We hook it two times to take new as well as edited posts into consideration.

Here's the code for your functions.php file.
add_action( 'admin_head-post.php', 'wpse44135AttachAdminStyle' );
add_action( 'admin_head-post-new.php', 'wpse44135AttachAdminStyle' );
function wpse44135AttachAdminStyle()
{
    add_action( 'admin_enqueue_scripts', 'wpse44135EnqueueAdminStyle' );
}
function wpse44135EnqueueAdminStyle()
{
    $scheme = get_user_meta(
        get_current_user_id(),
        'admin_color',
        true
    );

    wp_enqueue_style(
        "admin_style",
        get_template_directory_uri()."/scripts/custom.css",
        array( 'wp-admin', 'ie', "colors-{$scheme}" ),
        filemtime( get_template_directory()."/scripts/custom.css" ),
        "all"
    );
}

Alternatives?
In case you just want to add styles to the TinyMCE WYSIWYG editor, you can use add_editor_style() to register your themes stylesheet in the admin areas text editor as well. The path you add as argument is relative to your themes root. In your functions.php file:
add_editor_style( '/scripts/custom.css' );

It's as simple as that.

A: Here is a quick way to add some style in admin head. hope this helps:
add_action('admin_head', 'my_custom_fonts');
function my_custom_fonts() {
  echo '<style>
    body, td, textarea, input, select {
    font-family: "Lucida Grande";
    font-size: 12px;
  }
</style>';
}


text:
Q: Why can't you assign a dictionary in a map operation in JS like this? Can someone explain to me my error in logic for why this doesn't work to assign a key value pair in javascript and initialize their values to 0? The values return as undefined.
What is the best way to do this instead?
Example:
const letters = ['i','c','l','e'];
let dict = {};

dict = letters.map(value => dict[value] = 0);

A: map() returns an array of the results of the callback. So you're replacing the object with that array.
Since you're modifying the object in the loop, you don't need to assign back to the variable. And since you don't need an array of the results, you should use forEach() rather than map()
letters.forEach(letter => dict[letter] = 0);

BTW, in JavaScript we call these objects, not dictionaries.


text:
Q: Package to find synonyms of english words for Dart do you know a package to find synonyms of english words for the Dart language?
For example something similar to NLTK for python it would be perfect.
hope someone can help me
Thank you :)

I write these words at random otherwise it won't make me postI write these words at random otherwise it won't make me postI write these words at random otherwise it won't make me postI write these words at random otherwise it won't make me post

A: After doing some research the following packages popped up:
Lemmatizer

Lemmatizer for text in English. Inspired by Python's nltk.corpus.reader.wordnet.morphy

Sadly it doesn't support null safety.
Stemmer.

This package implements a stemming algorithm in Dart. Currently, it supports PorterStemmer and SnowballStemmer. It is a port of the exceptional Python NLTK library.

oxford_dictionary - you would need api key, so based on that I think it is a paid service.

The Oxford Dictionaries API offers an easy way to access powerful lexical data (words, definitions, translations, audio pronunciations, synonyms, antonyms, parts of speech, and more) to use in your apps and websites.

And if you are not in a hurry: the Chaquopy Flutter plugin is planning to support NLTK library in the future. As it says in the description - it is only available in Android.

This is a chaquopy plugin to run python code on android. This is the simplest version, where you can write you code and run it.

I don't know if these packages will do the work, but they could be starting point.
Edit:
As @Dabbel mentioned in his comment:
Lemmatizerx

Lemmatizer for text in English. Inspired by Python's nltk.corpus.reader.wordnet.morphy.


text:
Q: Google App Engine and Identity-Aware Proxy - Enable MFA for SSH? Is there a way to enable multi-factor auth for SSH access to App Engine instances? Everything I've found points to "OS Login" for that, but it only seems to apply to Compute instances.
I understand I can enable MFA for the org and the gcloud CLI will force the MFA for the initial authentication, but I'd prefer an MFA check every time an SSH connection was initiated.

A: TL;DR: No, you can not enable SSH MFA to the App Engine flex environment.
As you may be aware now, you can SSH to an App Engine Flex environment only for debugging as described at Comparing high-level features.
You can enable debug mode for a VM, but as you can read at Debugging an Instance page:

Any changes you make to the VM while in debug mode are temporary; you
will lose your changes when you disable debug mode. VMs that are being
debugged restart periodically, which can make it difficult to debug
long running tasks.

The SSH access to a VM for App Engine is not intended to be done on a regular basis, it's only meant to be done when you really need to debug your application. Since this is only a temporary solution,  you can not enable MFA or make any changes to the VM. That VM is being managed by Google and any change you perform will not stick.
If you need regular SSH access to your application or MFA, consider switching to a non managed solution such as GCE. App Engine it's a managed solution (PaaS) so you lose control over certain aspects.