text:
Q: Iterm2: Automate sending text to shell upon start Using profiles you can send text to the shell at the start of a session, under "send text at start". I'd like to do this 3 times in succession, but it looks like there's only one string allowed. Does anyone know of any other way to do this using iterm2? I believe I can use applescript but I'd rather be able to start a session using iterm2 directly.
Ex:
<terminal session starts>
ssh server
send "asdf"
send "qwer"
send "zxcv"
(done...)

The reason why I can't simply set a profile to do this is that my work has a special environment that usually asks 3 questions. I want to automate answering these 3 questions and set them to the iterm2 profile config under "send text at start".

A: There's a tool called Expect that does generalized handshaking and communication that you could use, however, iTerm2 can do some of what Expect does straight from the Advanced tab.
Note:  Expect is written in TcL, an awesome language to know in its own right.  This particular question is probably spelled out with a nicely commented answer in an Expect FAQ somewhere.  Also, if you chose to implement a solution with Expect over iTerm2, you can use that solution on more than your OSX host.  So think about that trade up front.  In the short-term, the iTerm2 Triggers option will do the trick for you.
So, to provide some of what Expect provides straight from iTerm2, goto the Advanced tab. There you will find the Triggers capability.  From there you can add "+" a specific trigger rule.  In a nutshell, what these triggers (and Expect) allow you to do is filter all text to and from the Terminal, match that text against the user specified regular expressions (ReEx) trigger, and when that ReEx is matched in the Terminal's text stream, iTerm2 will perform a user specified task.
Here's one trigger rule that will match a line containing exactly one word, Password, and then Send Text: My Password.

Keep in mind that the Terminal Text stream contains unseen characters, and specifying the exact ReEx to match can be a challenge, especially, for instance, because different servers implement different line separators, and if a ReEx specifically uses one, it can not match for no apparent reason.
One thing:  I'm thinking about why you may be asking this question?  Not sure of what you are familiar with, but if you want to auto-login via ssh, add a comment, and setting that up is a piece of cake.  If you are invested in this, search for keywords "ssh-keygen" and "generate rsa public keys for ssh."
I know this is a comment, but I thought I'd throw this out there since I already have the space - for what it is worth:
I think one would use the Send text at start: to set environment variables which are relevant to the remote host session.  For instance, I used this method to pass parameters to my remote processes as a means of passing parameters through environment variables.  I'm not certain, but that would be a use of that Command field to tailor what happens when a particular ssh userid@hostname is run.
See the second answer at Is it possible to get SSH to forward empty arguments? for the full example, but it all boils down to the following syntax:
$ ssh me@localhost 'VAR1="var1 text" /tmp/try.pl'

I hypothesize that one potential use of the Send text at start: option is to provide the VAR1="var1 text" /tmp/try.pl, or simply, the VAR="var1 text" to the remote process's environment.
Here's a more concrete example from scratch using a Dual-G5 Mac host named, r2d2:
Here's how I set up r2d2's profile:

Now when I kick of an r2d2 iTerm2, and echo $FRED, is see that any command I would have invoked a la the ssh could examine the environment and determine a context for execution:

Of course, this is speculation given what I've experienced, so it is just one possibility.  I now know that I'll be able to exploit this control path, so thanks for the question.

A: You can also have a script like ~/test.py
#!/usr/local/bin/python3

print("echo hello world")

And then execute this script as a co-process in iTerm2 menu Session->Run Co-Process, and specifying the script as ~/test.py
I think its necessary to make you script executable (though I haven't tried otherwise), chmod +x ~/test.py.
Happy coding!


text: Q: Is each multiplicative linear functional on $L^1(SL(2,R):SO(2,R))$ is triviall? We know that if $G=SL(2,R)$ and $H=SO(2,R)$ as a compact subgroup of $G$, then $\{\xi \in \hat{G}; \xi|_H=1\}$is triviall. Can we conclude that  each multiplicative linear functional on $\{f\in L^1(G); R_\xi f=f(a.e)\forall \xi \in H\}$ is triviall, too?

redpajama_set_name: RedPajamaStackExchange


text:
Q: Detect handle change inside componentDidUpdate method - Reactjs I have a form that contains several questions. Some of the questions contains a group of subquestions.
The logic to render sub questions is written inside componentDidUpdate method.
  componentDidUpdate = (prevProps, prevState, snapshot) => {
    if (prevProps !== this.props) {
      let questions = this.props.moduleDetails.questions,
          sgq       = {};

      Object.keys(questions).map((qId) => {
        sgq[qId] = (this.state.groupedQuestions[qId]) ? this.state.groupedQuestions[qId] : [];
        let answerId = this.props.formValues[qId],
            questionObj = questions[qId],
            groupedQuestions = [];
        if(questionObj.has_grouped_questions == 1 && answerId != null && (this.state.groupedQuestions != null)) {
          groupedQuestions = questions[qId].question_group[answerId];

          let loopCount = this.getLoopCount(groupedQuestions);

            for(let i=0; i<loopCount; i++) {
              sgq[qId].push(groupedQuestions);
            }
        }
      });

      this.setState({groupedQuestions: sgq});
    }
  }

The problem is that on every key stroke of text field, handleChange method is invoked which will ultimately invoke componentDidUpdate method. So the same question groups gets rendered on every key stroke.
I need a way to detect if the method componentDidUpdate was invoked due to the key press(handleChange) event so that i can write logic as follows.
if(!handleChangeEvent) {
    Logic to render question group
}

Any idea on how to integrate this will be appreciated.

A: I assume your textfield is a controlled component, meaning that its value exists in the state. If this is the case, you could compare the previous value of your textfield to the new one. If the value is different, you know the user entered something. If they are equal however, the user did something else at which point you want your snippet to actually execute.
Basically:
componentDidUpdate = (prevProps) => {
  // if value of textfield didn't change:
  if (prevProps.textfieldValue === this.props.textfieldValue) {
    // your code here
  }
}

Another approach is to use componentDidReceiveProps(). There you can compare the props to the previous ones, similarly to the above, and execute your code accordingly. Which method is most suitable depends on how your app works.


text:
Q: Guava's Optional.toJavaUtil() as method reference I'm stuck trying to pass Optional.toJavaUtil() as method reference to a map method (either Optional.map() and Stream.map()).
The simplified example of my code:
aLegacyService.getGuavaOptional()
    .toJavaUtil()
    .map(MyPojo::getAnotherGuavaOptional)
    .flatMap(Optional::toJavaUtil);    // <-- This doesn't compile

The compiler gives me a cryptic error:
Error:(177, 72) java: invalid method reference
  non-static method toJavaUtil() cannot be referenced from a static context

I think the reason is that there are 2 methods: instance method and static method, both with the same name. If I use lambda syntax, both variants work fine:
.flatMap(opt -> opt.toJavaUtil())            // This is OK
// and
.flatMap(opt -> Optional.toJavaUtil(opt));   // Also OK

Q: Is there a way to make this work with method reference? (e.g. by somehow specifying which of two methods I want to use?)


text:
Q: Debugging Python SAML assertion validation A similar question has been asked before, but no information was provided on ho to debug.
If I am working with this code:
from lxml import etree
import base64
from M2Crypto import EVP, RSA, X509

decoded_assertion = base64.b64decode(assertion)

root = etree.XML(decoded_assertion)
signature_node = root.find('{http://www.w3.org/2000/09/xmldsig#}Signature')
signature_value = signature_node.find('{http://www.w3.org/2000/09/xmldsig#}SignatureValue').text
signed_info = signature_node.find('{http://www.w3.org/2000/09/xmldsig#}SignedInfo')
signed_info_string_c14n = etree.tostring(signed_info,method="c14n")

certificate_node = root.find('{http://www.w3.org/2000/09/xmldsig#}Signature')\
        .find('{http://www.w3.org/2000/09/xmldsig#}KeyInfo')\
        .find('{http://www.w3.org/2000/09/xmldsig#}X509Data')\
        .find('{http://www.w3.org/2000/09/xmldsig#}X509Certificate')

x509 = X509.load_cert_string(base64.decodestring(certificate_node.text), X509.FORMAT_DER)
pubkey = x509.get_pubkey().get_rsa()

verify_EVP = EVP.PKey()
verify_EVP.assign_rsa(pubkey)
verify_EVP.reset_context(md='sha256')
verify_EVP.verify_init()
verify_EVP.verify_update(signed_info_string_c14n)
result = verify_EVP.verify_final(signature_value.decode('base64'))

print result

Is there any way to tell verify_EVP.verify_final to do more than just return 0 when validation fails? I have no idea on where to begin to debug.

A: I have faced the problem of verifying SAML assertions cryptographically in Python, and found no good ready-made solution from m2crypto (which, as far as I know, is unmaintained, unsupported, and not Python 3 compatible) nor in other libraries. So I wrote my own library, SignXML (https://github.com/kislyuk/signxml). Here is the basic pattern of verifying a SAML assertion with it:
from lxml import etree
from base64 import b64decode
from signxml import xmldsig

with open("metadata.xml", "rb") as fh:
    cert = etree.parse(fh).find("//ds:X509Certificate").text

assertion_data = xmldsig(b64decode(assertion_body)).verify(x509_cert=cert)


text:
Q: How to cancel a running query in java persistence? My application runs using Persistence API, Hibernate and Spring. I am using MySql DB.
There are some queries which might take a lot of time to compute, so I need a cancel button to cancel the execution of these queries.
I found out that there is a memthod java.sql.statement.cancel() which is used to cancel a query, but this can be accesssed from the statement object, how to do this from the entityManager object in Java persistence ?

A: You can use hibernate session objects CancelQuery() method.
Also if you want to automate this, you can set the query timeout.
JPA 2 defines the javax.persistence.query.timeout hint to specify default timeout in milliseconds. (Available since Hibernate 3.5 )
JPA provides javax.persistence.query.timeout hint to specify query timeout in milliseconds. This hint can be specified in @NamedQuery or @NamedNativeQuery. It can also be specified on the Query or TypedQuery by calling the setHint method. The query timeout defined by the hint can be overridden by the setHint method.
The default query timeout can be specified for an application in persistence.xml as shown below:
<persistence-unit name="PU" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <properties>
        ...
       <property name="javax.persistence.query.timeout"
        value="30" />
     </properties>
 </persistence-unit>


text:
Q: Need sample jboss-web.xml for jboss-6.4.8 version We have recently upgraded our application from JBoss 5 to JBoss 6.4.8 version.
In JBoss 5 version, We were using the jboss-web.xml which has following attributes defined

<security-domain flushOnSessionInvalidation="true"/>
<use-session-cookies>true</use-session-cookies>

The same jboss-web.xml is not working with jboss 6 version.I need the sample jboss-web.xml and also wants to know how we can set the above attributes in the jboss 6 version.Any help on this will be greatly appreciated.

A: Have a look at $JBOSS_HOME/docs/schema/ there should be all deployment descriptors available as xsd. And yes flushOnSessionInvalidation no longer is part of jboss-web.xml. But i think they fixed it with EAP Versions 7.0.8.CR1, 7.0.8.GA. Have a look at JBEAP-11895
As for your problem have a look at this answer.
In the comments section of WFLY-3221 is also an example.


text:
Q: How can I define an UUID for a class, and use __uuidof, in the same way for g++ and Visual C++? Note: This is a question-with-answer in order to document a technique that others might find useful, and in order to perhaps become aware of others' even better solutions. Do feel free to add critique or questions as comments. Also do feel free to add additional answers. :)

Visual C++ has always had a language extension __uuidof(classname) that can retrieve an UUID, a 128 bit Universally Unique Identifier, provided that the UUID's been associated with the class via __declspec, which also is a Visual C++ language extension:
#include <guiddef.h>        // GUID, another name for UUID

class
    __declspec( uuid( "290ff5cb-3a21-4740-bfda-2697ca13deae" ) )
    Foo
{};

#include <iostream>
using namespace std;

auto main()
    -> int
{
    cout << hex << __uuidof( Foo ).Data1 << endl;   // 290ff5cb
}

MinGW g++ 4.8.2 (and possibly some earlier versions) supports __uuidof, but it does not support MSVC's __declspec. Compiling the above with g++ 4.8.2 therefore fails, at least with the Nuwen distribution that I use. First g++ issues the warning "'uuid' attribute directive ignored", and then one gets a linker error "undefined reference to _GUID const& __mingw_uuidof<Foo>()".
The error hints at the way an UUID is associated with a class for g++, namely by specializing the function template __mingw_uuidof for the class.
Unfortunately the UUID specification is then of a form that's radically different from the Visual C++ form. It's numbers, not a string. And it's not tucked in after the class or struct keyword, but follows a declaration of the class:
#include <guiddef.h>        // GUID, another name for UUID

class Foo {};

template<>
auto __mingw_uuidof<Foo>()
    -> GUID const&
{
    static const GUID the_uuid =
    {
        0x290ff5cb, 0x3a21, 0x4740,
        { 0xbf, 0xda, 0x26, 0x97, 0xca, 0x13, 0xde, 0xae }
    };
    return the_uuid;
}

#include <iostream>
using namespace std;

auto main()
    -> int
{
    cout << hex << __uuidof( Foo ).Data1 << endl;   // 290ff5cb
}

How can one associate an UUID with a class so that it will work with both compilers' __uuidof, without redundancy, and preferably with the UUID as a direct sequence of digits (as with Visual C++)?

A: Up-front disclaimer: nothing of this has been extensively tested or reviewed. I just wrote it.
One possible unification approach is suggested by this fact:

*

*A Visual C++ __declspec( uuid ) doesn't need to be provided with the first declaration of a class: it can be applied after the first declaration.

E.g. Visual C++ code can look like this:
class Foo
{};

class  __declspec( uuid( "290ff5cb-3a21-4740-bfda-2697ca13deae" ) ) Foo;

Thus a which-compiler-is-it sniffing macro CPPX_UUID_FOR can be defined as …
#if !defined( CPPX_UUID_FOR )
#   if defined( _MSC_VER )
#       define CPPX_UUID_FOR    CPPX_MSVC_UUID_FOR
#   elif defined( __GNUC__ )
#       define CPPX_UUID_FOR    CPPX_GNUC_UUID_FOR
#   endif
#endif

and be invoked after the first declaration of the class:
#include <iostream>
using namespace std;

struct Foo {};
CPPX_UUID_FOR( Foo, "dbe41a75-d5da-402a-aff7-cd347877ec00" );

void test()
{
    using cppx::uuid::operator<<;
    cout << setw( 20 ) << "__uuidof: " << __uuidof( Foo ) << endl;
}

The macro implementation for Visual C++ is trivial:
#define CPPX_MSVC_UUID_FOR( name, spec )    \
    class __declspec( uuid( spec ) ) name

The macro implementation for g++ is a bit more involved:
#define CPPX_GNUC_UUID_FOR( name, spec )    \
template<>                                  \
inline                                      \
auto __mingw_uuidof<name>()                 \
    -> GUID const&                          \
{                                           \
    using cppx::operator"" _uuid;           \
    static constexpr GUID the_uuid = spec ## _uuid; \
                                            \
    return the_uuid;                        \
}                                           \
                                            \
template<>                                  \
inline                                      \
auto __mingw_uuidof<name*>()                \
    -> GUID const&                          \
{ return __mingw_uuidof<name>(); }          \
                                            \
static_assert( true, "" )

… where the static_assert only serves to support a final semicolon in the invocation.
The user defined literal is not strictly necessary, but I thought it was interesting to do it.
cppx::operator"" _uuid is defined thusly, in namespace cppx:
namespace detail {
    CPPX_CONSTEXPR
    auto uuid_from_spec( char const* const s, size_t const size )
        -> cppx::Uuid
    {
        return (
            size == 36?   cppx::uuid::from(
                    reinterpret_cast<char const (&)[37]>( *s )
                            ) :
            cppx::fail(
                "An uuid spec must be 36 chars, like"
                " \"dbe41a75-d5da-402a-aff7-cd347877ec00\""
                )
            );
    }
}  // namespace detail

#if !(defined( _MSC_VER ) || defined( NO_USER_LITERALS ))
CPPX_CONSTEXPR
auto operator"" _uuid( char const* const s, size_t const size )
    -> cppx::Uuid
{ return detail::uuid_from_spec( s, size ); }
#endif

where cppx::uuid::from is defined earlier in namespace cppx::uuid:
inline CPPX_CONSTEXPR
auto from( char const (&spec)[37] )
    -> Uuid
{ return Initializable( ce, spec ); }

where ce is just a constructor tag, of enumeration type Const_expr, that selects the constexpr constructor of the uuid::Initializable class:
struct Initializable: Uuid
{
    explicit CPPX_CONSTEXPR
    Initializable( Const_expr, char const (&spec)[37] )
        : Uuid( {
                // Data1
                (((((((((((((
                    static_cast<unsigned long>( nybble_from_hex( spec[0] ) )
                    << 4) | nybble_from_hex( spec[1] ))
                    << 4) | nybble_from_hex( spec[2] ))
                    << 4) | nybble_from_hex( spec[3] ))
                    << 4) | nybble_from_hex( spec[4] ))
                    << 4) | nybble_from_hex( spec[5] ))
                    << 4) | nybble_from_hex( spec[6] ))
                    << 4) | nybble_from_hex( spec[7] ),
                // Data2
                static_cast<unsigned short>(
                    (((((
                        static_cast<unsigned>( nybble_from_hex( spec[9] ) )
                        << 4) | nybble_from_hex( spec[10] ))
                        << 4) | nybble_from_hex( spec[11] ))
                        << 4) | nybble_from_hex( spec[12] )
                    ),
                // Data 3
                static_cast<unsigned short>(
                    (((((
                        static_cast<unsigned>( nybble_from_hex( spec[14] ) )
                        << 4) | nybble_from_hex( spec[15] ))
                        << 4) | nybble_from_hex( spec[16] ))
                        << 4) | nybble_from_hex( spec[17] )
                    ),
                // Data 4
                {
                    static_cast<unsigned char>( byte_from_hex( spec[19], spec[20] ) ),
                    static_cast<unsigned char>( byte_from_hex( spec[21], spec[22] ) ),
                    static_cast<unsigned char>( byte_from_hex( spec[24], spec[25] ) ),
                    static_cast<unsigned char>( byte_from_hex( spec[26], spec[27] ) ),
                    static_cast<unsigned char>( byte_from_hex( spec[28], spec[29] ) ),
                    static_cast<unsigned char>( byte_from_hex( spec[30], spec[31] ) ),
                    static_cast<unsigned char>( byte_from_hex( spec[32], spec[33] ) ),
                    static_cast<unsigned char>( byte_from_hex( spec[34], spec[35] ) )
                }
            } )
    {}

    explicit
    Initializable( char const (&spec)[37] )
        : Uuid()
    {
        for( int i = 0;  i < 8;  ++i )
        {
            Uuid::Data1 = (Uuid::Data1 << 4) | nybble_from_hex( spec[i] );
        }
        assert( spec[8] == '-' );
        for( int i = 9;  i < 13;  ++i )
        {
            Uuid::Data2 = (Uuid::Data2 << 4) | nybble_from_hex( spec[i] );
        }
        assert( spec[13] == '-' );
        for( int i = 14; i < 18;  ++i )
        {
            Uuid::Data3 = (Uuid::Data3 << 4) | nybble_from_hex( spec[i] );
        }
        assert( spec[18] == '-' );
        for( int i = 19; i < 23;  i += 2 )
        {
            Uuid::Data4[(i - 19)/2] = byte_from_hex( spec[i], spec[i + 1] );
        }
        assert( spec[23] == '-' );
        for( int i = 24; i < 36;  i += 2 )
        {
            Uuid::Data4[2 + (i - 24)/2] = byte_from_hex( spec[i], spec[i + 1] );
        }
    }
};

The two constructors mainly differ in how easy it is to judge the correctness or not of the code, but the last one (I wrote that first!) also has useful assert statements. I'm not sure how to best do such assertions for the constexpr constructor. Or even whether that is doable, which is one reason why there are two constructors instead of just one.
Oh, the << invocations here are just good old left-shifts, not fancy custom operator-notation output or stream or store operations. :)

The definitions of nybble_from_hex and byte_from_hex are pretty trivial, but the fail function is a bit subtle. In spite of appearances it's not  a constexpr function. Instead, it's a non-returning function. C++11 has a notation to express that, [[noreturn]], but as far as I know neither Visual C++ nor g++ supports that yet. So instead I use compiler specific annotations, like this:
#if !defined( CPPX_NORETURN )
#   if defined( _MSC_VER )
#       define CPPX_NORETURN    __declspec( noreturn )
#   elif defined( __GNUC__ )
#       define CPPX_NORETURN    __attribute__((noreturn))
#   else
#       define CPPX_NORETURN    [[noreturn]]
#   endif
#endif

and then fail can be coded up simply as e.g.
struct Whatever
{
    template< class Type >
    CPPX_CONSTEXPR operator Type () const { return Type(); }
};

inline
CPPX_NORETURN
auto fail( string const& s )
    -> Whatever
{ throw runtime_error( s ); }

I found it non-trivial (and possibly impossible) to express fail as a constexpr function when it has std::string argument, and as an ordinary function calls of it suppressed the constexpr property. The non-returning variant works OK with g++. However, I'm not sure what the standard has to say about this.


text:
Q: How to add a Floating Action Button, without AppCompat? I'm looking to make a new app, using only API 21.
To follow the Material Design, I'm trying to use a FAB, but I cannot find any decent information on how to use the one now included in the Design Library.
So far, I have added the library the the build.gradle file, and added a FAB to my view (code below)
<android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:src="@android:drawable/ic_menu_add"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        app:elevation="5dp"
        app:borderWidth="0dp"
        app:fabSize="mini"/>

(This is in a RelativeLayout)
When I launch the app, I get:

android.view.InflateException: Binary XML file line #15: Error
  inflating class android.support.design.widget.FloatingActionButton

I found one answer on SO that says I need to use an AppCompat theme, but I'd rather just use pure Material/API21 stuff.
How can I use a FAB without AppCompat (support libraries)?

A: The FAB is built into the new Design Compat library - which will work on devices as early as API 7.  You will need to include it as a dependency to use it (and shouldn't hesitate to do so).
If you want to avoid using a library (or any external code) you will need to draw the FAB yourself (using a Shape Drawable).
Bottom line, using the Design Compat lib is the preferred method for supporting a FAB, and you should use it.  The Design Compat lib IS the "pure/Material API21 stuff".
There is NOT a FAB implementation implemented for any API other then the one in the Design support lib.  You have to include the lib, or implement the code entirely yourself.
The Design lib has a dependency on AppCompat, so if you are planning on using the native fab, you will also need to include the dependency for AppCompat.
From the official blog post: "Note that as the Design library depends on the Support v4 and AppCompat Support Libraries, those will be included automatically when you add the Design library dependency."

A: The Material Design library has a dependency with AppCompat.
Check the @Booger answer. It reports the official blog.
How to use a FAB.
Add the dependency to your build.gradle:
compile 'com.android.support:design:22.2.0'

Just add the FAB to your design:
<android.support.design.widget.FloatingActionButton
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|right"
            android:src="@drawable/ic_add"
            android:layout_marginBottom="@dimen/fab_margin_bottom"
            android:layout_marginRight="@dimen/fab_margin_right"
            app:elevation="6dp"
            app:borderWidth="0dp"
            app:fabSize="normal" />

Currently there are some bugs.
You have to define app:borderWidth="0dp" to display the shadow with API21+.
Also you have to define different margins for API 21+ and older devices.
res/values/dimens.xml
<dimen name="fab_margin_right">0dp</dimen>
<dimen name="fab_margin_bottom">0dp</dimen>

res/values-v21/dimens.xml
<dimen name="fab_margin_right">16dp</dimen>
<dimen name="fab_margin_bottom">16dp</dimen>

FAB uses the accent color and you could override with app:backgroundTint attribute.
Finally you can set a ClickListener with:
fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        //do something
    }
});

A: Actually I was having the same problem. The solution was quite simple:
you have to define app:rippleColor="@color/colorPrimary"
and you can use a FAB without using Appcompat Themes and Activities. Of course you have to include  compile 'com.android.support:support-v4:25.3.1' and compile 'com.android.support:design:25.3.1'
but you DO NOT have to use AppCompatActivity and those Themes.
   <android.support.design.widget.FloatingActionButton
    android:id="@+id/action_add_palette"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="16dp"
    android:src="@android:drawable/ic_input_add"
    app:rippleColor="@color/colorPrimary" />

A: There is also several popular libraries on GitHub like:
FloatingActionButton which can expand/collapse as menu to reveal multiple actions.

A: I would say that although you intend to make your app available on API21 only but I encourage you to implement your application using Android Support Library AppCompat-v7 anyway. There are a lot of benefits you will get.
Anyway it is your choice. Just my suggestion. But if you are convinced. Or check out this full tutorial about how to use Android Design Support Library. http://inthecheesefactory.com/blog/android-design-support-library-codelab/en
Hope this help


text:
Q: onClick from Header component to call function from Other component and render Reactjs I am using Reactjs to make pagination and problem I got is that I cannot back to home page if currentPage is changed.
My code structure of Body component like this:
componentDidMount() {
 .....
}
componentDidUpdate() {
 ....
}
onPageChanged() {
....
   this.setState({
        pageChanged: true,
        currentPage: currentPage //1,2,3...
   });
}

render(){
  return(..)
}

When onePageChanged if I click to Home route, It does not reflect anything. How I can set componentDidUpdate to return the first page if I click on Header?
my Header component:
<h1 className="site-title">
   <Link to={CelestialSettings.path}>My Website</Link>
</h1>

I am thinking about using onClick on Header component like this:
<Link onClick={backhomepage()}>My Website</Link>
but I do not know how use.
Any suggestion? Thank you so much.


text:
Q: iterate through null terminated array I want to iterate through null terminated structure array.
While loop works fine, but when I try to access any structure fields I get "segfault" in response. What am I doing wrong?
PS I know that it is possible to determine array size and use simple "for" construction. I just want to figure out the source of the problem.
PSS Ok, if array initialization is wrong - how to do it correctly?
#include <stdio.h>
#include <stdlib.h>

typedef struct demo
{
    int a;
    int b;
    int c;
} demo;

demo * fieldDefinitions[] =
{
  { 1 , 1,  1 },
  { 2 , 2,  2 },
  { 3 , 3,  3 },
  NULL
};

int main()
{
    demo ** ptr = fieldDefinitions;
    printf( "Array: %d \n", &fieldDefinitions );

    while ( *ptr != NULL )
    {
        printf( "ptr: %d \n", ptr );
        printf( "ptr: %d \n", (**ptr).a ); // <--- problem here
        ptr++;
    }

    return 0;
}

A: As the others already've pointed out: Listen to your compiler, a standard conforming implementation must complain about:
demo * fieldDefinitions[] =
{
    { 1 , 1,  1 }, // <-- note that this is not a pointer to a demo.
    { 2 , 2,  2 },
    { 3 , 3,  3 },
    NULL
};

Also, use p as the printf format specifier for pointers, not d (which is for integer types).
You need pointers to demo objects, so these objects need to be created somehow, so that we can take their addresses. C99 added a feature called compound literals (looking somewhat similar to a cast, however, they are something different) creating unnamed objects:
#include <stdio.h>
#include <stdlib.h>

typedef struct demo
{
    int a;
    int b;
    int c;
} demo;

demo * fieldDefinitions[] =
{
    &(demo){ 1 , 1,  1 },
    &(demo){ 2 , 2,  2 },
    &(demo){ 3 , 3,  3 },
    NULL
};

int main()
{
    demo ** ptr = fieldDefinitions;
    printf( "Array: %p \n", (void *)&fieldDefinitions );

    for ( ; *ptr != NULL; ptr++ )
    {
        printf( "ptr: %p\n", (void *)ptr); // I'm not sure, what you really wanted ...
        printf( "*ptr: %p\n", (void *)*ptr ); // ... but I think you meant this
        printf( "ptr: %d\n", (*ptr)->a ); // or (**ptr).a, whatever you prefer
    }

    return 0;
}

The lifetime of an object created via a compound literal is that of the enclosing block or static if used in an initializer for an identifier with static storage duration (as in this example).
HTH

A: demo * fieldDefinitions[ 4 ] =
{
  { 1 , 1,  1 },
  { 2 , 2,  2 },
  { 3 , 3,  3 },
  NULL
};

You can't do that, as you can not do:
int *arr[] = {1, 2, 3, NULL};

Turning your warnings on you get:
initialization makes pointer from integer without a cast

If you want to use pointer arithmetic you can do somenting like:
#include <stdio.h>
#include <stdlib.h>

typedef struct demo
{
    int a;
    int b;
    int c;
} demo;

demo fieldDefinitions[] = {
    { 1 , 1,  1 },
    { 2 , 2,  2 },
    { 3 , 3,  3 },
};

int main(void)
{
    demo *ptr = fieldDefinitions;
    demo *end = &fieldDefinitions[sizeof(fieldDefinitions) / sizeof(fieldDefinitions[0]) - 1];

    do {
        printf( "ptr: %p \n", (void *)ptr);
        printf( "ptr: %d \n", ptr->a);
    } while (ptr++ < end);

    return 0;
}

A: demo * fieldDefinitions[] =
{
  { 1 , 1,  1 },
  { 2 , 2,  2 },
  { 3 , 3,  3 },
  NULL
};

you are claiming that fieldDefinitions will be an array of demo object pointers, but instead you are giving objects themselves.This is the way you initialize an array of structures (except NULL at the end). If your array is static then i suggest creating array of demo with known size such as
unsigned const int fieldDefinitions_size = 3;
demo fieldDefinitions_arr[fieldDefinitions_size] = {
    {1,1,1},
    {2,2,2},
    {3,3,3}
};

And iterate by using fieldDefinitions_size.
Or if you insist on having demo pointer array then you can individually allocate memory for each demo object and assign addresses to fieldDefinitions array. This thread will be useful.


text:
Q: ios- sqLite not deleting rows I am trying to delete all the rows in database for that I wrote following codes ..
- (id)init {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *databasePath = [documentsDirectory stringByAppendingPathComponent:@"dataBase.sqlite3"];
    bool databaseAlreadyExists = [[NSFileManager defaultManager] fileExistsAtPath:databasePath];
    if (!databaseAlreadyExists){
        NSString *databasePathFromApp = [[NSBundle mainBundle] pathForResource:@"dataBase" ofType:@"sqlite3"];
        [[NSFileManager defaultManager] copyItemAtPath:databasePathFromApp toPath:databasePath error:nil];
    }
    if (sqlite3_open([databasePath UTF8String], &_database) == SQLITE_OK){
    }
    return self;
}
-(void)deleteAll{
    NSString *query = @"DELETE FROM user_info";
    sqlite3_stmt *statement = nil;
    if (sqlite3_prepare_v2(_database, [query UTF8String], -1, &statement, nil) == SQLITE_OK) {
        NSLog(@"Should delete..");
    }
    sqlite3_finalize(statement);
    sqlite3_close(_database);
}

But when I rebuild the app data data appears. Whats wrong I am doing?

A: Try a conditional if:
if(sqlite3_prepare_v2(database, sql, -1, &deletestmt, NULL) != SQLITE_OK)

A: You never call sqlite3_step to actually execute the query.
Also, you close the database in the wrong place. Your close should be done opposite of the open.

A: First of all, get the database path after that open database
NSString *dbPath1=[SqliteManager getDataBasePath];
if (sqlite3_open([dbPath1 UTF8String], &database) == SQLITE_OK)
{
    NSLog(@"opened the data base");
    const char *sql = "delete from travels";
if(sqlite3_prepare_v2(database, sql, -1, &deletestmt, NULL) == SQLITE_OK)
        if(SQLITE_DONE != sqlite3_step(deletestmt))
            NSAssert1(0, @"Error while deleting. '%s'", sqlite3_errmsg(database));
        else
            isdeleted=YES;
}
sqlite3_reset(deletestmt);
sqlite3_close(database);

write in ur method inside.....
Getting Database Path....
+(NSString *)getDataBasePath
 {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
NSString *documentsDir = [paths objectAtIndex:0];
NSLog(@"file Path is %@",documentsDir);
return [documentsDir stringByAppendingPathComponent:@"Give ur Sqlite Filename"];
}


text:
Q: Determine the truth value of the statement if the universe of each variable consists of (i) all real numbers, (ii) all integers. ∀x (x > 0 → ∃y ((√x)/y = 3))
I've learned about different types of proofs, and I'm thinking here that I would first negate the statement to then prove the negation. Would the negation be: ∃x(x ≯ 0 → ∀y((√x)/y ≠ 3)) ?
If it's as easy as finding a number for x in which the statement is false, I could say:
let x = 25
(√25)/y = 5/y ≠ 3
Is this sufficient proof?
In either case, how would the proof be different with integers than with real numbers? Thanks ahead.

A: You shouldn't need to use a contradiction proof in either case. For the real number case, it is easier to use a constructive existence proof for the value of y. For the integer case, a counter example will suffice.
The field you choose changes the truth value of the proposition.
In the case of real numbers, you need to show that there exists some real number y such that ${\frac{\sqrt{x}}{y}=3}$ whenever x>0.
It is easy to see that letting y = ${\frac{\sqrt{x}}{3}}$ for any value of x>0 will yield:
${\frac{\sqrt{x}}{y} = \frac{3\sqrt{x}}{\sqrt{x}} = 3}$.
so the proposition is true in the real number field.
However, as your counter example shows it isn't true for the integers since letting ${x=25}$
causes ${\frac{\sqrt{25}}{y} = \frac{5}{y}}$ which does not equal 3 for any integer y.
Thus, the proposition is false among the integers.


text:
Q: IntelliJ - Test coverage. Only show classes that is tested I run a Unit test with coverage, and get the Coverage list.
The list contains the class that I am testing, and also classes that I have not tested. See picture below.
Is it a way to automatically hide classes that is not tested?

A: At the moment of writing this answer (Intellij Idea 2019.3 and Bundled Coverage Plugin), there is no such option.
Below are the only available configurations of Coverage Plugin.


text:
Q: R - eliminating duplicate columns in a sparse Matrix I have an R sparse Matrix (very big. not feasible to convert to a full matrix), I want to identify/eliminate duplicate columns if such exist. similar to unique(x,MARGIN=2), but that operates on sparse matrices.
is there anything like this around?
suggestions about how to do it?

A: I haven't found a great solution to this either, but this is what I've used.
library(data.table)
DFSummary<-summary(DF)
DT<-data.table(DFSummary)
setkey(DT,j)
nDF<-ncol(DF)

dupeList<- list()
dupeList[[nDF]]=NULL
  for(k in 1:nDF){
  dupeList[[k]]<-sort(DT[j==k,i])
  if(k%%1000==0) print (k/nDF)
  }

dupeVec<-duplicated(dupeList)
dupes<-which(dupeVec==TRUE)

Keep in mind that this solution would only work for a binary matrix. If you have a numeric matrix, you could do something like paste the i index to the x value. For example
    DFSummary$ix<-paste(DFSummary$i,DFSummary$x,sep=':'), and then store the ix values in the dupeList.

A: One option is to use uniquecombs of the transpose in package mgcv and then transpose the matrix. The function works on sparse matrix but returns a dense matrix. This may cause you a memory issue if the matrix you are working with is too big.
set.seed(123)
n <- 500
p <- 10/n
pDup <- 1/100
DupRow <- sample(c(1, 0), n, prob = c(p, 1-p), replace = TRUE)
IsDup <- sample(c(1, 0), n, prob = c(pDup, 1-pDup), replace = TRUE)
sum(IsDup)
# 5
myBigMat <-
     Reduce(cbind2, lapply(IsDup,
                                function(x) {
                                  if (x) {
                                    toFill <- DupRow
                                  } else {
                                    toFill <- sample(c(1, 0), n, prob = c(p, 1-p), replace = TRUE)
                                  }
                                  Matrix(toFill,nrow = n, ncol = 1, sparse = TRUE)
                                }
                                ))

NoDuplicateCols <- t(Matrix(mgcv::uniquecombs(t(myBigMat)), sparse = TRUE))
dim(NoDuplicateCols)
# 500 496


text:
Q: Issue opening images in Fancybox and Owl Carousel When clicking on the image a Fancybox opens. When sliding to the second image and closing the Fancybox in the Owl Carousel. Close the fancy box shows the second image in Owl Carousel. I need to set to the first image

$('.owl-carousel').owlCarousel({
  items: 1,
  loop: true,
  pagination: false,
  slideSpeed: 700,
  paginationSpeed: 700,
  rewindSpeed: 700,
  lazyLoad: true,
  margin: 30
});

$().fancybox({
  afterClose: function() {
    // here after fancy box i want to reset to 1st image active
  }
});
figure {
  margin: 15px 0;
}

figcaption {
  text-align: center;
}

.grayscale {
  filter: grayscale(0);
}

.grayscale:hover {
  filter: grayscale(50%)
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.4/jquery.fancybox.css" rel="stylesheet" />

Mountains

Mountain 2

Mountain 2

A:      $('[data-fancybox="images"]').each(function(){
        var relValue = $(this).attr('rel');
        $('[data-fancybox="images"][rel="'+relValue+'"]').fancybox({
            backFocus : false,
            hash   : false,
            afterClose: function() {

            }

        });
    });


text:
Q: ssh public key problem: /usr/bin/ssh-copy-id: ERROR: No identities found I have two users each with their own computers running Ubuntu. I want to remotely access one of them (say the desktop server) from the other one (say the client pc).
I'm trying to enable public key based authentication following the relative section in this answer (Connect two computers with SSH in a home LAN).
I started with the command from the client pc
ssh-keygen -t rsa -b 4096

After setting the file in which to save the key and the passphrase I launch the following command:
ssh-copy-id emanuele@emanuele-desktop.local

where emanuele@emanuele-desktop is the user@comp of the desktop server to which I'd like to remotely access
/usr/bin/ssh-copy-id: ERROR: No identities found

Any idea of what I'm missing?

A: ssh-copy-id expects the user's public key file to be located in ~/.ssh - specifically:

 The default_ID_file is the most recent file that matches: ~/.ssh/id*.pub,
 (excluding those that match ~/.ssh/*-cert.pub) so if you create a key
 that is not the one you want ssh-copy-id to use, just use touch(1) on
 your preferred key's .pub file to reinstate it as the most recent.

Correspondingly, that's where ssh-keygen writes generated keys by default - if you chose a non-default file location when you ran ssh-keygen, then you can specify that to ssh-copy-id using the -i option:

 -i identity_file
         Use only the key(s) contained in identity_file (rather than look‐
         ing for identities via ssh-add(1) or in the default_ID_file).  If
         the filename does not end in .pub this is added.  If the filename
         is omitted, the default_ID_file is used.


text:
Q: Timeout Module in Ruby - Getting Timer Value Is there a way to get the "timer" value when running the Timeout Module in Ruby?  Say I have this code:
require 'timeout'
begin
  status = Timeout::timeout(180) {
    sleep(10) until some action
  }
rescue Timeout::Error
  puts 'That took too long, exiting...'
end

So what I want is the overall value of total time that I've waited after each iteration.  So after the first 10 seconds, I've waited 10 total seconds, after the 2nd iteration of 10 seconds, I've waited 20 total seconds, and so on.
How can I get that overall value?

A: Timeout only yields the total seconds so here's an example on how to get that:
Timeout::timeout 5 do |sec|
  puts sec # => prints 5
  sleep 2
  puts sec # => prints 5
end

So to achieve the "overall" value (time wasted since the beginning) I think you'd have to do something like this:
Timeout::timeout 5 do |sec|
  start = Time.now
  puts (Time.now - start).round # => prints 0
  sleep 2
  puts (Time.now - start).round # => prints 2
end

I don't know if there's a better way to do this, but this works.


text:
Q: Why won't file stay selected after form post? I am trying to allow an image to be uploaded with a form.  I have code that makes sure that the user has entered valid information into the form.  If invalid information is submitted, the user is asked to correct the errors and submit the form again.  I am using the post data to populate the form fields so that the user does not have to enter the information again and is able to just edit the information they have already entered.  It seems that the $_POST is receiving the file information but it will change to displaying "No file selected." rather than the name of the file.  What is the problem here?  Below are some excerpts of my code
//Set field values as posted data.
if ($_FILES["Image"]["error"] > 0)
{
    echo "Error: " . $_FILES["Image"]["error"] . "
";
}
else
{
    echo "Upload: " . $_FILES["Image"]["name"] . "
";
    echo "Type: " . $_FILES["Image"]["type"] . "
";
    echo "Size: " . ($_FILES["Image"]["size"] / 1024) . " kB
";
    echo "Stored in: " . $_FILES["Image"]["tmp_name"];
}
$Name = $_POST['Name'];
$Image = $_FILES["Image"];

And the form:
<input type="file" name="Image" value="<?php echo($_FILES["Image"]["name"]); ?>">


text:
Q: Error when I run the app on my smartphone, but its correct If I run the app on Android Studio when I run my app in Android Studio, everything run correctly. The ListView in drawer is correctly populated by run a RushSearch() query.
But when I have created the apk and I installed on my smartphone to try run the app, the ListView in Drawer at the first run doesn't populated. If I close the app and run it again, everything is correct.
Why this anomaly?
The code for onCreate method on MainActivity.java class is this
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    callWebservice();

    // Layout principale col drawer
    setContentView(R.layout.activity_main_drawer);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    leftArrow = (ImageView) findViewById(R.id.left_arrow);
    titolo = (TextView) findViewById(R.id.titolo_id);

    ActionBarDrawerToggle actionBarDrawerToggle =
            new ActionBarDrawerToggle(this, drawerLayout, toolbar,
                    R.string.navigation_drawer_open, R.string.navigation_drawer_close);

    drawerLayout.setDrawerListener(actionBarDrawerToggle);
    actionBarDrawerToggle.syncState();

    drawerListView = (ListView) findViewById(R.id.drawer_listView);

    // SELECT * FROM Sections where Fk == 0;
    sectionsList = new RushSearch().whereEqual("Fk", 0).find(Sections.class);
    Log.d("ELEMENTI",""+sectionsList.size());
    drawerListViewAdapter = new DrawerListViewAdapter(sectionsList, getApplicationContext());

    // Adapter che si occupa di popolare il drawer
    drawerListView.setAdapter(drawerListViewAdapter);

    // Listner per il click su un elemento del drawer
    drawerListView.setOnItemClickListener(click);
}

The method callWebservice() is responsabile to take a JSON file from an url and its code is this
private void callWebservice() {

    String tag_json_obj = "GetItem";
    String url = String.format("http://digitalbox.getsandbox.com/item");
    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {

            try {
                saveSections(response.getJSONArray("Sections"));

            } catch (JSONException e) {
                e.printStackTrace();
            }

        }
    }, new Response.ErrorListener() {
        public void onErrorResponse(VolleyError error) {
            VolleyLog.d("Settings", "Error: " + error.getMessage());
        }
    }) {
        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            HashMap<String, String> headers = new HashMap<String, String>();
            headers.put("Content-Type", "application/json");
            headers.put("Accept", "application/json");
            return headers;
        }
    };
    NetworkController.getInstance().addToRequestQueue(jsonObjectRequest, tag_json_obj);
}

private void saveSections(final JSONArray section) {

    Thread t = new Thread(new Runnable() {
        @Override
        public void run() {

            int c = section.length();
            for (int i = 0; i < c; i++) {

                try {
                    JSONObject obj = section.getJSONObject(i);

                    Sections s = new RushSearch().whereEqual("ID", obj.getInt("ID")).findSingle(Sections.class);
                    if (s == null) {
                        s = new Sections();
                        s.setID(obj.getInt("ID"));
                    }

                    if (!obj.isNull("Fk"))
                        s.setFk(obj.getInt("Fk"));

                    s.setTitle(obj.getString("Title"));

                    if (!obj.isNull("CategoryColor"))
                        s.setCategoryColor(obj.getString("CategoryColor"));

                    s.setPos(obj.getInt("Pos"));
                    s.setLanguageId(obj.getInt("LanguageId"));
                    s.setUnavailableForSend(obj.getBoolean("UnavailableForSend"));

                    s.save();

                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            Log.d("sections", "DB updated");

        }
    });
    t.setPriority(Thread.MIN_PRIORITY);
    t.start();
}

If I run the app with Android Studio, in an AVD smartphone, I have this log
    11-30 15:21:53.520 2170-2170/? I/art: Not late-enabling -Xcheck:jni (already on)
11-30 15:21:53.520 2170-2170/? I/art: Late-enabling JIT
11-30 15:21:53.558 2170-2170/? I/art: JIT created with code_cache_capacity=2MB compile_threshold=1000
11-30 15:21:53.685 2170-2170/rawpepper.it.digitalbox W/System: ClassLoader referenced unknown path: /data/app/rawpepper.it.digitalbox-2/lib/x86
11-30 15:21:54.099 2170-2170/rawpepper.it.digitalbox W/art: Before Android 4.1, method int android.support.v7.internal.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
11-30 15:21:54.469 2170-2170/rawpepper.it.digitalbox D/ELEMENT: 13
11-30 15:21:54.486 2170-2210/rawpepper.it.digitalbox D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
11-30 15:21:54.592 2170-2210/rawpepper.it.digitalbox I/OpenGLRenderer: Initialized EGL, version 1.4
11-30 15:21:54.719 2170-2210/rawpepper.it.digitalbox W/EGL_emulation: eglSurfaceAttrib not implemented
11-30 15:21:54.719 2170-2210/rawpepper.it.digitalbox W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xad6fc2e0, error=EGL_SUCCESS
11-30 15:21:57.542 2170-2204/rawpepper.it.digitalbox D/Volley: [117] BasicNetwork.logSlowRequests: HTTP response for request=<[ ] http://digitalbox.getsandbox.com/item 0x95b78f5f NORMAL 1> [lifetime=3034], [size=196862], [rc=200], [retryCount=0]
11-30 15:21:57.691 2170-2180/rawpepper.it.digitalbox W/art: Suspending all threads took: 25.964ms
11-30 15:21:57.909 2170-2405/rawpepper.it.digitalbox D/sections: DB updated

that tells me that the number of elements in sectionList array are 13 (sixth row), that is correct.
app run with Android Studio
If I create the apk and I install it on my smartphone, and I plug this on pc to check the log when I run the app, I have this log
    11-30 15:35:01.765 17183-17183/rawpepper.it.digitalbox I/art: Late-enabling -Xcheck:jni
11-30 15:35:01.883 17183-17183/rawpepper.it.digitalbox W/System: ClassLoader referenced unknown path: /data/app/rawpepper.it.digitalbox-2/lib/arm
11-30 15:35:02.357 17183-17183/rawpepper.it.digitalbox W/art: Before Android 4.1, method int android.support.v7.internal.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
11-30 15:35:03.235 17183-17183/rawpepper.it.digitalbox D/ELEMENT: 0
11-30 15:35:03.249 17183-17260/rawpepper.it.digitalbox D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
11-30 15:35:03.304 17183-17260/rawpepper.it.digitalbox I/Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: QUALCOMM Build: 09/02/15, 76f806e, Ibddc658e36
11-30 15:35:03.306 17183-17260/rawpepper.it.digitalbox I/OpenGLRenderer: Initialized EGL, version 1.4
11-30 15:35:05.976 17183-17321/rawpepper.it.digitalbox D/sections: DB updated

that tells me that the elements in sectionList array are 0, but if I close and run it again, everything is correct.

A: You need to set up the drawer after the data is downloaded. For example by calling saveDate() when downloading a new section and setUpDraw() in onCreate().
private void saveData(Sections newSections) {
    newSections.save()
    setUpDraw()
}

private void setUpDraw() {

    drawerListView = (ListView) findViewById(R.id.drawer_listView);
    sectionsList = new RushSearch().whereEqual("Fk", 0).find(Sections.class);
    drawerListViewAdapter = new DrawerListViewAdapter(sectionsList, context); // You don't want application context
    drawerListView.setAdapter(drawerListViewAdapter);
    drawerListView.setOnItemClickListener(click);
}

A: I think you should call this part of your code:
// SELECT * FROM Sections where Fk == 0;
sectionsList = new RushSearch().whereEqual("Fk", 0).find(Sections.class);
Log.d("ELEMENTI",""+sectionsList.size());
drawerListViewAdapter = new DrawerListViewAdapter(sectionsList, getApplicationContext());

// Adapter che si occupa di popolare il drawer
drawerListView.setAdapter(drawerListViewAdapter);

After the saveSections() method completes. Something like this:
private void callWebservice() {

String tag_json_obj = "GetItem";
String url = String.format("http://digitalbox.getsandbox.com/item");
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
    @Override
    public void onResponse(JSONObject response) {
        try {
            saveSections(response.getJSONArray("Sections"));
// SELECT * FROM Sections where Fk == 0;
sectionsList = new RushSearch().whereEqual("Fk", 0).find(Sections.class);
Log.d("ELEMENTI",""+sectionsList.size());
drawerListViewAdapter = new DrawerListViewAdapter(sectionsList, getApplicationContext());

// Adapter che si occupa di popolare il drawer
drawerListView.setAdapter(drawerListViewAdapter);
        } catch (JSONException e) {
            e.printStackTrace();
        }

    }
}, new Response.ErrorListener() {
    public void onErrorResponse(VolleyError error) {
        VolleyLog.d("Settings", "Error: " + error.getMessage());
    }
}) {
    @Override
    public Map<String, String> getHeaders() throws AuthFailureError {
        HashMap<String, String> headers = new HashMap<String, String>();
        headers.put("Content-Type", "application/json");
        headers.put("Accept", "application/json");
        return headers;
    }
};
NetworkController.getInstance().addToRequestQueue(jsonObjectRequest, tag_json_obj);

}

A: I have modified my code, now I have this code for the onCreate() method
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        callWebservice();

//        setContentView(R.layout.activity_main);

        // Layout principale col drawer
        setContentView(R.layout.activity_main_drawer);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        leftArrow = (ImageView) findViewById(R.id.left_arrow);
        titolo = (TextView) findViewById(R.id.titolo_id);

        ActionBarDrawerToggle actionBarDrawerToggle =
                new ActionBarDrawerToggle(this, drawerLayout, toolbar,
                        R.string.navigation_drawer_open, R.string.navigation_drawer_close);

        drawerLayout.setDrawerListener(actionBarDrawerToggle);
        actionBarDrawerToggle.syncState();

        drawerListView = (ListView) findViewById(R.id.drawer_listView);
        setupDrawer();

    }

where the setupDrawer() method is
private void setupDrawer() {
        // SELECT * FROM Sections where Fk == 0;
        sectionsList = new RushSearch().whereEqual("Fk", 0).find(Sections.class);
        Log.d("ELEMENT", "" + sectionsList.size());
        drawerListViewAdapter = new DrawerListViewAdapter(sectionsList, getApplicationContext());

        // Adapter che si occupa di popolare il drawer
        drawerListView.setAdapter(drawerListViewAdapter);

        // Listner per il click su un elemento del drawer
        drawerListView.setOnItemClickListener(click);
    }

If I call this method from onCreate() or from callWebservice() after saveSections(response.getJSONArray("Sections")); in try-catch, I have the same problem.

A: Ok Man. Try this:
private void callWebservice() {
    String tag_json_obj = "GetItem";
    String url = String.format("http://digitalbox.getsandbox.com/item");
    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {

            try {
                new SaveData().execute(response.getJSONArray("Sections"));
            } catch (JSONException e) {
                e.printStackTrace();
            }

        }
    }, new Response.ErrorListener() {
        public void onErrorResponse(VolleyError error) {
            VolleyLog.d("Settings", "Error: " + error.getMessage());
        }
    }) {
        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            HashMap<String, String> headers = new HashMap<String, String>();
            headers.put("Content-Type", "application/json");
            headers.put("Accept", "application/json");
            return headers;
        }
    };
    NetworkController.getInstance().addToRequestQueue(jsonObjectRequest, tag_json_obj);
}

Then add this inner class inside your activity:
private final class SaveData extends AsyncTask<JSONArray, Void, Void> {
    protected Void doInBackground(JSONArray... params) {
        int c = section.length();
        for (int i = 0; i < c; i++) {

            try {
                JSONObject obj = section.getJSONObject(i);

                Sections s = new RushSearch().whereEqual("ID", obj.getInt("ID")).findSingle(Sections.class);
                if (s == null) {
                    s = new Sections();
                    s.setID(obj.getInt("ID"));
                }

                if (!obj.isNull("Fk"))
                    s.setFk(obj.getInt("Fk"));

                s.setTitle(obj.getString("Title"));

                if (!obj.isNull("CategoryColor"))
                    s.setCategoryColor(obj.getString("CategoryColor"));

                s.setPos(obj.getInt("Pos"));
                s.setLanguageId(obj.getInt("LanguageId"));
                s.setUnavailableForSend(obj.getBoolean("UnavailableForSend"));

                s.save();

            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        Log.d("sections", "DB updated");
        return null;
    }

    public void onPostExecute(Void result) {
        sectionsList = new RushSearch().whereEqual("Fk", 0).find(Sections.class);
        Log.d("ELEMENTI",""+sectionsList.size());
        drawerListViewAdapter = new DrawerListViewAdapter(sectionsList, getApplicationContext());
    }
}

I hope this helps!


text:
Q: Can I run E2E test with Nightwatch.js on CircleCI? I'm developing web sites and want to run test automatically on CircleCI.
I wrote config files and a js file for test, and run E2E test on my machine local. It works.
And then, I wrote circleci.yml and build project on CircleCI. It doesn't work.
Error log
$ npm run test

> static_web_site@0.0.0 test /home/ubuntu/static_web_site
> nightwatch

Starting selenium server... started - PID:  17970

[Test] Test Suite
=====================

Running:  Demo test Google

Error retrieving a new session from the selenium server

Connection refused! Is selenium server started?
{ state: 'session not created',
  sessionId: null,
  hCode: 537979030,
  value:
   { additionalInformation: '\nDriver info: driver.version: ChromeDriver',
     localizedMessage: 'session not created exception: Chrome version must be >= 58.0.3029.0\n  (Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 3.13.0-119-generic x86_64) (WARNING: The server did not provide any stacktrace information)\nCommand duration or timeout: 746 milliseconds\nBuild info: version: \'3.4.0\', revision: \'unknown\', time: \'unknown\'\nSystem info: host: \'box2107\', ip: \'127.0.0.1\', os.name: \'Linux\', os.arch: \'amd64\', os.version: \'3.13.0-119-generic\', java.version: \'1.8.0_102\'\nDriver info: driver.version: ChromeDriver',
     systemInformation: 'System info: host: \'box2107\', ip: \'127.0.0.1\', os.name: \'Linux\', os.arch: \'amd64\', os.version: \'3.13.0-119-generic\', java.version: \'1.8.0_102\'',
     supportUrl: null,
     cause: null,
     suppressed: [],
     message: 'session not created exception: Chrome version must be >= 58.0.3029.0\n  (Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 3.13.0-119-generic x86_64) (WARNING: The server did not provide any stacktrace information)\nCommand duration or timeout: 746 milliseconds\nBuild info: version: \'3.4.0\', revision: \'unknown\', time: \'unknown\'\nSystem info: host: \'box2107\', ip: \'127.0.0.1\', os.name: \'Linux\', os.arch: \'amd64\', os.version: \'3.13.0-119-generic\', java.version: \'1.8.0_102\'\nDriver info: driver.version: ChromeDriver',
     hCode: 60610566,
     class: 'org.openqa.selenium.SessionNotCreatedException',
     buildInformation:
      { buildRevision: 'unknown',
        buildTime: 'unknown',
        releaseLabel: '3.4.0',
        hCode: 163722713,
        class: 'org.openqa.selenium.internal.BuildInfo' },
     screen: null },
  class: 'org.openqa.selenium.remote.Response',
  status: 33 }

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! static_web_site@0.0.0 test: `nightwatch`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the static_web_site@0.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ubuntu/.npm/_logs/2017-06-30T02_34_01_711Z-debug.log

npm run test returned exit code 1

package.json
{
  "name": "static_web_site",
  "version": "0.0.0",
  "description": "",
  "scripts": {
    "build": "rimraf dist && webpack",
    "start": "webpack-dev-server -d --colors --inline --hot --port 4000 --host 0.0.0.0",
    "test": "nightwatch",
    "lint": "sass-lint -v -q && pug-lint app/**/*.pug"
  },
  "keywords": [],
  "author": "Allajah",
  "license": "MIT",
  "devDependencies": {
    "babel-core": "^6.23.1",
    "babel-loader": "^7.0.0",
    "babel-plugin-add-module-exports": "^0.2.1",
    "babel-polyfill": "^6.23.0",
    "babel-preset-es2015": "^6.22.0",
    "babel-register": "^6.24.1",
    "chromedriver": "^2.30.1",
    "copy-webpack-plugin": "^4.0.1",
    "css-loader": "^0.28.0",
    "extract-text-webpack-plugin": "^2.1.1",
    "file-loader": "^0.10.1",
    "html-webpack-plugin": "^2.28.0",
    "nightwatch": "^0.9.16",
    "node-sass": "^4.5.0",
    "normalize.css": "^6.0.0",
    "postcss-loader": "^2.0.6",
    "pug": "^2.0.0-beta.12",
    "pug-lint": "^2.4.0",
    "pug-loader": "^2.3.0",
    "rimraf": "^2.6.1",
    "sass-lint": "^1.10.2",
    "sass-loader": "^6.0.2",
    "selenium-server-standalone-jar": "=3.4.0",
    "style-loader": "^0.13.2",
    "webpack": "^2.6.1",
    "webpack-dev-server": "^2.4.1"
  }
}

nightwatch.json
{
  "src_folders": ["test/e2e/"],
  "output_folder": "test/reports/",
  "custom_commands_path": "",
  "custom_assertions_path": "",
  "page_objects_path": "",
  "globals_path": "node_modules/babel-register",
  "selenium": {
    "start_process": true,
    "server_path": "node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-3.4.0.jar",
    "log_path": "test/logs",
    "host": "127.0.0.1",
    "port": 4444,
    "cli_args": {
      "webdriver.chrome.driver": "node_modules/.bin/chromedriver"
    }
  },
  "test_settings": {
    "default": {
      "launch_url": "http://localhost",
      "selenium_port": 4444,
      "selenium_host": "localhost",
      "silent": true,
      "screenshots": {
        "enabled": true,
        "on_failure": true,
        "on_error": false,
        "path": "test/screenshots"
      },
      "desiredCapabilities": {
        "browserName": "chrome",
        "javascriptEnabled": true,
        "acceptSslCerts": true
      },
      "globals": {
        "baseUrl": "http://localhost:4000",
        "waitTime": 10000
      },
      "use_xpath": false
    }
  }
}

test/e2e/test.js
module.exports = {
    tag: 'nightwatch test',
    'test': (client) => {
        client.url('http://www.google.com').waitForElementVisible('body', 1000).assert.title('Google').assert.visible('input[type=text]').end()
    }
}

circle.yml
machine:
  node:
    version: 7.4.0
environment:
  PATH: "${PATH}:${HOME}/${CIRCLE_PROJECT_REPONAME}/node_modules/.bin"
dependencies:
  pre:
    - npm i -g npm
test:
  override:
    - npm run build
    - npm run start:
        background: true
    - sleep 10
    - npm run test

I wrote these scripts referring to https://github.com/beatfactor/nightwatch-circleci .
And I forked it and tried to run test on CircleCI but it din't work.
Someone can help me to run E2E test with Nightwatch.js on CircleCI?
Thank you :)

A: You just need to update Chrome on CircleCI.
The error from Selenium states that it is expecting Chrome to be at least version 58. The default Ubuntu images are using older (or much older) versions of Chrome.
To fix this, add these steps to your circle.yml when you install your dependencies:
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get --fix-broken --only-upgrade install google-chrome-stable


text:
Q: Application to create flash demo of a website I'm looking for some software to create a flash demo 'tour' of a website I've created.  FOS would be preferred but commercial is ok so long as not too expensive (I'm probably going to use this just the once).
Ideally something programmable to I can edit the demo and insert text, overlays etc.  I'm also not interested in adding sound.
Recommendations?

A: Adobe Captivate can record actions which can be edited.
It outputs a flash movie.

A: Captivate by Adobe is pretty much the standard app that people in business use but that's pretty expensive.
I have had good experience with Wondershare products so I'd expect this one to be pretty good (only $100):
http://www.sameshow.com/democreator/article/software-demo-making.html

A: It's not opensource but it is free and works on Windows and Linux
Wink from Debugmode.com is pretty good

A: Neither of these are free, but they're
not outrageously expensive, either.
Tanida Demo Builder
http://www.demo-builder.com/
TechSmith Camtasia Studio
http://www.techsmith.com/camtasia/features/win/

A: If you are using a Mac, ScreenFlow is an absolutely fantastic program. It costs $99, but is very professional and well worth the money.
http://www.telestream.net/screen-flow/overview.htm


text:
Q: How to implement random select and click from the list (Android / Appium) I was trying to create an automated testing with  a requirement to random select from the given list (with different urls) tried some of the script available online however cant make it to work and getting ElementNotFound. Please help me on this
List elementList = driver.findElements(By.xpath("//android.view.View[@content-desc = 'carouselItem']"));
Random rand = new Random();
int index = rand.nextInt(elementList.size()-1);
    elementList.get(index).click();

enter image description here


text:
Q: Encode Instructions of Stack-based language to Bytecode How can i encode in bytes a Language with instructions like "PUSH_k x" for an arbitrarily large x and k the number of bytes of x?

A: There are many approaches to encoding variable length numbers:
One simple approach is a variable length byte approach, which uses one bit of each byte to tell if another byte of the value follows.  For example, in each byte, use the high bit = 1 to say that there is at least one more byte — and use the high bit = 0 to say that this byte is the last byte.
The decoding, here into int type, goes like this:
int decodeVariableLengthNumber ( unsigned char *pc ) {
    int value = 0; // size here should accomodate the largest possible
    for(;;) {
       unsigned byte b = *pc++;
       value <<= 7;
       value |= b & 127;
       if ( b & 128 )
           continue;
       return value;
    }
}

And the encoding is simply the reverse as needed for this decoding.
This can encode 7 data/content bits in every 8 bit byte, so numbers from 0 to 127 in one byte, and 0 to 16383 in two bytes, for example.
Offsets can also be used so that the first byte encodes, 1..128 instead of 0..127 if that makes more sense for the application.  Also, the two byte format might assume one would not use the 2 byte encoding for a number that fits in the 1 byte form, so these might be offset by 127 (or 128), for a slightly larger reach.
You can encode k this way, and then have fixed size k bytes for x — or you can simply encode x itself directly in this variable length manner without necessarily a need for encoding a k for byte count.

Other food for thought to consider:

*

*self synchronizing encodings, which could even have some security advantages in instruction set architecture.

*UTF-8 A variable length encoding that has the self synchronization property.

*RISC V RISC V supports variable length instructions that are multiples of 2 bytes.


text:
Q: Linking existing facebook page to app I am developing an application which has facebook login. Whenever a user logins through facebook, my existing facebook page(I am the admin) should be auto liked. Is this possible to link my existing facebook page to the app which I have created in developers.fb.com?

A: It's been asked before, you can try the steps from previous questions, it still works as of July 2014:
How to link a Facebook app with an existing fan page


text:
Q: Calling C files from web service We are creating a web service in java using APACHE CXF framework, and from here we need to call few .c files which contains nothing but the methods for the db entry.
How can we call these .c files from our web service so that we can compile it and use the existing function for the db entry?


text:
Q: JavaScript: Variable Value gets lost between functions I have the following code
function updateSliderContent(json) {  //<- json defined here is correct
   var screen_order = json.screen_order.split('_');
   jQuery.each(screen_order, function(i, item) {
      var screen_id = item;
      //at this point it is not, thus the function does not execute whatever is in the if blocks
      if (json[screen_id].action == 'add') {
         //doSomething
      } else if (json[screen_id].action == 'remove') {
         //doSomthingElse
      };
   }
}

My problem is that somehow, the value of json (which is an object from an AJAX Call) gets lost in the each function of jquery. I have not yet found out why, nor how to solve it. Google does not give me the answer I am looking for.
Edit 1
Here is the actual call.
function updateSlider() {
   var screenOrder = '';
   jQuery('div#slider td').each(function(i, item) {
      screenOrder += this.abbr + '_';
   })
   var ajaxData = {
      sid: sid,
      story: story,
      date: theDate,
      screenOrder: screenOrder,
      mode: 'ajax_update_slider'
   };
   jQuery.ajax({
      data: ajaxData,
      dataType: 'json',
      success: function (json) {
         updateSliderContent(json);
      }
   });
   theDate = Math.round(new Date().getTime()/1000.0); //UNIX Timestamp
   sliderTimer = setTimeout('updateSlider();',15000);
};

A: I've attempted, and failed, to reproduce your problem on JS Bin:
http://jsbin.com/ereha (editable via http://jsbin.com/ereha/edit)
The code you've shown us so far seems perfectly fine, so the problem must be caused by some other part of your code or system. We're all just shooting in the dark if we don't know what the issue is.
Please try and reproduce the problem on http://jsbin.com and we can help you from there.
Complete Source Code
index.html
<!doctype html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>http://stackoverflow.com/questions/1831384/javascript-variable-value-gets-lost-between-functions</title>
    <script type="text/javascript" src="http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    <script type="text/javascript">
      $.ajaxSetup({url: 'test.json'});

      function updateSliderContent(json) {  //<- json defined here is correct
        var screen_order = json.screen_order.split('_');
        jQuery.each(screen_order, function(i, item) {
          var screen_id = item;
          //at this point it is not, thus the function does not execute whatever is in the if blocks
          if (json[screen_id].action == 'add') {
            console.log(screen_id, 'action add');
          } else if (json[screen_id].action == 'remove') {
            console.log(screen_id, 'action remove');
          };
        });
      }

      function updateSlider() {
        var ajaxData = {};
        jQuery.ajax({
          data: ajaxData,
          dataType: 'json',
          success: function (json) {
            updateSliderContent(json);
          }
        });
        // theDate = Math.round(new Date().getTime()/1000.0); //UNIX Timestamp
        sliderTimer = setTimeout('updateSlider();',15000);
      };

      $(updateSlider);
    </script>
  </head>
  <body>
  </body>
</html>

test.json
{
  'screen_order': 'foo_bar_baz',
  'foo': {
    'action': 'add'
  },
  'bar': {
    'action': 'add'
  },
  'baz': {
    'action': 'remove'
  }
}

A: There seems to be nothing wrong with the jQuery.each as I can't reproduce your problem.
        function alertName (json) {
            var a = new Array();
            a.push(1);
            a.push(2);

            jQuery.each(a, function(i, item) {
                alert(json[0].name);
                alert(json[1].name);
            });
        }

        var andre = { name: "André" }
        var joana = { name: "Joana" }

        var arrayOfJson = new Array();
        arrayOfJson.push(andre);
        arrayOfJson.push(joana);

        alertName(arrayOfJson);

alertName() function works exactly as it should. The json parameter isn't lost within jQuery.each function
It seems to be a problem on your implementation, something you're not telling us about. Please try to "compress" your issue to a working sample as I did and show us so that we can try in on our own :)

A: Are you sure json is an object. Maybe its a json-string? Than you should eval it before use.
If you get it via $.ajax() call don't forget to add dataType:'json' as an option...

A: tray in the if() clause to use item.action, because if the json data is an array of objects, item will contain each object, but this is only my assumption

A: I think you should make sure the function updateSliderContent is called after the json response from the server side.
The code below shouldn't work:
    var json = {};

    $.getJSON("/url/", {}, function(data){
        json = data;
    });

    //we call our function before the server response
    //and the json will be just blank object
    updateSliderContent ( json );

So, please have a look at your code because sometimes we did something like that without intention.
The code below should work and the json object must not be blank if the server really response the correct json.
    $.getJSON("/url/", {}, function(json){
        //we call only after the response from server
        updateSliderContent ( json );
    });


text:
Q: Jquery fadeIn And fadeOut problem using hover over a div I have this code:
var x;
x=jQuery(document);
x.ready(inicializarEventos);

function inicializarEventos()
{
    var x;
    x=jQuery(".Caja2");
    x.hover(entraMouse,saleMouse);
}

function entraMouse()
{
    jQuery(this).fadeOut();
}

function saleMouse()
{
    jQuery(this).fadeIn();
}

The problem is that when I move the mouse over the box it starts fade In and Fade Out constantly until stope the mouse move.
Other bad behevior is thar if I move the mouse in and out the box several times faster than the fade, it keep doing the efect over and over.
I need something that stop the animation when the mouse go back over the box.

A: On the second issue:
If your animations are "building up" as you run the mouse over the box, you can fix that by calling stop() first. Like so:
jQuery(this).stop().fadeOut();

jQuery(this).stop().fadeIn();

A: When you call fadeOut(), it will eventually make the item completely invisible, which probably triggers the mouseOut event.
Maybe you can use the fadeTo() method with a very low number, so it will not disappear:
function entraMouse()
{
    jQuery(this).fadeTo("fast",0.01);
}

function saleMouse()
{
    jQuery(this).fadeTo("fast",1.0);
}

A: Maybe you can have a boolean variable let's say it "is_faded_out" and set it true or false accordingly?

A: thats probably due the bubbling effect, lets say that you have a div with some content there:

Hello

World

then, the hover event for the Hello span, and the World paragrapgh is catched in the event listener of the hover of the div.

A: I had a similar problem, and solved this with:
function entraMouse()
{
    if (!jQuery(this).is(':hidden')) jQuery(this).fadeOut();
}

function saleMouse()
{
    if (jQuery(this).is(':hidden')) jQuery(this).fadeIn();
}


text:
Q: some problems were encountered while processing the POMs: [error] non resolvable import POM I want to start a new Jersey project but I failed in the first step because pom.xml show some errors and the project can't be built.
the error :
some problems were encountered while processing the POMs:
[error] non resolvable import POM: Could not transfer artifact org.glassfish.jersey: jersey-bom:pom...."

Here is my pom.xml :
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0   http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>

 <groupId>JERSEYProject</groupId>
 <artifactId>JERSEYProject</artifactId>
 <packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>simple-service-webapp</name>

<build>
    <finalName>simple-service-webapp</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <inherited>true</inherited>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.glassfish.jersey</groupId>
            <artifactId>jersey-bom</artifactId>
            <version>${jersey.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
<dependency>
    <groupId>org.glassfish.jersey.containers</groupId>
    <artifactId>jersey-container-servlet-core</artifactId>
</dependency>
</dependencies>

Can you please help me to fix this problem? I tried a lot of configurations but none of theme worked. I don't know if I had problem on my IDE configuration (IntelliJ).
Thank you!!

A: You need to specify the version of the glassfish.Either directly or as variable with the given name jersey.version


text:
Q: Error in Carousel slider codeigniter I am new to codeigniter i don't know how to display carousel slider in codeigniter

            <?php
            foreach($testimonials as $t)
            {
            ?>
            <?php

            ?>

                <img class="profile-circle" src="<?php echo base_url(); ?>uploads/images/testimonials/<?php echo $t->picture; ?>" alt="testimonials_image">

<?php echo $t->content; ?>

            <?php
            }
            ?>

this is the code , actually i know what the error is but i dont know how to rectify it , ie , at the first excecution the division class must be active item and after first excecution the class need to be only item.

A: If you are sure that the problem is the class "active" for the first element only, you can do something like this, in your foreach:

    <?php
    $counter = 0;
    //add a counter and check its value in your div.
    //If it's 0, echo active, otherwise nothing.
    //In the end of your loop, the counter increases so it won't be 0 again

    foreach ($testimonials as $t) {
    //next div will echo "active", if the $counter==0

        ?>
        <div class="item <?= ($counter == 0) ? "active" : "" ?>">

                <img class="profile-circle" src="<?php echo base_url(); ?>uploads/images/testimonials/<?php echo $t->picture; ?>" alt="testimonials_image">

<?php echo $t->content; ?>

        <?php

        //increase the $counter, or set it another value in order not to echo "active" again for the next loops
        $counter++;
    }
    ?>


text:
Q: Burst capture photos in gphoto2 on Linux Not sure where this best belongs: photography, electronics, software, or here. I have a Canon PowerShot G9 camera and I am using gphoto2 on Linux to control it over USB.
I need to take photos continuously and copy them to the computer (asynchronously is fine, so photos could be taken at maximum speed and transfers could queue up).
With gphoto2, I can do continuous capture like this:
gphoto2 --capture-image -F <frames> -I <seconds>
This gives me at best 4 seconds between captures (0.25 fps). If I unplug the camera and use its burst mode, I can take shots at 0.8 fps. I don't seem to be able to change the burst setting when plugged in with gphoto2. I tried some sample code that uses libgphoto2 directly in C, but that was even slower. How can I accomplish faster capture with this camera, or what cameras would let me do this?

A: Try Burst mode:
gphoto2 --set-config viewfinder=1 --set-config capturemode='Burst' --set-config burstnumber=5 --set-config capturetarget=1 --capture-image-and-download --force-overwrite


text:
Q: How can I find the last non-empty row of excel using openpyxl 3.03? How can I find the number of the last non-empty row of an whole xlsx sheet using python and openpyxl?
The file can have empty rows between the cells and the empty rows at the end could have had content that has been deleted. Furthermore I don't want to give a specific column, rather check the whole table.
For example the last non-empty row in the picture is row 13.

I know the subject has been extensively discussed but I haven't found an exact solution on the internet.

A: # Open file with openpyxl
to_be = load_workbook(FILENAME_xlsx)
s = to_be.active

last_empty_row = len(list(s.rows))
print(last_empty_row)
## Output: 13

s.rows is a generator and its list contains arrays of each rows cells.

A: If you are looking for the last non-empty row of an whole xlsx sheet using python and openpyxl.
Try this:
import openpyxl

def last_active_row():
    workbook = openpyxl.load_workbook(input_file)
    wp = workbook[sheet_name]
    last_row = wp.max_row
    last_col = wp.max_column

    for i in range(last_row):
        for j in range(last_col):
            if wp.cell(last_row, last_col).value is None:
                last_row -= 1
                last_col -= 1
            else:
                print(wp.cell(last_row,last_col).value)
    print("The Last active row is: ", (last_row+1)) # +1 for index 0

if __name__ = '___main__':
last_active_row()

This should help.

A: openpyxl's class Worksheet has the attribute max_rows


text:
Q: ASP.Net Link Button not working in Firefox (Version 8) I have developed an ASP.NET application to use in Facebook. It has a simple link button which is used to work as expected in older versions of Firefox.
<asp:LinkButton ID="lbtnLogOut" runat="server">Disconnect</asp:LinkButton>

 Protected Sub lbtnLogOut_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnLogOut.Click
    Response.Redirect(Request.ApplicationPath & "/login.aspx")
  End Sub

After upgrading Firefox to 8, I noticed Link Button is not working i.e the button is not causing Post Back. When I view the source code, the Javascript code for Link Button to cause Post Back is
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>

I used Firebug to debug the above code but _doPostBack function is not firing when I clicked on Link Button. It is working in all other browsers (IE 9, Google Chrome, Safari) though.
Note: I am using this ASP.Net web application as App inside Facebook. Facebook basically displays this website inside it using iFrame.
There is a similar question here, but it does not provide any solution to me.
Wondering the issue is caused by Facebook iFrame or Firefox? Any help would be appreciated.

A: It doesn't look like you're assigning an event handler to the LinkButton.
<asp:LinkButton ID="LinkButton1" runat="server" Text="Click" OnClick="LinkButton1_Click" />

The JavaScript you posted is the __doPostBack function, which is not exclusive to the LinkButton. You are correct in the sense that LinkButtons use __doPostBack to trigger postbacks, but the function won't be called unless you assign an event handler to the LinkButton.
For debugging purposes, I would also set CausesValidation to false, just to make sure that validation doesn't interfere with the click event.

A: Just use this code in your .master file or other appriopiate file just before the end </body> tag:
   <script language="javascript" type="text/javascript">
   <!--
   function __doPostBack(eventTarget, eventArgument) {
   var theform;
   if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
   theform = document.aspnetForm;
   }
   else {
   theform = document.forms["aspnetForm"];
   }
   theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
   theform.__EVENTARGUMENT.value = eventArgument;
   theform.submit();
   }
   // -->
  </script>

Replace 'aspnetForm' with your own.