Hey,
Im wondering, how can i get a SUM of a rating entity i get from the datastore (python)?
should i:
ratingsum = 0
for rating in ratings:
ratingsum + rating
print ratingsum
?
I'm playing around with Map Reduce in MongoDB and python and I've run into a strange limitation. I'm just trying to count the number of "book" records. It works when there are less than 100 records but when it goes over 100 records the count resets for some reason.
Here is my MR code and some sample outputs:
var M = function () {
book =…
"Write a for loop that prints the integers 1 through 40, separated by spaces or new lines. You may use only one variable, count which has already been declared as an integer."
So I use...
for(count = 1; count <= 40; count++)
{
cout << " " << count;
}
but they are using stdio.h as the only header and cout is not…
I am parsing a very large file of records (one per line, each of varying length), and I'd like to keep track of the number of bytes I've read in the file so that I may recover in the event of a failure.
I wrote the following:
string record = myTextReader.ReadLine();
bytesRead += record.Length;
ParseRecord(record);
However this…
I have a large framework consisting of many C++ classes. Is there a way using any tools at runtime, to trace all the C++ objects that are being constructed and currently exist?
For example, at a certain time t1, perhaps the application has objects A1, A2 and B3, but at time t2, it has A1, A4, C2 and so on?
This is a cross…
For example,
the start date = '20100530' and
the end date = '20100602'
How can I write a SQL to display the below result?
month: may, 2 days
month: June, 2 days
Given a Rakefile that executes some RSpec tests by way of a Spec::Rake::SpecTask, how can I programmatically determine the number of tests that passed, failed, and are pending once the task that ran the tests is finished?
I was practicing my java and was trying to make a simple counter with rollover at max, but for some reason it isn't rolling over. Any advice?
public class HandTallyCounter {
private int max;
private int count;
public HandTallyCounter(int max) {
this.max = max;
count = 0;
}
public void…
i want to do this:
reads the words in the file one at a time. (Use a string to do this)
Counts three things: how many single-character words are in the file, how many short (2 to 5 characters) words are in the file, and how many long (6 or more characters) words are in the file. HELP HERE
im not sure on how about reading…
I have the following code in my program which is throwing index out of bound exception at
line yearList.SetValue(years[count], count);
protected void invoiceYear_DataBound(object sender, EventArgs e)
{
//invoiceYear.SelectedItem.Value= GetYearRange();
String[] years =…
I tried importing a database dump from a SQL file and the insert failed when inserting the string Mér into a field defined as varying(3). I didn't capture the exact error, but it pointed to that specific value with the constraint of varying(3).
Given that I considered this unimportant to what I was…
I have a data structure with 15 unsigned longs, I have defined a hash function using hash_combine as follows:
friend std::size_t hash_value(const TUPLE15& given)
{
std::size_t seed = 0;
boost::hash_combine(seed, val1);
boost::hash_combine(seed, val2);
...
…
Hi all,
Trying to help a friend out with a friend out with some assembly code, but I've run into a small problem.
I'm trying to work out how I would loop through a 8 bit binary word and check the value of specific bits. I need to check bits 1, 3, 5 & 7 to see if they are 1.
i.e.
int…
I am running ActiveState's ActivePython 2.6.5.12 and PostgreSQL 9.0 Beta 1 under Windows XP.
If I create a table with an upper case first letter (i.e. Books), psycopg2 returns the "Programming Error: relation "books" does not exist" error message when I run the select statement:…
I am trying to get the Count of all records that have at least on person who is authorized on the record. Basically, a Record can have more than one person associated with it. I want to return the count of Total Records, a count of total Authorized Records where at least 1…
I have a survey database with one column for each question and one row for each person who responds. Each question is answered with a value from 1 to 3.
Id Quality? Speed?
-- ------- -----
1 3 1
2 2 1
3 2 3
4 3 2
…
I have a matrix, IEnumerable<IEnumerable<int>> matrix, for example:
{ {10,23,16,20,2,4}, {22,13,1,33,21,11 }, {7,19,31,12,6,22}, ... }
and another array:
int[] arr={ 10, 23, 16, 20}
I want to filter the matrix on the condition that I group all rows of…
I am looking to change a div's css when i scroll to a certain point down the page, a certain amount of pixels from the top of the page.
On page load i would have a div positioned statically. Once I started to scroll down the page and i hit a point from the top (say…
I have VBA code in an Excel spreadsheet. It is used to set the font and background color of a cell based on the value in that cell. I am doing it in VBA instead of "Conditional Formatting" because I have more than 3 conditions. The code is:
Private Sub…
I have a Postgre database that has say 10 columns. The fifth column is called column5. There are 100 rows in the database and possible values of column5 are c5value1, c5value2, c5value3...c5value29, c5value30. I would like to print out a table that…
In c it would be:
while(1){
i++;
printf("%d \r",i);
}
I assume the textview and the variable and the timer get created in oncreate, then there is a timer handler with an increment and a settext and a sleep? Seeing how to do this in androidese…
For each ad on my site, I would like a box that shows the number of views it has (similar to this site).
How would I capture the number of page views an ad has? Is there a function that does this in PHP?
When you hit the delete button a nice effect is run on that li and it is removed by using jquery's .remove() function.
For some reason if i try to .size() on the parent ul it just still says the number of list items that were there when the page…