text:
Q: What is Mage::getModel('core/resource_transaction') and when to use this model in Magento? In Magento's core code, Mage::getModel('core/resource_transaction') , what does this model do and in what situation do we want to initiate and use this core model class? Does this model has a corresponding table in the Magento database?

A: No, this model does not use any tables. It is needed to make MySQL transactions functionality. For example, you want to save invoice, shipment and order, but if something goes wrong, to rollback all previously saved data. You can do so:
$transactionSave = Mage::getModel('core/resource_transaction')
    ->addObject($invoice)
    ->addObject($order)
    ->addObject($shipment);
$transactionSave->save();

Transaction save method will go through all objects and call save method in them. If something will go wrong during shipment save, for example, Magento will call $this->_rollbackTransaction(); method (class Mage_Core_Model_Resource_Transaction, line 166) and will rollback all previously saved data using MySQL functionality.
If you want to call another then save method for your object, you may use addCommitCallback method
$transaction->addCommitCallback(array($order, 'place'));

Then after calling $transactionSave->save(); it will call $order->place() method.
For more examples go to class Mage_Sales_Model_Service_Quote class - it uses transactional save in lots of places.

A: This is a resource Model class (Mage_Core_Model_Resource_Transaction).
In example:
When you want to change something in a product and the same time you want to change something in a category you are going to instantiate catalog/category and catalog/product. And make your changes like this:
$prod_id = 554;
$cat_id = 323;

$product_object = Mage::getModel('catalog/product')->load($prod_id);
$product_object->setName('NewProductName');

try{
    $product_object->save();
    echo "Transaction for PRODUCT completed successfully";
} catch(EXCEPTION $e) {
    echo $e->getMessage();
}

$category_object = Mage::getModel('catalog/category')->load($cat_id);
$category_object->setName('NewCatName');

try{
    $category_object->save();
    echo "Transaction for Category completed successfully";
} catch(EXCEPTION $e) {
    echo $e->getMessage();
}

As you can see in the code above we save() 2 times. One for product and one for category. Catching 2 different exceptions, and 2 different transactions to the database.
In some (rare i think) cases is required to make changes using 2 or more objects and save to the database all in a Single Transaction.
So in our case we add the $product_object and $category_object to a Mage::getModel('core/resource_transaction') instance:
$one_transaction = Mage::getModel('core/resource_transaction');
$one_transaction->addObject($product_object);
$one_transaction->addObject($category_object);
try{
    $one_transaction->save();
} catch(EXCEPTION $e) {
    echo $e->getMessage();
}

The profit in this case is that if something goes wrong with one or more objects we added, no changes are posted to the database.


text:
Q: MongoDB C# Driver and server generated ObjectIds Is there a way get server generated ObjectIds instead of C# Driver generated ObjectIds? Using MongoCollectionSettings.AssignIdOnInsert = false only gets you zeroed out ObjectIds. I'm doing multi-threaded inserts on a capped collection, and I'm seeing threads switch between the ObjectId generation and the insert. This causes out of order ObjectIds in a collection that's supposed to be ordered for tailed cursors sorting on natural order. Right now I'm using a static lock object for the inserts, but that won't help with different executables/servers.
It appears this is possible with the pymongo driver: ObjectID generated by server on pymongo

A: Getting documents in insertion order from a capped collection
Capped collections maintain documents in insertion order, so you should ideally use natural order rather than relying on the timestamp in the generated _id. Your tailable cursor will be reading documents in natural order, so should not make any assumptions based on the _id.
Generating server-side _id
To generate _id on the server side using the C# driver you need to:

*

*set the class attribute [BsonIgnoreIfDefault]

*set the collection attribute AssignIdOnInsert = false

*insert a document without an _id
Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using MongoDB.Bson;
using MongoDB.Driver;
using MongoDB.Bson.Serialization.Attributes;

public class MyDoc {
    [BsonIgnoreIfDefault]
    public ObjectId? Id;
    public int X;
}

public static class Program {
    public static void Main(string[] args) {
        MongoClient client = new MongoClient(); // connect to localhost
        var server = client.GetServer ();
        var database = server.GetDatabase("test");
        var collectionSettings = new MongoCollectionSettings { AssignIdOnInsert = false };
        var collection = database.GetCollection<MyDoc>("nullid", collectionSettings);

        // Insert document without _id
        collection.Insert(new MyDoc { X = 1});
    }
}

redpajama_set_name: RedPajamaStackExchange


text:
Q: Exception in iReport 5.6.0 not working im installed ireport 5.6.0 and netbeans 8.0.2, then i opened and launch an exception below the log

-------------------------------------------------------------------------------
>Log Session: Thursday, July 2, 2015 12:17:51 AM CEST
>System Info:
  Product Version         = Jaspersoft iReport Designer 5.6.0
  Operating System        = Windows 7 version 6.1 running on x86
  Java; VM; Vendor        = 1.7.0_75; Java HotSpot(TM) Client VM 24.75-b04; Oracle Corporation
  Runtime                 = Java(TM) SE Runtime Environment 1.7.0_75-b13
  Java Home               = C:\Program Files\Java\jdk1.7.0_75\jre
  System Locale; Encoding = es_ES (ireport); Cp1252
  Home Directory          = C:\Users\XD
  Current Directory       = C:\Program Files\JasperSoft\iReport-5.6.0
  User Directory          = C:\Users\XD\.ireport\5.6.0
  Installation            = C:\Program Files\JasperSoft\iReport-5.6.0\ireport
                            C:\Program Files\JasperSoft\iReport-5.6.0\ide10
                            C:\Program Files\JasperSoft\iReport-5.6.0\nb6.5
                            C:\Program Files\JasperSoft\iReport-5.6.0\platform9
  Boot & Ext. Classpath   = C:\Program Files\Java\jdk1.7.0_75\jre\lib\resources.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\rt.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\jce.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.7.0_75\jre\classes;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\access-bridge.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\antlr-2.7.5.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\asm-attrs.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\asm.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\barbecue-1.1.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\bsh-1.3.0.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\cglib-2.1.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\cincom-jr-xmla.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\commons-beanutils-1.7.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\commons-collections-2.1.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\commons-dbcp-1.2.1.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\commons-digester-1.7.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\commons-javaflow-20060411.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\commons-logging-1.0.2.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\commons-logging-api-1.0.2.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\commons-pool-1.3.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\dom4j-1.6.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\ehcache-1.1.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\eigenbase-properties.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\eigenbase-resgen.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\eigenbase-xom.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\flexdock-0.4.1.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\groovy-all-1.0-beta-10.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\hibernate3.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\hsqldb-1.7.1.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\ireport.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\itext-1.3.1.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\jakarta-bcel-20050813.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\JasperBabylon-1.0.0.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\jasperreports-1.3.1.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\javacup.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\jcmdline-1.0.2.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\jcommon-1.0.0.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\jdt-compiler-3.1.1.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\jfreechart-1.0.0.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\jpa.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\jr-bsh-compiler.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\jsmoothgen-ant-0.9.7.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\jta.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\jxl-2.6.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\log4j-1.2.8.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\looks-2.0-rc.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\microba-0.4.1-bin.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\mondrian-2.0.1.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\mysql-connector-java-3.1.11-bin.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\nsisant-1.1.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\png-encoder-1.5.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\poi-2.0-final-20040126.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\rex-20070125.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\saaj-api-1.3.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\servlet.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\spring-2.0-m2.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\spring-context-2.0-m2.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\spring-hibernate3-2.0-m2.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\sqleonardo-2007.03.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\tinylaf.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\toniclf.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\xercesImpl.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\xml-apis.jar;C:\Program Files\Java\jdk1.7.0_75\jre\lib\ext\zipfs.jar
  Application Classpath   = C:\Program Files\JasperSoft\iReport-5.6.0\platform9\lib\boot.jar;C:\Program Files\JasperSoft\iReport-5.6.0\platform9\lib\org-openide-modules.jar;C:\Program Files\JasperSoft\iReport-5.6.0\platform9\lib\org-openide-util.jar;C:\Program Files\Java\jdk1.7.0_75\lib\dt.jar;C:\Program Files\Java\jdk1.7.0_75\lib\tools.jar
  Startup Classpath       = C:\Program Files\JasperSoft\iReport-5.6.0\platform9\core\core.jar;C:\Program Files\JasperSoft\iReport-5.6.0\platform9\core\org-openide-filesystems.jar;C:\Program Files\JasperSoft\iReport-5.6.0\platform9\core\locale\core_de.jar;C:\Program Files\JasperSoft\iReport-5.6.0\platform9\core\locale\core_es.jar;C:\Program Files\JasperSoft\iReport-5.6.0\platform9\core\locale\core_fr.jar;C:\Program Files\JasperSoft\iReport-5.6.0\platform9\core\locale\core_it.jar;C:\Program Files\JasperSoft\iReport-5.6.0\platform9\core\locale\core_ja.jar;C:\Program Files\JasperSoft\iReport-5.6.0\platform9\core\locale\core_pl.jar;C:\Program Files\JasperSoft\iReport-5.6.0\platform9\core\locale\core_pt_BR.jar;C:\Program Files\JasperSoft\iReport-5.6.0\platform9\core\locale\core_sq.jar;C:\Program Files\JasperSoft\iReport-5.6.0\platform9\core\locale\core_zh_CN.jar;C:\Program Files\JasperSoft\iReport-5.6.0\platform9\core\locale\core_zh_TW.jar;C:\Program Files\JasperSoft\iReport-5.6.0\platform9\core\locale\org-openide-filesystems_de.jar;C:\Program Files\JasperSoft\iReport-5.6.0\platform9\core\locale\org-openide-filesystems_es.jar;C:\Program Files\JasperSoft\iReport-5.6.0\platform9\core\locale\org-openide-filesystems_fr.jar;C:\Program Files\JasperSoft\iReport-5.6.0\platform9\core\locale\org-openide-filesystems_it.jar;C:\Program Files\JasperSoft\iReport-5.6.0\platform9\core\locale\org-openide-filesystems_ja.jar;C:\Program Files\JasperSoft\iReport-5.6.0\platform9\core\locale\org-openide-filesystems_pl.jar;C:\Program Files\JasperSoft\iReport-5.6.0\platform9\core\locale\org-openide-filesystems_pt_BR.jar;C:\Program Files\JasperSoft\iReport-5.6.0\platform9\core\locale\org-openide-filesystems_sq.jar;C:\Program Files\JasperSoft\iReport-5.6.0\platform9\core\locale\org-openide-filesystems_zh_CN.jar;C:\Program Files\JasperSoft\iReport-5.6.0\platform9\core\locale\org-openide-filesystems_zh_TW.jar;C:\Program Files\JasperSoft\iReport-5.6.0\ireport\core\locale\core_ireport.jar;C:\Program Files\JasperSoft\iReport-5.6.0\nb6.5\core\locale\core_nb_de.jar;C:\Program Files\JasperSoft\iReport-5.6.0\nb6.5\core\locale\core_nb_es.jar;C:\Program Files\JasperSoft\iReport-5.6.0\nb6.5\core\locale\core_nb_it.jar;C:\Program Files\JasperSoft\iReport-5.6.0\nb6.5\core\locale\core_nb_ja.jar;C:\Program Files\JasperSoft\iReport-5.6.0\nb6.5\core\locale\core_nb_pt_BR.jar;C:\Program Files\JasperSoft\iReport-5.6.0\nb6.5\core\locale\core_nb_zh_CN.jar;C:\Program Files\JasperSoft\iReport-5.6.0\nb6.5\core\locale\core_nb_zh_TW.jar;C:\Program Files\JasperSoft\iReport-5.6.0\nb6.5\core\locale\org-netbeans-upgrader_de.jar;C:\Program Files\JasperSoft\iReport-5.6.0\nb6.5\core\locale\org-netbeans-upgrader_es.jar;C:\Program Files\JasperSoft\iReport-5.6.0\nb6.5\core\locale\org-netbeans-upgrader_it.jar;C:\Program Files\JasperSoft\iReport-5.6.0\nb6.5\core\locale\org-netbeans-upgrader_ja.jar;C:\Program Files\JasperSoft\iReport-5.6.0\nb6.5\core\locale\org-netbeans-upgrader_pt_BR.jar;C:\Program Files\JasperSoft\iReport-5.6.0\nb6.5\core\locale\org-netbeans-upgrader_zh_CN.jar;C:\Program Files\JasperSoft\iReport-5.6.0\nb6.5\core\locale\org-netbeans-upgrader_zh_TW.jar
-------------------------------------------------------------------------------
ADVERTENCIA [org.netbeans.core.modules]: had to upgrade dependencies for module com.jaspersoft.ireport: added = [module org.netbeans.modules.options.api/1 > 1.4, module org.netbeans.modules.db/1 > 1.24] removed = [module org.netbeans.modules.db/0-1 > 1.21.0.5, module org.netbeans.modules.options.api/0-1 > 1.5.1]; details: [Major release version of module changed from 0 to 1 to signal stability; update your dependencies]
ADVERTENCIA [org.netbeans.core.startup.NbEvents]: The extension C:\Program Files\JasperSoft\iReport-5.6.0\ireport\modules\ext\slf4j-api-1.5.8.jar may be multiply loaded by modules: [C:\Program Files\JasperSoft\iReport-5.6.0\ireport\modules\com-jaspersoft-ireport-hadoop-hive.jar, C:\Program Files\JasperSoft\iReport-5.6.0\ireport\modules\com-jaspersoft-ireport.jar]; see: http://www.netbeans.org/download/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/classpath.html#class-path
ADVERTENCIA [org.netbeans.core.startup.NbEvents]: The extension C:\Program Files\JasperSoft\iReport-5.6.0\ireport\modules\ext\slf4j-log4j12-1.5.8.jar may be multiply loaded by modules: [C:\Program Files\JasperSoft\iReport-5.6.0\ireport\modules\com-jaspersoft-ireport-hadoop-hive.jar, C:\Program Files\JasperSoft\iReport-5.6.0\ireport\modules\com-jaspersoft-ireport.jar]; see: http://www.netbeans.org/download/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/classpath.html#class-path
ADVERTENCIA [org.netbeans.core.modules]: the module org.netbeans.modules.db uses org.openide.options which is deprecated: Usar preferentemente org.openide.util.NbPreferences.
ADVERTENCIA [o
    org.netbeans.modules.print [6.5.1 200903060201]
    com.jaspersoft.ireport.jasperserver [1.0 140528]
    org.netbeans.modules.dbapi [1.7.1.30 200903060201]
    org.netbeans.modules.db.metadata.model/0 [0.1.1 200903060201]
    org.openide.execution [1.12.1 200903060201]
    org.netbeans.modules.utilities/1 [1.29.1 200903060201]
    com.jaspersoft.ireport.designer.standalone [1.0 140528]
    org.netbeans.libs.jna/1 [1.1.2 200903060201]
    org.netbeans.modules.settings/1 [1.15.1 200903060201]
    org.netbeans.core.windows/2 [2.12.3.1 200903060201]
    org.netbeans.core.nativeaccess/1 [1.1.2 200903060201]
    org.netbeans.modules.progress.ui [1.2.1 200903060201]
    org.netbeans.modules.editor.plain.lib/1 [1.6.1 200903060201]
    org.netbeans.modules.properties.syntax/1 [1.20.1 200903060201]
    org.netbeans.modules.web.flyingsaucer/1 [1.2.1 1 200903060201]
    org.netbeans.core.execution/1 [1.12.1.1 200903060201]
    org.netbeans.core.output2/1 [1.10.1.1 1 200903060201]
    com.jaspersoft.ireport.components [1.0 140528]
    org.netbeans.modules.defaults/1 [1.5.1 200903060201]
    org.netbeans.modules.db.dataview [1.0.3 200903060201]
    org.netbeans.modules.db.core [1.7.3 200903060201]
    org.netbeans.modules.db.sql.editor [1.7.1.30 200903060201]
    org.netbeans.modules.editor.plain/2 [1.7.1 200903060201]
    org.netbeans.core.ide/1 [1.12.1 200903060201]
    com.jaspersoft.ireport.mongodb [0.9.3 140528]
    org.netbeans.modules.extbrowser/1 [1.13.1 200903060201]
    com.jaspersoft.jrx [1.0 140528]
    org.netbeans.modules.projectui [1.15.3.1.6 1 200903060201]
    org.netbeans.modules.refactoring.api [1.4.1 200903060201]
    com.jaspersoft.ireport.samples [1.0 140528]
    org.netbeans.modules.db.mysql [0.1.3 2 200903060201]
    org.netbeans.modules.db.drivers [1.2.1 200903060201]
    org.netbeans.modules.languages.refactoring/0 [1.0.1.1 1 200903060201]
    org.netbeans.modules.core.kit [1.2.4 200903060201]
    com.jaspersoft.ireport.addons [1.0 140528]
java.net.UnknownHostException: ireport.sf.net
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:579)
    at java.net.Socket.connect(Socket.java:528)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:211)
    at sun.net.www.http.HttpClient.New(HttpClient.java:308)
    at sun.net.www.http.HttpClient.New(HttpClient.java:326)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:997)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:933)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:851)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1301)
    at com.jaspersoft.ireport.heartbeat.Installer.run(Installer.java:98)
    at java.lang.Thread.run(Thread.java:745)
INFORMACIÓN [org.netbeans.core.windows.persistence]: [PersistenceManager.getTopComponentForID] Problem when deserializing TopComponent for tcID:'WelcomeTopComponent'. Reason: Error reading MultiFileObject@ed38d[Windows2Local/Components/WelcomeTopComponent.settings]: java.lang.reflect.InvocationTargetException
Content:
<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE settings PUBLIC "-//NetBeans//DTD Session settings 1.0//EN" "http://www.netbeans.org/dtds/sessionsettings-1_0.dtd">
<settings version="1.0">
    <module name="com.jaspersoft.ireport" spec="1.0"/>
    <instanceof class="org.openide.windows.TopComponent"/>
    <instanceof class="com.jaspersoft.ireport.designer.welcome.WelcomeTopComponent"/>
    <instance class="com.jaspersoft.ireport.designer.welcome.WelcomeTopComponent" method="getDefault"/>
</settings>

Method: getDefault
Class: class com.jaspersoft.ireport.designer.welcome.WelcomeTopComponent
Content:
<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE settings PUBLIC "-//NetBeans//DTD Session settings 1.0//EN" "http://www.netbeans.org/dtds/sessionsettings-1_0.dtd">
<settings version="1.0">
    <module name="com.jaspersoft.ireport" spec="1.0"/>
    <instanceof class="org.openide.windows.TopComponent"/>
    <instanceof class="com.jaspersoft.ireport.designer.welcome.WelcomeTopComponent"/>
    <instance class="com.jaspersoft.ireport.designer.welcome.WelcomeTopComponent" method="getDefault"/>
</settings>

Method: getDefault
Class: class com.jaspersoft.ireport.designer.welcome.WelcomeTopComponent
Caused: java.lang.NullPointerException
    at javax.swing.ImageIcon.<init>(ImageIcon.java:205)
    at com.jaspersoft.ireport.designer.welcome.GraySeparator.<init>(GraySeparator.java:46)
    at com.jaspersoft.ireport.designer.welcome.WelcomeTopComponent.initComponents(WelcomeTopComponent.java:90)
    at com.jaspersoft.ireport.designer.welcome.WelcomeTopComponent.<init>(WelcomeTopComponent.java:49)
    at com.jaspersoft.ireport.designer.welcome.WelcomeTopComponent.getDefault(WelcomeTopComponent.java:341)
Caused: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.netbeans.modules.settings.convertors.XMLSettingsSupport$SettingsRecognizer.createFromMethod(XMLSettingsSupport.java:670)
Caused: java.io.IOException: Error reading MultiFileObject@ed38d[Windows2Local/Components/WelcomeTopComponent.settings]
    at org.netbeans.modules.settings.convertors.XMLSettingsSupport$SettingsRecognizer.createFromMethod(XMLSettingsSupport.java:678)
    at org.netbeans.modules.settings.convertors.XMLSettingsSupport$SettingsRecognizer.instanceCreate(XMLSettingsSupport.java:581)
    at org.netbeans.modules.settings.convertors.SerialDataConvertor$SettingsInstance.instanceCreate(SerialDataConvertor.java:420)
[catch] at org.netbeans.core.windows.persistence.PersistenceManager.getTopComponentPersistentForID(PersistenceManager.java:531)
    at org.netbeans.core.windows.persistence.PersistenceManager.getTopComponentForID(PersistenceManager.java:641)
    at org.netbeans.core.windows.PersistenceHandler.getTopComponentForID(PersistenceHandler.java:422)
    at org.netbeans.core.windows.PersistenceHandler.initModeFromConfig(PersistenceHandler.java:386)
    at org.netbeans.core.windows.PersistenceHandler.load(PersistenceHandler.java:205)
    at org.netbeans.core.windows.WindowSystemImpl.load(WindowSystemImpl.java:69)
    at org.netbeans.core.NonGui$2.run(NonGui.java:178)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:312)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:738)
    at java.awt.EventQueue.access$300(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:699)
    at java.awt.EventQueue$3.run(EventQueue.java:697)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:708)
    at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Content:
<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE settings PUBLIC "-//NetBeans//DTD Session settings 1.0//EN" "http://www.netbeans.org/dtds/sessionsettings-1_0.dtd">
<settings version="1.0">
    <module name="com.jaspersoft.ireport" spec="1.0"/>
    <instanceof class="org.openide.windows.TopComponent"/>
    <instanceof class="com.jaspersoft.ireport.designer.welcome.WelcomeTopComponent"/>
    <instance class="com.jaspersoft.ireport.designer.welcome.WelcomeTopComponent" method="getDefault"/>
</settings>
TODO [null]: Method: getDefault
TODO [null]: Class: class com.jaspersoft.ireport.designer.welcome.WelcomeTopComponent
Diagnostic information
Input arguments:
    -Xms256m
    -Xmx512m
    -Dorg.netbeans.ProxyClassLoader.level=1000
    -XX:MaxPermSize=512m
    -Dapple.laf.useScreenMenuBar=true
    -Dapple.awt.graphics.UseQuartz=true
    -Dnetbeans.exception.report.min.level=99999
    -Djdk.home=C:\Program Files\Java\jdk1.7.0_75
    -Dnetbeans.home=C:\Program Files\JasperSoft\iReport-5.6.0\platform9
    -Dnetbeans.dirs=C:\Program Files\JasperSoft\iReport-5.6.0\ireport;C:\Program Files\JasperSoft\iReport-5.6.0\ide10;C:\Program Files\JasperSoft\iReport-5.6.0\nb6.5
    -Dnetbeans.user=C:\Users\XD\.ireport\5.6.0
    -Dnetbeans.system_http_proxy=DIRECT
    -Dnetbeans.system_http_non_proxy_hosts=
    -Dsun.awt.keepWorkingSetOnMinimize=true
Compiler: HotSpot Client Compiler
Heap memory usage: initial 256,0MB maximum 494,9MB
Non heap memory usage: initial 12,2MB maximum 544,0MB
Garbage collector: Copy (Collections=2 Total time spent=0s)
Garbage collector: MarkSweepCompact (Collections=1 Total time spent=0s)
Classes: loaded=5125 total loaded=5125 unloaded 0
INFORMACIÓN [org.netbeans.core.ui.warmup.DiagnosticTask]: Total memory 2.147.483.647
INFORMACIÓN [null]: Memoría total física 2.147.483.647
ADVERTENCIA [org.openide.filesystems.Ordering]: Found same position 1000 for both Menu/Tools/com-jaspersoft-ireport-designer-standalone-actions-ImportSettingsAction.shadow and Menu/Tools/org-netbeans-modules-favorites-templates-TemplatesAction.instance
ADVERTENCIA [org.openide.filesystems.Ordering]: Not all children in Menu/Window/ marked with the position attribute: [LayersAction.shadow], but some are: [FormattingToolsAction.shadow, OutlineAction.shadow, ErrorHandlerAction.shadow, IRConsoleAction.shadow, GenericInspectorAction.shadow, RepositoryAction.shadow, JRViewerAction.shadow, ViewFavoritesTabAction.shadow, StylesLibraryAction.shadow, ViewRuntimeTabAction.shadow, ShowPaletteAction.shadow, org-netbeans-core-actions-GlobalPropertiesAction.shadow, WelcomeAction.shadow, Output, SwitchToRecentDocumentAction.shadow, ProgressListAction.shadow, Separator3.instance, CloseWindowAction.shadow, MaximizeWindowAction.shadow, org-netbeans-core-windows-actions-UndockAction.shadow, Separator4.instance, CloneDocumentAction.shadow, CloseAllDocumentsAction.shadow, CloseAllButThisAction.shadow, DocumentsAction.shadow, Separator5.instance, org-netbeans-core-windows-actions-ResetWindowsAction.shadow]
ADVERTENCIA [org.openide.loaders.InstanceDataObject]: instanceClass was a com.jaspersoft.ireport.samples.OpenSampleAction
ADVERTENCIA [org.openide.loaders.InstanceDataObject]: instanceClass was a com.jaspersoft.ireport.samples.OpenSampleAction
ADVERTENCIA [org.openide.loaders.InstanceDataObject]: instanceClass was a com.jaspersoft.ireport.samples.OpenSampleAction
ADVERTENCIA [org.openide.loaders.InstanceDataObject]: instanceClass was a com.jaspersoft.ireport.samples.OpenSampleAction
ADVERTENCIA [org.openide.loaders.InstanceDataObject]: instanceClass was a com.jaspersoft.ireport.samples.OpenSampleAction
ADVERTENCIA [org.openide.loaders.InstanceDataObject]: instanceClass was a com.jaspersoft.ireport.samples.OpenSampleAction
ADVERTENCIA [org.openide.loaders.InstanceDataObject]: instanceClass was a com.jaspersoft.ireport.samples.OpenSampleAction
Action Basic_report created!
Action Elements created!
Action Parameters_and_Variables created!
Action Groups created!
Action Fonts created!
Action Charts created!
Action Subreports created!
Action Crosstabs created!
INFORMACIÓN [org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogCache]: Processing URL: http://updates.netbeans.org/netbeans/updates/6.5.1/uc/final/beta/catalog.xml.gz?unique=099971725-1fa0-4a5d-a767-76a5147f8c69_bb9c14e4-9363-47a6-8411-02a1c2bfe69e
INFORMACIÓN [org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogCache]: Processing URL: http://updates.netbeans.org/netbeans/updates/6.5.1/uc/final/stable/catalog.xml.gz?unique=099971725-1fa0-4a5d-a767-76a5147f8c69_bb9c14e4-9363-47a6-8411-02a1c2bfe69e
INFORMACIÓN [org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogCache]: Processing URL: http://plugins.netbeans.org/nbpluginportal/updates/6.5/catalog.xml.gz
INFORMACIÓN [org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogCache]: Processing URL: http://updates.netbeans.org/netbeans/updates/6.5.1/uc/final/thirdparty/catalog.xml.gz?unique=099971725-1fa0-4a5d-a767-76a5147f8c69_bb9c14e4-9363-47a6-8411-02a1c2bfe69e
INFORMACIÓN [org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogCache]: Reading URL http://updates.netbeans.org/netbeans/updates/6.5.1/uc/final/beta/catalog.xml.gz?unique=099971725-1fa0-4a5d-a767-76a5147f8c69_bb9c14e4-9363-47a6-8411-02a1c2bfe69e failed (java.util.concurrent.ExecutionException: java.net.UnknownHostException: updates.netbeans.org)
INFORMACIÓN [org.netbeans.modules.autoupdate.ui.actions.AutoupdateCheckScheduler]: java.net.UnknownHostException: updates.netbeans.org
java.io.IOException: java.net.UnknownHostException: updates.netbeans.org
    at org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogCache.notifyException(AutoupdateCatalogCache.java:188)
    at org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogCache.copy(AutoupdateCatalogCache.java:183)
    at org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogCache.writeCatalogToCache(AutoupdateCatalogCache.java:104)
    at org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogProvider.refresh(AutoupdateCatalogProvider.java:117)
    at org.netbeans.modules.autoupdate.services.UpdateUnitProviderImpl.refresh(UpdateUnitProviderImpl.java:153)
    at org.netbeans.api.autoupdate.UpdateUnitProvider.refresh(UpdateUnitProvider.java:158)
[catch] at org.netbeans.modules.autoupdate.ui.actions.AutoupdateCheckScheduler$4.run(AutoupdateCheckScheduler.java:150)
    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
    at org.openide.util.RequestProcessor$Processor.doEvaluate(RequestProcessor.java:1042)
    at org.openide.util.RequestProcessor$Task.waitFinished(RequestProcessor.java:734)
    at org.netbeans.modules.autoupdate.ui.actions.AutoupdateCheckScheduler.refreshUpdateCenters(AutoupdateCheckScheduler.java:319)
    at org.netbeans.modules.autoupdate.ui.actions.AutoupdateCheckScheduler.scheduleRefreshProviders(AutoupdateCheckScheduler.java:130)
    at org.netbeans.modules.autoupdate.ui.actions.AutoupdateCheckScheduler.access$500(AutoupdateCheckScheduler.java:97)
    at org.netbeans.modules.autoupdate.ui.actions.AutoupdateCheckScheduler$6.run(AutoupdateCheckScheduler.java:408)
    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
    at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)
INFORMACIÓN [org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogCache]: Reading URL http://updates.netbeans.org/netbeans/updates/6.5.1/uc/final/stable/catalog.xml.gz?unique=099971725-1fa0-4a5d-a767-76a5147f8c69_bb9c14e4-9363-47a6-8411-02a1c2bfe69e failed (java.util.concurrent.ExecutionException: java.net.UnknownHostException: updates.netbeans.org)
INFORMACIÓN [org.netbeans.modules.autoupdate.ui.actions.AutoupdateCheckScheduler]: java.net.UnknownHostException: updates.netbeans.org
java.io.IOException: java.net.UnknownHostException: updates.netbeans.org
    at org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogCache.notifyException(AutoupdateCatalogCache.java:188)
    at org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogCache.copy(AutoupdateCatalogCache.java:183)

How can resolve this problem?
PD: iReport its open but, the iReport opens anyway but I'm afraid it does not work well, and also before opening always displays the message that there is an exception and so.
Thank all guys. . .


text:
Q: Aurelia Select Not Binding Properly I have the following component:
import {inject, customElement, bindable} from 'aurelia-framework';
import {I18N} from 'aurelia-i18n';
import {Router} from 'aurelia-router';
import {HubFactory} from 'service';
import {hub} from 'enums';

@customElement('language-switcher')
@inject(Element, I18N, Router, HubFactory)
export class LanguageSwitcher {
  languageMatcher = (a, b) => {console.log(a,b); a.id === b.id;}

  @bindable languages = [];
  @bindable selectedLanguage = {};

  constructor(element, i18n, router, hubFactory) {
    this.element = element;
    this.i18n = i18n;
    this.router = router;
    this.usmHub = hubFactory.getHub(hub.usersSessionManagementHub);
  }

  switchLanguage() {
    ...
  }
}

with the following template:
<template>
  <form role="language" class="navbar-form navbar-left m-t-1">
    <div class="input-group">
      <select value.bind="selectedLanguage" change.delegate="switchLanguage()" matcher.bind="languageMatcher" class="form-control">
        <option repeat.for="language of languages" model.bind="language">${language.shortName}</option>
      </select>
    </div>
  </form>
</template>

which is used like this in the parent view:
<language-switcher languages.bind="languages" selectedLanguage.bind="selectedLanguage"></language-switcher>

The problem I have is that the select doesn't use the selectedLanguage as the default selected option and in the matcher function logs the default empty object for b instead. The a object is logged properly.
In the parent VM both the languages and the selectedLanguage are computed as follows and both return a value when I inspect them:
get languages() {
    return this.session.getSupportedLanguages();
  }

  get selectedLanguage() {
    return this.session.getDefaultLanguage();
  }

The languages get populated properly, however the selected language does not. Both methods in the session object point to the same array. Please advise as to what I am doing wrong.
Each language has an id property.
Thank you in advance

A: *

*When binding to a mixed-case property (eg @bindable selectedLanguage), use kebab case (eg selected-language.bind="..."). This is required because the DOM automotically lower-cases everything.

*When declaring a bindable property that serves as a "value", set it's default binding-mode to "two way". This way you can use .bind in your templates and will not need to remember to explicitly two-way bind to the property using .two-way="...":
@bindable({ defaultBindingMode: bindingMode.twoWay }) defaultLanguage;

*Make sure your matcher function returns true/false. Your matcher is missing a return statement!
Here's a running example with all three issues fixed: https://gist.run/?id=9f96ac9d135fb39f4b7c172a23e6859c

A: Ok, I've just realized that I need to use kebab case for the selectLanguage bindable attribute.

A: I see two issues in your code:
1 - Binding HTML expressions should be converted to kebab case. So, instead of
selectedLanguage.bind="selectedLanguage"

you should use:
selected-language.bind="selectedLanguage"

2 - Any reasons for using getters? You could bind the property directly:
Running example https://gist.run/?id=bcd7841ed21616136d5b6ab259a9d9c2


text:
Q: How can i update one row usign two keys in laravel? I have a need to update a table like this :
UPDATE table SET column = value WHERE first_id = 1 AND second_id = 2
Is it possible to do this in Laravel using eloquent model? If it is how can i do this?
I was trying with :
$object = Model::where('first_id' , 1)->where('second_id' , 2)->get();

$object->column = $value

$object->save();

A: Yes you can do it. Here is how you can do it.
Model::where('first_id', 1)
      ->where('second_id', 2)
      ->update(['column' => 'yourValue']);

A: You are getting a collection. You can update the column of each of those collection. You can only get the first one collection using first.
foreach($object as $obj){
   $obj->column = $value;
   $obj->save();
}

Or
$object = Model::where('first_id' , 1)->where('second_id' , 2)->first();

$obect->column =$value;
$object->save();


text:
Q: Interchangeable GUI toolkit for textmode and graphical mode I am looking for a cross platform GUI toolkit (for C) that works equally well in the terminal as it does in the "graphical world".
What (I think) I want is something like ncurses but with the option to set the guimode before starting. So for example if my program is started from the commandline I can go textmode and if it is started from X or Windows or whatever I can instead start a graphical GUI using the same API. Something like this...
guimode=TEXTMODEGUI;
or
guimode=GRAPHICALGUI;
before doing something like this...
drawwindow("title","text");
I have not found any ncurses to gtk+/wx/qt/whatever wrappers so far. Does something like this exits?!

A: If you are willing to accept C++ for the GUI part, use libyui from the YaST project. It supports Qt, Gtk and ncurses. I answered a similar question to yours here.

A: The only project I've run into like this is Charva for Java.  I have not used it and there appears to be no development since 2006.


text:
Q: knit_hooks and knit_theme don't seem to play nicely with each other I'm trying to get knitr to wrap text AND have syntax highlighting.  I can get one or the other to work, but not both. How do I fix this?
Here is an example, The only difference between the two is that knit_hooks$set changes from:
knit_hooks$set(par=function(before, options, envir){if (before) par(mar=c(4,4,.1,.1),cex.lab=.95,cex.axis=.9,mgp=c(2,.7,0),tcl=-.3)})

to
knit_hooks$set(source=listing, output=listing)

UPDATE:  From what I can tell, it's because I'm using \begin{lstlisting} to process the code chunks, so any changes that I make to knit_theme aren't effective (they only change the background color, not the text itself), and I need to fiddle around with \lstdefinestyle instead and set colors manually, which isn't quite the solution I'm looking for.
Syntax Highlighting
\documentclass{article}
\title{Combining knittheme with knithooks}
\author{author}

\usepackage{listings}
\usepackage{inconsolata}

<<echo=FALSE>>=
    library(knitr)
    thm <- knit_theme$get("solarized-dark")
    options(width=60)
    listing <- function(x, options) {
        paste("\\begin{lstlisting}[basicstyle=\\ttfamily,breaklines=true]\n", x, "\\end{lstlisting}\n", sep = "")
    }

    #knit_hooks$set(source=listing, output=listing)
    knit_hooks$set(par=function(before, options, envir){if (before) par(mar=c(4,4,.1,.1),cex.lab=.95,cex.axis=.9,mgp=c(2,.7,0),tcl=-.3)})

    knit_theme$set(thm)
@

\begin{document}
\maketitle
<<Test>>=
    years    = 1996:2010 #Check Syntax highlighting
    years[1]+5 #Check that code wraps to fit in between the page margins and doesn't go on and on until you can't read it anymore.
@
\end{document}

Wrapping Text
\documentclass{article}
\title{Combining knittheme with knithooks}
\author{author}

\usepackage{listings}
\usepackage{inconsolata}

<<echo=FALSE>>=
    library(knitr)
    thm <- knit_theme$get("solarized-dark")
    options(width=60)
    listing <- function(x, options) {
        paste("\\begin{lstlisting}[basicstyle=\\ttfamily,breaklines=true]\n", x, "\\end{lstlisting}\n", sep = "")
    }

    knit_hooks$set(source=listing, output=listing)
    #knit_hooks$set(par=function(before, options, envir){if (before) par(mar=c(4,4,.1,.1),cex.lab=.95,cex.axis=.9,mgp=c(2,.7,0),tcl=-.3)})

    knit_theme$set(thm)
@

\begin{document}
\maketitle
<<Test>>=
    years    = 1996:2010 #Check Syntax highlighting
    years[1]+5 #Check that code wraps to fit in between the page margins and doesn't go on and on until you can't read it anymore.
@
\end{document}


text:
Q: Filter a RDD in java to split into 2 new RDD I'm trying to filter my RDD so I can create 2 new RDDs
My RDD contains numbers and 1 string. This String has 2 possible values - Yes and No, is how i want to filter my RDD.
I know in python I can do this:
rdd.filter(rdd.contains(_))

but I want to do this in Java, is this possible ?


text:
Q: How to open ASCII file in WEKA software I have converted the .tiff file into ascii format with the help of ArcGIS, now i want to open that same file in WEKA, and it is asking me to open file in .arff format which i am clueless on how to convert ascii file into that, as format for ascii file is  .TXT.

A: It's difficult to see the issue without some sample data or error message, but it appears that the file can't be read into Weka in its current state.
You could try formatting the dataset to comply with the Attribute-Relation File Format.
Failing this, you could also format the dataset into a Comma-Delimited File Format with header information on the first row, and data underneath.  CSV Files are accepted into Weka quite fine.
Hope this Helps!

A: Considering that you are working with satellite imagery and that you know R, you could try something like this:
library(raster)
library(foreign)
library(RWeka)

dir.satellite <- '../tiffs' # Folder with your satellite TIF files
# Read them from their full paths
bands <- list.files(file.path(dir.satellite), full.names = T,
                    pattern = '.TIF$')
stkTIF <- raster::stack(bands) # group them into a rasterStack object
# Write the WEKA arff file
write.arff(as.matrix(stkTIF),
           file = file.path(dir.satellite, 'your_file_name.arff'))


text:
Q: Сохранить несколько значений в одну переменную с типом number (Побитовые операторы) Мне нужно решить такую задачу, у меня есть несколько переменных:
const area = 547030;
const people = 63182000;
const worked = true; // или число 1
const retired = false; // или число 0

Мне нужно сохранить эту информации в одну переменную с названием допустим result (в виде целого числа с типом number).
Чтобы я потом мог из этого числа получить те значение, которые я туда сохранял, а именно:
area, // 547030
people, // 63182000
worked, // true или число 1
retired // false или число 0

Я так понял здесь нужно использовать Побитовые операторы и Формат 32-битного целого числа. Только мне не ясно, как мне сохранить в одну переменю столько информации, чтобы потом можно было ее прочитать и найти те значение, которые я туда сохранил.

A: Подумаешь прошло полгода и меня сегодня утром осенило, что тут и без побитовых операций можно обойтись, вообщем вот такой код получился:

function Binary() {
  this.encode = function(data) {
    let number = "";
    let map = {}
    for (var d in data) {
      number += data[d].toString(2)
      map[d] = data[d].toString(2).length;
    }

    return [parseInt(number,2),map];
  }

  this.decode_map = function(number,map,name) {
    let length;
    let start = 0;
    for(let key in map) {
      if(key === name) {
        length = map[key];
        break;
      }
      start += map[key]
    }
    return this.decode(number,start,start+length);
  }

  this.decode = function(number,start,end) {
    return parseInt((number.toString(2).slice(start,end)),2);
  }
}

const data = {
 area : 547030,
 people : 63182000,
 worked : 1,
 retired : 0,
}

const $b = new Binary()

let [num,map] = $b.encode(data);
console.log(num);
console.log(map);
console.log("area " + $b.decode_map(num,map,'area'));
console.log("people " + $b.decode_map(num,map,'people'));
console.log("worked " + $b.decode_map(num,map,'worked'));
console.log("retired " + $b.decode_map(num,map,'retired'));

encode - получает объект ключ: число и сливает все числа в одно, переводя в двоичный код, затем возвращая полученное число в 10-ом формате. Также эта функция возвращает карту, в которой указана длина каждого числа в двоичной системе и ее его ключ, это нужно для декодирования.
encode_map - передаем число, карту и ключ тех данных, что хотим получить.
encode - в довесок, если нужно вырезать из числа часть двоичного представления, без всяких карт


text:
Q: Is it possible to override a driver that has been compiled into the kernel? I have a USB device for which I have an API.  This API only works if the USB device doesn't use the ftdi_sio/usbserial drivers.
On my laptop, if I plug the USB device in, these drivers get loaded (as modules) and I have to unload them using modprobe -r after which code using the API can see the device.
I have another device which experiences the same issue although no modules are loaded so I'm guessing these drivers are compiled into the kernel.  My question is this - is there any way to stop this device from using these drivers or do I have to recompile the kernel, etc?
Thanks for any help!

A: You are essentially looking for a way to :

*

*unbind the default driver from your USB device
and

*bind a driver of your choice to it.

Take a quick look at this to get you started.
A slightly more detailed description of the same is available in this excellent LWN article of (un)binding device drivers.


text:
Q: r1soft agent is failing with the error: "write error while sending code: Broken pipe" I have an Ubuntu 10.04.4 LTS server with r1soft agent installed in it. Recently, the backups are failing with the following error.
--------
write error while sending code: Broken pipe
--------

I have reinstalled the buagent but to no avail. On checking the server logs, I could see the following errors listed in it:
--------
# tail -f /var/log/messages |grep -i buagent
Nov 17 03:35:06 microscope buagent: Need to back up 126 sectors
Nov 17 03:35:06 microscope buagent: (Righteous Backup Linux Agent) 1.79.0 build 12433
Nov 17 03:35:06 microscope buagent: allowing control from backup server (10.128.136.195) with valid RSA key
Nov 17 03:35:06 microscope buagent: allowing control from backup server (10.128.136.201) with valid RSA key
Nov 17 03:35:06 microscope buagent: sending auth challenge for allowed host at (10.128.136.201) port (47890)
Nov 17 03:35:06 microscope buagent: host (10.128.136.201) port (47890) authentication successful
Nov 17 03:35:06 microscope buagent: Backup request accepted.  Starting backup.
Nov 17 03:35:06 microscope buagent: Snapshot completed in 0.010 seconds.
Nov 17 03:45:03 microscope buagent: Error reading blocks from snapshot.
Nov 17 03:45:03 microscope buagent: Reading blocks failed
Nov 17 03:45:03 microscope buagent: error backup aborted
Nov 17 03:45:03 microscope buagent: backup failed on agent closing connection
Nov 17 03:45:03 microscope buagent: Backup failed.
Nov 17 03:45:03 microscope buagent: write error while sending code: Broken pipe (32)
Nov 17 03:45:03 microscope buagent: tell child write failed
--------

I tried changing the 'Timeout' and 'DiskAsPartition' value in '/etc/buagent/agent_config' file but no luck. Also, verified that proper route is added to the backup server. The agent is also running fine.
Am I missing anything? Any help would be much appreciated.
Note: CDP 2.0 is installed in the backup server.


text:
Q: Вывод в Toast контента из 2х удалённых файлов Всем привет, есть код вывода содержания файла в интернете. Мне нужно, чтобы в тоаст выводилось содержание из 2х файлов. вот полный код активити
package com.example.byfile;

import android.os.Bundle;
import com.example.byfile.R;
import android.app.Activity;

import android.os.Bundle;

import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import java.net.*;
import java.io.*;
import java.nio.charset.Charset;

public class MainActivity extends Activity {

     Button btnSend;

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

            final Button btnSend = (Button)this.findViewById(R.id.btnSend);
            btnSend.setOnClickListener(new View.OnClickListener()
            {
                public void onClick(final View v)
                {
                    new Thread(new Runnable()
                    {
                        @Override
                        public void run()
                        {
                            try
                            {
                                 final URL myURL = new URL("http://мой-сайт/1.txt");
                                    final URLConnection connection = myURL.openConnection();
                                    connection.setDoInput(true);
                                    final Reader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), Charset.forName("UTF-8")));

                                    final URL myURL2 = new URL("http://мой-сайт/2.txt");
                                    final URLConnection connection2 = myURL2.openConnection();
                                    connection2.setDoInput(true);
                                    final Reader reader2 = new BufferedReader(new InputStreamReader(connection2.getInputStream(), Charset.forName("UTF-8")));
                                try
                                {
                                    //буфер 1
                                    final char [] buffer1 = new char[1024];
                                    final StringBuilder message = new StringBuilder();

                                    int readCount;
                                    do
                                    {
                                        readCount = reader.read(buffer1);
                                        message.append(buffer1);
                                    }
                                    while (readCount >= buffer1.length);

                                    //буфер 2
                                    final char [] buffer2 = new char[1024];
                                    final StringBuilder message2 = new StringBuilder();

                                    int readCount2;
                                    do
                                    {
                                        readCount2 = reader2.read(buffer2);
                                        message2.append(buffer2);
                                    }
                                    while (readCount2 >= buffer2.length);

                                    MainActivity.this.runOnUiThread(new Runnable()
                                    {
                                        @Override
                                        public void run()
                                        {

                                            Toast.makeText(MainActivity.this.getApplicationContext(), message + message2.toString(), Toast.LENGTH_LONG).show();
                                        }
                                    });

                                }
                                catch (final IOException ex)
                                {
                                    Log.d("IOException", ex.getMessage());
                                }
                                finally
                                {
                                    reader.close();
                                }
                            }
                            catch (final Exception ex)
                            {
                                Log.d("Some exception", ex.getMessage());
                            }
                        }
                    }).start();

                }
            });

}}

A: Может вообще дело в этом:
Toast.makeText(MainActivity.this.getApplicationContext(), message + message2.toString(), Toast.LENGTH_LONG).show();

И надо заменить на:
Toast.makeText(MainActivity.this.getApplicationContext(), message.toString() + message2.toString(), Toast.LENGTH_LONG).show();


text:
Q: Creating a javascript Object and calling it's method I have the following code, in one file, but it doesnt seem to work.
I'm basically trying to create an object and try to simply call the object's function and display it, it doesn't do that and I dont know why.
var mice = new Mice(10, 10);
function Mice(posX, posY)
{
    this.x = posX;
    this.y = posY;
    this.moveLeft = function ()
    {
        this.x = x - 1;
    }

    this.moveRight = function ()
    {
        this.x = x + 1;
    }

    this.getXPos = function ()
    {
        return this.x;
    }
}

document.onkeydown = function(e)
{
    //document.getElementById("mainBody").innerHTML = e.keyCode;

    switch(e.keyCode)
    {
    case 37:
        //document.getElementById("mainBody").innerHTML = "you have pressed left";
        mice.moveLeft();
        document.getElementById("mainBody").innerHTML = mice.getXPos();
        break;
        default:
    //do nothing
    break;
    }
}

any help on trying to get this working will be greatly appreciated.
Thanks

A: In your "move" functions, you have to consistently refer to this.x:
    this.x = this.x - 1;

Similarly, the "getXPos" function must also:
    return this.x;

A: return x;

You never made an x variable anywhere.
You mean return this.x;.

A: There is no x variable in the scope of your getXPos() method. I think you mean to return this.x


text:
Q: Android Support Toolbar shadow API > 19 Using android.support.v7.widget.Toolbar, I find that it displays a weird shadow in devices with API > 19.
How it looks in Android 4.4.2 API 19:

How it looks in anything with API >19:

I'd need it to look like it does with API 19, where it does not have any shadows and rather "integrates" with the background.

Since I'm using this Activity with a DrawerLayout, I have 2 layouts.
activity_main_tabbed.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_tabbed_drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:openDrawer="right">

    <include
        layout="@layout/activity_main_tabbed_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="right"
        android:fitsSystemWindows="true" />

</android.support.v4.widget.DrawerLayout>

activity_main_tabbed_content.xml
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:background="@drawable/activity_background_vertical"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:background="@android:color/transparent">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="@dimen/action_bar_height"
            android:elevation="0dp"
            android:background="@android:color/transparent"
            app:layout_scrollFlags="scroll|enterAlways">
            <ImageView
                android:layout_width="wrap_content"
                android:id="@+id/btn_toolbar_back"
                android:src="@drawable/left_white_arrow"
                android:visibility="gone"
                android:layout_height="match_parent"
                android:layout_marginRight="@dimen/btn_back_toolbar_margin_right"
                android:minHeight="@dimen/btn_back_toolbar_height"
                android:minWidth="@dimen/btn_back_toolbar_width"
                android:layout_gravity="left|center_vertical"/>
            <rokk3rlabs.dingding.utils.views.FontTextView
                android:layout_width="wrap_content"
                android:textSize="@dimen/toolbar_text_size"
                android:layout_height="wrap_content"
                android:textColor="@color/colorPrimary"
                android:text="@string/toolbar_title"
                android:layout_gravity="left"
                android:id="@+id/toolbar_title" />

        </android.support.v7.widget.Toolbar>

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="@dimen/action_bar_height"
            app:tabMode="fixed"
            android:elevation="0dp"
            app:tabGravity="fill"/>
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"  />
</android.support.design.widget.CoordinatorLayout>

styles.xml
<resources>

    <style name="AppTheme" parent="Theme.AppCompat">
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <!--   <item name="android:windowBackground">@drawable/activity_background</item>-->
        <item name="android:textColorPrimaryInverse">@color/colorPrimary</item>
        <item name="android:textColorSecondaryInverse">@color/colorPrimary</item>
        <item name="android:colorBackground">@color/colorPrimaryDark</item>
        <item name="android:colorForeground">@color/colorPrimary</item>
        <item name="android:textColorPrimary">@color/colorPrimary</item>
        <item name="android:textColorSecondary">@color/colorPrimary</item>
        <item name="android:windowBackground">@color/colorPrimary</item>
    </style>

styles.xml (v21)
<style name="AppTheme" parent="Theme.AppCompat">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:textColorPrimaryInverse">@color/colorPrimary</item>
    <item name="android:textColorSecondaryInverse">@color/colorPrimary</item>
    <item name="android:colorBackground">@color/colorPrimaryDark</item>
    <item name="android:colorForeground">@color/colorPrimary</item>
    <item name="android:textColorPrimary">@color/colorPrimary</item>
    <item name="android:textColorSecondary">@color/colorPrimary</item>
    <item name="android:navigationBarColor">@color/navigationBarColor</item>
    <item name="android:statusBarColor">@color/statusBarColor</item>
    <item name="android:windowBackground">@color/colorPrimary</item>
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
</style>

A: Either make the AppBarLayout have a solid background or set its app:elevation="0dp" (not android:elevation).
Note: Why do you set every color to colorPrimary is puzzling. Purple text over purple background is not going to work. It also makes it impossible to know where the appbar layout ends and the activity background begins in the screenshot.


text:
Q: Show {$f_{n}$} contains a uniformly convergent subsequence. Let {$f_{n}$} be a sequence of functions on [0, 1], such that all $f_{v}$ have continuous second derivatives. Assume that there exists $M$ such that $f_{n}(0) ≤ M, f'_{n}(0) ≤ M$ for all $n > 0$, and that for all $n > 0$ and all $x ∈ [0, 1)$,$|f''_{n}(x)| ≤\frac{1}{\sqrt{1-x}}$.
Prove that then {$f_{n}$} contains a uniformly convergent subsequence.
My thought is, show {$f_{n}$} is pointwise bounded and equicontinous. Since $f_{n}(0)$ is bounded, I only need to prove they're equicontinous. But I don't know how to use the second derivative premise.
In addition, it's not homework problem, I just saw it on exam last year and stucked here for some days. Thanks in advance for any help.

A: I am assuming that you have $\lvert f_n(0) \rvert \le M$ and $\lvert f'_n(0) \lvert \le M$. That is, you need these bounded from top and bottom; otherwise, I'm pretty sure the property isn't true. With this modification, the following reasoning works:
Note that for any $x \in [0,1]$, $$f_n'(x) = f'_n(0) + \int^{x}_0 f''(t) dt.$$ Thus $$\lvert f_n'(x) \rvert \le \lvert f'_n(0)\rvert + \left \lvert\int^x_0 f''_n(t) dt\right \rvert \le M + \int^x_0 \lvert f''_n(t)\rvert dt \le M + \int^1_0 \frac{1}{\sqrt{1-t}}dt = M+2.$$ This is a uniform (in both $x$ and $n$) bound on $f'_n(x)$. By the mean value theorem, we have for any $x,y \in [0,1]$ and any $n \in \mathbb N$, $$\lvert f_n(x) - f_n(y) \rvert = \lvert f'_n(c)\rvert \lvert x - y \rvert \le (M+2) \lvert x-y\rvert,$$ where $c$ is some value between $x$ and $y$ (and it depends on $n$, but that doesn't matter). This shows that all of $f_n$ are Lipschitz continuous with the same Lipschitz constant, and hence the family is equicontinuous.
Of course, you also need uniform boundedness. This follows since $$\lvert f_n(x) \rvert \le \lvert f_n(0) \rvert + \lvert f_n(x) - f_n(0) \rvert \le M + (M+2) \lvert x \rvert \le 2M+2.$$
EDIT: Indeed, you need $\lvert f_n(0) \rvert \le M$ and $\lvert f'_n(0) \lvert \le M$. If you only have the bound from above, then $f_n(x) = x-n$ gives a counterexample. In this case you can take $M =1$ and you have $f_n(0), f'_n(0) \le M$. You also have $\lvert f''_n(x) \rvert \le \frac{1}{\sqrt {1-x}}$. But there is no uniformly convergent subsequence.


text:
Q: SQL Query Hibernate with clause where how should be this query in hibernate
public Double getValuPrice(int param1, int param2){

        Query query = session.createQuery("FROM TableClass WHERE e.product= :param1 and e.type = :param2");
        query.setParameter("param1 ",param1);
        query.setParameter("param2",param2);

        result = query.uniqueResult();
        List lista = query.list();

        return lista;
}

and i want show the value returned in a Servlet
List list = classDao.getValuPrice(origem, destino);

out.println("<h1>" + list.eq(0) + "</h1>");

A: Seems like you are missing Select clause and table alias.
It should be like
Query query = session.createQuery("Select * FROM TableClass e WHERE e.product= :param1 and e.type = :param2");

A: In your query you are doing from TableClass and then WHERE e.product = :param1. I would have thought that would give you an error along the lines of Unable to resolve path [e.product], unexpected token [e]. Also you have a rogue space in one of your parameters, which will give you a could not locate named parameter [param1 ] error.
You don't, however, need the select * as suggested by Lenin's answer (see the Hibernate manual (v4.3 §11.4.1 "Executing Queries"))
So correcting these:

*

*remove the space in "param1 "

*specify a type for result (and do a cast) - unless result is a field you haven't shown in your sample code

*and, of course, remove e. before your properties in the query (or add e as an alias for TableClass)

*You are returning a List but the method specifies a Double - I'm not sure what you want to do here so you'll need to work that out yourself.

The code now looks like
public Double getValuPrice(int param1, int param2){
    Query query = session.createQuery("FROM TableClass WHERE product= :param1 and type = :param2");
    query.setParameter("param1",param1);
    query.setParameter("param2",param2);
    // assuming result is a field with type TableClass
    result = (TableClass)query.uniqueResult();
    List lista = query.list();

    return lista; // <-- fix the return statement
}

If you want to return a specific field on TableClass, which is a Double (e.g. double price;) then do:
Query q = session.createQuery("select price from TableClass WHERE product= :param1 and type = :param2"
...
Double result = ((Number) q.uniqueResult()).doubleValue();


text:
Q: "begins to drive" or "begins driving"?
*

*He starts the car and begins to drive around the warehouse.

*He starts the car and begins driving around the warehouse.
Does one of these sound better/more natural than the other to you native English speakers?


text:
Q: change the date format in a grid field ExtJS simple question but I can't figure out how to resolve it.
I'm receiving a date with hour from JSON with this format :
"date_deb":"2013\/12\/28 23:00:00"

Note that the \ are for escaping the / and are not displayed.
I would like to display this dates in this format into my grid :
"28/12/2013 23:00:00"

I've tried this into my fields definition:
{name:'date_deb', type: 'date', dateFormat: 'd-m-Y H:i:s'}

But it's not working, nothing is displayed.
By checking the ExtJS docs, I've seen this :
dateReadFormat

I'm using ExtJS4.2

A: In your field definition provide the dateFormat as it is returned from the server:
{name:'date_deb', type: 'date', dateFormat: 'Y/m/d H:i:s'}

and then in your column config use ExtJS's built-in dateRenderer with the format you'd like to render your dates with:
renderer: Ext.util.Format.dateRenderer('d/m/Y H:i:s')

You'll only need dateReadFormat and dateWriteFormat if you have a reader (to read data from server) AND a writer (to send modified data back to server) which need different date formats. Otherwise dateFormat will apply as the default format for both.

A: If the above doesn't work for you, try adding xtype: 'datecolumn' in your grid's 'columns' config.
columns: [{
            text : 'date',
            dataIndex: 'LoginDateTime',
            xtype: 'datecolumn',
            format: 'Y-m-d g:i A',
}]

This should work.

A: use this function to render date for grid
In your column definition define renderer as this
renderer: renderDate
example { dataIndex: 'TaskEndDate', header: 'PlannedEndDate', flex: 1, renderer: renderDate },
function renderDate(value)
{
    if (value == '' || value == undefined) {
        return '';
    }

    else {
        getDate = new Date(parseInt(value.substr(6)));
        }

   return Ext.util.Format.date(getDate, 'm-d-Y');
}

A: In your column config use "formatter".
    formatter: 'date("d/m/Y H:i:s")'


text:
Q: Validating links in PHP I'm building a broken link checker. So far I've managed to get this to crawl a user specified page for links and then echo a complete list of links, so I know it's finding them. What I need to do now is get it to check each of those links for the HTTP response, (which I can then highlight in some way later).
 $html = file_get_contents($_POST['urlInput']);

    $dom = new DOMDocument();
    @$dom->loadHTML($html);

    $xpath = new DOMXPath($dom);
    $hrefs = $xpath->evaluate("/html/body//a");

    for ($i = 0; $i < $hrefs->length; $i++) {
            $href = $hrefs->item($i);
            $url = $href->getAttribute('href');
            echo $url.'
';

This is where my problem starts. The above code will find and echo all links on a page, and I'm trying to figure out how to check each of them.
The code below doesn't work, but being completely new to PHP I don't understand what it is and/or isn't doing!
 get_http_response_code($url);
    }

    function get_http_response_code($url) {
      $headers = get_headers($url);
      return substr($headers[0], 9, 3);
    }

    $get_http_response_code = get_http_response_code($url);

    if ( $get_http_response_code == 200 ) {
      echo "Working!";
    } else {
      echo "Broken!";
    }

For now I would just like to find out how to get it to echo working or broken for each link.
Thanks in advance!

A: Solution found:
<?php

$website = $_POST['urlInput'];

$html = file_get_contents($website);

$website = preg_replace('{/$}', '', $website);

$dom = new DOMDocument();
@$dom->loadHTML($html);

$xpath = new DOMXPath($dom);
$hrefs = $xpath->evaluate("/html/body//a");

for ($i = 0; $i < $hrefs->length; $i++) {
        $href = $hrefs->item($i);
        $url = $href->getAttribute('href');

//The following two lines included to handle relative paths

        $url = ltrim($url, '/');
        $url = isAbsoluteUrl($url) ? $url : $website.'/'.$url;

//It then calls this function for each iteration of loop

 get_http_response_code($url);
}

function get_http_response_code($url) {

        $handle = curl_init($url);
        curl_setopt($handle,  CURLOPT_RETURNTRANSFER, TRUE);

        $response = curl_exec($handle);

        $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
        if($httpCode == 200) {
                echo $url . ": ok
";
        } else if($httpCode == 301 || $httpCode == 302) {
                echo $url . ": Redirected
";
        } else {
                echo $url . ": Nook
";
        }

        curl_close($handle);
}

function isAbsoluteUrl($url)
    {
        if (strpos($url, 'http://') !== false || strpos($url, 'https://') !== false) {
                return true;
              }

              return false;
    }

?>


text:
Q: How to use WebRTC without an answer? In the absence of a signalling server for coordinating the initial exchange, does WebRTC provide any way to allow the responder to send information freely to the caller, if the responder has only received an offer and has no other methods of communication with the caller?
(There's no signalling server because the web app must be useable offline. Any method to establish a connection with only one exchange of information would also be useful.)
Sorry, it's a long and weird question.

A: I guess by offline you mean that you have two parties that will connect through a network not connected to the internet.
Signaling is just a way to transmit information between the two parties. For the sake of example it can even be manual copy and paste. Even one of the parties can play the role of a server if the other one has a way of connecting to it (doable within the same network).
Without some kind of signaling mechanism, a WebRTC connection is not possible. And signaling is not part of the WebRTC specification, nor of any implementation.

A: Webrtc needs a signalling system for establishing peer to peer connection.  Now the thing to notice is why it needs signalling.
In the process of establishing peer connection the two parties exchange sdp which contains information such as the IP and Port at both ends at which the media/data packets will get exchanged. Similarly it contains the encoding/decoding or codec to be used plus many other useful things.Thus without the exchange of these packets between both the parties any communication can't be possible.
That is why it is not possible at least in case of webrtc that without the communication from both sides a peer connection can be established.


text:
Q: jsoup image is not getting parsed i am using jsoup to retrive images from fallowing  web page
{
http://www.jcpenney.com/dotcom/jewelry-watches/fine-jewelry/mens-jewelry/bulova%25c2%25ae-mens-stainless-steel-watch/prod.jump?ppId=180d97e&catId=cat100240089&selectedLotId=0514592&selectedSKUId=05145920000&navState=navState-:catId-cat100240089:subcatId-:subcatZone-false:N-100240089%20158:Ns-:Nao-0:ps-24:pn-1:Ntt-:Nf-:action-guided%20navigation&catId=SearchResults
}
my code is
String url = "http://www.jcpenney.com/dotcom/jewelry-watches/fine-jewelry/mens-jewelry/bulova%25c2%25ae-mens-stainless-steel-watch/prod.jump?ppId=180d97e&catId=cat100240089&selectedLotId=0514592&selectedSKUId=05145920000&navState=navState-:catId-cat100240089:subcatId-:subcatZone-false:N-100240089%20158:Ns-:Nao-0:ps-24:pn-1:Ntt-:Nf-:action-guided%20navigation&catId=SearchResults";

           Document doc= Jsoup.connect(url).userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.120 Safari/535.2").get();

          String imgUrl=doc.select("#mapImageSjElement4 img").attr("abs:src");

it should return me image url but i am not getting image url.any suggestions?????
i want to retreive main product image which is on left side of web page.

A: If you print the whole document, you'll see that that image and much more within the website is loaded by javascript scrips scattered all over the page. In order to get that image, you'll have to choose between the 2:

*

*Use a GUIless web-broser like Selenium, Webdriver, HTTPClient; and upon full load of the page, get it's html content

*Emulate the javascript by studying it's code, and retrieve the data you want

That would be a way to use the 2nd approache I mentioned without adding any extra libs to your project:
//Let's say you have the right script in a String
//variable named javascript.
String[] html = javascript.split("\n");

String imgUrl = "";
for(String line : html) {
    if (line.contains("imgUrl variable name here")) {
        imgUrl = line;
        break;
    }
}

//Now that you have what you want in a variable
//just split / substring it, untill you narrowed
//it down to what you want.


text:
Q: AWS Step Function: state A pass lambda output to state B My AWS lambda function check-version-lambda returns
{"latest": "yes"} or {"latest": "no"}.
I have the AWS step function below, to pass above result to next state.
The next state process_version is a choice state, how do I retrieve the input inside Choices? What to fill in for <???>?
  {
      "StartAt": "check_version",
      "States": {
        "check_version": {
          "Type": "Task",
          "Resource": "arn:aws:lambda:us-east-1:000:function:check-version-lambda",
          "OutputPath": "$.latest",
          "Next": "process_version"
        },
        "process_version": {
          "Type": "Choice",
          "Choices": [
            {
              "Variable": "<???>",
              "StringEquals": "yes",
              "Next": "next_state"
            },
            {
              "Variable": "<???>",
              "StringEquals": "no",
              "Next": "next_state"
            }
          ],
          "Default": "next_state"
        }
      }
    }

A: In your "check_version" state, you can use
"ResultPath": "$.result",
"OutputPath": "$.result",

to explicitly configure the step function to put the result of the lambda (e.g. {"latest": "yes"}) into the result property of the input object. OutputPath tells the step function to only select that result as state output and hand it over to the next state.
In your "process_version" state, you should then be able to use:
"Variable": "$.result.latest",
"StringEquals": "yes",
"Next": ...

Source: https://docs.aws.amazon.com/step-functions/latest/dg/input-output-example.html


text:
Q: MS Project - Assign a resource to multiple tasks that take place on the same day I have a number of tasks that all are 1 day in duration and take place on the same day. I want to assign a resource to these tasks but only have it calculate for 1 day - it currently calculates 8 hours for each task (even though they're on the same day) for the resource.

A: Insert the "Work" column. Do this BEFORE you assign resources to the task. Let us assume that you have 4 one -day tasks--all on same day--and you wish to have "Bob" Work on these tasks. So, enter "2 Hours" in the Work column for all 4 tasks. THEN, assign Bob to all 4 tasks. Bob's total Work for the day will be 8 hours.


text:
Q: How to get rid of sudo creep for btrfs commands? Until recently, I was able to run btrfs commands without the sudo prefix. Things like btrfs subvolume list /home would work.
But I issued one command with sudo (I think for creating a snapshot). Now I have to use sudo with every command.
I tried making sure that all the subvolumes have correct non-root ownership (user & group), but still I have to use sudo
What else may have changed? How can I fix this?


text:
Q: Simple countdown using minutes and seconds I need a countdown that will refresh a page, and I think I've finally got it, except for one thing. I'd like the countdown to be in minutes and seconds, not just seconds (the countdown is for one hour). A simple MM:SS format would be fine, but also writing out minutes and seconds would work. Can anybody help?
<SCRIPT LANGUAGE="JavaScript">
<!--
var counterobj = document.all ? counter : document.getElementById("counter");

var countdownfrom = 3600;   //countdown period in seconds
var currentsecond = counterobj.innerHTML = countdownfrom+1;

function countdown()
{
if (currentsecond!=1)
{
currentsecond-=1;
counterobj.innerHTML = currentsecond;
}
else
{
self.location.reload();
return;
}
setTimeout("countdown()",1000)
}

countdown()
//-->
</script>

A: Calculate minutes using a floor doing like
minute = Math.floor(currentsecond/60);

Then just output as normal.
edit -- fixed! Hopefully! (accidentally said to use mod -- you need to use Floor, I believe)


text:
Q: AlertView Not Rotating in ios7? Our app only supports Landscape mode and need to support iOS5.1 & 6.0 & 7.0. Bynow, we've set the rootviewcontroller and
                   BaseSdk : 7.0
DeploymentTarget : 5.1
Our App is working fine in iOS 5 and ios 6.
But in iOS7, when the alertview is present and the user rotating to portrait, alertview also rotating to potrait, which not happens on iOS5 & 6.
And also once alertview went to portrait, it doesn't rotate to landscape.
Note: My ViewController's orientation is fine. It is always only supports Landscape.

A: I Solved the issue by implementing the supportedInterfaceOrientations Method:
Before i've used only
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    if (landscapeOnly) {
        return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
    }
    else {
        return YES;
    }
}

Now i've implemented supportedInterfaceOrientations method also along with that. Because when alert view comes, supportedInterfaceOrientations is called automatically.
-(NSUInteger)supportedInterfaceOrientations{
    if (landscapeOnly) {
        return ((1 << UIInterfaceOrientationLandscapeLeft) | (1 << UIInterfaceOrientationLandscapeRight));
    }
    else{
        return ((1 << UIInterfaceOrientationLandscapeLeft) | (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationPortrait) | (1 << UIInterfaceOrientationPortraitUpsideDown));
    }
}

( 1 << UIInterfaceOrientationLandscapeLeft) is for UIInterfaceOrientationMaskLandscape

A: Here is some links that can help you:
iOS 7 Viewcontroller not rotating when alertview is present
iOS 7: UIAlertView created in UIActionSheet delegate function cannot auto rotate
Hope this is helps you.


text:
Q: How do I update a boolean field to its opposite in Mongoose? So I have this function:
async function update_subscription_status(id) {
    await User.updateOne({chat_id: id}, {
        mailing: // need to change this boolean field to its opposite
    })
}

Is there any way to do it without checking its state before updating?

A: Use update-documents-with-aggregation-pipeline
$set
$eq returns true or false
async function update_subscription_status(id) {
    await User.updateOne(
      { chat_id: id },
      [ { "$set": { "mailing": { "$eq": [false, "$mailing"] } } } ]
    )
}


text:
Q: Accessing IEnumerable List of values I have the following code
@model IEnumerable<Shop_Online.com.Models.Product>

@using (Html.BeginForm())
{

            ITEM
            DELIEVERY DETAILS
            QTY
            SUB TOTAL
            Remove Items

        @foreach (var item in Model)
        {

                                @Html.DisplayFor(x => item.Model_Name)

                            30 days Replacement

                Free Delievery Delivered in 2-3 business days.
                @Html.TextBox("Total_Products",1)
                Rs. @Html.DisplayFor(x => item.Price)
                <button type="submit" class="remove" value="@item.Id" id="@item.Id" name="Action">Remove</button>

        }

            Estimated Price: Rs.@ViewBag.total

            <input type="submit" name="Action" value="PLACE ORDER" style="border: 1px solid #ec6723; width: 216px; cursor: pointer; height: 45px; color: #fff; background: -webkit-linear-gradient(top,#f77219 1%,#fec6a7 3%,#f77219 7%,#f75b16 100%)" />

}
And here is the controller
public ActionResult Order(IEnumerable<Product> products, string Action)
    {
        if (Action == "PLACE ORDER")
        {
         //some code here
    }

Product Object
 public partial class Product
{
    public int Id { get; set; }
    public string Model_Name { get; set; }
    public string Company_Name { get; set; }
    public Nullable<int> Price { get; set; }
    public string Photo { get; set; }
    public string Big_Photo { get; set; }
    public string AlternateText { get; set; }
    public string Model_FullName { get; set; }
    public Nullable<int> Product_Id { get; set; }
    public string Video_record { get; set; }
    public string second_camera { get; set; }
    public string primary_camera { get; set; }
    public string touch_screen { get; set; }
    public string operating_sys { get; set; }
    public string warranty { get; set; }
    public Nullable<int> Company_Id { get; set; }
    public Nullable<int> Total_Products { get; set; }
}

I am getting null when I try to access the IEnumerable values . I am getting value for the Action variable. I even tried using for loop but still it doesn't work. I am able to display.This is something basic I am asking but  I tried searching things on Google but weren't able to correct my mistake. Can anyone plz tell me how to correct the above code. Thanks

A: In order for the default MVC Model binding mechanism to recognize a collection of entities being submitted by the form in a POST, you will need to ensure that the names of the fields have a running zero based index in the name attribute of the Html elements which are posted back to the controller, e.g.:
@for (var i = 0; i < 10; i ++)
{
  <input type='text' name="products[@i].ProductId"/>
  <input type='text' name="products[@i].Total_Products">

}

You have a couple of other options:

*

*Build up a JSON array of the form elements and then post the array to the controller via AJAX

*You could come up with your own naming mechanism and then either parse the FormCollection manually, or build a custom model binder

As an aside, you might want to change the name of your Action variable to avoid confusion with the Linq Action delegate


text:
Q: Dividing small financial values equally into several accounts Imagine that: I have a small financial value to divide in several costs accounts.
For example: I have $0.36 of something cost to divide equally on my 40 subsidiaries, and my smallest value I can register to one subsidiary is $0.01.
Looking to the problem is simple: 36 subsidiaries will have $0.01 of cost registered, and 4 of my subsidiaries won't have that cost, right?
Is there a known or common algorithm to resolve that? (that kind of algorithm that have a fancy name :) )

A: I see 2 solutions:
1. Use money type or equivalent (many frameworks contains it)
2. Use fractions like A/B.
For example, you need to devide 0.36 on 40 members. So, every will get 0.36/40 or 9/10. And store this as two values 9 and 10. Then, use fraction arithmetic


text:
Q: Why won't console commands work in CoD 4? I want to create a new movie cfg. When I am in multiplayer and load a new devmap with:
/devmap mp_mapname

I can't get other commands to work. Every time I insert a new command in the console and hit enter, it appears to be a new text-chat message.
Can anyone help me with this one?


text:
Q: Execute "sp_msforeachdb" in a Java application Hi StackOverflow community :)
I come to you to share one of my problems...
I have to extract a list of every table in each database of a SQL Server instance, I found this query :
EXEC sp_msforeachdb 'Use ?; SELECT DB_NAME() AS DB, * FROM sys.tables'

It works perfectly on Microsoft SQL Server Management Studio but when I try to execute it in my Java program (that includes JDBC drivers for SQL Server) it says that it doesn't return any result.
My Java code is the following :
this.statement = this.connect.createStatement(); // Create the statement
this.resultats = this.statement.executeQuery("EXEC sp_msforeachdb 'Use ?; SELECT DB_NAME() AS DB, * FROM sys.tables'"); // Execute the query and store results in a ResultSet

this.sortie.ecrireResultats(this.statement.getResultSet()); // Write the ResultSet to a file

Thanks to anybody who will try to help me,
Have a nice day :)
EDIT 1 :
I'm not sure that the JDBC driver for SQL Server supports my query so I'll try to get to my goal in another way.
What I'm trying to get is a list of all the tables for each database on a SQL Server instance, the output format will be the following :
+-----------+--------+
| Databases | Tables |
+-----------+--------+

So now I'm asking can someone help me to get to that solution using SQL queries thru Java's JDBC for SQL Server driver.
I also wish to thanks the very quick answers I got from Tim Lehner and Mark Rotteveel.

A: If a statement can return no or multiple results, you should not use executeQuery, but execute() instead, this method returns a boolean indicating the type of the first result:

*

*true: result is a ResultSet

*false : result is an update count

If the result is true, then you use getResultSet() to retrieve the ResultSet, otherwise getUpdateCount() to retrieve the update count. If the update count is -1 it means there are no more results. Note that the update count will also be -1 when the current result is a ResultSet. It is also good to know that getResultSet() should return null if there are no more results or if the result is an update count.
Now if you want to retrieve more results, you call getMoreResults() (or its brother accepting an int parameter). The return value of boolean has the same meaning as that of execute(), so false does not mean there are no more results!
There are only no more results if the getMoreResults() returns false and getUpdateCount() returns -1 (as also documented in the Javadoc)
Essentially this means that if you want to correctly process all results you need to do something like below:
boolean result = stmt.execute(...);
while(true)
    if (result) {
        ResultSet rs = stmt.getResultSet();
        // Do something with resultset ...
    } else {
        int updateCount = stmt.getUpdateCount();
        if (updateCount == -1) {
            // no more results
            break;
        }
        // Do something with update count ...
    }
    result = stmt.getMoreResults();
}

NOTE: Part of this answer is based on my answer to Java SQL: Statement.hasResultSet()?

A: If you're not getting an error, one issue might be that sp_msforeachdb will return a separate result set for each database rather than one set with all records.  That being the case, you might try a bit of dynamic SQL to union-up all of your rows:
-- Use sys.tables
declare @sql nvarchar(max)
select @sql = coalesce(@sql + ' union all ', '') + 'select ''' + quotename(name) + ''' as database_name, * from ' + quotename(name) + '.sys.tables'
from sys.databases
select @sql = @sql + ' order by database_name, name'
exec sp_executesql @sql

I still sometimes use INFORMATION_SCHEMA views as well, since it's easier to see the schema name, among other things:
-- Use INFORMATION_SCHEMA.TABLES to easily get schema name
declare @sql nvarchar(max)
select @sql = coalesce(@sql + ' union all ', '') + 'select * from ' + quotename(name) + '.INFORMATION_SCHEMA.TABLES where TABLE_TYPE = ''BASE TABLE'''
from sys.databases
select @sql = @sql + ' order by TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME'
exec sp_executesql @sql

Be aware that this method of string concatenation (select @sql = foo from bar) may not work as you intend through a linked server (it will only grab the last record).  Just a small caveat.

A: UPDATE
I've found the solution !
After reading an article about sp_spaceused being used with Java, I figured out that I was in the same case.
My final code is the following :
this.instances = instances;
for(int i = 0 ; i < this.instances.size() ; i++)
{
    try
    {
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        this.connect = DriverManager.getConnection("jdbc:sqlserver://" + this.instances.get(i), "tluser", "result");

        this.statement = this.connect.prepareCall("{call sp_msforeachdb(?)}");
        this.statement.setString(1, "Use ?; SELECT DB_NAME() AS DB, name FROM sys.tables WHERE DB_NAME() NOT IN('master', 'model', 'msdb', 'tempdb')");
        this.resultats = this.statement.execute();

        while(true)
        {
            int rowCount = this.statement.getUpdateCount();
            if(rowCount > 0)
            {
                this.statement.getMoreResults();
                continue;
            }
            if(rowCount == 0)
            {
                this.statement.getMoreResults();
                continue;
            }

            ResultSet rs = this.statement.getResultSet();
            if(rs != null)
            {
                while (rs.next())
                {
                     this.sortie.ecrireResultats(rs); // Write the results to a file
                }
                rs.close();
                this.statement.getMoreResults();
                continue;
            }
            break;
        }
        this.statement.close();
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
}

It tried it out and my file has everything I want in it.
Thank you all for your help ! :)


text:
Q: PHP Trying To Count Multiple Tables I'm going to cut straight to the code.
$query1 = mysql_query("
SELECT *, COUNT(1) AS `numberofenteries1` FROM `table1` WHERE `user`='$username' GROUP BY `firstname`,`lastname`
");
$query2 = mysql_query("
SELECT *, COUNT(1) AS `numberofenteries2` FROM `table2` WHERE `user`='$username' GROUP BY `firstname`,`lastname`
");
while($row = mysql_fetch_assoc($query1))
{
    $firstname  = $row ['firstname'];
    $lastname   = $row ['lastname'];
    $enteries1  = $row ['numberofenteries1'];
    $enteries2  = $row ['numberofenteries2'];
echo $enteries1 $enteries2;

I am trying to echo out two numbers counting rows from different table in a while loop. No matter what I try, I always run into an error. I have already tried naming the rows different, adding another row (row1 and row2) count to the while loop, and nothing. (For the code, it is necessary that I have them grabbing data from two different tables instead of one) How would I accomplish what I am aiming for. Any extra information will be provided. Thanks for any and all help.

A: in the while bucle you have only the var $query1, that mind the count only return
$row ['numberofenteries1'];

try use this:
while($row = mysql_fetch_assoc($query1))
{
    $firstname  = $row ['firstname'];
    $lastname   = $row ['lastname'];
    $enteries1  = $row ['numberofenteries1'];
}

while($rowa = mysql_fetch_assoc($query2))
    {
        $firstname2  = $rowa ['firstname'];
        $lastname2   = $rowa ['lastname'];
        $enteries2  = $rowa ['numberofenteries1'];
    }


text:
Q: Set theory - What is $n(\emptyset) =?$ Context from my School Textbook.

A set containing no elements is called the empty set or null set or void set.
  Reading Notation :
  The empty set or null set or void set is denoted by the symbol $\emptyset$ or $\{ \}$.

The concept of empty set plays a key role in the study of sets just like the role of the number zero in the study of number system.
Think and answer! What is $n(\emptyset)$?

A: Without additional information, I can only guess. But I think it's likely that $n(A)$, for a given set $A$, is the number of elements of $A$. Since the empty set $\emptyset$ has no elements, we thus have $n(\emptyset) = 0$.


text:
Q: FluentAssertions fails with struct with enum but not class I have a nested class and FluentAssertions can assert them.
Then I change class to struct and the test fails.
( If I change IEnumerable<ItemStruct> MyItems { get; set; } to ItemStruct MyItem { get; set; } the comparison succeeds in both cases. So I guess it has to do with the IEnumerable. )
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;

namespace CowsCannotReadLogs.FileHandling.UnitTest
{
    [TestClass]
    public class TestFluentAssertionStruct
    {
        public struct DataStruct
        {
            public IEnumerable<string> MyItems { get; set; }
        }

        // Fails.
        [TestMethod]
        public void TestSimpleStruct()
        {
            var data1 = new DataStruct { MyItems = new[] { "A" } };
            var data2 = new DataStruct { MyItems = new[] { "A" } };
            data1.Should().BeEquivalentTo(data2);
        }

        // Fails.
        [TestMethod]
        public void TestSimpleStructWithComparingByValue()
        {
            var data1 = new DataStruct { MyItems = new[] { "A" } };
            var data2 = new DataStruct { MyItems = new[] { "A" } };
            data1.Should().BeEquivalentTo(data2,
                options => options.ComparingByValue<DataStruct>());
        }

        public class DataClass
        {
            public IEnumerable<string> MyItems { get; set; }
        }

        // Succeeds.
        [TestMethod]
        public void TestSimpleClass()
        {
            var data1 = new DataClass { MyItems = new[] { "A" } };
            var data2 = new DataClass { MyItems = new[] { "A" } };
            data1.Should().BeEquivalentTo(data2);
        }
    }
}

A: When using BeEquivalentTo on structs, the two instances are by default compared by value semantics.
to compare the structs by their members, the default behavior can be overridden  either locally or globally.
Locally inside a test:
[TestMethod]
public void Test()
{
    subject.Should().BeEquivalentTo(expected,
        opt => opt.ComparingByMembers<DataStruct>());
}

Globally in e.g. [AssemblyInitialize]:
[AssemblyInitialize]
public static void AssemblyInitialize(TestContext context)
{
    AssertionOptions.AssertEquivalencyUsing(opt => opt.ComparingByMembers<DataStruct>());
}


text:
Q: Recyclerview Duplicate Values with LiveData onBackPressed in Fragment I have a recyclerview with load more, and I can't store the values in the database. So when I load the data, everything works perfectly. The problem occurs when I navigate to another fragment, and click onBackPressed, the onChanged of the observer is being called again and it is giving me the last values called from the API. Then as you can see in the code below, they are automatically being added to the list and published in UI
 productsViewModel.productsObject.observe(viewLifecycleOwner, Observer { result ->
        if (result.status != Status.LOADING) {
            (activity as MainActivity?)!!.dismissProgressDialog(getView())
            if (result.status == Status.SUCCESS && result.data != null) {
                val productsResult = parseObject(result.data.asJsonObject)
                if (!productsResult.isNullOrEmpty()) {
                    products.addAll(productsResult)
                    productAdapter.submitList(products)
                    progressBar.visibility = View.GONE
                    numberSearch.text = products.size.toString() + "/" + total + " " + resources.getString(R.string.items_found)
                } else if (result.status == Status.ERROR) {
                    if (result.message.isNullOrBlank())
                        Utils.showSnackBar(requireContext(), view, getString(R.string.something_wrong_try_again), true)
                    else
                        Utils.showSnackBar(requireContext(), view, result.message, true)
                }
            }
        }
    })

A: I think that you are not observing your result correctly.
For example, if the value of result is Status.LOADING what happens? After you enter that block, maybe there are other cases that you are not handling. We don't know because there is no other when or else if block.
Another way more "clean" would be:
productsViewModel.productsObject.observe(viewLifecycleOwner, Observer { result ->
    when(result.status) {
        Status.LOADING -> manageLoading()
        Status.SUCCESS -> manageSuccess()
        Status.ERROR -> manageError()
        else -> manageBaseCase()
    }
}

Thus, it is not all embedded in a unique if block making the management more understandable.
In your Fragment you should manually send an event to "reset" the actual state of the LiveData so that you will be sure that there won't be duplicate items.
Your Fragment may look something like this:
class ProductsFragment : Fragment() {
    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        return inflater.inflate(R.layout.product_fragment, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        observe()
        productsViewModel.send(Event.Load)
    }
}