text:
Q: parsererror when calling jasperreport from ajax in spring mvc I'm calling endpoint from jquery ajax to generate jasperreport using spring mvc and I want to view generated report as pdf in new browser tab.
The problem is that I'm getting report parsererror with conversion failure from text to application/pdf error returned to ajax ,and if I make debug of the request from browser I see pdf text obtained in response
Here is Ajax code that calls the spring mvc method
var developerData = {};
        developerData["from"] = $("#productivity_dateTimeFrom").val();
        developerData["to"] = $("#productivity_dateTimeTo").val();
        $.ajax({
            type : "POST",
            contentType : "application/json; charset=utf-8",
            url : 'Productivity',
            data : JSON.stringify(developerData),
            dataType : 'application/pdf',
            success : function(data) {
                window.open(data.fileUrl);
            },
            error : function(request,status,error){
                alert(request)
                alert(status)
                alert(error)
            }
        });

Spring mvc method to be called from ajax:
@RequestMapping(value = "/Productivity", method = RequestMethod.POST, produces ="application/pdf")
@ResponseBody
public ResponseEntity<byte[]> runReport(@RequestBody String object) throws IOException, JRException {

    db_con db_con = new db_con();
    Resource resource = new ClassPathResource("Productivity.jasper");
    InputStream jasperStream = null;
    Gson g = new Gson();
    try {
        jasperStream = resource.getInputStream();
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    DateTimeRange p = g.fromJson(object, DateTimeRange.class);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("p_from_date",dateUtils.convertStringToTimestamp(p.getFrom().replace("T", " ")+":00.000"));
    params.put("p_to_date",dateUtils.convertStringToTimestamp(p.getTo().replace("T", " ")+":00.000"));
    params.put("username", "admin");
    params.put("p2", 1L);
    params.put("p3", "All");
    JasperReport jasperReport = null;

    try {
        jasperReport = (JasperReport) JRLoader.loadObject(jasperStream);
    } catch (JRException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    Connection rep_connection = null;

    try {
        rep_connection = db_con.get_connection();
    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    JasperPrint jasperPrint = null;
    try {
        jasperPrint = JasperFillManager.fillReport(jasperReport, params, rep_connection);
    } catch (JRException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    final ByteArrayOutputStream outStream = new ByteArrayOutputStream();

    try {
        JasperExportManager.exportReportToPdfStream(jasperPrint, outStream);
    } catch (JRException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    HttpHeaders headers = new HttpHeaders();

    headers.setContentType(MediaType.APPLICATION_PDF);
    String filename = "report.pdf";

    headers.add("content-disposition", "inline;filename=" + filename);

    return new ResponseEntity<>(outStream.toByteArray(), headers, HttpStatus.OK);

}

A: Try downloading the pdf as a blob and using a blob url to view it
    $.ajax({
        type : "POST",
        contentType : "application/json; charset=utf-8",
        url : 'Productivity',
        data : JSON.stringify(developerData),
        xhrFields:{
            responseType: 'blob'
        },
        success : function(data) {
            window.open(URL.createObjectURL(data));
        },
        error : function(request,status,error){
            alert(request)
            alert(status)
            alert(error)
        }
    });


text:
Q: CakePHP - Find conditions not returning expected results I have an Invoice model, which has 2 fields determining its processing status.  One is technician_id, and one is date_processed.  They are both used for slightly different things, and each can be null.
I want to retrieve all those Invoices where date_processed is null and the technician_id is either null or is the same as the current user's id.
I thought I knew what I was doing, but obviously I have my Friday head on or something, as I can't get it to work.  Here's what I have at the moment:
        $conditions = array(
            'Invoice.date_processed' => null,
            'Invoice.technician_id' => array(null, $user_id)
            )
    );

I've also tried:
    $conditions = array(
            'Invoice.date_processed' => null,
            'OR' => array(
                'Invoice.technician_id' => null,
                'Invoice.technician_id' => $user_id
            )
    );

However, both of these return only those Invoices where the technician_id matches the user_id, and not those where the technician_id is null (the date_processed field is filtered correctly).
Can anyone tell me what I'm doing wrong?

A: I think the solution could be this:
$conditions = array(
  'OR' =>
        array(
               array('AND' => array(
                              array('Invoice.date_processed' => null),
                              array('Invoice.technician_id' => null)
                        )),
               array('AND' => array(
                              array('Invoice.date_processed' => null),
                              array('Invoice.technician_id' => $user_id)
                        ))
             )
);

A: The reason that your first "or" statement wasn't working is because of how array's work in php, defining a key twice overwrites the first key.
So when you were doing this
$conditions = array(
        'Invoice.date_processed' => null,
        'OR' => array(
            'Invoice.technician_id' => null,
            'Invoice.technician_id' => $user_id
        )
);

It was more like saying this
$conditions = array(
        'Invoice.date_processed' => null,
        'OR' => array(
            'Invoice.technician_id' => $user_id
        )
);

The correct way of doing an 'OR' statement in cakephp without having the excessive 'AND' statement would be
$conditions = array(
        'Invoice.date_processed' => null,
        'OR' => array(
            'Invoice.technician_id' => array(null, $user_id)
        )
);

redpajama_set_name: RedPajamaStackExchange


text:
Q: jQuery : How to get JSON data of the table with custom header values jQuery : How to get JSON data of the table data with custom header values. Have one table and need to convert entire table data to the json format data. Now im trying to replace array of headers (custom headers) insted of actual table headers in the json data.  I tried to replace original table heades with $headers =["ID", "ABC", "XYZ","Test"];
I tried with below code,
expected output:
[{"ID":"22222","ABC":"test5","XYZ":"3000","":"abc"},{"ID":"3333","ABC":"test1","XYZ":"1000","":"erf"},{"ID":"44444","ABC":"test2","XYZ":"2000","":"sde"},{"ID":"55555","ABC":"test3","XYZ":"3000","":"fre"}]

Fiddle

$(document).ready(function() {
  $("#getJsondata").click(function() {
    var jsonData1 = [];
    var matchId = 1234;
    var $headers = $("#firstTable").find("th:eq(0),th:eq(1),th:eq(2)");
    //var $headers =["ID", "ABC", "XYZ","Test"];
    var $rows = $("#firstTable").find("tbody tr")
      .each(function(index) {
        const $cells = $(this).closest("tr").find("td:eq(0),td:eq(1),td:eq(2),td:eq(3)");
        jsonData1[index] = {};
        $cells.each(function(cellIndex) {
          jsonData1[index][$($headers[cellIndex]).text()] = $(this).text();
        });
      });
    alert(JSON.stringify(jsonData1));
  });
});
td {
  border: 1px solid black;
}

      Header1
      Header2
      Header3
      Header4
      Header5
      Header6

      22222
      test5
      3000
      abc
      22222
      Y

      3333
      test1
      1000
      erf
      22222
      Y

      44444
      test2
      2000
      sde
      22222
      Y

      55555
      test3
      3000
      fre
      22222
      Y

<button id="getJsondata" type="button">
   GetJsonData
</button>

A: This seems to do what you wanted

const headers = ["ID", "ABC", "XYZ", "Test"];
$(function() {
  $("#getJsondata").on("click", function() {
    const data = [];
    $("#firstTable").find("tbody tr").each(function() {
         data.push({})
         $(this).find("td").map(function(i) {
          return this.textContent;
        }).get()      // get the array of all cell contents
        .slice(0, -2) // get rid of the last two
        .forEach((text,i) => data[data.length-1][headers[i]] = text) // add to the object
      })
    console.log(JSON.stringify(data));
  });
});
td {
  border: 1px solid black;
}

      Header1
      Header2
      Header3
      Header4
      Header5
      Header6

      22222
      test5
      3000
      abc
      22222
      Y

      3333
      test1
      1000
      erf
      22222
      Y

      44444
      test2
      2000
      sde
      22222
      Y

      55555
      test3
      3000
      fre
      22222
      Y

<button id="getJsondata" type="button">
   GetJsonData
</button>

A: You can get td index and depending on this get  $headers value at that index and push same inside JSON Array .I have use :lt(less then) because there are only 4 header value you can remove that if you need all tds values
Demo Code :

$(document).ready(function() {
  $("#getJsondata").click(function() {
    var jsonData1 = [];
    var $headers = ["ID", "ABC", "XYZ", "Test"];
    $("#firstTable").find("tbody tr").each(function(index) {
      var values = {}; //create obj
      //loop through tr > td only < 4
      $(this).find("td:lt(4)").each(function(index) {
        values[$headers[index]] = $(this).text(); //add values
      })
      jsonData1.push(values) //push in array
    });
    alert(JSON.stringify(jsonData1));
  });
});
td {
  border: 1px solid black;
}

      Header1
      Header2
      Header3
      Header4
      Header5
      Header6

      22222
      test5
      3000
      abc
      22222
      Y

      3333
      test1
      1000
      erf
      22222
      Y

      44444
      test2
      2000
      sde
      22222
      Y

      55555
      test3
      3000
      fre
      22222
      Y

<button id="getJsondata" type="button">
   GetJsonData
</button>


text:
Q: mongodb not able to update below request data using java Below is the my JSON request data and I want to update currency and subAmount. I tried but it did not updating properly.
Here is my code:
{
    "mid":"5032219",
    "description" : "Sample description",
    "currency" : "INR",
    "amount" : {
        "subAmount":"20"
    }
}

I tried using below code,
passing the params values are - {currency=AUG, amount={"subAmount":"20.00"}}
public void updateInvoiceModel(InvoiceModel model, Map param) {
        MongoCollection<Document> collection = database.getCollection("invoice");
        BasicDBObject searchQuery = new BasicDBObject("invoiceNumber", model.getInvoiceNumber());
        BasicDBObject updateFields = new BasicDBObject();
        for (Entry<String, Object> entry : param.entrySet()) {
            updateFields.append(entry.getKey(), entry.getValue());
        }
        BasicDBObject setQuery = new BasicDBObject();
        setQuery.append("$set", updateFields);
        collection.updateOne(searchQuery, setQuery);

}
Kindly let me know if anyone have a solution.

A: Please use the following:
db.collection_name.update(
   { _id: mid },
   { $set:
      {
         "currency" : "INR", "amount" : { "subAmount":"20" }
      }
   }
)


text:
Q: PHP Websocket server subscribe for redis it's my first question. :)
So my problem is that:
I have a Apache server, who use Redis(Predis) server. Also have and WebSocket server (PHP WebSocketServer, who need to "subscribe" Redis server.
For subscribing I use:
    $pubsub = $client->pubSubLoop();
// Subscribe to your channels
$pubsub->subscribe('control_channel', 'notifications');
// Start processing the pubsup messages. Open a terminal and use redis-cli
// to push messages to the channels. Examples:
//   ./redis-cli PUBLISH notifications "this is a test"
//   ./redis-cli PUBLISH control_channel quit_loop
foreach ($pubsub as $message) {
    switch ($message->kind) {
        case 'subscribe':
            echo "Subscribed to {$message->channel}", PHP_EOL;
            break;
        case 'message':
            if ($message->channel == 'control_channel') {
                if ($message->payload == 'quit_loop') {
                    echo "Aborting pubsub loop...", PHP_EOL;
                    $pubsub->unsubscribe();
                } else {
                    echo "Received an unrecognized command: {$message->payload}.", PHP_EOL;
                }
            } else {
                echo "Received the following message from {$message->channel}:",
                     PHP_EOL, "  {$message->payload}", PHP_EOL, PHP_EOL;
            }
            break;
    }
}

I realize that the WebSocket server using kind of infinite loop, and Predis (subscribe) is the same.
So hit me if I'm wrong, or can you give me some advice.
Thanks.


text:
Q: How to create a persistent top and bottom on bottom sheet I want to create a flutter bottom sheet, and when I scroll it, the top and bottom parts of it will stay the same, only the contents part is moving. So, I can put the title on the top part of the bottom sheet, and buttons on the bottom part of the bottom sheet.
Here is my code for the floating action button and the model bottom sheet:
DateTime selectedDate = DateTime.now();

final marginForTasksAddingPanel =
  const EdgeInsets.only(left: 10.0, right: 10.0);
final sizedBoxForTasksAddingPanel = const SizedBox(height: 30.0);
final sizedBoxForTasksAddingPanelBetweenEachSection =
  const SizedBox(height: 15.0);

floatingActionButton: SizedBox(
      height: 70.0,
      width: 70.0,
      child: FittedBox(
        child: FloatingActionButton(
          onPressed: () => showModalBottomSheet(
            shape: const RoundedRectangleBorder(
              borderRadius: BorderRadius.vertical(
                top: Radius.circular(30.0),
              ),
            ),
            isScrollControlled: true,
            isDismissible: true,
            context: context,
            builder: (context) => tasksAddingPanel(),
          ),
          child: const Icon(
            Icons.add_outlined,
          ),
          backgroundColor: Colors.blue,
          elevation: 10.0,
        ),
      ),
    ),

Widget tasksAddingPanel() => DraggableScrollableSheet(
    expand: false,
    initialChildSize: 0.90,
    maxChildSize: 0.90,
    minChildSize: 0.90,
    builder: (context, scrollController) => Container(
      padding: const EdgeInsets.all(16.0),
      child: Stack(children: [
        ListView(
          controller: scrollController,
          children: [
            Container(
              margin: const EdgeInsets.only(top: 10.0, left: 10.0),
              child: const Text(
                'Add task',
                style: TextStyle(
                  fontSize: 23.0,
                ),
              ),
            ),
            sizedBoxForTasksAddingPanel,
            Container(
              margin: marginForTasksAddingPanel,
              child: const Text(
                'Title',
                style: TextStyle(
                  fontSize: 16.0,
                ),
              ),
            ),
            sizedBoxForTasksAddingPanelBetweenEachSection,
            Container(
              margin: marginForTasksAddingPanel,
              child: const TextField(
                decoration: InputDecoration(
                  hintText: 'Enter the name of the task',
                ),
              ),
            ),
            sizedBoxForTasksAddingPanel,
            Container(
              margin: marginForTasksAddingPanel,
              child: const Text(
                'Pick a date',
                style: TextStyle(
                  fontSize: 16.0,
                ),
              ),
            ),
            sizedBoxForTasksAddingPanelBetweenEachSection,
            Container(
              margin: marginForTasksAddingPanel,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  Text(
                    "${selectedDate.toLocal()}".split(' ')[0],
                    style: const TextStyle(
                        fontSize: 20, fontWeight: FontWeight.bold),
                  ),
                  const SizedBox(
                    width: 30.0,
                  ),
                  ClipRRect(
                    borderRadius: BorderRadius.circular(50.0),
                    child: ElevatedButton(
                      onPressed: () => _selectedDate(context),
                      // Refer step 3
                      child: const Text(
                        'Select date',
                        style: TextStyle(
                            color: Colors.white,
                            fontWeight: FontWeight.bold),
                      ),
                    ),
                  ),
                ],
              ),
            ),
            sizedBoxForTasksAddingPanel,
            Container(
              margin: marginForTasksAddingPanel,
              child: const Text(
                'Label it',
                style: TextStyle(
                  fontSize: 16.0,
                ),
              ),
            ),
            sizedBoxForTasksAddingPanelBetweenEachSection,
            Container(
              margin: marginForTasksAddingPanel,
              child: GestureDetector(
                onTap: () {},
                child: Card(
                  color: Colors.blue,
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(20.0),
                  ),
                  child: const ListTile(
                    title: Center(
                      child: Text(
                        'Personal',
                        style: TextStyle(
                          color: Colors.white,
                        ),
                      ),
                    ),
                    trailing: Icon(
                      Icons.arrow_downward_outlined,
                      color: Colors.white,
                    ),
                  ),
                ),
              ),
            ),
            sizedBoxForTasksAddingPanel,
            Container(
              margin: marginForTasksAddingPanel,
              child: const Text(
                'Set a reminder',
                style: TextStyle(
                  fontSize: 16.0,
                ),
              ),
            ),
            sizedBoxForTasksAddingPanelBetweenEachSection,
            Container(
              margin: marginForTasksAddingPanel,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: [
                  Text(
                    "${selectedDate.toLocal()}".split(' ')[0],
                    style: const TextStyle(
                        fontSize: 20, fontWeight: FontWeight.bold),
                  ),
                  const SizedBox(
                    width: 30.0,
                  ),
                  SizedBox(
                    width: 150.0,
                    child: GestureDetector(
                      onTap: () => showCupertinoModalPopup(
                        context: context,
                        builder: (context) => SizedBox(
                          height: 200.0,
                          child: CupertinoDatePicker(
                            mode: CupertinoDatePickerMode.dateAndTime,
                            initialDateTime: selectedDate,
                            onDateTimeChanged: (DateTime newDate) {
                              setState(() {
                                selectedDate = newDate;
                              });
                            },
                          ),
                        ),
                      ),
                      child: Card(
                        color: Colors.blue,
                        shape: RoundedRectangleBorder(
                          borderRadius: BorderRadius.circular(20.0),
                        ),
                        child: const ListTile(
                          title: Center(
                            child: Icon(
                              Icons.alarm_add_outlined,
                              color: Colors.white,
                            ),
                          ),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ]),
    ),
  );

A: You don't need  DraggableScrollableSheet in this case, you can pass Container as showModalBottomSheet's builder and  use
Column [TopWidget, Expanded<ListView>, BottomWidget ]

Test Widget
class DGTS extends StatelessWidget {
  const DGTS({Key? key}) : super(key: key);

  xBottomSheet(BuildContext context) {
    showModalBottomSheet(
        context: context,
        isDismissible: true,
        isScrollControlled: true,
        shape: const RoundedRectangleBorder(
          borderRadius: BorderRadius.vertical(
            top: Radius.circular(30.0),
          ),
        ),
        builder: (context) => LayoutBuilder(
              builder: (context, constraints) {
                return Container(
                  height: constraints.maxHeight * .9,
                  decoration: const BoxDecoration(
                    color: Colors.cyanAccent,
                    borderRadius: BorderRadius.vertical(
                      top: Radius.circular(30.0),
                    ),
                  ),
                  child: Column(
                    children: [
                      Container(
                          height: 100,
                          alignment: Alignment.center,
                          width: double.infinity,
                          decoration: const BoxDecoration(
                            color: Colors.red,
                            borderRadius: BorderRadius.vertical(
                              top: Radius.circular(30.0),
                            ),
                          ),
                          child: Text("Top Bar")),
                      Expanded(
                        child: ListView(
                          children: List.generate(
                            44,
                            (index) => Container(
                              alignment: Alignment.center,
                              color: index.isEven
                                  ? Colors.deepPurple
                                  : Colors.green,
                              height: 100,
                              child: Text("Item $index"),
                            ),
                          ),
                        ),
                      ),
                      Container(
                          alignment: Alignment.center,
                          height: 100,
                          width: double.infinity,
                          color: Colors.amber,
                          child: Text("Bottom")),
                    ],
                  ),
                );
              },
            ));
  }


text:
Q: How to hash IBM MobileFirst SQL adapter username password url and port in xml file? I'm using a IBM MobileFirst SQL adapter to get data from a AWS Oracle RDS.
In order to connect to the sql adapter, we need to provide the username, password, url and port. The connection works, however, how should I hash it so that no one can read it? This is to make it more secure. Is this possible?
<driverClass>oracle.jdbc.driver.OracleDriver</driverClass>
   <url>jdbc:oracle:thin:@xxx.rds.amazonaws.com:1525/SchemaSample</url>
            <user>Username</user>
            <password>Password</password>
</dataSourceDefinition>

A: First, you're using a very old build of 7.1 and your team should consider updating both the client and server versions.
Second, just to clarify, you don't "connect to the sql adapter". Your client sends a request to the MobileFirst Server, to use the adapter in order to connect to the AWS Oracle RDS. It is the request of the adapter to the AWS that you want its properties hashed, or encrypted.
As for encrypting properties, this depends on the application server you've installed MobileFirst Server on (WAS, WAS liberty, or Tomcat). In general, the process is as follows:

*

*If you're using Tomcat, you can create a custom property in the worklight.properties file, encrypt it as instructed here and then re-deploy the .war file.

*If you're using WAS or WAS liberty, you can also create such custom property in worklight.properties, and then expose it as a JNDI entry in the application server. You can then encrypt it using the encryption tools provided by each application server.
See here for an example how to set it up: https://stackoverflow.com/a/25159260/1530814
Once you have it setup, you can now take care of the encryption by following the documentation of the tool for your application server.

*

*Encryption tools by each application server (search for "Encoding the JDNI properties")


text:
Q: Connectivity between Web Server and SQL Server inside Amazon VPC I have a Webserver and a SQL Server inside an Amazon VPC.
Previously, a Webserver outside the VPC could connect to the SQL Server fine.
Now, sometime, when running SQL Scripts (the deployment script reruns all the stored procedures on install), some of the create procedure scripts fail with an error
"An exception occurred while executing a Transact-SQL statement or batch. A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 -The semaphore timeout period has expired)"
Once it starts failing, it will continue to fail until a reboot. It is always the same scripts that fail. Rebooting both servers clears the problem, but that's not a long term solution. Windows Firewalls off on both machines. Windows Server 2012 on both machines. It might be correlated with a pending Windows Update on the Web Server; every time it's stopped there have been updates pending. Server Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (X64) Jun 17 2011 00:54:03 Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows NT 6.2  (Build 9200: ) (Hypervisor)
If I open up the Security Group for the SQL Server, I can connect to it directly and run all the scripts from my development machine; they still fail when I run them from the Web Server, so I'm pretty sure it's the Web Server that's the problem. I'm just not sure how or why.
The scripts are automatically generated from the database; they're basically identical, and don't contain syntax errors, and work when run from elsewhere. But some of them die when being run from the Web Server.
What could the problem be?

A: Looks like a combination of 2 things:

*

*The default MTU of 1500 is too high for Amazon Server

*Blocking ICMP (default for an AWS security group) stops the negotiation of a suitable MTU.

Setting a lower MTU and enabling IMCP seems to have fixed it, so far, anyway.


text: Q: Branding on MySite We have a main site and a mySite. Both are having the same branding with the top navigational bar. This menu contains some URLS linked to main site. I am using a sitemap to generate the relative URLs for this top menu bar. I want to use the same URLs but hardcoded absolute URLs from My Site linked to Main site. I am able to use the same master page as main site for MySite but as links are coded as relative URLs,which results as Broken links. The main reason for this is all the urls in the form of http://mysite.mainsitelist.com. Please let me know how can I get the absolute URLs for the mysite.


text: Q: why is minetest outdated in the Ubuntu repositories? The Game Minetest in the ubuntu repositories is version 0.3.1 it has no been nearly a year since this release and version 0.4.5 has recently come out. Is there any reason why this is?


text:
Q: Python tips for memory optimization I need to optimize the RAM usage of my application.
PLEASE spare me the lectures telling me I shouldn't care about memory when coding Python. I have a memory problem because I use very large default-dictionaries (yes, I also want to be fast). My current memory consumption is 350MB and growing. I already cannot use shared hosting and if my Apache opens more processes the memory doubles and triples... and it is expensive.
I have done extensive profiling and I know exactly where my problems are.
I have several large (>100K entries) dictionaries with Unicode keys. A dictionary starts at 140 bytes and grows fast, but the bigger problem is the keys. Python optimizes strings in memory (or so I've read) so that lookups can be ID comparisons ('interning' them). Not sure this is also true for unicode strings (I was not able to 'intern' them).
The objects stored in the dictionary are lists of tuples (an_object, an int, an int).

my_big_dict[some_unicode_string].append((my_object, an_int, another_int))

I already found that it is worth while to split to several dictionaries because the tuples take a lot of space...
I found that I could save RAM by hashing the strings before using them as keys!
But then, sadly, I ran into birthday collisions on my 32 bit system. (side question: is there a 64-bit key dictionary I can use on a 32-bit system?)
Python 2.6.5 on both Linux(production) and Windows.
Any tips on optimizing memory usage of dictionaries / lists / tuples?
I even thought of using C - I don't care if this very small piece of code is ugly. It is just a singular location.
Thanks in advance!

A: For a web application you should use a database, the way you're doing it you are creating one copy of your dict for each apache process, which is extremely wasteful. If you have enough memory on the server the database table will be cached in memory (if you don't have enough for one copy of your table, put more RAM into the server). Just remember to put correct indices on your database table or you will get bad performance.

A: I've had situations where I've had a collection of large objects that I've needed to sort and filter by different methods based on several metadata properties. I didn't need the larger parts of them so I dumped them to disk.
As you data is so simple in type, a quick SQLite database might solve all your problems, even speed things up a little.

A: I suggest the following: store all the values in a DB, and keep an in-memory dictionary with string hashes as keys.  If a collision occurs, fetch values from the DB, otherwise (vast majority of the cases) use the dictionary.  Effectively, it will be a giant cache.
A problem with dictionaries in Python is that they use a lot of space: even an int-int dictionary uses 45-80 bytes per key-value pair on a 32-bit system.  At the same time, an array.array('i') uses only 8 bytes per a pair of ints, and with a little bit of bookkeeping one can implement a reasonably fast array-based int → int dictionary.
Once you have a memory-efficient implementation of an int-int dictionary, split your string → (object, int, int) dictionary into three dictionaries and use hashes instead of full strings.  You'll get one int → object and two int → int dictionaries.  Emulate the int → object dictionary as follows: keep a list of objects and store indexes of the objects as values of an int → int dictionary.
I do realize there's a considerable amount of coding involved to get an array-based dictionary.  I had had problem similar to yours and I have implemented a reasonably fast, very memory-efficient, generic hash-int dictionary.  Here's my code (BSD license).  It is array-based (8 bytes per pair), it takes care of key hashing and collision checking, it keeps the array (several smaller arrays, actually) ordered during writes and does binary search on reads.  Your code is reduced to something like:
dictionary = HashIntDict(checking = HashIntDict.CHK_SHOUTING)
# ...
database.store(k, v)
try:
    dictionary[k] = v
except CollisionError:
    pass
# ...
try:
    v = dictionary[k]
except CollisionError:
    v = database.fetch(k)

The checking parameter specifies what happens when a collision occurs: CHK_SHOUTING raises CollisionError on reads and writes, CHK_DELETING returns None on reads and remains silent on writes, CHK_IGNORING doesn't do collision checking.
What follows is a brief description of my implementation, optimization hints are welcome!  The top-level data structure is a regular dictionary of arrays.  Each array contains up to 2^16 = 65536 integer pairs (square root of 2^32).  A key k and a corresponding value v are both stored in k/65536-th array.  The arrays are initialized on-demand and kept ordered by keys.  Binary search is executed on each read and write.  Collision checking is an option.  If enabled, an attempt to overwrite an already existing key will remove the key and associated value from the dictionary, add the key to a set of colliding keys, and (again, optionally) raise an exception.

A: Use shelve or a database to store the data instead of an in-memory dict.

A: If you want to stay with the in-memory data store, you could try something like memcached.
That way, you can use a single in-memory key/value-store from all the Python processes.
There are several python memcached client libraries.

A: Redis would be a great option here if you have the option to use it on a shared host - similar to memcached, but optimised for data structures. Redis also supports python bindings.
I use it on a day to day basis for number crunching but also in production systems as a datastore and cannot recommend it highly enough.
Also, do you have an option to proxy your app behind nginx instead of using Apache? You might find (if allowed) this proxy/webapp arrangement less hungry on resources.
Good luck.

A: If you want to do extensive optimization and have full control on memory usage you could also write a C/C++ module. Using Swig the code wrapping into Python can be done easily, with some small performance overhead comparing to pure C Python module.


text:
Q: Java classpath used by Spring I know a way to print the classpath of a project at runtime like here:
http://www.mkyong.com/java/how-to-print-out-the-current-project-classpath/
But sometimes the main is even too late, for example when using spring.
Is there a way to print something(e.g. classpath) even before Spring starts the injection process?
Providing some context, i am running a unit test in spring as follows:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:/jmsAppContext.xml")
public class TestProjectProvisioningIntegration
{
....

}

It finds correctly the jmsAppContext.xml, but fails to find one of the properties files.

A: To get the same effect as you have in the link you posted, you could get the classpath in a static initializer (just do the same as the example, only then in a static { ... } block instead of a main method. The JVM will execute the static initializer first, before loading any other classes your class depends on (other than the classes you reference in the static initializer).


text:
Q: MYSQL move some values to new column depending on uniqueness I have a list of products, product options (eg size) and option values (eg S/M/L/XL) all stored in a single table per the image below:

This works fine when a product has only one option set (eg size). As you will see product ID 53 has two types of options, being size (option_id 11)and colour (option_id 13).
Further in the database I also have products that can have up to three types of options, and I'm trying to write a script that accommodates these variances as I'm trying to migrate my online store to another system which is pretty specific about the format they receive product data in.
I am struggling to figure out the right way to approach this problem and write the UPDATE statement in a way that moves the 2nd and 3rd options/value sets into the appropriate 2nd and 3rd columns (option_2_name, option_2_value_name and option_3_name, option_3_value_name respectively, if they of course exist per product).
To help visually, here's another image that shows where I want (in this case) the size options/values for product 53 to move to:

Can you help point me in the right direction?

A: Well, like I said, it's not a normal table structure, so operations on it are going to be weird, and I'm still questioning this approach. But here's something you can use to move to column 2:
update table_name t1
set option_2_name = option_1_name, option_2_value=option_1_value,
    option_1_name=NULL, option_1_value=NULL
where
(select count(distinct option_id)
   from table_name t2
  where t1.product_id = t2.product_id
    and t1.option_id > t2.option_id) = 1

and to column 3:
update table_name t1
set option_3_name = option_1_name, option_3_value=option_1_value,
    option_1_name=NULL, option_1_value=NULL
where
(select count(distinct option_id)
   from table_name t2
  where t1.product_id = t2.product_id
    and t1.option_id > t2.option_id) = 2

And so on you you will need more.
That will move higher option ids further. I didn't test it, but it should run fine.


text:
Q: SSRS report deployment on azure I am using SSRS report in my web application now, I want to deploy SSRS report on azure, I found one option using azure VM but its costly as I am using free account, Is there any other option?
Please suggest me the proper way.

A: Now spinning a SQL Server VM might result in costs way higher than you might expect (due to licenses), so always make sure you run it on a version of SQL Server Developer, which has all the features of the highest SQL edition, but it is free (not to be run in production). See here.
If you use one of the SQL Gallery Images, then you don't need an additional SQL Server license. See Azure VM pricing here
You can try Pay-As-You-Go option
You need to be more specific - the cost of licensing what? Azure SQL Reporting? Virtual Machines? SQL Server licensing?
you would have to set up SSRS somewhere. Azure-hosted VM depends on a lot of factors such as your budget, on-premise infrastructure capacity, overall cloud strategy of your organization.
Licensing - Azure lets you pay directly for VMs that include SSRS. For example you can get SQL Server Standard 2012 (which includes SSRS) on a "Small" Server 2012 vm for about


text:
Q: set default value to more than 1 product ID using javascript I have set default value to an input box and set it to readonly.
I also disable some select options.
It is working but when I add another ID for another product, only 1 ID works.
Please note that I don't have access to the actual html pages. I can only access the js file.
What I need is:
if I go to product 1 OR product 2, I will see the text box is set to 28 in readonly and the Weeks/Months disabled.
Below is my sample HTMLs.
The HTMLs below are two different HTML pages.
HTML for product 1

Deliver products every <input type="text" id="thisInput_prod1">

<select id="thisSelect_prod1">
    <option value="Days" selected>Days</option>
    <option value="Weeks">Weeks</option>
    <option value="Month">Month</option>
</select>

HTML for product 2

Deliver products every <input type="text" id="thisInput_prod2">

<select id="thisSelect_prod2">
    <option value="Days" selected>Days</option>
    <option value="Weeks">Weeks</option>
    <option value="Month">Month</option>
</select>

This is the .js file
window.onload = SetDefaultValue;

function SetDefaultValue() {

document.getElementById('thisInput_prod1').setAttribute('value','28');
document.getElementById('thisInput_prod1').readOnly = true;
var x = document.getElementById('thisSelect_prod1');
x.options[1].disabled=true;
x.options[2].disabled=true;

//below is to set the other product - I disable because its not working
//document.getElementById('thisInput_prod2').setAttribute('value','28');
//document.getElementById('thisInput_prod2').readOnly = true;
//var y = document.getElementById('thisSelect_prod2');
//y.options[1].disabled=true;
//y.options[2].disabled=true;
}

A: When there's no thisInput_prod2 element, document.getElementById('thisInput_prod2') will evaluate to null, and then the code will abort trying to call .setAttribute on that null. You should assign it to a variable and test it to see if it's === null before dereferencing it.

A: Here is your working example : Fiddle
    document.getElementById('thisInput_prod1').value = '28';
    document.getElementById('thisInput_prod1').readOnly = true;
    var x = document.getElementById('thisSelect_prod1');
    x.options[1].disabled = true;
    x.options[2].disabled = true;

    document.getElementById('thisInput_prod2').readOnly = true;
    var y = document.getElementById('thisSelect_prod2');
    y.options[1].disabled=true;
    y.options[2].disabled=true;


text:
Q: Apply style to "i"th node, if "i" appears in a list of pairs I have written a command to make the following image with TikZ:

Calling the command that created this image looks like this:
    \drawmatching{%
        G,A,T,T,A,C,A}{%
        G,C,A,T,T,G,C,A%
    }{
        0/0,
        1/2,
        2/3,
        3/4,
        5/6,
        6/7%
    }

This says to link position 0 in the first image with 0 in the second, position 1 in the first image with 2 in the second, etc.
Now what I'd like to do is style each of the letters that is at the end of an edge by, for instance, making it bold (or red, or whatever). That is, in the top string, I'd like letters at indices 0, 1, 2, 3, 5, and 6 to be bold, and in the bottom string, I'd like the letters at 0, 2, 3, 4, 6, and 7 to be bold. And this is where I'm stuck.
Here is the full MWE:
\documentclass{standalone}

\usepackage{tikz}
\usepackage{xparse}

\begin{document}

\newcommand{\letterspacing}{.5}

\NewDocumentCommand{\drawmatching}{m m m O{0} O{0}}{
    \pgfmathsetmacro{\xstart}{#4}
    \pgfmathsetmacro{\ystart}{#5}

    \foreach [count=\i] \letter in {#1}{
        \pgfmathtruncatemacro{\index}{\i-1}

        % check if \index in the list of pairs?
        \tikzset{letter/.style={}}

        \node[anchor=base, letter] at (\xstart+\letterspacing*\i,\ystart) (a\index) {\texttt \letter};
        \node[above=.45cm, anchor=base] at (\xstart+\letterspacing*\i,\ystart) {\tiny \index};

    }

    \foreach [count=\i] \letter in {#2}{
        \pgfmathtruncatemacro{\index}{\i-1}
        \node[anchor=base] at (\xstart+\letterspacing*\i,\ystart-2) (b\index) {\texttt \letter};
        \node[anchor=north] at (\xstart+\letterspacing*\i,\ystart-2) {\tiny \index};
    }

    \foreach \i/\j in {#3}{
        \draw (a\i) -- (b\j);
    }
}

\begin{tikzpicture}
    \drawmatching{%
        G,A,T,T,A,C,A}{%
        G,C,A,T,T,G,C,A%
    }{
        0/0,
        1/2,
        2/3,
        3/4,
        5/6,
        6/7%
    }
\end{tikzpicture}

\end{document}

My first thought was to check at the commented line above whether \index appears as the first number in a pair in the list of ordered pairs, but I fell down an xparse rabbit hole. Is there an easy way to do this?

A: An approach with LaTeX conditionals and style commands. The idea is to do a nested loop over #3 each time a letter needs to be printed, and in that nested loop check if any of the numbers mentioned in #3 (first number for the top, second number for the bottom) matches the current index.
If a match is found (using \ifnum[index from inner loop]=[index from outer loop]), a command can be defined (called \letterstyle in the code below) to change the font, for example use a color, or italics, etc. This command should be assigned a default value before the loop that will be used if no match is found for any element in the loop.
Note that I switched \texttt to \ttfamily in your code, \texttt is a command that takes an argument, while \ttfamily is a switch that changes the font for all remaining text in the current scope (or until a new family is used with another font switch).
MWE:
\documentclass{standalone}

\usepackage{tikz}
\usepackage{xparse}

\begin{document}

\newcommand{\letterspacing}{.5}

\NewDocumentCommand{\drawmatching}{m m m O{0} O{0}}{
    \pgfmathsetmacro{\xstart}{#4}
    \pgfmathsetmacro{\ystart}{#5}

    \foreach [count=\i] \letter in {#1}{
        \pgfmathtruncatemacro{\index}{\i-1}

        % default style if no match is found: black
        \gdef\letterstyle{\color{black}}
        \foreach \lfirst/\lsecond in {#3}{
            \ifnum\lfirst=\index\gdef\letterstyle{\color{red}}\fi
        }
        \node[anchor=base] at (\xstart+\letterspacing*\i,\ystart) (a\index) {\ttfamily\letterstyle\letter};
        \node[above=.45cm, anchor=base] at (\xstart+\letterspacing*\i,\ystart) {\tiny \index};

    }

    \foreach [count=\i] \letter in {#2}{
        \pgfmathtruncatemacro{\index}{\i-1}
        % default style if no match is found: italics
        \gdef\letterstyle{\itshape}
        \foreach \lfirst/\lsecond in {#3}{
           \ifnum\lsecond=\index\gdef\letterstyle{\upshape}\fi
        }
        \node[anchor=base] at (\xstart+\letterspacing*\i,\ystart-2) (b\index) {\ttfamily\letterstyle\letter};
        \node[anchor=north] at (\xstart+\letterspacing*\i,\ystart-2) {\tiny \index};
    }

    \foreach \i/\j in {#3}{
        \draw (a\i) -- (b\j);
    }
}

\begin{tikzpicture}
    \drawmatching{%
        G,A,T,T,A,C,A}{%
        G,C,A,T,T,G,C,A%
    }{
        0/0,
        1/2,
        2/3,
        3/4,
        5/6,
        6/7%
    }
\end{tikzpicture}

\end{document}

Result:


text:
Q: Is it faster to create a new class inside a function or pass it as a parameter in PHP I've got a class that is used in a few functions independently from one another. So my question is: is it faster to pass the initiated class as a parameter to the function or to create a new instance every time the function is called upon?
Like this:
$class_a = new Class_a;

function rnd_fun($class_a){
... do stuff...
}

Or like this:
function rnd_fun(){
$class_a = new Class_a;
... do stuff...
unset($class_a);
}

A: I tried to do a benchmark and these are the results by using this
very creative class
class Class_a {
    public $first_name = "";
    public $age = "";

    public function setVar($first_name, $age){
        $this->first_name = $first_name;
        $this->age = $age;
    }

    public function wasteTime(){
        $i = 0;
        while($i < 100){
            $this->age = $this->age * $i;
            $this->age = $this->age / pi();
            $i++;
        }
    }
}

By passing the class as a parameter I got something around 0.46s using this code:
$class_a = new Class_a;

$i = 0;
while($i < 10000){
    test($class_a);
    $i++;
}

function test($class_a){
        $class_a->setVar("Geronimo", "72.1");
        $class_a->wasteTime();
    }

This is by initiating a new class inside the function:
$i = 0;
while($i < 10000){
    test();
    $i++;
}

function test(){
    $class_a = new Class_a;
    $class_a->setVar("Geronimo", "72.1");
    $class_a->wasteTime();
    unset($class_a);
}

I have to point out though that the second method took a slightly higher time to execute (around 0.47s).
However I believe that the difference between the two is negligible since both run at around the same speed for this many iteration and their delay won't be noticeable in an average piece of code.


text:
Q: Obj-C objects not being released in a C callback function I am using the AudioFileOpenWithCallbacks function in my app to provide MP3 data in chunks. I call the function as follows:
AudioFileOpenWithCallbacks((__bridge void *)(self), TTMAudioFile_ReadProc, NULL, TTMAudioFile_GetSizeProc, NULL, 0, &aqData.mAudioFile);

In this case, self is the containing Objective-C class.
My TTMAudioFile_ReadProc callback function is as follows:
OSStatus TTMAudioFile_ReadProc(void *inClientData, SInt64 inPosition, UInt32 requestCount, void *buffer, UInt32 *actualCount) {

    TTMAudioQueuePlayer *this = (__bridge TTMAudioQueuePlayer *)inClientData;
    NSData *data = [this.decryptor dataAtOffset:inPosition length:requestCount error:NULL];
    memcpy(buffer, data.bytes, data.length);

    NSUInteger length = data.length;
    *actualCount = (UInt32)length;

    return noErr;
}

This works, but the NSData isn't being released. Profiling Allocations in Instruments reveal many allocations that look like the following:

Apparently there are two extra retain calls in my callback function, but I don't see where I can be retaining them. Furthermore, I am using ARC, so I don't know why this is happening either.

A: I needed an autorelease pool.
The C callback function TTMAudioFile_ReadProc is called on a separate thread from the main thread. In this case, an autorelease pool is not automatically created, unlike when working with dispatch queues.
OSStatus TTMAudioFile_ReadProc(void *inClientData, SInt64 inPosition, UInt32 requestCount, void *buffer, UInt32 *actualCount) {
    @autoreleasepool {
        TTMAudioQueuePlayer *this = (__bridge TTMAudioQueuePlayer *)inClientData;
        NSData *data = [this.decryptor dataAtOffset:inPosition length:requestCount error:NULL];

        memcpy(buffer, data.bytes, data.length);
        NSUInteger length = data.length;
        *actualCount = (UInt32)length;

        return noErr;
    }
}


text:
Q: Friend shares his games with multiple people on family sharing but I get ejected My friend shares his library with multiple people, including me. As he is the host of the library, if the playes a game then I get ejected. I understand that well. What I don't understand is this - if other guy from the list playes a shared game, I also get ejected. Which is weird, since if I was already playing a shared game, other people shouldn't be able to play them, and therefore not eject me. So what is happening here?

A: From what I can tell, whoever starts a game will kick off any other person already playing. The exception is for the account owner, who takes priority over everyone else.
There's a Steam FAQ Page that seems vaguely helpful - I'll summarize the important parts here:

Can two users share a library and both play at the same time?
No, a shared library may only be accessed by one user at a time.

When I authorize a device to lend my library to others, do I limit my own ability to access and play my games?
As the account holder, you may always access and play your games at any time. If you decide to start playing when another user is already playing one of your games, he/she will be given a few minutes to either purchase the game or quit playing.

My understanding is that deciding to start playing will force anyone who isn't the account owner to quit.
There's also a similar question from Arqade in 2016 that uses an apt explanation:

Family sharing acts as though you were passing the account login back and forth.


text:
Q: Whats is the correct plural form of compound nouns First: This is not a question about spelling in software development. But I'm often stumbling upon it in software development.
In software development it's often necessary to name entities both in singular and plural form to distinguish if it's about a single entity or a list of such entities.

$car  = new Car();     // one car
$cars = new Cars();    // a list of cars
$cars->add( $car );    // add a car to the list of cars

Now in my current use case I'm implementing a QR code algorithm. I need a mapping of encoding modes to their indicators. That means I have multiple encoding modes, every one of them mapped to a different indicator.
Would a list of those mappings be called

*

*'encoding mode indicators'

*

*This would imply their is one encoding mode with multiple indicators.

*'encoding modes indicators'

*

*This would imply their is multiple encoding modes with multiple indicators.

I could name that list 'encoding mode indicator mappings'. That would nail it. But while it's a use case in software development, what would a correct real world spelling look like? There are multiple cases, I'd have to decide which plural form is correct and currently I don't now.

A: Typically, you pick the operative noun and make that plural.
For example:

*

*a solicitor general is a solicitor (the title doesn't tell you they're a general), so the plural would be solicitor_s_ general; but

*a bus timetable is a timetable, not a bus, so the plural is bus timetable_s_.
Note that "bus timetables" doesn't tell you whether you have only 1 bus or multiple buses. It only tells you that you have multiple timetables, and that "bus" is the topic of those timetables. Also, because "bus" is used here as a descriptive noun (functioning like an adjective), the plural buses isn't normally used here. There are exceptions, but in this particular case, if you want to express that all the timetables relate to the same bus, you'd say something like "timetables for one bus". If they are for 5 buses, you can say "timetables for five buses", and so on.
In your case, the mapping is neither an encoding mode nor an indicator. So you'll need to properly name the mapping first. Your rejected mappings works best here.

A: Mode indicator is a noun1 + noun2 construction = a noun2 associated with noun1. In this, noun1 typically acts adjectivally and is not inflected. A mode indicator would tell you which of many modes is operating.
In encoding mode, encoding is either a gerund or an adjective and follows the above guidance.
In either case it is not inflected.
"encoding mode indicator" can either be (i) an adjective, i.e. a mode indicator that encodes or (ii) a gerund - a thing that indicates the mode of action of encoding.
From the context I would choose (ii) and therefore the plural of encoding mode indicator is encoding mode indicators
Consider
We have a language department -> we have two language departments.
We have a French language department -> we have two French language departments.


text:
Q: JUnit with Ant returns "No runnable methods" I'm banging my head against a wall - I have a basically empty test file (its more to test my build file than anything else
A few months back my build file got corrupted - and for some reason starting a new project didnt fix it, so I had to make one from scratch, initially it just needed to support build, but now it requires test - and it is not working :(
package com.rcdc.questiondatabase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
public class RCDCServiceTest {

  public RCDCServiceTest() {
  }

  @BeforeClass
  public static void setUpClass() {
  }

  @AfterClass
  public static void tearDownClass() {
  }

  @Before
  public void setUp() {
  }

  @After
  public void tearDown() {
  }

// TODO add test methods here.
  // The methods must be annotated with annotation @Test. For example:
  //
  @Test
  public void testHelloTest() {
    if(true){
      assertTrue(true);
    }
  }
}

My build file:
<?xml version="1.0" encoding="UTF-8"?>

<project name="INCAP" default="default" basedir=".">
    <description>Builds, tests, and runs the project INCAP.</description>

  <property name="build.dir" value="war/WEB-INF/classes"/>
  <property name="dist.dir" value="dist"/>
  <property name="test.dir" value="test"/>
  <property name="test.build.dir" value="testbuild"/>
  <path id="project.classpath">
    <pathelement path="war/WEB-INF/classes" />
    <fileset dir="war/WEB-INF/lib">
      <include name="**/*.jar" />
    </fileset>
    <pathelement path="${java.home}/../lib/tools.jar:${libs.jsp-compiler.classpath}:${libs.jsp-compilation.classpath}"/>
  </path>
  <path id="project.test.classpath">
    <pathelement path="war/WEB-INF/classes" />
    <fileset dir="war/WEB-INF/lib">
      <include name="**/*.jar" />
    </fileset>
    <pathelement path="${java.home}/../lib/tools.jar:${libs.jsp-compiler.classpath}:${libs.jsp-compilation.classpath}"/>
  </path>

   <target name="copyjars" description="Copies the App Engine JARs to the WAR.">
  </target>
  <target name="clean">
    <delete dir="war/WEB-INF/classes"/>
  </target>
  <target name="compile" depends="copyjars" description="Compiles Java source and copies other source files to the WAR.">
    <mkdir dir="${build.dir}" />
    <copy todir="${build.dir}">
      <fileset dir="src">
        <exclude name="**/*.java" />
      </fileset>
    </copy>
    <property name="myclasspath" refid="project.classpath"/>

    <echo message="Classpath ${myclasspath}" />
    <javac
        srcdir="src"
        destdir="${build.dir}"
        classpathref="project.classpath"
        debug="on" />
  </target>

  <target name="compiletest" depends="compile" description="compile the tests " >
    <mkdir dir="${test.build.dir}" />
    <javac
        srcdir="test"
        destdir="${test.build.dir}"
        classpathref="project.test.classpath"
        debug="on" />
  </target>

  <target name="dist" depends="compile">
    <mkdir dir="war/WEB-INF/classes" />
    <copy todir="war/WEB-INF/classes">
      <fileset dir="src">
        <exclude name="**/*.java" />
      </fileset>
    </copy>
    <property name="myclasspath" refid="project.classpath"/>
  </target>

  <target name="test" depends="compiletest" description="run the tests " >
    <junit printsummary="yes" fork="yes" haltonfailure="yes">
      <formatter type="plain"/>
      <batchtest fork="true">
        <fileset dir="${test.dir}">
          <include name="**/*Test*.java"/>
        </fileset>
      </batchtest>
      <classpath refid="project.test.classpath" />
    </junit>
  </target>

  <target name="test-single" depends="compiletest" description="Run a single test">
    <fail unless="browser.context" message="Property not set: 'test-class'"/>
    <echo message="                             -- Running single test --"/>
    <echo message="                                 -- ${browser.context} --" />
    <junit printsummary="yes" fork="yes" showoutput="yes" haltonfailure="yes">
      <formatter type="plain"/>
      <batchtest fork="true">
        <fileset dir="test">
          <include name="${javac.includes}"/>
        </fileset>
      </batchtest>
      <classpath refid="project.classpath" />
    </junit>
</target>
</project>

A: Your test classpath doesn't seem to have your test classes on it, so although Ant knows which test names it should look for to run, JUnit can't find the associated class to run.
From your follow-up comment - when Netbeans executes tests directly, it invokes it's own JUnit runner with associated listeners - or results parsers - that hook into the JUnit lifecycle so know what tests are doing. When you tell Netbeans to run an Ant task, it doesn't know about what Ant is doing (it doesn't have sight of the tasks within Ant), so doesn't know whether you're trying to run the JUnit task, or one of the many other tasks within Ant that it wouldn't make sense to try and reports on, other than in the console.


text:
Q: Putting a toolbar directly under a navigation controller without hiding the content underneath the toolbar I am trying to put a toolbar directly beneath a navigation bar but I need the toolbar to not hide the content from the view directly beneath it. My quick solution was to set the navigation controller's native toolbar to visible, which works and properly resizes the view beneath it so that it doesn't let anything hide behind it, BUT the default toolbar shows at the bottom of the screen.
I need it to be at the top, just under the nav bar. I figure the easy solution would be to change the frame of the default toolbar (which I don't know how to do) OR to position a new instance of the toolbar onto the view (which works but it hides the content beneath it) but have it resize the views below.
Please see the following image that I found to see what I'm trying to do. (note how the tableview's first row starts UNDER the tab bar)

Thanks!!!

A: You are confusing two things.  The NavigationController toolbar property IS the bottom bar, any toolbar that you add to a view has nothing to do with the nav controller but is a property of that view.
If you have your own toolbar at the top of a view you need to move the rest of the view content down or set that toolbar to translucent if thats what your looking for.
Again the nav controller toolbar is always the bottom bar, the toolbar you drop in IB is just a toolbar for that view that you can put anywhere.

A: I don't believe you can change the frame of the default toolbar. You will need to create your own instance of a toolbar, position it at the bottom of the navigation bar and resize your tableView to fit below.
We can't see how you have your views set up but if you are starting with a view that is subclassed as UITableViewController you will have trouble doing that. What you want is to start with a UIViewController as your master controller, add a tableview and toolbar as subviews. Then position and size them as appropriate.
If you are hiding and showing the toolbar you will create a method to move it up under the navigation controller and again resize the tableview.


text:
Q: ConTeXt: \placeinitial to account for quotation mark Background
In novels, a lettrine is typically a letter. When writing prose, sometimes chapters begin with an opening quotation mark.
Problem
The quotation mark is stylized, rather than the first letter of the paragraph.
Code
Consider:
\setuphead[chapter][
  after={\placeinitial},
  page=no,
]

\starttext
\chapter{Harriet Tubman}
"Every great dream begins with a dreamer. Always remember, you have within
you the strength, the patience, and the passion to reach for the stars to
change the world.
\chapter{Eleanor Roosevelt}
Great minds discuss ideas; average minds discuss events; small minds
discuss people.
\stoptext

This produces:

Question
Without changing any text between \starttext and \stoptext, how would you change the \placeinitial macro to allow for changing the size and alignment of a quotation mark that is a chapter's first character---and format the first letter into a lettrine, as well?
Related
See the following question for examples:

*

*size and alignment of quotation mark with lettrine

A: First of all, none of this is documented in https://wiki.contextgarden.net/Command/setupinitial. I had to find this out by reading the Lua source.
It looks like you cannot apply special formatting to the opening quote. There is just no code for it and since it is in Lua there is also no straightforward and easy way to hook into it. What is available though is skipping the quote by adding first to the methods (very intuitive...).
To request more features you will have to contact the mailing list.
\defineinitial[two][method={first,auto}]
\setuphead[chapter][
  after={\placeinitial[two]},
  page=no,
]

\starttext
\chapter{Harriet Tubman}
"Every great dream begins with a dreamer. Always remember, you have within
you the strength, the patience, and the passion to reach for the stars to
change the world.
\chapter{Eleanor Roosevelt}
Great minds discuss ideas; average minds discuss events; small minds
discuss people.
\stoptext


text:
Q: react js with dynamic routing .not able to fetch the data from fake json server when i click on the image item the detail page should be open coontaing all the details of that particular image..i am not able to fetch the ingrdients part and the details are getting from the json server the folling code is:
home.js
import Homeview from './Homeview/Homeview'

export default class Home extends Component {

    state= {
        img : []
    }
    componentDidMount(){
        axios.get('http://localhost:3001/food')
        .then(res=>{
            const data = res.data
            this.setState({
                img : data
            })
        })
    }
    render() {
        return (
            <Homeview homeview= {this.state.img}/>
        )
    }
}

homeview.js
const Homeview = (props) => {

const {homeview} = props
return (

        {homeview.map((e)=>{
            return(

                    <Link to={`/Home/`+e.id}></Link>

            )

    })}

)
}

export default Homeview

homedetail.js
import React, { Component } from 'react'
import axios from 'axios'

const url = "http://localhost:3001/food"
export default class Homedetail extends Component {

state= {
    topicd : ''
}

componentDidMount(){
    axios.get(`${url}/${this.props.match.params.id}`)
    .then(res=>{
        const data = res.data
       // console.log(data)
        this.setState({
            topicd:data
        })
    })
}
render() {

    console.log(this.state.topicd.ingredients)

    let ingredients =null

    if(ingredients===true){
        ingredients = this.state.topicd.ingredients.map((e)=>{
            return(

{e.name}

{e.type}

            )
        })
        return ingredients
    }
    return (

{this.state.topicd.name}

            {ingredients}
            {/* {this.state.topicd.food.ingredients.map((e)=>{
                return (

                        {e.name}
                        {e.type}

                )
            })} */}

    )
}

}
db.json
{
    "food":
    [
    {
        "id":1,
        "name": "Crock Pot Roast",
        "ingredients": [
            {
                "quantity": "1 package",
                "name": "brown gravy mix",
                "type": "Baking"
            },
            {
                "quantity": "1 package",
                "name": "dried Italian salad dressing mix",
                "type": "Condiments"
            },
            {
                "quantity": "1 package",
                "name": "dry ranch dressing mix",
                "type": "Condiments"
            },
            {
                "quantity": "1/2 cup",
                "name": "water",
                "type": "Drinks"
            }
        ],
        "steps": [
            "Place meet roast in crock pot.",
            "\t Mix the dried mixes together in a bowl and sprinkle over the roast.",
            "\t Pour the water around the roast.",
            "\t Cook on low for 7-9 hours."
        ],
        "imageURL": "http://img.sndimg.com/food/image/upload/w_266/v1/img/recipes/27/20/8/picVfzLZo.jpg",
        "originalURL": "http://www.food.com/recipe/to-die-for-crock-pot-roast-27208"
    },
    {
        "id":2,
        "name": "Roasted Asparagus",
        "ingredients": [
            {
                "quantity": "1 lb",
                "name": " asparagus",
                "type": "Produce"
            },
            {
                "quantity": "1 1/2 tbsp",
                "name": "olive oil",
                "type": "Condiments"
            },
            {
                "quantity": "1/2 tsp",
                "name": "kosher salt",
                "type": "Baking"
            }
        ],
        "steps": [
            "Preheat oven to 425°F.",
            "\t Cut off the woody bottom part of the asparagus spears and discard.",
            "\t With a vegetable peeler, peel off the skin on the bottom 2-3 inches of the spears (this keeps the asparagus from being all.\",string.\", and if you eat asparagus you know what I mean by that).",
            "\t Place asparagus on foil-lined baking sheet and drizzle with olive oil.",
            "\t Sprinkle with salt.",
            "\t With your hands roll the asparagus around until they are evenly coated with oil and salt.",
            "\t Roast for 10-15 minutes, depending on the thickness of your stalks.",
            "\t They should be handeled gentally when pierced with the tip of a knife.",
            "\t The tips of the spears turn to deep brown but observe them keenly, to avoid burning.",
            "\t They are plain, its good to serve them with a light vinaigrette. If need something add spices to balance the meal."
        ],
        "imageURL": "http://img.sndimg.com/food/image/upload/w_266/v1/img/recipes/50/84/7/picMcSyVd.jpg",
        "originalURL": "http://www.food.com/recipe/roasted-asparagus-50847"
    },
    {
        "id":3,
        "name": "Curried Lentils and Rice",
        "ingredients": [
            {
                "quantity": "1 quart",
                "name": "beef broth",
                "type": "Misc"
            },
            {
                "quantity": "1 cup",
                "name": "dried green lentils",
                "type": "Misc"
            },
            {
                "quantity": "1/2 cup",
                "name": "basmati rice",
                "type": "Misc"
            },
            {
                "quantity": "1 tsp",
                "name": "curry powder",
                "type": "Condiments"
            },
            {
                "quantity": "1 tsp",
                "name": "salt",
                "type": "Condiments"
            }
        ],
        "steps": [
            "Bring broth to a low boil.",
            "\t Add curry powder and salt.",
            "\t Cook lentils for 20 minutes.",
            "\t Add rice and simmer for 20 minutes.",
            "\t Enjoy!"
        ],
        "imageURL": "http://dagzhsfg97k4.cloudfront.net/wp-content/uploads/2012/05/lentils3.jpg"
    },
    {
        "id":4,
        "name": "Big Night Pizza",
        "ingredients": [
            {
                "quantity": "5 teaspoons",
                "name": "yeast",
                "type": "Baking"
            },
            {
                "quantity": "5 cups",
                "name": "flour",
                "type": "Baking"
            },
            {
                "quantity": "4 tablespoons",
                "name": "vegetable oil",
                "type": "Baking"
            },
            {
                "quantity": "2 tablespoons",
                "name": "sugar",
                "type": "Baking"
            },
            {
                "quantity": "2 teaspoons",
                "name": "salt",
                "type": "Baking"
            },
            {
                "quantity": "2 cups",
                "name": "hot water",
                "type": "Misc"
            },
            {
                "quantity": "1/4 cup",
                "name": "pizza sauce",
                "type": "Misc"
            },
            {
                "quantity": "3/4 cup",
                "name": "mozzarella cheese",
                "type": "Dairy"
            }
        ],
        "steps": [
            "Add hot water to yeast in a large bowl and let all them to mix well for 15 minutes.",
            "\t Add oil, sugar, salt and flour and allow them to mix well for next hour.",
            "\t Knead the dough and spread it on a pan.",
            "\t Spread pizza sauce and add the cheese.",
            "\t Garnish it with toppings.",
            "\t Bake at 400°F for 15 minutes.",
            "\t Enjoy!"
        ],
        "imageURL": "http://upload.wikimedia.org/wikipedia/commons/c/c7/Spinach_pizza.jpg"
    },
    {
        "id":5,
        "name": "Cranberry and Apple Stuffed Acorn Squash Recipe",
        "ingredients": [
            {
                "quantity": "2",
                "name": "acorn squash",
                "type": "Produce"
            },
            {
                "quantity": "1",
                "name": "boiling water",
                "type": "Drinks"
            },
            {
                "quantity": "2",
                "name": "apples chopped into 1.4 inch pieces",
                "type": "Produce"
            },
            {
                "quantity": "1/2 cup",
                "name": "dried cranberries",
                "type": "Produce"
            },
            {
                "quantity": "1 teaspoon",
                "name": "cinnamon",
                "type": "Baking"
            },
            {
                "quantity": "2 tablespoons",
                "name": "melted butter",
                "type": "Dairy"
            }
        ],
        "steps": [
            "Cut squash in half, remove seeds.",
            "\t Place squash in baking dish, cut down the sides.",
            "\t Pour water to 1/4 th inch of bowl.",
            "\t Bake for 30 minutes at 350°F.",
            "\t In another large bowl, combine remaining ingredients.",
            "\t Remove squash from oven, fill with mix.",
            "\t Bake for 30-40 minutes more until squash tenders.",
            "\t Enjoy!"
        ],
        "imageURL": "http://elanaspantry.com/wp-content/uploads/2008/10/acorn_squash_with_cranberry.jpg",
        "originalURL": ""
    },
    {
        "id":6,
        "name": "Mic's Yorkshire Puds",
        "ingredients": [
            {
                "quantity": "200g",
                "name": "plain flour",
                "type": "Baking"
            },
            {
                "quantity": "3",
                "name": "eggs",
                "type": "Dairy"
            },
            {
                "quantity": "300ml",
                "name": "milk",
                "type": "Dairy"
            },
            {
                "quantity": "3 tbsp",
                "name": "vegetable oil",
                "type": "Condiments"
            }
        ],
        "steps": [
            "Put the flour and some seasoning into a large bowl.",
            "\t Keep adding eggs(one at a time).",
            "\t Whisk in milk until you have a smooth batter.",
            "\t Cool it in the fridge for at least 30 minutes.",
            "\t Heat oven to 22°C/gas mark it to 7.",
            "\t Pour the oil into the holes of muffin tin.",
            "\t Heat tin in the oven for 5 minutes.",
            "\t Ladle the batter into the tin.",
            "\t Bake for 30 minutes until well browned and risen."
        ],
        "imageURL": "http://upload.wikimedia.org/wikipedia/commons/f/f9/Yorkshire_Pudding.jpg",
        "originalURL": "http://upload.wikimedia.org/wikipedia/commons/f/f9/Yorkshire_Pudding.jpg"
    },
    {
        "id":7,
        "name": "Old-Fashioned Oatmeal Cookies",
        "ingredients": [
            {
                "quantity": "1 cup",
                "name": "raisins",
                "type": "Produce"
            },
            {
                "quantity": "1",
                "name": "cup water",
                "type": "Drinks"
            },
            {
                "quantity": "3/4 cup",
                "name": "shortening",
                "type": "Baking"
            },
            {
                "quantity": "1 1/2 cups",
                "name": "sugar",
                "type": "Baking"
            },
            {
                "quantity": "2 1/2 cups",
                "name": "flour",
                "type": "Baking"
            },
            {
                "quantity": "1 tsp.",
                "name": "soda",
                "type": "Baking"
            },
            {
                "quantity": "1 tsp.",
                "name": "salt",
                "type": "Baking"
            },
            {
                "quantity": "1 tsp.",
                "name": "cinnamon",
                "type": "Baking"
            },
            {
                "quantity": "1/2 tsp.",
                "name": "baking powder",
                "type": "Baking"
            },
            {
                "quantity": "1/2 tsp.",
                "name": "cloves",
                "type": "Baking"
            },
            {
                "quantity": "2 cups",
                "name": "oats",
                "type": "Baking"
            },
            {
                "quantity": "1/2 cup",
                "name": "chopped nuts",
                "type": "Baking"
            }
        ],
        "steps": [
            "Boil raisins with water over medium heat until they are plump, for about 15 minutes.",
            "\t Drain raisins, reserving the liquid.",
            "\t Add enough water to reserved liquid to measure 1/2 cup.",
            "\t Heat oven to 400°C.",
            "\t Mix it thoroughly with sugar, eggs and vanilla.",
            "\t Stir in reserved liquid.",
            "\t Blend in remaining ingredients.",
            "\t Drop dough by rounded teaspoon about 2 inches apart onto ungreased baking sheet.",
            "\t Bake for next 8 to 10 minutes.",
            "\t About six pieces of cookies."
        ],
        "imageURL": "http://s3.amazonaws.com/gmi-digital-library/65caecf7-a8f7-4a09-8513-2659cf92871e.jpg",
        "originalURL": "#"
    },
    {
        "id":9,
        "name": "Curried chicken salad",
        "ingredients": [
            {
                "quantity": "3",
                "name": "skinless, boneless chicken breasts, halved lengthwise",
                "type": "Meat"
            },
            {
                "quantity": "1/2 cup",
                "name": "mayonnaise",
                "type": "Baking"
            },
            {
                "quantity": "1 tbsp",
                "name": "lemon zest",
                "type": "Produce"
            },
            {
                "quantity": "1 tbsp ",
                "name": "lemon juice",
                "type": "Produce"
            },
            {
                "quantity": "1 1/2 tsp",
                "name": "curry powder",
                "type": "Baking"
            },
            {
                "quantity": "1/4 tsp",
                "name": "salt",
                "type": "Baking"
            },
            {
                "quantity": "2",
                "name": "ripe mangoes, diced",
                "type": "Produce"
            },
            {
                "quantity": "1/4 cup",
                "name": "dried cranberries",
                "type": "Produce"
            },
            {
                "quantity": "2",
                "name": "green onions, thinly sliced",
                "type": "Produce"
            },
            {
                "quantity": "1",
                "name": "celery stalk, finely chopped",
                "type": "Produce"
            },
            {
                "quantity": "6 leaves",
                "name": "Boston lettuce",
                "type": "Produce"
            },
            {
                "quantity": "6",
                "name": "English muffins, toasted",
                "type": "Misc"
            }
        ],
        "steps": [
            "Arrange the chicken in a single layer within the large pot.",
            "\t Add water and boil chicken over medium-high.",
            "\t Flip chicken, reduce heat to medium and simmer until cooked, about 6 more min.",
            "\t Cool.",
            "\t Add mayo with lemon zest, juice, curry and salt in large bowl.",
            "\t Using 2 forks, shred chicken, then add mayo mixture with mango, cranberries, green onions and celery.",
            "\t Divide among muffins with lettuce leaves",
            "\t Serve the Sandwich with tops along with chicken"
        ],
        "imageURL": "http://www.chatelaine.com/wp-content/uploads/2013/05/Curried-chicken-salad.jpg",
        "originalURL": "http://www.chatelaine.com/recipe/stovetop-cooking-method/curried-chicken-salad/"
    }
]
}

A: i see you using the component/presentational pattern, but i dont see where did you call HomeDetail and where is the onClick function to handler the click you talk about, maybe im missing something,


text:
Q: how to enter while loop using gdb? I have a while loop as below.
while (*d++ = *sc++)

As I wish to understand pointers in dept I would like to enter the while loop and understand how the while loop is working with the pointers.
I used step in gdb but it does not go into the while loop completely. Is there any way to get into the while loop and understand the manipulation in every step.

A: * binds tighter then postfix ++. ++ on the right side will be applied last, so:
while (*d++ = *sc++)

is the same as:
while (*d = *sc)
{
  d++;
  sc++;

The modification is much better to be traced in gdb.
Update:
Don't code like this OP!
Although it might look cool, and prove you are smart. It's difficult to be parsed by the common human brain and therefore error prone? Which we do not want, do we?
Better go for a more clear alternative like proposed above and let the compiler scramble the code.

A: Option 1:
Look into the assembly code debugging as suggested by  Olaf Dietsche.
Option 2:
Use gcc -S test.c to stop compiler after assembling to see the assembly code of your program. Understanding assembly code might be a little hard. More info here
Option 3:
Rewrite your program to something like
while(1)
{
    if(*d++ != *sc++)
    {
        break;
    }
}

So that you can put breakpoints and see the values changing.

A: An alternative, but identical way to write the code is:
*d = *sc;
while (*d > 0)
{
  d++;
  sc++;
  *d = *sc;
}


text:
Q: Property of strong deformation retract. Let $X$ be a topological space and let $X'\subseteq X$ be a subspace of $X$.
Let also $U$ be a path component $X$ such that.
I want to show that if $X'$ is a (strong) deformation retract of $X$ then $X'\cap U$ is a deformation retract of $U$.
My attempt is as follows:
Let
$$H:X\times[0,1]\to X$$
be the deformation retract of $X'$ in $X$, i.e.

*

*$\forall x\in X \ \ H(x,0)=x$,

*$\forall x\in X \ \ H(x,1)\in X'$, and

*$\forall x\in X'\forall t\in[0,1] \ \ H(x,t)=x$.

Now, I believe that since $U$ is a path-connected component of $X$, then if we restrict $H$ to $(X'\cap U)\times [0,1]$ we will take a deformation retract
from $X'\cap U$ to $U$. That is because for each $u\in U$ the map
$h_{u}:[0,1]\to X$ where $h_{u}(t)=H(u,t)$ is continuous and hence a path in $X$, which contains $h_{u}(0)=H(u,0)=u$. Therefore, since $U$ is a path-component of $X$, $h_{u}([0,1])\subseteq U$ and so $H(U\times[0,1])\subseteq U$.
I am not quite keen on with homotopy so I am not completely sure about all the implications of the above proof. Is there any flaw?


text:
Q: Is $\mathbb{Z}[\sqrt{2}]$ a lattice? Is $\mathbb{Z}[\sqrt{2}]=\{a+b\sqrt{2}\mid a,b\in\mathbb{Z}\}$ a discrete subgroup of $\mathbb{R}$?
How to prove that?

A: No. It fails to be discrete. In fact $\mathbb Z[\sqrt 2]$ is dense in $\mathbb R$.
It suffices to observe that the sequence $(\sqrt 2-1)^n\in \mathbb Z[\sqrt 2] $ converges to $0$.


text:
Q: Install application ubuntu14.04 lts I am a beginner , just want to ask why ubuntu doesn't create by default a run icon in my /usr/share/application.
i installed netbeans and a run icon was created in the application directory but when i installed xampp that doesn't work for displaying the run icon.
what i must do to create the default run icon without using a script for run .

A: Not everything is available in left vertical sidebar. You need to search for it and then pull it on the left vertical sidebar.
Then it will be available for some of them like Eclipse you can create it following this link


text:
Q: A limited composition of two unlimited functions on natural numbers? Can someone give an example of two functions $f,g:\Bbb N\to \Bbb N$ such that
$|\operatorname{Im}f|,|\operatorname{Im}\,g|\notin\Bbb N$, but such that
$|\operatorname{Im}\,g\circ f|\in\Bbb N$?

A: $$
f(n)=2n+1
$$
$$
g(n) = \begin{cases}
1 \quad \mbox{if $n$ is odd}; \\
n \quad \mbox{if $n$ is even}.
\end{cases}
$$


text:
Q: Switch to next video from Youtube API (React) I am attempting to have the next video in a channel play right after the other. Currently, the website has the videos showing one after the other, but my goal is to show one video and the second one plays right after the other is done. I have the function set up for the video ending, but right now it just causes an alert. I am using the Youtube Data API to pull in the videos and their information.

Here is a snippet of the code I am using:
constructor() {
super();
this.state = {
  videos: [],
};

}

  componentDidMount() {
fetch('https://www.googleapis.com/youtube/v3/search?key='APIKey'&channelId=UCXIJgqnII2ZOINSWNOGFThA&part=snippet,id&order=date&maxResults=2')
.then(results => {
  return results.json();
}).then(data => {
  let videos = data.items.map((videos) => {
    return(

      <YouTube
              className="player"
              id="video"
              videoId={videos.id.videoId}
              opts={VIDEO_OPTS}
              onEnd={this.playNextVideo}
            />

{videos.snippet.title}

Video by: {videos.snippet.channelTitle}

    );
  });
  this.setState({videos: videos});
  console.log("state", this.state.videos);
})

  }

  playNextVideo = () => {
    alert('The video is done!');
  }

A: I suggest you to do few things a little bit different.
First save the results.json(); to your videos variable in the state and not the whole youtube component, that's bad practice.
Second save another variable in your state that indicates the current playing video id (playingVideoId). Initialize it in the componentDidMount and change it in your playNextVideo function like this:
constructor() {
    super();
    this.index=0;
}

componentDidMount() {
        fetch('https://www.googleapis.com/youtube/v3/search?key='APIKey'&channelId=UCXIJgqnII2ZOINSWNOGFThA&part=snippet,id&order=date&maxResults=2').then(results => {
          this.setState({videos: results.json()});
          this.setState({playingVideoId: this.state.videos[this.index]});
        })}

playNextVideo = () => {
              this.setState({playingVideoId: this.state.videos[++this.index]});
          }

Now use the render function to render the component
render() {
    return(
          <YouTube
                  className="player"
                  id="video"
                  videoId={this.state.playingVideoId}
                  opts={VIDEO_OPTS}
                  onEnd={this.playNextVideo}
            />
        );
}


text:
Q: Why can I not boot off non-Windows CD or DVD with Windows 7 installed? I've looked at:
http://www.superuser.com/questions/22952/installing-windows-7-on-a-dual-boot-machine
and
http://www.superuser.com/questions/16098/how-can-i-get-my-ubuntu-boot-manager-back-after-windows-7-install
The bottom line is, after a Windows 7 install, the only way I could get the Ubuntu LiveCD (or FreeBSD, or Debian, or Ultimate Boot CD) to boot, was to unplug the SATA cable on the Windows partition (I was lucky to have more than one HDD).
Why?
--
EDIT (2009-10-20):
The issue is purely academic now, since I used my "unplug drive" workaround last month. I've put a bounty on this because I want to know for my own benefit, and unplugging a drive is not a feasible solution. Thank you to everyone who has contributed to this question. I value your input.

A: When you have more then one hard drive, cdrom, etc you only get so many choices to boot from even if you select them properly in the linked image.  Make sure the drive you want to boot from is on the top when in the cdrom/hard drive menu.
You can have the First Boot Device CDROM but then have two CDROMs under the boot menu and it's choosing your bluray instead of your DVDRW or however you may have it set up.  Unplugging it was probably what brought the correct one to the top.

A: Erm... feel a little bit silly to ask this question, but have you set your optical drive (DVD drive) to be the first device in your PC's boot priority? In short, have you set or selected your optical drive with the Ubuntu CD to be the first to boot?
Find the boot priority settings in your BIOS.

A: Have you tried booting using a USB-based storage device ? You can take almost any .ISO file and set it to make a USB device bootable with it. UNETBOOTIN, which can run under both Windows and Linux can take a .ISO file of any Linux distribution and make your USB storage device bootable with this ISO file, just as if you were booting off a CDROM. If you cannot boot off a CDROM, this may be an alternative solution.
JF

A: This is very odd though as the BIOS settings override any OS settings. Windows 7 is not even loaded at the point where the BIOS selects from which medium to load the desired OS from.
I do understand that (all?) Windows versions have always destroyed any bootloader e.g. LILO or GRUB and replaced it with its own. In this case I always installed first Windows and then another OS if needed.
In your case though, you are trying to boot from a CD or DVD which really should be invoked prior to Windows 7 having anything to say.
I suggest you edit the BIOS setting and simply set CD/DVD as the first and only boot option. Then disable the rest (2nd,3rd,4th, etc) boot options. That setting will work fine as a HD is really not required for the system to boot (from a CD/DVD).
If anything else fails, are you sure the media is not corrupted?

*

*Try to download another distribution to see if that also fails.

*Try to use a different writer.


text:
Q: What's the role of Change-Id in commit message Why Change-Id is important for gerrit ? What kind of problems it may have without Change-Id in the commit message ? We are using Change-Id in our commit message, but without knowing the exact reason. Our client wants to remove the Change-Id from commit message, they feel it doesn't contain any valuable information for the commit itself. So now I need to convince them the necessity of it. Could you please help ?

A: It is neccessary to group the different patch sets (versions) of a change together. Otherwise there is no reason between the first commit and its overworked versions. So although there's an option "Require Change-Id", which can be deactivated, it is strongly adviced to not do so. See also in the Gerrit Docs.


text:
Q: Applescript or automator to print only 3 first pages of a pdf I'd like to automate printing the first 3 pages of a PDF. It's fine if the document has to be split.
I have Adobe Acrobat Pro installed as well.

A: This will prompt you to select the PDF file, then print the first 3 pages of it(change the sourceFile variable if you want to choose the PDF in another way):
set sourceFile to (choose file with prompt "Choose a PDF file:" of type {"PDF"})
do shell script "lpr " & quoted form of POSIX path of sourceFile & " -o page-ranges=1-3"

If you want to have a drag-and-drop application:
on open droppedItem set sourceFile to POSIX path of droppedItem
do shell script "lpr " & quoted form of POSIX path of sourceFile & " -o page-ranges=1-3" end open


text:
Q: jquery / ajax / expression engine - set a custom member field within a safecracker form I'm using jquery with expression engine to submit an ajax form, utilizing the safe cracker module, documented here:
http://expressionengine.com/user_guide/modules/safecracker/examples.html
Basically, my form allows logged in members to vote. I want them to be able to vote only once though, so I set up a custom profile data field called "voted" which I want to set to "true" once they submit the form. Is this possible? If so, how?

A: SafeCracker has an extension hook called safecracker_submit_entry_end (documentation), so you can build an extension which uses that hook, then in that hook's method do what you need to do.
Hint: that extension hook gets passed a reference to the SafeCracker object, which is not documented ... so when you first test out the extension, simply print the object so you can see what it contains:
function safecracker_submit_entry_end($safecracker)
{
    print_r($safecracker); exit();
}

If you're unfamiliar with developing extensions and for ExpressionEngine, using the database class, etc, that's a whole other thing. I can post some links to get you started if that's the case.


text:
Q: How to run java code through eclipse console? I have virtually no java/eclipse experience, so bear with me.  I have written a code to use the Euclidean algorithm to compute a greatest common divisor.
public class Euclid {
    public static int gcd(int a, int b){
        while (b!= 0){
            if (a > b){
                a -= b;
            }
            else {
                b -= a;
            }
        }
        return a;
    }

}

How would I go about testing this in the eclipse console to ensure that it runs properly?  E.g were I using python, which I have some experience with, I'd think to simply type gcd(32, 24) into IDLE and hit enter.

A: Java is a compiled language, not a scripting language. There is no console with read-eval-print loop. You can add a main function in the class:
public static void main (String [] args){ System.out.println(gcd(32,24)); }

And then you can right click and run

A: You can use System.in so you can type something into the console and press enter. After you've done that, you can work with the input as shown in the following example:
public static void main(String[] args) {

    System.out.println("Enter something here : ");

    try{
        BufferedReader bufferRead = new BufferedReader(new InputStreamReader(System.in));
        String s = bufferRead.readLine();

        System.out.println(s);
    }
    catch(IOException e)
    {
        e.printStackTrace();
    }

  }

Another option is simply using the main method. You start a java application from within a main method. So for example in Eclipse you can just right-click the file with the main method in it and choose Run as -> Java Application and it will run your code from your main method:
public static void main(String[] args) {

        Euclid euclid = new Euclid();
        int value = euclid.gcd(32, 24);

}


text:
Q: What algorithm can I implement to speed up some Cellular Automata simulations? I am writing a ncurses based C.A. simulator for (nearly) any kind of C.A. which uses the Moore or Neumann neighborhoods.
With the current (hardcoded and most obvious [running state funcs]) the simulation runs pretty well; until the screen is filled with 'on' (or whatever active) cells.
So my question is:
Are there any efficient algorithms for handling at least life-like rules?
or Generations, Weighted life/generations...
Thanks.

A: it's generally nice to only run update passes in areas of the grid that had activity in the previous time step.  if you keep a boolean lattice of "did i change this time?" for each pass, you only need to update cells within one radius of those with an "on" in the change lattice.

A: I think writing state machines is not as much algorhitms designing problem as is just problem how to write clean and "bug free" code. What are you probably looking for is implementation of cellular automata / state chart.
http://www.state-machine.com/ //<- no this is not coincidence
http://www.boost.org/doc/libs/1_40_0/libs/statechart/doc/index.html
You might also try whit stackless python http://stackless.com/. It can be used for state machines or CA.  Here http://members.verizon.net/olsongt/stackless/why_stackless.html#the-factory it is tutorial for stackless implementing factory process simulation

A: You could look into the HashLife algorithm and try to adapt its concept to whatever automata you are working on.