text:
Q: Responsive menu yootheme transparent I have the issue on this website http://drfernandezconti.com that on responsive smartphone version the menu is transparent on chrome, but not on firefox.
This is also happening on iOs, and I couldn't test it on Android.
It seems some CSS property is not recognized by chrome or iOs, but I don't know wich one is.
Thanks.

A: Finally I could find the problem, just need to add
.uk-offcanvas-page { position: relative; }

on my custom css. It is a recognized bug by yoo_theme people that will be fixed on the next release.


text:
Q: Console.log shows hidden object info When I do console.log(someobject), I see some __proto__ object things inside my object, which contain a huge amount of data in them.
If I have a lot properties on my objects (properties that are also objects), I can easily get hundreds of protos. Anyway does this affect performance in any way? Should I use arrays instead?

A: It's just part of JavaScript's internal prototype chain. Whenever a new object is created, its __proto__ property is set to its "parent" object's prototype property. To answer your question, it has no impact on performance that you can control directly, so don't worry about it.
If you want to read more about it, check out MDN, https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/Proto

A: Familiarize yourself with the prototypical inheritance JavaScript uses. See, e.g., here at MDN.
In a nutshell: Objects in JavaScript are not created by instantiating classes, but creating an object that is like another object (the prototype). So every object has a pointer to its prototype.
If a method or attribute of an object is required at some point in the code, the compiler checks, whether the object posseses such a property itself (comp. hasOwnProperty()). If not, it takes a look at the respective prototype object. If the property can not be found there it looks at the prototype of the prototype an so forth. This is done all the way up to Object, which is the base prototype in JavaScript. The chain of prototypes is also called prototype chain.
As this is an inherent feature of the language you can not circumvent it anyways and thus it wont have any impact on your specific site's performance.

A: This may slow down the console.log calls, but not not your application in production mode.
Anyway the __proto__ property of Objectobjects is a non-standard and deprecated Mozilla extension, it is going to be removed someday so don't worry about it (the standard Object.getPrototypeOf(obj) method can already bu used instead of obj.__proto__).

redpajama_set_name: RedPajamaStackExchange


text:
Q: mockito when thenReturn does not return stubbed array list List<Populate> fullAttrPopulateList = getFullAtrributesPopulateList(); //Prepare return list

when(mockEmployeeDao.getPopulateList(null)).thenReturn(fullAttrPopulateList);

MyDTO myDto = testablePopService.getMyPopData(); //Will call mockEmployeeDao.getPopulateList(null)

//verify(mockEmployeeDao,times(1)).getPopulateList(null);

assertEquals(fullAttrPopulateList.size(), myDto.getPopData().size()); //This fails because myDto.getPopData().size() returns 0

As you can see testablePopService.getMyPopData() calls mockEmployeeDao.getPopulateList(null) but when I debug it a zero sized list returns instead of the stubbed array list which is prepared by getFullAtrributesPopulateList();
If I uncomment the verify statement, it passes the test meaning getPopulateList(null) behavior does get called.
Can anyone give me some advice why my stubbed array list cannot be returned even it is verified the expected behavior happened? How come an empty array list returns rather than a null if I did something wrong?

A: First, check that the method is non-final and visible throughout its hierarchy. Mockito can have trouble mocking methods that are hidden (e.g. overriding a package-private abstract class's implementation); also, Mockito is entirely unable to mock final methods, or even to detect that the method is final and warn you about it.
You may also want to check that your call is using the overload you expect. Mockito's default list return value is an empty list, so you may simply stubbing one method and seeing the default value for another. You can see which method interactions Mockito has added by adding a call to verifyZeroInteractions temporarily, and Mockito will throw an exception with a list of calls that mock has received. You could also add verifyNoMoreInteractions, and even leave it in there, at the expense of test brittleness (i.e. the test breaks when the actual code continues to work).


text:
Q: WndProc assignment issue I am attempting to make a custom GLWindow class that includes all of my setting up of my OpenGL window. However, I also want to include the WndProc callback function for messages being sent to the window in my GLWindow class.
GLWindow.h:

class GLWindow
{
    private:
        HWND hWnd;
        HDC hDC;
        HGLRC hRC;
    public:
        GLWindow();

        LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

        bool Create();

        ~GLWindow();
}

GLWindow.cpp:

GLWindow::GLWindow()
{

}

bool GLWindow::Create(int width, int height, char * title, bool fullscreen)
{
    WNDCLASSEX window;

    HINSTANCE hInstance;

    hInstance = GetModuleHandle(NULL);
    window.cbSize = sizeof(WNDCLASSEX);
    window.cbClsExtra = 0;
    window.cbWndExtra = 0;
    window.hbrBackground = NULL;
    window.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    window.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
    window.hCursor = LoadCursor(NULL, IDC_ARROW);
    window.hInstance = hInstance;
    window.lpfnWndProc = GLWindow::WndProc; // ERROR
}

GLWindow::~GLWindow()
{

}

The Error is that  a value of type "LRESULT (__stdcall GLWindow::*)(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)" cannot be assigned to an entity of type "WNDPROC."
I can't figure it out
I've gotten this to work when WndProc shares the same .cpp file as the WinMain function, but it seems as if the scope throws it off.

A: It should be a static or global function. Class member function expects to receive an additional hidden parameter called this, so the signature doesn't match.


text:
Q: Mitmproxy Client connection killed by block_global
Installed the latest version of mitmproxy, added cert,  all like in instructions. Proxy not working, can't reach any site...what I'm doing wrong? Thanks for your time.

A: There is an option in mitmproxy called block_global: Block connections from globally reachable networks, as defined in the IANA special purpose registries. Default: True
https://docs.mitmproxy.org/stable/concepts-options/
You could try to set this option as false: mitmdump --set block_global=false


text:
Q: ViewBinding with 2 possible layouts I am doing the migration to view binding and I have a fragment where I use 2 different layouts depending on a variable. Basically it goes like this.
override fun onCreateView(
    inflater: LayoutInflater,
    container: ViewGroup?,
    savedInstanceState: Bundle?
) = inflater.inflate(

    when (ussdType) {
        UssdType.USSD_TYPE -> R.layout.fragment_transaction
        else -> R.layout.fragment_balance
    }, container, false
)

The problem is that if I refactor it to viewbinding I will need 2 types of viewbindings (FragmentTransactionBinding and FragmentBalanceBinding) so for example to use a button element.
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)

    continue_button.setOnClickListener { onContinueAction(it) }

}

I don't know how to proceed since I have 2 different viewbindings

A: Simply create two variable that represent viewBinding
private lateinit var bindingTransaction: FragmentTransactionBinding
private lateinit var bindingBalance: FragmentBalanceBinding

and inflate one of them depend on your ussdType
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
        return when (ussdType) {
            UssdType.USSD_TYPE -> {
                bindingTransaction = FragmentTransactionBinding.inflate(inflater, container, false)
                bindingTransaction.root
            }
            else -> {
                bindingBalance = FragmentBalanceBinding.inflate(inflater, container, false)
                bindingBalance.root
            }
        }
    }

A: I'm also given a project which has 2 possible layouts in a fragment.
There are only 3 ways out. (If you don't have time to read, go with the 3rd option which is the best way)
One is to continue with findViewById() or Kotlin Synthetics. But both are not a good solution.
2nd way is to use two nullable viewBinding variables and use ? To do task So the one which is not null will be executed. If you want some value out of views, then you can get either of the bindings using smart null checks (Elvis operator) ex: val text = b1.tv.text ?: b2.tv.text
3rd (best way) is, create another fragment for BalanceFragment and use respective binding in it. This will also help you separate out the code so you have clear separation of concerns.


text:
Q: For which $a \in \mathbb{R}$ is this function invertible? Task from an exam:
Given is the real vector space where $a \in \mathbb{R}$ is fixed:
$V = \left\{ f: \mathbb{R} \rightarrow \mathbb{R}: f(x) = \lambda_{1}e^{x}\sin(ax)+ \lambda_{2}e^{x}\cos(ax) \text{ for } x \in \mathbb{R}, \lambda_{1}, \lambda_{2} \in \mathbb{R} \right\}$
with the basis $A=(f_{1},f_{2})$, whereby  $\text{ }$ $\text{ }$$f_{1}(x)=e^{x}\sin(ax), \text{ } \text{ }f_{2}(x)= e^{x}\cos(ax)$.
And because every element of this vector space is characterized by an ordered pair $(\lambda_{1}, \lambda_{2}) \in \mathbb{R}^{2}$ of coefficients, with allocation $f=\lambda_{1}f_{1}+\lambda_{2}f_{2} \mapsto (\lambda_{1}, \lambda_{2})$, every linear mapping of $V$ in $V$ can be seen as a $2\times 2$ matrix.
Let $L: V \rightarrow V$ be the linear mapping which assigns every function $f \in V$ its derivative $f' \in V$ to $x$.
For which $a \in \mathbb{R}$ is the function/mapping $L$ invertible?

I'm not sure how to do this. But I tried that:
$$f(x)=\lambda_{1}e^x \sin(ax)+ \lambda_{2}e^x \cos(ax)$$
$$f'(x)= \lambda_{1}e^x \sin(ax)+ \lambda_{1}a \cos(ax)+ \lambda_{2}e^x \cos(ax) - \lambda_{2}e^xa \sin(ax)$$
and as I understood from task this derivative would be $L$.
But what we do now? I have really no idea how to continue :s

A: Since $Lf_1$ is the function
$$
e^x\sin(ax)+ae^x\cos(ax)=f_1(x)+af_2(x)
$$
and $Lf_2$ is the function
$$
e^x\cos(ax)-ae^x\sin(ax)=-af_1(x)+f_2(x)
$$
the matrix of $L$ with respect to the basis $A$ is
$$
\begin{bmatrix}
1 & -a \\
a & 1
\end{bmatrix}
$$
which has determinant $1+a^2\ne0$ (since $a$ is real). So $L$ is invertible for every $a$.


text:
Q: conditionally add an xmlattribute to an xmlelement with Oracle SQL I'm dealing with a system that accepts data loads in XML format. For example, there's a field called "col1", and that field has the value "world" in it. The system interprets <col1 />, <col1></col1>, and a missing <col1> element as "no change" to the field called col1. (This is good because, if we were creating new data, "no change" would mean to accept whatever the default value is.) If I need to delete whatever is in the field, the <col1> element needs to have an xsi:nil attribute with a value of true.
So, when I'm extracting data from one instance of the system to load into another instance (inserting with SQL is not an option), I need to conditionally add xsi:nil="true" attribute to the XML returned from a query in Oracle 12c to explicitly indicate that the value of the element is null. (Always adding xsi:nil with a value of true or false, as appropriate, could work but is not desirable as it breaks convention and bloats file size.)
A test case can be set up as follows.
create table table1 (id number(10), col1 varchar2(5));
insert into table1 values (1,'hello');
insert into table1 values (2,null);
commit;

I want to to get this back from a query:
<outer><ID>1</ID><COL1>hello</COL1></outer>
<outer><ID>2</ID><COL1 xsi:nil="true"></COL1></outer>

This query throws an error.
select
    xmlelement("outer",
        xmlforest(id),
        (case col1
            when null then xmlelement(COL1, xmlattributes('xsi:nil="true"'), null)
            else xmlforest(col1)
            end)
    )
from table1
;

Is there some other way to conditionally include the xmlattributes call, or some other way to get the output I want?

A: I found that this query works, but it's more verbose than I would like.
select
    xmlelement("outer",
        xmlforest(id),
        xmlelement(col1,xmlattributes(case when col1 is null then 'true' else null end as "xsi:nil"), col1)
        ).getClobVal()
from table1
;

A: You can use NVL2 to make it slightly less verbose:
Query 1:
SELECT  XMLELEMENT(
          "outer",
          XMLFOREST( id ),
          XMLELEMENT( col1, xmlattributes( NVL2(col1,NULL,'true') as "xsi:nil"), col1 )
        ).getClobVal() AS element
FROM    table1;

Result:
OUTPUT
-----------------------------------------------------
<outer><ID>1</ID><COL1>hello</COL1></outer>
<outer><ID>2</ID><COL1 xsi:nil="true"></COL1></outer>

Query 2: You could also use XMLFOREST to generate the elements and then APPENDCHILDXML to append the missing element (including namespaces are left as an exercise to the OP):
SELECT  APPENDCHILDXML(
          XMLELEMENT( "outer", XMLFOREST( id, col1 ) ),
          '/outer',
          NVL2( col1, NULL, XMLTYPE('<COL1 nil="true"></COL1>') )
        ).getClobVal() AS element
FROM    table1;

Result:
OUTPUT
-------------------------------------------
<outer><ID>1</ID><COL1>hello</COL1></outer>
<outer><ID>2</ID><COL1 nil="true"/></outer>


text:
Q: Does Tibco WebFOCUS only return XML Response for REST calls? I am new to Tibco WebFocus. I want to connect to my Webfocus environment from Java code. I am going through one of the pdf document given by webfocus which is a developer guide for communication between webfocus and rest application. So in that document I see only XML response but no JSON response for a Rest call and the version of webfocus mentioned in the document is 82.07. I want to know if we can get the JSON response from Webfocus as it will be convenient and lightweight for Java.
Thanks in advance.


text:
Q: I want to create a file that been given name by the user and save some image in it ? in php i want to create a file.The name of the file is given by the user.So i take the textfield value to $name and how can i save a file with that name? i know how to save with a static name like
 $myfile="ads.txt"

so my question is.is there a way that i can create a file with the name $name and save some stuff in it like image.

A: $file = fopen($name, 'wb'); // for the love of God and all that is holy, please validate $name
fwrite($file, $data);
fclose($file);

A: You can't save images in a txt file.
What you must do is save the actual image to your server (uploaded via a file field) and save to a database the location and name of the image, along with the user id, so you know who uploaded it.
There is quite a large amount of code involved, so i would suggest googling for "php file upload tutorial", plenty of examples out there.


text:
Q: Safely refresh activity details from AsyncTask I have an Android app with an associated website.
I've a LoginActivity which accepts user credentials, uses an AsyncTask subclass to verify them with the website, and if correct stores them in SharedPreferences for future use.
I've a MainActivity which displays user details, based on those SharedPreferences values.
So when the AsyncTask completes, I need to refresh the user details displayed in the Main activity.

*

*I could do this by passing a reference to the MainActivity to the LoginActivity when calling it, and then in the AsyncTask onPostExecute, call a function in that MainActivity instance to refresh the displayed data.
This seems to be a common way of doing it, but I'm not sure if it's completely safe. It's unlikely, but what happens if the MainActivity is terminated by the OS while the AsyncTask is still processing?

*Alternatively, in this instance I could just finish() the MainActivity when I start the LoginActivity, and launch a new MainActivity from the onPostExecute which would display the refreshed data.
But I may have other activities where user interaction is proceeding while a background AsyncTask is refreshing data - in those cases the second method won't work.
Just wondering if there's a better way of doing it, or is the first way safe enough?

A:
I could do this by passing a reference to the MainActivity to the LoginActivity when calling it, and then in the AsyncTask onPostExecute, call a function in that MainActivity instance to refresh the displayed data.

The out-of-the-box way of dealing with activities coming and going is to use AsyncTaskLoader. This approach implements @ByteMe's suggestion to unregister/register activity instances. Unfortunately, its programmer API is... less than painless. In particular, the API is written for a screen that begins loading immediately when it's opened. Using the Loaders API in a screen that begins loading upon user interaction is perfectly possible, but the implementation is a bit awkward.
A common alternate approach –still using only core- and support-v4 library classes– is to use an IntentService to do the background work and the LocalBroadcastManager to deliver the result.
If using Open Source libraries is an option, you might want to look at Otto Bus or RxJava to deliver the "load finished" event.

Alternatively, in this instance I could just finish() the MainActivity when I start the LoginActivity, and launch a new MainActivity from the onPostExecute which would display the refreshed data.

If I understand correctly, the MainActivity is your launch activity. The first thing it does is check if login is necessary and, if it is, it directs to LoginActivity. If login isn't necessary, it shows the account data and if it is, it waits for LoginActivity to return.
This sounds to me like a perfect fit for startActivityForResult(Intent, int). Just have the main activity launch the login activity with a request code. The login activity can call setResult(int, Intent) with a return code and the authentication data. The main activity can then implement onActivityResult() to get the return value from the login activity and do all that needs to be done.
As an added benefit, you can centralise all SharedPreferences interaction in the main activity and keep it entirely outside login activity. This makes for lower coupling between the two.
An entirely different approach that you could consider is to ditch user authentication entirely and rely on Google+ Sign-in to identify users by their Google+ account. You can do the same through Facebook. On the upside, using either of these (or both) will completely free you from the responsibility of managing authentication and credentials in a secure way. On the downside, there's vendor lock-in and it may scare off some users.


text:
Q: Official site - CXF Apache - CORS Example - Ambiguos Anyone from Apache who could help me in the CORS example in your site?
http://cxf.apache.org/docs/jax-rs-cors.html#JAX-RSCORS-Examples
The example from this pages is a little ambiguous because the "address='/rest'" does not point to any resource "rest".
Thank you!

A: Services are exposed on url "/rest", so resources are avalible at paths like "/rest/delete".


text:
Q: Efficient way to replace SET/LIST property in Janusgraph In JanusGraph, I want to replace entire value of SET(or LIST) property.
Accoding to this article, both storage backend and index backend (ES, Solr) behavior MUST be taken into account for consistency and efficiency though, the article was written about Titan 1.0.
Currently, I have two option to do it as follows. Which one is better ? Or is there best way to update SET/LIST property in JanusGraph.

*

*JanusGraph version: github master

*Gremlin version: 3.2.6

Sample schema
mgmt = graph.openManagement()
person = mgmt.makeVertexLabel('Person').make()
name = mgmt.makePropertyKey('name').dataType(String.class).cardinality(SET).make()
mgmt.buildIndex('i_person_name', Vertex.class).addKey(name, Mapping.STRING.asParameter()).buildMixedIndex('elastic-search')
mgmt.commit()

person = g.addV('Person').property('name', 'Alexander').property('name', 'Alex').next()
g.tx().commit()

Solution 1
Drop entire property values, and then set new values.
new_names = ['Alex', 'Alexander Emmanuel Rodriguez'] as Set

v = g.V().hasLabel('Person').has('name', 'Alexander').next()
g.V(v).properties('name').drop().iterate()
new_names.each{
    v.property('name', it)
}

g.tx().commit()

Solution 2
Drop only old values and set only new values.
new_names = ['Alex', 'Alexander Emmanuel Rodriguez'] as Set

v = g.V().hasLabel('Person').has('name', 'Alexander').next()
v.properties('name').each {
    new_names.remove(it.value()) ? null : it.remove()
}
new_names.each {
    v.property('name', it)
}

g.tx().commit()

A: You can drop old and add new values in a single traversal. I have to admit it's not the easiest traversal, but it works:
gremlin> g = TinkerGraph.open().traversal()
==>graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
gremlin> g.addV("person").property(list, "name", "Alexander")
==>v[0]
gremlin> g.V().valueMap()
==>[name:[Alexander]]

gremlin> new_names = [ "Alex"
                     , "Alexander Emmanuel Rodriguez"] as Set
==>Alex
==>Alexander Emmanuel Rodriguez

gremlin> g.withSideEffect("nn", new_names).
           V().has("person","name","Alexander").as("p").
           sideEffect(
             properties("name").choose(value().where(without("nn")),
                                         drop(), value().store("x"))).barrier().
           select("nn").unfold().where(without("x")).as("n").
           select("p").property(list, "name", select("n")).iterate()

gremlin> g.V().valueMap()
==>[name:[Alex,Alexander Emmanuel Rodriguez]]


text:
Q: Caused by: com.datastax.driver.core.exceptions.SyntaxError: line 0:-1 mismatched input '' expecting ')' I'm new to cassandra. I'm trying to setup a cassandra2.0.0 cluster(4 nodes) and config it with wso2 DAS 3.0.1 . I have setup the cluster successfully, after configure it to DAS, while starting up the DAS server  gives following error,
[2016-02-29 16:52:38,515]  INFO {com.datastax.driver.core.Cluster} -  New Cassandra host /127.0.0.3:9042 added
[2016-02-29 16:52:38,515]  INFO {com.datastax.driver.core.Cluster} -  New Cassandra host /127.0.0.2:9042 added
[2016-02-29 16:52:38,515]  INFO {com.datastax.driver.core.Cluster} -  New Cassandra host localhost/127.0.0.1:9042 added
[2016-02-29 16:52:38,516]  INFO {com.datastax.driver.core.Cluster} -  New Cassandra host /127.0.0.4:9042 added
[2016-02-29 16:52:39,055] ERROR {org.wso2.carbon.analytics.dataservice.core.AnalyticsDataServiceComponent} -  Error in activating analytics data service: line 0:-1 mismatched input '<EOF>' expecting ')'
com.datastax.driver.core.exceptions.SyntaxError: line 0:-1 mismatched input '<EOF>' expecting ')'
    at com.datastax.driver.core.exceptions.SyntaxError.copy(SyntaxError.java:35)
    at com.datastax.driver.core.DefaultResultSetFuture.extractCauseFromExecutionException(DefaultResultSetFuture.java:289)
    at com.datastax.driver.core.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:205)
    at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:52)
    at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:44)
    at org.wso2.carbon.analytics.datasource.cassandra.CassandraAnalyticsRecordStore.lookupRecordsByIds(CassandraAnalyticsRecordStore.java:337)
    at org.wso2.carbon.analytics.datasource.cassandra.CassandraAnalyticsRecordStore.readRecordsByIds(CassandraAnalyticsRecordStore.java:331)
    at org.wso2.carbon.analytics.datasource.cassandra.CassandraAnalyticsRecordStore.readRecords(CassandraAnalyticsRecordStore.java:282)
    at org.wso2.carbon.analytics.datasource.core.util.GenericUtils.listRecords(GenericUtils.java:323)
    at org.wso2.carbon.analytics.dataservice.core.indexing.GlobalShardAllocationConfig.getNodeIdsForShard(GlobalShardAllocationConfig.java:46)
    at org.wso2.carbon.analytics.dataservice.core.indexing.GlobalShardMemberMapping.reset(GlobalShardMemberMapping.java:54)
    at org.wso2.carbon.analytics.dataservice.core.indexing.GlobalShardMemberMapping.<init>(GlobalShardMemberMapping.java:47)
    at org.wso2.carbon.analytics.dataservice.core.indexing.IndexNodeCoordinator.<init>(IndexNodeCoordinator.java:101)
    at org.wso2.carbon.analytics.dataservice.core.indexing.AnalyticsDataIndexer.init(AnalyticsDataIndexer.java:213)
    at org.wso2.carbon.analytics.dataservice.core.AnalyticsDataServiceImpl.<init>(AnalyticsDataServiceImpl.java:148)
    at org.wso2.carbon.analytics.dataservice.core.AnalyticsDataServiceComponent.activate(AnalyticsDataServiceComponent.java:63)
    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.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
    at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
    at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
    at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
    at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
    at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
    at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
    at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:451)
    at org.wso2.carbon.ntask.core.internal.TasksDSComponent.activate(TasksDSComponent.java:106)
    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.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
    at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
    at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
    at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
    at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
    at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
    at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
    at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:451)
    at org.wso2.carbon.core.internal.StartupFinalizerServiceComponent.completeInitialization(StartupFinalizerServiceComponent.java:199)
    at org.wso2.carbon.core.internal.StartupFinalizerServiceComponent.serviceChanged(StartupFinalizerServiceComponent.java:288)
    at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:451)
    at org.wso2.carbon.server.admin.internal.ServerAdminServiceComponent.activate(ServerAdminServiceComponent.java:106)
    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.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
    at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
    at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
    at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
    at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
    at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
    at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
    at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:451)
    at org.wso2.carbon.core.init.CarbonServerManager.initializeCarbon(CarbonServerManager.java:514)
    at org.wso2.carbon.core.init.CarbonServerManager.start(CarbonServerManager.java:219)
    at org.wso2.carbon.core.internal.CarbonCoreServiceComponent.activate(CarbonCoreServiceComponent.java:94)
    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.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
    at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
    at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
    at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
    at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
    at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
    at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
    at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
    at org.eclipse.equinox.http.servlet.internal.Activator.registerHttpService(Activator.java:81)
    at org.eclipse.equinox.http.servlet.internal.Activator.addProxyServlet(Activator.java:60)
    at org.eclipse.equinox.http.servlet.internal.ProxyServlet.init(ProxyServlet.java:40)
    at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.init(DelegationServlet.java:38)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5262)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5550)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.datastax.driver.core.exceptions.SyntaxError: line 0:-1 mismatched input '<EOF>' expecting ')'
    at com.datastax.driver.core.Responses$Error.asException(Responses.java:101)
    at com.datastax.driver.core.DefaultResultSetFuture.onSet(DefaultResultSetFuture.java:140)
    at com.datastax.driver.core.RequestHandler.setFinalResult(RequestHandler.java:293)
    at com.datastax.driver.core.RequestHandler.onSet(RequestHandler.java:455)
    at com.datastax.driver.core.Connection$Dispatcher.messageReceived(Connection.java:734)
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
    at org.jboss.netty.handler.timeout.IdleStateAwareChannelUpstreamHandler.handleUpstream(IdleStateAwareChannelUpstreamHandler.java:36)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
    at org.jboss.netty.handler.timeout.IdleStateHandler.messageReceived(IdleStateHandler.java:294)
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
    at org.jboss.netty.handler.codec.oneone.OneToOneDecoder.handleUpstream(OneToOneDecoder.java:70)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
    at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:462)
    at org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:443)
    at org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303)
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
    at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)
    at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:318)
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)
    at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
    at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
    at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
    ... 3 more
[2016-02-29 16:52:39,095]  INFO {org.wso2.carbon.core.init.JMXServerManager} -  JMX Service URL  : service:jmx:rmi://localhost:11111/jndi/rmi://localhost:9999/jmxrmi

This seems like a syntax error in configuration files,
I checked most of them.If any one had the same experience or have ideas are welcome.If you need any config file please comment.
Thanx in Advance,

A: Sorry for the delay update,
This was an intermediate error occurred due to incompatible product versions. Correct Cassandra version should be Cassandra 2.2.0 with DAS 3.0.1
Thanks,


text:
Q: jQuery color change or CSS? I've tried achieving a hover/selected color change for a particular field, but I'm thinking jQuery is the answer. I've looked into some button click tutorials, but maybe I'm not just seeing it or doing it correctly.
The idea here is that when a user hovers over a Headline, the background color changes, when they click the headline to expand it, the background color remains constant (selected), however as it stands right now the background color of the expanded fields do not change.
Here is the demo:
http://www.notedls.com/demo

A: Use jQuery to add/remove classes that set the styles. This will keep css separate to the code, which is a better solution, especially if designers are involved.

A: I see that you have JQuery add a selected class to your li element when clicked. Depending on what you want to do, you can color the li.selected background color, or target the div based on the li.selected element.
ul#acc1 li.selected {
   background-color: #xxxxxx;
}

ul#acc1 li.selected div {
   background-color: #xxxxxx;
}

A: For accessibility reasons these should be created as a set of <a> tags inside the list. This is so that a screen reader/ keyboard tab will stop on the hyperlink.
You can then use pseudo-classes (states) such as hover in css so this will work even if script is disabled.
a:link {background-colorr:#FF0000;}      /* unvisited link */
a:visited {background-color:#00FF00;}  /* visited link */
a:hover {background-color:#FF00FF;}  /* mouse over link */
a:active {background-color:#0000FF;}  /* selected link */


text:
Q: Parsing huge XML file for getting information from huge CSV file I have huge problem.
I have a task to put in database information about products. All information's except price are in XML file that is big 100mb.
In another file there are information's about price of that product. That is CSV file with size about 200mb
In simple logic

*

*Parse XML into array

*Search price by unique ID of product in another file

*Add found price to element of array where is that product

*Put information's in database

But i Cannot do that. Problem is in SIZE.
I manage to parse XML and put it in array, but I cannot handle CSV file. If there is 1000 products, for each product he need to parse CSV file (that CSV file have more than 30.000.000 lines). I cannot parse that CSV one, much less 1000.
I need suggestion how to solve this problem

A: Looks like a job for a database to me. Load both files into a database and then do a simple join.

A: Use XMLReader for the XML, SplFileObject for the CSV.
Do not keep the information in memory. Write it directly into a database like MySQL or SQlite. After all the data is imported you can use SQL to aggregate it.


text:
Q: Com port max speed I have a hardware that send data to the com port in the form: "HxxxxVxxxx" where x = number: eg: (H1234V5678).
I want to ask, what should I set the sample rate to send it as soon as possible. (baud 9600, 8bits, parity: none, stop bit: 1).
The program written in Java or C# was able to recive these data on the whole, not in parts.
When sending data every 22ms, and receive such data:
2014-08-11 18:48:39.669  56 36 36 37
2014-08-11 18:48:39.674  48 30 0D 0A
2014-08-11 18:48:39.687  56 36
2014-08-11 18:48:39.692  36 39 48 30
2014-08-11 18:48:39.696  0D 0A
2014-08-11 18:48:39.712  56 36 36 38
2014-08-11 18:48:39.716  48 30 0D 0A
2014-08-11 18:48:39.732  56 36
2014-08-11 18:48:39.737  36 37 48 30
2014-08-11 18:48:39.742  0D 0A
2014-08-11 18:48:39.753  56

but i wana somethink like:
2014-08-11 18:48:39.600  56 36 36 37 48 30 0D 0A
2014-08-11 18:48:39.622  56 36 36 37 48 30 0D 0A
2014-08-11 18:48:39.644  56 36 36 37 48 30 0D 0A
2014-08-11 18:48:39.666  56 36 36 37 48 30 0D 0A
2014-08-11 18:48:39.688  56 36 36 37 48 30 0D 0A

c# code:
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
    string timestamp = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff");
    int bytes = comport.BytesToRead;
    byte[] buffer = new byte[bytes];
    comport.Read(buffer, 0, bytes);

    File.AppendAllText(@"c:\file.txt", timestamp + "  "+ByteArrayToHexString(buffer) +"\n" + Environment.NewLine);
}

A: It looks like the data you're receiving is in a slightly different format than: "HxxxxVxxxx"
The way I read your logs, you're receiving "V66H0\r\n".
(\r = carriage return, \n = line feed)
If you can guarantee that all of your individual commands will end in a \r\n (0x0D,0x0A), then you have 2 options:

*

*Create a buffer and keep adding to it until you hit a 0x0D 0x0A, then you can process that as a line.

*Instead of using the asynchronous SerialPort.DataRecieved event, you could change your code around to using the synchronous SerialPort.ReadLine() method, which will read an entire line at a time.
This is obviously simplified, but it should work something like this:
public bool KeepRunning = true;
while(KeepRunning)
{
    string command = serialport.ReadLine();
    processCommand(command);
}

Where serialport is an already opened SerialPort object, and processCommand is some method that will handle an entire line.

A: Changing the baud rate will not give you the desired result you are looking for
. The SerialPort class (nor any class based on Stream which is what the class tries to emulate) guarantees the exact amount of data received will be the amount you requested. If you want 8 byte chunks you need to buffer the incoming data and every time you get 8 bytes worth of data you return the result.
You will need to put a layer to do your buffering between your reading of the serial port and your File.AppendAllText so you build up until you have 8 bytes of data then you write out to the file.
private byte[] buffer = new byte[8];
private int bufferOffset = 0;

private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
    int totalBytesToRead = comport.BytesToRead;
    int totalBytesRead = 0;

    while (totalBytesToRead > totalBytesRead)
    {
        //Chooses the remaining size in the buffer or the remaining bytes available to read, whichever is smaller.
        var bytesToRead = Math.Min(buffer.Length - bufferOffset, totalBytesToRead - totalBytesRead);

        var bytesRead = comport.Read(buffer, bufferOffset, bytesToRead);

        bufferOffset += bytesRead;
        totalBytesRead += bytesRead;

        //If we have filled our buffer write it out to the file.
        if (bufferOffset == buffer.Length)
        {
            string timestamp = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff");
            File.AppendAllText(@"c:\file.txt", timestamp + "  " + ByteArrayToHexString(buffer) + "\n" + Environment.NewLine);
            bufferOffset = 0;
        }
    }
}


text:
Q: Can't scroll horizontal on webView I need to scroll and zoom webView horizontally, because i have a big canvas with ticket sales, and scroll isn't working on devise lower than 5.0, but i need to support versions 4.1+.
Here's my webView
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setLoadsImagesAutomatically(true);
    webView.getSettings().setAllowFileAccessFromFileURLs(true);
    webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
    webView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
    webView.setScrollbarFadingEnabled(false);
    webView.setVerticalScrollBarEnabled(true);
    webView.setHorizontalScrollBarEnabled(true);
    webView.getSettings().setAppCacheEnabled(false);

    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setDisplayZoomControls(false);
    webView.setWebChromeClient(new WebChromeClient());
    webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    webView.addJavascriptInterface(new MyJavaScriptInterface(getContext()), "HtmlViewer");
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.getSettings().setUseWideViewPort(true);
    webView.getSettings().setDomStorageEnabled(true);
    webView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);

    //  webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    if (Build.VERSION.SDK_INT >= 19) {
        webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    }
    else {
        webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

    //  ((GiftsActivity)getActivity()).dismissSpinner();
    webView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {

            view.loadUrl(url);
//                view.reload();

            return false;
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            webView.loadUrl("javascript:HtmlViewer.showHTML" +
                    "(document.getElementsByTagName('pre')[0].innerHTML);");
        }
    });

    webView.loadUrl(url);
    ((GiftsActivity)getActivity()).dismissSpinner();

}

and xml
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<WebView android:id="@+id/webViewPosterPlaces"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android" />
</LinearLayout>

I tried to change layout to relative and changing orientation to horisontal, also i tried to put webview inside scrollview, but it won't works too.
By the way when i zoom in web view i also can't scroll horizontal.
vertical scroll works properly as a Zoom in, but zoom out don't work too
PROBLEM RESOLVED:
Need to remove this line:   webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);

A: Need to remove this line: webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN)


text:
Q: Passing pointer of object (which is created before ) to extern "C" function of dynamic shared library Example
I have 2 two files compiled together:

*

*MyClass.h / cpp which contain data and function members;

*Main.cpp which contains int main() and will load a dynamic library that was compiled from the source below;
==== Compile as dynamiclib.so=========

*

*dynamic.c which has extern "C" functionOfDynamic(MyClass*)

Scenario
In the file main.cpp I will load (dopen(dynamic.so,....)) a dynamic library (that was compiled from dynamic.c), and one of its functions will be called and be passed a MyClass pointer.
My question: Can the function from the dynamic library call member functions of MyClass?
dynamic.c
#include "MyClass.h"

int SomeMethodWrapper(void *A){

     return static_cast<MyClass*>(A)->SomeMethod();  // got core dump
}

extern "C" int functionOfDynamic(void* A) {
    SomeMethodWrapper(A);
}

I got core dump
Note: MyClass object  was created before loading "dynamiclib.so"
========Update==============
Dear All
The code above should be fine , I got core dump because I put something wrong , sorry

A: Suppose you have
MyClass.h / MyClass.cpp implementing
class MyClass {
public:
     //...
     void Foo( void );
;

Then you create your instance in Main.cpp, on which you call your DLL.
So how does this look on the DLL side? If you compile your DLL to call MyClass::Foo, and if you include MyClass.cpp in your DLL-project also (which you must, otherwise its unresolved external compile error), then you essentially compile void Foo( void ) twice which sounds like a problem to me.
Instead, you should use an interface declaration:
IMyClass.h
with
struct IMyClass {
    virtual void Foo( void ) = 0;
}

and accordingly in the MyClass.h
class MyClass : public IMyClass;

so that you can call Foo (which is pure virtual) from your DLL without the actual implementation of the function. This works and regardless of the C or C++. Hope this helps.


text:
Q: How to hide Safari's toolbars when orientation changes to landscape mode? I've tried the following approach:
<meta name="viewport" content="width=device-width, minimal-ui">

and
window.addEventListener('load', function() {
setTimeout(scrollTo, 0, 0, 1);
}, false);

But it hasn't worked. Could you advise something on this?

A: The best solution I found is this one. Basically make your content higher than viewport and it would become fullscreen (Hiding toolbars) when switching to landscape. Not perfect but usable.


text:
Q: Enable 'Close' button on uninstall modal window Is it possible in Inno Setup to enable or hide window close button at uninstall modal window?

The reason is that I'm using VCL Style Inno to style my installer and in first uninstall modal window it uses active close button style when it's actually disabled.


text:
Q: "(" char doesn't work in PowerShell I can't get this to work. It doesn't like the "(" char;
how do I fix it?
 Dir | Rename-Item -NewName { $_.name -replace "(","" }

How do I handle this type of special character in PowerShell?

A: Let's try analyzing the problem a bit. First off, create some dummy files that contain a parenthesis like so,
for($i=0;$i -le 4; ++$i) { set-content -path $("file($i).txt" -f $i) -value $i }
Output:
gci
    Directory: C:\temp\foo
Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---         17.2.2014     10:34          3 file(0).txt
-a---         17.2.2014     10:34          3 file(1).txt
-a---         17.2.2014     10:34          3 file(2).txt
-a---         17.2.2014     10:34          3 file(3).txt
-a---         17.2.2014     10:34          3 file(4).txt

Now that we have some test data, let's try to run the command that provied an error message like so,
Dir | Rename-Item -NewName { $_.name -replace "(","" }

Rename-Item : The input to the script block for parameter 'NewName' failed.
Invalid regular expression pattern: (.
At line:1 char:27
+ Dir | Rename-Item -NewName <<<<  { $_.name -replace "(","" }
    + CategoryInfo          : InvalidArgument: (file(0).txt:PSObject) [Rename-Item], ParameterBind   ingException
    + FullyQualifiedErrorId : ScriptBlockArgumentInvocationFailed,Microsoft.PowerShell.Commands.Re   nameItemCommand

Oops! The error message says that an invalid regular expression was used. That means -replace is not going to just replace strings but it supports regular expressions too!
In order to get -replace to treat the input as literal text instead of a regex, the input needs to be escaped. The simple way is to insert backslashes \, but this gets soon tedious. There luckily is an easier way, as .Net Regex class has a built-in escape method [Regex]::Excape(). Like so,
Dir | Rename-Item -NewName { $_.name -replace [regex]::escape("("),"" }
Output:
ls
    Directory: C:\temp\foo
Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---         17.2.2014     10:34          3 file0).txt
-a---         17.2.2014     10:34          3 file1).txt
-a---         17.2.2014     10:34          3 file2).txt
-a---         17.2.2014     10:34          3 file3).txt
-a---         17.2.2014     10:34          3 file4).txt

A: You've got a great explanation of the exact cause of your problem from @vonPryze, but there's a much simpler solution. The -replace operator uses regular expressions which need escaping, but the .Replace() string method just uses strings. So if you don't need a regex, just use the method and there's no need to escape anything:
dir | rename-item -NewName { $_.name.Replace("(","") }

A: Dir | Rename-Item -NewName { $_.name -replace "\(","" } # This works


text:
Q: how to set value in DataGridViewComboBoxColumn from a datatable? DataGridViewComboBoxColumn dgvcb = (DataGridViewComboBoxColumn)grvPackList.Columns["Units"];
                Globals.G_ProductUtility G_Utility = new Globals.G_ProductUtility();
                dgvcb.DisplayStyle = DataGridViewComboBoxDisplayStyle.DropDownButton;
                G_Utility.addUnittoComboDGV(dgvcb);
                DataSet _ds = iRawMaterialsRequest.Select();
                grvPackList.DataSource = _ds.Tables[0];

the problem is that the DataGridViewComboBoxColumn in the datagrid is not selected with the value in table how is it possilbe to set value of DataGridViewComboBoxColumn from datasoure
int i=0;
                foreach (DataRow dgvr in  _ds.Tables[0].Rows )
                {
                    grvPackList.Rows[i].Cells["Units"].Value = dgvr["Units"].ToString();
                    i++;
                }

this code is working but is there any solution with out using loops?

A: int i=0;
 foreach (DataRow dgvr in  _ds.Tables[0].Rows )
                {
                    grvPackList.Rows[i].Cells["Units"].Value = dgvr["Units"].ToString();
                    i++;
                }

When i Tried this it worked fine

A: you can bind the DataGridViewComboBoxColumn directly to your datasouce like
DataGridViewComboBoxColumn dgvcb = (DataGridViewComboBoxColumn)grvPackList.Columns["Units"];
dgvcb.ValueMember = "YourUnitValue";
dgvcb.DisplayMember = "Units";
dgvcb.DataSource = _ds.Tables[0];


text:
Q: CKEditor - Get Element by Id or Class I'm trying to get an element with his ID or Class but with no success...

Cannot read property 'getById' of undefined

I follow instructions here : CKEDITOR docs GetById()
Here is my code:
$(document).ready(function () {
    ckeditor_init();
});

var $textarea = $('#tiny_mce_block').find('textarea').attr('id');
function ckeditor_init() { // This works
    CKEDITOR.replace($textarea, {
        language: 'fr',
        allowedContent: true,
    });

    var editor = CKEDITOR.instances[$textarea]; // This works
    var $dataCkeditor = editor.getData(); // This works

    var el = $(editor.document.getById('2')); // This doesn't work !

    console.log(el);
}

FIDDLE : http://jsfiddle.net/B4yGJ/395/
In my $dataCkeditor = editor.getData(); I have this:
mardi
qualité sécurité efficacité

How can I select an element either by an ID (in my case "2") or by a Class (in my case for example "st") and after get the "data-time-start"  ?
thanks !

A: Use instanceReady event (see my previous answer):
http://jsfiddle.net/oleq/LjggqL1m/
function ckeditor_init() { // This works
    CKEDITOR.replace(textarea, {
        language: 'fr',
        allowedContent: true,
        on: {
            instanceReady: function() {
                var editor = this;
                var data = editor.getData();
                var el = $(editor.document.getById('2'));

               alert(el);
            }
        }
    });
}

You could also get interested in editor#contentDom event, which fires each time editor's DOM is loaded, i.e. on editor.setData().

A: You need to run the line which sets the $textarea value inside the DOMReady handler, otherwise the value will be null as the element will not be available in the DOM when the code is executed. Try this:
var textarea;
$(document).ready(function () {
    ckeditor_init();
    textarea = $('#tiny_mce_block').find('textarea').attr('id');
});

function ckeditor_init() {
    CKEDITOR.replace(textarea, {
        language: 'fr',
        allowedContent: true,
    });

    var editor = CKEDITOR.instances[textarea];
    var $dataCkeditor = editor.getData();
    var el = $(editor.document.getById('2'));
    console.log(el);
}

Note also that the $ prefix is primarily used in javascript to denote variables holding a jQuery object. As the textarea var only holds a string, I have removed the $ for consistency.

A:     var textarea;
$(function () {
  textarea = $('#tiny_mce_block').find('textarea');
  ckeditor_init();
});
function ckeditor_init() {
 for(var i = 0; i < textarea.length; i++){
    CKEDITOR.replace(textarea[i]);
    var editor = CKEDITOR.instances[textarea[i]];
 }
}

A: Here, I have assigned/stored CKEditor as global variable.
In HTML file:

JS File.

*

*Here getById || find() || findOne methods useds

*Custom config also loaded

*JQuery Method to find Element

*Startup focus trigged
var GlobalEditor =null;
  $(document).ready(function () {
   editor_initialize_events();

   //Here Find Element id/Class and It's return CKEditor DOM Element ||
    var _byId= CKEDITOR.document.find('#I1');
    var _byClass= CKEDITOR.document.findOne('.myClass');
   // You can find element by Global varibale
    var _byId= GlobalEditor.document.find('#I1');
   // JQuery
   var el = $(GlobalEditor.document.getById('2').$);
 });
 function editor_initialize_events() {
    GlobalEditor = CKEDITOR.replace('maineditor', {
       customConfig: DOMAIN_ROOT + "ckeditor/config6.js",
       startupFocus: true
     });
}


text:
Q: Is there a way to avoid Swift retain/release for high performance code? I wanted to write a Swift version of the classic cache data structure that uses a array up until a certain configurable limit, then switches to a map[2].
Unfortunately the performance characteristics I get when writing even simpler data structure makes me think that this is not doable in swift at the moment.
Consider this piece of code :
import Foundation

let aKey = 196
var cache: [(Int, String)] = []

for _ in 0..<1_000_000_000
{
    var t: String?
    for (k, v) in cache
    {
        if k == aKey
        {
            t = v
            break
        }
    }

    if t == nil
    {
        let str = "some cache value with key=\(aKey)"
        cache.append((aKey, str))
        t = str
    }
}

This takes around 0.785s to execute.
This other program, which should be roughly equivalent :
import Foundation

struct DummyCache<K:Hashable, V>
{
    var array:[(K, V?)] = []

    subscript(index: K) -> V?
    {
        get
        {
            for (k, v) in array
            {
                if k == index
                {
                    return v
                }
            }

            return nil
        }
        set(newValue)
        {
            array.append((index, newValue))
        }
    }
}

let aKey = 196
var cache: DummyCache<Int, String> = DummyCache()
cache[aKey] = "some cache value with key=\(aKey)"

for _ in 0..<1_000_000_000
{
    var t: String? = cache[aKey]
}

Is in fact 45x slower! (around 35.532s)
When profiling this code, I can see that most of the time is spent in the swift runtime :

Is there a way to improve the performance of this ?

[2] For the record, here is the data structure I had in mind :
import Foundation

struct Cache<K:Hashable, V>
{
    let limit: Int
    var array:[(K, V)]? = nil
    var map: [K:V]? = nil
    let buildValueFromKey: (K) -> V

    init(limit: Int = 20, buildValueFromKey:@escaping (K) -> V) //optimal limit depends, must conduct tests to find optimal value
    {
        self.limit = limit
        self.buildValueFromKey = buildValueFromKey
    }

    subscript(index: K) -> V
    {
        mutating get
        {
            if var map = map
            {
                if let res = map[index]
                {
                    return res
                }
                else
                {
                    let res = buildValueFromKey(index)
                    map[index] = res
                    return res
                }
            }
            else //array mode
            {
                if array == nil
                {
                    let res = buildValueFromKey(index)
                    array = [(index, res)]
                    return res
                }
                //else

                for (k, v) in array! //can't be null at that point
                {
                    if k == index
                    {
                        return v
                    }
                }

                // array does not contain index at this point, create & append it
                let res = buildValueFromKey(index)
                array!.append((index, res))
                return res
            }
        }
    }
}

let aKey = 196
var cache: Cache<Int, String> = Cache{ "some cache value with key=\($0)" }

for _ in 0..<1_000_000_000
{
    var t: String? = cache[aKey]
}

A: So good question and still no answer. I haven't profiled your code, but have some possible solution. In case you experience performance drops with array of objects (not of structs/POTs), take a looks at ContiguousArray - it was invented especially to eliminate retains/releases moving to block-based allocations.
Here is official docs: https://developer.apple.com/documentation/swift/contiguousarray
And more tips for inspiration: https://github.com/apple/swift/blob/main/docs/OptimizationTips.rst


text:
Q: Repairs during raids - What are my options? Is there any other way to have repairs in raid besides Jeeves or Reins of the Traveler's Tundra Mammoth?
Are my only repair options for raids:

*

*Jeeves

*Reins of the Traveler's Tundra Mammoth

*Hearthstone, repair, port back in via warlock summons?

What options do I have besides these 3 things?
Note: I am not talking about LFR. I'm talking about N, H, and M raiding

A: In addition to the ones you mentioned (and mage portal mentioned in comments), here are your other two options, both made with Engineering:
Field-Repair-Bot-74a
Field-Repair-Bot-110g
Note of course that the mount is only available in "outside" environments. These two repair bots also share a cooldown, according to Wowhead.


text:
Q: Browser detection in JavaScript? How do I determine the exact browser and version using JavaScript?

A: I recommend using the tiny javascript library Bowser. It is based on the navigator.userAgent and quite well tested for all browsers including iphone, android etc.
https://github.com/ded/bowser
You can use simply say:
if (bowser.msie && bowser.version <= 6) {
  alert('Hello IE');
} else if (bowser.firefox){
  alert('Hello Foxy');
} else if (bowser.chrome){
  alert('Hello Chrome');
} else if (bowser.safari){
  alert('Hello Safari');
} else if(bowser.iphone || bowser.android){
  alert('Hello mobile');
}

A: All the information about web browser is contained in navigator object. The name and version are there.
var appname = window.navigator.appName;

Source: javascript browser detection

A: //Copy and paste this into your code/text editor, and try it

//Before you use this to fix compatability bugs, it's best to try inform the browser provider that you have found a bug and there latest browser may not be up to date with the current web standards

//Since none of the browsers use the browser identification system properly you need to do something a bit like this

//Write browser identification
document.write(navigator.userAgent + "
")

//Detect browser and write the corresponding name
if (navigator.userAgent.search("MSIE") >= 0){
    document.write('"MS Internet Explorer ');
    var position = navigator.userAgent.search("MSIE") + 5;
    var end = navigator.userAgent.search("; Windows");
    var version = navigator.userAgent.substring(position,end);
    document.write(version + '"');
}
else if (navigator.userAgent.search("Chrome") >= 0){
document.write('"Google Chrome ');// For some reason in the browser identification Chrome contains the word "Safari" so when detecting for Safari you need to include Not Chrome
    var position = navigator.userAgent.search("Chrome") + 7;
    var end = navigator.userAgent.search(" Safari");
    var version = navigator.userAgent.substring(position,end);
    document.write(version + '"');
}
else if (navigator.userAgent.search("Firefox") >= 0){
    document.write('"Mozilla Firefox ');
    var position = navigator.userAgent.search("Firefox") + 8;
    var version = navigator.userAgent.substring(position);
    document.write(version + '"');
}
else if (navigator.userAgent.search("Safari") >= 0 && navigator.userAgent.search("Chrome") < 0){//<< Here
    document.write('"Apple Safari ');
    var position = navigator.userAgent.search("Version") + 8;
    var end = navigator.userAgent.search(" Safari");
    var version = navigator.userAgent.substring(position,end);
    document.write(version + '"');
}
else if (navigator.userAgent.search("Opera") >= 0){
    document.write('"Opera ');
    var position = navigator.userAgent.search("Version") + 8;
    var version = navigator.userAgent.substring(position);
    document.write(version + '"');
}
else{
    document.write('"Other"');
}

//Use w3schools research the `search()` method as other methods are availible

A: Since Internet Explorer 11 (IE11+) came out and is not using the tag name of MSIE anymore I came up with a variance of an older detection function:
navigator.sayswho= (function(){
    var N= navigator.appName, ua= navigator.userAgent, tem;

    // if IE11+
    if (new RegExp("Trident/.*rv:([0-9]{1,}[\.0-9]{0,})").exec(ua) !== null) {
        var M= ["Internet Explorer"];
        if(M && (tem= ua.match(/rv:([0-9]{1,}[\.0-9]{0,})/))!= null) M[2]= tem[1];
        M= M? [M[0], M[2]]: [N, navigator.appVersion,'-?'];
        return M;
    }

    var M= ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
    if(M && (tem= ua.match(/version\/([\.\d]+)/i))!= null) M[2]= tem[1];
    M= M? [M[1], M[2]]: [N, navigator.appVersion,'-?'];
    return M;
})();

A: Sadly, IE11 no longer has MSIE in its navigator.userAgent:
Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; OfficeLiveConnector.1.5; OfficeLivePatch.1.3; .NET4.0C; BRI/2; BOIE9;ENUS; rv:11.0) like Gecko

As to why you want to know which browser you're using, it's because every browser has its own set of bugs, and you end up implementing browser and version specific workarounds, or tell the user to use a different browser!

A: var browser = navigator.appName;
var version = navigator.appVersion;

Note, however, that both will not necessarily reflect the truth. Many browsers can be set to mask as other browsers. So, for example, you can't always be sure if a user is actually surfing with IE6 or with Opera that pretends to be IE6.

A:

navigator.saysWho = (() => {
  const { userAgent } = navigator
  let match = userAgent.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []
  let temp

  if (/trident/i.test(match[1])) {
    temp = /\brv[ :]+(\d+)/g.exec(userAgent) || []

    return `IE ${temp[1] || ''}`
  }

  if (match[1] === 'Chrome') {
    temp = userAgent.match(/\b(OPR|Edge)\/(\d+)/)

    if (temp !== null) {
      return temp.slice(1).join(' ').replace('OPR', 'Opera')
    }

    temp = userAgent.match(/\b(Edg)\/(\d+)/)

    if (temp !== null) {
      return temp.slice(1).join(' ').replace('Edg', 'Edge (Chromium)')
    }
  }

  match = match[2] ? [ match[1], match[2] ] : [ navigator.appName, navigator.appVersion, '-?' ]
  temp = userAgent.match(/version\/(\d+)/i)

  if (temp !== null) {
    match.splice(1, 1, temp[1])
  }

  return match.join(' ')
})()

console.log(navigator.saysWho) // outputs: `Chrome 89`

As the name implies, this will tell you the  name and version number supplied by the browser.
It is handy for sorting test and error results, when you are testing new code on multiple browsers.

A: This is something I wrote to get client info
var ua = navigator.userAgent.toLowerCase();
var check = function(r) {
    return r.test(ua);
};
var DOC = document;
var isStrict = DOC.compatMode == "CSS1Compat";
var isOpera = check(/opera/);
var isChrome = check(/chrome/);
var isWebKit = check(/webkit/);
var isSafari = !isChrome && check(/safari/);
var isSafari2 = isSafari && check(/applewebkit\/4/); // unique to
// Safari 2
var isSafari3 = isSafari && check(/version\/3/);
var isSafari4 = isSafari && check(/version\/4/);
var isIE = !isOpera && check(/msie/);
var isIE7 = isIE && check(/msie 7/);
var isIE8 = isIE && check(/msie 8/);
var isIE6 = isIE && !isIE7 && !isIE8;
var isGecko = !isWebKit && check(/gecko/);
var isGecko2 = isGecko && check(/rv:1\.8/);
var isGecko3 = isGecko && check(/rv:1\.9/);
var isBorderBox = isIE && !isStrict;
var isWindows = check(/windows|win32/);
var isMac = check(/macintosh|mac os x/);
var isAir = check(/adobeair/);
var isLinux = check(/linux/);
var isSecure = /^https/i.test(window.location.protocol);
var isIE7InIE8 = isIE7 && DOC.documentMode == 7;

var jsType = '', browserType = '', browserVersion = '', osName = '';
var ua = navigator.userAgent.toLowerCase();
var check = function(r) {
    return r.test(ua);
};

if(isWindows){
    osName = 'Windows';

    if(check(/windows nt/)){
        var start = ua.indexOf('windows nt');
        var end = ua.indexOf(';', start);
        osName = ua.substring(start, end);
    }
} else {
    osName = isMac ? 'Mac' : isLinux ? 'Linux' : 'Other';
}

if(isIE){
    browserType = 'IE';
    jsType = 'IE';

    var versionStart = ua.indexOf('msie') + 5;
    var versionEnd = ua.indexOf(';', versionStart);
    browserVersion = ua.substring(versionStart, versionEnd);

    jsType = isIE6 ? 'IE6' : isIE7 ? 'IE7' : isIE8 ? 'IE8' : 'IE';
} else if (isGecko){
    var isFF =  check(/firefox/);
    browserType = isFF ? 'Firefox' : 'Others';;
    jsType = isGecko2 ? 'Gecko2' : isGecko3 ? 'Gecko3' : 'Gecko';

    if(isFF){
        var versionStart = ua.indexOf('firefox') + 8;
        var versionEnd = ua.indexOf(' ', versionStart);
        if(versionEnd == -1){
            versionEnd = ua.length;
        }
        browserVersion = ua.substring(versionStart, versionEnd);
    }
} else if(isChrome){
    browserType = 'Chrome';
    jsType = isWebKit ? 'Web Kit' : 'Other';

    var versionStart = ua.indexOf('chrome') + 7;
    var versionEnd = ua.indexOf(' ', versionStart);
    browserVersion = ua.substring(versionStart, versionEnd);
}else{
    browserType = isOpera ? 'Opera' : isSafari ? 'Safari' : '';
}

A: This little library may help you. But be aware that browser detection is not always the solution.

A: Here is how I do custom CSS for Internet Explorer:
In my JavaScript file:
function isIE () {
      var myNav = navigator.userAgent.toLowerCase();
      return (myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : false;
}

jQuery(document).ready(function(){
    if(var_isIE){
            if(var_isIE == 10){
                jQuery("html").addClass("ie10");
            }
            if(var_isIE == 8){
                jQuery("html").addClass("ie8");
                // you can also call here some function to disable things that
                //are not supported in IE, or override browser default styles.
            }
        }
    });

And then in my CSS file, y define each different style:
.ie10 .some-class span{
    .......
}
.ie8 .some-class span{
    .......
}

A: If you want a function that returns the browser as well as the version, here is an improvement from the original answer:
navigator.browserInfo =
(
    function()
    {
        var browser = '';
        var version = '';
        var idString = '';

        var ua = navigator.userAgent;
        var tem = [];
        var M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i);

        //IE will be identified as 'Trident' and a different version number. The name must be corrected to 'Internet Explorer' and the correct version identified.
        //ie correction
        if(/trident/i.test(M[1]))
        {
            tem = /\brv[ :]+(\d+.?\d*)/g.exec(ua) || [];
            browser = 'Internet Explorer';
            version = tem[1];
        }

        //firefox
        else if(/firefox/i.test(M[1]))
        {
            tem = /\brv[ :]+(\d+.?\d*)/g.exec(ua) || [];
            browser = 'Firefox';
            version = tem[1];
        }

        //safari
        else if(/safari/i.test(M[1]))
        {
            tem = ua.match(/\bVersion\/(\d+.?\d*\s*\w+)/);
            browser = 'Safari';
            version = tem[1];
        }

        //If 'Chrome' is found, it may be another browser.
        else if(M[1] === 'Chrome')
        {
            //opera
            var temOpr = ua.match(/\b(OPR)\/(\d+.?\d*.?\d*.?\d*)/);
            //edge
            var temEdge = ua.match(/\b(Edge)\/(\d+.?\d*)/);
            //chrome
            var temChrome = ua.match(/\b(Chrome)\/(\d+.?\d*.?\d*.?\d*)/);

            //a genuine 'Chrome' reading will result from ONLY temChrome not being null.
            var genuineChrome = temOpr == null && temEdge == null && temChrome != null;

            if(temOpr != null)
            {
                browser = temOpr[1].replace('OPR', 'Opera');
                version = temOpr[2];
            }

            if(temEdge != null)
            {
                browser = temEdge[1];
                version = temEdge[2];
            }

            if(genuineChrome)
            {
                browser = temChrome[1];
                version = temChrome[2];
            }
        }
        //There will be some odd balls, so if you wish to support those browsers, add functionality to display those browsers as well.

        if(browser == '' || version == '')
        {
            idString = 'We couldn\'t find your browser, but you can still use the site';
        }
        else
        {
            idString = browser + ' version ' + version;
        }

        alert('Your browser is ' + idString);

        //store the type of browser locally
        if(typeof(Storage) !== "undefined")
        {
            //Store
            localStorage.setItem('browser', browser);
            localStorage.setItem('version', version);
        }
        else
        {
            alert('local storage not available');
        }
    }
)();

With this, it also stores the result locally, so this check is not necessary to run every time.

A: Instead of hardcoding web browsers, you can scan the user agent to find the browser name:
navigator.userAgent.split(')').reverse()[0].match(/(?!Gecko|Version|[A-Za-z]+?Web[Kk]it)[A-Z][a-z]+/g)[0]

I've tested this on Safari, Chrome, and Firefox. Let me know if you found this doesn't work on a browser.

*

*Safari: "Safari"

*Chrome: "Chrome"

*Firefox: "Firefox"
You can even modify this to get the browser version if you want. Do note there are better ways to get the browser version
navigator.userAgent.split(')').reverse()[0].match(/(?!Gecko|Version|[A-Za-z]+?Web[Kk]it)[A-Z][a-z]+\/[\d.]+/g)[0].split('/')

Sample output:
Firefox/39.0

A: Here's how to detect browsers in 2016, including Microsoft Edge, Safari 10 and detection of Blink:
// Opera 8.0+ (UA detection to detect Blink/v8-powered Opera)
isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Firefox 1.0+
isFirefox = typeof InstallTrigger !== 'undefined';
// Safari 3.0+
isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || safari.pushNotification);
// Internet Explorer 6-11
isIE = /*@cc_on!@*/false || !!document.documentMode;
// Edge 20+
isEdge = !isIE && !!window.StyleMedia;
// Chrome 1+
isChrome = !!window.chrome && !!window.chrome.webstore;
// Blink engine detection
isBlink = (isChrome || isOpera) && !!window.CSS;

The beauty of this approach is that it relies on browser engine properties, so it covers even derivative browsers, such as Yandex or Vivaldi, which are practically compatible with the major browsers whose engines they use. The exception is Opera, which relies on user agent sniffing, but today (i.e. ver. 15 and up) even Opera is itself only a shell for Blink.

A: This is what I'm using:
var ua = navigator.userAgent;
var info = {
        browser: /Edge\/\d+/.test(ua) ? 'ed' : /MSIE 9/.test(ua) ? 'ie9' : /MSIE 10/.test(ua) ? 'ie10' : /MSIE 11/.test(ua) ? 'ie11' : /MSIE\s\d/.test(ua) ? 'ie?' : /rv\:11/.test(ua) ? 'ie11' : /Firefox\W\d/.test(ua) ? 'ff' : /Chrom(e|ium)\W\d|CriOS\W\d/.test(ua) ? 'gc' : /\bSafari\W\d/.test(ua) ? 'sa' : /\bOpera\W\d/.test(ua) ? 'op' : /\bOPR\W\d/i.test(ua) ? 'op' : typeof MSPointerEvent !== 'undefined' ? 'ie?' : '',
        os: /Windows NT 10/.test(ua) ? "win10" : /Windows NT 6\.0/.test(ua) ? "winvista" : /Windows NT 6\.1/.test(ua) ? "win7" : /Windows NT 6\.\d/.test(ua) ? "win8" : /Windows NT 5\.1/.test(ua) ? "winxp" : /Windows NT [1-5]\./.test(ua) ? "winnt" : /Mac/.test(ua) ? "mac" : /Linux/.test(ua) ? "linux" : /X11/.test(ua) ? "nix" : "",
        touch: 'ontouchstart' in document.documentElement,
        mobile: /IEMobile|Windows Phone|Lumia/i.test(ua) ? 'w' : /iPhone|iP[oa]d/.test(ua) ? 'i' : /Android/.test(ua) ? 'a' : /BlackBerry|PlayBook|BB10/.test(ua) ? 'b' : /Mobile Safari/.test(ua) ? 's' : /webOS|Mobile|Tablet|Opera Mini|\bCrMo\/|Opera Mobi/i.test(ua) ? 1 : 0,
        tablet: /Tablet|iPad/i.test(ua),
};

info properties:

*

*browser: gc for Google Chrome; ie9-ie11 for IE; ie? for old or unknown IE; ed for Edge; ff for Firefox; sa for Safari; op for Opera.

*os: mac win7 win8 win10 winnt winxp winvista linux nix

*mobile: a for Android; i for iOS (iPhone iPad); w for Windows Phone; b for Blackberry; s for undetected mobile running Safari; 1 for other undetected mobile; 0 for non-mobile

*touch: true for touch enabled devices, including touch laptops/notebooks that has both mouse and touch together; false for no touch support

*tablet: true or false
https://jsfiddle.net/oriadam/ncb4n882/

A: It is usually best to avoid browser-specific code where possible. The JQuery $.support property is available for detection of support for particular features rather than relying on browser name and version.
In Opera for example, you can fake an internet explorer or firefox instance.

A detailed description of JQuery.support can be found here: http://api.jquery.com/jQuery.support/
Now deprecated according to jQuery.

We strongly recommend the use of an external library such as Modernizr
  instead of dependency on properties in jQuery.support.

When coding websites, I always make sure, that basic functionality like navigation is also accessible to non-js users. This may be object to discussion and can be ignored if the homepage is targeted to a special audience.

A: This tells you all the details about your browser and the version of it.
<!DOCTYPE html>

A: You could use the jQuery library to detect the browser version.
Example:
jQuery.browser.version
However, this only makes sense if you are also using other functions of jQuery. Adding an entire library just to detect the browser seems like overkill to me.
More information:
http://api.jquery.com/jQuery.browser/
(you have to scroll down a bit)

A:  var isOpera = !!window.opera || navigator.userAgent.indexOf('Opera') >= 0;
        // Opera 8.0+ (UA detection to detect Blink/v8-powered Opera)
        var isFirefox = typeof InstallTrigger !== 'undefined';   // Firefox 1.0+
        var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
        // At least Safari 3+: "[object HTMLElementConstructor]"
        var isChrome = !!window.chrome;                          // Chrome 1+
        var isIE = /*@cc_on!@*/false;

you can more read
How to detect Safari, Chrome, IE, Firefox and Opera browser?

A: I know I'm WAY late to this question, but figured I'd throw my snippets up here. A lot of the answers here are OK, and, as one points out, it's generally best to use feature detection rather than rely on the userAgent string. However, if you are going to go that route, I've written a complete snippet, as well as an alternate jQuery implementation to replace the depricated $.browser.

Vanilla JS
My first snippet simply adds four properties to the navigator object: browser, version, mobile, & webkit.
jsFiddle

*

*GitHub

*min

/** navigator [extended]
 *  Simply extends Browsers navigator Object to include browser name, version number, and mobile type (if available).
 *
 *  @property {String} browser The name of the browser.
 *  @property {Double} version The current Browser version number.
 *  @property {String|Boolean} mobile Will be `false` if is not found to be mobile device. Else, will be best guess Name of Mobile Device (not to be confused with browser name)
 *  @property {Boolean} webkit If is webkit or not.
 */
;(function(){function c(){try{switch(!0){case /MSIE|Trident/i.test(navigator.userAgent):return"MSIE";case /Chrome/.test(navigator.userAgent):return"Chrome";case /Opera/.test(navigator.userAgent):return"Opera";case /Kindle|Silk|KFTT|KFOT|KFJWA|KFJWI|KFSOWI|KFTHWA|KFTHWI|KFAPWA|KFAPWI/i.test(navigator.userAgent):return/Silk/i.test(navigator.userAgent)?"Silk":"Kindle";case /BlackBerry/.test(navigator.userAgent):return"BlackBerry";case /PlayBook/.test(navigator.userAgent):return"PlayBook";case /BB[0-9]{1,}; Touch/.test(navigator.userAgent):return"Blackberry";
case /Android/.test(navigator.userAgent):return"Android";case /Safari/.test(navigator.userAgent):return"Safari";case /Firefox/.test(navigator.userAgent):return"Mozilla";case /Nokia/.test(navigator.userAgent):return"Nokia"}}catch(a){console.debug("ERROR:setBrowser\t",a)}}function d(){try{switch(!0){case /Sony[^ ]*/i.test(navigator.userAgent):return"Sony";case /RIM Tablet/i.test(navigator.userAgent):return"RIM Tablet";case /BlackBerry/i.test(navigator.userAgent):return"BlackBerry";case /iPhone/i.test(navigator.userAgent):return"iPhone";
case /iPad/i.test(navigator.userAgent):return"iPad";case /iPod/i.test(navigator.userAgent):return"iPod";case /Opera Mini/i.test(navigator.userAgent):return"Opera Mini";case /IEMobile/i.test(navigator.userAgent):return"IEMobile";case /BB[0-9]{1,}; Touch/i.test(navigator.userAgent):return"BlackBerry";case /Nokia/i.test(navigator.userAgent):return"Nokia";case /Android/i.test(navigator.userAgent):return"Android"}}catch(a){console.debug("ERROR:setMobile\t",a)}return!1}function e(){try{switch(!0){case /MSIE|Trident/i.test(navigator.userAgent):return/Trident/i.test(navigator.userAgent)&&
/rv:([0-9]{1,}[\.0-9]{0,})/.test(navigator.userAgent)?parseFloat(navigator.userAgent.match(/rv:([0-9]{1,}[\.0-9]{0,})/)[1].replace(/[^0-9\.]/g,"")):/MSIE/i.test(navigator.userAgent)&&0<parseFloat(navigator.userAgent.split("MSIE")[1].replace(/[^0-9\.]/g,""))?parseFloat(navigator.userAgent.split("MSIE")[1].replace(/[^0-9\.]/g,"")):"Edge";case /Chrome/.test(navigator.userAgent):return parseFloat(navigator.userAgent.split("Chrome/")[1].split("Safari")[0].replace(/[^0-9\.]/g,""));case /Opera/.test(navigator.userAgent):return parseFloat(navigator.userAgent.split("Version/")[1].replace(/[^0-9\.]/g,
""));case /Kindle|Silk|KFTT|KFOT|KFJWA|KFJWI|KFSOWI|KFTHWA|KFTHWI|KFAPWA|KFAPWI/i.test(navigator.userAgent):if(/Silk/i.test(navigator.userAgent))return parseFloat(navigator.userAgent.split("Silk/")[1].split("Safari")[0].replace(/[^0-9\.]/g,""));if(/Kindle/i.test(navigator.userAgent)&&/Version/i.test(navigator.userAgent))return parseFloat(navigator.userAgent.split("Version/")[1].split("Safari")[0].replace(/[^0-9\.]/g,""));case /BlackBerry/.test(navigator.userAgent):return parseFloat(navigator.userAgent.split("/")[1].replace(/[^0-9\.]/g,
""));case /PlayBook/.test(navigator.userAgent):case /BB[0-9]{1,}; Touch/.test(navigator.userAgent):case /Safari/.test(navigator.userAgent):return parseFloat(navigator.userAgent.split("Version/")[1].split("Safari")[0].replace(/[^0-9\.]/g,""));case /Firefox/.test(navigator.userAgent):return parseFloat(navigator.userAgent.split(/Firefox\//i)[1].replace(/[^0-9\.]/g,""));case /Android/.test(navigator.userAgent):return parseFloat(navigator.userAgent.split("Version/")[1].split("Safari")[0].replace(/[^0-9\.]/g,
""));case /Nokia/.test(navigator.userAgent):return parseFloat(navigator.userAgent.split("Browser")[1].replace(/[^0-9\.]/g,""))}}catch(a){console.debug("ERROR:setVersion\t",a)}}a:{try{if(navigator&&navigator.userAgent){navigator.browser=c();navigator.mobile=d();navigator.version=e();var b;b:{try{b=/WebKit/i.test(navigator.userAgent);break b}catch(a){console.debug("ERROR:setWebkit\t",a)}b=void 0}navigator.webkit=b;break a}}catch(a){}throw Error("Browser does not support `navigator` Object |OR| has undefined `userAgent` property.");
}})();
/*  simple c & p of above   */

A: var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
    // Opera 8.0+ (UA detection to detect Blink/v8-powered Opera)
var isFirefox = typeof InstallTrigger !== 'undefined';   // Firefox 1.0+
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
    // At least Safari 3+: "[object HTMLElementConstructor]"
var isChrome = !!window.chrome && !isOpera;              // Chrome 1+
var isIE = /*@cc_on!@*/false || !!document.documentMode;
// Edge 20+
var isEdge = !isIE && !!window.StyleMedia;
// Chrome 1+
var output = 'Detecting browsers by ducktyping:
';
output += 'isFirefox: ' + isFirefox + '
';
output += 'isChrome: ' + isChrome + '
';
output += 'isSafari: ' + isSafari + '
';
output += 'isOpera: ' + isOpera + '
';
output += 'isIE: ' + isIE + '
';
output += 'isIE Edge: ' + isEdge + '
';
document.body.innerHTML = output;

A: Not exactly what you want, but close to it:
var jscriptVersion = /*@cc_on @if(@_jscript) @_jscript_version @else @*/ false /*@end @*/;
var geckoVersion = navigator.product === 'Gecko' && navigator.productSub;
var operaVersion = 'opera' in window && 'version' in opera && opera.version();

The variables will contain the appropriate version or false if it is not available.
I'd appreciate it if someone using Chrome could find out if you can use window.chrome in a similar way to window.opera.

A: I found something interesting and quicker way.
IE supports navigator.systemLanguage which returns "en-US" where other browsers return undefined.

A: Some times we need simple method to check if the browser is IE or not. This is how it could be:
 var isMSIE = (/trident/i).test(navigator.userAgent);

 if(isMSIE)
 {
  /* do something for ie */
 }
 else
 {
  /* do something else */
 }

or simplified siva's method:
 if(!!navigator.systemLanguage)
 {
  /* do something for ie */
 }
 else
 {
  /* do something else */
 }

MSIE v.11 check:
if( (/trident/i).test(navigator.userAgent) && (/rv:/i).test(navigator.userAgent) )
{
  /* do something for ie 11 */
}

other IE browsers contain MSIE string in their userAgent property and could be catched by it.

A: I make this small function, hope it helps. Here you can find the latest version
browserDetection
function detectBrowser(userAgent){
  var chrome  = /.*(Chrome\/).*(Safari\/).*/g;
  var firefox = /.*(Firefox\/).*/g;
  var safari  = /.*(Version\/).*(Safari\/).*/g;
  var opera   = /.*(Chrome\/).*(Safari\/).*(OPR\/).*/g

  if(opera.exec(userAgent))
    return "Opera"
  if(chrome.exec(userAgent))
    return "Chrome"
  if(safari.exec(userAgent))
    return "Safari"
  if(firefox.exec(userAgent))
    return "Firefox"
}

A: Below code snippet will show how how you can show UI elemnts depends on IE version and browser
$(document).ready(function () {

var msiVersion = GetMSIieversion();
if ((msiVersion <= 8) && (msiVersion != false)) {

    //Show UI elements specific to IE version 8 or low

    } else {
    //Show UI elements specific to IE version greater than 8 and for other browser other than IE,,ie..Chrome,Mozila..etc
    }
}
);

Below code will give how we can get IE version
function GetMSIieversion() {

var ua = window.navigator.userAgent;
var msie = ua.indexOf('MSIE ');
if (msie > 0) {
    // IE 10 or older => return version number
    return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
}

var trident = ua.indexOf('Trident/');
if (trident > 0) {
    // IE 11 => return version number
    var rv = ua.indexOf('rv:');
    return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
}

var edge = ua.indexOf('Edge/');
if (edge > 0) {
    // Edge (IE 12+) => return version number
    return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
}

// other browser like Chrome,Mozila..etc
return false;

}


text:
Q: Do photonic creation (anihilation) operators $a^\dagger$ ($a$) taken at different times commute? This question was spawned from a discussion with my supervisor on the nature of the second-order correlation function
\begin{align}
G^{(2)} (t_1,t_2) &= <\Psi| E^-(t_1) E^-(t_2)  E^+(t_2) E^+(t_1)|\Psi>, \tag{1}
\end{align}
with
\begin{align}
E^+(t) = (E^-(t))^\dagger \propto \int^\infty_{-\infty} d\omega \, a_\omega e^{-i\omega t}
\end{align}
being the positive (negative) frequency parts of the electric field operator
\begin{align}
E(t) = E^+(t)+E^-(t).
\end{align}
The question now is, if (and when) the operators within $G^{(2)}$ commute. That is, do the Heisenberg picture representations of the photonic creation (anihilation) operators $a^\dagger_\omega(t) =  a_\omega^\dagger e^{+i\omega t}$ ($a_\omega(t) =  a_\omega e^{-i\omega t} $) in a single mode (labeled by its angular frequency $\omega$) commute at different times.
My take was that for all times $t$ we can see that the time dependence of $a$ is simply a c-number and we find
\begin{align}
[a_\omega(t),a_\omega^\dagger(t+\Delta t)] = [a_\omega,a^\dagger_\omega] e^{i\omega\Delta t} = e^{i\omega\Delta t}.\tag{2}
\end{align}
However, he claimed that at different times we could consider the operators to refer to different temporal modes and that they thus commuted.
(I am somewhat unfamiliar with the concept of temporal modes,but understand that for well localized wave packets we can at some point neglect interaction between them which would be reflected by a commutation of their creation and anihilation operators. Still in my understanding the time dependence here is fundamentally different from modes in frequency, because it enters as a consequence of the photons being solutions to a real physical differential equation that has a certain time behaviour.)
He thus wanted to show that
\begin{align}
G^{(2)}\propto <\Psi| n(t_2)n(t_1)|\Psi>, \tag{3}
\end{align} and that it thus represents "the probability [density] to find a photon at time $t_1$ and a photon at time $t_2$" in the context of the two-photon state in question.
I am assuming this is correct in some cases and am looking for an understanding of what kind of light allows for this picture. We were talking about interference experiments with two-photon states from an SPDC source.
I also am unsure if I am missing the point by not regarding the finite time-resolution of a real detector.

A: $a_ω$s for different ωs commute, but not for the same ω, which you exploited already, in a somewhat freaky bypass of plain Fourier transforming.
Your teacher almost certainly had you evaluate
$$
[E^+(t),E^-(\tau)]\propto \int\!\! d\omega d\omega' ~ [a_\omega, a_{\omega'}^\dagger ]~ e^{-i\omega t +i \omega' \tau}\\
\propto \int d\omega  ~    e^{-i\omega (t- \tau)} \propto \delta (t- \tau)~.
$$


text:
Q: Order failure in PayPal integration I am doing PayPal integration in my project. Everything is working, but at the end, the payment success method is not generated. My code for payment success is:
else if ([response isKindOfClass:[DoExpressCheckoutPaymentResponseDetails class]]) {
    DoExpressCheckoutPaymentResponseDetails *dres = (DoExpressCheckoutPaymentResponseDetails *)response;
    if (dres.PaymentInfo.count > 0 && ((PaymentInfo *)[dres.PaymentInfo objectAtIndex:0]).TransactionID.length > 0)
    {
        [self paymentSuccess:((PaymentInfo *)[dres.PaymentInfo objectAtIndex:0]).TransactionID];
    }
    else
    {
        NSLog(@"Error came");
        [self paymentFailed];
    }
}

and the payment success method is...
UINavigationController *navController = self.navigationController;

orderResultsViewController.forDelivery = ((ReviewOrderViewController *)[navController.viewControllers objectAtIndex:navController.viewControllers.count - 2]).forDelivery;
orderResultsViewController.transactionID = transactionID;
[navController popViewControllerAnimated:FALSE];
[navController setNavigationBarHidden:FALSE animated:TRUE];
[navController pushViewController:orderResultsViewController animated:TRUE];

If you got it then point me in some direction to go...
-(void)paymentFailed {
    [self.navigationController popViewControllerAnimated:TRUE];
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Order failed"
                                                    message:@"Your order failed. Touch \"Pay with PayPal\" to try again."
                                                   delegate:nil
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil];
    [alert show];
    [alert release];
}

I am getting above alert view and payment order failed....