text:
Q: Clustered database timers in WildFly Applying the following configuration in standalone-full-ha.xml.
<timer-service thread-pool-name="timer" default-data-store="clustered-store">
    <data-stores>
        <database-data-store name="clustered-store"
                             datasource-jndi-name="java:jboss/datasources/projectXADatasource"
                             database="mysql"
                             partition="timer"/>
    </data-stores>
</timer-service>

The XA datasource located at java:jboss/datasources/projectXADatasource already works fine.
The application does not get deployed. The deployment process fails with the following error.
ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 2) WFLYCTL0013: Operation ("deploy") failed
- address: ([("deployment" => "WildFly.ear")])
- failure description: {"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.deployment.subunit.\"WildFly.ear\".\"WildFly-ejb.jar\".component.BackgroundJobManager.ejb3.timerService is missing [jboss.thread.executor.ejb3.timer]"]}

Applying the same configuration to non-clustered environment (standalone-full.xml) also fails with the same error.

The only thing I have changed is the DDL statement from
create-table.mysql=CREATE TABLE JBOSS_EJB_TIMER (ID VARCHAR(255) PRIMARY KEY NOT NULL...

to
create-table.mysql=CREATE TABLE JBOSS_EJB_TIMER (ID VARCHAR(191) PRIMARY KEY NOT NULL...

available under ${Home}/modules/system/layers/base/org/jboss/as/ejb3/main/timers/timer-sql.properties
Because MySQL is configured to use the utf8mb4 character set which VARCHAR(255) exceeds for a primary key (767 bytes).
The JDBC driver gives the following error even after this change.
21:07:07,750 ERROR [org.jboss.as.ejb3] (MSC service thread 1-7) WFLYEJB0163: Cannot create table for timer persistence: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Specified key was too long; max key length is 767 bytes
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
    at com.mysql.jdbc.Util.getInstance(Util.java:387)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:941)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3870)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3806)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2470)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2617)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2546)
    at com.mysql.jdbc.StatementImpl.executeUpdateInternal(StatementImpl.java:1541)
    at com.mysql.jdbc.StatementImpl.executeLargeUpdate(StatementImpl.java:2605)
    at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1469)
    at com.mysql.jdbc.jdbc2.optional.StatementWrapper.executeUpdate(StatementWrapper.java:749)
    at org.jboss.jca.adapters.jdbc.WrappedStatement.executeUpdate(WrappedStatement.java:414)
    at org.jboss.as.ejb3.timerservice.persistence.database.DatabaseTimerPersistence.checkDatabase(DatabaseTimerPersistence.java:286)
    at org.jboss.as.ejb3.timerservice.persistence.database.DatabaseTimerPersistence.start(DatabaseTimerPersistence.java:160)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

But I do not think this is relevant to the root problem. The table is created even after this error.

How to fix this error?
component.BackgroundJobManager.ejb3.timerService is missing [jboss.thread.executor.ejb3.timer]

Where BackgroundJobManager is a singleton EJB having a persistent timer in it. The timer is persisted correctly in the file system (default) but it fails to persist to the database.
I am on WildFly 9.0.2 final.

A: Currently, I am going with the default thread-pool as follows.
<timer-service thread-pool-name="default" default-data-store="clustered-store">
    <data-stores>
        <database-data-store name="clustered-store" datasource-jndi-name="java:jboss/datasources/projectXADatasource" database="mysql" partition="timer"/>
    </data-stores>
</timer-service>

and the default thread-pool in standalone-full-ha.xml is defined as follows.
<thread-pools>
    <thread-pool name="default">
        <max-threads count="10"/>
        <keepalive-time time="100" unit="milliseconds"/>
    </thread-pool>
</thread-pools>

Any other thoughts or suggestions are welcome.


text:
Q: Taking Seats on a Plane: The General Case $n$ men are getting on a plane which contains $n+k$ seats. Each one has a seat number but among them, $m$ men forgot  his seat number. They get on the plane one by one. For person $X$ if he knows his seat number and if the seat is empty then he take it but if the seat if occupied then he chooses randomly a chair and sits. On the other hand if $X$ does not know his seat number them he chooses randomly a chair and sits.  What is the probability that the last $i$ persons sit on their proper seat!? (Those who forgot their seat number are not necessary the first $m$ persons who get on the plane)
COMMENT: Some versions of this problem are posted to SE. You can see the following ones: Number 1, Number 2, Number 3

A: Let us assume that the $i$ first-class passengers wait in their luxury lounge and will sue the company if they do not find their seat empty.
Let us number the people and their places from 1 to $n$. (The numbers of the $k$ extra seats do not matter.) I will also assume that the $i$ last passengers are disjoint from the $m$ forgetful people.
In that case, each of the $m$ people starts a rising chain of displaced persons
among the $n-i$ ordinary passengers. For each pattern of $m$ chains among them, the only thing that interests us what the last persons in the chains do.
There are $\binom{m+i+k}m$ choices for their seats (this includes one forgetful person choosing immediately their own seat), but only $\binom{m+k}m$ choices will make the airline company happy.
So, I get as success probability
$$\dfrac{\binom{m+k}m}{\binom{m+i+k}m} = \dfrac{(m+k)(m+k-1)\dots(k+1)}{(m+i+k)(m+i+k-1)\dots(i+k+1)}.$$

redpajama_set_name: RedPajamaStackExchange


text:
Q: At what distance could you see andromeda with the naked eye? We've all seen the telescope photographs of andromeda galaxy:

I'm wondering if it were possible to travel close enough to the andromeda galaxy could you achieve a same perspective with the naked eye? What distance away from andromeda would give you the same vantage point as the photograph to the point that you could take the same photograph with a regular point and shoot camera?
I assume you would be in intergalactic space between andromeda and the milky way.
On that note, if you were halfway between the two, would you be able to clearly make out both galaxies in their entirety  or would you simply see 2 points of light that more resemble stars than galaxies?

A: Well, First off, you can see  the Andromeda galaxy with your naked eye from a dark place on a clear night.  You should try it if you can.  It looks like a smudge of appreciable size, not like a point.  So half way between the Milky way and Andromeda, both would look like smudges twice as wide as Andromeda does from earth.  I think a standard point and shoot camera is slightly better than the naked eye, but not a whole lot.  The other way to think about it is to consider the power of the lens used to take the picture. Telescopes are usually between 10 and 100 power, although more is possible.  A point and shoot is usually 1-3X I think.  The naked eye is 1X of course. But long exposures "see" much more than the naked eye.  So to get 10X you would need to be 90% of the way to Andromeda so the remaing distance is 1/10th of the way to Andromeda, to get 33X power equivalent, you would need to be 97% of the way to Andromeda, etc.  I am guessing you would see some structure at 10X, particularly with a long exposure from space, but to get the equivalent of the truly excellent pictures you see on the web or in astronomy magazines you might have to go to 33X or even 100X. For 100X you would have to go 99% of the way to Andromeda.  Again, your point and shoot with a long exposure is probably three to ten times better than your naked eye.

A: Andromeda is bigger than the Moon, it's just too dark to see with the naked eye.

Source: http://apod.nasa.gov/apod/ap061228.html


text:
Q: scope of a online examination system in uml that is project outline of the project i am a beginner in this field. I dont know much about uml. I have to submit a project on "online examination system" using "agrouml". So, any one please give me the scope of the project. How to write a scope of a project? any answer will be appreciated.

A: A scope could be defined in text or in the partly Use Case diagram. Define Actors - people, who would work with your system (Admin, Lector, Student, Faculty staff member...) For each of them write down their actions they'll do to your system.
In Use case you'll have stick men for actors and ovals for use cases. Connect actors to their use cases.
Call the diagram Scope Definition, for people not to mix it with the real use case diagram. Which it is not.
The full Use Case Diagram should include also the parts of your system, connected to Use Cases "from the other side". But you will have to do it AFTER scope definition and APART from it, as another diagram.


text:
Q: Dynamic generated markers in leaflet I am trying to display custom markers on a map. The markers are created dynamically with every record that i get through API. The images are hosted elsewhere. However whenever i try to pull up the map with the markers those do not display and only a default marker shows up. I am wondering if i do something wrong with the marker set up:
    var dynamicIcon = [];
    var dIcon = [];
    var weatherMarker = [];
    $.getJSON('http://api.openweathermap.org/data/2.5/box/city?bbox=1.89,49.05,2.86,48.63,10&cluster=yes', function(data)
          {
            var i=0;
            while(i < data.list.length-1)
            {
            dynamicIcon[i] = L.Icon.Default.extend({
                 options:{
                 iconURL:'http://openweathermap.org/img/w/'+data.list[i].weather[0].icon+'.png',
                }
                        });
            dIcon[i] = new dynamicIcon[i]();
            weatherMarker[i] = new L.marker([data.list[i].coord.lat, data.list[i].coord.lon], {icon: dIcon[i]}, {draggable:false});
            map.addLayer(weatherMarker[i]);
          }
         });

A: Apparently i was doing it wrong; like this it works:
       dynamicIcon[i] = new L.Icon({
         iconUrl:'http://openweathermap.org/img/w/'+data.list[i].weather[0].icon+'.png',
       });
       weatherMarker[i] = new L.marker([data.list[i].coord.lat, data.list[i].coord.lon], {
                        icon:dynamicIcon[i] });
       map.addLayer(weatherMarker[i]);


text:
Q: Exception in Release Mode due to ZipFile I'm using a code snippet to access a Zip File containing APK file . It works fine in Debug Mode, but, throws Exception in Release Mode.
 ZipFile zip = new ZipFile(file);
 ZipEntry mft = zip.getEntry("AndroidManifest.xml");
 is = zip.getInputStream(mft);

It doesn't make any issue if released in Debug Mode. But, in Release Mode, app gets crashed.
 W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x418c6c08)
 ************ 29072016 ************
 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vxeed.xnap/com.vxeed.xnap.forms.MainMenu}: java.lang.NullPointerException
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2413)
 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
 at android.app.ActivityThread.access$900(ActivityThread.java:175)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:146)
 at android.app.ActivityThread.main(ActivityThread.java:5602)
 at java.lang.reflect.Method.invokeNative(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:515)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
 at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.NullPointerException
 at com.vxeed.xnap.common.ay.a(Unknown Source)
 at com.vxeed.xnap.forms.MainMenu.onCreate(Unknown Source)
 at android.app.Activity.performCreate(Activity.java:5451)
 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
 at android.app.ActivityThread.access$900(ActivityThread.java:175)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:146)
 at android.app.ActivityThread.main(ActivityThread.java:5602)
 at java.lang.reflect.Method.invokeNative(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:515)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
 at dalvik.system.NativeStart.main(Native Method)

If I get rid of this method, it works fine. Do I need to add anything extra in proguard-rules? Please advise. Thanks in advance


text:
Q: Best approach for HTTPModule Recently created my first httpmodule. It drops and manages a user cookie. This all works fine.
I now need to drop another cookie relating to site affiliates.
The question is, is is better practice to create 2 entirely separate httpmodules or add extra code to the existing one. The reason I ask is because the functionality is closely related (they both drop a cookie).

A: Why not write a Class Library that deals with cookies, then write your HttpModules that use the Cookies Class Library?
I don't believe you should join them, because they set cookies for different reasons, and it's easier to disable them individually if they aren't in the same module.


text:
Q: How to set up a server to use TLS-SRP authentication? How to get it work at all?
I used this manual. I created a verifier file and started openssl s_server with a self-signed RSA certificate. Now I can't connect to it.
>gnutls-cli --srpusername user --srppasswd secret 127.0.0.1 -p 4433 --insecure
Processed 145 CA certificate(s).
Resolving '127.0.0.1'...
Connecting to '127.0.0.1:4433'...
*** Fatal error: A TLS fatal alert has been received.
*** Received alert [40]: Handshake failed
No certificates found!
*** Handshake has failed
GnuTLS error: A TLS fatal alert has been received.

Curl seems not to work too, but win32 binaries doesn't have SRP in "Features:" output from curl -V
Even openssl s_client stops working as far as I add -cipher SRP param.
openssl s_server -srpvfile xx.srp -tls1 -cipher SRP -cert ssl.crt -key ssl.key -www

-
Loading 'screen' into random state - done
CONNECTED(00000750)
2672:error:1407745B:SSL routines:SSL23_GET_SERVER_HELLO:reason(1115):.\ssl\s23_c
lnt.c:741:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 7 bytes and written 321 bytes
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
---

What now?
I'm using latest versions (OpenSSL 1.0.1e 11 Feb 2013, gnutls-3.0.22-w32, latest curl win32 build).
How should SRP accounts be registered?
Please add a tag for TLS-SRP

A: These instructions worked for me using openssl 1.0.1e compiled on win32.
Step 1. create empty SRP password file passwd.txt
Step 2. Add a user to the SRP password file
openssl srp -srpvfile passwd.txt -userinfo "This is Myself" -add myself
Enter pass phrase for myself:
Verifying - Enter pass phrase for myself:

Step 3. Start SRP server
openssl s_server -nocert -cipher SRP -srpvfile passwd.txt -accept 444
Loading 'screen' into random state - done
Using default temp DH parameters
Using default temp ECDH parameters
ACCEPT

Step 4. Connect to server
openssl s_client -srpuser myself -cipher SRP -connect localhost:444
Loading 'screen' into random state - done
CONNECTED(00000108)
Enter pass phrase for SRP user:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 2407 bytes and written 1184 bytes
---
New, TLSv1/SSLv3, Cipher is SRP-AES-256-CBC-SHA
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1
    Cipher    : SRP-AES-256-CBC-SHA
    Session-ID: 69AE0C7ED831DCCDA0E79CB5ED55E0BF9C65CA64B4077585CF9DD93CEE611358


text:
Q: FParsec failing at the end of a spaces separated list, expecting another element of the list I am trying to use FParsec to parse a list of zero or more elements of the form [string] where the string in the middle can be anything (except ] as to disambiguate from the end of the string). Here is my code as is:
let parseArgumentList : Parser<string list, unit> =
    let parseArgument = (skipChar '[') >>. (manySatisfy (fun x -> x <> ']')) .>> (skipChar ']')
    sepBy (parseArgument) (spaces)

[<EntryPoint>]
let main argv =
    let parserResult = run parseArgumentList "[testString] [testString]"

    printfn "%A" parserResult
    0

The output here is:
Failure:
Error in Ln: 1 Col: 26
[testString] [testString]
                         ^
Note: The error occurred at the end of the input stream.
Expecting: '['

It is as if the parser is expecting another set of parenthesis rather than terminating at 2 occurances in sepBy. I tested this by changing the spaces to (skipChar ' ') >>. spaces and sure enough it parses fine. I am however unwilling to remove the option of no spaces between arguments. Any ideas or advice would be greatly appreciated.

A: I think using sepEndBy instead of sepBy will do what you want:
let parseArgumentList =
    sepEndBy parseArgument spaces

From the FParser doc: The parser sepEndBy p sep parses zero or more occurrences of p separated and optionally ended by sep. (Emphasis added.)
Running this on your test input produces the expected result:
Success: ["testString"; "testString"]

Note that this solution also has the nice side-benefit of consuming trailing spaces, if there are any. E.g. When the input is "[testString] [testString]    ".


text:
Q: Overflow on divs? I have created a three-column background type thing, as I previously described in my first question: How to create a three-column website background using CSS?. Anyways, I have it working mostly successfully like so:
I have a div with id centercolumn, containing all my page's content (header, content, footer, etc.):
<html>
    <body>
        <div id="centercolumn">
            <!-- content -->
        </div>
    </body>
</html>

Then, in CSS, I have the following settings (only showing the relevant code):
body {
    background-image: url('theimagetobetiledalongthesides.png');
}

#centercolumn {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    left: 0;

    margin-left: auto;
    margin-right: auto;

    width: 760px;

    background-image: url('theimagetobetiledalongthemiddlecontentcolumn.png');
}

Essentially, the body provides the background for the whole page, then the centercolumn div goes on top of that and stretches all the way down the page, and has a different background image. This gives the appearance of having three columns: one in the middle for content, and two on the sides.
I believe the issue I'm having is with the overflow property of the centercolumn div. On any browser I've tested with (Chrome, Firefox, IE, Opera, and Safari), the center column initially goes all the way to the bottom of the page (as it should). When I vertically resize the page, making it smaller/shorter, once I reach the actual content (which is text), a scrollbar appears on the side of the page/browser (as it normally would). However, when I scroll down to see the rest of the content, it's as though the centercolumn div doesn't go all the way down: the different background image of the centercolumn stops part way down (exactly where the bottom of the browser was before I scrolled back down). My text runs out of the centercolumn background image, and on to the background image of the body.
When I set the overflow on the centercolumn div to be scroll and start resizing the page, it works fine (the div seems to go all the way down - the centercolumn background image doesn't cut off), but it creates a rather ugly effect where the scroll bar actually appears on the side of the middle content column rather than the side of the browser.
What can I do to get the middle content column's different background image to go all the way down, without causing a scrollbar to appear on the side of the middle column as I vertically resize the browser window?
edit: JSFiddle example at http://jsfiddle.net/dDfkC/1/.

A: You could try something like this:
#centercolumn {
    position: absolute;
    top: 0;
    min-height:100%;

    margin: auto;

    width: 760px;
    background-repeat: repeat-x;
    background-image: url('theimagetobetiledalongthemiddlecontentcolumn.png');
}

Would probably be better to see an example of what you have and exactly what you would like to achieve

A: You are using position:absolute, which is wrong, you want to use relative positioning then margin:0 auto; to center this column.
What you need to do is set it
#centercolumn {
    position:relative;
    margin: 0 auto;
    width:760px;
    background-image: url(whatever);
    background-repeat: both;
}

And if you want it to expand to the bottom of the page, no matter how little content you have:
body, html {
    height:100%;
}

and add to above
#centercolumn {
    min-height: 100%;
}

and a real basic CSS Reset:
* {
    margin:0;
    padding:0;
}

A: You can use fixed positioning for the left and right columns and static positioning for the main column, as in this jsfiddle


text:
Q: Android Application is crashing after adding TabHost I am making an an application which can add contacts to your phone contact list by watching tutorials however when i add Tabs to my application and run it,it crashes and message has been shown that my app has been stopped unfortunately
This is my main xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="wrap_content" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".Contact_main"
android:orientation="vertical"
android:id="@+id/background">

<TabHost
    android:layout_width="match_parent"
    android:layout_height="400dp"
    android:id="@+id/tabhost"
    android:clickable="false"
    android:focusable="false"
    android:focusableInTouchMode="false">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:clickable="false"
            android:focusable="false"
            android:focusableInTouchMode="false"></TabWidget>

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

            <LinearLayout
                android:id="@+id/tab1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:text="Contact Creators"
                    android:id="@+id/lblcreatortitle"
                    android:layout_gravity="center"
                    android:layout_marginTop="10dp"
                    android:textSize="30sp" />

                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textPersonName"
                    android:ems="10"
                    android:id="@+id/textname"
                    android:layout_marginTop="15dp"
                    android:hint="Contact name" />

                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="phone"
                    android:ems="10"
                    android:id="@+id/textphone"
                    android:layout_gravity="center"
                    android:hint="Phone no"
                    android:focusableInTouchMode="true"
                    android:layout_marginTop="15dp"
                    android:editable="false" />

                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textEmailAddress"
                    android:ems="10"
                    android:id="@+id/textemail"
                    android:layout_gravity="center_horizontal"
                    android:hint="Email"
                    android:focusableInTouchMode="true"
                    android:layout_marginTop="15dp" />

                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:ems="10"
                    android:id="@+id/textaddress"
                    android:layout_gravity="center_horizontal"
                    android:hint="Address"
                    android:focusableInTouchMode="true"
                    android:layout_marginTop="15dp"
                    android:inputType="textPostalAddress" />

                <Button
                    android:layout_width="200dp"
                    android:layout_height="wrap_content"
                    android:text="Add Contact"
                    android:id="@+id/buttonadd"
                    android:layout_gravity="center"
                    android:layout_marginTop="15dp"
                    android:enabled="false" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/tab2"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical"></LinearLayout>

        </FrameLayout>
    </LinearLayout>
</TabHost>

and this is my mainactivity
package com.example.sayedshazeb.contact;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TabHost;

public class Contact_main extends ActionBarActivity {

EditText nametext,phonetext,emailtext,adresstext;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_contact_main);

    nametext = (EditText) findViewById(R.id.textname);
    phonetext = (EditText) findViewById(R.id.textphone);
    emailtext = (EditText) findViewById(R.id.textemail);
    adresstext = (EditText) findViewById(R.id.textaddress);
    TabHost tabHost = (TabHost)findViewById (R.id.tabhost);
    tabHost.setup();
    TabHost.TabSpec spec1 = tabHost.newTabSpec("Tab1");
    spec1.setContent(R.id.tab1);
    spec1.setIndicator("Contact");

    TabHost.TabSpec spec2 = tabHost.newTabSpec("Tab2");
    spec2.setContent(R.id.tab2);
    spec2.setIndicator("List");

    tabHost.addTab(spec1);
    tabHost.addTab(spec2);

    final Button addbtn = (Button) findViewById(R.id.buttonadd);

    nametext.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            addbtn.setEnabled(!nametext.getText().toString().trim().isEmpty());
        }

        @Override
        public void afterTextChanged(Editable s) {

        }
    });
}

}

here is my log-
01-21 11:23:02.784    3064-3064/com.example.sayedshazeb.contact E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.example.sayedshazeb.contact, PID: 3064
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sayedshazeb.contact/com.example.sayedshazeb.contact.Contact_main}: java.lang.IllegalArgumentException: you must specify a way to create the tab indicator.
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2237)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2286)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1246)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:212)
            at android.app.ActivityThread.main(ActivityThread.java:5137)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:718)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.IllegalArgumentException: you must specify a way to create the tab indicator.
            at android.widget.TabHost.addTab(TabHost.java:221)
            at com.example.sayedshazeb.contact.Contact_main.onCreate(Contact_main.java:36)
            at android.app.Activity.performCreate(Activity.java:5231)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2201)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2286)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1246)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:212)
            at android.app.ActivityThread.main(ActivityThread.java:5137)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:718)
            at dalvik.system.NativeStart.main(Native Method)

I don't know what am i doing wrong ? why is my application crashing after adding Tabs?

A: Looks like you are using the android.R.id.tabhost instead of R.id.tabhost when you are binding your TabHost from your xml. Without some logcat output thats my best guess.
Good Luck


text:
Q: Use hosts file for docker-in-docker container in kubernetes pod What I want:
Dynamically add hosts in kubernetes pods created by Jenkins master and allow the mounted docker in the pod to use the hosts.
I am using Jenkins to create dynamic slaves for docker build, and created docker-in-docker slave containers for docker build and docker push. The docker-in-docker is created by mounting docker.sock of the VM to the container:
volumeMounts:
- name: hostpathvolume
  mountPath: '/var/run/docker.sock'

I am using hostAliases of kubernetes to append the hosts file with some private docker registries:
hostAliases:
- ip: 9.110.73.11
  hostnames:
  - devopsprod.icp
- ip: 9.119.42.60
  hostnames:
  - devops.icp

I have confirmed that the pods created have these hosts in /etc/hosts, but when I run:
docker login -u xxx -p xxx devops.icp:8500

I got a DNS error:
Error response from daemon: Get https://devops.icp:8500/v2/: dial tcp: lookup devops.icp on 0.0.0.0:00: no such host

This means the docker I run in the container is not using the /etc/hosts in the pod to look up for the ip address. Is there a way to fix this? I don't want to add the hosts manually in the VM's /etc/hosts file.

A: You have mounted docker.sock into the Pod, but Docker still uses the configuration from the Node, not from Pod. There are no other options, you need to add aliases to /etc/hosts on each Node to make it work.


text:
Q: how to share files with other Mob phone connected to the same network with which you are connected? I want to share file from my Mob Phone to other Mob Phone which are connected to the same network with which i am connected, is it can do easily with tcp or dhcp or socket, please i don't know about all of these also.

A: yes u can share the file through socket communication. Implement the server socket from the device which has the file. And client socket in the other device.
here is the link which shows simple socket communication http://www.javaworld.com/jw-12-1996/jw-12-sockets.html
Once socket communication is done , read data from the input stream in a loop as long as data is available.

A: You can share your file with other mob phone which are connected with same network with which you are already connected.
Now how to share these files between parties, see this articles it will solve your problem
Sending file from one client to another client using socket in java


text:
Q: React. You can now view Local: at: http://localhost:3000. But sometimes does not On Your Network: http: //192.168 X.XXXX:YYYY React
You can now view
Local: http://localhost:3000.
But sometimes does not view
On Your Network: http: //192.168.1.246:3000
What to do, If you want to see markup on another devises in the same network

A: do this
webpack-dev-server --port 3000 --hot --host 0.0.0.0

If you are prompted to install something, do it.
Otherwise
npm install --save-dev webpack-cli
or
yarn add webpack-cli --dev
will install it

If after installation it will offer
 npm audit fix

do it.
That is all.


text:
Q: How to Import Data from one theme to another theme in wordpress using Option Tree Plugin? How to Import Data from one theme to another theme in wordpress using Option Tree Plugin?
I am created a theme using option tree plugin but i want to import all the content into another theme. But by bad-luck i am not successful.

A: Go to Option tree -> Settings -> Export
Copy the contents present under Settings and Theme options then go to the new website and then go to
Option tree -> Settings -> Import
Paste Settings content and click import settings button, it will import all option tree settings. Then paste theme options then click import theme options button. Hope this helps


text:
Q: he not be stopped
He kept her gait down because it was very important that he not be stopped.

This sentence is from Cold Iron by Miles Cameron, a medieval fantasy book. I find this sentence strange. Could we rephrase it as:

... him not being stopped was very important.

or

... him being not stopped was very important.

or, maybe:

... it was very important him not being stopped

And is it an idiomatic sentence that the writer has written here, or is it just there to impart an archaic quality to the story?

A: "He [not] be stopped" is using the the present subjunctive of the verb 'to be'. This form is identical to the bare infinitive (and imperative) of the verb (in this case 'be') in all forms. The main use of the English present subjunctive is in that clauses expressing a circumstance that is desired, demanded, recommended, necessary, etc. It is more likely to be found in more formal writing and in speech by educated speakers.
English subjunctive

A: I wouldn't say that it's idiomatic or archaic.
Remove the negative, and it's a pretty uncontroversial sentence:

It was very important that he be stopped.

It may seem slightly bit odd because of the passive voice, but this construction isn't unusual in English:

They shouldn't be worried.
Those weren't meant to be eaten!
You shouldn't be sitting there.

Your first rephrasing is OK, though the word ordering would seem a bit odd to a native speaker.
The second is a bit bizarre, though I've heard similar constructions (usually indicating that the speaker doesn't know the a word, such as an antonym for stopped, and is indicating that while emphasizing the condition they want to express).
The third is very unusual, having the pronoun it at the start of the sentence and the antecedent him not being stopped without the word that in between, though with a comma between important and him you get a fairly common construction.

A: A more usual was to express this meaning would be "it was very important that no one stop him." The quoted passage is in the passive voice, because it is emphasizing the possible act of stopping the character, and the character's efforts to avoid it. The person who might do the stopping, who would be the subject of the verb "stop" in an active construction is not important to the author, and so the author has avoided it by a passive construction. This is a case where a passive construction is better than an active one, in my view.
The agent could be indicated with a by clause as:

It was very important that he not be stopped by anyone.

However, this doesn't really add anything to the meaning.


text:
Q: how to add a new row in repeater control from javascript in asp.net I have using the following HTML block within a Repeater control. I can add rows to the HTML table from client side (JavaScript) and values are added. When the page post backs by a button click, the table become empty. But I am not able to get the values from the binding repeater control in server side too. It shows nothing. How can I add the values to repeater from client side or binding with HTML table ?

                Name

                City

                State

        <asp:repeater id="repSelectlist" runat="server" enableviewstate="true">
            <ItemTemplate>

                            <%# DataBinder.Eval(Container.DataItem, "DataItem.CustName")%>

                            <%# DataBinder.Eval(Container.DataItem, "DataItem.custCity")%>

                            <%# DataBinder.Eval(Container.DataItem, "DataItem.custstate")%>

            </ItemTemplate>
        </asp:repeater>

If I use runat="server" for the HTML table, it shows the following error:

Value of type 'System.Web.UI.WebControls.Repeater' cannot be converted
  to 'System.Web.UI.HtmlControls.HtmlTableRow'.

A: Use the HeaderTemplate and FooterTemplate sections of the repeater control.
<asp:repeater id="repSelectlist" runat="server" enableviewstate="true">
<HeaderTemplate>

  Name

  City

  State

</HeaderTemplate>

<ItemTemplate>

 <%# DataBinder.Eval(Container.DataItem, "DataItem.CustName")%>

 <%# DataBinder.Eval(Container.DataItem, "DataItem.custCity")%>

 <%# DataBinder.Eval(Container.DataItem, "DataItem.custstate")%>

</ItemTemplate>

<FooterTemplate>

</FooterTemplate>
</asp:repeater>


text:
Q: node express, how to clear cookie after log out Basically i'm doing redirect from a.example.com to www.example.com and i expect to be able to delete cookies on www.example.com (because cookie is created with .example.com as the cookie domain), but following code doesn't work.
I know that this question seems like duplicate question, i tried everything from similar question but it doesn't work. See after the code what i already tried.
Using express 3.0.3 and node 0.10.32.
express session middleware
...
var cookiedata = {
    domain              : '.example.com',
    originalMaxAge      : null,
    httpOnly            : false
};

app.use(express.session({
        store  : ...,
        secret : ...,
        key    : 'express.sid',
        cookie : cookiedata
}));
...

logout function
function logout(req, res){
    ...

    req.session.destroy(function(){
        req.session = null;

        res.clearCookie('express.sid', { path: '/' });
        res.redirect('https://www.example.com');

    });
}

What i already tried from similar question

*

*https://github.com/strongloop/express/issues/691
So i put path : '/' in express session middleware such as:
app.use(express.session({ ..., path : '/' });

No success.

*https://groups.google.com/forum/#!topic/express-js/PmgGMNOzhgM
Instead res.clearCookie i used:
res.cookie('express.sid', '', {expires: new Date(1), path: '/' });

No success.

A: This is working for me with cookie-parser module:
router.get('/logout', function(req, res){
    cookie = req.cookies;
    for (var prop in cookie) {
        if (!cookie.hasOwnProperty(prop)) {
            continue;
        }
        res.cookie(prop, '', {expires: new Date(0)});
    }
    res.redirect('/');
});

A: What worked for me was adding path and domain in res.clearCookie
res.clearCookie(<cookie-name>, {path: '/', domain: <domain-on-which-cookie-is-set>}
Also, make sure to include credentials on the frontend, otherwise no cookie will be sent with the request. If no cookie goes to the server, it has nothing to clear!
fetch('url.com', {credentials: "include"}

A: This is response.clearCookie of Express.JS (file response.js at line 749).
var opts = merge({ expires: new Date(1), path: '/' }, options);
return this.cookie(name, '', opts);

If you set a breakpoint at this line you will see expires is reported at an invalid date. So instead of using response.clearCookie, just make it expire immediately like this one.
response.cookie("express.sid", "", { expires: new Date() });


text:
Q: Is it possible to send verification email to user after he logged in? I removed email verification from required actions in Keycloak admin ui.
Now a user can log in immediately after registration, but verification email is not sent at all.
So how to make user not being require to verify his email but at the same continue to receive a verification email ?
My current keycloak version is 7.0.0


text:
Q: Modelling a Complex Object in Redis I am looking to use Redis as a database since it provides excellent real time data capabilities and scales better than mongo. But the data that I am using is mostly in some kind of complex json format and Redis does not easily accommodate it, given that it is primarily a key-value store.
How would I model this complex object using redis?
vacation : [
    {
      daysUntilVacation: 10,
      vacationType: {
        type: 'tropical',
        media: [
          {
            type : 'image',
            src  : 'http://www.hawaii.com',
          }
        ]
      }
    }
  ]

A: You're asking the wrong question - with Redis you need to begin with identifying your queries, and only afterwards can you model the data to be efficiently manipulated.
That said, you may want to look at ReJSON - a Redis module that implements a JSON data type:

*

*Blog: https://redislabs.com/blog/redis-as-a-json-store/

*Documentation: https://redislabsmodules.github.io/rejson/

*Source: https://github.com/redislabsmodules/rejson
(disclaimer: module's author here ;))


text:
Q: JavaScript local scope variable available in event after host function returns. Why? So... I come from c++ background and I don't understand few things about JS. For example:
function a()
{
   var x = 0; // Local variable

   $(document).on('mousedown', function(){console.log('down: ', x++);});
   $(document).on('mouseup', function(){console.log('up: ', x++);});
   setInterval(function(){console.log('interval: ', x++);}, 1000);

   //W3schools: 'Local variables are deleted when the function is completed.'
}
a();

Why the console output looks like this? (while random clicking)

interval:  0
down:  1
up:  2
interval:  3
down:  4
up:  5
interval:  6
down:  7
interval:  8
up:  9
interval:  10
down:  11
interval:  12
up:  13
interval:  14
down:  15
up:  16
interval:  17
interval:  18

I expected it to be 'undefined's or NaNs or nulls since x should be removed at the end of the scope, but it seems that all three callback reference it just fine forever... why? Is it a new behavior or it works like this since old JS versions? I can't find an answer.

A: W3schools' comment is incomplete. Most of the time, variables do get cleaned up when a function finishes (not necessarily instantly, but the next time garbage collection runs). But that's only because most of the time there are no more references to those variables.
However, since javascript supports functions as first class objects, it also supports closures. When you have a line like this:
$(document).on('mousedown', function(){console.log('down: ', x++);});

...you are creating a closure. That closure is the new function, plus the lexical environment in which it was defined. It has a reference to x, and so even once a finishes resolving, that x will not be garbage collected. Later when the function is called, it can still access the closure variables just fine.
x can still potentially be garbage collected, but only if all the closures referencing it get garbage collected as well. In this case, you'd achieve that by unregistering the mouseup and mousedown events, and cancelling the interval.

A: The functions can access x because you gave them that variable in a scope where it was accessible. It counts up because in javascript you don't give the actual value but just a reference to it, so all your callbacks still reference the x inside the a() function. And because it's still referenced javascript's garbagecollector won't delete it because it thinks it's still 'in use', which it is (because your callback functions use it to increase it every call).


text:
Q: integrate UISearchController with Async result update in swift I want to implement UISearchContoller that search from webservice JSON with swifty json, exactly like apple's appStore when you search for an app, it loads without load them into tableView
here is what I have done in updateSearchResultsForSearchController method:
func updateSearchResultsForSearchController(searchController: UISearchController) {
    filterContentForSearchText(searchController.searchBar.text!)
}

func filterContentForSearchText(searchText: String) {
filteredContents = myStruct.filter{$0.name.rangeOfString(searchText) != nil

}

A: Posting more of your code would be nice, like what you are using to get the results from the web service, However, I will try to step you through it anyway.
I have done with before just using a UISearchBar and it's delegate method, one the user pressed the search button or enter, I would use NSURLSession to pass the user's search terms to the API, and parsed the response.
func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
    let searchText : String = searchBar.text
    webService.getRecipe(ingredient: searchText, completionHandler: { (recipeArray) in
            self.highProteinArray = recipeArray
            dispatch_async(dispatch_get_main_queue(), {
                self.collectionView.reloadData()
            })
        })
}

As you can see I used a callback to handle setting the newly parsed data to a variable for later use, and then reloaded the collectionView.  This way your tableView/collectionView will load and set itself up while you are waiting for the response from the web service and then parsing it, once that is complete you just reload to show the new data.
To add a little extra you could even add a fading in animation in your cellForItemAtIndexPath or cellForRowAtIndexPath, whichever you are using.


text:
Q: How to Enable and Disable a Command I currently have a Discord Bot and i would like to be able to use a command to turn on and off another command e.g ?command off & ?command on.
I've had a look round on here and other sites but unable to find what i am looking for.
Could someone provide some examples or where to look please.


text:
Q: git - multiline function as alias is not working I have written a function which beautify the git log output (to solve the problem mentioned in different color for data and time in git log output).
function gl() {
my_date=();
my_time=();

    while IFS= read -r line; do
        my_date+=( $(date +"%d-%m-%Y" -d @$line) )
        my_time+=($(date +"%H:%M" -d @$line))
    done < <( git log --format="%at" )

    for (( n=0; n<${#my_date[@]}; n++ )); do
        git --no-pager log -1 --skip=$n --pretty=format:"%C(#d33682)%h %C(#859900)${my_date[$n+1]} %C(#b58900)${my_time[$n+1]} %C(#6c71c4)%ce %C(#2aa198)%s";
        printf "\n";
    done

}

So far so good.
Then, I port this function as git alias using the following code in my bash terminal:
git config --global alias.l '!f(){
my_date=();
my_time=();

while IFS= read -r line; do
    my_date+=( $(date +"%d-%m-%Y" -d @$line) )
    my_time+=($(date +"%H:%M" -d @$line))
done < <( git log --format="%at" )

for (( n=0; n<${#my_date[@]}; n++ )); do
    git --no-pager log -1 --skip=$n --pretty=format:"%C(#d33682)%h %C(#859900)${my_date[$n+1]} %C(#b58900)${my_time[$n+1]} %C(#6c71c4)%ce %C(#2aa198)%s";
    printf "\n";
done
}; f'

Now every time I try to use git l, It says f: 2: Syntax error: "(" unexpected (expecting "}").
What might be the issue here?

A: The script you're writing contains several bashisms.  Git invokes /bin/sh, which on your system is not bash.  On Debian and Ubuntu, it's dash instead, which is much faster but less featureful.
Debian specifies the features you may expect in /bin/sh, which are basically those found in POSIX, plus test -a and test -o, local, echo -n, and some extensions to kill and trap.  These are generally a safe subset of features you may use in /bin/sh on a typical open source operating system.
The first non-portable construct you're using is shell arrays.  Those exist only in bash and zsh and are not portable.  In addition, the use of the three-part for loop is also a bashism.  POSIX sh has only the for name in list syntax.  The use of function is similarly non-portable.
The use of process substitution (<()) is also unportable.  You'll need to use the git log command as the beginning of a pipeline, but because typically segments of a pipeline are written in subshells, you'll need to be explicit about the scope of the subshell if you want to capture variables correctly.
The way I would write the function is this:
gl() {
    git log --format="%at" | (
    n=0;
    while IFS= read -r line
    do
        date=$(date +"%d-%m-%Y" -d @$line)
        time=$(date +"%H:%M" -d @$line)
        git --no-pager log -1 --skip=$n \
            --pretty=format:"%C(#d33682)%h %C(#859900)$date %C(#b58900)$time %C(#6c71c4)%ce %C(#2aa198)%s%n"
        n=$((n + 1))
    done)
}


text:
Q: Loading array of user tweets for embedded user tweet timeline The below code successfully displays a table view with the tweet ID in the array 'tweets' displayed.  Could someone please tell me how I can modify this to display all tweets for a particular user handle or hastag?  I think I have to use the loadUserWithID method from TwitterKit but am not sure how to implement it.  Many thanks
import UIKit
import TwitterKit

class TwitterViewController: UITableViewController, TWTRTweetViewDelegate {

let tweetTableReuseIdentifier = "TweetCell"
// Hold all the loaded Tweets
var tweets: [TWTRTweet] = [] {
    didSet {
        tableView.reloadData()
    }
}
let tweetIDs = [
    "184701590"] // our favorite bike Tweet

override func viewDidLoad() {

    Twitter.sharedInstance().logInGuestWithCompletion { guestSession, error in
        if (guestSession != nil) {
            Twitter.sharedInstance().APIClient.loadTweetsWithIDs(self.tweetIDs) { tweets, error in
                if let ts = tweets as? [TWTRTweet] {
                    self.tweets = ts
                } else {
                    println("Failed to load tweets: \(error.localizedDescription)")
                }
            }
        }
    }
    // Setup the table view
    tableView.estimatedRowHeight = 150
    tableView.rowHeight = UITableViewAutomaticDimension // Explicitly set on iOS 8 if using automatic row height calculation
    tableView.allowsSelection = false
    tableView.registerClass(TWTRTweetTableViewCell.self, forCellReuseIdentifier: tweetTableReuseIdentifier)

            }

// MARK: UITableViewDelegate Methods
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return self.tweets.count
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let tweet = tweets[indexPath.row]
    let cell = tableView.dequeueReusableCellWithIdentifier(tweetTableReuseIdentifier, forIndexPath: indexPath) as TWTRTweetTableViewCell
    cell.tweetView.delegate = self
    cell.configureWithTweet(tweet)
    return cell
}

override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    let tweet = tweets[indexPath.row]
    return TWTRTweetTableViewCell.heightForTweet(tweet, width: CGRectGetWidth(self.view.bounds))
}

A: TwitterKit supports showing a User Timeline directly.
class UserTimelineViewController: TWTRTimelineViewController, TWTRTweetViewDelegate {

  convenience init() {
    let dataSource = TWTRUserTimelineDataSource(screenName: "TomCruise", APIClient: TWTRAPIClient())
    self.init(dataSource: dataSource)

    self.title = "@\(dataSource.screenName)"
  }

  func tweetView(tweetView: TWTRTweetView, didSelectTweet tweet: TWTRTweet) {
    print("Selected tweet with ID: \(tweet.tweetID)")
  }

}

You can see more details here: https://dev.twitter.com/twitter-kit/ios/show-timelines


text:
Q: execute Ant from docker-compose I'm a newbie with docker.
I'm creating a dockerfile, and want to execute hello world from Ant file "build.xml"  with docker commands. Is this possible?

A: This is a quick solution:

*

*create a folder "ant"

*create a file ant/Dockerfile with the contents

FROM alpine

WORKDIR /work

RUN apk update && apk add openjdk8 && apk add apache-ant

ENTRYPOINT [ "ant" ]

*create a file ant/build.xml with the contents (I know you can do better than this but I can't :) )

<?xml version = "1.0"?>
<project name = "Hello World Project" default = "info">
   <target name = "info">
      <echo>Hello World - Welcome to Apache Ant!</echo>
   </target>
</project>

*build the docker image

docker build -t ant:1.0 ./ant

*run the ant build

docker run --rm -v $(pwd)/ant:/work ant:1.0

Of course you can put in "ant" your whole project and build that.
This can be refined, but hopefully it answers your question so far.

A: @Mihai's answer seems right but there was something I needed to add because I got an error like this:
 > [3/3] RUN apk update && apk add openjdk8 && apk add apache-ant:
#6 0.239 fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/x86_64/APKINDEX.tar.gz
#6 0.482 139776850742088:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:ssl/statem/statem_clnt.c:1913:
#6 0.484 ERROR: https://dl-cdn.alpinelinux.org/alpine/v3.13/main: Permission denied
#6 0.484 WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.13/main: No such file or directory

I had to do what I saw in this answer.

*

*Create a repositories file with these contents:
http://dl-cdn.alpinelinux.org/alpine/v3.13/main
http://dl-cdn.alpinelinux.org/alpine/v3.13/community

*In Dockerfile before the RUN apk update add the following:
COPY repositories /etc/apk/repositories


text:
Q: Alignment of the TabBarControls in a TabSet we're using smartGWT for our web application. An the main page is a tabset that shows different tabs. What I want to do is do a button to the tab set with the setTabBarControls method which then is alligned to the left instead to the right. So it would somewhat look like the current Firefox version.
Is there a possibility to change the allignment of the TabBarControls? I couldn't find any.

A: If you want to create something like the Firefox corner button, just use TabSet.addChild().  That will place the button at the upper left, and you can use setLeft/setTop to move it elsewhere.  If you want the control to appear to the left of the tabs, set a layoutStartMargin on the TabBar to leave space for it.


text:
Q: HTML/CSS Help I cant't position my search box for some reason my search box is stuck right under my logo every time I try to move it. Here is my code
.searchbox{
    position: absolute;
    top:50px;
    right: 50px;
}

And my HTML

                            <form action="search.php" methond="GET" id="search" >
                                    <input type ="text" name="q" size"60" placeholder="Find Surfers...">

My logo css doesn't have position: relative
.logo{
    width: 125px;
}
.logo img{
    width: 150px;
height: 38px;
padding-top: 5px;
}

A: That's probably because .logo has position: relative;. Throw out the searchbox from the .logo div. That isn't a part of the logo, is it?
Do something like this

header{
  width: 100%;
  height: 70px;
  background-color: #eee;
  position: relative;
  padding: 25px 0;
}
header #logo{
  width: 150px;
  height: 60px;
  background-color: orange;
  line-height: 60px;

}
header #searchbox{
  position: absolute;
  top: 50px;
  right: 50px;
}

Logo

    <input type="text" id="searchbox" value="Search...">


text:
Q: Expressing the Uncountable Hat Paradox mathematically I came across this article https://jaydaigle.net/blog/what-is-the-axiom-of-choice/#fnref:7 and was wondering how would one mathematically express and explain the Uncountable Hat Puzzle (under the same heading on the page) since there are no definite ordered "steps", just a couple of assumptions? I have only started studying about equivalence relations and real coordinate spaces so i am not very sure how to go about this.
I would appreciate any and all help on this >:)


text:
Q: What does this struct mean in Julia? I am trying to lean deep learning using Julia. In one of the tutorials, which is about MLP, use the below structure for modeling multiple layers in ANN. What does this code mean?
struct Chain
    layers
    Chain(layers...) = new(layers)
end

A: This definition in isolation doesn't really "mean" anything; it is just a user defined struct with one field (called layers) and one inner constructor. Usually custom structs like this is used for collecting some data and/or used to define operations on, e.g. you could define a function f operating on this struct like this:
function f(c::Chain)
    # do something with the layers in the chain
end

but in order to understand what it is used for in this specific case you probably need to consult the documentation and/or the rest of the code.

A: One peculiarity in this example:
The inner constructor takes multiple arguments (layers...) and creates a tuple out of them, which is assigned to the property layers.
julia> c = Chain(1, 2, "foo")
Chain((1, 2, "foo"))


text:
Q: Operation not allowed from within a pluggable database Pre-Built Developer VMs for Oracle VM VirtualBox I downloaded Pre-Built Developer VMs for Oracle VM VirtualBox , which contains Oracle Database 12c Enterprise Edition Release 12.2.0.1.0
I want to BACKUP the Database using Rman, but it is in NOARCHIVELOG mode, so it is necessary to shutdown and change the database to ARCHIVELOG mode, but when I try to alter database to archive log , it gives an error saying operation not allowed from within a pluggable database. An operation was attempted that can only be performed in the root container.

A: "Pluggable Databases" are not really Oracle Databases at all.
Think of them more like "TableSpaces on Steroids".
All the "real" database work, including Redo Logging, is done by the Container Database (CDB).  Seems a bit weird, I know, but that's how Our Friends in Redwood City decided to do things.
You can do just about everything that PDBs do using Tablespaces, Schemas and [tight] Security Management (and we used to just that!)


text:
Q: HTML 5 validation warning - Element 'header' is not a known element. Pls advice I have been trying for hours to solve this and have been searching for a similar issue like mine but none of the solutions I have tried works. I have a web application and added a user control:
<dx:Header runat="server" ID="HeaderControl" />

which I have referenced in web.config:
<controls>
    <add src="~/UserControls/HeaderControl.ascx" tagName="Header" tagPrefix="dx"/>
  </controls>

Everything works fine and it can build and run but there is that green wavy line and I get this warning:

Element 'Header' is not a known element. This can occur if there is a compilation error in the Web site, or the web.config file is missing.

I also found that this is because of the HTML 5 validation but I am lost now to fix this. I tried many things and don't know what else I can do to try and solve this. Please advice.

A: Ok, this issue been around - for 10, and probably 15+ years.
When you drag the control onto the web form - it sets up the correct reference.
OR YOU can do as your example - setup in web config.
Both should work - you are doing this 100% correct.
There are several tricks you can do to make this work.
I find it "difficult" since when in the forms desinger, or even the markup, then all of your simple (public) properites ARE supposed to show up in the property sheet -- BUT Again, this DOES NOT WORK.
So try this:
Change the build from x64 or ANY CPU to x86.
Then from build, you have 2 options:

Use the 2nd opiton:
Problem:
I OFTEN and in fact my case NEED and MUST and WILL deploy this build as x64 bits. I am using some library code and even some un-managed code - so I must and WILL deploy as x64 bits.
But, if I use x64 bits, then the property sheets and the markup "fail" as you note will occur!!!
However, I do find that in MOST cases (not all, but MOST) cases, if you do a re-build of the project to ANY CPU, then the green squggle goes away, and then the property sheet works.
So, say I have this user control on the page:
 <uc1:UHotelEdit runat="server" ID="UHotelEdit"
    MyTable ="tblHotelsA" />

In designer, we see this:

And if I try to display the property sheet, I get this:

So, try changing the build (config) to ANY CPU).
If ANY CPU does not work, then try x86.
So, this :

Then do a rebuild solution
You now get this:

Note the green squiggle is gone, and note how the property sheet works.
This can be a pain, since if your applicaiton MUST run and MUST deploy as x64 bits, then you have to CHANGE back to that before you re-compile and deploy (or publish).
In fact, once you do the above flip to ANY or x86?
You can now develop, and the property sheet for the UC works, and he green squiggle is gone.
and in fact you can EVEN flip the project back to x64 bits.
As long as you don't hit f5, or re-build, then at least you get a brief time of being able to use the property sheet.
But, once you hit f5, or re-build (and have flipped back to x64 bits), then after building, you are BACK to your issue/probelm (property sheet not working + green HTML markup warning squggle returns).
So, try ANY CPU. You may well find that this works, and often ANY CPU will, and often I find I can debug and develop the web applcation that way.
Then at deploy time I do always flip back to x64 bits.
So, it depends, and in some cases, you may well be just fine working with ANY CPU.
However, for vs 2022, then things are different.
So try the above tip, see if it works. (it not ideal).
And this issue?
Post here and other forums - going back for 12 and even more years!
this probem/issue is NOT new, and been around for a VERY long time.
The issue centers around some x32 bit code in VS and the desinger that NOT been upgraded to x64 bits.
I don't have vs2022 to try this out, but you MAY WELL find the REVERSE of above is required for this to work (since vs2022 is the FIRST version of vs that is x64 bits as opposed to x32 bits).
So do try ANY CPU. that often works.
but, if ANY CPU (and rebuld) does not work, then try as x86 - and rebuild and now the property sheet should work.
And you can even flip project back to x64 bits, but you lose the intel-sense, property sheet and green HTML markup warning WILL return after the NEXT build or even hitting f5 to run/debug.


text:
Q: Is "case-sensitively" a word? A colleague just asked about comparing values "case sensitively". I see those words together on technical sites, but nowhere else. I myself see no problem with the phrase, though it sounds a bit awkward. Is there a better single-word substitute for "in a case-sensitive fashion"?

A: The word case-sensitively may be rare outside of technical sites, because the concept is little needed anywhere else. However, it's built out of normal, productive English morphological rules, so it's perfectly licit. I don't believe that there is any other terse alternative.

A: The term I've seen most often is "case sensitivity." Ergo:

*

*"A colleague asked me about comparing values in a case-sensitive manner."

This leads naturally to:

*

*"A colleague asked me about comparing case-sensitive values."

Trying to force the construction into an adverb leads to unhappy results.


text:
Q: jqgrid enable disable multiselect on button click i wanted to enable and disable the multiselect option of jqgrid at runtime (button click)
i have tried "gridContainer.jqGrid('hideCol', 'cb');" this hides the checkbox columns only which breaks the UI of the header row.
Tried setting the multiselect:true using SetGridParams but giving "cm is not defined" error.

A: Someone has managed to do it here.


text:
Q: Solving for the equation, giving exact solutions between (0 and $2\pi$) I have the problem: $\sin(2x)=\tan(x)$
I used the double angle formula to get $2\sin(x)\cos(x)=\tan(x)$.
But after that step, I do not know whether or not to subtract $\tan(x)$ or to set $2\sin(x)\cos(x)$ to $u$ and solve for $U$.

A: $$
2\sin(x)\cos(x)=\tan(x)
$$
Here, two possibilities: $\sin(x) = 0 \implies x \in \{ 0, \pi, 2\pi\}$
or
$$
2\cos(x)=\frac 1{\cos x}
\iff \cos^2 x = \frac 12
\iff x \in \left\{ \frac \pi 4, \frac {3\pi} 4, \frac {5\pi} 4, \frac {7\pi} 4
\right\}
$$

A: Write $\tan{(x)}=\frac{\sin (x)}{\cos(x)}$
allowing you to write it as:
$$ 2\sin{(x)}\cos{(x)}=\frac{\sin{(x)}}{\cos(x)} $$
After a little manipulation you can get it into this form:
$$ \sin{(x)}(2\cos^2(x)-1) =0$$
So you are then solving:
$$ \sin(x)=0 \;\;\; \text{ and } \;\;\; 2\cos^2(x)-1=0 $$
Can you see how to proceed from here?

A: $$2\sin x\cos x=\dfrac{\sin x}{\cos x}\\
\implies \cos x=\dfrac{1}{\sqrt{2}}\text{ and/or }\sin x=0\\
\implies x=\dfrac{\pi}{4},\dfrac{3\pi}{4},\dfrac{5\pi}{4},\dfrac{7\pi}{4},0,\pi,2\pi$$


text:
Q: Button position in kivy gridlayout I'm trying to move this button to top-right but no matters what I do I just can't move it. It is always in the bottom-left and never leaves this position.
This is my .py:
    #!/usr/bin/python
    # coding=UTF-8

    import kivy
    from kivy.uix.gridlayout import GridLayout
    from kivy.app import App
    from kivy.uix.button import Button
    from kivy.lang import Builder

    Builder.load_file('listadex.kv')

    class TestS(GridLayout):
        def bt1(self):
            print 'Olar galera'        #layout.add_widget(bt1.Button(text='TestS'))

    class SegundaTela(App):
        def build(self):
    #layout = GridLayout(cols=2, row_force_default=False, row_default_height=10)
    #layout.add_widget(bt1.Button(text='TestS'))
    #layout.add_widget(bt2.Button(text='TestA'))
    #layout.add_widget(bt3.Button(text='TestD'))
    #layout.add_widget(bt4.Button(text='TestMC'))
    #return layout
    CF = TestS()
    return CF

    SegundaTela().run()

And this is my .kv
    <TestS>:
        GridLayout:
            rows: 1
            cols: 1
            padding: 3
            spacing: 3

            Button:
                text: 'botao1'
                on_press: root.bt1()
                pos_hint: {'center_x':.15}

A: I suggest using relative layout. for example
RelativeLayout:

    Button:
        text: 'botao1'
        on_press: root.bt1()
        pos_hint: {'center_x': 0.5, 'center_y': 0.5}

change center_x and center_y till they meet your needs.


text:
Q: Difference between calling a method and accessing an attribute I'm very new to Python, and I'm using Python 3.3.1.
class Parent: # define parent class
    parentAttr = 100
    age = 55

    def __init__(self):
        print ("Calling parent constructor")

    def setAttr(self, attr):
        Parent.parentAttr = attr

class Child(Parent):
    def childMethod(self):
        print ('Calling child method')

Now I'll create
c=child
c.[here every thing will appear methods and attr (age,setAttr)]

How can I distinguish between methods and atrributes? I mean, when do I use c.SetAtrr(Argument), and  c.SetAtrr=value?

A: Methods are attributes too. They just happen to be callable objects.
You can detect if an object is callable by using the callable() function:
>>> def foo(): pass
...
>>> callable(foo)
True
>>> callable(1)
False

When you call a method, you look up the attribute (a getattr() operation) and then call the result:
c.setAttr(newvalue)

is two steps; finding the attribute (which in this case looks up the attribute on the class, and treats it as a descriptor), then calls the resulting object, a method.
When you assign to an attribute, you rebind that name to a new value:
c.setAttr = 'something else'

would be a setattr() operation.
If you wanted to intercept getting and setting attributes on instances of your class, you could provide the attribute access hooks, __getattr__, __setattr__ and __delattr__.
If you wanted to add a method to an instance, you would have to treat the function as a descriptor object, which produces a method object:
>>> class Foo: pass
...
>>> foo = Foo()  # instance
>>> def bar(self): pass
...
>>> bar
<function bar at 0x10b85a320>
>>> bar.__get__(foo, Foo)
<bound method Foo.bar of <__main__.Foo instance at 0x10b85b830>>

The return value of function.__get__(), when given an instance and a class, is a bound method. Calling that method will call the underlying function with self bound to the instance.
And speaking of descriptors, the property() function returns a descriptor too, making it possible to have functions that behave like attributes; they can intercept the getattr(), setattr() and delattr() operations for just that attribute and turn it into a function call:
>>> class Foo:
...     @property
...     def bar(self):
...         return "Hello World!"
...
>>> foo = Foo()
>>> foo.bar
"Hello World!"

Accessing .bar invoked the bar property get hook, which then calls the original bar method.
In almost all situations, you are not going to need the callable() function; you document your API, and provide methods and attributes and the user of your API will figure it out without testing each and every attribute to see if it is callable. With properties, you have the flexibility of providing attributes that are really callables in any case.


text:
Q: Post a form in a new window / inAppBrowser in Ionic (Cordova) I want to submit a checkout form to an external url, that should open a new window with the result, but I can't make my app to open it nor in a separate window, nor using the in app browser.
What I've done until now is to create a directive with the form inside, and from linker function, call the submit element at some point.
When I'm running in browser, this opens a new window (like I want). The problem appears when running on device, because it just REPLACES the content of my view with the new content WITHOUT OPENING an external window.
So, the question is... when running on device, how can I post this form opening a new window (navigator) or in-app-browser, and show there the results?
Thanks!!

A: Well, it has been complex to figure it out, but at the end the solution is "quite" simple. I'll post it here to help any other people facing the same problem. If anyone has a more elegant solution, it will be welcomed.
What I ended doing is to:

*

*Open the new window with my own template with angular and my form.

*In the new window controller, create a callback function in the global window object

*From the old window, after the loadstop event, execute that callback

*The posted form in the new window, redirects to the destination page (that is what I wanted to).

Here's the code (Observe that I'm using a directive with the form, so I can control when to submit it, from link function, and that data is shared with the directive through a service) :

angular.module('starter', ['ionic'])

.constant('cartData', {
        redirectUrl: 'https://test.mycart.com/hpp/pay.shtml',
        redirectMethod: 'POST',
        redirectData: {
                'formParam1': 'value1',
                'formPara2': 'value2'
            }
    }
)

.controller('InitCtrl', function($cordovaInAppBrowser, $scope, cartData) {

    $scope.openView = function(){

        var counter = 0;
        if(ionic.Platform.isWebView()){

            $ionicPlatform.ready(function() {
                //this is the cordova in app web view
                var ref = $cordovaInAppBrowser.open('payment.html', '_blank', {location:'yes'});

                $rootScope.$on('$cordovaInAppBrowser:loadstop', function(e, event){
                    if(counter < 1){
                        //prevent the callback to be called several times
                        $cordovaInAppBrowser.executeScript({
                            code: 'window.paymentCallback('+ angular.toJson(cartData) +');'
                        });
                        counter++;
                    }
                });
            });
        }
    };

})

//and then in payment.js

window.paymentCallback = null;

angular.module('payment', [])

.directive('autoSubmitForm', ['$timeout', 'autoSubmitFormDelegate', function($timeout, autoSubmitFormDelegate) {
    return {
        replace: true,
        scope: {},
        template: '<form action="{{formData.redirectUrl}}" method="{{formData.redirectMethod}}">'+
                      '
'+
                           '<input type="hidden" name="{{key}}" value="{{val}}" />'+
                      '
'+
                  '</form>',
        link: function($scope, element, $attrs) {

            autoSubmitFormDelegate.submitCallback = function(data) {
                $scope.formData = data;
                $timeout(function() {
                    element[0].submit();
                });
             };
        }
    }
}])

.factory('autoSubmitFormDelegate', function(){
    var delegate = {};

    delegate.submitCallback = null;

    delegate.submitForm = function(data){
        if(delegate.submitCallback){
            delegate.submitCallback(data);
        }
    }

    return delegate;
})

.controller('PaymentCtrl', function($scope, $timeout, $window, $sce, autoSubmitFormDelegate){

    $window.paymentCallback = function(data){
        console.log("callback called");
        data.redirectUrl = $sce.trustAsResourceUrl(data.redirectUrl);
        $timeout(function(){
            autoSubmitFormDelegate.submitForm(data);
        });
    };

})
<link href="http://code.ionicframework.com/1.1.1/css/ionic.min.css" rel="stylesheet">

  <ion-view view-title="Init">
  <ion-content>

Init

      <button class="button button-positive" ng-click="openView()">Open new view</button>
  </ion-content>
</ion-view>

    <auto-submit-form></auto-submit-form>

</script>


text:
Q: Are there gaps in the 2% resistor standard values? I was reading the Wikipedia entry for E-series resistor values, and I decided to graph the values on a log plot. The plot shows the values nearly evenly spaced, which makes sense because adjacent values are supposed to be related approximately by the factor where N is the resistor series (E6, E12,...,E192).
If I then plot the tolerance range for each value in the E6,E12, E24 ranges, I see overlap for each standard resistor value with the adjacent value – this makes sense because every resistor made can then be used. Here is my plot, which is crude but makes the point – note that I zoomed in a bit, so all values are not shown.

However, if you plot the range of values for the E48, E96, and E192 ranges, I see small gaps. This means that every resistor made may not fall into a standard 2% tolerance value. I show my plot for the E48 resistor series below. I zoomed in quite a bit to make things a bit clearer.

I can also demonstrate that the gaps exist using algebra, but I thought the charts illustrate the issue better.
Are there really gaps in the 2% standard resistor values?

A: Resistors are not made to random value and then sorted, they are manufactured to be close to the desired value ( a bit lower)  and then trimmed with cutters, abrasive or laser trimming) into the final value (sometimes a bit high, depending on the process), typically well within tolerance (typical error is usually less than 1/3 of the guaranteed tolerance, last I measured a bunch.
So the gaps due to rounding or whatever in the standard series are of no consequence to the manufacturers.
As such, you can get much closer than you might expect, most of the time, to the desired value by paralleling or putting in series standard values to make the nominal value very close to the exact value you want.

A: There will quite probably be - in fact you appear to have shown there are.
However you have to ask yourself if it really matters?

*

*If you need those values exactly you would go with higher tolerance (e.g. 0.5%, 0.1%, etc) resistors.

*If you are relying on tolerance to get exact resistor values, then your design can clearly cope with the resistor not being exact anyway so you pick the one which best suits your design (e.g. if you have a maximum current limit you might go for the closest one above to ensure the limit is met).

A: The gaps are due to roundoff error, e.g. for the least example in your \$\rm E\color{#C00}{48}\$ graph.
$$ 8.25 \times 1.\color{#0a0}{02} = 8.415 $$
$$ 8.66 \times 0.98 = 8.487 $$
So there is a gap between \$ 8.415\$ and \$ 8.487,\$ as your graph shows. But more exactly
$$ \overbrace{8.2540}^{\Large {10^{\frac{44}{\color{#C00}{48}}}}} \times \overbrace{1.\color{#0a0}{0243}}^{\Large{10^\frac{1}{2\cdot{\color{#C00}{48}}}}} = 8.454 $$
$$ \underbrace{8.6596}_{\Large 10^{\frac{45}{\color{#c00}{48}}}} \times 0.9757 = 8.449  $$
and now there is no gap since \$\:\: 8.449 < 8.454\$.
Notice that, more exactly, the tolerance is a slightly higher than \$2\%,\$ i.e. \$ \color{#0a0}{2.43}\%.\$
A little algebra shows that there will never be any gaps when using exact values.


text:
Q: wkhtmltopdf not preserving layout I'm trying to convert a simple HTML page with a custom grid layout (https://jsfiddle.net/nvhk3vp9/) to PDF using wkhtmltopdf 0.12.3 on Linux 64-bit with this simple command:
wkhtmltopdf index.html output.pdf

However, the resulting PDF file doesn't produce the desired result:

Am I missing something?
Edit 1:
After changing to vh and vw measure units the output has improved, however the result isn't yet as expected:

A: Have you tried to use a vh?
.col {
  float: left;
  width: 25%;
  height: 25vh;
  border: 1px solid;
  display: inline-block;
}


text:
Q: Why does my spawned thread open in the parent AppDomain instead of the current child AppDomain? We have a service that runs multiple (and varied, depending on pieces installed) assembly modules.  Each module is run in its own AppDomain because we can have multiple instances of the same assembly running, connected to different databases.
Recently I added a new module, to replace an existing, separate service.  This module is multi-threaded and also uses our inhouse, legacy logging library which is also multi-threaded.  The new module is a c# wrapper over existing unmanaged c++ code.
My problem is that the logging code stores data in the AppDomain, including the file name and location to write to, etc.  This works fine on the module's main thread, but when new threads are created they are created under the parent AppDomain, that of the service executable itself.  The parent AppDomain doesn't contain the data the logging code is looking for and so it can't write out its data.
I found an article about this stating that threads created using the old Win32 CreateThread() call would not be created in the current AppDomain and that I should use .Net threads.  That was the case with my code, so I changed my module code to use .Net threads and I am still getting the same result.
I also tried making the logging class run as a Singleton, but the spawned threads still try to pull the Singleton from the parent AppDomain, which of course doesn't have the correct data.
I really need to get this working and I have hit a wall.
Any ideas???


text:
Q: Linkage Incompatible I've got a C++ library where I'm trying to export some methods so they can be used in another C# application. At the top of my header file, I've got the following:
extern "C" {
  __declspec(dllexport) void __cdecl initSamplers();
  __declspec(dllexport) void __cdecl ldbnBNOT(const unsigned int nbPts, std::vector<Point>& samples);
}

However, my intellisense tells me that I have an error in the declaration of the ldbnBNOT method. The error states, "linkage specification is incompatible with previous "ldbnBNOT" (declared in line 79)". In this same header file, but farther down below on line 79 I have this method:
extern void __cdecl ldbnBNOT(const unsigned int nbPts,
              std::vector<Point> &samples)
{
  samples.clear();
  auto n = std::floor(std::sqrt((double)nbPts));
  Point p;

  double inv = 1.0 / n;
  unsigned mask = 128 - 1;
  unsigned shift = std::log2(128);
  for (unsigned Y = 0; Y < n; Y++) {
    for (unsigned X = 0; X < n; X++) {
      unsigned index = ((Y & mask) << shift) + (X & mask);
      double u = phi( (Y & 0xfffffff0) + (lutLDBN_BNOT[index] & 0xf) );
      double v = phi( (X & 0xfffffff0) + (lutLDBN_BNOT[index] >> 4) );
      p[0] = inv * (X + u);
      p[1] = inv * (Y + v);
      samples.push_back(p);
    }
  }
}

The signature in the __cdecl ldbnBNOT matches the same signature as the extern method... But I don't understand why I'm still getting this linker error.


text:
Q: What does " get off relatively lightly" mean in this sentence? This is a sentence from a report in the Economist.

Children who rebel may be threatened with being sent to stay with family in China, and they know from relations there that teenagers in America, even Asian ones, get off relatively lightly compared with those in China.

What does "get off relatively lightly" mean in this sentence?

A:
get off
Escape a punishment; be acquitted

http://www.oxforddictionaries.com/definition/english/get-off?q=get+off
Get off relatively lightly means there was some punishment, but not as much you might expect.
In your example, the phrase means that American teenagers aren't punished as harshly as Chinese teenagers for rebelling.

A: "teenagers in America, even Asian ones, get off relatively lightly compared with those in China" means that how teen rebellions in America are dealt with is less serious than in China.
Phrasal verbs like "get off" annoy non-native speakers of English to no end, since other languages use different structures to convey their meanings, and the phrasal verbs' meanings can vary by context.


text:
Q: How should I create a Clang NamedDecl instance? As a learning exercise, I am trying to build a C++ AST in code using the Clang classes directly.
The NamedDecl constructor is protected.
How can I create a NamedDecl instance?

A: The NamedDecl is used by Clang as a base class for more specific decls that are named (e.g. ValueDecl, TypeDecl, ...) which are still mostly base classes for more specific Decl kinds. Thus Clang doesn't want you to create a NamedDecl directly and urges you to create something more specific.
If for example the decl you want to create an object for represents a class you should create a RecordDecl or a XCCRecordDecl.
Of course you can circumvent this mechanism by deriving from clang::NamedDecl and making the constructor of the derived class public.


text:
Q: citation color bracket, \Cref{equation}, doi with url in reference list \documentclass[5p]{elsarticle}

\begin{filecontents*}{mybibfile.bib}
@article{allik_hughes_1,
  title   = "Finite element method for piezoelectric vibration",
  journal = "Int J Numer Meth Engng",
  year="1970",
  volume="2",
  number="1--2",
  pages   = "151--157",
  doi     = "10.1002/nme.1620020202",
  author  = "{Allik H, Hughes TJR}"
}

@article{allik_hughes_2,
  title   = {Vibrational response of sonar transducer using piezoelectric finite elements},
  journal = "J Acoust Soc Am ;",
 year="1970",
  volume="2",
 number="1--2",
  pages   = "151--157",
  doi     = "10.1121/1.1903513",
  author  = "{Allik H, Kenneth MW, John TH}"
}

@article{Fish,
  title   = "Modeling and simulation of piezocomposites",
  journal = "Comput Meth Appl Mech and Engng",
  year="1970",
  volume="2",
  number="1--2",
  pages   = "151--157",
  pages   = ":3211 -- 3232",
  doi     = "10.1016/S0045-7825(03)00343-8",
  author  = "{Fish J, Chen W }"
}
\end{filecontents*}

\usepackage{hyperref}
\hypersetup{colorlinks = true, allcolors = cyan}
\usepackage[nameinlink,noabbrev]{cleveref}

\Crefformat{figure}{#2Fig.~#1#3}
\Crefmultiformat{figure}{Figs.~#2#1#3}{ and~#2#1#3}{, #2#1#3}{ and~#2#1#3}

\usepackage{lineno}
\modulolinenumbers[5]

\journal{Journal of \LaTeX\ Templates}

\usepackage{subfig}
\usepackage{float}
\usepackage{graphicx}
\usepackage{color}
\usepackage{pgf,tikz}
\usepackage{multirow}

\usepackage{amsmath,amsfonts,amsthm,bm}
\bibliographystyle{elsarticle-num}

\begin{document}
\hypersetup{allcolors = cyan}

\captionsetup[figure]{labelfont={bf},labelformat={default},labelsep=period,name={Fig.}}%used to ref Figure 1: to Fig.1.

\section{Introduction}

In  \Cref{figure}, in ref \cite{allik_hughes_1,allik_hughes_2,Fish}, in \Cref{table}  and in equation Eq. \ref{equation}

\begin{align}
M=\frac{a{b}c}{2}. dE, \label{equation}
\end{align}

\begin{figure}[H]
\centering
  \includegraphics[height=1.0 in, width=2.0 in]{bimorph.png}
\caption{Static deflection of the bimorph actuator: Accuracy analysis} \label{figure}.
\end{figure}

\begin{table}[H]
%\begin{table}[H]
\caption{Accuracy : Static } \label{table}
\centering
\begin{tabular}{c c c c c c}
\hline
\multirow{3}{*}{none} &\multicolumn{2}{c}{none}\\ \cline{2-3}&a($\mu$m)&relative error[\%]\\ \cline{2-3} \cline{4-5}
&b&b\\
\hline
1000&1000&100& \\
\hline
\end{tabular}
%\end{table}
\end{table}

\section*{References}
\bibliography{mybibfile}

\end{document}

I would like to get color brackets when I cite these reference.
Why doi does not appear in the Reference list. How can I include the URL of the doi?
Also, is it possible to use \Cref{equation}? I tried \Cref{equation}, but it did not work for me. Therefore I am using Eq.\ref{equation}.

A: Concerning your question about \cref{equation}:
cleverref should be loaded last, in particular it has to be loaded after amsmath.
\documentclass[5p]{elsarticle}

\usepackage{amsmath,amsfonts,amsthm,bm}

\usepackage{hyperref}
\hypersetup{colorlinks = true, allcolors = cyan}
\usepackage[nameinlink,noabbrev]{cleveref}

\begin{document}
\hypersetup{allcolors = cyan}

\Cref{nameequation}

\begin{align}
M=\frac{a{b}c}{2}. dE, \label{nameequation}
\end{align}

\end{document}

Colouring the citation bracket
Based on Biblatex square brackets color you could do:
\documentclass[5p]{elsarticle}

\usepackage{filecontents}
\begin{filecontents*}{mybibfile.bib}
@article{allik_hughes_1,
  title   = "Finite element method for piezoelectric vibration",
  journal = "Int J Numer Meth Engng",
  year="1970",
  volume="2",
  number="1--2",
  pages   = "151--157",
  doi     = "10.1002/nme.1620020202",
  author  = "{Allik, H and Hughes, T J R}"
}

@article{allik_hughes_2,
  title   = {Vibrational response of sonar transducer using piezoelectric finite elements},
  journal = "J Acoust Soc Am",
 year="1970",
  volume="2",
 number="1--2",
  pages   = "151--157",
  doi     = "10.1121/1.1903513",
  author  = "{Allik, H and Kenneth, M W and John, T H}"
}

@article{Fish,
  title   = "Modeling and simulation of piezocomposites",
  journal = "Comput Meth Appl Mech and Engng",
  year="1970",
  volume="2",
  number="1--2",
  pages   = "151--157",
  pages   = "3211 -- 3232",
  doi     = "10.1016/S0045-7825(03)00343-8",
  author  = "{Fish, J and Chen, W}"
}
\end{filecontents*}

\usepackage{hyperref}
\hypersetup{colorlinks = true, allcolors = cyan}
\usepackage[nameinlink,noabbrev]{cleveref}
\usepackage{color}
\bibliographystyle{elsarticle-num}

\bibpunct{\color{cyan}[}{\color{cyan}]}{,}{n}{}{;}

\begin{document}

\hypersetup{allcolors = cyan}

\cite{allik_hughes_1,allik_hughes_2,Fish},
\bibliography{mybibfile}

\end{document}