jQuery IE Error with wordpress: Line: 3 Error: Syntax error, unrecognized expression: nth-of-type

Question: I have built a child theme in wordpress. I'm using jQuery to hide and reveal sub menus. Everything works great in all the browsers except IE. In IE none of my jQuery works for the sub menus. When I try to debug I get this error.
Line: 3
Error: Syntax error, unrecognized expression: nth-of-type
That error appears in the build-in jQuery library that wordpress uses. I am using nth-of-type selectors in my own Jquery, but even when I remove them the problem still persists. This is the jQuery I am using to control the sub menus
if ($("body").hasClass('taxonomy-colordesign')){
$("#hybrid-categories-5 h4").toggleClass("tabDown");//pulls the background image in the tab
$("#hybrid-categories-5 h4").siblings('.dots').toggleClass('active');//activates the little square next to it
$("#hybrid-categories-5 h4").next("ul.xoxo.categories").toggleClass("openTab");//opens up the ul that contains the list of options
$(".menu-main-menu-container li:nth-of-type(3) a").addClass("current");
}

else if ($("body").hasClass('taxonomy-colorart')){
$("#hybrid-categories-12 h4").toggleClass("tabDown");
$("#hybrid-categories-12 h4").siblings('.dots').toggleClass('active');
$("#hybrid-categories-12 h4").next("ul.xoxo.categories").toggleClass("openTab");
$(" #hybrid-categories-9, #hybrid-categories-3, #hybrid-categories-5").hide();
$(".menu-main-menu-container li:nth-of-type(2) a").addClass("current");

}

else if ($("body").hasClass('taxonomy-mediadesign')){
$("#hybrid-categories-3 h4").toggleClass("tabDown");
$("#hybrid-categories-3 h4").siblings('.dots').toggleClass('active');
$("#hybrid-categories-3 h4").next("ul.xoxo.categories").toggleClass("openTab");
$(".menu-main-menu-container li:nth-of-type(3) a").addClass("current");

}

If anyone could help me I'd really appreciate it.
Answer: cos the nth-of-type is not a valid jquery selector..
Eg.
$(".menu-main-menu-container li:nth-of-type(2) a").addClass("current"); is invalid change it to
 $(".menu-main-menu-container li:eq(2) a").addClass("current");

You can refer http://api.jquery.com/nth-child-selector/ or http://api.jquery.com/eq/ for docs
Comment: from your page it looks like there is a syntax error, parenthesis missing
Comment: thanks for the help, but I tried this and it is still giving me the same error. here is a [link](http://www.ryanswansondesign.com/Portfolio/art-portfolio/)
Comment: i know its an old question and i came across by my own mistake in the code, but as of jQuery 1.9 this answer is not true any more. [the selector exists](https://api.jquery.com/nth-of-type-selector/)


Why is $\frac{1}{n}\sum_{i=1}^{n}(\langle\vec{x}_i,\vec{w}\rangle-y_i)^2 = \frac{1}{n}(X\vec{w}-\vec{y}_i)^T (X\vec{w}-\vec{y}_i)$?

Question: I am reading about Ridge Regression in Machine Learning (in particular, the calculation of the empirical risk w.r.t. the square loss function) and do not understand the following step:
$$\frac{1}{n}\sum_{i=1}^{n}(\langle\vec{x}_i,\vec{w}\rangle-y_i)^2 = \frac{1}{n}(X\vec{w}-\vec{y}_i)^T (X\vec{w}-\vec{y}_i)$$
I tried to calculate the left side and got
$$ \frac{1}{n}\sum_{i=1}^{n}(\langle\vec{x}_i,\vec{w}\rangle)^2-2(\langle\vec{x}_i,\vec{w}\rangle)\vec{y}_i+\vec{y}_i^2$$
But now I have no idea how to continue and I am not sure whether I am on the right track or not!
Comment: expand the RHS you'll get the LHS (the sizes of theses matrices/vectors are $w : k\times 1$, $y : n \times 1$, $X : k \times n$ and the $x_i$ are the rows of $X$)
Answer: There is no need to expand the LHS. Just note that
$$X\vec{w} = (\langle \vec{x}_1, \vec{w}\rangle, \ldots, (\langle \vec{x}_n, \vec{w}\rangle)^T\\
z^Tz = \langle z, z \rangle = \sum \limits_{i = 1}^n z_i z_i = \sum \limits_{i = 1}^n z_i^2$$
where $\vec{x}_i$ are the row vectors of $X$.


Can I return a game I activated through Steam and bought from GameFly, and get a refund if I have never downloaded it to my PC?

Question: I recently bought a game though GameFly, and I never actually downloaded the game. Now I would like to get a refund. May I return and get a refund, and if so then how do I go about getting my refund?
If not, what other alternatives are there? Such as Steam trading, etc. I just want my money back, or most of it.
Another possible alternative would be to exchange it for a different game. Can I do this? Thank you.
Comment: I'm voting to close your question. This question is about a business, not games.
Comment: [We've opened a meta](http://meta.gaming.stackexchange.com/questions/4037/are-questions-about-game-companies-policies-on-topic) discussion on this and similiar questions.
Answer: GameFly seems to pass the buck and their FAQ says:

Your game activation is supported by your Game Publisher.  GameFly Customer Support does not have access to assist you with this activation.

However, if it's a Steam game, and you activated the game on your Steam account, there's no going back - it's permanently yours.  You can't trade the game if you've activated it to your account.  Trading only works with gifts that you've not activated on your account already.
I think the exception to this rule is in European countries, there might be a short-term "out" due to the laws being different there.  I don't live in Europe so I can't really comment on how this would change the situation.  I also don't know how the GameFly involvement would complicate things, but I'd suggest contacting Steam Support if you're a European gamer.
Comment: Even with the EU regulations, you still can't get a refund on Steam games (other than pre-orders) from EU countries.
Comment: Not the answer I was looking for, but a good answer nonetheless. Thank you!


gparted disk partition wont resize

Question: hey im really new to ubuntu but over the past few weeks I have brought some old machines back from the dead by running ubuntu rather than windows and im loving it, even convinced my dad to get rid of winidows 10.
So I decided to dual boot my main pc running windows 7 and focal fossa yesterday. left all the partitioning up to ubuntu installer and im already out of space, it gave me 9gb. now im having difficulty booting ubuntu and getting loads of warnings about low disk space.
been in to windows disk manager and unallocated some space, made a bootable gparted usb which i cant get to run keep getting a message saying no bootable partition in table, then remembered i have a bootable usb that i installed ubuntu with(literally hours earlier).
so im on my live usb in gparted, and i cant resize the ubuntu partition, made a bit more unalocated space in gparted but still cant make my ubuntu partition any bigger.

what am i doing wrong? would i be better just reinstalling ubuntu (im 6 hours in and 5 of them have been spent trying to resize a partition)
thanks
Comment: You can't resize because ther is no unallocated space near the partition. If you move `/dev/sda3` to the left, it should be fixed.
Comment: @Pilot6 That won't work.
Answer: Move /dev/sda3 to the left, then you'll be able to resize /dev/sda4.
Comment: That won't work.
Comment: @heynnema Why won't it work?
Comment: OP wants to add to their /dev/sda5. How does this answer accomplish that?
Comment: @heynnema The question was how to resize sda4. sda5 is inside.
Comment: You're answer is incomplete/wrong, Reread the question. re: *"cant make my ubuntu partition any bigger"*. Resizing /dev/sda4 won't accomplish this by itself. Their *"ubuntu partition"* is /dev/sda5, and your answer doesn't even mention /dev/sda5. See my answer.
Answer: Make sure that you have a good backup of your important Ubuntu files, as this procedure can corrupt or lose data.
Keep these things in mind:

always start the entire procedure with issuing a swapoff on any mounted swap partitions, and end the entire procedure with issuing a swapon on that same swap partition
a move is done by pointing the mouse pointer at the center of a partition and dragging it left/right with the hand cursor
a resize is done by dragging the left/right side of a partition to the left/right with the directional arrow cursor
if any partition can't be moved/resized graphically, you may have to manually enter the specific required numeric data (don't do this unless I instruct you to)
you begin any move/resize by right-clicking on the partition in the lower pane of the main window, and selecting the desired action from the popup menu, then finishing that action in the new move/resize window

Do the following...
Note: if the procedure doesn't work exactly as I outline, STOP immediately and DO NOT continue.
Note: This particular re-partition is slightly complicated because of the extended partition.
Note: If this is a newer UEFI computer, this disk should really be in GPT partition format, not MBR format.

boot to a Ubuntu Live DVD/USB, in "Try Ubuntu" mode
start gparted
move /dev/sda3 partition all the way left

reboot now to test if moving this partition caused a problem booting Windows or Ubuntu
if it boots ok, then return here and continue

resize the left side of /dev/sda4 extended partition all the way left

this might be tricky as it's an extended partition
if you can't do this, stop, and contact me for an alternate procedure

move /dev/sda5 partition all the way left
resize the right side of /dev/sda5 all the way right
click the Apply icon

gparted disk partition wont resize


How long will an item stay unclaimed in Treasure Hunter?

Question: Yesterday, I used one of my Treasure Hunter keys and was awarded a Lucky Armadyl Chestplate. However, since there is a TH promotion going on that rewards "oddments" as well, all items will be converted to oddments instead of coins if you choose that option. I have no need for the chestplate and would like to convert it to coins, but since the promotion is going on, I can't convert it to coins until the promotion is over, (I believe its over on August 7th).
My question is: How long can I leave the chestplate unclaimed before it will disappear? Will it stay in there indefinitely until I decide to do something with it? Or will it go away when Treasure Hunter resets at reset time?
Comment: I want to say the answer is indefinite unless they change treasure hunter to something else.  According to the Wiki page, when they transferred from the Squeal of Fortune to Treasure Hunter, and unclaimed items were converted into keys.  So unless this happens, I would think your chestplate would still be there.
Comment: Just a quick thing as well - If you win an item as part of a promotion but you don't claim it, the item can still be claimed even after the promotion (Happened to me with a [Pumpkin amulet](http://runescape.wikia.com/wiki/Pumpkin_amulet))
Comment: Yeah, that makes sense. Would be really dumb of Jagex to make people lose unclaimed items, especially ones of such a high convert value.
Answer: So I waited until reset happened tonight and then checked Treasure Hunter to see if the chestplate was still there... and it was! So it looks like items will stay unclaimed until you claim them regardless of game reset. However, this does make Treasure Hunter unplayable until claimed.


SQL Server Extreme slowness after reboot or fail-over of cluster

Question: I have a SQL Server 2008 R2 SP1 cluster with 2008 OS.  Any time a reboot happens or a failover happens the next several days any processing is extremely slow; however if we leave them running they run much better.  I have been researching the possibility when the procedure cache is flushed then with all the plans needing to be rebuilt this is causing the slowness instead of being able to go to memory for the existing plan.  Has anyone else experience this and what did you do to resolve so a reboot would not affect the system so negatively?
Answer: One thing you can do is monitor your most resource intensive queries after the procedure cache is flushed.  Once you ID what queries are taking a long time reading from disk to get put back into the buffer pool, you can schedule a job to spin up those queries immediately after the reboot so when the first user goes to execute it, it is already in the buffer pool and will read from memory instead of disk.  Here is a query to find I/O intensive queries after your reboot:
<code>SELECT TOP 25 cp.usecounts AS [execution_count]
      ,qs.total_worker_time AS CPU
      ,qs.total_elapsed_time AS ELAPSED_TIME
      ,qs.total_logical_reads AS LOGICAL_READS
      ,qs.total_logical_writes AS LOGICAL_WRITES
      ,qs.total_physical_reads AS PHYSICAL_READS
      ,SUBSTRING(text,
                   CASE WHEN statement_start_offset = 0
                          OR statement_start_offset IS NULL
                           THEN 1
                           ELSE statement_start_offset/2 + 1 END,
                   CASE WHEN statement_end_offset = 0
                          OR statement_end_offset = -1
                          OR statement_end_offset IS NULL
                           THEN LEN(text)
                           ELSE statement_end_offset/2 END -
                     CASE WHEN statement_start_offset = 0
                            OR statement_start_offset IS NULL
                             THEN 1
                             ELSE statement_start_offset/2  END + 1
                  )  AS [Statement]
FROM sys.dm_exec_query_stats qs
   join sys.dm_exec_cached_plans cp on qs.plan_handle = cp.plan_handle
   CROSS APPLY sys.dm_exec_sql_text(cp.plan_handle) st
ORDER BY qs.total_physical_reads DESC;
</code>
Answer: Rebuilding plan most probably would not be the problem. I see simmilar behaviour on our system, problem is HDD array. I tested if we could move to SSD it would speed up cold start queries more than 10x.


remove and append works but not replace html

Question: I'm creating an array of rows , and want to use later
if i append them back it works , but i want to replace html and it doesn't , curious why. In addition , if i only want to attach 50 rows back , how would i do that ?
works
var removedRows = [];

$('#statsBody tr[role="row"]').each(function (i) {
    removedRows.push($(this));
});

$.each(removedRows, function(i, v) {
    $('#statsBody').append(v);
});

doesn't work , only returns a single row
var removedRows = [];

$('#statsBody tr[role="row"]').each(function (i) {
    removedRows.push($(this));
});

$.each(removedRows, function(i, v) {
    $('#statsBody').html(v);
});

If i clear the html and then append it works fine , but why would using html vs append here not work
$('#statsBody').html('');

$.each(removedRows, function(i, v) {
    $('#statsBody').append(v);
});

Comment: This depends entirely on what you mean by it 'doesn't work' as that's not nearly clear enough. That being said, the difference between `append()` and `html()` is that the latter completely removes the original content before updating it with the value provided.
Comment: doesnt work , as i said , when i use html , it only shows 1 table row , the very last one in the array
Comment: [`.append()`](https://api.jquery.com/append/) doesn't mean "create new content" - if the content already exists, then append = move.   If you want additional copies, then use `.clone()` or an html string.
Comment: dont want new copies , i just want to replace existing html
Answer: .html() always replaces the entire content.
It's the same as $(".destination").empty().append(new_element)
While .append() adds content, it doesn't replace existing content.

Every time you call .html() it clears first.
So given this code:

$(".out").html($(".source")[0]);
$(".out").html($(".source")[1]);
$(".out").html($(".source")[2]);

1

2

3

only the last entry $(".source")[2] will exist as the last one overwrites the previous two.
This is what is happening in your loop/$.each - each loop empties the destination from the previous loop's .html leaving just the last one.

To append only 50 you could add as basic counter:
let i = 0;
$('#statsBody').html('');

$.each(removedRows, function(i, v) {
    i++;
    if (i<50)
        $('#statsBody').append(v);
});

or you could use a basic for loop:
for (let i=0; i<50; ++i) {
    $("#statsBody").append(removedRows[i])
}

or you could count how many are there before appending (if not appending in one go) (not recommended as counting them each loop would be very inefficient).
if you don't want more than 50 (ie lose 51+) then you can use splice()
removedRows.splice(0, 49);

using .length = on an array is similar to .splice:

var x = [1, 2, 3];
x.length = 2;
console.log(x);

if you want to keep them, but only add 50 at a time (ie add another 50 later) then you can use .slice()

var rows = $(".source");
$(".body").empty();
var page = 0;
setTimeout(() => {
  $(".body").append(rows.slice(page, 2));
  page += 2;
}, 500);
setTimeout(() => {
  $(".body").append(rows.slice(page));
}, 1000);

1

2

3

Comment: excellent explanation and write up . Thanks !
Answer: v is contain the object data. .html() is expecting html string.
Update Code:
var removedRows = [];

$('#statsBody tr[role="row"]').each(function (i) {
    removedRows.push($(this));
});

$.each(removedRows, function(i, v) {
    $('#statsBody').html(v.outerHTML());
});

Comment: The `v` argument is a reference to an Element object and has no `html()` method. *Edit* - your update is also wrong as `outerHTML` is a property not a method.


Retrieve html from element into a variable

Question: I want to retrieve the html within an element and save it into a variable that I'll use for post.
Here's an example of the html:

blablabla

This is the jquery I used:
$(document).ready(function(){

    $("#save").click(function(){

      $('#editable2').prop('outerHTML');
      alert( $(this).data("outerHTML") );

    });

});

However the popup box keeps on saying undefined.
Thanks!
Comment: You are never adding the key `outerHTML` to the data store anywhere. You might want to read up on what `.data` does: http://api.jquery.com/data/. Maybe you intended to write `alert($('#editable2').prop('outerHTML'))`?
Comment: I would use Firebug or Chrome dev tools to debug the jQuery.  Test to see what your variables contain.  Put a break point on your alert and then, for instance, see what $(this) is returning.
Answer: If you are trying to assign the content of a  to a variable you could do something like the following.
HTML

content

click

JS
$(document).ready(function(){

  $("#save").click(function(){
    var popup = $('#editable2').prop("outerHTML");
    alert( popup );
  });

});

Here's a working example: http://www.codepen.io/anon/pen/jiDmx
If you're trying to get just the contents of the #editable2 div (which is my guess), then just do:
var popup = $('#editable2').html();

Answer: Use alert( $('#editable2').html());
Comment: Thanks, but then there is no variable to use for post, is there? How would that work?
Comment: Well I wanted to use ajax to save the variable into a mysql table.


Is it possible to multiply values in JSON?

Question: Is it valid in JSON to set value of key as the result of multiplaying/adding two variables/values/string+number/string+string/etc.?Is it possible?
F.e
{
  "string": "600*"+40
}

Comment: @ochi not if it is really JSON
Comment: you could provide a function, I believe.  like `{"string": function(){return 600*40} }`
Comment: What is the real problem you are trying to solve? [XY-problem](http://xyproblem.info/)
Comment: @charlietfl you are correct! Strictly speaking, JSON does not allow it
Answer: JSON isn't code. It's not JavaScript. It's just a format for writing data. It can't do anything dynamically.
If you wanted to do something like that, you'd have to do it with whatever is creating the JSON.
With JavaScript, you can do something like this:
const jsonStr = '{ "value": 600 }'; // load your JSON from somewhere
const data = JSON.parse(jsonStr); // parse JSON
data.value *= 40; // do stuff
console.log(JSON.stringify(data)); // turn back into JSON.

Note, if it was something like { "value": "600" } where the value is a string, not a number (note the quotation marks ("")), you'd have to remember to parseInt first: data.value = parseInt(data.value) * 40
Answer: In short, no. You can't multiply Strings and JSON means that it's a string representation of a Javascript Object.
Answer: I think you can save it this way
{
    "string": "600+40"
}

or
{
    "string": "600*40"
}

but it will only be string. If you want to do math on it you have to convert it.


How to display a variable in my info window on Google Maps

Question: I want to display my "double CO2Data" in my textView in my info window. I am not sure where and how I write that code. Does anyone have any tips or ideas on how to do that?
My MapsActivity:
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback,
    GoogleApiClient.ConnectionCallbacks,
    GoogleApiClient.OnConnectionFailedListener,
    LocationListener {

private GoogleMap mMap;
GoogleApiClient mGoogleApiClient;
Location mLastLocation;
Marker mCurrLocationMarker;
LocationRequest mLocationRequest;
private boolean initiateApp;
double CO2data = 1.02;
double N2data = 0.002;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        checkLocationPermission();
    }
    // Obtain the SupportMapFragment and get notified when the map is ready to be used.
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
    initiateApp = true;

}

/**
 * Manipulates the map once available.
 * This callback is triggered when the map is ready to be used.
 * This is where we can add markers or lines, add listeners or move the camera. In this case,
 * we just add a marker near Sydney, Australia.
 * If Google Play services is not installed on the device, the user will be prompted to install
 * it inside the SupportMapFragment. This method will only be triggered once the user has
 * installed Google Play services and returned to the app.
 */
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);

    //Initialize Google Play Services
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (ContextCompat.checkSelfPermission(this,
                Manifest.permission.ACCESS_FINE_LOCATION)
                == PackageManager.PERMISSION_GRANTED) {
            buildGoogleApiClient();
            mMap.setMyLocationEnabled(true);
        }
    }
    else {
        buildGoogleApiClient();
        mMap.setMyLocationEnabled(true);
    }
}

/* Here we create the infoWindow **/
protected synchronized void buildGoogleApiClient() {
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(LocationServices.API)
            .build();
    mGoogleApiClient.connect();

    mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {

        public View getInfoWindow(Marker arg0) {
            View v = getLayoutInflater().inflate(R.layout.custom_infowindow, null);

            return v;
        }

        public View getInfoContents(Marker arg0) {

            //View v = getLayoutInflater().inflate(R.layout.custom_infowindow, null);

            return null;

        }
    });

}

@Override
public void onConnected(Bundle bundle) {

    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(0);
    mLocationRequest.setFastestInterval(0);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.ACCESS_FINE_LOCATION)
            == PackageManager.PERMISSION_GRANTED) {
        LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
    }

}

@Override
public void onConnectionSuspended(int i) {

}

@Override
public void onLocationChanged(Location location) {

    mLastLocation = location;
    if (mCurrLocationMarker != null) {
        mCurrLocationMarker.remove();
    }

    //Place current location marker
    LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.position(latLng);
    markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA));
    mCurrLocationMarker = mMap.addMarker(markerOptions);
    mCurrLocationMarker.showInfoWindow();

    Log.d("ADebugTag", "Value: " + Double.toString(location.getLatitude()));
    Log.d("ADebugTag", "Value: " + Double.toString(location.getLongitude()));

    //move map camera

    if(initiateApp){
        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15));
    }
    initiateApp = false;

    boolean contains = mMap.getProjection()
            .getVisibleRegion()
            .latLngBounds
            .contains(latLng);

    if(!contains){
        mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
    }

}

@Override
public void onConnectionFailed(ConnectionResult connectionResult) {

}

public static final int MY_PERMISSIONS_REQUEST_LOCATION = 99;
public boolean checkLocationPermission(){
    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.ACCESS_FINE_LOCATION)
            != PackageManager.PERMISSION_GRANTED) {

        // Asking user if explanation is needed
        if (ActivityCompat.shouldShowRequestPermissionRationale(this,
                Manifest.permission.ACCESS_FINE_LOCATION)) {

            // Show an explanation to the user *asynchronously* -- don't block
            // this thread waiting for the user's response! After the user
            // sees the explanation, try again to request the permission.

            //Prompt the user once explanation has been shown
            ActivityCompat.requestPermissions(this,
                    new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
                    MY_PERMISSIONS_REQUEST_LOCATION);

        } else {
            // No explanation needed, we can request the permission.
            ActivityCompat.requestPermissions(this,
                    new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
                    MY_PERMISSIONS_REQUEST_LOCATION);
        }
        return false;
    } else {
        return true;
    }
}

@Override
public void onRequestPermissionsResult(int requestCode,
                                       String permissions[], int[] grantResults) {
    switch (requestCode) {
        case MY_PERMISSIONS_REQUEST_LOCATION: {
            // If request is cancelled, the result arrays are empty.
            if (grantResults.length > 0
                    && grantResults[0] == PackageManager.PERMISSION_GRANTED) {

                // permission was granted. Do the
                // contacts-related task you need to do.
                if (ContextCompat.checkSelfPermission(this,
                        Manifest.permission.ACCESS_FINE_LOCATION)
                        == PackageManager.PERMISSION_GRANTED) {

                    if (mGoogleApiClient == null) {
                        buildGoogleApiClient();
                    }
                    mMap.setMyLocationEnabled(true);
                }

            } else {

                // Permission denied, Disable the functionality that depends on this permission.
                Toast.makeText(this, "permission denied", Toast.LENGTH_LONG).show();
            }
            return;
        }

        // other 'case' lines to check for other permissions this app might request.
        // You can add here other case statements according to your requirement.
    }
}
}

My custom infowindow xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="110dp"
android:layout_height="110dp"
android:orientation="vertical"
android:gravity="center"
>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/infoText"
        android:textColor="#000000"
        android:padding="10dp"
        android:layout_centerInParent="true"
        android:background="#ffffff"
        />

</RelativeLayout>

</LinearLayout>

The code that I used to for the info window
mMap.setInfoWindowAdapter(new InfoWindowAdapter() {

public View getInfoWindow(Marker arg0) {
    View v = getLayoutInflater().inflate(R.layout.custom_infowindow, null);
    return v;
}

public View getInfoContents(Marker arg0) {

    //View v = getLayoutInflater().inflate(R.layout.custom_infowindow, null);

    return null;

}
});

Comment: What's your exact problem? Are you facing problem in setting info window text or problem in setting a double value in textview?
Comment: @Kunu I have problem in setting a double value in changing the textView in my MapsActivity. I tried adding
private TextView text = (TextView)findViewById(R.id.infoText);
and then in my OnCreate method:
text.setText("Value" + CO2Data); But this crashes the app
Comment: Could you post the whole code? I can't see any info window in above question.
Comment: I just copy pasted the code that is under "Here we create the infoWindow" in MapsActivity.
Comment: @Kunu I just took the code from the answer here: http://stackoverflow.com/questions/16711522/how-to-change-the-custom-infowidnow-shape-of-the-google-maps-api-v2/16712599#16712599
Comment: Could you please add those code here in your question?
Comment: @Kunu now I added it :). I want to update the textView in the custom_infowindow with a double value.
Comment: check my answer.
Answer: Change your info window content code, right now you are returning null I guess
public View getInfoContents(Marker arg0) {

    View v = getLayoutInflater().inflate(R.layout.custom_infowindow, null);
    TextView tv = (TextView) v.findViewById(R.id.infoText);
    tv.setText(String.valueOf(CO2data));

    return v;

}

Comment: Now the app does not crash, but it does not display the value in the textView.
Comment: Now I got it to work! I should have put your code in the "setInfoWindowAdapter" method. Thank you very much for the help!
Comment: Happy to help you. Yeah as it is override method of the `InfoWindowAdapter` interface it must be inside that.


SparkR: Assign values of a column with condition

Question: I want to replace values of a column with a certain condition.
Example of R data frame:
df <- data.frame(id=c(1:7),value=c("a", "b", "c", "d", "e", "c", "c"))

I want to replace values "c" and "d", in column value by "e".
In R, it can be done this way
df[df$value %in% c("c","d"),]$value <- "e"

I tried to do the same thing in sparkR. Tried ifelse, when functions but couldn't give me the desired result.
Does anyway run into the same issue?
Comment: `df$value <- ifelse(df$value %in% c("c","d"), "e", df$value)` should equally work on `Spark DataFrame`'s.
Comment: It doesn't work. I got an error `Error in rep(yes, length.out = length(ans)) :
  attempt to replicate an object of type 'environment'`
Comment: What spark version are u running?
Comment: I am running spark 1.6
Comment: I think this was a known bug, fixed in 1.6.1
Answer: The first comment of mtoto works well (with spark 3.0.1) and should be transformed in answer and accepted.
df$value <- ifelse(df$value %in% c("c","d"), "e", df$value)

Another valid slightly different method to replace strings in a column could be the following:
df$value <- regexp_replace(df$value, "c", "e")


How to map properties of an object to another?

Question: I know there are many questions on this matter, but I can't figure out how to apply it in my case.
Code is as following:
const mailDocumentSchema = new schema.Entity('mailDocuments', {}, { idAttribute: 'identifier' });
const mailSchema = new schema.Entity('mails', { emailDocument: [mailDocumentSchema] }, { idAttribute: 'identifier' });
const mailAccountSchema = new schema.Entity('mailAccounts', { mails: [mailSchema] }, { idAttribute: 'address' });

const mailMapper = (item: any): Mail => ({
  id: item.identifier,
  title: item.subject,
  documents: item.emailDocument,
  subject: item.realSubject,
  receiver: item.receiver,
  createdDate: item.createdDate,
  sendDate: item.sendDate,
  body: item.body
});

const mailDocumentMapper = (item: any): MailDocument => ({
  id: item.identifier,
  docId: item.oldDocId,
  name: item.name,
  createdDate: item.createdDate,
  bodyStatus: item.bodyStatus
});

export const undefinedDocumentsMapper = (response: any[]): NormalizedMailbox => {
  const undefinedDocuments = map(groupBy(response, item => item.receiver), (item, key) => ({ name: null, address: key, mails: item }));
  const normalizedResponse = normalize(undefinedDocuments, [mailAccountSchema]);
  return {
    mailAccounts: Object.values<MailAccount>(normalizedResponse.entities.mailAccounts),
    mails: Object.values<any>(normalizedResponse.entities.mails).map(mailMapper),
    mailDocuments: Object.values<any>(normalizedResponse.entities.mailDocuments).map(mailDocumentMapper)
  };
};

API response is:
[
   { identifier: "...", title: "...", receiver: "...", emailDocuments: [{...}] },
   ...
]

What I want is to map the receiver and title properties from mails entity objects to mailDocuments entity objects.
As a result to get mailDocuments entity objects as such:
{
  id: "...",
  docId: "...",
  name: "...",
  createdDate: "...",
  bodyStatus: ...,
  title: "...",
  receiver: "..."
}

How to accomplish this?
Answer: If I understand correctly, you can do the following:
mails.forEach(mail => {
  mail.documents.forEach(document => {
    document.receiver = email.receiver
    document.title = email.title
  })
})


Get the size of a conditional subset of a list

Question: Assume that you have a list with an arbitrary amounts of items, and you wish to get the number of items that match a specific conditions. I though of two ways to do this in a sensible manner but I am not sure which one is best (more pythonic) - or if there is perhaps a better option (without sacrificing too much readability).
import numpy.random as nprnd
import timeit

my = nprnd.randint(1000, size=1000000)

def with_len(my_list):
    much = len([t for t in my_list if t >= 500])

def with_sum(my_list):
    many = sum(1 for t in my_list if t >= 500)

t1 = timeit.Timer('with_len(my)', 'from __main__ import with_len, my')
t2 = timeit.Timer('with_sum(my)', 'from __main__ import with_sum, my')

print("with len:",t1.timeit(1000)/1000)
print("with sum:",t2.timeit(1000)/1000)

Performance is almost identical between these two cases. However, which of these is more pythonic? Or is there a better alternative?

For those who are curious, I tested the proposed solutions (from comments and answers) and these are the results:
import numpy as np
import timeit
import functools

my = np.random.randint(1000, size=100000)

def with_len(my_list):
    return len([t for t in my_list if t >= 500])

def with_sum(my_list):
    return sum(1 for t in my_list if t >= 500)

def with_sum_alt(my_list):
    return sum(t >= 500 for t in my_list)

def with_lambda(my_list):
    return functools.reduce(lambda a, b: a + (1 if b >= 500 else 0), my_list, 0)

def with_np(my_list):
    return len(np.where(my_list>=500)[0])

t1 = timeit.Timer('with_len(my)', 'from __main__ import with_len, my')
t2 = timeit.Timer('with_sum(my)', 'from __main__ import with_sum, my')
t3 = timeit.Timer('with_sum_alt(my)', 'from __main__ import with_sum_alt, my')
t4 = timeit.Timer('with_lambda(my)', 'from __main__ import with_lambda, my')
t5 = timeit.Timer('with_np(my)', 'from __main__ import with_np, my')

print("with len:", t1.timeit(1000)/1000)
print("with sum:", t2.timeit(1000)/1000)
print("with sum_alt:", t3.timeit(1000)/1000)
print("with lambda:", t4.timeit(1000)/1000)
print("with np:", t5.timeit(1000)/1000)

Python 2.7
('with len:', 0.02201753337348283)
('with sum:', 0.022727363518455238)
('with sum_alt:', 0.2370256687439941) # <-- very slow!
('with lambda:', 0.026367264818657078)
('with np:', 0.0005811764306089913) # <-- very fast!

Python 3.6
with len: 0.017649643657480736
with sum: 0.0182978007766851
with sum_alt: 0.19659815740239048
with lambda: 0.02691670741400111
with np: 0.000534095418615152

Comment: Consider alternatively `sum(t>=500 for t in my_list)`
Comment: @khelwood I guess that'd work as well, but I'm not sure if that'd make a difference with `with_sum`.
Comment: If you feel functional today: `reduce(lambda a, b: a + (1 if b >= 500 else 0), my_list, 0)`
Comment: @khelwood Interestingly enough, your suggestion is ten times slower than the original suggestion.
Comment: @BramVanroy That _is_ interesting.
Comment: @BramVanroy Also interesting is that the performance difference between approaches is noticeably different in Python 2.7 -- the (non-numpy) results are all closer together.
Answer: The 2nd one, with_sum is more pythonic in the sense that it uses much less memory as it doesn't build the whole list because the generator expression is fed to sum().
Comment: Though the first one can do the very same thing by simply removing the `[` `]`.
Comment: @AdamBarnes No, you can't use `len()` on a generator, try it
Answer: I'm with @Chris_Rands. But as far as performance is concerned, there is a faster way using numpy:
import numpy as np

def with_np(my_list):
    return len(np.where(my_list>=500)[0])

Comment: @BramVanroy yes. Though numpy arrays, or, ndarrays to be more specific, are similar in terms of structure to native lists, they are very different under the hood. By design they are meant to deal with multi-dimensional matrices and linear algebra by combining the simplicity and idiomatic nature of python and low-level language performance, allowing easy vectorization and complex operations at low cost. Essentially ndarrays are stride views on memory.
Comment: Wow, this is incredibly fast. Any clue as to why this is so fast? (~50 times faster than my original approach)


Touchpad issues Ubuntu 14.04

Question: After switching from Windows 8.1 to Ubuntu (as a dual boot) ,I found that the touchpad doesn't work on my Ubuntu, but does on Windows.
Please if someone could have a solution for this?
Comment: Please [edit] your question and add output of `xinput` terminal command.
Answer: Did you install xserver-xorg-input-synaptics
?
<code>sudo apt-get install xserver-xorg-input-synaptics
</code>
Comment: This package is installed by default.

Touchpad issues Ubuntu 14.04


Incrementing a variable when the user gets the correct answer

Question: I am facing a problem / serious bug, which I can't seem to resolve on my own, though I am still building the app, I want the app to increment the variable storesTotalCorrectAnswer whenever the user checked the radio button (that contains the correct answer) but I thought it was working until I starting noticing that the scores were not accurate, so I added a toast message and the toast message isn't displaying on the app, so I knew that the storesTotalCorrectAnswer variable isn't working as intended.
Please - how do I solve this bug?
What I want to achieve is to increment the storesTotalCorrectAnswer when the user check the radio button that contains the correct answer.
I have tried various ways including using an if statement on almost everywhere in the code but now seems to be working
 com.myafrica.africaquiz;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

import java.util.Random;

public class MainActivity extends AppCompatActivity {

//this variable stores the total number of correct answers
int storesTotalCorrectAnswer = 0;

//this variable counts the total number of randomQuestions asked
int randomNumberCounter = 0;

//this variable stores the random numbers generated
int randomNumber = 0;

//this variables stores the views for public access to other methods
TextView testQuestionID;

RadioButton answerA_ID;
RadioButton answerB_ID;
RadioButton answerC_ID;
RadioButton answerD_ID;

RadioGroup radioGroup_ID;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    //get the text view and stores it in this variable
    testQuestionID = findViewById(R.id.testQuestion);

    //get the radio button view and stores it in this variable
    answerA_ID = findViewById(R.id.answerA);
    answerB_ID = findViewById(R.id.answerB);
    answerC_ID = findViewById(R.id.answerC);
    answerD_ID = findViewById(R.id.answerD);

    //get the radio group ID and stores it for future reference
    radioGroup_ID = findViewById(R.id.radioGroup_ID);

   }

//When the onclicked() is clicked this method runs
public void GetNextQuestion(View view) {

    randomNumberGenerator();

    //just to know when the onClicks runs
    Toast.makeText(MainActivity.this, "NEXT  is clicked", Toast.LENGTH_LONG).show();

}

//the random number generator method
public void randomNumberGenerator() {

    //the random number generator
    Random ranNum = new Random();
    randomNumber = ranNum.nextInt(4) + 1;

    //to stop the questions from displaying once the required number is reached
    if (randomNumberCounter < 4) {

        //to know how many times the random method has been called
        while (randomNumber > 0) {
            randomNumberCounter++;

            switch (randomNumber) {

                /* When the randomNumber is generated (number from 1 to 4)
                 * it matches the case and displays the required question */

                case 1:
                    question1();
                    break;

                case 2:
                    question2();
                    break;

                case 3:
                    question3();
                    break;

                case 4:
                    question4();
                    break;
            }

            break;

        }
    }

    // shows a next layout after the question stops showing
    else {
        Intent secondActivity = new Intent(this, Main2Activity.class);
        secondActivity.putExtra("secondActivity", "" + storesTotalCorrectAnswer);
        startActivity(secondActivity);
    }
}

/*
 * This part of the code will contain the questions and answer part of the quiz app.
 * Each question and answer is a method that will called when the Next button is clicked in the app.
 * When the button is clicked the setText() will automatically (re)set the text in the text layout in the XML
 */

public void question1() {
    testQuestionID.setText("Which part of Africa can Ghana be located");
    answerA_ID.setText(" A: West Africa");
    answerB_ID.setText(" B: East Africa");
    answerC_ID.setText(" C: Central Africa");
    answerD_ID.setText(" D: North Africa");

    //wanted to increment the storesTotalCorrectAnswer when the correct radio button is clicked and displayed a toast message

    if (answerA_ID.isChecked()) {
        storesTotalCorrectAnswer++;
        Toast.makeText(MainActivity.this, "Question 1 Answer is clicked", Toast.LENGTH_LONG).show();
    }

    radioGroup_ID.clearCheck();

}

public void question2() {
    testQuestionID.setText("What is the capital of Nigeria");
    answerA_ID.setText(" A: Abuja");
    answerB_ID.setText(" B: Kano");
    answerC_ID.setText(" C: Lagos");
    answerD_ID.setText(" D: Port Harourt");

    //wanted to increment the storesTotalCorrectAnswer when the correct radio button is clicked and displayed a toast message

    if (answerA_ID.isChecked()) {
        storesTotalCorrectAnswer++;
        Toast.makeText(MainActivity.this, "Question 2 Answer is clicked", Toast.LENGTH_LONG).show();
    }

    radioGroup_ID.clearCheck();
}

public void question3() {
    Toast.makeText(MainActivity.this, "Question 2 Answer is clicked", Toast.LENGTH_LONG).show();
    testQuestionID.setText("Which of these countries are not located in Africa");
    answerA_ID.setText(" A: Niger");
    answerB_ID.setText(" B: Nigeria");
    answerC_ID.setText(" C: Rwanda");
    answerD_ID.setText(" D: Non of the Above");

    //wanted to increment the storesTotalCorrectAnswer when the correct radio button is clicked and displayed a toast message

    if (answerD_ID.isChecked()) {
        storesTotalCorrectAnswer++;
        Toast.makeText(MainActivity.this, "Question 3  Answer is clicked", Toast.LENGTH_LONG).show();
    }

    radioGroup_ID.clearCheck();
}

public void question4() {
    Toast.makeText(MainActivity.this, "Question 2 Answer is clicked", Toast.LENGTH_LONG).show();
    testQuestionID.setText("What is the estimated population of Africa, as at 2015");
    answerA_ID.setText(" A: 1.2 Billion");
    answerB_ID.setText(" B: 500 Billion");
    answerC_ID.setText(" C: 2 Billion");
    answerD_ID.setText(" D: 360 million");

    //wanted to increment the storesTotalCorrectAnswer when the correct radio button is clicked and displayed a toast message

    if (answerA_ID.isChecked()) {
        storesTotalCorrectAnswer++;
        Toast.makeText(MainActivity.this, "Question 4  is clicked", Toast.LENGTH_LONG).show();
    }

    radioGroup_ID.clearCheck();
}

/* END OF CODE */
}

Comment: storesTotalCorrectAnswer should not affect whether a Toast will appear or not. If you can't get a Toast to appear, it would be for some other reason.
Comment: I decided to include the Toast when I noticed that the output wasn't displaying  Intended, so if the code was running fine the Toast would have displayed.
Comment: You need to debug your code, and SO is a terrible debugger! https://ericlippert.com/2014/03/05/how-to-debug-small-programs/
Comment: @jdv thanks i will read that up.
Answer: Firstly try to display your value using Logcat or
if (answerA_ID.isChecked()) {
        System.out.println("Right Answer");
    }
If it's showing the answer then use this (++storesTotalCorrectAnswer) Instead of  this (storesTotalCorrectAnswer++)
Comment: i believe that `if (answerA_ID.isChecked())` always returns true even if the radio button is checked or not.
Comment: hope you have use this (++storesTotalCorrectAnswer) Instead of this (storesTotalCorrectAnswer++)??
Comment: Yes I did use `++storesTotalCorrectAnswer`.
Answer: I tried this and it is working fine, the only problem is on your if-statements. You said you want it 1 to 4, but the condition is checking >0 and <4 which means 1 to 3. Whenever the randomNumber is 4 it will not work, so change the if (randomNumberCounter < 4) to if (randomNumberCounter <= 4).
Comment: Oh i didn't see that. i did change it and notice that i get a total of 5 questions now i am still wondering why? Meanwhile the initial bug i was experiencing still continues. I believe the `if (answerA_ID.isChecked())` always returns true even if the radio button is clicked or not
Comment: looking at the code above you would see that `int randomNumberCounter = 0;` and  `if (randomNumberCounter < 4) {
        while (randomNumber > 0) {
            randomNumberCounter++;` thats the first number sent is zero (0) after that it's start incrementing by 1, that explains when i changed it to `if (randomNumberCounter <= 4)` from `if (randomNumberCounter < 4)` it started generating 5 question i could change it to `if (randomNumberCounter <= 3)` so i dont confused users.


Linux command line for ssl server?

Question: I always use the socket command line tool to do quick socket tests for programs I'm writing.  http://w21.org/jnickelsen/socket/
I was wondering if there was a similar command line tool to set up a quick ssl socket client/server to test things.
Edit: Easy Answer
So to make it easy on people who may wonder the same thing:
If you want to be a client use openssl's s_client:
openssl s_client -connect host:port

If you want to be a server use openssl's s_server:
openssl s_server -accept <port> -key <keyfile> -cert <certfile>

Quick And Dirty cert and key for the server to use for testing:
openssl req -x509 -nodes -days 365 -newkey rsa -keyout keyfile.key -out certfile.crt

Comment: This is not a single command but a way to setup in Ruby:

http://stackoverflow.com/questions/7735422/verify-client-certificate-using-sslserver-in-ruby
Answer: Quick SSL Client:
openssl s_client -connect <host>:<port>

Quick SSL Server:
openssl s_server -accept <port>

Comment: Found these after my question.  The server end is a little more complicated.  I was hoping it would just have a default certificate that it would use, but it didn't, so I had to self sign my own.
Comment: The manpage is at https://www.openssl.org/docs/man1.1.1/man1/openssl-s_server.html . There are lots of options.

Linux command line for ssl server?


How to retrieve data from mysql php when click on spinner item android?.... it shows " app unfortunately has stopped"

Question: I want to retrieve data from mysql database using webserver php when user click on item in spinner in android app .... but it shows that app has unfortunately stopped.... and don't know what is the error....
JSONparser class
    public class JSONParser {
static InputStream is = null;
static JSONObject jObj = null;
static String json = "";

public JSONParser() {

}

public JSONObject makeHttpRequest(String url, String method,
        List<NameValuePair> params) {

    try {

        if (method == "POST") {

            DefaultHttpClient httpClient = new DefaultHttpClient();
            HttpPost httpPost = new HttpPost(url);
            httpPost.setEntity(new UrlEncodedFormEntity(params));

            HttpResponse httpResponse = httpClient.execute(httpPost);
            HttpEntity httpEntity = httpResponse.getEntity();
            is = httpEntity.getContent();

        } else if (method == "GET") {

            DefaultHttpClient httpClient = new DefaultHttpClient();
            String paramString = URLEncodedUtils.format(params, "utf- 8");
            url += "?" + paramString;
            HttpGet httpGet = new HttpGet(url);

            HttpResponse httpResponse = httpClient.execute(httpGet);
            HttpEntity httpEntity = httpResponse.getEntity();
            is = httpEntity.getContent();
        }

    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    try {
        BufferedReader reader = new BufferedReader(new InputStreamReader(
                is, "iso-8859-1"), 8);
        StringBuilder sb = new StringBuilder();
        String line = null;
        while ((line = reader.readLine()) != null) {
            sb.append(line + "\n");
        }
        is.close();
        json = sb.toString();
    } catch (Exception e) {
        Log.e("Buffer Error", "Error converting result " + e.toString());
    }

    try {
        jObj = new JSONObject(json);
    } catch (JSONException e) {
        Log.e("JSON Parser", "Error parsing data " + e.toString());
    }

    return jObj;

}

 }

plantgrow class
    public class Plantgrow extends Activity {
Spinner plantts;
Intent grow;
Button groow;
TextView info;
String data,select;
JSONParser jParser = new JSONParser();

private static String url_imp_info = "http://10.0.2.2:850/planting/plantinfo.php";
private static final String TAG_SUCCESS = "success";
private static final String TAG_INFOS = "infos";
private static final String TAG_PINFO= "pinfo";

JSONArray infos = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_plantgrow);
    plantts=(Spinner) findViewById(R.id.spinner1);
    info=(TextView) findViewById(R.id.txt_plantinfo);

        ArrayAdapter<CharSequence>   adapter=ArrayAdapter.createFromResource(this,R.array.plants,android.R.layout.simple_spinner_item);
    plantts.setAdapter(adapter);
    groow=(Button) findViewById(R.id.bt_grow);

    plantts.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1,
                int arg2, long arg3) {
            // TODO Auto-generated method stub
    Object item=arg0.getItemAtPosition(arg2);
    select=item.toString();

        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

        }

    });

    groow.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            grow=new Intent(getApplicationContext(), Planting.class);
            startActivity(grow);
        }
    });
    new GetInfo().execute();

}
class GetInfo extends AsyncTask<String, String, String> {

protected String doInBackground(String... args) {

    List<NameValuePair> params = new ArrayList<NameValuePair>();

    params.add(new BasicNameValuePair("select", select));

    JSONObject json = jParser.makeHttpRequest(url_imp_info, "GET",
            params);

    Log.d("All names: ", json.toString());

    try {

        int success = json.getInt(TAG_SUCCESS);
        if (success == 1) {
            infos = json.getJSONArray(TAG_INFOS);
            for (int i = 0; i < infos.length(); i++) {
                JSONObject c = infos.getJSONObject(i);
             data = c.getString(TAG_PINFO);

            }
        }
        else {

            Intent i = new Intent(getApplicationContext(), Main2.class);

            i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(i);
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }

    return null;
}

protected void onPostExecute(String file_url) {
    super.onPostExecute(file_url);

    runOnUiThread(new Runnable() {
        public void run() {
            info.setText(data);

        }
    });
}

}

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

}

php code
<?php

$response = array();

require_once __DIR__ . '/db_connect.php';

 $db = new DB_CONNECT();

mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET 'utf8'");

    if (isset($_GET["select"])) {

$select = $_GET['select'];

$result = mysql_query("SELECT importantInfo FROM plantinfo WHERE plantName=$select") or     die(mysql_error());

if (!empty($result)) {

if (mysql_num_rows($result) > 0)
{

    $response["infos"] = array();

while ($row = mysql_fetch_array($result)) {

    $info = array();

$info["pinfo"] = $row["importantInfo"];

    array_push($response["infos"], $info);

}

    $response["success"] = 1;

echo json_encode($response);
} else {

$response["success"] = 0;

$response["message"] = "No info found";

echo json_encode($response);
}

    } else
{           $response["success"] = 0;

        $response["message"] = "No info found";

    echo json_encode($response);

}

} else {

$response["success"] = 0;

$response["message"] = "Required field(s) is missing";

echo json_encode($response);

}

?>

logCat
03-25 19:48:58.737: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:48:58.747: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:48:58.957: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:48:58.987: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:48:59.486: D/dalvikvm(770): GC_FOR_ALLOC freed 86K, 8% free 2526K/2728K, paused  28ms, total 30ms
03-25 19:48:59.506: I/dalvikvm-heap(770): Grow heap (frag case) to 5.578MB for 3145744-  byte allocation
03-25 19:48:59.546: D/dalvikvm(770): GC_FOR_ALLOC freed 1K, 4% free 5596K/5804K, paused 37ms, total 37ms
03-25 19:48:59.596: D/dalvikvm(770): GC_CONCURRENT freed <1K, 4% free 5596K/5804K,  paused 4ms+14ms, total 52ms
03-25 19:48:59.727: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:48:59.727: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:48:59.727: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:48:59.787: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:48:59.827: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:48:59.837: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:48:59.887: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:48:59.917: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:48:59.927: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:48:59.927: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:48:59.927: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:48:59.927: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:48:59.927: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:48:59.947: D/gralloc_goldfish(770): Emulator without GPU emulation detected.
03-25 19:49:00.187: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:00.237: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:00.297: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:00.297: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:00.507: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:00.507: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:00.507: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:00.556: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:00.736: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:00.736: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:00.766: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:00.766: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:00.826: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:00.826: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:01.371: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:01.371: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:01.417: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:01.430: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:01.933: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:01.936: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:02.036: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:02.036: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:02.326: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:02.366: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:02.377: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:02.377: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:02.457: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:02.457: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:02.527: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:02.537: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:02.727: I/Choreographer(770): Skipped 40 frames!  The application may be    doing too much work on its main thread.
03-25 19:49:02.727: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:02.747: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:02.857: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:02.887: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:02.887: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:03.257: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:03.257: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:04.427: D/dalvikvm(770): GC_FOR_ALLOC freed 55K, 3% free 5723K/5896K, paused 266ms, total 297ms
03-25 19:49:04.587: I/dalvikvm-heap(770): Grow heap (frag case) to 8.701MB for 3145744-byte allocation
03-25 19:49:04.927: D/dalvikvm(770): GC_CONCURRENT freed 5K, 3% free 8790K/8972K, paused  12ms+39ms, total 332ms
03-25 19:49:05.977: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:06.007: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:06.277: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:06.456: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:06.516: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:06.546: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:06.576: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:06.576: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:06.576: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:06.666: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:06.666: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:06.706: I/Choreographer(770): Skipped 35 frames!  The application may be doing too much work on its main thread.
03-25 19:49:06.727: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:06.727: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:06.807: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:06.807: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:06.827: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:06.848: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:07.027: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:07.077: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:07.097: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:07.127: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:07.217: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:07.217: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:07.727: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:07.736: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:08.117: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:08.417: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:08.467: I/Choreographer(770): Skipped 64 frames!  The application may be doing too much work on its main thread.
03-25 19:49:08.477: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:08.517: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:08.517: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:08.517: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:08.738: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:08.738: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:08.897: I/Choreographer(770): Skipped 31 frames!  The application may be doing too much work on its main thread.
03-25 19:49:08.897: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:08.907: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:09.037: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:09.037: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:09.366: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:09.366: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:09.406: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:09.406: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
 03-25 19:49:09.497: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:09.497: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:09.537: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:09.590: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:09.697: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:09.877: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:09.887: I/Choreographer(770): Skipped 39 frames!  The application may be doing too much work on its main thread.
03-25 19:49:09.897: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:09.907: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:10.150: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:10.150: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:10.210: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:11.517: D/dalvikvm(770): GC_FOR_ALLOC freed 66K, 3% free 8899K/9084K, paused     277ms, total 315ms
03-25 19:49:11.727: I/dalvikvm-heap(770): Grow heap (frag case) to 11.801MB for 3145744-byte allocation
03-25 19:49:12.126: D/dalvikvm(770): GC_CONCURRENT freed 5K, 2% free 11965K/12160K, paused 44ms+44ms, total 399ms
03-25 19:49:12.917: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:12.957: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:13.047: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:13.217: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:13.298: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:13.316: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:13.337: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:13.337: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:13.356: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:13.476: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:13.476: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:13.526: I/Choreographer(770): Skipped 59 frames!  The application may be doing too much work on its main thread.
03-25 19:49:13.546: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:13.546: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:13.586: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:13.586: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:13.596: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:13.606: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:13.807: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:13.847: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:13.877: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:13.908: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:14.481: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:14.517: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:14.548: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:14.548: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:16.426: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:16.487: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:16.487: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:16.506: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:16.637: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:16.637: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:16.707: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:16.777: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:16.897: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:17.077: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:17.087: I/Choreographer(770): Skipped 48 frames!  The application may be doing too much work on its main thread.
03-25 19:49:17.097: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:17.117: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:17.599: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:17.599: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:17.637: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:18.354: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:18.404: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:18.514: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:18.845: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:18.904: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:18.914: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:18.924: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:18.934: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:18.934: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:19.023: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:19.023: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:19.033: I/Choreographer(770): Skipped 138 frames!  The application may be doing too much work on its main thread.
03-25 19:49:19.033: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:19.054: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:19.284: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:19.355: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:19.405: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:19.434: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:19.534: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:19.534: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:19.614: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:19.614: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:19.964: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:19.964: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:19.964: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:20.014: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:20.034: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:20.034: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:20.084: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:20.084: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:20.084: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:20.084: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:20.094: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:20.094: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:20.104: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:20.114: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:20.134: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:20.144: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:20.144: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:20.144: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:20.174: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:20.174: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:20.174: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:20.174: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:20.204: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:20.204: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:20.204: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:20.204: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:21.736: E/JSON Parser(770): Error parsing data org.json.JSONException: Value Unknown of type java.lang.String cannot be converted to JSONObject
03-25 19:49:21.745: W/dalvikvm(770): threadid=16: thread exiting with uncaught exception (group=0x40a70930)
03-25 19:49:21.814: E/AndroidRuntime(770): FATAL EXCEPTION: AsyncTask #5
03-25 19:49:21.814: E/AndroidRuntime(770): java.lang.RuntimeException: An error occured while executing doInBackground()
03-25 19:49:21.814: E/AndroidRuntime(770):  at android.os.AsyncTask$3.done(AsyncTask.java:299)
03-25 19:49:21.814: E/AndroidRuntime(770):  at     java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
03-25 19:49:21.814: E/AndroidRuntime(770):  at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
03-25 19:49:21.814: E/AndroidRuntime(770):  at java.util.concurrent.FutureTask.run(FutureTask.java:239)
03-25 19:49:21.814: E/AndroidRuntime(770):  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
03-25 19:49:21.814: E/AndroidRuntime(770):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
03-25 19:49:21.814: E/AndroidRuntime(770):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
03-25 19:49:21.814: E/AndroidRuntime(770):  at java.lang.Thread.run(Thread.java:856)
03-25 19:49:21.814: E/AndroidRuntime(770): Caused by: java.lang.NullPointerException
03-25 19:49:21.814: E/AndroidRuntime(770):  at com.example.agricultureguide.Plantgrow$GetInfo.doInBackground(Plantgrow.java:102)
03-25 19:49:21.814: E/AndroidRuntime(770):  at com.example.agricultureguide.Plantgrow$GetInfo.doInBackground(Plantgrow.java:1)
03-25 19:49:21.814: E/AndroidRuntime(770):  at android.os.AsyncTask$2.call(AsyncTask.java:287)
03-25 19:49:21.814: E/AndroidRuntime(770):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
03-25 19:49:21.814: E/AndroidRuntime(770):  ... 4 more
03-25 19:49:21.954: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:22.114: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:22.124: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:23.704: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:23.704: I/Choreographer(770): Skipped 413 frames!  The application may be doing too much work on its main thread.
03-25 19:49:23.714: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:23.914: W/Trace(770): Unexpected value from nativeGetEnabledTags: 0

03-25 19:49:28.765: I/Process(770): Sending signal. PID: 770 SIG: 9
03-25 19:49:31.345: W/Trace(795): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:32.144: W/Trace(795): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:32.176: W/Trace(795): Unexpected value from nativeGetEnabledTags: 0
03-25 19:49:33.025: D/dalvikvm(795): GC_FOR_ALLOC freed 52K, 7% free 2526K/2696K, paused 60ms, total 66ms
03-25 19:49:33.084: I/dalvikvm-heap(795): Grow heap (frag case) to 5.578MB for 3145744-byte allocation
03-25 19:49:33.214: D/dalvikvm(795): GC_FOR_ALLOC freed 1K, 4% free 5596K/5772K, paused 58ms, total 58ms
03-25 19:49:33.334: D/dalvikvm(795): GC_CONCURRENT freed <1K, 4% free 5596K/5772K, paused 17ms+6ms, total 120ms

stacktrace console
 [2014-03-27 22:16:16 - AgricultureGuide] ------------------------------
 [2014-03-27 22:16:16 - AgricultureGuide] Android Launch!
 [2014-03-27 22:16:16 - AgricultureGuide] adb is running normally.
[2014-03-27 22:16:16 - AgricultureGuide] Performing     com.example.agricultureguide.MainActivity activity launch
[2014-03-27 22:16:16 - AgricultureGuide] Automatic Target Mode: using existing emulator  'emulator-5554' running compatible AVD 'agriculture'
[2014-03-27 22:16:16 - AgricultureGuide] Uploading AgricultureGuide.apk onto device 'emulator-5554'
[2014-03-27 22:16:30 - AgricultureGuide] Installing AgricultureGuide.apk...
[2014-03-27 22:16:36 - AgricultureGuide] Success!
[2014-03-27 22:16:36 - AgricultureGuide] Starting activity com.example.agricultureguide.MainActivity on device emulator-5554
[2014-03-27 22:16:38 - AgricultureGuide] ActivityManager: Starting: Intent {   act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]   cmp=com.example.agricultureguide/.MainActivity }

Comment: that is not complete..when you run your program you will receive an exception.Also post it too.
Comment: i don't know .... i just copy the content of logCat.... you mean that i didn't copy all of it???? what should i do?
Answer: Check the success condition in onPostExecute()
  if(success==1)
    {    info.setText(data);
    }
   else
    {
        Intent i = new Intent(getApplicationContext(), Main2.class);
        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(i);
    }

onPostExecute() runs in UI thread only so you can avoid runOnUiThread there
Comment: i tried it ... but it shows also that the app has stopped
Comment: i post it now          ,,,,
Answer: it worked with me when I add tag for items into spinner using StringWithTag class


AS3 window class which can hold components

Question: I need to create a "popup window" in AS3, which can contain things like textboxes and datagrids and stuff like that.
I have searched thoroughly, and have been unable to find such a component or class. Why did they remove the AS2 window in as3? That would have been perfect for this.
The closest thing I could find was http://fatal-exception.co.uk/blog/?p=69 which cannot support textboxes or datagrids.
Thanks for your help, I need this very badly.
Answer: It's not entirely clear what you want to do.
If you want to create a display object at the top of your application, then create a new layer directly on stage. That can have anything you like in it, and you can make it draggable or whatever you wish.
If you want to create a Flash window that floats above the browser, then you can't. Or rather, you can, but you need to create a new window using JavaScript (called from ExternalInterface, see this StackO question), load in a new SWF, and then link the two SWFs using LocalConnection. This is really unsatisfactory though, because LocalConnection is broken (in a whole host of ways).
Answer: I was able to build a window class myself quite easily. It has some decent functionality.
I used startDrag(false) and stopDrag(); to program the dragging functionality, and this.parent.removeChild(this); to get rid of the window.
Comment: That doesn't answer your own question, so should not be considered an answer.
Comment: It includes the basic functionality needed to make a "window". Implementation is up to whoever is using the code. I'm afraid you misinterpreted my question. The main question is not why the component was removed in as3, rather how can I create something which in effect mimics its capabilities. I feel your downvote was unnecessary, "drowntoge" provided a similar answer yet you did not downvote them. Please explain your logic.
Answer: What I would do is to create a class that extends MovieClip, include a TextField at the top as the title, an X button to close it, event handlers in order to handle dragging etc.
You can then instantiate the class and add the items to be shown as children.
Comment: Pretty much what I eventually did


How to make html map show the url at bottom of browser?

Question: Normally when we hover over a link defined by this is a link we get a tool tip in the bottom corner of browser saying that its going to "blah.com".
Now I am trying to use <map>, which doesn't show a tool tip.
Is there a way to make that happen?
Answer: This is probably what you're looking for. This is a slightly modified version of Jose Antonio's solution. Have added code to show tool-tip on bottom right of browser window.
Check this fiddle: http://jsfiddle.net/xmkFB/1/
Answer: I'm not sure if I understood your question.
But if you want tool tips you are looking for the title attribute in the html tags.
If you are looking for the url in the browsers status bar I think It depends on the browser. (ex.: firefox 9 shows both the url for a and area tags)
check out this fiddle
Comment: He is looking for a tooltip like thing at the bottom right of the browser.
Comment: or bottom left ;)  The point is I want to let users know where the link goes to.
Answer: As far as I'm concerned the <map> element supports the title attribute so you might want to do something like <map title="your tool tip here" />
Whether or not that gets rendered as tool tip will mostly depend on the user agent.
Here's a working sample: http://jsfiddle.net/QhyU8/


Javascript validation issues

Question: I having some trouble validating some fields with javascript.  I'm trying to test a field called name of 30 characters max, John Smith, Paul M'Dougall Laura-Jane should all test true but gazz8932 should test false.
The EAID should be up to 16 characters 123kjg-34_dfs should test true but wil *&$ etc it should test false.
Finally the url should be from youtube.com or ea.com but I can't bet any of these to work.
If any light can be shed it would be much appreciated...
// create the errors array
var errors = false;

// clean last errors
$('#goalsubmission p.error').remove();
$('#goalsubmission .error').removeClass('error');

// test the name
var reg = /^[a-z ,.'-]{0,30}/i;
var name = $('#goalsubmission input#name');
if(reg.test(name.val()) == false){
    name.parent().addClass('error');
    errors == true;
    name.parent().append('
Make sure you have put your name using only letters and spaces.
');
} else {
    name.parent().removeClass('error');
}

/*
// test the email
var reg = /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/;
var email = $('#goalsubmission input#email');
var result = reg.test(email.val());
if(email.val().length == 0 || result == false){
    email.parent().addClass('error');
    errors == true;
    email.parent().append('
Make sure you have entered a valid email address.
');
} else {
    email.parent().removeClass('error');
}
*/

// test the ea id
var reg = /^[a-z0-9-_]{0,16}/i;
var eaid = $('#goalsubmission input#eaid');
if(reg.test(eaid.val()) == false){
    eaid.parent().addClass('error');
    errors == true;
    eaid.parent().append('
Make sure you have entered a valid EAID.
');
} else {
    eaid.parent().removeClass('error');
}

// test the url
var regYT = /^http:\/\/(?:www\.)?youtube.com\/watch\?v=\w+(&\S*)?$/
var regEA = /^http:\/\/(?:www\.)?ea.com\/?$/
var url = $('#goalsubmission input#url');
if(
//                          url.val().length == 0 ||
//                          url.val().length > 255  ||
    (regYT.test(url.val()) == false && regEA.test(url.val()) == false)
){
    url.parent().addClass('error');
    errors == true;
    url.parent().append('
Make sure you have entered a valid Url, from either YouTube or EA.
');
} else {
    url.parent().removeClass('error');
}

Comment: Can you specify the rules that say why `gazz8932` or `*&$` are no valid matches?
Comment: /^[a-z ,.'-]{0,30}/i as far as I understand say, from start of string case insensitive of length 0-30 chars looking for a-z spaces, commas, fullstops, hyphens and quotation marks.  Is this not the case?  There is no mention of numbers so it should test false if there are numbers correct?
Comment: Yes. I see the source of my misunderstanding: you're asking three questions in one. Maybe better split up the question, focusing on one regex each. Even better to first search this site since questions like these have been asked dozens of times before.
Comment: I got everything working using the solution below.  As for the urls I used the following: var reg = /(youtube.com|ea.com)/; if(reg.test(url.val()) == false) etc
Comment: Better escape the dot or your regex will hit on something like `tearcompany.info`. Also, use word boundaries, or you'll mistakenly match `tea.com` etc.
Answer: You need to mark the regex with $ at the end, so that it doesn't match anything further from the expression. This way, you'll match "Paul", but not "Paul123" with the following expression:
var reg = /^[a-z ,.'-]{0,30}$/i;

Same thing happens with eai:
var reg = /^[a-z0-9-_]{0,16}$/i;

Comment: No, the uppercase letters are included (`/i` modifier).

Javascript validation issues


.htaccess: Block all countries except for one country

Question: I am trying to block all country access except for one using .htaccess.
What I have right now is
RewriteEngine on
<Directory nameOfDirectory>
Order Allow, Deny
Allow IP range 1
Allow IP range 2
</Directory>

I keep getting Internal Server Errors. What I am doing wrong? Note that country in question actually has over 500 IP ranges.
Of course if there is a better way to do this besides .htaccess, I am all ears.
Update: Apache error log
[Tue Mar 15 06:29:37.308444 2016] [core:alert] [pid 14435] [client xxx.xxx.6.2:59534] /var/www/.htaccess: <Directory not allowed here

Comment: Why not try [this generator](http://incredibill.me/htaccess-block-country-ips) to create the addresses and .htaccess file for you?
Comment: @egg I tried that site before. I am still getting an 'internal server error' plus I want to block a specific directory which that site doesn't provide the syntax for.
Comment: What version of Apache are you using?
Answer: I've not tried this, but how about denying first and adding the Deny from all; something like this:
<Directory "nameOfDirectory">
    Order deny,allow
    Deny from all
    Allow from 192.168.0.1
    Allow from 192.168.0.2
    Allow from 10.0.0.1
    Allow from 10.0.0.2
    Allow from 127.0.0.1
</Directory>

Your error.log tells you that you don't have permission to use <Directory>. So you can either allow it (with AllowOverride Authconfig FileInfo Options in your apache config for the directory) or just drop a htaccess file inside the directory to protect and remove the <directory> tags.
This will work in the directory you want to protect:
    Order deny,allow
    Deny from all
    Allow from 192.168.0.1
    Allow from 192.168.0.2
    Allow from 10.0.0.1
    Allow from 10.0.0.2
    Allow from 127.0.0.1

Comment: Tried that. The problem is that it's throwing a 'server error' as if there is a problem with the syntax or something.
Comment: Updated post with error log. Seems like I can't have .htaccess in /var/www?
Comment: It means you can't have  in your htaccess; either allow this or remove the `Directory` tags and drop this file in the directory to protect (updated answer).
Comment: Still getting an 'internal server error.' I actually removed everything except for the 'RewriteEngine on' 'order,allow,deny' 'deny all' ...and put it in that specific folder.
Comment: The [AllowOverride](http://httpd.apache.org/docs/2.4/mod/core.html#allowoverride) option in your apache config doesn't allow you to use `Order` or `Deny` either, which stops you in your tracks. You'll need to change this to `AllowOverride Authconfig FileInfo Options` for your `Directory` or VHost.
Comment: This is what I have in apache2.conf:

        Options FollowSymLinks
       AllowOverride Authconfig FileInfo Options
 getting an internal error still
Comment: I am getting an error when restarting Apache `The apache2 configtest failed, so we are trying to kill it manually. This is almost certainly suboptimal, so please make sure your system is working as you'd expect now!`


Unable to use jenkins after restarting the pc

Question: I have installed the jenkins using jenkins.war file on windows, i have set up the plugins for it. But next day when i tried to open the jenkins on 192.168.43.75:8090. It is not working
Comment: it all depends on how you started jenkins. Let me ask you this, if you open a notepad on your computer and then restart it, do your find it opened when your laptop is booted?
Comment: Now, i understand, i need to enter jenkins command, everytime i want to use jenkins
Answer: If you want Jenkins to start automatically when your PC is restarted, you could install Jenkins as a Windows service. Documentation: https://wiki.jenkins.io/display/JENKINS/Installing+Jenkins+as+a+Windows+service
Answer: did you run the war file again after your restart?
java -jar jenkins.war --httpPort=8090

Are you able to see Jenkins is fully up and running in the server logs?
If still issues persist then update the question with the server logs.
Comment: do I need to run the war file everytime after I restart my pc?
Comment: You can install it as a windows service .
Answer: If you are running on Linux you can run the command in background like below:
java -jar jenkins.war --httpPort=8090 &

If you running in Windows, then you need to register it as Windows service.
Answer: One way is we can deploy jenkins.war in Tomcat. In this way, everytime we start tomcat, then Jenkins also gets running.
Another way is to use java -jar jenkins.war --httpPort=8090, but we have to hit this command everytime we want to use Jenkins.


Why do both water tanks have hot inputs? Is my boiler (on-demand) feeding into my hot water heater?

Question: I have an interesting setup that I'm trying to understand (without tearing apart sheetrock).  I have two electric tank-based water heaters, and a tankless gas water heater that is used for the boiler system.
This is the tankless heater:

And here are the two electric tank-based heaters:

There is also a water recirculation pump hooked up to the water heater on the left.  Here's a close-up shot:

I believe that the two tank-based water heaters are hooked up in series, with the right one receiving cold water and feeding the left one, which then provides hot water to the house.  This explains why both the input and output of the left one are hot.  However, on the right one, the output is always hot (expected) but the input is sometimes hot, sometimes cold.  Why?  Is it possible that the on-demand boiler is feeding into the input of the right one?  Are there any other explanations?
Comment: I could see having 2 hot water heaters in series, the upstream one being on a timer so it only runs when the church is occupied.  The downstream one provides water for anytime use, the upstream one refills it with preheated water at peak times, and off peak, does not.  Doubling hot water supply in peak times,
Comment: Is this a house, apartment complex?
Comment: This is a small church
Answer: If the right hand heater were supplying hot water to the left hand heater, it would be strange to hide the pipework in the wall.
I guess it is more likely that they are feeding separate heating circuits.
It is not unusual for the return pipe to be nearly as hot as the output line, if the system has been running for a while.
There ought to be records of the system somewhere showing how it is connected up. If the church doesn't have them, the original installers should - or at least could advise.
Answer: Despite being obscured behind the wall, it turns out that the two water heaters were indeed in series, the right side feeding into the left side.  I accepted the other answer tho since it is probably more helpful in the general sense.


Svn and disconnected edits

Question: I am using svn (VisualSVN Server in specific with VisualSVN and thus TortoiseSVN). Is it possible to work in an offline scenario? E.g. code is checked in, and then modify the solution without checking out the relevant file?
What (if anything) will go wrong?
Comment: Take a look at http://stackoverflow.com/questions/4934208/working-offline-with-svn-on-local-machine-temporary
Answer: You can work offline with local repository through file://. First you need to create local repo, sync with remote, then switch working dir to the local repo, after some work you can sync them back with remote and switch working dir back to remote. This is described here.
Answer: You can continue working, but ...
Some svn actions still can be completed while you're not connected to repo. For example - svn diff, to see your local changes, svn st. This is possible since while you checkout, svn save copy of each checkout file in .svn.
Actions that require access to repo can not be accomplished - e.g. svn commit.
Answer: No, SVN requires access to a centralized server.  You cannot queue up commits offline for later transmission to the server.
You may find what you need with a distributed version control system such as Mercurial or Git.  They allow you to work offline as if you were connected, and then synch your changes when you eventually connect.

Svn and disconnected edits


In any ring $R$:product of non-unit and any element is non unit.

Question: My question may seem duplicate for :
Product of a non-unit with any other element
and
Can non-units be multiplied together to form units?
But these above don't give complete answer:
Because both of them , proved it in the case of commutative ring with unity , and for the case of non commutative ring with unity , they just gave example that there exists left inverse and right inverse.
Definition of unit: $a\in R$ is unit iff  it has both left and right inverse.
So: $a\in R$ is non unit iff  it doesn't have left or right inverse.
Now my approach to problem:
Let $a\in R$ be non unit  and let $b \in R$
case $1$: $b$ is unit:
For the sake of contradiction assume $ab$ is unit.
then $\exists m \in R$ such that $(ab)m=1_{R}$ and $m(ab)=1_{R}$
which implies $a=(bm)^{-1}$ so $a$ is unit which is contradiction since $a$ is nonunit.
note:$(bm)^{-1}$ is unit because $b,m$ are units.
Case $2$: b is non unit:
For the sake of contradiction assume $ab$ is unit.
then $\exists m \in R$ such that $(ab)m=1_{R}$ and $m(ab)=1_{R}$
Now by associativity $a(bm)=1_{R}$ and $(ma)b=1_{R}$ which means $a$ has right inverse and b has left inverse.
But there is no contradiction until I also show $a$ has left inverse and $b$ has right inverse.
But I don't how to continue.
Can you , please , help me to continue solution?
Comment: https://math.stackexchange.com/questions/327098/product-of-a-non-unit-with-any-other-element gave an example which contradicts your conjecture in the non-commutative case.
Comment: @AnneBauval I have said that it doesn't in the body of my question
Comment: And I disagreed with that claim in my first comment. See also my new comment in the proposed "such good answer" ;-).
Answer: Consider the abelian group $A=\Bbb Z^{\omega}$ of sequences of integers and let $R=\operatorname{End}(A)$ be its ring of endomorphisms.
For $f\in A$, define $D(f)$ per
$$ D(f)(n)=f(n+1)$$
and $I(f)$ per
$$ I(f)=\begin{cases}f(n-1)&n>0\\0&n=0\end{cases}$$
As $D$ is not injective and $I$ is not onto, $D$ cannot have a left inverse and $I$ cannot have a right inverse. So neither $D$ nor $I$  is a unit.
But their product is a unit, in fact $D\circ I=\operatorname{id}_A$.
Comment: This is exactly the example given in the proposed duplicate.
Comment: So the statement turns out to be false and your answer gives counter example?

thank you for your kindness to write such good answer.
Comment: @AnneBauval Sorry , you are right.

I need to delete my question right?

but it will not be accepted by the site since it has answer now?
Comment: @Mahmoudalbahar Yes you can delete your question


Is it possible for multiple summons to participate in the same chase?

Question: In Naruto Online, you can equip 3 summons that help you string together chases. I've tried many combinations with my ninja's chase skills and my chases never seem to utilize more than 1 summon per turn. I'm wondering if it's possible to chain something like ninja + summon + summon + ninja in a single chase or do I need to equip summons that combo PER chase.
Answer: No this is not possible. You can only select one summon that will help you out.
However you should always set the strongest summons in the slots you don't need since they increase your power.
Comment: No. When you select your talents (don't know the english description though) you have your 3 selectet summons at the bottom. There you can select the one you want to use
Comment: So only the summon in the top slot counts right?
Answer: No it isn't possible you can only use the summon you select. For instance, if I have the serpent, the Flood dragon, and the illusion crow and I select the flood dragon then only the flood dragon would show up in battle.
Comment: This does not add anything new to a question that was answered two years ago
Comment: sorry just trying to get some coupons for my games