text:
Q: How to use values read from html for variables i'm trying to use mongodb and ajax. i want to load data from database which has the same name with radiobutton's value.
it kinda like this.
@app.route('/Dessert', methods=['POST'])
def read_dessert():
    selecteddb = request.form['dessert_give']

    data_list = list(ddb.selecteddb.find({},{'_id':False}))
    return jsonify({'result': selecteddb})

and ajax from index.html
   function send_dessert() {
        let dessert = $(":input:radio[name=type]:checked").val()
        $.ajax({
            type: "POST",
            url: "/Dessert",
            data: {dessert_give: dessert},
            success: function (response) {
                console.log(response)
                alert('dataload complete')

            }
        });

however, the result shows nothing, what should i do?
It was successful to load the database by directly declaring the values checked by radiobutton. However, I am doing this because I want to load different databases based on the values checked in radiobutton.


text:
Q: Need help with finding the electronic schematics I'm trying to find what kind of circuitry(circuit components or schematics) is used in this anemometer: http://www.nrgsystems.com/sitecore/content/Products/5966.aspx
There are a lot of details about mechanical parts but not the electronics in their website. It just says it is generating ac sine waves that's all. I want to know whats in the anemometer.

A: When you click the "Specifications" tab on that anemometer page,
it specifically says

Signal type:   low level AC sine wave, frequency linearly proportional to wind speed
... (more details about the output signal omitted) ...
Magnet:    Indox 1, 25 mm (1 inch) diameter, 13 mm (0.5 inch) long, 4 poles
Coil:  single coil, bobbin wound, 4100 turns of #40 wire, shielded for ESD protection

From those specs, it is almost certainly a fixed-coil, moving-magnet magneto -- a kind of alternator -- with the wires from the coil coming directly out.
It apparently doesn't have any other "electronics" or "circuits".
It has a coil of wire, and it has a magnet spinning in the center of that coil.
That's it.
They gave you details about each and every electronic part of the device -- both the coil, and the magnet.
I'm a little puzzled -- Why would anyone think "they give no info about it" when their website already lists almost everything there is to know about it?
Could you give a link to a web page about something you've designed, that shows the amount of detail you think is appropriate?

(Image from http://en.wikipedia.org/wiki/File:Alternator_1.svg ).

A:
Signal type    low level AC sine wave, frequency linearly proportional to wind speed

presumably, a small generator

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to retrieve layout of an item using JSS I am really new to JSS and I am very confused by the docs and how Sitecore is supposed to assemble layout information. I am trying to retrieve layout information of an item using JSS for one of our MVC project. The item in question renders fine in the browser using our traditionnal MVC stack. However I  am unable to retrieve layout information of that item using JSS.
The item in question is based on the standard template and has the following presentation/layout details:

*

*The layout points to a cshtml file.

*The cshtml file contains the HTML layout, and a placeholder rendered using @Html.Sitecore().Placeholder("Menu")

*The content of the placeholder is defined in Sitecore Layout Details dialog using a control/rendering named "Menu".

*The rendering "Menu" points to a controller named Web.Controllers.MenuController and action named GetMenu
Content of the cshtml file:
@using Sitecore.Mvc

                @Html.Sitecore().Placeholder("Menu")

                @Html.Raw(Model.Content)

When retrieving the layout information of the item using the render endpoint (/sitecore/api/layout/render/jss?item={item_id}&...). I get the fields values of the item, but I do not get any presentation details nor placeholder information.
{
    "sitecore": {
      "context": {
        "pageEditing": false,
        "site": {
          "name": null
        },
        "pageState": "normal",
        "language": "fr",
        "itemPath": "/my-item"
      },
      "route": {
        "name": "prendre-route-securite",
        "displayName": "prendre-la-route-en-toute-securite",
        "fields": {"Content": {"value": "My Content"}},
        "databaseName": "web",
        "deviceId": "fe5d7fdf-89c0-4d99-9aa3-b5fbd009c9f3",
        "itemId": "85cac673-2cfb-496c-ba62-0f1d634ae241",
        "itemLanguage": "fr",
        "itemVersion": 1,
        "layoutId": "b39337a1-8bb5-44c3-ba97-0dce8ef517f6",
        "templateId": "34c34e2b-f2ac-405f-afb3-d0185bc936bb",
        "templateName": "ArticleZoneConseils",
        "placeholders": {}
      }
    }
  }

The documentation says I am supposed to put some values inside the Layout Service Placeholders field of the layout. But I have no clue of what I should put in there to get the placeholder data showing in the REST query.


text:
Q: Python, Pandas Dataframe - creating a derived column with conditional statements I have a Pandas DataFrame with 50 columns and 50k rows. There is one column with measurement data that needs correcting with a calibration factor. The factor is an integer value to be added or substracted. There are multiple (10ish) measurements in the same column of measurement data ['T_calibrated'], they all have an unique serial number in a seperate column ['serial']
I can calibrate a single sensor as follows using .where:
data['T_calibrated'] = data['T_uncalibrated'].where(data['serial'] == 12345)-2.7

12345 is the unique serial number
-2.7 is the calibration factor.
How would I write this in a more generic form so that I can add the unique calibration factor associated with each serial number and add this all as a single combined column ['T_calibrated']. So far I'm getting stuck with brute force ways. I'm sure there must be some very elegant way to do this.
I have a second dataframe with the serial number and calibration factor that can be looped or compared with ofcourse.

A: Close after posting my question I saw the light.
I joined the two dataframes on the serial numbers preserving the original index of the original (because I want that). Then I created another column just subtracting the two values. I didn't know how to add "inplace=True" with the join statement.
Here's my code:
calibrated_data=data.join(calibration_dataframe.set_index('serial'),on='serial')
calibrated_data['T_calibrated'] = calibrated_data.T_uncalibrated - calibrated_data.calibration_factor

A: You describe two data frames structured as below.  Simplest approach is to merge them then calculate required column from merged data frame.
import numpy as np

serial = [f"{a}{ord(a)}" for a in list("abcdef")]

df = pd.DataFrame({"serial":np.random.choice(serial, 50), "T_uncalibrated":np.random.randint(20,30,50)})
dfs = pd.DataFrame({"serial":serial, "calibration":np.random.randint(-2,2,len(serial))})

df.merge(dfs, on="serial").assign(T_calibrated=lambda d: d["T_uncalibrated"]+d["calibration"])

sample output

serial
T_uncalibrated
calibration
T_calibrated

c99
20
-2
18

c99
27
-2
25

c99
28
-2
26

c99
28
-2
26

c99
20
-2
18

c99
22
-2
20

c99
24
-2
22

c99
24
-2
22

d100
21
-1
20

d100
26
-1
25


text:
Q: Chosen jquery plugin - Get the selected text/ label (not value) of multiple selection I have a chosen multi-select box as below
No matter how many items are selected, I want to get only the current (single) selected label.
I found that params.selected can get the selected value, but what I need is the selected label.
I also cannot use $("#purposes option:selected").text() because it get multiple selected labels,

$("#purposes").chosen().on("change", function(event, params) {
  console.log(params.selected); //this works for value only
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.jquery.min.js"></script>

<select class="chosen-select" id="purposes" multiple data-placeholder="Purposes">
  <option value="1">Massaging</option>
  <option value="2">Downloading</option>
  <option value="3">Research</option>
  <option value="4">Travel arrangements</option>
  <option value="8">Banking</option>
  <option value="9">OTHERS</option>
</select>

A: You could find the option with the selected value and get its label by .text()
$(this).find(`option[value=${params.selected}]`).text()

$("#purposes").chosen().on("change", function(event, params) {
  console.log($(this).find(`option[value=${params.selected}]`).text())
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.jquery.min.js"></script>
<select class="chosen-select" id="purposes" multiple data-placeholder="Purposes">
  <option value="1">Massaging</option>
  <option value="2">Downloading</option>
  <option value="3">Research</option>
  <option value="4">Travel arrangements</option>
  <option value="8">Banking</option>
  <option value="9">OTHERS</option>
</select>


text:
Q: How is WITH used in Oracle SQL (example code shown )? I found this example code online when I searched for "how to do an Exclusive Between oracle sql"
Someone was proving that, in Oracle, BETWEEN is by default inclusive.
So they used such code :
with x as (
    select 1 col1 from dual
    union
    select 2 col1 from dual
    union
    select 3 col1 from dual
    UNION
    select 4 col1 from dual

 )

 select *
   from x
  where col1 between 2 and 3

I've never seen such an example, what is going on with the WITH  ?

A: In short, WITH clause is an inline view, or subquery. It is useful when you will refer to something multiple times, or when you want to abstract parts of a complex query to make it easier to read.
If you are from SQL Server world, you can also think of it like a temporary table.
So:
WITH foo as (select * from tab);

select * from foo;

is like
select * from (select * from tab);

Though it may be more efficient since x is resolved to a single dataset, even if queried multiple times.
It also reduces repetition. If you use a subquery more than once in a statement, you can consider factoring it out using WITH.
It has nothing to do with the BETWEEN example, it is just the author's choice of approach for demonstrating a concept.


text:
Q: Hibernate ignore column if not exist Ok the problem is that i have a aplication that make queries to different DB, and some Entities there are missing columns. Is there a way to ignore missing columns without using inheritance?

A: There are different possibilities depending of your needs:

*

*If you never need these extra columns, which exist only in some databases, then you just do not define them in the mapping (or in the annotations). Then they are never read by Hibernate, and on insertion the columns are set to null (you can define default values or triggers in the database if you want values different than null).

*If you need the extra columns when they exist, then you need different mappings for the different databases. Better you use xml mapping files for this case. Anyway you have an individual hibernate.cfg.xml for each database (the connect string is in there). In here for the tables with different columns you specify different mapping files (tag <mapping resource="..." />). The Java pojo, i. e. the Java class, is the same for all databases, and it contains all columns which exist on any database, but in the database specific mapping files you only map those columns to Java members which really exist in that database. (With annotations this is annoying because then you need different Java classes for different databases and you have to handle the logic in your code.)

*If the tables are read only, then you can define a database view over that table and let this view providing missing columns with default values. Then in Hibernate you map the view and not the table.


text:
Q: Area between the ROC curve and the Random Guessing Line How close is my classifier to random guessing?
I need to quantify the inability of a binary classifier to obtain better results than random guessing in a single number evaluation metric.
The random guessing line (RGL) from (0,0) to (1,1) has an AUC of 0.5. But so does the blue curve (grey area).

Wouldn't it be more suitable to use the area between the RGL and the ROC-curve to estimate how "close" a classifier is to actual random guessing?

A: First, the 0.5 random guess line is just a visual reference, what we really want to know if how well the classifier performs overall. I'm also not sure how your proposed method would provide a different result, assuming that you subtract first section that is below the 0.5 line.
Second, the AUC also has a nice statistical property where it is equivalent to the Wilcoxon-Mann-Whitney U Test statistic. This is the probability that the classifier will rank a randomly chosen positive instance higher than a randomly chosen negative instance.
In this case, we don't need to see the AUC value to know this is a poor classifier (and one unlikely to be seen in real life, as it implies that true positive values are consistently rated under a certain probability threshold while false positive values are more evenly distributed).

A:
How close is my classifier to random guessing?

You could test this by using Kolmogorov-Smirnov.
In Python:
from scipy import stats

stats.ks_2samp(actual, preds)

Small K-S statistic and high p-value suggest that your classifier is no better than random.
(Also this might help: How to determine whether a classifier is significantly better than random guessing?)


text:
Q: Fetch current birthdays after logging into facebook with pyhhon I have decided to attempt to create a simple web scraper script in python. As a small challenge I decided to create a script which will be able to log me into facebook and fetch the current birthdays displayed in the side. I have managed to write a script which is able to log me into my facebook, however I have no idea how to fetch the birthdays displayed.
This is my scrypt.
from selenium import webdriver
from time import sleep
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options

usr = 'EMAIL'
pwd = 'PASSWORD'

driver = webdriver.Chrome(ChromeDriverManager().install())
driver.get('https://www.facebook.com/')
print ("Opened facebook")
sleep(1)

username_box = driver.find_element_by_id('email')
username_box.send_keys(usr)
print ("Email Id entered")
sleep(1)

password_box = driver.find_element_by_id('pass')
password_box.send_keys(pwd)
print ("Password entered")

login_box = driver.find_element_by_id('u_0_b')
login_box.click()

print ("Login Sucessfull")

print ("Fetched needed data")
input('Press anything to quit')
driver.quit()
print("Finished")

This is my first time creating a script of this type. My assumption is that I am supposed to traverse through the children of the "jsc_c_3d" div element until I get to the displayed birthdays. Furthermore the id of this element changes everytime the page is refreshed. Can anyone tell me how this is done or if this is the right way that I should go on about solving this problem?
The div for the birthday after expecting elements:

            Bobi Mitrevski
            and
            Trajce Tusev have birthdays today.

A: You are correct that you would need to traverse through the inner elements of jsc_c_3d to extract the birthdays that you want. However this whole automated web-scraping is a problem if the id value is dynamic, such that it changes on each occasion. In this case, text parsers such as bs4 would do the job.
With the bs4 approach you simply have to extract the relevant div tags from the DOM and then you can parse the data to obtain the required contents.
More generally, this problem is solvable using the Facebook-API which could be as simple as
import facebook

token = 'a token' # token omitted here, this is the same token when I use in https://developers.facebook.com/tools/explorer/
graph = facebook.GraphAPI(token)
args = {'fields' : 'birthday,name' }
friends = graph.get_object("me/friends",**args)


text:
Q: fullCalendar events post method to MySQL I am attempting to create a MySQL backed events interface, using fullCalendar and MySQL. I have tried to manipulate the examples in the fullCalendar documentation and have successfully created a events feed from my database.
I am now trying to create a eventDrop call which sends an events id, title and start time to the database. I used the code from a previous question to create the eventDrop call, here is the JavaScript for the whole callendar page:
$(document).ready(function() {
    /* initialize the external events
    -----------------------------------------------------------------*/

    $('#external-events div.external-event').each(function() {

        // create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/)
        // it doesn't need to have a start or end
        var eventObject = {
            title: $.trim($(this).text()) // use the element's text as the event title
        };

        // store the Event Object in the DOM element so we can get to it later
        $(this).data('eventObject', eventObject);

        // make the event draggable using jQuery UI
        $(this).draggable({
            zIndex: 999,
            revert: true,      // will cause the event to go back to its
            revertDuration: 0  //  original position after the drag
        });
    });

    /* initialize the calendar
    -----------------------------------------------------------------*/

    $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        editable: true,
        droppable: true, // this allows things to be dropped onto the calendar !!!
        drop: function(date, allDay) { // this function is called when something is dropped

            // retrieve the dropped element's stored Event Object
            var originalEventObject = $(this).data('eventObject');

            // we need to copy it, so that multiple events don't have a reference to the same object
            var copiedEventObject = $.extend({}, originalEventObject);

            // assign it the date that was reported
            copiedEventObject.start = date;
            copiedEventObject.allDay = allDay;

            // render the event on the calendar
            // the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)
            $('#calendar').fullCalendar('renderEvent', copiedEventObject, true);

            // if so, remove the element from the "Draggable Events" list
            $(this).remove();
        },

        // events from mysql database
        events: "/json-events.php",

        // submit to database
        eventDrop: function(calEvent, jsEvent, view) {
            var method = 'POST';
            var path = 'submit.php';
            var params = new Array();
            params['id'] = calEvent.id;
            params['start'] = calEvent.start;
             params['end'] = calEvent.end;
             params['title'] = calEvent.title;
            post_to_url( path, params, method);
  }
    });
});

The PHP file I hoped would receive the POST data and insert it into the database with an end time equal to the start time plus 15 mins (edited after answer below):
<?php

mysql_connect("") or die(mysql_error());
mysql_select_db("") or die(mysql_error());

$id = $_POST["id"];
$title = $_POST["title"];
$start = $_POST["start"];
$end = date(Y-m-d T H:i:s , strtotime($start)+900);

$query = "INSERT INTO `events` VALUES (`$id`, `$title`, `$start`, `$end`, ``)";
mysql_query($query);
print $query;
?>

The database is not receiving the event data.

A: This is the conclusion I have come up with and I have no problem running this off my test and public server.
I have taken the FullCalendar and this is the format I use.
The database is real simple.
id integer 11 chars primary key auto-increment,
title varchar 50,
start varchar 50,
end varchar 50,
url varchar 50.

This is the index.php or index.html file.
<!DOCTYPE html>

<link href='css/fullcalendar.css' rel='stylesheet' />
<link href='css/fullcalendar.print.css' rel='stylesheet' media='print' />

loading...

json.php needs to be running in the same directory.

This is the json.php file.
<?php
mysql_pconnect("localhost", "root", "") or die("Could not connect");
mysql_select_db("calendar") or die("Could not select database");

$rs = mysql_query("SELECT * FROM events ORDER BY start ASC");
$arr = array();

while($obj = mysql_fetch_object($rs)) {
$arr[] = $obj;
}
echo json_encode($arr);
?>

A: Once remove the column names in insert query and try, if you don't get then let's think about it. Do something like this
mysql_query(INSERT INTO `events` VALUES ('$id', '$title', '$start', '$end', ''));

Just print the post values before inserting, if it seems clear, then check your query.
echo the query and exit, you may get something like this
mysql_query(INSERT INTO `events` VALUES ('23', 'event title', 'start date', 'end date', ''));

Run this query to find errors if any

A: print $query - there should be a ; at the end


text:
Q: Pushing data that is not merged to a new DF, pandas I have two DFs see below:
DF1
ID           Green
B1           20
B2           10
B3            5
B4            2
B5            0
B8            0

DF2
ID           Red
B1           2
B2           4
B3           10
B9           12
B7           10

I've done a merge of the two dataframes with the following:
 import pandas as pd
 import numpy as np

DF3 = pd.merge(DF1, DF2, how = 'left', left_on='ID, right_on='ID')

ID         Green       Red
B1           20        2
B2           10        4
B3            5       10

Is there a way for the data in DF1 that did not get matched/merged to be pushed to a new dataframe (e.g DF4) and the same for the data in DF2 to also get pushed to a new dataframe (e.g DF5)?
So DF4 and DF5 would be:
DF4
ID           Green
    B4            2
    B5            0
    B8            0

DF5
ID           Red
B9           12
B7           10

Thank you for any insight or guidance.
Kind regards,

A: You can see the differences in both dataframes, parts that will not be merged, by checking which parts are in one and not the other. For example,
DF1[~DF1.isin(DF2)].dropna()

Result:
    ID  Green
3   B4  2
4   B5  0
5   B8  0

and
DF2[~DF2.isin(DF1)].dropna()

result:
    ID  Red
3   B9  12
4   B7  10

A: A general way to manage this is to pull in all the data into a single dataframe - simply change the how to 'outer'.

DF3 = pd.merge(DF1, DF2, how = 'left', left_on='ID, right_on='ID')

And then you can access the union of the two by calling:

DF3.dropna(thresh=1)

And you can access the ones with only red values calling:

DF3.loc[DF3['Green'].isna()]

If you call the inverse, DF3['Red'].notna() you end up with both rows with a Green value and a Red value as well as the rows with a Red value and a NaN for the green.  So you have to call all the rows.  See below if you truly want just one column for the red or green.

DF3.loc[DF3['Green'].isna()].drop(labels = 'Green')


text:
Q: Tools to speed the generation of locale files (for rails) I'm involved in preparing a pre-existing rails application for translation - going through the files under app/views/, finding the text, making a key in config/locales/de.yml (in this case), copying the text into de.yml, and putting t("key") in the view file. Repeat hundreds, maybe thousands of times. This is very tedious.
I don't think it can be fully automated, but the key things I need to do are select the text and give it a key.
So does anyone know of a tool that will automate the rest of the steps? I want to select the text, hit a key combo, type in a key, and the tool will put a key in the de.yml file, append the text, and put t("key") in place of the text that was selected.
My only key requirement is that it should run on Linux. I'm a vim user, but I'll learn Emacs if that is the best way to do it. I'll even install Eclipse if that is the best way ... I imagine that vim or emacs macros should easily be able to do the amount of work I'm asking for.
Anyone? Please?
With a bit of googling, I've managed to find a textmate plugin which would be near perfect if I had a Mac and Textmate. Something similar would be great.

A: Normally for those cases I use, I18n::Backend::Database (ActiveRecord Adapter for storing translations in the database). This has one major advantage that might also be helpful for your case, I can store translations without the key syntax.
Suppose you have this text <%= link_to 'Das ist ein Link Text', root_url %>
You could transform it to this with I18n::Backend::Database <%= link_to t('Das ist ein Link Text'), root_url %>.
Using this you could create a quick Textmate/Emacs/Vim shortcut to just basiclly wrap the t() around a string.
Does that solve your problem?


text:
Q: time code with hundredths? Been creating a time code format from decimal seconds but now need to get hundredths into the format.
so for 1.5 secs i need to get 00:00:01:050 but i need some help as not getting anywhere!
Any help appreciated... D.
function secondsToTime(secs) {

    var hours = Math.floor(secs / (60 * 60));

    var divisor_for_minutes = secs % (60 * 60);
    var minutes = Math.floor(divisor_for_minutes / 60);

    var divisor_for_seconds = divisor_for_minutes % 60;
    var seconds = Math.ceil(divisor_for_seconds);

    // guesswork!
    var divisor_for_hund = divisor_for_seconds / 100;
    var hund = divisor_for_hund;

    var obj = {
        "tc": pad(hours, 2) + ':' + pad(minutes, 2) + ':' + pad(seconds, 2)+ ':' + pad(hund, 3),
        "h": pad(hours, 2),
        "m": pad(minutes, 2),
        "s": pad(seconds, 2)
    };
    return obj;
}

A: var hundredths = Math.round((secs % 1) * 100);

secs % 1 will make 0.5 from 1.5 or 0.456 from 123.456 and when you multiply that by 100, you get the number of hundredths you want to display. Then just round the result.
Update: It was pointed out you probably want ms. Just put 1000 in place of the 100.


text:
Q: Can not create an iPhone xib file with Xcode 6 The checkbox to create a .xib file in Xcode 6 seems to be disabled. I can not find any way to enable it again. Does anybody know if this is possible?

A: FYI,  you can create xib file by follow.

A: Make sure you didn't accidentally select the OS X Cocoa Class file type instead of iOS Cocoa Touch Class.
Incorrect:

Correct:

A: Creating xib files in xcode 6 is,
First of all create empty project  as,
Go to-> File > New >Project, Then select IOS >Other > Empty  then Next
After that creating a xib file as,
Go to->File >New> File then IOS > Cocoa Touch Class and then NEXT
Then select Viewcontroller and check for the "Also create XIB file" Then Next
This will create a empty project as well as xib file.

A: I had encountered this problem. Below is fix for this :

*

*Right click on files present in Project Navigator section.

*Select New File.
OR
Select File from list of tab present in Xcode
Select New -> File
OR
Simply press cmd+N

*Choose template for your new file as iOS not OS X, tvOS or watchOS.

*Select Cocoa Touch Class and then press Next

*Enter Class name and select subclass of it.

*Checkmark Also create XIB file.

*Select device type and Language and then click Next

*Click on Create and make sure that Targets is selected.


text:
Q: Swift: Toolchain download seemingly components missing On the swift website you have several options / versions to choose from, but some of the packages don't seem to include swift-build, what is the reason for this?
Notably:
Swift-2.2.1 14.04 May 3
Should be similar for the version of 15.10. It does not seem to be the case with the master-branch tar-balls.
Its actually quite relevant for me to try to stay up to date as possible, since Swift reaks of memory leaks at this point in time.

A: The release of Swift 2.2 does not include the swift package manager, as the package manager was still too early in development to include in a release version of Swift at that point. Instead, a feature was added to the package manager to allow using the version from a 3.0 toolchain with the Swift from a 2.2 toolchain, so that people could use a more recent version of the package manager.


text:
Q: boost::interprocess : Creating and inserting elements to a vector of structs (C++03) I have problem with creating vector of complex structures within boost::interprocess using msvc2008. Answers of questions asked before (links below) provides some solutions, but none of them works with msvc2008. Error type is always the same:
error: no match for 'operator=' (operand types are 'complex_data' and 'const complex_data')

Previous questions about the problem:
Shared memory Vectors in boost with
How to I create a boost interprocess vector of interprocess containers?
Suggested solutions:
http://coliru.stacked-crooked.com/a/10000376928990e2
http://coliru.stacked-crooked.com/a/3d6582c2d59015d2
Note: I know I should move to newer versions of Visual Studio. But sadly, I am currently stuck with msvc2008.

A: Without knowing your actual code, it looks as if you should perhaps add operator= for your type because MSVC is not able to generate it (?).
//Other members...
complex_data& operator=(complex_data const&) = default;

Or if the compiler doesn't take that hint, define the body the old-fashioned way:
complex_data& operator=(complex_data const& rhs) {
    id_ = rhs.id_;
    char_string_ = rhs.char_string_;
    int_vector_ = rhs.int_vector_;
    return *this;
}


text:
Q: Calculate for the standard error The instructor of a Chemistry Laboratory Class, which is composed of 10 students, asked each individual to record the time it took for a certain chemical to change its color after the third trial. The data (in minutes) were as follows: 5.18, 9.02, 13.35, 10.91, 8.57, 9.24, 10.16, 8.01, 9.33, and 11.28. What is the margin of error for the estimate at 95% confidence?
$mean = 9.505\ $ mins
$\sigma = 2.0613\ $ mins
$E = 1.96 *\frac{2.0613}{\sqrt{10}}$
$E = 1.2776$
I'm pretty sure I solved it correctly but my answer isn't in the choices on my worksheet so I want to know if I actually answered it correctly.
[edit] : added choices
2.84 minutes, 2.46 minutes, 2.87 minutes, 2.69 minutes, 2.64 minutes, 2.33 minutes, 2.61 minutes, 2.71 minutes, 2.39 minutes, 2.30 minutes, 2.50 minutes, 2.92 minutes, 2.41 minutes, 2.57 minutes, 2.79 minutes

A: Here is a way to derive a value of about 2.69 minutes.
Let $\{x_1, ..., x_{N}\}$ denote the $N = 10$ observed values. The mean is indeed
$$\bar x = \frac{\sum_{i=1}^{N} x_i}{N} = 9.505\,.$$
We don't know the variance of the population. The sample standard deviation is
$$s = \sqrt{\frac{\sum_{i=1}^{N} (x_i - \bar x)^2}{N-1}} \approx 2.172777\,.$$
Since the standard deviation of the population is unknown, we should use the $t$-distribution for calculation the confidence interval. However, you have to use the normal distribution to obtain a value of the margin of error that is present in the choices.
We compute the margin of error for a 95% confidence interval ($\alpha = .05$),
$$E = \Phi^{-1}\left(1 - \frac{\alpha}{2}\right) \frac{s}{\sqrt{N}} \approx 1.346677\,,$$
where $\Phi$ denotes the cumulative distribution function of the standard normal distribution.
As you can see, margin of error $E$ is considerably lower than the values of the choices. I suppose, you have to find the full width of the confidence interval instead:
$$2 E \approx 2.69\,.$$

R code for these calculations:
x <- c(5.18, 9.02, 13.35, 10.91, 8.57, 9.24, 10.16, 8.01, 9.33, 11.28)
N <- length(x)
mu <- mean(x)
s <- sd(x)
alpha <- 0.05
E <- qnorm(1 - alpha / 2) * s / sqrt(N)
2 * E
# [1] 2.693353


text:
Q: Xamarin - Visual Studio 2019 - Meu arquivo principal não é criado, onde este contém o [App.xaml / MainPage.xaml] e [App.xaml.cs / MainPage.xaml.cs] Olá,
Estou tendo problemas na criação do meu Projeto em Xamarin na IDE Visual Studio 2019.
Vou resumir o que acontece:
*Seleciono o Mobile App Xamarin.Forms e crio um novo projeto.
*O projeto abre normalmente sem erros, entretanto, apenas dois diretórios principais são criados, sendo respectivamente (.Android e .iOS). Desta maneira, não consigo realizar a programação do aplicativo pois não há o Diretório principal.
Segue um print da situação:

Paralelamente, também não é possível abrir arquivos .xaml (Que deveriam ser criados junto com o diretório principal).
Segue um print da situação:

Erro:`0x80004005`

Arquivo .sln do Projeto:
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31727.386
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "teste.Android", "teste.Android\teste.Android.csproj", "{F89628F2-7103-4A21-BE80-65DAB7EF852D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "teste.iOS", "teste.iOS\teste.iOS.csproj", "{14630878-9A2D-4401-9611-D91F0666E0CF}"
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|Any CPU = Debug|Any CPU
        Debug|iPhone = Debug|iPhone
        Debug|iPhoneSimulator = Debug|iPhoneSimulator
        Release|Any CPU = Release|Any CPU
        Release|iPhone = Release|iPhone
        Release|iPhoneSimulator = Release|iPhoneSimulator
    EndGlobalSection
    GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {F89628F2-7103-4A21-BE80-65DAB7EF852D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {F89628F2-7103-4A21-BE80-65DAB7EF852D}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {F89628F2-7103-4A21-BE80-65DAB7EF852D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
        {F89628F2-7103-4A21-BE80-65DAB7EF852D}.Debug|iPhone.ActiveCfg = Debug|Any CPU
        {F89628F2-7103-4A21-BE80-65DAB7EF852D}.Debug|iPhone.Build.0 = Debug|Any CPU
        {F89628F2-7103-4A21-BE80-65DAB7EF852D}.Debug|iPhone.Deploy.0 = Debug|Any CPU
        {F89628F2-7103-4A21-BE80-65DAB7EF852D}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
        {F89628F2-7103-4A21-BE80-65DAB7EF852D}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
        {F89628F2-7103-4A21-BE80-65DAB7EF852D}.Debug|iPhoneSimulator.Deploy.0 = Debug|Any CPU
        {F89628F2-7103-4A21-BE80-65DAB7EF852D}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {F89628F2-7103-4A21-BE80-65DAB7EF852D}.Release|Any CPU.Build.0 = Release|Any CPU
        {F89628F2-7103-4A21-BE80-65DAB7EF852D}.Release|Any CPU.Deploy.0 = Release|Any CPU
        {F89628F2-7103-4A21-BE80-65DAB7EF852D}.Release|iPhone.ActiveCfg = Release|Any CPU
        {F89628F2-7103-4A21-BE80-65DAB7EF852D}.Release|iPhone.Build.0 = Release|Any CPU
        {F89628F2-7103-4A21-BE80-65DAB7EF852D}.Release|iPhone.Deploy.0 = Release|Any CPU
        {F89628F2-7103-4A21-BE80-65DAB7EF852D}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
        {F89628F2-7103-4A21-BE80-65DAB7EF852D}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
        {F89628F2-7103-4A21-BE80-65DAB7EF852D}.Release|iPhoneSimulator.Deploy.0 = Release|Any CPU
        {14630878-9A2D-4401-9611-D91F0666E0CF}.Debug|Any CPU.ActiveCfg = Debug|iPhone
        {14630878-9A2D-4401-9611-D91F0666E0CF}.Debug|Any CPU.Build.0 = Debug|iPhone
        {14630878-9A2D-4401-9611-D91F0666E0CF}.Debug|Any CPU.Deploy.0 = Debug|iPhone
        {14630878-9A2D-4401-9611-D91F0666E0CF}.Debug|iPhone.ActiveCfg = Debug|iPhone
        {14630878-9A2D-4401-9611-D91F0666E0CF}.Debug|iPhone.Build.0 = Debug|iPhone
        {14630878-9A2D-4401-9611-D91F0666E0CF}.Debug|iPhone.Deploy.0 = Debug|iPhone
        {14630878-9A2D-4401-9611-D91F0666E0CF}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
        {14630878-9A2D-4401-9611-D91F0666E0CF}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
        {14630878-9A2D-4401-9611-D91F0666E0CF}.Debug|iPhoneSimulator.Deploy.0 = Debug|iPhoneSimulator
        {14630878-9A2D-4401-9611-D91F0666E0CF}.Release|Any CPU.ActiveCfg = Release|iPhoneSimulator
        {14630878-9A2D-4401-9611-D91F0666E0CF}.Release|Any CPU.Build.0 = Release|iPhoneSimulator
        {14630878-9A2D-4401-9611-D91F0666E0CF}.Release|Any CPU.Deploy.0 = Release|iPhoneSimulator
        {14630878-9A2D-4401-9611-D91F0666E0CF}.Release|iPhone.ActiveCfg = Release|iPhone
        {14630878-9A2D-4401-9611-D91F0666E0CF}.Release|iPhone.Build.0 = Release|iPhone
        {14630878-9A2D-4401-9611-D91F0666E0CF}.Release|iPhone.Deploy.0 = Release|iPhone
        {14630878-9A2D-4401-9611-D91F0666E0CF}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
        {14630878-9A2D-4401-9611-D91F0666E0CF}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
        {14630878-9A2D-4401-9611-D91F0666E0CF}.Release|iPhoneSimulator.Deploy.0 = Release|iPhoneSimulator
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
    EndGlobalSection
    GlobalSection(ExtensibilityGlobals) = postSolution
        SolutionGuid = {4542AFFA-6983-4843-99C2-413868B597F7}
    EndGlobalSection
EndGlobal


text:
Q: PHP error : count() throws Parameter must be an array or an object that implements Countable I am getting this error

count(): Parameter must be an array or an object that implements Countable

CODE
if(count($settings['cols'])>0)
{
    $settings_list[] = 'cols:[' . self::prepare_reports_settings_val($settings['cols']) . ']';
}

I am getting error in if(count($settings['cols'])>0). What should I write instead of count here?
UPDATE
all of the three answer are correct . is_array() worked and if($settings['cols']) also worked . I can't mark right all three . So I am writing here . Thank you all :-)

A: You probably don't need to count it, as $settings['cols'] is already the number you want to compare. Just compare it directly:
if ($settings['cols'] > 0) {

A: as you say count use for array and object .
first of all you should know what is the type of your variable.
so you can use
echo gettype($settings['cols']);
and see what type you have.
i think  $settings['cols'] is a number that you need .
you can use echo or var_dump to see it.
but if you want to get count of what you have you should do this:
1.arrays and objects : count()
2.for string : strlen()
3.for int : i think you dont need it

A: if(is_array($settings['cols']) && count($settings['cols'])>0)


text:
Q: Jmeter I keep getting: 'java.net.ConnectException: Connection timed out: connect'? Jmeter I keep getting: 'java.net.ConnectException: Connection timed out: connect' ?

*

*I have created a load test which tests a specific url at 200 users

*when running the load test for x1 iteration i keep seem to be getting: Connection timed outs?

*I have made the following changes listed here: https://msdn.microsoft.com/en-us/library/aa560610(v=bts.20).aspx
But the issue is still there:
[1

A: You most probably don't have access to the target host from where you test.
Did you configure proxy as your web browser is probably configured

*

*http://jmeter.apache.org/usermanual/get-started.html#proxy_server
But if failure is partial, then you server might be overloaded and rejecting some requests.

A: My expectation is that "problematic" requests are simply not able to finish in 20 seconds (most probably you have modified Connect timeout and set this value in HTTP Request or HTTP Request Defaults)
20 seconds looks like a long response time to me so your finding indicates application under test performance problem.
Going forward if you would like to see more "human readable" message in the results file switch to Duration Assertion instead of setting timeouts on protocol level

See How to Use JMeter Assertions in Three Easy Steps article for more information on conditionally failing JMeter requests.

A: Please check client configuration from where you are running your tests. It might be like your client system is not able to handle 200 threads. Do the test iteration wise means try with 10, 50 , 70 and so on. Check from which iteration onwards you are getting the error. It is also advisable not to include the listeners during load testing.
Please check the best practices for load testing using jmeter.
http://jmeter.apache.org/usermanual/best-practices.html


text:
Q: Matplotlib function animation not animating for pre-calculated data I am working on some animated scatter plots in python with matplotlib. I currently have this code:
def calulateStep():

    # Math stuff ....
    # Changes values in in 'circpos' Nx2 array

fig, ax = plt.subplots(figsize=(5, 5))
ax.set(xlim=(-WELLRADIUS,WELLRADIUS), ylim=(-WELLRADIUS,WELLRADIUS))

[x,y] = np.hsplit(circpos,2)

scat = ax.scatter(x.flatten(),y.flatten())

def animate(i):
    calculateStep()
    scat.set_offsets(circpos)
    return scat,

anim = FuncAnimation(fig, animate, frames=60)

anim.save('test2.gif',writer='imagemagick')

plt.draw()
plt.show()

The function calculateStep calculates new x,y values for the scatter. circpos contains the data array at each step. this works well and produces an animated gif ofthe scatter plot as expected. However the function is a rather slow numerical calculation and many many steps are required to produce stable output, so I would rather calculate all before and then animate only select frames. So I tried this.
results = [circpos]

for h in range(61):

    calculateStep()
    results.append(circpos)

fig, ax = plt.subplots(figsize=(5, 5))
ax.set(xlim=(-WELLRADIUS,WELLRADIUS), ylim=(-WELLRADIUS,WELLRADIUS))

[x,y] = np.hsplit(results[0],2)

scat = ax.scatter(x.flatten(),y.flatten())

def animate(i):

    scat.set_offsets(results.pop(0))
    return scat,

anim = FuncAnimation(fig, animate, frames=60)

anim.save('test2.gif',writer='imagemagick')

plt.draw()
plt.show()

However with this method the generated gif contains only the final frame of the animation. If I print the data from within the animate function I find that the correct numerical values are being popped from the results list but for some reason only the final value is there in the gif. I have also tried using results[i] rather than results.pop(0) I am at a loss to understand this behavior.

A: Well it seems I solved my own problem. When I add each iteration of the global array circpos to the results list, it is of course a shallow copy. Meaning it's just a reference to the original circpos array. So I end up with a list full of references to the same object. The print out was just me misinterpreting what I was looking at.
Instead I now add circpos.copy() to my list to get new copies of the array at each step.
This has tripped me up in Python before I realize. Still learning!


text:
Q: Math equation formats I need to store equations in a text file, in a source format that can be converted to something that can be rendered (e.g. mathML). I like the format used in OpenOffice. I don't want to use TeX, or at least I don't want to pull in all the baggage of interpreting TeX. What format does OpenOffice Equation Editor use, and are there 3rd party command-line converters that will process this format? I don't want to have to run OpenOffice every time I need to render/convert my equations.

A:
What format does OpenOffice Equation Editor use?

LibreOffice Math (and OpenOffice Math) both use MathML to represent mathematical markup.
Just save any equation using Math and simply unpack it (it is ZIP packed).
For example if you create famous [E=mc²] and save it, then in content.xml inside your .odt file you will find something like this:
<?xml version="1.0" encoding="UTF-8"?>
<math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
        <mfenced open="[" close="]"><mrow>
            <mi>E</mi><mo stretchy="false">=</mo><msup><mi mathvariant="italic">mc</mi><mn>2</mn></msup>
        </mrow></mfenced>
        <annotation encoding="StarMath 5.0">left[ E=mc^2 right]</annotation>
    </semantics>
</math>

As you see, Math stores equation in own format annotation section, but you can use plain MathML as input format.

… command-line converters that will process this format

I believe, you can use Python API for Libre (Open) Office.
You can put your own equation in annotation (in StarMath's format). Looks like Math builds equation based on how it is represented in annotation and the rest of MathML file is just for representation/compatibility.
If MathML doesn't look like made from StartMath it will propose to "repair"
 the file and it will work just fine after this.

A: I assume you want to know about the math commands for OpenOffice Math. The commands are proprietary, and there don't seem to be any 3rd party converters.
You can use tex without pulling in the whole tex compilation system. I use the javascript library mathJax to render directly. If you want to convert to an intermediate format such as mml and then render later, you can use a library such as SnuggleTeX for Java.

A: The syntax in OpenOffice Math is based on eqn, which is much more readable than LaTeX. If you store equations as eqn code, you can render them very quickly with troff or convert to LaTeX and render that way. Troff's rendering of math is not quite as nice as LaTeX's, but troff is much more lightweight.

A: The format for StarMath is documented in the LibreOffice 4.4 Math Guide. Appendix A contains the Command Reference.


text:
Q: Meaning of these terms - Simulation of vector control (FOC) of induction motor? I'm having hard time doing simulation of vector control for 3 phase asynchronous machine. I was studying MATLAB - Simulink simulations available already on MathWorks site but I couldn't understand that what certain terms mean.

*

*1e-3 was added in denominator for following two equations.
As you can see the equations written below model by author himself gives no clue as why 1e-3 is there. And this is not the only one simulation which has this term here. Even Mathwork's site has this term as can be seen from this page.
But I couldn't find any documentation as from where does it comes. Is it because they want to ensure there won't be division by 0? But then isn't 1e-3 quite larger term? This was wild guess ...

*The last block in previous figure (K*Ts/(z-1)) shows discrete time integrator right? But what is the difference between that integrator and one shown below (it is PI Torque controller) and what is its significance? Note that this is also part of the same page linked above.

Thanks in advance.


text:
Q: Faster way than mapply function in R I recently asked a question for which I got a useful answer but the following code runs very slowly considering my big dataset (14K rows).
How can I make this faster using mcmapply like here?
this is the code:
within(df,
  count <- mapply(function(x, y) {
    in5year <- paste(animals.2[year %in% (x-4):x], collapse = "; ")
    sum(strsplit(in5year, "; ")[[1]] %in% strsplit(y, "; ")[[1]])
  }, year, animals.1)
)

A: A solution using parallel.  Used mclapply instead of mcmapply as it was a little faster.
library(parallel)
library(dplyr)
library(microbenchmark)

df = data.frame(animals.1 = c("cat; dog; bird", "dog; bird", "bird", "dog"),
                animals.2 = c("cat; dog; bird","dog; bird; seal", "bird", ""),
                stringsAsFactors = F)

df <- replicate(10000,{df}, simplify=F) %>% do.call(rbind, .)
df$year <- seq(2000,2000 + nrow(df) - 1)

st_func <- function(df) {
  within(df,
         count <- mapply(function(x, y) {
           in5year <- paste(animals.2[year %in% (x-4):x], collapse = "; ")
           sum(strsplit(in5year, "; ")[[1]] %in% strsplit(y, "; ")[[1]])
         }, year, animals.1)
  )
}

mc_func <- function(df) {
  df$count <- mclapply(1:nrow(df), function(i) {
    x <- df$year[i]
    y <- df$animals.1[i]
    in5year <- paste(df$animals.2[df$year %in% (x-4):x], collapse = "; ")
    sum(strsplit(in5year, "; ")[[1]] %in% strsplit(y, "; ")[[1]])
  }, mc.cores=4) %>% unlist
  return(df)
}

identical(mc_func(df), st_func(df)) # TRUE

microbenchmark(mc_func(df), st_func(df), times=5)

Unit: seconds
        expr       min        lq      mean   median        uq      max neval cld
 mc_func(df)  8.588759  8.637135  9.101409  8.91779  8.924929 10.43843     5  a
 st_func(df) 30.090307 30.107282 30.440877 30.45653 30.696706 30.85356     5   b


text:
Q: Gateway between wireless network and wired network not routing packets I have the following interfaces/routes :

# ip route show
192.168.101.0/24 dev eth0  proto kernel  scope link  src 192.168.101.10
192.168.8.0/24 dev tun0  proto kernel  scope link  src 192.168.8.1
default via 192.168.101.251 dev eth0

Device eth0 is connected to a network with a gateway (192.168.101.251).
My clients are behind an access point (with some hotspot software) which is connected to tun0:
clients -> tun0 -> gateway -> eth0 -> internet

I can ping an internet host from eth0 but my clients behind the hotspot can't access internet through tun0.
How do I route packets from tun0 to internet (and back) ?

A: You need to enable ip_forward on the gateway:
sysctl net.ipv4.ip_forward=1

and masquerade your clients:
# /sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# /sbin/iptables -A FORWARD -i tun0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
# /sbin/iptables -A FORWARD -i tun0 -o eth0 -j ACCEPT

You also need to set your clients to use the IP of tun0 as their default gateway.

A: You must route default gateway for 0.0.0.0 to tun0
For example:
route add -net default gw 192.168.101.251 dev tun0

might works for you. May be you have to remove default GW for eth0
route del -net default gw 192.168.101.251 dev eth0

This will routes all internet traffic over tun0 device.
If you add these two lines in to end of /etc/network/interfaces file, it runs on system boot..


text:
Q: Writing a loop to create multiple dataframes and rasters from a SpatialPointsDataFrame I am working with a large SpatialPointsDataFrame that consists of animal tracking data. The SpatialPointsDataFrame has 19 animal id's, and for each animal, there is a series of xy coordinates. For each animal, I am assigning the xy coordinates to a raster grid, and then calculating the proportion of time the animal spends in each grid square.
I have taken a subset of the SpatialPointsDataFrame (eg. 1 animal) and written a series of functions that accomplishes this goal. I would now like to write a loop that will do the exact same procedure for every other animal id in my SpatialPointsDataFrame.
My SpatialPointsDataFrame (called "spdf4points") has two data attributes: "date" (which isn't relevant to my problem) and "id"
table(spdf4points$id)
15K12    28   31A    34    46    72    73   73e    78    96   96b    99   99b    C1   C17    M1  M16c  M17a    M7

This is my code for calculating the proportion of time spent in each grid cell for animal 15K12:
#15K12 is the first animal id
r15K12<-raster(chla) #creating an empty raster for 15K12 based on the extent and resolution of a different raster layer
r15K12[] <- 0

table15K12<-table(cellFromXY(r15K12, subset(spdf4points, id=="15K12")))
tab15K12<-as.data.frame(table15K12)
tab15K12$Freq<-tab15K12$Freq/sum(tab15K12$Freq)
r15K12[as.numeric(names(table15K12))]<-table15K12

How could I write a loop to repeat this for every other animal?
My desired output is both a raster and dataframe for each animal.
So, I would I would like to first create the empty raster for each animal id. So I would like to repeat the following line of code for every animal id.
r15K12<-raster(chla)
#r[animalID]

I would then like to repeat the next chunk of code for every animal id to 1) populate the raster with the data for that animal and 2) create the dataframe for that animal
table15K12<-table(cellFromXY(r15K12, subset(spdf4points, id=="15K12")))
tab15K12<-as.data.frame(table15K12)
tab15K12$Freq<-tab15K12$Freq/sum(tab15K12$Freq)
r15K12[as.numeric(names(table15K12))]<-table15K12

Note, this chunk of code would use the empty raster created for that animal, and the subset of spdf4point corresponding to that animal ID

A: Possibly I don't fully understand you question, but I see no problems with the solution of putting info into lists. Check out http://www.r-tutor.com/r-introduction/list
rasters = list()
data_frames = list()
for (i in 1:length(spdf4points$id)){
   animal_id = spdf4points$id[i]
   rasters[[animal_id]] <- raster(chla)
   rasters[[animal_id]][] <- 0
   animal_tab <- table(cellFromXY(r15K12, subset(spdf4points, id==animal_id)))
   #adds a field to the list of data frames
   animal_tab <- as.data.frame(animal_tab)
   animal_tab$Freq <- animal_tab$Freq/sum(animal_tab$Freq)
   data_frames[[animal_id]] <- animal_tab
   rasters[[animal_id]][as.numeric(names(animal_tab))] <- animal_tab
}

You can then rbind the list or do more with it. Can't figure out anything else, as the setup is still mildly confusing to me.

A: ids=unique(spdf4points$id)
all_rasters <- list()
all_dfs <- list()
for (i in ids){
   loopraster <- tempraster #tempraster is the empty raster of desired extent and resolution
   tablepoints<-table(cellFromXY(tempraster, subset(spdf4points, id==i)))
   dfpoints<-as.data.frame(tablepoints)
   dfpoints$Freq<-dfpoints$Freq/sum(dfpoints$Freq)
   loopraster[as.numeric(names(tablepoints))]<-tablepoints
   all_rasters[[i]] <- loopraster
   all_dfs[[i]] <- dfpoints
   print(i)
}


text:
Q: How do you implement a 2D Array in NASM I am trying to figure out how to print out both rows and columns of an array. The program asks how many rows and columns and depending on user input it would display "Enter a number for [0][0]" "Enter a number for [0][1]" and etc.
Here is what I have written so far:
%include "io.inc"

SECTION .data              ; Data section, initialized variables
num_rows db "How many rows?: ",0
num_col db "How many columns?: ",0
prompt db "Enter a number for [%d][%d]:",10,0

sum db "The sum is: ",10,0
number db "%d",10,0

rows times 4 dd "%d",0
col times 4 dd "%d",0

arrayLen dd 9 ; length of array

;size equ rows*col

formatin db "%d", 0

section .bss
array resd 6; this is a test array for testing purposes

SECTION .text               ; Code section.

global CMAIN             ; the standard gcc entry point
extern    printf ,scanf

CMAIN:                   ; the program label for the entry point

;-----Ask for the number of rows and display
push num_rows
call printf
add esp,4 ;remove the parameter

push rows ;address of rows
push formatin ;arguments are right to left
call scanf
add esp,8
;move the values into the registers
mov ebp,[rows]

push ebp
push number
call printf
add esp,8

;----Ask for the number of cols and display
push num_col
call printf
add esp,4

push col
push formatin
call scanf
add esp,8

;move the values into the registers
mov ebx, [col]

push ebx
push number
call printf
add esp,8

mov ebp,array

push ecx
push number
call printf
add esp,8

mov ecx,0
xor ebp,ebp

outerLoop:
  mov edx,ecx
  push ecx
  mov ecx,0
inner:
  push ecx

  ;output
  push ecx
  push edx
  push prompt
  call printf
  add esp,12

  ;Get addr
  push ecx
  push edx
  push esi
  ;call GetElement
  add esp,12

  ;input
 push eax
 push number
 call scanf
  add esp,8

  pop  ecx
  inc ecx
  cmp ecx,[col]
  jl inner
  pop ecx

end_outer:
 inc ecx
 cmp ecx,[rows]
 jl outerLoop

push sum
call printf
add esp,4

 xor ebp,ebp <- My professor told me never to use this
 ret

;GetElement: THIS WHOLE SUBPROGRAM IS COMMENTED

;    mov ebx,[ebp+8] ;addr of array
;   mov ecx,[ebp+12] ;row
;  mov esi,[ebp+16] ;col

; mov eax,ecx
;  mul dword [col]
;  add eax,esi
;  imul eax,4
;  add eax,ebx
;  leave
;  ret

When I run the code the indexes [rows][cols] do not print correctly. Can someone guide me?

A: Your problem has nothing to do with accessing array elements - your logic is correct (although imul eax,4 is a bad idea and should be replaced by a shl eax,2 or lea eax,[eax*4] or lea eax,[ebx+eax*4], because the offset in the array is not a signed value and it's faster to avoid this multiplication).
Instead; your problem is that C calling conventions are nasty. They pollute the code with lots of extra instructions to manipulate the stack that make it harder to read and debug the code; and optimizing it (e.g. using sub esp, ... to reserve space for the max. parameters you want to pass to any child function and mov [rsp+ ...], ... instead of push ... to set parameters before calling a child function) is painful; and the whole thing ends up being an error prone and slow mess (that is unnecessary for assembly unless you're calling functions compiled by a C compiler).
More specifically; for your GetElement, you're using ebp as stack frame but not setting up ebp as the stack frame, so when the function tries to get the parameters from the stack into registers the function doesn't get the parameters from the right location.
To actually comply with C calling conventions (CDECL), it would want to be more like:
GetElement:
    push ebp
    mov ebp,esp            ;Set up ebp as stack frame

    push ebx               ;ebx is "callee preserved" (not "caller saved") and is modified, so it must be saved/restored
    push esi               ;esi is "callee preserved" (not "caller saved") and is modified, so it must be saved/restored

    mov ebx,[ebp+3*4+4]    ;addr of array
    mov ecx,[ebp+3*4+4+4]  ;row
    mov esi,[ebp+3*4+4+8]  ;col

    mov eax,ecx
    mul dword [col]
    add eax,esi
    lea eax,[ebx+eax*4]

    pop esi
    pop ebx

    leave
    ret

Ironically, for your code the parameters are already in registers - the only caller is doing this:
    push ecx         ;col
    push edx         ;row
    push esi         ;address of array
    call GetElement
    add esp,12

..which means that (if you forget about C calling conventions) your GetElement could be like this (10 unnecessary instructions deleted):
;Inputs:
; ecx = column
; edx = row
; esi = address of array
;
;Outputs:
; eax = address of element in the array
;
;Trashed:
; edx

GetElement:
    mov eax,edx
    mul dword [col]
    add eax,ecx
    lea eax,[esi+eax*4]
    ret

..and the calling code could be like this (4 unnecessary instructions deleted):
    call GetElement


text:
Q: how to create a copy of a table in HBase on same cluster? or, how to serve requests using original state while operating on a working state Is there an efficient way to create a copy of table structure+data in HBase, in the same cluster?  Obviously the destination table would have a different name.  What I've found so far:

*

*The CopyTable job, which has been described as a tool for copying data between different HBase clusters.  I think it would support intra-cluster operation, but have no knowledge on whether it has been designed to handle that scenario efficiently.

*Use the export+import jobs.  Doing that sounds like a hack but since I'm new to HBase maybe that might be a real solution?
Some of you might be asking why I'm trying to do this.  My scenario is that I have millions of objects I need access to, in a "snapshot" state if you will.  There is a batch process that runs daily which updates many of these objects.  If any step in that batch process fails, I need to be able to "roll back" to the original state.  Not only that, during the batch process I need to be able to serve requests to the original state.
Therefore the current flow is that I duplicate the original table to a working copy, continue to serve requests using the original table while I update the working copy.  If the batch process completes successfully I notify all my services to use the new table, otherwise I just discard the new table.
This has worked fine using BDB but I'm in a whole new world of really large data now so I might be taking the wrong approach.  If anyone has any suggestions of patterns I should be using instead, they are more than welcome.  :-)

A: All data in HBase has a certain timestamp.  You can do reads (Gets and Scans) with a parameter indicating that you want to the latest version of the data as of a given timestamp.  One thing you could do would be to is to do your reads to server your requests using this parameter pointing to a time before the batch process begins.  Once the batch completes, bump your read timestamp up to the current state.
A couple things to be careful of, if you take this approach:

*

*HBase tables are configured to store the most recent N versions of a given cell.  If you overwrite the data in the cell with N newer values, then you will lose the older value during the next compaction.  (You can also configure them to with a TTL to expire cells, but that doesn't quite sound like it matches your case).

*Similarly, if you delete the data as part of your process, then you won't be able to read it after the next compaction.

So, if you don't issue deletes as part of your batch process, and you don't write more versions of the same data that already exists in your table than you've configured it to save, you can keep serving old requests out of the same table that you're updating.  This effectively gives you a snapshot.


text:
Q: how to manage content using php and mysql Can someone give me info about how to manage contents like post, in a website. Can I store post contents in mysql and retrieve them, or do I have to do something different.
I am making a website where user can post their articles. So to implement that can I use mysql as my database and php to process the information and show it on website.
One more thing I am confused about how to generate links to those articles dynamically, like
 http://www.example.com/first-article.php
http://www.example.com/second-article.php
So are these files like first-article.php going to be created in my website folder. If so isn't it going to create mess after some years, when you will be having like 10,000 post so that means 10,000 php files.
I don't want to use content management systems like joomla, drupal or wordpress. Please guide me how to implement those above mentioned.

A: First you'll need to create a table to store all your data.
Let's do something like that to begin :
articles
--------
id_article (integer) (auto_increment) (primary key)
title (varchar 250)
author (varchar 250)
date (date)
content (text)

You can create this table easily in your favorite database management tool.
If you don't have any, I highly recommend [mysql workbench][1] which is awesome (You may consider using a good tool from the beginning, not that shitty phpMyAdmin...).
id_article is a number which will help you to identify your articles.
You don't have to set it, it starts from 1, and will auto increment.
Then let's focus on the php script.
I suggest 3 : articles.php to display all articles, article_detail.php to display one full article, and article_edit.php to edit an article.
Note that I won't give you php code otherwise you may not learn a lot. I'll just give you pseudo-code, let me know if you are stuck and need help.
//articles.php  //<---this is a comment
//first let's prepare a basic html page

        <title>Article list</title>

Articles list :

<?php
//connect to mysql server + select database using [mysqli][2]
//execute the following query : "Select * from articles" with [mysqli_query][3]
//loop on your resultset using while and [mysqli_fetch_array()][4]
    //in your loop, echo the

 that will populate your

    //Note, to create the links use : echo "".$row['title']."";
?>

There is our first script.
You can try it by manually creating some rows in the table articles
//article_detail.php
//Note that there isn't much new in there
//First your html

        <title>Article detail</title>

<?php
//a new thing are the http variables.
//we will be using [$_GET][5]
$id_article = (int) $_GET['id_article']; //remember to cast your integers as int in order to prevent SQL Injection
//connect to the database.
//use mysqli_query to execute : "Select * from articles where id_article='$id_article'"
//use fetch_array() to get the row.
//display the row the way you want using html.

Once you have tested this, you can move on the final script.
This one will take an integer as $_GET parameter : 'id_article' (if there is no parameter then we will have to create a new article using mysql.
And it will also optionnaly take a $POST parameter with title, author and content.
//article_edit.php
<title>Edit an article</title>

<?
if(count($_POST)){
//POST request, get the parameters from it, and update the row using $_GET['id_article']
//remember to use htmlentities() and addslashes() on author, title and content, so your script is bullet-proof to XSS and SQL Injection
echo "
Article updated!
";
}
if(isset($_GET['id_article'])){
    //We are editing an existing article : gather its content for edition
}else{
    //New article, create an empty row, and select it.
}
//after this if statement you should have '$id_article' and an array '$article' which contains the article data

?>

<form method='post' action='./article_edit.php?id_article=<?=$id_article?>'>
Author : <input size='50' name='article_author' value='<?=$article['author']?>'/>

Title  : <input size='100' name='article_title' value='<?=$article['title']?>'/>

Content : <textarea name='article_content'><?=$article['content']?></textarea>

<input type='submit' value='Send'/>
</form>

There you go.
A good php function, if I could name a friendly one, is [var_dump()][6], it basically shows you the content of variables. Very good tool.
What to do next ?
-Save the creation date of the article.
-Use include and centralize your common source code (eg : mysql_connect, html headers...)
-Add a login page, and authorize editing only to members.
-Install a text editor like tiny_mce for editing articles.
-...
Have fun.
1: http://dev.mysql.com/downloads/tools/workbench/
2: http://php.net/manual/en/mysqli.construct.php
3: http://php.net/mysqli_query
4: http://php.net/manual/en/mysqli-result.fetch-array.php
5: http://php.net/manual/en/reserved.variables.get.php
6: http://php.net/manual/en/function.var-dump.php

A: While i agree that the question is quite broad, perhaps a look at a PHP Framework like Laravel may help you http://laravel.com.

A: Yes you can use php and mysql to implement your desired system.
What you can do is create a table in the mysql database for your posts like tbl_articles that holds all your data relating to an article such as its id, title, content, date, etc.
Next you can create a php page such as display_article.php that displays each article based on the id provided in the url. Then your url can be in the form http://example.com/display_article.php/first-article
This is just a suggestion. There can be other better methods to do it.
Hope it helps.

A: "I don't want to use content management systems like joomla, drupal or wordpress. Please guide me how to implement those above mentioned."
What you are describing is essentially writing your own CMS. You need to learn PHP and MySQL at a level higher that you have right now. "How to write my own CMS" is probably too large of a question for SO.
There's a few guides on the web that might be better suited for what you are doing. Try:
[http://css-tricks.com/php-for-beginners-building-your-first-simple-cms/][1]
[http://www.elated.com/articles/cms-in-an-afternoon-php-mysql/][2]

Please vote. =)


text:
Q: Recent Apps on UiAutomator I am now working with Android UiAutomator on for UI Test on my Android app. My app has a function that requires the user to verify the email to continue, so I try to do it like this: after reach to that function -> getUiDevice.pressHome -> Browser -> try to log in email -> PressHome again -> Press RecentApps then I stuck here, I cannot press on my Apps to return to it again. I try another way by clicking on my App icon but it starts my app again, not at the state before. Can anyone suggest me a solution for this? Any help is appreciate.
Thanks in advance.

A: Try this :
UiObject appBackground = new UiObject(new UiSelector().description("ABC"));
appBackground.click();

It did not show any description through 'uiautomatorviewer' command but this worked for me.

A: I could manage to create this behavior with:
fun backgroundAndForeground() {
    val device = UiDevice.getInstance(getInstrumentation())
    device.pressHome()
    // Pressing app switch two times makes the last app put on background come to foreground.
    device.pressKeyCode(KeyEvent.KEYCODE_APP_SWITCH)
    device.pressKeyCode(KeyEvent.KEYCODE_APP_SWITCH)
}

A: In this case, I think that android only resume app when clicking the recent app image. It does not work on clicking display text or app icon. So, we need to click image of your app in recent app list. At that time you need to write as below. I always do that for similar case.
// Take all image view by class type and click by instance no.
new UiObject(new UiSelector().className("android.widget.ImageView").instance(3)).click();

You need to count instance no of your recent app image view. Not app icon image in recent app scroll view. Please try this. Thanks.

A: I've spent half a day on this and concluded I needed to issue a device.click(). Since my use-case is that my app was the last one running (not switching to the browser like you), I can safely click the middle of the screen and it'll always work.
If you're the 2nd to last running app, you can probably do x: 0 and y: device.displayHeight/2.
I've not tested this on many operating systems, only 9.


text:
Q: Perl: Reset $1 variable I have a subroutine that works on the first time it is called but on the second time, if the URL is not valid, it uses the previous value of $1. Is there a simple way to rest the value of $1 or to be equal to a NULL value?
Edit: Here is my code
our %hash;
sub GetOnce{
    $mech->get($_[0]);
    $val = $mech->content;
    $val =~ /value="(.*?)"/;
    if($1 ne "") {$hash{$_[1]} = $1;}
}
GetNonce("http://URL1", "VAR1"); #Valid URL
GetNonce("http://URL2", "VAR2"); #Timesout

I just want to reset the value for Error Handling. I.e. if URL1 is valid but URL2 is invalid or timesout, then $1 will be the same for both of them. If URL1 is invalid/timesout and URL2 is valid, then only the $1 from URL2 is saved. And if they're both valid, then the program stores each of their $1's.

A: I'd suggest not using $1, and instead:
my ( $match ) = ( $val =~ m/value="(.*?)"/ );

Useful feature of pattern matching like this - in a scalar context, it's a 'true/false' but in a list context, it returns a list of matches. Which you can then assign to individual scalars.
So anyway - $match is undef if the match fails, and whatever is in the match if it worked. You should make a point of using defined to test this though, because if the value in $match is 0 or '' it'll evaluate false, despite having worked.
E.g.:
our %hash;
sub GetOnce{
    my ( $url, $key ) = @_;
    $mech->get($url);
    my ( $match ) = ( $mech -> content =~ m/value="(.*?)"/ );
    #may not need to test it -  you could just have an undef value.
    if ( defined $match ) { $hash{$key} = $match };
}

A: You should test the regex match itself, rather than the value of the captures. It is also best to name the values in @_, and to use a complementary character class instead of a non-greedy match in your regex.
Like this
our %hash;

sub get_once {
    my ($url, $key) = @_;
    $mech->get($url);
    my $content = $mech->content;
    $hash{$key} = $1 if $content =~ /value="([^"]*)"/;
}


text:
Q: Problem with ASMX and SPContext.Current equals to null I'm deploying my application to an Sharepoint Foundation Farm... In my application there is a web service (tt2sp.asmx) installed in the _vti_bin directory.
On my site the anonymous access is disabled.
When i try to get SPContext.Current it always return me NULL..
Where is the problem? I tried to deploy also in _layouts but the problem was the same..
I checked the web.config looking for anonimous access allows, but seems allright..
Any suggestion?
Thank you very much!


text:
Q: 'wb' vs 'w' in Unix for Python Many posts that considered there's no difference between wb and w in Unix environments, e.g. Python file IO 'w' vs 'wb' [duplicate]. But mine works the opposite.
The environment is Ubuntu 16.04 and Python 2.7.13. Executing the following code
from __future__ import print_function

log = open("output.txt", "w")
print('{:02d} {} {} {} {} {}'.format(
                queryID,
                "Q0",
                match[0], # filename
                rank,
                match[1], # score
                config.MY_NAME
            ), file = log)

Got error:
TypeError: write() argument 1 must be unicode, not str

Then I tried to replace with wb, problem solved, no more error
log = open("output.txt", "wb")

Could anyone help explain what's going on here?


text:
Q: Debugging OOM Exit Code 137 on circleci Linux 4GB RAM instance We have tests that run on an 8GB RAM instance with no problems but when downgrading to 4GB, the tests abruptly stop and exit with code 137. I ssh'd into the instance and followed the output of top but the %MEM used does not go above 5%.
The tests run fine locally using no where near even 1GB RAM as well. Could the number of vCPUs be an issue?
https://circleci.com/docs/2.0/configuration-reference/#resource_class
~$ dmesg | grep -i oom
[97139.572780] node invoked oom-killer: gfp_mask=0x24000c0, order=0, oom_score_adj=0
[97139.572824]  [<ffffffff8118a335>] oom_kill_process+0x205/0x3d0
[97139.572833]  [<ffffffff811f431d>] mem_cgroup_oom_synchronize+0x30d/0x330
[97139.573080] [ pid ]   uid  tgid total_vm      rss nr_ptes nr_pmds swapents oom_score_adj name
[107600.844934] postgres invoked oom-killer: gfp_mask=0x24000c0, order=0, oom_score_adj=0
[107600.844978]  [<ffffffff8118a335>] oom_kill_process+0x205/0x3d0
[107600.844984]  [<ffffffff811f431d>] mem_cgroup_oom_synchronize+0x30d/0x330
[107600.845178] [ pid ]   uid  tgid total_vm      rss nr_ptes nr_pmds swapents oom_score_adj name

Someone on ##linux recommended this command which I'm not sure how to parse.
Otherwise what are the steps one should take to debug this?
If this helps this is a scala play app with these options.
  SBT_OPTS: "-Xmx2G -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -Xss2M -Duser.timezone=GMT"
  JAVA_OPTS: "-Xmx2G -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -Xss2M -Duser.timezone=GMT"


text:
Q: woocommerce - change the html of products in category product's html looks like this:

abc

        15.86 €

        Buy

Is it possible to move the price next to the button?

abc

        Buy
        15.86 €

The only way I have found out it that I should edit core of the plugin, which is useless because I will loose all changes after updates.
Edit: for example this theme, they have this structure:

Yellow Necklace

            £19.00

A: You can override a template file and that will not be updated when you update woocommerce.
From the WooCommerce docs

Alternatively, you can edit these files in an upgrade safe way through
  overrides. Simply copy it into a directory within your theme named
  /woocommerce, keeping the same file structure.
Example: To overide the admin order notification, copy:
  woocommerce/templates/emails/admin-new-order.php to
  yourtheme/woocommerce/emails/admin-new-order.php


text:
Q: Segmentation fault at linking miniruby I tried to install Ruby 2.0.0dev (2011-12-15 trunk 34025) on Mac OSX Lion (10.7.2).
But I got 'Segmentation Fault' at linking miniruby.
The sequence I've tried is following:
$ autoconf
$ ./configure --prefix=$HOME/tmp/ruby --enable-shared
(snip)
$ make
(snip)
compiling dmyext.c
linking miniruby
<internal:prelude>:1: [BUG] Segmentation fault
ruby 2.0.0dev (2011-12-15 trunk 34025) [x86_64-darwin11.2.0]

-- Control frame information -----------------------------------------------
c:0003 p:0002 s:0006 b:0006 l:000005 d:000005 TOP    <internal:prelude>:1
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:001248 d:001248 TOP

-- Ruby level backtrace information ----------------------------------------
<internal:prelude>:1:in `<compiled>'

-- C level backtrace information -------------------------------------------

   See Crash Report log file under ~/Library/Logs/CrashReporter or
   /Library/Logs/CrashReporter, for the more detail of.

-- Other runtime information -----------------------------------------------

* Loaded script: ./miniruby

* Loaded features:

    0 enumerator.so

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

make: *** [.rbconfig.time] Abort trap: 6

And I've got the CrashReport like this:
Process:         miniruby [3571]
Path:            /Users/USER/*/miniruby
Identifier:      miniruby
Version:         ??? (???)
Code Type:       X86-64 (Native)
Parent Process:  gnumake [1617]

Date/Time:       2011-12-16 13:47:24.753 +0900
OS Version:      Mac OS X 10.7.2 (11C74)
Report Version:  9
Sleep/Wake UUID: 0A0C0C42-7935-495E-AE81-F7C6C21A4599

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_BAD_ACCESS (SIGABRT)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000841f0f

VM Regions Near 0x841f0f:
-->
    __TEXT                 000000010dd7e000-000000010df64000 [ 1944K] r-x/rwx SM=COW  /Users/USER/*

Application Specific Information:
objc[3571]: garbage collection is OFF
abort() called

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff94d22ce2 __pthread_kill + 10
1   libsystem_c.dylib               0x00007fff95c8a7d2 pthread_kill + 95
2   libsystem_c.dylib               0x00007fff95c7ba7a abort + 143
3   miniruby                        0x000000010ddae079 rb_bug + 185
4   miniruby                        0x000000010de5cc8c sigsegv + 76 (signal.c:592)
5   libsystem_c.dylib               0x00007fff95cdccfa _sigtramp + 26
6   miniruby                        0x000000010deb4ef0 vm_exec_core + 2976 (vm_insnhelper.c:1144)
7   miniruby                        0x000000010dec04be vm_exec + 94 (vm.c:1218)
8   miniruby                        0x000000010dec03f1 rb_iseq_eval + 401 (vm.c:1444)
9   miniruby                        0x000000010de581d8 ruby_process_options + 1432 (ruby.c:1098)
10  miniruby                        0x000000010ddb24f0 ruby_options + 128 (eval.c:73)
11  miniruby                        0x000000010dd7eac7 main + 71 (main.c:38)
12  miniruby                        0x000000010dd7ea74 start + 52

Thread 1:
0   libsystem_kernel.dylib          0x00007fff94d22df2 __select + 10
1   miniruby                        0x000000010decfd9c thread_timer + 380 (thread_pthread.c:1164)
2   libsystem_c.dylib               0x00007fff95c888bf _pthread_start + 335
3   libsystem_c.dylib               0x00007fff95c8bb75 thread_start + 13

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x0000000000000006  rcx: 0x00007fa48309c338  rdx: 0x0000000000000000
  rdi: 0x0000000000000303  rsi: 0x0000000000000006  rbp: 0x00007fa48309c360  rsp: 0x00007fa48309c338
   r8: 0x00007fff7b01afb8   r9: 0x00007fa48309c1e8  r10: 0x00007fff94d22d0a  r11: 0xffffff80002d8220
  r12: 0x000000010e200028  r13: 0x00007fa482c0d2d0  r14: 0x00007fff7b01d960  r15: 0x000000010e2fff50
  rip: 0x00007fff94d22ce2  rfl: 0x0000000000000246  cr2: 0x000000010dec6b80
Logical CPU: 0

Binary Images:
       0x10dd7e000 -        0x10df63ff7 +miniruby (??? - ???) <584607C5-64CE-3DB6-B848-3E915D864EF4> /Users/USER/*/miniruby
    0x7fff6d97e000 -     0x7fff6d9b2ac7  dyld (195.5 - ???) <4A6E2B28-C7A2-3528-ADB7-4076B9836041> /usr/lib/dyld
    0x7fff8aa13000 -     0x7fff8aa18ff7  libsystem_network.dylib (??? - ???) <5DE7024E-1D2D-34A2-80F4-08326331A75B> /usr/lib/system/libsystem_network.dylib
    0x7fff8aa81000 -     0x7fff8aa86fff  libcompiler_rt.dylib (6.0.0 - compatibility 1.0.0) <98ECD5F6-E85C-32A5-98CD-8911230CB66A> /usr/lib/system/libcompiler_rt.dylib
    0x7fff8b8f3000 -     0x7fff8b92eff7  libsystem_info.dylib (??? - ???) <9C8C2DCB-96DB-3471-9DCE-ADCC26BE2DD4> /usr/lib/system/libsystem_info.dylib
    0x7fff8be12000 -     0x7fff8be54ff7  libcommonCrypto.dylib (55010.0.0 - compatibility 1.0.0) <A5B9778E-11C3-3F61-B740-1F2114E967FB> /usr/lib/system/libcommonCrypto.dylib
    0x7fff8c00b000 -     0x7fff8c015ff7  liblaunch.dylib (392.18.0 - compatibility 1.0.0) <39EF04F2-7F0C-3435-B785-BF283727FFBD> /usr/lib/system/liblaunch.dylib
    0x7fff8c1b8000 -     0x7fff8c1c3ff7  libc++abi.dylib (14.0.0 - compatibility 1.0.0) <8FF3D766-D678-36F6-84AC-423C878E6D14> /usr/lib/libc++abi.dylib
    0x7fff8c9cb000 -     0x7fff8c9ccff7  libremovefile.dylib (21.0.0 - compatibility 1.0.0) <C6C49FB7-1892-32E4-86B5-25AD165131AA> /usr/lib/system/libremovefile.dylib
    0x7fff8ddc0000 -     0x7fff8ddc4fff  libmathCommon.A.dylib (2026.0.0 - compatibility 1.0.0) <FF83AFF7-42B2-306E-90AF-D539C51A4542> /usr/lib/system/libmathCommon.A.dylib
    0x7fff8e164000 -     0x7fff8e164fff  libkeymgr.dylib (23.0.0 - compatibility 1.0.0) <61EFED6A-A407-301E-B454-CD18314F0075> /usr/lib/system/libkeymgr.dylib
    0x7fff90298000 -     0x7fff902a0fff  libsystem_dnssd.dylib (??? - ???) <7749128E-D0C5-3832-861C-BC9913F774FA> /usr/lib/system/libsystem_dnssd.dylib
    0x7fff90865000 -     0x7fff90869fff  libdyld.dylib (195.5.0 - compatibility 1.0.0) <F1903B7A-D3FF-3390-909A-B24E09BAD1A5> /usr/lib/system/libdyld.dylib
    0x7fff9086a000 -     0x7fff9086bfff  libunc.dylib (24.0.0 - compatibility 1.0.0) <C67B3B14-866C-314F-87FF-8025BEC2CAAC> /usr/lib/system/libunc.dylib
    0x7fff90eb1000 -     0x7fff90f95def  libobjc.A.dylib (228.0.0 - compatibility 1.0.0) <C5F2392D-B481-3A9D-91BE-3D039FFF4DEC> /usr/lib/libobjc.A.dylib
    0x7fff91a7b000 -     0x7fff91af0ff7  libc++.1.dylib (19.0.0 - compatibility 1.0.0) <C0EFFF1B-0FEB-3F99-BE54-506B35B555A9> /usr/lib/libc++.1.dylib
    0x7fff91e72000 -     0x7fff91e9ffe7  libSystem.B.dylib (159.1.0 - compatibility 1.0.0) <095FDD3C-3961-3865-A59B-A5B0A4B8B923> /usr/lib/libSystem.B.dylib
    0x7fff91ec9000 -     0x7fff91ecafff  libsystem_sandbox.dylib (??? - ???) <8D14139B-B671-35F4-9E5A-023B4C523C38> /usr/lib/system/libsystem_sandbox.dylib
    0x7fff91fd8000 -     0x7fff9204bfff  libstdc++.6.dylib (52.0.0 - compatibility 7.0.0) <6BDD43E4-A4B1-379E-9ED5-8C713653DFF2> /usr/lib/libstdc++.6.dylib
    0x7fff935ff000 -     0x7fff93605fff  libmacho.dylib (800.0.0 - compatibility 1.0.0) <D86F63EC-D2BD-32E0-8955-08B5EAFAD2CC> /usr/lib/system/libmacho.dylib
    0x7fff93c9d000 -     0x7fff93ca6ff7  libsystem_notify.dylib (80.1.0 - compatibility 1.0.0) <A4D651E3-D1C6-3934-AD49-7A104FD14596> /usr/lib/system/libsystem_notify.dylib
    0x7fff93fee000 -     0x7fff93ffcfff  libdispatch.dylib (187.7.0 - compatibility 1.0.0) <712AAEAC-AD90-37F7-B71F-293FF8AE8723> /usr/lib/system/libdispatch.dylib
    0x7fff943d6000 -     0x7fff943ddfff  libcopyfile.dylib (85.1.0 - compatibility 1.0.0) <172B1985-F24A-34E9-8D8B-A2403C9A0399> /usr/lib/system/libcopyfile.dylib
    0x7fff9440e000 -     0x7fff9445cfff  libauto.dylib (??? - ???) <D8AC8458-DDD0-3939-8B96-B6CED81613EF> /usr/lib/libauto.dylib
    0x7fff9468f000 -     0x7fff946acff7  libxpc.dylib (77.17.0 - compatibility 1.0.0) <72A16104-2F23-3C22-B474-1953F06F9376> /usr/lib/system/libxpc.dylib
    0x7fff94884000 -     0x7fff94886fff  libquarantine.dylib (36.0.0 - compatibility 1.0.0) <4C3BFBC7-E592-3939-B376-1C2E2D7C5389> /usr/lib/system/libquarantine.dylib
    0x7fff94d0c000 -     0x7fff94d2cfff  libsystem_kernel.dylib (1699.22.73 - compatibility 1.0.0) <69F2F501-72D8-3B3B-8357-F4418B3E1348> /usr/lib/system/libsystem_kernel.dylib
    0x7fff94d2d000 -     0x7fff94d33ff7  libunwind.dylib (30.0.0 - compatibility 1.0.0) <1E9C6C8C-CBE8-3F4B-A5B5-E03E3AB53231> /usr/lib/system/libunwind.dylib
    0x7fff95158000 -     0x7fff9515dfff  libcache.dylib (47.0.0 - compatibility 1.0.0) <B7757E2E-5A7D-362E-AB71-785FE79E1527> /usr/lib/system/libcache.dylib
    0x7fff95340000 -     0x7fff95341ff7  libsystem_blocks.dylib (53.0.0 - compatibility 1.0.0) <8BCA214A-8992-34B2-A8B9-B74DEACA1869> /usr/lib/system/libsystem_blocks.dylib
    0x7fff95c3a000 -     0x7fff95d17fef  libsystem_c.dylib (763.12.0 - compatibility 1.0.0) <FF69F06E-0904-3C08-A5EF-536FAFFFDC22> /usr/lib/system/libsystem_c.dylib
    0x7fff95d18000 -     0x7fff95d19fff  libdnsinfo.dylib (395.6.0 - compatibility 1.0.0) <718A135F-6349-354A-85D5-430B128EFD57> /usr/lib/system/libdnsinfo.dylib

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 1313925
    thread_create: 1
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=54.5M resident=16.3M(30%) swapped_out_or_unallocated=38.3M(70%)
Writable regions: Total=83.5M written=240K(0%) resident=1432K(2%) swapped_out=0K(0%) unallocated=82.1M(98%)

REGION TYPE                      VIRTUAL
===========                      =======
MALLOC                             19.2M
MALLOC guard page                    16K
STACK GUARD                           4K
Stack                              64.0M
__DATA                              676K
__LINKEDIT                         48.0M
__TEXT                             6640K
shared memory                        12K
===========                      =======
TOTAL                             138.4M

What should I do or did I overlook something?
Thanks in advance.

A: This is what worked for me:
$export CC=/usr/bin/gcc-4.2

A: Try following steps.
Find a gcc:
$ ls /usr/bin/gcc-*

Re-try with found gcc:
$ autoconf
$ CC=/usr/bin/gcc-4.2 ./configure --prefix=$HOME/tmp/ruby --enable-shared
$ make

A: This works with 1.9.3-p547 downloaded and built from the official Ruby site.
CFLAGS="-mmacosx-version-min=10.9" LDFLAGS="-mmacosx-version-min=10.9" CPPFLAGS="-mmacosx-version-min=10.9" ./configure
make
make install


text:
Q: Why i got a null message when retrieveng an string line from a file in java I tried to retrieve a single line of text from a text file in java, and indeed i got what i expect but at the end it adds a null reference, but i don't know why. here my code:
public class EncryptDecryptFile {

public void writeDecryptionFile(String message) {

    File f;
    FileWriter writeArchive;

    try {

        f = new File("C:\\Users\\Dell\\Training\\DecryptionFile.txt");
        writeArchive = new FileWriter(f);
        BufferedWriter bw = new BufferedWriter(writeArchive);
        PrintWriter text = new PrintWriter(bw);

        text.write(message+"\n");
        text.close();
        bw.close();

    } catch (Exception ex) {
        System.out.println(ex.getMessage());
    }

}

public String readEncryptionFile() {

    File file = new File("C:\\Test\\EncryptionFile.txt");

    String line = "";

        try (
                BufferedReader br = new BufferedReader(new FileReader(file))) {

            while (true) {

                line = br.readLine();
                if (line != null) {

                    System.out.print(line);

                } else {

                    break;
                }
            }

    } catch (IOException e) {

        e.printStackTrace();

    }

    return line;

}

public static void main(String[] args) {

    EncryptDecryptFile file = new EncryptDecryptFile();
    file.writeDecryptionFile("Hello World!!!");
    System.out.println(file.readEncryptionFile());

}

}

The result is as follows
Hello World!!!
null
Where is that null coming from ?
I appreciate any help :(

A: You are returning line and printing it at the end of System.out.println(file.readEncryptionFile()); at that time it must be null (or the loop would not end). Solution, don't print it. Just do
file.readEncryptionFile();

Note: You also print with-in readEncryptionFile()

A: Do not do
System.out.println(file.readEncryptionFile());

You are already printing it out in this method, so just calling
file.readEncryptionFile();

should suffice.
Of course you do not need to return a String from this method.
Alternative in the readEncryptionFile, create a StringBuilder Object and append to that if the line is not null, then return the String of the StringBuilder Object.


text:
Q: How To get mp3 file list from SdCard with ContentResolver.Query on Android? I created a folder that's Cuzler in mnt/sdcard and put some mp3 files..  and here codes what I am using..
File cuzFolder = new File(Environment.getExternalStorageDirectory() + "/Cuzler/");
String storageFolder = cuzFolder.getPath();

Uri urlCuz = Uri.parse(storageFolder);
Log.i(TAG, "CUZ: " + urlCuz.toString());
Cursor cur = mContentResolver.query(urlCuz, null,

MediaStore.Audio.Media.IS_MUSIC + " = 1", null, null);
Log.i(TAG, "Query finished. " + (cur == null ? "Returned NULL." : "Returned a cursor."));

cur returns null.. I've given the write/read permissions.  I am making a mp3 player that will play some mp3s in a folder in sdcard, the path is true because I am downloading mp3s to this folder and no problem. But I do not understand why query returns null ?
I also tried something like
Uri urlCuz = Uri.parse("content://" + storageFolder);

and gave direct link like mnt/sdcard/Cuzler or /mnt/scard/Cuzler
How can I solve this problem?

A: public class MainActivity extends AppCompatActivity {

    ListView listView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        listView = (ListView) findViewById(R.id.list_view);

        ContentResolver resolver = MainActivity.this.getContentResolver();
        ArrayList<String> stringArrayList = new ArrayList<String>();

        String GENRE_ID      = MediaStore.Audio.Genres._ID;
        String GENRE_NAME    = MediaStore.Audio.Genres.NAME;
        String SONG_ID       = android.provider.MediaStore.Audio.Media._ID;
        String SONG_TITLE    = android.provider.MediaStore.Audio.Media.TITLE;
        String SONG_ARTIST   = android.provider.MediaStore.Audio.Media.ARTIST;
        String SONG_ALBUM    = android.provider.MediaStore.Audio.Media.ALBUM;
        String SONG_YEAR     = android.provider.MediaStore.Audio.Media.YEAR;
        String SONG_TRACK_NO = android.provider.MediaStore.Audio.Media.TRACK;
        String SONG_FILEPATH = android.provider.MediaStore.Audio.Media.DATA;
        String SONG_DURATION = android.provider.MediaStore.Audio.Media.DURATION;

        String[] genreColumns = {
               SONG_ID,
                SONG_TITLE
        };

        if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
                != PackageManager.PERMISSION_GRANTED) {

            // Should we show an explanation?
            if (shouldShowRequestPermissionRationale(
                    Manifest.permission.READ_EXTERNAL_STORAGE)) {
                // Explain to the user why we need to read the contacts
            }

            requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
                    1);

            // MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE is an
            // app-defined int constant that should be quite unique

            return;
        }

        Cursor cursor = resolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,genreColumns,null,null,null);
        for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext())
//            genreIdToGenreNameMap.put(cursor.getString(0), cursor.getString(1));
             stringArrayList.add(cursor.getString(1));

        cursor.close();

        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,stringArrayList);
        listView.setAdapter(adapter);

    }
}


text:
Q: system crash reason One of our server recently get frequently crash....I am pasting some of the syslog here, anyone familar with system would give me a hint what caused this? Much appreciated.
I am using Ubuntu 12.10.
Sep 26 12:45:22 epgg2 kernel: [  183.799965] Pid: 1718, comm: subtleKnife Not tainted 3.5.0-17-generic #28-Ubuntu Dell Inc. PowerEdge M710HD/037M3H
Sep 26 12:45:22 epgg2 kernel: [  183.800593] RIP: 0010:[<ffffffffa029ba73>]  [<ffffffffa029ba73>] nfs_file_set_open_context+0x23/0x80 [nfs]
Sep 26 12:45:22 epgg2 kernel: [  183.801163] RSP: 0018:ffff882414253b88  EFLAGS: 00010286
Sep 26 12:45:22 epgg2 kernel: [  183.801467] RAX: 0000000000000000 RBX: ffff882415c22100 RCX: 0000000000000046
Sep 26 12:45:22 epgg2 kernel: [  183.801922] RDX: 0000000000000046 RSI: ffff882415c22100 RDI: ffff882417960500
Sep 26 12:45:22 epgg2 kernel: [  183.802414] RBP: ffff882414253ba8 R08: 0000000000000003 R09: 0000000000000003
Sep 26 12:45:22 epgg2 kernel: [  183.802923] R10: 0000000014930401 R11: ffffffffa02af354 R12: ffff882415903e00
Sep 26 12:45:22 epgg2 kernel: [  183.803341] R13: ffff882415c22100 R14: ffff8824147b05d8 R15: ffff882415863680
Sep 26 12:45:22 epgg2 kernel: [  183.803751] FS:  00007f6a486fb700(0000) GS:ffff88247fc00000(0000) knlGS:0000000000000000
Sep 26 12:45:22 epgg2 kernel: [  183.804217] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
Sep 26 12:45:22 epgg2 kernel: [  183.813112] CR2: 0000000000000030 CR3: 0000002417dbb000 CR4: 00000000000007f0
Sep 26 12:45:22 epgg2 kernel: [  183.822364] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
Sep 26 12:45:22 epgg2 kernel: [  183.831519] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Sep 26 12:45:22 epgg2 kernel: [  183.840683] Process subtleKnife (pid: 1718, threadinfo ffff882414252000, task ffff8824150e9700)
Sep 26 12:45:22 epgg2 kernel: [  183.858177] Stack:
Sep 26 12:45:22 epgg2 kernel: [  183.866686]  ffff882417960500 0000000000000000 ffff882415903e00 ffff882415c22100
Sep 26 12:45:22 epgg2 kernel: [  183.884425]  ffff882414253c58 ffffffffa0299059 0000000014253bd8 ffff8824158d72b0
Sep 26 12:45:22 epgg2 kernel: [  183.902915]  0000800017960510 ffff8824158d72b0 0001000000008000 ffff88241641dc00
Sep 26 12:45:22 epgg2 kernel: [  183.921834] Call Trace:
Sep 26 12:45:22 epgg2 kernel: [  183.930943]  [<ffffffffa0299059>] nfs4_file_open+0x169/0x1b0 [nfs]
Sep 26 12:45:22 epgg2 kernel: [  183.940062]  [<ffffffff8118010f>] __dentry_open+0x21f/0x330
Sep 26 12:45:22 epgg2 kernel: [  183.948970]  [<ffffffffa0298ef0>] ? nfs_setlease+0x10/0x10 [nfs]
Sep 26 12:45:22 epgg2 kernel: [  183.958192]  [<ffffffff8118025a>] vfs_open+0x3a/0x40
Sep 26 12:45:22 epgg2 kernel: [  183.966984]  [<ffffffff81181208>] nameidata_to_filp+0x58/0xb0
Sep 26 12:45:22 epgg2 kernel: [  183.975650]  [<ffffffff8118fb3f>] do_last+0x49f/0xa10
Sep 26 12:45:22 epgg2 kernel: [  183.984227]  [<ffffffff81191399>] path_openat+0xd9/0x430
Sep 26 12:45:22 epgg2 kernel: [  183.992336]  [<ffffffff810561ec>] ? release_task+0x2cc/0x480
Sep 26 12:45:22 epgg2 kernel: [  184.000385]  [<ffffffff81191811>] do_filp_open+0x41/0xa0
Sep 26 12:45:22 epgg2 kernel: [  184.008385]  [<ffffffff8119e906>] ? alloc_fd+0xc6/0x110
Sep 26 12:45:22 epgg2 kernel: [  184.016628]  [<ffffffff81181355>] do_sys_open+0xf5/0x230
Sep 26 12:45:22 epgg2 kernel: [  184.024512]  [<ffffffff811814b1>] sys_open+0x21/0x30Sep 26 12:45:22 epgg2 kernel: [  184.032264]  [<ffffffff81689d29>] system_call_fastpath+0x16/0x1b
Sep 26 12:45:22 epgg2 kernel: [  184.040002] Code: 0f 1f 84 00 00 00 00 00 55 48 89 e5 48 83 ec 20 48 89 5d e8 4c 89 65 f0 4c 89 6d f8 66 66 66 66 90 48 8b 47 18 48
 85 f6 48 89 f3 <4c> 8b 68 30 74 03 f0 ff 06 4d 8d a5 88 00 00 00 48 89 9f a0 00
Sep 26 12:45:22 epgg2 kernel: [  184.064228] RIP  [<ffffffffa029ba73>] nfs_file_set_open_context+0x23/0x80 [nfs]
Sep 26 12:45:22 epgg2 kernel: [  184.080078]  RSP <ffff882414253b88>
Sep 26 12:45:22 epgg2 kernel: [  184.088187] CR2: 0000000000000030
Sep 26 12:45:22 epgg2 kernel: [  184.096113] ---[ end trace 4a4d24758d2ccf4f ]---
Sep 26 12:45:22 epgg2 kernel: [  184.095989] BUG: unable to handle kernel paging request at 0000000f00010a0e
Sep 26 12:45:22 epgg2 kernel: [  184.120329] IP: [<ffffffff8103f989>] __ticket_spin_lock+0x9/0x30
Sep 26 12:45:22 epgg2 kernel: [  184.128303] PGD 2415580067 PUD 0
Sep 26 12:45:22 epgg2 kernel: [  184.136792] Oops: 0002 [#2] SMP
Sep 26 12:45:22 epgg2 kernel: [  184.144177] CPU 2
Sep 26 12:45:22 epgg2 kernel: [  184.144293] Modules linked in: vesafb nfsd nfs lockd fscache auth_rpcgss nfs_acl sunrpc dcdbas gpio_ich coretemp kvm ghash_clmulni_intel aesni_intel cryptd aes_x86_64 microcode joydev lpc_ich i7core_edac edac_core mac_hid wmi acpi_power_meter lp parport hid_generic usbhid hid bnx2x libcrc32c mpt2sas mdio scsi_transport_sas bnx2 raid_class

A: It is probably a bug in the BIOS, kernel or the nsf module. You should update your BIOS firmaware if a newer version is available, upgrade the kernel, preferably to latest version and see if it still happens. If it does report a bug using How do I report a bug? guide.


text:
Q: Checking the contents of a table cell with Javascript I have a table in my page and I'd like to use a while loop to check the contents of the first column of the code. This what what my code looks like. The name of my table is "list".
        var row=1;
        var cell=0;
        var flag=true;
        while (flag){
            var ele = list.rows[row].cells[cell].innerHTML;
            var stuff = ele.toString();

            if (stuff.search("Live") > -1 || stuff.search("Offline") > -1){
                row = row + 1;
            }
            else{
                flag = false;
            }
        }

and with the variable i, I can then go and modify stuff in that row specifically but for some reason I keep getting:

"Uncaught TypeError: Cannot read property 'innerHTML' of undefined"

When I try to run it and it`s not outputting properly. My table looks like this:

Sort	Stream Name

	Twitch.tv test

	own3d test

	livestream.com test

I have no idea why it`s not working.

A: You need to initialize the variable list.
For example,
var list = document.querySelectorAll('#list');


text:
Q: Python. How to make the previously entered value in telegram appear in the line "Write a message" Hello. Need help) There is a code:
def edit(message):
    num = int(message.text)
    num = num - 1
    bot.send_message(message.chat.id, list[num])

The logic is simple. The person enters data. They are saved in the list under their own number. The person then enters a number to edit their entry. And is it possible to make his entry appear in the "enter message" line, and not receive individual SMS.
enter image description here
Thanks in advance)