text:
Q: JavaScript alert with 3 buttons I have a JavaScript alert button that appears on the website when a user is going to proceed to a signup page.
It looks something like this
Would you like to proceed to the signup page?
< OK > < Cancel >
Would it be possible to add a third button to the alert so that it looks like
Would you like to proceed to the signup page?
< More Info > < OK > < Cancel >

A: Nowdays, you can use an HTML dialog element.
<dialog open>

Greetings, one and all!

  <button>Ok</button><button>Maybe</button><button>Cancel</button>
</dialog>

And do what you want with it.
document.querySelectorAll('button').forEach($button =>
  $button.onclick = () => document.querySelector('dialog').removeAttribute('open'))

https://jsfiddle.net/6nus2zt4/1/
Hope this helps to future generations :)

A: however you can use confirm function.. but NOT three buttons.
var r=confirm("Press a button!");
if (r==true)
  {
  x="You pressed OK!";
  }
 else
  {
  x="You pressed Cancel!";
  }

A: Unfortunately, I don't think you can change the number of buttons in an alert box.  (At least not in any browser that I know of.)  You can use one of the many modal dialog scripts that are out on the net.  Something like Eric Martin's SimpleModal Dialog for jquery would probably work.
They basically take a div and style it up with css and javascript to mimic a dialog box.

A: No.
You need to use a custom modal dialog, such as jQuery UI Dialog.


text:
Q: How to convert an old JavaScript API to a promise I've got an AWS call that looks like this:
ecs.describeServices(params, function(err, data) {
   if (err) {
      return { data: '',success: false };
   } else {
      return { data: 'whohoo',success: true};
   }
});

This is in a method that needs to return a promise that resolves to my return object.
I've been experimenting with this type solution, but just can't figure it out.
        var keepsHisWord;
        keepsHisWord = true;
        var promise1 = new Promise(function(resolve, reject) {
            if (keepsHisWord) {
                resolve({ mytest: "mytest101" });
            } else {
                reject("The man doesnt want to keep his word");
            }
        });

Edit:
Working. Thanks to the two people who posted. That really helped a lot.  And wondering why the question down-voted. I did a bunch of research first. I guess just not as smart at the down-voter.
            var promise1 = function(params) {
            return new Promise(function(resolve, reject) {
                ecs.describeServices(params, function(err, data) {
                    if (err) {
                        resolve({
                            error: "my error"
                        });
                    } else {
                        resolve({
                            runningCount: data.services[0].runningCount,
                            pendingCount: data.services[0].pendingCount,
                            status: data.services[0].status,
                            desiredCount: data.services[0].desiredCount,
                            createdAt: data.services[0].desiredCount,
                            events: data.services[0].events
                        });
                    }
                });
            });
        };
        return promise1(params);

A: Wrap your service call into promise:
promiseFunc = function(params) {

    return new Promise(function(resolve,reject){

        ecs.describeServices(params, function(err, data) {
            if (err) {
                resolve({ data: '',success: false });
            } else {
                reject({ data: 'whohoo',success: true});
            }
        });

    })

}

Then use it:
 promiseFunc(params).then(x => {})

A: Starting from Node 8 there is a util.promisify function, which does exactly that
var util = require('util');
var describeServices = util.promisify(ecs.describeServices);
describeServices(params)
    .then()
    .catch()

You also can find many implementations of this function in the internet.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Square Integration in iOS I am trying to find out some technical doc,blog or sample code, which can help me to integrate Squareup API into iOS.
I have googled it already, which didn't helped me much.
I have the android github code for reference.
I have also found the feasibility of squareup in iOS, as you can check this app:
http://itunes.apple.com/us/app/drchrono-emr/id363897223?mt=8
This app has used the squareup, that means, it is available to integrate in iOS.
Looking forward  for the suggestion.
Thanks

A: As of 2014 it does look like they offer an API:
https://connect.squareup.com/

A: Square does not offer an API. [Source1] [Source2]
Their official Github account does have a deprecated (as of April 2012) android api that will not work. I would advise looking elsewhere for in-app payment solutions.
Also keep in mind that in-app payments are a gray area in the iOS terms of service. If you are selling something in the app, it must be available for sale outside of the app as well. Selling items through the app only will have to use Apple's In-App Purchase framework so they get their 30% cut.


text:
Q: binding couldbees-hosted database to Play app Does it work for anyone? I used
    bees app:bind
command and although it bound the app and db, (as shown by bees app:bindings) it did not show any db credential variables it created (neither I could just use them in application.config).
I tried setting those credential variables via
    bees config:set
but running the app via
    play run
still threw a dereferencing error.
Thanks!

A: Sure it work, we use it on this app
see the db.* properties on conf file


text:
Q: jQuery add/remove class only works once I have a small/(strange?) problem with some basic jQuery. Inside an HTML form i have two elements:

     <input type="checkbox" name="service-web" id="service-webdesign" value="Webdesign" />
     Webdesign

     <input type="checkbox" name="service-web" id="service-SEO" value="SEO" />
     SEO

Now, what I want to do is add/remove a class called "active" to style either of these elements different when they are hit. Here is the jQuery to achieve that:
$('#service-webdesign').click(function(){
    if($('#service-webdesign-span').hasClass('active')){
        $('#service-webdesign-span').removeClass('active')
        } else ($('#service-webdesign-span').addClass('active'))
    });

$('#service-SEO').click(function(){
    if($('#service-SEO-span').hasClass('active')){
        $('#service-SEO-span').removeClass('active')
        } else ($('#service-SEO-span').addClass('active'))
    });

Although both of them are identical (functioning wise), only the first one is working as expected. I am sure that is has nothing to do with their order though, since swapping the jQuery around doesn't make any difference. I have started with jQuery only just yesterday, so I probably lack the ability to see through this behaviour.
Any help would be much appreciated!

A: service-SEO-span is a class but service-webdesign-span is an id and you're targeting them both as if they were ids.

A: You should use toggleClass
And you should use the right selector as Juhana already mentioned in the comments!
$('#service-webdesign-span').toggleClass('active');


text:
Q: how can I get complete header info from urlib2 request? I am using the python urllib2 library for opening URL, and what I want is to get the complete header info of the request. When I use response.info I only get this:
Date: Mon, 15 Aug 2011 12:00:42 GMT
Server: Apache/2.2.0 (Unix)
Last-Modified: Tue, 01 May 2001 18:40:33 GMT
ETag: "13ef600-141-897e4a40"
Accept-Ranges: bytes
Content-Length: 321
Connection: close
Content-Type: text/html

I am expecting the complete info as given by live_http_headers (add-on for firefox), e.g:
http://www.yellowpages.com.mt/Malta-Web/127151.aspx

GET /Malta-Web/127151.aspx HTTP/1.1
Host: www.yellowpages.com.mt
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Cookie: __utma=156587571.1883941323.1313405289.1313405289.1313405289.1;    __utmz=156587571.1313405289.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)

HTTP/1.1 302 Found
Connection: Keep-Alive
Content-Length: 141
Date: Mon, 15 Aug 2011 12:17:25 GMT
Location: http://www.trucks.com.mt
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET, UrlRewriter.NET 2.0.0
X-AspNet-Version: 2.0.50727
Set-Cookie: ASP.NET_SessionId=zhnqh5554omyti55dxbvmf55; path=/; HttpOnly
Cache-Control: private

My request function is:
def dorequest(url, post=None, headers={}):
    cOpener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookielib.CookieJar()))
    urllib2.install_opener( cOpener )
    if post:
        post = urllib.urlencode(post)
    req = urllib2.Request(url, post, headers)
    response   = cOpener.open(req)
    print response.info()  // this does not give complete header info, how can i get complete header info??
    return response.read()
 url = 'http://www.yellowpages.com.mt/Malta-Web/127151.aspx'
 html = dorequest(url)

Is it possible to achieve the desired header info details by using urllib2? I don't want to switch to httplib.

A: Those are all of the headers the server is sending when you do the request with urllib2.
Firefox is showing you the headers it's sending to the server as well.
When the server gets those headers from Firefox, some of them may trigger it to send back additional headers, so you end up with more response headers as well.
Duplicate the exact headers Firefox sends, and you'll get back an identical response.
Edit: That location header is sent by the page that does the redirect, not the page you're redirected to. Just use response.url to get the location of the page you've been sent to.
That first URL uses a 302 redirect. If you don't want to follow the redirect, but see the headers from the first page instead, use a URLOpener instead of a FancyURLOpener, which automatically follows redirects.

A: I see that server returns HTTP/1.1 302 Found - HTTP redirect.
urllib automatically follow redirects, so headers returned by urllib is headers from http://www.trucks.com.mt, not http://www.yellowpages.com.mt/Malta-Web/127151.aspx


text:
Q: Reference to emplaced map values requires definition of class I need to change the way that I include headers in a larger project that I'm working on. I was able to simulate the errors I currently get with a smaller, single program.
By way of example, the following compiles:
#include <map>

class C;

class A {
public:
    C& add();
    std::map<int,C> Cmap;
    void dosomethingwithC();
};

class B {
public:
    A& add();
    std::map<int,A> Amap;
};

class C {
public:
    B& add();
    std::map<int,B> Bmap;
};

int main()
{
    C c;
    auto& emplacedB = c.add();
    auto& emplacedA = emplacedB.add();
    auto& emplacedC = emplacedA.add();
    emplacedC.add();
    return 0;
}

C& A::add()
{
    auto emplace_results = Cmap.emplace(std::piecewise_construct,
        std::forward_as_tuple(3),
        std::forward_as_tuple());
    auto pair_iterator = emplace_results.first;
    auto& emplaced_pair = *pair_iterator;
    auto& map_value = emplaced_pair.second;
    return map_value;
}

B& C::add()
{
    auto emplace_results = Bmap.emplace(std::piecewise_construct,
        std::forward_as_tuple(3),
        std::forward_as_tuple());
    auto pair_iterator = emplace_results.first;
    //auto& emplaced_pair = *pair_iterator;
    std::pair<const int,B>& emplaced_pair = *pair_iterator;
    auto& map_value = emplaced_pair.second;
    return map_value;
}

A& B::add()
{
    auto emplace_results = Amap.emplace(std::piecewise_construct,
        std::forward_as_tuple(3),
        std::forward_as_tuple());
    auto pair_iterator = emplace_results.first;
    auto& emplaced_pair = *pair_iterator;
    auto& map_value = emplaced_pair.second;
    return map_value;;
}

void A::dosomethingwithC()
{
    Cmap[3].add();
}

But, if I move A's function definition closer to A, then the following does not compile:
#include <map>

class C;

class A {
public:
    C& add();
    std::map<int,C> Cmap;
    void dosomethingwithC();
};

C& A::add()
{
    auto emplace_results = Cmap.emplace(std::piecewise_construct,
        std::forward_as_tuple(3),
        std::forward_as_tuple());
    auto pair_iterator = emplace_results.first;
    auto& emplaced_pair = *pair_iterator;
    auto& map_value = emplaced_pair.second;
    return map_value;
}

class B {
public:
    A& add();
    std::map<int,A> Amap;
};

class C {
public:
    B& add();
    std::map<int,B> Bmap;
};

int main()
{
    C c;
    auto& emplacedB = c.add();
    auto& emplacedA = emplacedB.add();
    auto& emplacedC = emplacedA.add();
    emplacedC.add();
    return 0;
}

B& C::add()
{
    auto emplace_results = Bmap.emplace(std::piecewise_construct,
        std::forward_as_tuple(3),
        std::forward_as_tuple());
    auto pair_iterator = emplace_results.first;
    //auto& emplaced_pair = *pair_iterator;
    std::pair<const int,B>& emplaced_pair = *pair_iterator;
    auto& map_value = emplaced_pair.second;
    return map_value;
}

A& B::add()
{
    auto emplace_results = Amap.emplace(std::piecewise_construct,
        std::forward_as_tuple(3),
        std::forward_as_tuple());
    auto pair_iterator = emplace_results.first;
    auto& emplaced_pair = *pair_iterator;
    auto& map_value = emplaced_pair.second;
    return map_value;;
}

void A::dosomethingwithC()
{
    Cmap[3].add();
}

Even though class C is declared I get an error. The error explains that std::pair uses undefined class C.
What is the correct way to structure the headers and includes to make this compile?

A: Approach

*

*All the declarations must go in the headers and

*all the definitions go into the .cpp files.

*None of the headers include each other.

In this specific instance the error regarding the missing definition (for the std::pair, as part of the std::map) goes away if all the .cpp files include all the declarations. (A needs C, but C needs B)
So even though the error was for a missing definition, it could be solved by including a declaration. I'm not sure why and will post a separate question.
Solution
A.h
#ifndef A_h
#define A_h

#include <map>

class C;

class A {
public:
    C& add();
    std::map<int,C> Cmap;
    void dosomethingwithC();
};

#endif

B.h
#ifndef B_h
#define B_h

#include <map>

class A;

class B {
public:
    A& add();
    std::map<int,A> Amap;
};

#endif

C.h
#ifndef C_h
#define C_h

#include <map>

class B;

class C {
public:
    B& add();
    std::map<int,B> Bmap;
};

#endif

A.cpp
#include "A.h"
#include "B.h" // also required here
#include "C.h"

C& A::add()
{
    auto emplace_results = Cmap.emplace(std::piecewise_construct,
        std::forward_as_tuple(3),
        std::forward_as_tuple());
    auto pair_iterator = emplace_results.first;
    auto& emplaced_pair = *pair_iterator;
    auto& map_value = emplaced_pair.second;
    return map_value;
}

void A::dosomethingwithC()
{
    Cmap[3].add();
}

B.cpp
#include "A.h"
#include "B.h"
#include "C.h" // also required here

A& B::add()
{
    auto emplace_results = Amap.emplace(std::piecewise_construct,
        std::forward_as_tuple(3),
        std::forward_as_tuple());
    auto pair_iterator = emplace_results.first;
    auto& emplaced_pair = *pair_iterator;
    auto& map_value = emplaced_pair.second;
    return map_value;;
}

C.cpp
#include "A.h" // also required here
#include "B.h"
#include "C.h"

B& C::add()
{
    auto emplace_results = Bmap.emplace(std::piecewise_construct,
        std::forward_as_tuple(3),
        std::forward_as_tuple());
    auto pair_iterator = emplace_results.first;
    //auto& emplaced_pair = *pair_iterator;
    std::pair<const int,B>& emplaced_pair = *pair_iterator;
    auto& map_value = emplaced_pair.second;
    return map_value;
}

Main.cpp
#include "A.h"
#include "B.h"
#include "C.h"

int main()
{
    C c;
    auto& emplacedB = c.add();
    auto& emplacedA = emplacedB.add();
    auto& emplacedC = emplacedA.add();
    emplacedC.add();
    return 0;
}


text:
Q: I can not separate a list to others on properties **When I try to separate Cards to other lists I get Stack Overflow Exception. How can I fix it? **
I don't know which way is best. Doing it at on properties or in a method.
public static List<Card>? cards
{
    get
    {
        return cards;
    }
    set
    {
        foreach (var linesorgu in value)
        {
            if (linesorgu.line == "3" || linesorgu.line.ToLower() == "done")
            {
                done.Add(linesorgu);
                cards.Remove(linesorgu);
            }
            else if (linesorgu.line == "2" || linesorgu.line.ToLower() == "inprog")
            {
                InProg.Add(linesorgu);
                cards.Remove(linesorgu);
            }
            else if (linesorgu.line == "1" || linesorgu.line.ToLower() == "todo")
            {
                todo.Add(linesorgu);
                cards.Remove(linesorgu);
            }
            else { Console.WriteLine("Line yazımında bir yanlış var"); }

              cards = value;

        }
    }

A: Your need to introduce backing field. Currently in your getter and setter your are calling the card property itself which results in "infinite" recursion which ends up with SO exception. Also note that cards.Remove(linesorgu); will not actually work because at some point you will try to modify iterated collection.
private static List<Card> _cards;
public static List<Card>? cards
{
    get
    {
        return _cards;
    }
    set
    {
        var newCards = new List<Card>();
        foreach (var linesorgu in value)
        {
            if (linesorgu.line == "3" || linesorgu.line.ToLower() == "done")
            {
                done.Add(linesorgu);
            }
            else if (linesorgu.line == "2" || linesorgu.line.ToLower() == "inprog")
            {
                InProg.Add(linesorgu);
            }
            else if (linesorgu.line == "1" || linesorgu.line.ToLower() == "todo")
            {
                todo.Add(linesorgu);
            }
            else
            {
                newCards.Add(linesorgu);
                Console.WriteLine("Line yazımında bir yanlış var");
            }
        }

        _cards = newCards;
    }
}


text:
Q: django csrf for api that works with ios apps I am building an ios app that communicates with the server for getting the data.
If its just a normal app, I can send csrf token via forms (since all from same domain). But, for ios apps, I dont think I can set csrf token .
So, when making requests from ios apps, to the server, I am getting error regarding csrf.  So, whats the solution for this? Disabling this csrf feature or some other better way ? This is my first ios app, so please tell me a better way so i will follow that.

A: For those URLs ("API end points") that your iOS app is accessing, you will need to specify @csrf_exempt on the corresponding view functions to disable csrf protection.
More details here - https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#django.views.decorators.csrf.csrf_exempt
And protect those urls via other authentication methods, such as session authentication.
For your authentication purposes, you can easily take reference to what django rest framework and django tastypie has done.  Both use SessionAuthentication classes to handle authentication and protect the exposed urls (API endpoints) that your iOS app can connect to.
References:-

*

*http://django-rest-framework.org/api-guide/authentication.html

*https://django-tastypie.readthedocs.org/en/latest/authentication_authorization.html
Django tastypie also has an authorization class, which is not to be confused with authentication. It also has an APIKey authorization class which becomes useful when you do want to expose your django URLs to other 3rd party developers who may want to build an app of their own to talk to your django URLs to access data (think "facebook APIs"). Each 3rd party developer can in essence be provided a unique API and because you have the APIKeyAuthorization class and a unique API Key provided to each 3rd party app, you can be sure that only "authorized" apps can consume your django URLs. This is the essence of how various big platforms like "Google+" or "Facebook" etc work.
Details of how django's csrf works
https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#how-it-works

The CSRF protection is based on the following things:
A CSRF cookie that is set to a random value (a session independent
  nonce, as it is called), which other sites will not have access to.
This cookie is set by CsrfViewMiddleware. It is meant to be permanent,
  but since there is no way to set a cookie that never expires, it is
  sent with every response that has called
  django.middleware.csrf.get_token() (the function used internally to
  retrieve the CSRF token).
A hidden form field with the name 'csrfmiddlewaretoken' present in all
  outgoing POST forms. The value of this field is the value of the CSRF
  cookie.
This part is done by the template tag.
For all incoming requests that are not using HTTP GET, HEAD, OPTIONS
  or TRACE, a CSRF cookie must be present, and the 'csrfmiddlewaretoken'
  field must be present and correct. If it isn't, the user will get a
  403 error.
This check is done by CsrfViewMiddleware.
In addition, for HTTPS requests, strict referer checking is done by
  CsrfViewMiddleware. This is necessary to address a Man-In-The-Middle
  attack that is possible under HTTPS when using a session independent
  nonce, due to the fact that HTTP 'Set-Cookie' headers are
  (unfortunately) accepted by clients that are talking to a site under
  HTTPS. (Referer checking is not done for HTTP requests because the
  presence of the Referer header is not reliable enough under HTTP.)
This ensures that only forms that have originated from your Web site
  can be used to POST data back.


text:
Q: Server.Transfer to internal virtual application My question is how to manage several virtual applications, located at the same host
firstdomain.com is redirected to firstdomain.com/1
seconddomain.com is redirected to seconddomain.com/2
and so on...
each new domain must be located at different folder, and for now it is working fine.
But it causes some inconvenient, for example seconddomain.com/1 is showing firstdomain.com web site.
i'm trying to create something like dispatch at root directory "/" to transfer necesary domain with Server.Transfer("").
but it is not working like I thought:
Server.Transfer("/" + folder + "");

causes this error:

Server Error in '/' Application. Error
  executing child request for
  /web_folder.
Description: An unhandled
  exception occurred during the
  execution of the current web request.
  Please review the stack trace for more
  information about the error and where
  it originated in the code.
Exception Details:
  System.Web.HttpException: Error
  executing child request for
  /web_folder.

Server.Execute("/" + folder + "");

causes error too:

Error executing child request for
  /web_folder.
Description: An unhandled exception
  occurred during the execution of the
  current web request. Please review the
  stack trace for more information about
  the error and where it originated in
  the code.
Exception Details:
  System.Web.HttpException: Error
  executing child request for
  /web_folder.

both applications works fine accessed by its specified url.
and also there is a problem with two applications, if I use HttpModules from root web.config, it causes compilation error inside virtual application. It may be passed, if I add reference to same project in virutal site.
Any suggestions ?
i think there must be any solution, many people need to redirect any subdomain to a subfolder without Redirect, to keep the original URL dsplay
thanks.

A: You cannot Server.Transfer to an application that is hosted to a different virtual directory in IIS than the one that's performing the request.

A: Server.Transfer can only happen for single HttpContext. Each virtual directory or app has its own HttpContext object and they know not that co-exists! so you cannot do that.


text:
Q: Quick create C# properties from variables For C#, I hate writing out the variables and then writing out all the properties. Isn't there a way to select all variables, right click and create all the properties.

A: FYI, simply typing "prop" (no quotes) triggers one of the snippets that comes with VS, and you just tab your way through, by far the quickest option.

A: Why aren't you doing:
public int SomeProperty { get; set; }

or
public int SomeOtherProperty { get; private set; }

?

A: from this line:
string mytest;

select the whole line "string mytest;",
then VS menu: Edit > Refactor > Encapsulate field ...
you get this:
public string Mytest { get => mytest; set => mytest = value; }

A: Right click on the field declaration, menu Refactor -> Encapsulate field and you go from
int n;

to
int n;

public int N
{
   get { return n; }
   set { n = value; }
}

A: Are you looking for a code refactoring tool? If so, check out ReSharper. It provides an easy to to turn simple field-backed properties into auto-properties, and vice versa.
If you simply don't want to write custom field-backed properties, you can use auto-properties, fpor example, like so:
public string MyProperty { get; set; } // generates an auto-property

which is equivalent to:
private string m_MyProperty;
public string MyProperty
{
  get { return m_MyProperty; }
  set { m_MyProperty = value; }
}

You can even make the accessibilty of the setter and getter difference:
public string MyProperty { get; private set; }

If you do choose to use auto-properties, be aware that you cannot access the underlying field, nor can you supply an implementation for just one portion (just the getter or just the setter). You can, however, make the property virtual.

A: If you're using C# 3.0 or above (VisualStudio 2008, essentially), you can use auto properties. While this isn't exactly what you're asking for, it should (hopefully) do the trick.
Rather than writing:
private string m_Name;

public string Name
{
    get { return m_Name; }
    set { m_Name = value; }
}

You can just write:
public string Name { get; set; }

This will give you quick, "dumb" (i.e. no retrieval or assignment logic) properties that can go on your class. If you find you need retrieval and assignment logic later, just come back and do the full property declaration syntax and you won't have to change any of the calling code.
The only real difference is that you'll have to use the property to get the value within your class, as the backing variable is generated and compile time and unavailable to your code.

A: we can quickly create c# properties in visual studio using prop shortcut
and behalf of visual studio tool we can generate c# properties using a tool called c# property generator..
when class has so many properties in it , when we create a object of that class,
we have to take certain pain to assign properties so this tool will reduce your pain to certain extent this will automatically assign object with properties..
c# property assigner

A: You probably should be using Auto-Implemented properties in C# for most things. However, if you want 'old-style' properties with explicit backing fields you can create a Visual Studio code snippet to make them easier to write. This blog post has an example of one.


text:
Q: Does $y'=f(y), y(0)=0$ have a continuous differentiable solution Does $y'=f(y), y(0)=0$ have a continuous differentiable solution , Where
$$ f(y)=\cases{
0 & if $y>0$\\
1 & if $y\leq 0$
}$$

 how to solve this problem is we can apply picard theorem..can any help me with this

A: Of course Picard's theorem does not apply, but there might exist an acceptable solution nevertheless.
The given IVP has a bona fide solution $y(x)=x$, valid for $x\leq0$. But there is indeed no solution valid in a full neighborhood of $x=0$.
Proof. A prospective solution in an interval $\>]{-h},,h[\>$ has $y'(0)=1$, hence satisfies
$$y(x)=x+o(x)=x\bigl(1+o(1)\bigr)\qquad(x\to0)\ .$$
In particular we have $y(x)>0$ for $0<x<\delta$ and therefore $y'(x)=0$ for $0<x<\delta$. Now it is a theorem that the derivative of a differentiable function automatically satisfies the intermediate value theorem, whereas the derivative of the function $x\mapsto y(x)$ envisaged here assumes only the values $0$ and $1$.$\quad\square$


text:
Q: Merge based on 2 columns values - Check for duplicate key values error I have two data tables with the following columns - ddate,fnumber,file,model and fnumber,ddate,model,model_id,file. I would like to update the first table with values from the second table matched by ddate and fnumber columns.
If I use merge:
dtPT <- merge(dtPT, dtAT, by = c("fnumber", "ddate"), all.x = TRUE)

then I get the following error -

Error in vecseq(f__, len__, if (allow.cartesian || notjoin) NULL else
  as.integer(max(nrow(x),  :    Join results in 8568291 rows; more than
  8537179 = max(nrow(x),nrow(i)). Check for duplicate key values in i,
  each of which join to the same group in x over and over again. If
  that's ok, try including j and dropping by (by-without-by) so that
  j runs for each group to avoid the large allocation. If you are sure
  you wish to proceed, rerun with allow.cartesian=TRUE. Otherwise,
  please search for this error message in the FAQ, Wiki, Stack Overflow
  and datatable-help for advice.

I tried to search for duplicated records in dtAT:
setkeyv(dtAT, c("fnumber", "ddate"))
dtAT[duplicated(dtAT)]

but it returns 0 rows.
I also tried to use match instead, but it doesn't work as I expected (sample data is used below):
tPT <- "ddate,fnumber,file,model
2014-05-26,S71149,ps1.csv,320
2014-09-26,,ps2.csv,
2014-10-16,,ps3.csv,"

tAT <-
"fnumber,ddate,model,model_id,file
S71149,2014-05-26,319,VU-BHP,as1.csv
S71149,2014-05-25,320,,as2.csv
S71149,2014-05-23,322,VU-BTP,as3.csv"

columnClasses <- c("POSIXct", "factor", "character", "factor")
dtPT <- read.csv(text=tPT, header = TRUE, sep = ",", na.strings = c(""), colClasses = columnClasses)
dtPT <- as.data.table(dtPT)

columnClasses <- c("character", "POSIXct", "character", "factor", "factor")
dtAT <- read.csv(text=tAT, header = TRUE, sep = ",", na.strings = c(""), colClasses = columnClasses)
dtAT <- as.data.table(dtAT)

dtPT$model_code <- dtAT[match(paste(dtAT$fnumber, dtAT$ddate), paste(dtPT$fnumber, dtPT$ddate)), dtAT$model]

The code above in result assigns model_code values to all rows:
        ddate fnumber    file model model_code
1: 2014-05-26  S71149 ps1.csv   320        319
2: 2014-09-26      NA ps2.csv    NA        320
3: 2014-10-16      NA ps3.csv    NA        322

when 320 should assigned to the first row only:
        ddate fnumber    file model model_code
1: 2014-05-26  S71149 ps1.csv   320        319
2: 2014-09-26      NA ps2.csv    NA         NA
3: 2014-10-16      NA ps3.csv    NA         NA

Since for second and third rows there is no match by combination of ddate and fnumber.
(the merge, of course, works well with the example below, but returns the error with Production data)

A:
I would like to update the first table with values from the second table

Instead of merge function there is a update on join feature in data.table, it will be faster as it updates by reference and don't need to materialize bigger dataset after joins.
The general syntax is

DT1[DT2, value := i.lookup_value]

So going to your example

library(data.table)

tPT <- "ddate,fnumber,file,model
2014-05-26,S71149,ps1.csv,320
2014-09-26,,ps2.csv,
2014-10-16,,ps3.csv,"

tAT <- "fnumber,ddate,model,model_id,file
S71149,2014-05-26,319,VU-BHP,as1.csv
S71149,2014-05-25,320,,as2.csv
S71149,2014-05-23,322,VU-BTP,as3.csv"

columnClasses <- c("POSIXct", "factor", "character", "factor")
dtPT <- read.csv(text=tPT, header = TRUE, sep = ",", na.strings = c(""), colClasses = columnClasses)
dtPT <- as.data.table(dtPT)

columnClasses <- c("character", "POSIXct", "character", "factor", "factor")
dtAT <- read.csv(text=tAT, header = TRUE, sep = ",", na.strings = c(""), colClasses = columnClasses)
dtAT <- as.data.table(dtAT)

setkeyv(dtPT, c("fnumber","ddate"))
setkeyv(dtAT, c("fnumber","ddate"))

dtPT[dtAT, model_code := i.model]
#         ddate fnumber    file model model_code
# 1: 2014-09-26      NA ps2.csv    NA         NA
# 2: 2014-10-16      NA ps3.csv    NA         NA
# 3: 2014-05-26  S71149 ps1.csv   320        319

If you get mentioned error you should start by checking duplicates but not on full rows but on your composite key. The simple code below.

dtPT[,.N,c("fnumber","ddate")][N>1L]
dtAT[,.N,c("fnumber","ddate")][N>1L]


text:
Q: Are opamps as a voltage regulator effcient? If I setup an opamp in a non-inverting configuration as follows:

Vrail+ is 7.5V, Vrail- is GND (0 V)
Vin is 2.5V,
Vout = 3.3V (in other words, the gain, aka, 1+R2/R1 is 1.32 [V/V])
Iout = 100mA (connected to some load)
What are the source of my losses? How efficient are these types of configurations? Do I only take the quiescent current as the only loss?

A: Opamps are linear devices, and as such, they're going to be as (in)efficient as any other linear regulator.
The load current at the output pin is supplied from the opamp's power supply pins, and any difference in voltage between the two pins appears across the driver transistors in the opamp's output stage. This voltage, multiplied by the load current, represents power that will get dissipated as heat inside the opamp.

A: The inherent efficiency will be the same as any other linear regulator, give or take, depending on the op-amp quiescent current (could be uA to mA for the op-amp just sitting there with no load).
\$P_D = (V_{in} - V_{out}) \cdot I_{load} + I_q \cdot V_{in} \$
100mA will require an expensive op-amp or a booster stage on the output.
There's another problem- linear regulators are designed and specified for capacitive loads such as the bypass capacitors on whatever you're going to connect to the 3.3V rail. If you connect an op-amp as shown in your schematic to such a load it will probably oscillate and/or overshoot. That could damage your load, and even if the bypass capacitors kill the apparent oscillation it will greatly increase the power consumption of your circuit. I suggest that unless you have very special requirements, you should use voltage regulators to regulate voltage and op-amps to manipulate signals. It's not that you couldn't compensate such a circuit with additional components so it would be stable, it's just that I don't see the point.

A: Opamps can't usually supply 100 mA.  But, they can still be used to control a power voltage if you add some current gain to their output.  If you really want a opamp to control a power voltage that can supply 100s of mA, here is a simple way:

The opamp still does the controlling and still provides voltage gain from Vin to Vout.  However, Q1 provides most of the Vout current.  R2 and R3 are the voltage feedback and the overall gain is the reciprocal of their attenuation ratio.  In this example R2 and R3 are equal, so the voltage gain from Vin to Vout is 2.
You might think all you need is the transistor and R2 and R3, but that could be unstable.  To make the opamp stable, you put a small cap directly between its output and inverting input.  But, you also need to let the opamp output not be loaded directly with the end load, especially if that load is capacitive.  R1 decouples the opamp output from the load such that the opamp should be able to reach whatever output voltage it wants to.  Without that, the stability feedback provided by C1 won't work right and the thing can oscillate anyway.
The best value of C1 is hard to predict, so start with something vaguely plausible, like I show, and then experiment.  Making it lower will invite instability and result in oscillations.  Making it higher will dampen the response to transient loads.  Test by connecting the worst case non-resistive load you expect, find the value of C1 just where it starts to be unstable, and then double it in the real circuit.
However, stepping back a couple of layers in this case, you don't need a opamp voltage regulator since the voltage you want is both a common value and known up front.  There are plenty of 3-terminal linear regulators specifically designed for this task that can source 100 mA.  If it's OK to waste the extra power as heat in the linear regulator, then this is clearly the way to go in your case.  In this case you're dropping 7.5V - 3.3V = 4.2V, which times 100 mA is 420 mW.  A linear regulator in a TO-220 or similar case will get warm, but won't require a heat sink.
If efficiency or getting rid of heat is a issue, then use a buck regulator to make the 3.3 V supply from the existing 7.5 V supply.

A: You won't be able to supply 100mA from all standard op-amps - maybe 20mA for most and up to 50mA for more specialist devices. There are such things as power op-amps that can deliver amps but these are specialist devices.
Regarding efficiency - the power delivered to the load might be 3.3V x 20mA = 66mW and the  power into the opamp will be 7.5V x (20mA + ~5mA for the op-amp) = 187.5mW.
The quiescent current of the device may be 3mA rising to 5mA to produce the output current. There's a bit of hand-waving but even if you ignored any current taken by the op-amp you still have 7.5V powering it and 20mA being delivered to the load = 150mW.
If you ran the op-amp from a 5V supply it would be better but remember it is a linear device that isn't like a switch mode power supply - if your output is 20mA this 20mA gets taken from the op-amps power rails.

A: This circuit gives the output voltage as is set for (maximum output is limited by the rails) but it will not be well regulated anymore at higher load. This also depends on the strength of the op amp of interest. There are lots of high current capability (Amperes) op amps available now out there.
This circuit isn't a voltage regulator by any chance. It'll oscillate with high capacitive load, and can't sustain line or load transients.


text:
Q: Android: Can you use an APK file to install files to the device but not an application I have an application that uses files stored on an the SD card..  I want to release new "modules" which are just data files on the sdcard (but no separate application). I want to used the market to manage install/uninstall/updates.
is there a way with the APK files to create a "files only" installer?
I do have the main app which will place the "default module" files in the Asset folder, and then copy them to the SDcard when executed the first time, but this requires an app to be actually run. I want the "modules" to place files on the sdcard directly..
is this possible?

A: Looks like APK Expansion already does what you want. It says that the expansion files are unzipped to the shared storage, which I believe is the SD Card.

A: Google recently revealed "Smart App Updates" for Google Play.  This allows users to only download the changes with that update, rather than the entire APK.  I have yet to publish an app in the Play Store, but this should be covered in their submission process.
http://developer.android.com/guide/google/play/expansion-files.html


text:
Q: Binomial or Joint Probability The probability of getting a 6 when rolling a dice is 1/6.
Say I have 5 dices in front of me, the probability of 5 of them being a 6 is equal to:
$P[D_1=6]\cdot P[D_2=6]\cdot P[D_3=6]\cdot P[D_4=6]\cdot P[D_5=6] = (1/6)^5 = 0.000128601$
Where $P[D_i=6]$ is the probability of the $i^{th}$ dice being a 6
Now, why is it that I get the same answer by seeing this problem as 5 Bernoulli trials each with a probability of success equal to 1/6 and by calculating the desired probability via the binomial distribution, namely the probability of 5 successes out of 5 trials:
$P[5|5] = 5!/(0!\cdot5!)\cdot(1/6)^5\cdot(5/6)^0 = 0.000128601$
I'm trying to understand two things:

*

*why I don't get the same result for 4 successes out of 5 trials compared to just doing (1/6)^4 if what I wan to know is the probability of 4 out of my 5 dices being a 6.

*Why are the results for 5 out of 5 the same? Is it a coincidence? Is one of them more or less valid than the other?
Thanks!

A: The answer is that the probability of rolling {6, 6, 6, 6, not-6} on your dice is equal to $\frac{1}{6^4} \times \frac{5}{6} \approx 0.00064$, but it's not the only way to get 4 6s. There's also {6, 6, 6, not-6, 6}, {6, 6, not-6, 6, 6}, {6, not-6, 6, 6, 6} and {not-6, 6, 6, 6, 6}, each of which has the same probability of occurring. So there are a grand total of 5 ways it can happen, resulting in a total probability of $\frac{1}{6^4} \times \frac{5}{6} \times 5 \approx 0.003215$.
In general, if the probability of success is $p$ and the probability of failure is $1-p$, then since the number of ways to arrange $k$ successes amongst $n$ events is $n \choose k$, the total probability of having $k$ successes is ${n \choose k}p^k(1-p)^{n-k}$, which is the Binomial probability distribution.
The reason your calculation works for 5 successes from 5 dice is because there is exactly 1 way to do so: {6, 6, 6, 6, 6} so ${n \choose k} = 1$ and $n-k = 0$ so $(1-p)^{n-k} = (1-p)^0 = 1$, so both those terms disappear from the calculation, leaving you with just $p^n$.


text:
Q: How do Transforms in WPF work? I recently used a TranslateTransform in my WPF application to implement dragging a UserControl across the screen.  There is a new bug in that after the first time you drag it somewhere else on the screen, when you click on the "Title bar" on the control, it jumps back to where it was originally displayed.  It will still follow the mouse, but that initial jump is disconcerting.
I don't know what's going on, but this got me to wondering.  Since WPF controls don't have a left or top property of their own, unless you put them into a Canvas, and those are attached properties anyway, just what properties are being modified by the TranslateTransform?

A: WPF's layout and render passes have intrinsic knowledge of transforms. By modifying the X and Y properties of the TranslateTransform, you're causing the layout/render pass to take those new values into consideration when positioning the associated FrameworkElement.
To put it another way: the TranslateTransform is not modifying other properties, but by modifying its properties you are triggering another layout/render pass and thus affecting the on-screen positioning of the associated FrameworkElement.
Read here for more information.


text:
Q: User specific data retrieval I am currently making a project that requires me to be able to pull information off Firestore with data specific to a user.
At the moment I have the application creating a user and am able to read a specific table.
I was wondering is there any way to read and or save data specfic to a UserID?
public String UID = FirebaseAuth.getInstance().getCurrentUser().getUid();

I'm using this at the moment to read and save the userid to a document but was wondering what the most popular methods of  user-specific data retrieval is?
Would it be possible to set a document equal to a userid and retrieve it that way?
I'm just asking to see if there are multiple ways of doing this and whats the most popular. For some reason I am finding tutorials/documentation hard come by so even links to them would be appreciated.
Thanks.

A:
was wondering what the most popular methods of user-specific data retrieval is?

Assuming you have a database structure that looks like this:
Firebase-root
  |
  --- users
       |
       --- uid
            |
            --- uid: "TheUidOfTheUser"
            |
            --- //other users details

A recommend way would be to use a DocumentReference like in the following lines of code:
String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();
FirebaseFirestore rootRef = FirebaseFirestore.getInstance();
DocumentReference uidRef = rootRef.collection("users").child(uid);
uidRef.get(/* ... */);

The second approach would be to use a Query, like this:
String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();
FirebaseFirestore rootRef = FirebaseFirestore.getInstance();
Query query = rootRef.whereEqualTo("uid", uid);
query.get(/* ... */);

In which the uid variable holds the value for the uid of the user that you are searching for.


text:
Q: How to hide header in iframe tag to show reports in visualforce pages I'm showing reports in visualforce page by using iframe tag. But in the visualforce page. It is not only showing report, It is showing the headers also. I want to hide the header.
I used:
<apex:iframe src="" height="1588px" width="100%"/>

And i also did:
<apex:page sidebar="false" showheader="false">

A: In then Iframe src url add ?isdtp=mn  it will hide the header for you.


text:
Q: Hidden UINavigationBar appearing on becomeFirstResponder (UIKeyboard appears) In iOS8 I have a UIViewController in which I have set
[self.navigationController setNavigationBarHidden:YES animated:YES];
in viewDidAppear.
However in this same UIViewController I am triggering the keyboard using becomeFirstResponder. It seems that the hidden state of the navigationBar is ignored since it suddenly animates into the view when the keyboard appears.
Setting self.navigationController.hidesBarsWhenKeyboardAppears to true causes a brief animation toggle which is not desirable in the current case.
Has anyone come across this? Is there any new API to tell the navigationBar to stay hidden regardless?
Thanks

A: In iOS8 there are a lot of nifty features regarding the navigationController, one of them is the new gesture properties like navigationController.hidesBarsOnSwipe. In our application some UIViewControllers hide the navigation bar, whilst others don't.
The problem was that even though we where hidding the navigationController, we where not resetting that property, causing a lot of confusion.
So if you see any quircky behaviour with the visibility of the navigationController.navigationBar make sure you are re-setting all the necessary properties accross views.


text:
Q: Strange results with a range index for a vector in R I am trying to write a k-windsor median function in R.
winsor <- function(x, k) {
   stopifnot(is.numeric(x))
   stopifnot(all.equal(k, as.integer(k)))
   n = length(x)
   # cat("N is: ", n)
   stopifnot(k <= (n-1)/2)
   # cat("x[k+1] is: ", x[k+1])
   x[1:k] <- x[k+1]
   # cat("x[1:k] is: ", x[1:k])
   # cat("x[n-k] is: ", x[n-k])
   x[n-k+1:n] <- x[n-k]
   # cat("x[n-k+1:n] is: ", x[n-k+1:n])
   # cat(x)
   mean(x)
}

I am executing this instruction:
winsor(c(1,2,3,4,5,6,7,8,9,10),3)

x[n-k+1:n] is:  7 7 7 7 7 7 7 7 7 7
should be: 7 7 7
making for my function calculating wrong results
Anybody knows why x[8:10] is producing such strange results?
Thanks!

A: Put parentheses at x index.
x[(n-k+1):n]

The operator : precedes the arithmatic ones (see this for details).
[]'s


text:
Q: Defining navigation from Person to Country but not from Country to Persons using the Fluent syntax I have the following relationship between Person and Country defined by convention. This works perfectly.
public class Person
{
    public long PersonId {get; set;}
    public string Name {get; set;}

    public long CountryId {get; set;}
    public virtual Country Country {get; set;}
}

public class Country
{
    public long CountryId {get; set;}
    public string Name {get; set;}
}

I now wish to change the name of the property Country to something else. As I understand it this means the relationship does not work anymore by convention. So I wish to define it using the fluent syntax.
I found this reference but it is not clear to me how I should handle this exact scenario since in their examples both sides of the relation contain a foreign key or collection.
There is a section "Configuring a Relationship with One Navigation Property" which makes me think it should look like this:
modelBuilder.Entity<Patient>()
    .HasRequired(t => t.Country)
    .WithRequiredPrincipal();

However, whenever when storing countries this results in the following exception
{"The INSERT statement conflicted with the FOREIGN KEY constraint \"FK_dbo.Countries_dbo.Patients_CountryId\". The conflict occurred in database \"TESTS_ffbe7a6e73a747ce8cda71f963bb20b7\", table \"dbo.Patients\", column 'PatientId'.\r\nThe statement has been terminated."}

So my question are now:
- How do I define the above 'by convention' relationship using fluent syntax?
- Is the CountryId property still required when using the fluent syntax?

A: In your sample code you're expressing this:

*

*Entity<Patient>().HasRequired(t => t.Country): each patient must have a related country

*.WithRequiredPrincipal(): each country must have a related patient

I suppose you don't need each country to have one or more related patients. So, do this:
  modelBuilder.Entity<Person>()
              .HasRequired(p => p.Country)
              .WithMany();

This means that each person must have a country, and each country can have many related persons. And you don't specify a nvaigation back from country to person.
To understand this kind of fluent API relationships take into account that the first function (i.e HasRequired) is the relationship from the first entity to the second entity. And then, the second function (i.e. WithXXX) is the relationship back from the second entity to the first one.
Thanks to the Fluent API it's easy to express any kind of relationship without making mistakes. Besides there are overloads with or without paramteres that allow you to specify the navigation properties, or omit them if they're not present. For example, if you needed to navigate back from country to persons, using a Persons property, it would look like this:
  WithMany(c => c.Persons)


text:
Q: A Docker container silently killed by Travis CI I have a Docker image that has a few custom libraries compiled and installed for automating tests.
It has "/bin/bash" as its ENTRYPOINT, so a container created by docker run does not immediately exit.
However, when I run it on Travis CI, it dies after a few seconds:
# .travis.yml
... (omit language, os, etc)

install:
  - docker pull <dockerhub link>
  - docker run -td <dockerhub addr>
  - docker ps
  - sleep 15
  - docker ps

The first docker ps shows that the created container is up for a few seconds.
However, the second docker ps shows nothing; during the 15 seconds, something happened to the container.
When the commands are run on my local computer, I can observe that it is kept alive.
Is it because Travis CI kills certain docker containers? If it is true, what should I do to make it keep alive?

A: The reason was that I was running an image that was built from arm64 machine whereas my Travis CI was using AMD64. :/
For anyone who saw this, please double check your architecture. :P


text:
Q: Is there a way to create a postmeta field in database when new post is made, but have no meta input on admin side? I've taken over a site someone else built with a VERY poorly coded theme and VERY poorly coded plugins.   I just need a really quick temporary fix for an issue.
The site has a "projects" page, which is set up as a custom post type, and each project has a project type and list of services, both of which are set up as taxonomies/terms.
The problem is all of the old projects have fields in the postmeta table for project_type and services
However, neither the theme nor the CMB2 plugin create this field when a new project is made. If I manually create the fields in the database I can then change the information from the WP-admin, but then I would have to add them manually each time a new project is made.
If I add a metabox either manually or through the CMB2 plugin, it creates a second field for the same item in the admin back end, so that won't work.
Is there any way to just create these empty database fields in the postmeta table each time a new post is made?
P.S. I know there must just be an error somewhere in the theme or plugins but I don't have time to hunt through someone elses poorly formatted, uncommented code when all I need is a temporary fix until I can rebuild the site.


text:
Q: Python - append JSON into main branch Maybe I am too stuck to see the simple solution for the following problem:
Given:
import json
a = {
  "24631331976_defa3bb61f_k.jpg668058":{
  "regions": {
      "0": {},
      "1": {}
      }
  }
}

b = {
  "16335852991_f55de7958d_k.jpg1767935":{
  "regions": {
      "0": {}
      }
  }
}

I want to append them in order to get the following output.
enter image description here
Thanks to Daniel Hepper and SegFault, the problem could be solved with:
a.update(b)

A: c = {}
c.update(a)
c.update(b)

Alternatively, if you are fine with modifying a:
a.update(b)

Note that your code uses Python dictionaries, not JSON strings.

A: You cannot 'append' a dict to another one, simply because the append add element  to the end of an ordered list of elements.
dicts don't have the notion of order, fist or last element. Thus no append for dict.
The action you want to do is merging two dicts, and you can do that using the update method defined for the dict type.
a.update(b)

PS: that will modify the dict a


text:
Q: How is the NetworkAdapter.NetworkAdapterID generated in UWP? I wanted to use the MAC Address of the device as a unique identifier, but this isn't exposed in the UWP API. The closest thing I can find is:
hostname.IPInformation.NetworkAdapter.NetworkAdapterId;
It seems to be the same value (after app restart and PC restart) but I don't know if it's robustly persistent. The docs don't seem to say, does anyone know what this ID actually consists of? Is it safe to use this as a reliable means of device identification?
If not, can someone recommend something?
Many thanks,
Peter

A:
How is the NetworkAdapter.NetworkAdapterID generated in UWP

Derive from this case,

No, the NetworkAdapterId value is a GUID and has nothing to do with the machine MAC address. You cannot get the MAC adress of the computer through WinRT APIs exposed for the Windows Store application type.


text:
Q: Firestore for web - on offline write, throw rather than save locally & sync on connection restore As far as I understand, Firestore, by default, works in such a way that if a write is made, but the client is offline, the write is stored locally, then sent to the server once the connection's restored.
It's an undesired behaviour for me, since:

*

*I've got an app that stores some data.

*Multiple users can update the same data.

*As far as I understand, if user A stores a local write due to network errors, then user B makes some changes, then user A gets his connection back running, then user's A write will overwrite user's B changes.

Therefore, I'd like to completely disable the offline features. If a write directly to the servers could not be completed for whatever reason, I'd like to have an error thrown, or be signaled in any other way, so I can simply inform the user. How do I do that?
My current code:
    firestore
      .collection("someData")
      .doc(props.id)
      .set({ contentState: content }, { merge: true })
      .catch(x => {
        console.log("Error!");
        setSyncError(true);
      });

The catch func never fires, I assume it's because the buffer-offline-writes capability is enabled by default.

A: You mention "Firestore for web" in your question's title.
Note that for the web, offline persistence is disabled by default, as explained in the doc:

When you initialize Cloud Firestore, you can enable or disable offline
  persistence:

*

*For Android and iOS, offline persistence is enabled by default. To disable persistence, set the PersistenceEnabled option to false.

*For the web, offline persistence is disabled by default. To enable persistence, call the enablePersistence method. Cloud Firestore's
  cache isn't automatically cleared between sessions. Consequently, if
  your web app handles sensitive information, make sure to ask the user
  if they're on a trusted device before enabling persistence.

For the case when there is no connection between your browser and the Firestore "backend"/service, please see the following Stack Overflow Q/A: How to detect firestore connection failure


text:
Q: Java: For loop on Objects of Strings I'm new in Java and I have to solve this exercise. I have this code:
    public class StringList {
        private String list = "";
        public StringList(String... str) {
            for (String s : str) list += s+"\t";
        }
    }

and I have to change the class so that its objects allow the iteration by using this instruction:
for (String s : new StringList("a", "b", "c")) System.out.println(s);

My idea was to create a List and iterate on it. So I changed the code in this way:
public class StringList {
    private List<String> list = new ArrayList<String>();
    public StringList(String... str) {
        for (String s: str) list.add(s);
    }
}

but when I try the iteration with the above instruction I get this error (Can only iterate over an array or an instance of java.lang.Iterable) and I spent hours trying to fix it but I keep failing. Any help?

A: You have to implement Iterable<String> to your StringList like this:
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Spliterator;
import java.util.function.Consumer;

public class StringList implements Iterable<String> {
    private List<String> list = new ArrayList<String>();

    public StringList(String... str) {
        for (String s: str) { list.add(s); }
    }

    @Override
    public Iterator<String> iterator() {
        return list.iterator();
    }

    @Override
    public void forEach(Consumer<? super String> action) {
        list.forEach(action);
    }

    @Override
    public Spliterator<String> spliterator() {
        return list.spliterator();
    }
}

A: To do it the clean way, give a look at the java.lang.Iterable interface : https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html
If your StringList class implements it, then the instruction will work. I'll let you complete the exercise yourself though, but you can start with
public class StringList implements Iterable<String> {
    // the attribute you need to store the strings object

    // your constructor

    @Override
    public Iterator<String> iterator() {
        // This is what you need to fill
    }
}

PS : Using a list of string as an attribute is not a bad idea at all and will save you a lot of efforts and time, search what you can do with it


text:
Q: Opening Google calendar from Flutter app (Deep Linking) I want to open Google calendar app more specifically the create event page in the app from my another flutter app.
I am using the URL launcher package but it opens the app in chrome
What change should I make in the URL so that the add event page opens directly in the google calendar app.
Currently my URL looks like below

https://calendar.google.com/calendar/u/0/r/eventedit?dates=20210226T033000/20210226T040000&ctz=Asia/Calcutta&location&text=Blawsome:+A+Crystal+Alchemy+Healing+Meditation&details=Parth+Pitroda

My code for that part is as below
if (await canLaunchUrl(Uri.parse('https://calendar.google.com/calendar/u/0/r/eventedit?dates=20210226T033000/20210226T040000&ctz=Asia/Calcutta&location&text=Blawsome:+A+Crystal+Alchemy+Healing+Meditation&details=Parth+Pitroda'))) {
await launchUrl(
            Uri.parse('https://calendar.google.com/calendar/u/0/r/eventedit?dates=20210226T033000/20210226T040000&ctz=Asia/Calcutta&location&text=Blawsome:+A+Crystal+Alchemy+Healing+Meditation&details=Parth+Pitroda'),
          mode: LaunchMode.externalApplication);
} else {
    throw 'Could not launch URL';
}

A: rathe than using a HTTP request, you could use googleapis package from https://pub.dev which has inbuilt methods to create Google Calender events directly within the Calender app.
Check package and documentation here.
Happy coding!


text:
Q: how to pass edited cell value to backend in ag-grid angular I am  trying to send the edited data in cell (ag-grid angular) to server, but i donot know how to do this, can anyone share me code examples
enter image description here
 onAddRow()
  {
    this.agGrid.api.updateRowData({
 add: [
{"DeviceMacAddress": rowNode.setDataValue(col,value)}
]
    });

in html
<button (click) = "onAddRow()">ADD ROW </butoton>

i do not know where i have to set the edited data and need to pass the edityed data along with first row data
first data in rows are coming from server and second row is added manually by using Add Row button ,here I am adding mac address and i want to push this to rowdata
this is my problem i am stuck here.

A: Step 1: Add this piece of code in the ag grid property:
      onCellValueChanged: (event) => this.inlineEdit(event),

Step 2:
inlineEdit(event){

        //you api call to send data to the server.

}

I hope it is what you are looking for :)


text:
Q: How can you deploy a web application onto one of many web servers using Ansible? I suspect I'm going about this in the wrong way, but I want to use Ansible to install one of a set of web servers and then install a web app on top of that. I'm having a hard time figuring out what the roles should look like and, in particular, what the app role should depend on.
I can have roles for each of the web servers, but then it seems like I'd have to have a role per app-webserver pair. There doesn't seem to be a way to have the app depend on any web server, or use a variable to specify the dependent role based on my attempts at using one in meta/main.yml.
Alternatively, I can have a generic webserver role that itself installs one of the supported webservers, but I'm not sure how that should work and I've been enable to find an example to refer to.
Perhaps I'm thinking about this the wrong way. Is duplication the only way to go about this? (I simplified the problem somewhat for brevity, in actuality I also have multiple databases that can be used, so the combinations would be m*n app-webserver-db triplets.)

A: I'm not sure to fully understand your problem. But it seems that you can solve this by organizing your inventory properly.
[webservers]
srv1
srv2
srv3
srv4

[application1]
srv1

[application2]
srv2

[application3]
srv3

[application4]
srv4

You can configure all webservers at once, and then install each application on the appropriate webserver.
---
- hosts: webservers
  roles:
    - webserver_role

- hosts: application1
  roles:
    - application1_role

- hosts: application2
  roles:
    - application2_role

- hosts: application3
  roles:
    - application3_role

- hosts: application4
  roles:
    - application4_role

webserver_role would install and configure the common stuff, while application1_role, application2_role, application3_role and application4_role would install and configure application specific stuff.

A: You can use groups of groups in your inventory. Create a main group webservers, and subgroups for every application server (geronimo, jetty, and so on) :
[webservers:children]
geronimo
glassfish
jetty
wildfly

[geronimo]
srv1

[glassfish]
srv2

[jetty]
srv3

[wildfly]
srv4

And then install appropriate application server according to the containing subgroup. And finally install application on every webservers :
---
- hosts: geronimo
  roles:
    - geronimo_role

- hosts: glassfish
  roles:
    - glassfish_role

- hosts: jetty
  roles:
    - jetty_role

- hosts: wildfly
  roles:
    - wildfly_role

- hosts: webservers
  roles:
    - application_role


text:
Q: how can i create html code (or other code) with input type text How can I create HTML code (or other code) with input type text when users insert texts or numbers and click go the browser go to domainurl.com/XXXinputtextXXX
Thanks.

A: Maybe like this:

function go(){
  var inp=document.getElementById('inp').value;
  window.location.href = "http://domainurl.com/XXX"+inp+"XXX";
}
<input type="text" id="inp">
<input type="button" onclick="go();" value="go">

A: You can use the onclick event to trigger a function which redirects you using window.location:
* Note: The snippet will not take you to the website (so test it on your local device). Also the current website will redirect you if it doesn't understand the path, so you will only see your URL for a few seconds before it redirects.

function openWindow() {
  let inputtext = document.getElementById('text-box').value; // Get the inputted text from text box
  window.location = "http://www.domainurl.com/XXX" +inputtext +"XXX"; // Take the user to the location with the input
}
<input type="text" id="text-box" />
<button id="btn" onclick="openWindow()">Click me</button>


text:
Q: Changing an array to list in TFS Reports Creating a report in Team Foundation Server(TFS) and my parameter is set as an array and I want to be able to display this array. I want to be able to switch the array to a list and then be able to show what is selected out of the list by the parameter the user selects. Can someone help please?? :)

A: A multi-valued parameter is returned as an array, have you tried something like...
=JOIN(Parameters!MyParameter.Label,",")

...in a text box?


text:
Q: It takes time while exporting telerik grid to pdf I am trying to export telerik grid data to pdf/excel. Although telerik provides handy methods to export grid to pdf/excel but it takes lots of time to export the grid to desired format if there are more than 500 rows in the grid.
Note: I want to export whole data but not visible page in the grid.
Thanks
Anil.

A: The time needed to export this content depends strongly on your grid structure. You may be able to export 500 items or even 30000 items but to reiterate, it all depends on your setup. Post your markup here and I will look inside for you.


text:
Q: convert a C nested for loop to arm32 I want to convert this C nested for loop into arm64 assembly language, the purpose of the loop is to loop throughout a matrix and call the function callback to set each pixel of that matrix to a certain color, I was wondering would I call the callback(I, J,0) under the bx lr in done or in the inner loop
for (int i=0;i<8;i++){
    for (int j=0;j<8;j++){
        calledback(I,j,0);
    }
}

.global _start
.text
_start:

     #open frame buffer 1
        mov r0,#1
        bl openfb
        cmp r0,#0
        blt _start_exit

        mov r1,#0
loop_outer:
        cmp r2,#8       #i < 8
        bge done
        mov r3,r1       #i = 0
        ADD r3,r3,#1    #i++
        loop_inner:
                mov r4,r1       #j = 0
                cmp r5,#8       #j < 8
                ADD r6,r6,#     #i++
                bge inner_done  #goes back to inner loop
        inner_done:
                b loop_outer
done:
        MOV r0,r1
        bx lr

        #close frame buffer and clean up data strucutres created by openfb
        bl closefb

_start_exit:
        #clean exit
        mov r7,#1
        svc #0


text:
Q: Use checkpoint and a MRAN snapshot as CRAN mirror with travis-ci? I'd like to use the checkpoint package or the MRAN snapshot repo to set the versions of packages that get used when my package is built on Travis-CI.
I'm looking for advice on getting either of these working:

*

*Travis using the local files (i.e. stored in the github repo of my pkg) of the packages that my package depends on. For example, if I use checkpoint to download the sources of the packages and store them in a directory with my package, how can I get Travis to install the packages from that local location, rather than from CRAN? or,

*Travis use the MRAN snapshot URL to download the packages archived on a specific date, as set in the URL.
I've been experimenting with various options in the .travis.yml file in this test package: https://github.com/benmarwick/checkpointtest
For example, here are .travis.yml files that I've tried:
# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r

language: R
sudo: false
cache: packages
warnings_are_errors: false

cran: https://mran.revolutionanalytics.com/

and
# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r

language: R
sudo: false
cache: packages
warnings_are_errors: false

repos:
  CRAN: https://mran.revolutionanalytics.com/snapshot/2016-09-02

and
# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r

language: R
sudo: false
cache: packages
cran: https://mran.revolutionanalytics.com/snapshot/2016-09-02
env:
  global:
  - R_LIBS_USER=~/vignettes/packages/.checkpoint/2016-09-02/lib/x86_64-w64-mingw32/3.3.1
  - R_LIBS_SITE=~/vignettes/packages/.checkpoint/2016-09-02/lib/x86_64-w64-mingw32/3.3.1

And several other combinations.
So far everything has resulted in an error (https://travis-ci.org/benmarwick/checkpointtest), often this is the error message:
W: Failed to fetch https://mran.revolutionanalytics.com//bin/linux/ubuntu/precise/Packages server certificate verification failed.
 CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none

How can I get Travis-CI to be aware of the checkpoint package, and not contact CRAN to download dependencies?
This question is related to my packrat question about getting Travis to use non-CRAN package sources.

A: This appears to work:
# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r

language: R
sudo: false

cache:
  packages: true

repos:
  MRAN: "https://mran.microsoft.com/snapshot/2016-11-08"

warnings_are_errors: false


text:
Q: How do I install OpenMCU on Debian(9.1) server? If it doesnt exist, what are the alternatives? Using this as a guide:
https://wiki.videoswitch.ru/en/install/bin_linux
The entire thing seems abandoned but I was willing to try anyways.
The wget returned nothing for Debian. I tried compiling from source somehow but I realized the source files link was 404'd too. Out of desperation I tried installing through the Ubuntu repositories but that 404'd too. "Releases has no release files" after I run apt-get update
Is the project abandoned? Are there any alternatives, that could be connected into IMS later on?
After reading into Ekiga from a slightly older thread but after checking out the website it looks like a client not something I could build videoconferencing server on.

A: The main "official home page" certainly seems to have been taken over by sex peddlers.  But there are still source code repositories that you can copy (albeit at your own risk, as their provenances seem somewhat suspect):

*

*https://github.com/muggot/openmcu

*https://github.com/tamldt/tamldt_openmcu

*https://github.com/FreeMCU/freemcu

*https://github.com/15623668525/openmcu-ru

*… and so on.


text:
Q: Is there a way to add a script that runs before any elements are added to the DOM but that relies on the body element? I am attempting to check every mutation on a page using MutationObserver.
Is there a simple way to fix the following so I don't have to include it in the body (i.e. include it in the <head>) as an inline script?
The issue comes with the fact that I need the bodyList variable to be able to start monitoring items added to the page.
Obviously I can't use the onLoad event or anything as by then the mutations have all occurred (unless there is a way of accessing them after the fact I am unaware of?).
Or is there a way to attach the mutation observer to the document itself rather than an element?
I am sure the answer is simple but I can't find any documentation that covers this.
<body>
<script>
//I want to move this inline script into the <head>
var bodyList = document.querySelector("body"),
            observer = new MutationObserver(function (mutations) {
                mutations.forEach(function (mutation) {
                   console.log("MUTATION", mutation)
                });
            });
    observer.observe(bodyList, {childList: true, subtree: true});
</script>
....all the HTML elements that I want to monitor

A: You can attach an observer to the HTML document itself, wait for the <body> to appear, then attach an observer to the body:
// In the <head>:
new MutationObserver((_, observer) => {
    const { body } = document;
    if (!body) return;
    // Remove this observer, since it's not needed anymore; body exists
    observer.disconnect();
    new MutationObserver(function (mutations) {
        mutations.forEach(function (mutation) {
            console.log("MUTATION", mutation)
        });
    })
        .observe(body, { childList: true, subtree: true });
})
    .observe(document.documentElement, { childList: true });


text:
Q: Working with BLE Android 4.3 how to write characteristics? I am working on a BLE project (Android application) using Android 4.3 API, i have used sample BLE app it is only reading characteristics in DeviceControlActivity.activity, but i want to write characteristics and send it to BLE chip on clicking a button. How can I write data on chip cc2540 .. Basically i don't know the step by step procedure to write characteristics.
write i can only see the name and id of device with following piece of code in DeviceControlActivity
 private final ExpandableListView.OnChildClickListener servicesListClickListner =
        new ExpandableListView.OnChildClickListener() {
            @Override
            public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
                                        int childPosition, long id) {
                if (mGattCharacteristics != null) {
                    final BluetoothGattCharacteristic characteristic =
                            mGattCharacteristics.get(groupPosition).get(childPosition);
                    final int charaProp = characteristic.getProperties();
                    if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
                        // If there is an active notification on a characteristic, clear
                        // it first so it doesn't update the data field on the user interface.
                        if (mNotifyCharacteristic != null) {
                            mBluetoothLeService.setCharacteristicNotification(
                                    mNotifyCharacteristic, false);
                            mNotifyCharacteristic = null;
                        }
                        mBluetoothLeService.readCharacteristic(characteristic);
                        showDialog("reading");
                    }

                    if ((charaProp | BluetoothGattCharacteristic.PROPERTY_WRITE) > 0) {
                        // If there is an active notification on a characteristic, clear
                        // it first so it doesn't update the data field on the user interface.
                        if (mNotifyCharacteristic != null) {
                            mBluetoothLeService.setCharacteristicNotification(
                                    mNotifyCharacteristic, false);
                            mNotifyCharacteristic = null;
                        }
                        mBluetoothLeService.writeCharacteristic(characteristic);
                        showDialog("writing");
                        //characteristic.setValue(bytes);
                        //characteristic.setValue("testing");
                        //characteristic.setWriteType(BluetoothGattCharacteristic.PERMISSION_WRITE);
                    }
                    if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
                        mNotifyCharacteristic = characteristic;
                        mBluetoothLeService.setCharacteristicNotification(
                                characteristic, true);
                    }

                    byte[] value = {0x00, (byte) (0xB9) , 0x0D, (byte) (0x90), 0x2F};
                    if(!characteristic.setValue(value))
                    {
                        Log.w(TAG, "Couldn't set characteristic's local value");
                        //return;
                    }

                    characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE);
                    /*if(!writeCharacteristic.writeCharacteristic(characteristic))
                    {
                        Log.w(TAG, "Couldn't write characteristic");
                    }*/

                    return true;
                }
                return false;
            }
};

A: Please note that the logic OR in:
if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0)" in the original post should be a logic AND for the permission check to work. Same for the second charaProp comparison. Otherwise bot statements are true regardless of the actual permission flag.

A: The following code is write characteristic using string data in utf-8 format:
public void writeCharacteristic(BluetoothGattCharacteristic characteristic,
            String data) {
        if (mBluetoothAdapter == null || mBluetoothGatt == null) {
            Log.w(TAG, "BluetoothAdapter not initialized");
            return;
        }

        Log.i(TAG, "characteristic " + characteristic.toString());
        try {
            Log.i(TAG, "data " + URLEncoder.encode(data, "utf-8"));

            characteristic.setValue(URLEncoder.encode(data, "utf-8"));

            // TODO
            mBluetoothGatt.writeCharacteristic(characteristic);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }

Hope it helps!

A: The following code is write characteristic using byte[] data:
    public boolean writeCharacteristic(){

    //check mBluetoothGatt is available
    if (mBluetoothGatt == null) {
        Log.e(TAG, "lost connection");
        return false;
    }
    BluetoothGattService Service = mBluetoothGatt.getService(your Services);
    if (Service == null) {
        Log.e(TAG, "service not found!");
        return false;
    }
    BluetoothGattCharacteristic charac = Service
            .getCharacteristic(your characteristic);
    if (charac == null) {
        Log.e(TAG, "char not found!");
        return false;
    }

    byte[] value = new byte[1];
    value[0] = (byte) (21 & 0xFF);
    charac.setValue(value);
    boolean status = mBluetoothGatt.writeCharacteristic(charac);
    return status;
}

A: public boolean writeCharacteristic(byte value[],int type){
    //check mBluetoothGatt is available
    if (mBluetoothGatt == null) {
        Log.e(TAG, "lost connection");
        return false;
    }
    BluetoothGattService Service = mBluetoothGatt.getService(UUID_SIMPLESERVICE);
    if (Service == null) {
        Log.e(TAG, "service not found!");
        //////////NO service found...........
         return false;
    }
    BluetoothGattCharacteristic charac1 = null;
    boolean status1 = false;

    if(type==1) {
        charac1 = Service.getCharacteristic(UUID_PORT1);
        charac1.setValue(value);
        status1 = mBluetoothGatt.writeCharacteristic(charac1);
        Log.v("________BLESERVICE____", "___WRITE CHARATERISTICS STATUS:_________"+status1);
        onReliableWriteCompleted(status1);
    }
    if (charac1 == null) {
        Log.e(TAG, "char not found!");
        return false;
    }

    Log.v("___TYPE___","______________________"+type);
    return status1;
}


text:
Q: Phalcon - Module exception if does not exist I have set the Route:
$router->add('/:module/:controller/:action/:params', [
      'module' => 1,
      'controller' => 2,
      'action' => 3,
      'params' => 4
]);

When I enter URL to the browser, for example: auth/login/index and module under this URL does not exist, so it throws an exception:
Phalcon\Mvc\Application\Exception: Module 'auth' isn't registered in the application container

How can I catch this exception?
SOLUTION:
    $router->add('/:module/:controller/:action/:params', [
        'module' => 1,
        'controller' => 2,
        'action' => 3,
        'params' => 4
    ])->beforeMatch(function($uri) use ($application) {

        $modules = $application->getModules();

        $moduleName = array_filter(explode('/', $uri))[1];

        if(!isset($modules[$moduleName]))
            return false;

        return true;
    });

In beforeMatch method I check If module exist.

A: For second param you can use closure and check via
if ($di->has('modulename'))

Update1
As I can see https://github.com/phalcon/cphalcon/blob/master/phalcon/mvc/application.zep#L232
you can use event manager and return false from beforeStartModule if module not found in DI
if typeof eventsManager == "object" {
    if eventsManager->fire("application:beforeStartModule", this, moduleName) === false {
        return false;
    }
}

Update2
Also you can use dispatcher setting:
// Initialize the Dispatcher
$di->setShared('dispatcher', function() use ($eventsManager) {
    $dispatcher = new \Phalcon\Mvc\Dispatcher;

    // Attach a listener for type "dispatch:beforeException"
    $eventsManager->attach('dispatch:beforeException', function($event, $dispatcher, $exception) {
       /**
        * @var \Phalcon\Mvc\Dispatcher\Exception $exception
        * @var \Phalcon\Mvc\Dispatcher $dispatcher
        */
       switch ($exception->getCode()) {
           case \Phalcon\Mvc\Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
           case \Phalcon\Mvc\Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
           case ANY OTHER CODE HERE:
               $dispatcher->forward([
                   'controller' => 'error',
                   'action'     => 'show404'
               ]);
               return false;
       }
    });

    // Setting up the Dispatcher component
    $dispatcher->setDefaultNamespace('your_default_namespace_here');

    // Obtain the Events Manager from the DI and bind the eventsManager to the module dispatcher
    $dispatcher->setEventsManager($eventsManager);

    return $dispatcher;
});


text:
Q: full image caption for images with dynamic size I have this code:
HTML

caption

caption

caption

CSS
.box {
    position: relative;
    width: 30%;
    height: auto;
    display: inline-block;
}

.box img {
    height: auto;
    width: 100%;
    position: absolute;
    left: 0;
}

.box span {
    position: absolute;
    width: 100%;
    height: auto;
    color: #FFF;
    left: 0;
    background-color: #FF0000;
}

You can find it here:
http://jsfiddle.net/v2Vk3/3/
Just want the caption to be the same height and width as the image, overlaping it and without changing the automatic resizing for images.
Is there any way to get this working with CSS?
Thx

A: I guess you have asked for this http://jsfiddle.net/6hgCj/
.box {
position: relative;
width: 30%;
height: auto;
display: inline-block;
}

.box img {
height: auto;
width: 100%;
}

.box span {
position: absolute;
width: 100%;
height: 100%;
color: #FFF;
left: 0;
top:0;
background-color: #FF0000;
}


text:
Q: How to customize the servlet port for an embedded JBoss server using Maven plugin 'jboss-as-maven-plugin'? I'm using Maven 3.0.4 with jboss-as-maven-plugin for embedded JBoss server. I would like to customize the port on which JBoss listens for requests, normally 8080. However, I can't customize it with the "port" property in the configuration section. Below is my configuration:
    <plugin>
        <groupId>org.jboss.as.plugins</groupId>
        <artifactId>jboss-as-maven-plugin</artifactId>
        <version>7.4.Final</version>
        <configuration>
             <port>8082</port>
        </configuration>
    </plugin>

I've checked the official documentation for jboss-as-maven-plugin: https://docs.jboss.org/jbossas/7/plugins/maven/latest/run-mojo.html
but don't know what's wrong in it.
In server.log, there is no ERROR message but stop at below:
...
12:52:03,385 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-8) Pausing Coyote HTTP/1.1 on http--127.0.0.1-8080
12:52:03,385 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-8) Stopping Coyote HTTP/1.1 on http--127.0.0.1-8080
12:52:12,859 INFO  [org.jboss.as.configadmin] (ServerService Thread Pool -- 26) JBAS016200: Activating ConfigAdmin Subsystem
12:52:12,866 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 31) JBAS010280: Activating Infinispan subsystem.
12:52:12,876 INFO  [org.jboss.as.osgi] (ServerService Thread Pool -- 39) JBAS011940: Activating OSGi Subsystem
12:52:12,877 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 38) JBAS011800: Activating Naming Subsystem
12:52:12,888 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 44) JBAS013101: Activating Security Subsystem
12:52:12,910 INFO  [org.jboss.as.connector] (MSC service thread 1-2) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final)
12:52:12,936 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
12:52:12,964 INFO  [org.jboss.as.security] (MSC service thread 1-5) JBAS013100: Current PicketBox version=4.0.7.Final
12:52:12,978 INFO  [org.jboss.as.naming] (MSC service thread 1-8) JBAS011802: Starting Naming Service
12:52:13,016 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-2) JBAS015400: Bound mail session [java:jboss/mail/Default]
12:52:13,078 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
12:52:13,112 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-2) JBoss Web Services - Stack CXF Server 4.0.2.GA
12:52:13,393 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-4) JBAS015012: Started FileSystemDeploymentService for directory D:\mshello\SWS-Client\target\jboss-as-run\jboss-as-7.1.1.Final\standalone\deployments
12:52:13,400 INFO  [org.jboss.as.remoting] (MSC service thread 1-3) JBAS017100: Listening on /127.0.0.1:4447
12:52:13,401 INFO  [org.jboss.as.remoting] (MSC service thread 1-8) JBAS017100: Listening on /127.0.0.1:9999
12:52:13,408 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-2) Starting Coyote HTTP/1.1 on http--127.0.0.1-8080
12:52:13,523 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
12:52:15,125 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
12:52:15,127 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 3534ms - Started 133 of 208 services (74 services are passive or on-demand)
<< stopped here >>

I can see [org.apache.coyote.http11.Http11Protocol] is still listening on http--127.0.0.1-8080, is it the cause? If yes, how to configurate it in pom.xml?
After removing the whole configuration about port 8082, the server can be startup successfully by mvn jboss-as:run without any problem.
Any suggestion?

A: You could copy the standalone.xml and change the port numbers in the <socket-binding-group/> section. Then you would use the serverConfig configuration property to point to the standalone.xml you created.


text:
Q: Kubernes Job Curl URL using bad/illegal format or missing URL I prepared a job yaml file and deployed it. Job will send post request to grafana api create user method. However it returns error.
error: "curl: (3) URL using bad/illegal format or missing URL"
How Should I change command lines?
yaml file:
apiVersion: batch/v1
kind: Job
metadata:
  name: grafanauser-ttl
spec:
  ttlSecondsAfterFinished: 100
  template:
    spec:
      containers:
      - name: grafanauser
        image: curlimages/curl:7.72.0
        command:
            - '/bin/sh'
            - '-ec'
            - 'curl -X POST "http://admin:admin@grafana.utility.svc.cluster.local/api/admin/users" \
                -H "Content-Type:application/json" -d \
                "{"name":"test","email":"test@localhost.com","login":"test","password":"test","OrgId": 1}"'
      restartPolicy: OnFailure

A: Your curl command isn't properly formated that's why you're seeing this issue. There's a couple of other threads regarding this error message you're receiving from curl.
However a quick fix would be to supply the curl in a single line. The following would work:
---
apiVersion: batch/v1
kind: Job
metadata:
  name: grafanauser-ttl
spec:
  ttlSecondsAfterFinished: 100
  template:
    spec:
      containers:
        - name: grafanauser
          image: curlimages/curl:7.72.0
          command:
            - /bin/sh
            - -ec
            - 'curl -X POST "http://admin:admin@grafana.utility.svc.cluster.local/api/admin/users" -H "Content-Type:application/json" -d "{"name":"test","email":"test@localhost.com","login":"test","password":"test","OrgId": 1}"'
      restartPolicy: OnFailure

I don't have the service running, but you shouldn't receive the curl error anymore:
$ kubectl logs grafanauser-ttl-xjt2q
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: grafana.utility.svc.cluster.local

A: You shell command line translates to
curl -X POST "http://admin:admin@grafana.utility.svc.cluster.local/api/admin/users"                 -H "Content-Type:application/json" -d                 "{"name":"test","email":"test@localhost.com","login":"test","password":"test","OrgId": 1}"

which will make shell strip away all the quotes:
curl -X POST http://admin:admin@grafana.utility.svc.cluster.local/api/admin/users -H Content-Type:application/json -d {name:test,email:test@localhost.com,login:test,password:test,OrgId: 1}

and curl will choke on the final 1} (its last argument)
Try rewriting it using YAML block literal:
        command:
            - '/bin/sh'
            - '-ec'
            - |
                curl -X POST "http://admin:admin@grafana.utility.svc.cluster.local/api/admin/users" \
                -H "Content-Type:application/json" -d \
                '"{"name":"test","email":"test@localhost.com","login":"test","password":"test","OrgId": 1}'


text:
Q: Decomposing a entry-wise positive positive-semidefinite matrix? Let $\mathbf{A}$ be a symmetric $n\times n$ positive semi-definite matrix and also such that each of its entry is positive. Does $\mathbf{A}$ have a decomposition of the form
\begin{align}
\mathbf{A} \,=\,\sum_{i=1}^{i=k}\mathbf{y}_i\mathbf{y}_i^T
\end{align}
where each vector $\mathbf{y}$ is also entry-wise positive and $k\leq n$.


text:
Q: Binding Values to WHERE IN(sql) I wan't to create sql query search based on sidebar options selected for holiday search. So i generate an array of clicked values, and based on that array keys i generate dynamic_str;
$base_sql = 'SELECT * FROM holidays';
$dynamic_str_sample ='WHERE country IN (:countries)';
//country - one of the keys, :countries values([france, uk, etc]) Adding some 'AND' and other key value pairs based on options selected.

> $stmt = $this->db->bindValue(:countries, $string-with-commas-originally-made-from-array-values);
// there is a for loop if i need to bind multiple values (:values[index]);

doesn't work. Might be a bit confusing, adding sample selection array under which i'm constructing sql query:
Array
(
    [Price] => Array (
            [0] => 101-300
            [1] => 301-500
            [2] => 501-700
        )

    [KelionesTipas] => Array
        (
            [0] => chill
        )

    [Country] => Array
        (
            [0] => Spain
            [1] => Portugal
        )
)


text:
Q: Extract text from brackets I have a file like this:
input file:
Evigen1000005_c0_g1_i1  0.240   1.212   1.408   3.784   2.029   0.963   -1.22409810298695       1       NA      NA      NA      NA      PF04597.13;Ribophorin_I;4.6e-148        NA      1;21;0.875      len=569;ExpAA=32.49;First60=12.82;PredHel=1;Topology=o433-450i     Q9SFX3  OST1A_ARATH     reviewed        Dolichyl-diphosphooligosaccharide--protein_glycosyltransferase_subunit_1A_(EC_2.4.99.18)_(Ribophorin_IA)_(RPN-IA)_(Ribophorin-1A)  OST1A_RPN1A_At1g76400_F15M4.10  Arabidopsis_thaliana_(Mouse-ear_cress)  614     protein_N-linked_glycosylation_via_asparagine_[GO:0018279]      endoplasmic_reticulum_[GO:0005783];_integral_component_of_membrane_[GO:0016021];_membrane_[GO:0016020];_oligosaccharyltransferase_complex_[GO:0008250]     dolichyl-diphosphooligosaccharide-protein_glycotransferase_activity_[GO:0004579]        3702.AT1G76400.1;  PF04597;        IPR007676;      3702    ath:AT1G76400;  F15M4.10        2.4.99.18       SUBCELLULAR_LOCATION:_Endoplasmic_reticulum_membrane_{ECO:0000250};_Single-pass_type_I_membrane_protein_{ECO:0000250}.  SIGNAL_1_25_{ECO:0000255}. AT1G76400.1;    NA      NA      NA      NA      NA      NA      NA      NA      NA      NA      NA
Evigen1000006_c0_g1_i1  0.358   0.179   0.000   0.424   0.139   0.183   NA      NA      NA      NA      NA      NA      PF07767.10;Nop53_(60S_ribosomal_biogenesis);5.2e-21     NA      1;31;0.588      len=170;ExpAA=14.33;First60=14.27;PredHel=0;Topology=o     O22892  NOP53_ARATH     reviewed        Ribosome_biogenesis_protein_NOP53       At2g40430_T2P4.22       Arabidopsis_thaliana_(Mouse-ear_cress)  442     ribosomal_large_subunit_assembly_[GO:0000027];_ribosomal_large_subunit_export_from_nucleus_[GO:0000055]    nucleolus_[GO:0005730];_nucleoplasm_[GO:0005654]        rRNA_binding_[GO:0019843]       3702.AT2G40430.2;       PF07767;   IPR011687;      3702    ath:AT2G40430;  T2P4.22 SUBCELLULAR_LOCATION:_Nucleus,_nucleolus_{ECO:0000250|UniProtKB:Q9NZM5}._Nucleus,_nucleoplasm_{ECO:0000250|UniProtKB:Q9NZM5}.   AT2G40430.1_[O22892-1]; NA NA      NA      NA      NA      NA      NA      NA      NA      NA      NA      NA      NA

I want to take out the text form the brackets which only starts with "GO:". After each GO: there are 7 digits. e.g. "GO:0018279". They are GO terms. The number of GO terms in each row are not equal. The output must be a file which the first column includes the Untranscript ids (e.g. Evigen1000005_c0_g1_i1) and the rest GO terms. I want an output file like this:
output file:
Evigen1000005_c0_g1_i1 GO:0018279 GO:0005783 GO:0016021 GO:0016020 GO:0008250 GO:0004579
Evigen1000006_c0_g1_i1 GO:0000027 GO:0000055 GO:0005730 GO:0005654 GO:0019843

A: How about
sed -r 's/(^[^[:space:]]* )[^[]*\[/\1/; s/\][^[]*(\[|$)/ /g' file
Evigen1000005_c0_g1_i1 GO:0018279 GO:0005783 GO:0016021 GO:0016020 GO:0008250 GO:0004579
Evigen1000006_c0_g1_i1 GO:0000027 GO:0000055 GO:0005730 GO:0005654 GO:0019843 O22892-1

Your desired output does NOT reflect the processed input sample.
EDIT: or even
sed -r 's/((^[^ ]* )|\])[^[]*(\[|$)/\2 /g' file

EDIT: with your question and desired output three times revised, try
sed -r 's/((^[^ ]* )|\])[^[]*(\[GO)/\2 GO/g; s/\].*$//' file

A: Suggested script, that matches your final specification.
#!/bin/bash

while read line
do
# echo "$line"
 name=${line%% *}
 echo -n "$name "
 data=$(<<< "$line" grep -o '\[GO:.\{7\}\]' | tr '\n' ' ' | sed -e 's/\[//g' -e 's/\]//g')
 echo "$data"
done < "$1"

Testing:
$ ./script input
Evigen1000005_c0_g1_i1 GO:0018279 GO:0005783 GO:0016021 GO:0016020 GO:0008250 GO:0004579
Evigen1000006_c0_g1_i1 GO:0000027 GO:0000055 GO:0005730 GO:0005654 GO:0019843

A: Faster in sed:
start='\[GO:' end='\]'
sed -e 's,'"$start"$',\1,g' -e 's,'"$end"$',\2,g' \
    -e $'s, [^\1]*, ,' -e $'s,\1\\([^\2]*\\)\2[^\1]*,GO:\\1 ,g' \
    infile

or awk:
awk -vone=$'\1' -vtwo=$'\3' -vstart='\[GO:' -v end='\]' '
           {
            printf("%s ",$1);
            gsub(start,one);
            gsub(end,two);
            sub("^[^"one"]*"one,"GO:")
            gsub(two"[^"one"]*"one," GO:")
            sub(two".*$" ,"")
           }
           1' infile


text:
Q: How to capture combination of keys( CTRL+ALT + SPACE) in WPF RichEdit control i want to capture key combination such as ALT+CTL+SPACE in my RichEdit control in WPF.

A: You can add  PreviewKeydown event for RichTextBox.
PreviewKeyDown="TextBox_OnPreviewKeyDown" in xaml

event handler in code behind as follows
private void TextBox_OnPreviewKeyDown(object sender, KeyEventArgs e)
{

    if (Keyboard.IsKeyDown(Key.LeftCtrl) && Keyboard.IsKeyDown(Key.LeftAlt) &&
        Keyboard.IsKeyDown(Key.Space))
    {
        //  All keys were pressed
    }
}

you can test when three keys are pressed.


text:
Q: Как с рекурсией вернуть общий корень двух древ (древо не двоичное)? Существует класс дерева(не двоичное), но с одной особенностью. У каждого есть своё id.
Как с помощью рекурсии вернуть ближайшее общее материнское дерево в методе closest_node? В функции closest_node нужно найти его с помощью id в виде аргумента.

Например,у древ T6 И T1 ближайшее общее материнское древо это T2. У древ T2 и T3 ближайшее общее материнское древо это T3. У древ T4 и T5 ближайшее общее материнское древо это T3.
class Tree:
    _id: int
    _main: Optional[IdTree]
    _nodes: List[IdTree]

    def __init__(self, id:int) -> None:
         self._main = None
         self._nodes= []

    def add_node(self, node: IdTree) -> None:
        """Добавьте нижние древо в список <self._nodes> и поставьте <self> главным древом <node>.
        """
        self._nodes.append(node)
        node._main = self

    def closest_node(self, id: int) -> Tree:
        """Верните ближайшее общее материнское древо с помощью рекурсии.
        >>> t1 = Tree(1)
        >>> t2 = Tree(2)
        >>> t3 = Tree(3)
        >>> t4 = Tree(4)
        >>> t5 = Tree(5)
        >>> t2.add_node(t1)
        >>> t3.add_node(t2)
        >>> t3.add_node(t4)
        >>> t4.add_node(t5)
        >>> t3.closest_node(1)
        >>> t3
        >>> t3.closest_node(3)
        >>> t3
        >>> t1.closest_node(5)
        >>> t3
        """


text:
Q: jqGrid - Default Sort Order by Column Happy New Years Eve!
I would like to be able to set the default for value some columns to descending. So, the first time the user clicks on that column, it sorts descending by nature.
I have no problem setting the default sort field and order of my grid. But that is all the info I am finding.
$grid->setGridOptions(array(

"caption"=>"Player Statistics",
"rowNum"=>200,
"rowList"=>array(50,200,1000),
"sortname"=>"percentOwned",
"sortorder" => 'desc',
"width" => 1000,
"height" => 400,
"hoverrows" => true,
"viewrecords" => false

));

How do I set the default sort to descending on a per column basis? Is it possible?
Thanks!

A: Although not in the documentation, 'firstsortorder' => 'desc' does the trick.
$grid->setGridOptions(array(
'firstsortorder' => 'desc'
"caption"=>"Player Statistics",
"rowNum"=>200,
"rowList"=>array(50,200,1000),
"sortname"=>"percentOwned",
"sortorder" => 'desc',
"width" => 1000,
"height" => 400,
"hoverrows" => true,
"viewrecords" => false
));