text:
Q: uiview animation used to work on iphone sdk 2.2 and now it doesn't on sdk 3.0 I have an animation block that worked fine when runnung the app on iphone OS 2.2. Now I compile the same code for iphone OS 3.0 and it doesn't work.
UIViewAnimationTransition  trans = UIViewAnimationTransitionFlipFromLeft;

[UIView beginAnimations: nil context: NULL];
UIView *forview = [[self view] superview];
[UIView setAnimationTransition: trans forView:forview  cache: YES];
[UIView setAnimationDuration:1.0];

[[self navigationController] popViewControllerAnimated:NO];

[UIView commitAnimations];

What the code does, it uses the navigation controller to change the top most view, but with the flip transition and not with the built in one.
any ideas on what might have change in the sdk or what I'm doing wrong?
thanks!!

A: This isn't a direct answer to your question but depending on why you're doing this, it may be possible to achieve the effect you're after by using presentModalViewController:animated: with a modalTransitionStyle of UIModalTransitionStyleFlipHorizontal.


text:
Q: Docker: how to set a custom domain name for container? I'm deploying with Docker a PHP server available at localhost:8085.
How can I set Docker so that my container is available at a custom domain name (https://example.com) on my local network?
In result, every user connected to the same WiFi network would access to the server using the URL https://example.com (pointing to localhost:8085).

redpajama_set_name: RedPajamaStackExchange


text:
Q: В каком порядке выполняются фикстуры? Использую pytest для тестирования. Использую фикстуры в качестве тестовых пре- и посткондишенов. Но разные тесты требуют разный набор этих самых прекондишенов и для получения тестовых данных.
Обычный тест имеет вид:
@pytest.mark.usefixtures('fixture1', 'fixture2')
def test_testname(some_fixture):
    pass

some_fixture - постоянно плавающая фикстура, которая для каждого теста разная. Это тестовые данные.
fixture1 и fixture2 - это фикстуры, которые, как раз-таки, приводят систему в необходимое состояние. На данный момент они друг от друга никак не зависят.
В это уравнение мне нужно впихнуть fixture3. При этом важно, чтобы она выполнялась ПЕРЕД fixture1.
Если фикстуры в usefixtures выполняются просто по порядку, то вопрос снимается как дурацкий. Если же нет, то как?


text:
Q: Where to handle logic in MVVM view models? After some initial reading on WPF and MVVM i'm currently working on a small debug application for a digital IO controller. In this application i'v got a tree of view models, which looks like this:
IOControllerViewModel > ConfigurationViewModels > PortViewModels > ChannelViewModels
This corresponds to the business objects, where the IOController contains a set of Configurations, which then contains a list Ports, which then contains a list of Channels, which finally represent the input/output channels of the IO controller.
But now my question is where to handle the "logic"?
For example i want to toggle the state of a output channel. The IOControllerViewModel is currently the only instance, which has a reference to the business object, that contains the needed ToggleChannel() method. Now i see three options:

*

*Put the login inside the ChannelViewModel. Thus pass the
necessary business object from my root all way down to the leafs.

*Put the logic inside the IOControllerViewModel. Thus an event or
something similar must be fired by the ChannelViewModel and then
handled by the IOControllerViewModel.

*Introduce a controller, which is responsible for any logic and
publish the controller to all view models.

*Any other option? Best practice?
Thanks a lot!

A: Usually I put logic on the layer that uses it, and use a messaging system such as PRISM's EventAggregator or MVVM Light's Messenger to communicate between ViewModels. (If you're interested, I wrote a brief post about this here)
In your case, it depends on what layer handles the login. For example, if a LoginViewModel successfully authenticates a user, it would broadcast something like a UserAuthenticated message, containing relevant parameters. Interested ViewModels could then subscribe to UserAuthenticated messages, and handle them accordingly.
Keep in mind that with MVVM, your ViewModels are you application. The app should run just fine without any Views at all (such as from a Test script)

A: If I understood you correctly you're using a hierarchical structure which could live with just one ViewModel, the IOControllerViewModel. All those Configurations, Ports and Channels could be observable properties or collections of its corresponding item.
You would then just use an IOControllerView which contains an ItemsControl which accesses all configurations. In the DataTemplate of each configuration item you would have an ItemsControl which uses the ports as ItemsSource and so on.
It's not good to have more ViewModels than needed, especially if there's no need for a View because you could use a DataTemplate instead.
I hope I got you right.


text:
Q: Implement errorhandler in WCF with IoC I'm trying to implement an errorhandler on my WCF service following this tutorial:
Implementing IErrorHandler
In this errorhandler I want every exception to log into a logfile, by passing my logger, implementing ILogger (using by NLog in my case).
The problem now is that I want to use dependency injection, with the logger as a constructor parameter, initialized by my IoC container (using SimpleInjector).
Anybody who can help me with this? (FYI... I'm quite new with DI and IoC)
ErrorHandler:
public class ErrorHandler : IErrorHandler, IServiceBehavior
{
    private readonly ILogger _logger;

    public ErrorHandler(ILogger logger)
    {
        _logger = logger;
    }

    public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters)
    {
    }

    public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
    {
        IErrorHandler errorHandler = new ErrorHandler(_logger);

        foreach (ChannelDispatcherBase channelDispatcherBase in serviceHostBase.ChannelDispatchers)
        {
            var channelDispatcher = channelDispatcherBase as ChannelDispatcher;

            if (channelDispatcher != null)
            {
                channelDispatcher.ErrorHandlers.Add(errorHandler);
            }
        }
    }

    public bool HandleError(Exception error)
    {
        _logger.Error("EXCEPTION: ", error);
        return true;
    }

    public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
    {
    }

    public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
    {
        // Shield the unknown exception
        FaultException faultException = new FaultException("Server error encountered. All details have been logged.");
        MessageFault messageFault = faultException.CreateMessageFault();

        fault = Message.CreateMessage(version, messageFault, faultException.Action);
    }
}

ErrorHandlerElement:
public class ErrorHandlerElement : BehaviorExtensionElement
{
    private readonly ILogger _logger;

    public ErrorHandlerElement(ILogger logger)
    {
        _logger = logger;
    }

    protected override object CreateBehavior()
    {
        return new ErrorHandler(_logger);
    }

    public override Type BehaviorType
    {
        get
        {
            return typeof(ErrorHandler);
        }
    }
}

Web.config
Same as in tutorial, but with my own type in the behaviorExtension
Global.asax.cs
Creates the SimpleInjector container and registers the types

A: I don't have the complete answer for you because I don't know Windsor. I have done this using Unity by utilizing the build policy extensions. I think Windsor have something similar.
See http://www.primordialcode.com/blog/post/unity-wcf-service-resolution-container-extension/ details on how to use Build Policies together with WCF.
Below is a snippet that I used to be able to configure the service host before resolving. The code enables configuration and adding of service endpoints and behaviors as interfaces that on host resolution will be resolved through the container.
Be aware that I typically don't use the app.config or equivalents.
public class WcfServiceHostBuildPlanPolicy<TInterface, TImplementation> : IBuildPlanPolicy
    where TInterface : class
    where TImplementation : class, TInterface
{
    private class ServiceEndpoint
    {
        public string Address { get; set; }
        public Binding Binding { get; set; }
        public Type Type { get; set; }
    }

    private readonly List<ServiceEndpoint> endpoints;
    private readonly List<Type> behaviors;

    /// <summary>
    /// Adds a new service behavior.
    /// </summary>
    public void AddBehavior<T>() where T : IServiceBehavior
    {
        behaviors.Add(typeof (T));
    }

    public void AddServiceEndpoint(Type type, string address, Binding binding)
    {
        endpoints.Add(new ServiceEndpoint
        {
            Address = address,
            Binding = binding,
            Type = type
        });

    }

    public WcfServiceHostBuildPlanPolicy()
    {
        m_Behaviors = new List<Type>();
        m_Endpoints = new List<ServiceEndpoint>();
    }

    public void BuildUp(IBuilderContext context)
    {
        if (context.Existing == null)
        {
            // build up dependencies
            var behavior = context.NewBuildUp<DIServiceBehavior<TInterface, TImplementation>>();

            // create new DIServiceHost
            var serviceHost = new DIServiceHost<TInterface, TImplementation>(behavior);

            // add behaviors to ServiceHost
            foreach (var behaviorType in behaviors)
            {
                var newBehavior = context.NewBuildUp(new NamedTypeBuildKey(behaviorType)) as IServiceBehavior;
                serviceHost.Description.Behaviors.Add(newBehavior);
            }

            // add service endpoints to ServiceHost
            endpoints.ForEach(s => serviceHost.AddServiceEndpoint(s.Type, s.Binding, s.Address));

            context.Existing = serviceHost;
        }
    }
}


text:
Q: Using a control in WiX to save an ID to config file I have a Wix installer already set up. I wish to add an input field to accept an ID (eg. ABC123) and then save that ID to the App.config file as a key. How would I go about doing this for my application? (I have several machines that need content pushed out to them based on this ID)
Here is a sample of how I started to go about this. I'm not proficient enough in WiX as of now.
<Component Id="Settings">
  <util:XmlFile
        Id="XmlSettingsUpdate"
        Action="setValue"
        File="[INSTALLDIR]/$(var.ProductName.exe.config)"
        SelectionLanguage="XPath"
        Permanent="yes"
        ElementPath="//appSettings/add"
        Name="StationId" Value="[addStationId]" />
</Component>

And I want to add this key to the app config:
<add key="StationId" value="default" />

EDIT: Okay. So I figured out that I need to use XmlFile to append the attribute to the xml file. So I guess with this edit, how would I crate a text input in the installer that would save to the Value=[addStationId]


text:
Q: mod_wsgi daemons not working I setup mod_wsgi on my ubuntu/apache2 server.
I'm trying to run threads but daemons do not work.
When I try to run them in the background, nothing happens.
My wsgi script:
import sys, logging
sys.path.insert(0, "/var/www/xxx/public_html/blockchain/")

from app import app as application

logging.basicConfig(filename'/var/www/xxx/blockchain/wsgi.log', level=logging.INFO, filemode='w')

My xxx.conf file is:
Listen 8888
<VirtualHost *:8888>
        ServerName xxx.com
        ServerAlias xxx.com
        ErrorLog /var/www/xxx/logs/error.log
        CustomLog /var/www/xxx/logs/acccess.log combined
        WSGIDaemonProcess xxx user=www-data group=www-data processes=5 threads=10
        WSGIProcessGroup xxx
        WSGIApplicationGroup %{GLOBAL}
        WSGIScriptAlias / /var/www/xxx/public_html/blockchain/xxx.wsgi
        Alias /static/ /var/www/xxx/public_html/blockchain/static
        <Directory /var/www/xxx/public_html/blockchain>
                Order allow,deny
                Allow from all
        </Directory>

</VirtualHost>

The relevant part o my python script is:
if __name__ == '__main__':

    t1 = threading.Thread(target=doFirstThing, daemon=True)
    t2 = threading.Thread(target=doSecondThing, daemon=True)
    t3 = threading.Thread(target=doThirdThing, daemon=True)

    t1.start()
    t2.start()
    t3.start()

    app.run(host='0.0.0.0', port='8888', debug=True)

How can I make my threads work int he background when my Flask file is launched using wsgi.
Thanks


text:
Q: Postgres query error I have a query in postgres
insert into c_d (select * from cd where ak = '22019763');

And I get the following error
ERROR:  column "region" is of type integer but expression is of type character varying
HINT:  You will need to rewrite or cast the expression.

A: An INSERT INTO table1 SELECT * FROM table2 depends entirely on order of the columns, which is part of the table definition. It will line each column of table1 up with the column of table2 with the same order value, regardless of names.
The problem you have here is whatever column from cd with the same order value as c_d of the table "region" has an incompatible type, and an implicit typecast is not available to clear the confusion.
INSERT INTO SELECT * statements are stylistically bad form unless the two tables are defined, and will forever be defined, exactly the same way. All it takes is for a single extra column to get added to cd, and you'll start getting errors about extraneous extra columns.
If it is at all possible, what I would suggest is explicitly calling out the columns within the SELECT statement. You can call a function to change type within each of the column references (or you could define a new type cast to do this implicitly -- see CREATE CAST), and you can use AS to set the column label to match that of your target column.
If you can't do this for some reason, indicate that in your question.

A: Check out the PostgreSQL insert documentation. The syntax is:
INSERT INTO table [ ( column [, ...] ) ]
{ DEFAULT VALUES | VALUES ( { expression | DEFAULT } [, ...] ) | query }

which here would look something like:
INSERT INTO c_d (column1, column2...) select * from cd where ak = '22019763'

This is the syntax you want to use when inserting values from one table to another where the column types and order are not exactly the same.


text:
Q: Why do my images not show up when using XHTML2PDF on Google App Engine? I have followed exactly the code here: Convert HTML into PDF using Python, but my images are still not showing up. They have absolute URLs, in any case.
xhtml2pdf and reportlab are both placed in my app folder as modules, so no import errors pop up or anything. The PDF renders fine, except that images are not being displayed. I tried to remove HTML and CSS width/height attributes as well to no avail.
Any pointers?

A: I've seen the same issue when running my App Engine based application locally. The issue centers around my install of PIL.
The PDFs render as expected and with images up in the cloud.

A: For some reasons I had this issue when the @frame was too small compare to image. When I tried to render it outside frames - it worked. So the solution was to use zoom: 20% and adjust frame's width and height. Note, that img { zoom: 20% } doesn't work inside the @frame definition for some reasons so I had to move it to global scope (even outside the @page definition).


text:
Q: How to change the default isolation level of a transaction in a stored procedure in PostgreSQL PL/pgSQL? I am interested in controlling the isolation level of a transaction inside a PostgreSQL procedure but haven't found any information on how to do it. The documentation on Transaction Management within Chapter 42. PL/pgSQL — SQL Procedural Language only states that:

A new transaction starts out with default transaction characteristics such as transaction isolation level.

Can we change the default isolation level? Can you provide example code?

A: That should be simple:
ALTER PROCEDURE myproc
   SET default_transaction_isolation = 'repeatable read';

The downside to that is that because of the limitations of transaction management inside procedures, you can no longer COMMIT or ROLLBACK inside such a procedure.
If you need that, you could start the procedure body like this:
COMMIT;  -- otherwise you get a silly error
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;

Transaction management inside procedures is pretty limited at the moment.


text:
Q: Custom FrontEndToken calls So I've been playing with FrontEndTokens recently and discovered that there are some of them that don't seem to have a standard-usage way of being called. For example, the "Tab" token isn't called when the tab key is pressed, but is captured by the {"MenuCommand","Tab"} event binding, which makes it ripe for abuse as a custom event. That is, if it really doesn't have a common usage, it should be possible to use it as a place holder for a function that will be performed by whatever event handlers. Tkinter in python has this sort of thing via a virtual event caller.
That led me to wondering if it's possible to construct personalized FrontEndTokens that I could use as EventHandler callbacks.
I'm afraid the answer to this is probably no, given that some of the simple test I've run (e.g. trying NotebookEventActions -> {{"MenuCommand", "CustomEvent"} :> Print[1]} haven't worked) but if this were possible it would extend the UI capabilities of Mathematica dramatically.


text:
Q: How can I lock an FTP user to their home directory? I have found some help regarding locking an FTP user to their home directory, but after following steps, I find I'm still able to run cd .. and exit that directory and browse the file system. I'm using CentOS 7. Here are my steps:
yum install vsftpd ftp -y
systemctl enable vsftp && suystemctl start vsftpd
I modify /etc/vsftpd/vsftpd.conf and set chroot_local_user=YES.
useradd lockeduser
passwd lockeduser
Following prompts, I set the password.
usermod --home /mnt/library/locked-folder lockeduser
Once that has been configured, I ftp in and open a connection to the local IP.
I now land in the locked-folder directory, however I can navigate anywhere I want from there.
I feel I am missing something obvious.


text:
Q: Understanding a textbook example of linear mappings as matrices. I have a linear mapping $f:Q_{\leq1}[t] \to Q_{\leq1}[t]$ matrix A given by
$f(a_{1}t + a_{0}) = 2a_{1} + a_{0}$
And two bases given by
$B_{1} = \{1, t\}$ and $B_{2} = \{t+1, t-1\}$
so that
$[f]_{B1,B1} = \begin{bmatrix}
1 & 0\\
0 & 2
\end{bmatrix}$
$[f]_{B1,B2} = \begin{bmatrix}
1/2 & 1\\
-1/2 & 1
\end{bmatrix}$
$[f]_{B2,B2} = \begin{bmatrix}
3/2 & 1/2\\
1/2 & 3/2
\end{bmatrix}$
$[f]_{B2,B1} = \begin{bmatrix}
1 & -1\\
2 & 2
\end{bmatrix}$
I know this is really basic, but I am having trouble understanding how these mappings are constructed from B1 and B2. For the first one, I've figured out that it is clearly in relation to the identity matrix as a representation of B1, but beyond that I am a bit lost.
This topic is very important for me so please reply comprehensively.

A: So, (I take it it's) $f(a_0+a_1t)=a_0+2a_1t$, or $f(\begin{pmatrix}a_0\\a_1\end{pmatrix})=\begin{pmatrix}a_0\\2a_1\end{pmatrix}$..
Once you have the first one, which you get by just applying $f$ to the elements of $B_1=\{\begin {pmatrix}1\\0\end {pmatrix},\begin {pmatrix}0\\1\end {pmatrix}\}$ and writing the results in terms of $B_1$, you get the others by applying the transition matrix (or its inverse).
The transition matrix between $B_1$ and $B_2$ is
$$P=[I]_{B_2,B_1}=\begin {pmatrix}1\quad -1\\1\quad 1\end {pmatrix}$$.  Notice that the columns are the elements of $B_2$.
Then $P^{-1}=\begin {pmatrix}1/2\quad 1/2\\-1/2\quad 1/2\end {pmatrix}$.
Thus $[f]_{B_1,B_2}=P^{-1}[f]_{B_1,B_1}$.
And $[f]_{B_2,B_1}=[f]_{B_1,B_1}P$.
Finally $[f]_{B_2,B_2}=P^{-1}[f]_{B_1,B_1}P$.

A: $f(a_1t+a_0)=2a_1t+a_0.$
To compute the first column of $[f]_{B_i,B_j}$, take the first vector of $B_i$, then its image by $f$, and finally the (two) coordinates of this image in $B_j.$ Same for the second column, starting from the second vector of $B_i.$
The coordinates of $a+bt$ in $B_1$ are $\begin{pmatrix}a\\b\end{pmatrix}.$
Since $1=\frac{(t+1)-(t-1)}2$ and $t=\frac{(t+1)+(t-1)}2,$ the coordinates in $B_2$ of $a+bt=a\frac{(t+1)-(t-1)}2+b\frac{(t+1)+(t-1)}2=\frac{a+b}2(t+1)+\frac{-a+b}2(t-1)$ are $\begin{pmatrix}\frac{a+b}2\\\frac{-a+b}2\end{pmatrix}.$
I think now you will be able to obtain your four matrices.


text:
Q: How to execute grep -v -e 'expr1' and grep -e 'expr2' at the same command? I have the following command to extract string that do not start with www. and do not contain /:
grep -v -e '^www\.' -e '/' test2.txt

But I want the above in addition to matching somestring.somestring pattern, which can be achieved with this command:
grep -e '^[^\.]*\.[^\.]*$'

How to put all theses into one line?

A: Pipe the first grep's result into the second grep.

A: You can't combine reverse and forward matches in one grep invocation
You can do it with sed:
sed -e '/^www\./d' -e '/\//d' -e '/^[^.]*\.[^.]*$/!d' ./*.txt

Or awk (which contrary to sed would be able to print the name of the matching file like grep):
awk -F. 'NF == 2 && !/^www\./ && !/\// {print FILENAME": "$0}' ./*.txt

You could do it with two grep invocations provided you don't want the file names to be printed:
cat ./*.txt | grep '^[^.]*\.[^.]*$' | grep -v -e / -e '^www\.'

Here using cat to feed the content of all the files on stdin so the first grep doesn't print the file names. Some grep implementations have grep -h to skip printing the file names if there's more than one file. In the case of only one file name, grep doesn't print the file name anyway, and you can feed it on its stdin with redirections:
<onefile.txt grep '^[^.]*\.[^.]*$' | grep -v -e / -e '^www\.'

You could implement negation with PCRE's (?!...) negative look-ahead operators if your grep supports -P:
grep '^(?!www\.)(?!.*/)[^.]*\.[^.]*$' ./*.txt

But here, you could do it all with -v with:
grep -v -e / -e '^www\.' -e '^[^.]*$' -e '\..*\.'

That is also exclude lines that contain no dot and lines that contain more than one dot.


text:
Q: jQuery slideDown not fluid I am working on a jQuery menu for my friend. The menu is done, the only problem is that the slide down is not fluid and I can't find the problem here.
jQuery code:
$.fn.vmenu=function(settings)
{
    vMenu={
        init: function(elem) {
            $(elem).find('li').each(function(){
                var u=$(this).children('ul');
                if (u.length>0) {
                    $(this).addClass('has_child');
                }
                var a=$(this).children('a');
                if (a.hasClass('active')) {
                    $(this).addClass('active').parents('li').addClass('open');
                }
            });

            $(elem).find('ul').each(function(){
                var o=$(this).find('li.open');
                var a=$(this).find('a.active');
                if (o.length == 0 && a.length==0) {
                    $(this).css('display','none');
                }
            });

            $(elem).find('a').click(function(){
                return vMenu.click($(this));
            });
        },
        click: function(elem) {
            var l=$(elem).parent('li');
            var u=$(l).children('ul');

            if (u.length == 0) {
                return this.forward(elem);
            }

            if ($(l).hasClass('open')) {
                $(l).removeClass('open');
                $(l).find('ul').stop(true,true).slideUp(300);
                $(l).find('li').removeClass('open');
                if($(l).children('a').hasClass('open')) {
                    $(l).children('a').css({color:'#939393'});
                    $(l).children('a').removeClass('open');
                }
            } else {
                $(l).addClass('open');
                $(u).stop(true,true).slideDown(300);
                $(l).children('a').css({color:'#F37121'});
                $(l).children('a').addClass('open');
            }

            return false;
        },
        forward: function(elem) {
            return true;
        }
    }
    vMenu.init($(this));
}

$(document).ready(function(){
 $('#vmenu').vmenu();
});

CSS code:
/* ### partner box ### */
.partnerBox { padding-top: 52px; width: 253px; float: left; background: url('http://www.realbingo.nl/images/partner-top.png') left top no-repeat; }
.partnerBox .bottom { padding-bottom: 12px; float: left; background: url('http://www.realbingo.nl/images/paasbonus-bottom.png') left bottom no-repeat; }
.partnerBox .mid { padding: 0 20px 0 15px; width: 218px; float: left; background: url('http://www.realbingo.nl/images/paasbonus-mid.png') left top repeat-y; }
.partnerBox h3 { padding-left: 5px; margin-top: -36px; color: #fff; font-size: 20px; }
.partnerBox ul { padding: 0px 0 0 0; margin-bottom: -5px; overflow: hidden; width: 100%; }
.partnerBox li { padding-left: 5px; font-size: 13px; float: left; list-style: none; width: 208px; line-height: 39px; border-bottom: 0px; }
.partnerBox li a { padding-left: 9px; color: #939393; text-decoration: none; display: block; background: url('http://www.realbingo.nl/images/arrow1.png') left center no-repeat; }
.partnerBox li a:hover { color: #F37121 !important; }
#vmenu li { border-bottom: #ece3e3 solid 1px; }
#vmenu li > ul > li { border-bottom: 0px; height: 30px; line-height: 30px; margin-top: -8px;}
.text ul{ line-height: 18px; margin-bottom: 2px; }

HTML code:

Linkpartners

Bingo

Link 1

Link 2

Roulette

Link 1

Link 2

Poker

Link 1

Link 2

Tekst

                        Dit is een lap tekst die door en door gaat tot het einde.. en verder... :D:D:D:D:D:D:D:D

Any tips and/or ideas to make the code more efficient are very appreciated too.

A: If you're talking about the slideDown jumping when it gets to the bottom of the reveal it is likely to be caused by the bottom margin on the ".text ul" CSS. jQuery can't calculate the height including margins.
If you're talking about the slideDown content moving around during the animation, this is often related to the top padding of either the element you're sliding or the first child element.


text:
Q: pass string to controller using ajax I want to build search field look for users in my system...i will write the name of user in the field and ajax function will pass the name from search field to method in controller this method will return ienumerable of all users those have same name....when i pass id of user it works successfully and i gets the specific user because i pass int value...but The problem occurs when i pass string ...so how to pass the name of user to controller using ajax.
here is view tags

        <input id="user"  asp-for="ResearchAuthor.ApplicationUserId" class="form-control" asp-items="ViewBag.ApplicationUserId" />
        بحث

    <select id="add" asp-for="ResearchAuthor.ApplicationUserId" class="form-control" asp-items="ViewBag.ApplicationUserId">
        <option>@Localizer["إختر المستخدم"]</option>
    </select>

and ajax code

and the function in controller:
   [AllowAnonymous]
    public JsonResult GetUsers(string SearchString)
    {
        var users = new SelectList(_context.ApplicationUsers.Where(u=>u.ArName==SearchString), "Id", "ArName");
        return Json(users);
    }

A: You must check it in backend. if it is int then ok but then it is string try to convert into int if is possible.


text:
Q: how to add a drop down list Report needs option to select multiple super product types
Selection of multiple super product types?
IF @superProductType = 'ALL'
    INSERT INTO #ProductDetails
    SELECT pt_sp_type_c, pt_sb_type_c
    FROM product..p_type_p_type
    WHERE pt_sp_type_c NOT IN ('EQUITY','OPTEQTY')
    AND p_type_use_sp_c= 'RPCDB'
    AND p_type_use_sb_c = 'TRD'
    AND pt_rel_stat_c = 'ACTIVE'
ELSE
    INSERT INTO #ProductDetails
    SELECT pt_sp_type_c, pt_sb_type_c
    FROM product..p_type_p_type
    WHERE pt_sp_type_c NOT IN ('EQUITY','OPTEQTY')
    AND pt_sp_type_c IN (@superProductType)
    AND p_type_use_sp_c= 'RPCDB'
    AND p_type_use_sb_c = 'TRD'
    AND pt_rel_stat_c = 'ACTIVE'

I have a parameter here @super product type,can anyone help me how to change this code
Here in this code i need to make some changes: ---parameter is @superProductType
The above code was for the option to select multiple super product types
when i select All and one value from the drop down list like 'ALL','ASKF'
both the above conditions in the code if else will fail
It should not get selected ALL and other ASKF at the same time
either should has to select
How can we differentiate that ALL not selecting ALL from together
if we select ALL remaining values in the drop down list must be deleted
It should not have two values selected together IF ALL only ALL has to select remaining should discard
I am not sure how to eliminate the rest of values in the drop down list
looking for suitable solution,can anybody see the code abnove and tell me what is the change i have to do in the code.

A: If you have set the SSRS parameter to Multivalue then you should change the query to use IN (@ParamName) syntax. so your query would become:
IF @superProductType = 'ALL'
    INSERT INTO #ProductDetails
    SELECT pt_sp_type_c, pt_sb_type_c
    FROM product..p_type_p_type
    WHERE pt_sp_type_c NOT IN ('EQUITY','OPTEQTY')
    AND p_type_use_sp_c= 'RPCDB'
    AND p_type_use_sb_c = 'TRD'
    AND pt_rel_stat_c = 'ACTIVE'
ELSE
    INSERT INTO #ProductDetails
    SELECT pt_sp_type_c, pt_sb_type_c
    FROM product..p_type_p_type
    WHERE pt_sp_type_c NOT IN ('EQUITY','OPTEQTY')
    AND pt_sp_type_c IN ( @superProductType )
    AND p_type_use_sp_c= 'RPCDB'
    AND p_type_use_sb_c = 'TRD'
    AND pt_rel_stat_c = 'ACTIVE'


text:
Q: H2O PCA number of components I wonder why number of components in H2o PCA algorithm is limited to 9. It is not sure sometimes to be enough.

k: Specify the rank of matrix approximation. This can be a value from 1 to 9 and defaults to 1.

A: The H2O prcomp algorithm (i.e. PCA) is not limited to 10 components. The limit is the number of columns in your data (or the number of rows if that is smaller).
The online documentation (http://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-science/pca.html and http://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-science/algo-params/k.html) is wrong.  (I'll ping someone at H2O.)
Here is quick R script to show this:
library(h2o)
h2o.init()
d <- as.h2o(matrix(runif(2000),nrow = 40, ncol = 50))
m = h2o.prcomp(d, k = 20)
m

I.e. make a matrix of random data, and request the first 20 components.
The output looks like:
Importance of components:
                            pc1      pc2      pc3      pc4      pc5      pc6      pc7      pc8      pc9     pc10     pc11
Standard deviation     3.569561 0.599236 0.560946 0.529781 0.518060 0.495266 0.477426 0.438890 0.429845 0.417752 0.407795
Proportion of Variance 0.754456 0.021262 0.018631 0.016619 0.015892 0.014524 0.013496 0.011406 0.010940 0.010333 0.009847
Cumulative Proportion  0.754456 0.775718 0.794349 0.810968 0.826859 0.841383 0.854880 0.866285 0.877225 0.887559 0.897405
                           pc12     pc13     pc14     pc15     pc16     pc17     pc18     pc19     pc20
Standard deviation     0.394316 0.386367 0.370733 0.362824 0.354425 0.343219 0.321725 0.304999 0.295844
Proportion of Variance 0.009206 0.008839 0.008138 0.007795 0.007438 0.006975 0.006129 0.005508 0.005182
Cumulative Proportion  0.906612 0.915451 0.923589 0.931384 0.938822 0.945797 0.951926 0.957434 0.962616

Note that only 96.2% of the variance is explained by the first 20 components. If you set k to 40 you will see 100% of the variance explained. If you set k higher than 40 you will get an error message.
Note: the python API will behave identically.
Aside: I needed so many components because this was random data. With data that has more signal it should not need so many to capture most of the variance. But for high-dimensional data, using more than 10 components is a very reasonable thing to do.


text:
Q: UITextView - How to remain cursor after hide keyboard I'm trying to make a UITextView that user could input text and emoticons.
And I got a problem with the cursor displaying.
My goal is to make the cursor appears as normal while selecting emoticon(Keyboard is hidden).
I know it could be done because a app called "Kakao Story" have the feature.
Does anybody have a solution about it?? Thanks.

A: I found a way to make keyboardView hidden to access my purpose.
Here is the code
+ (void)hideKeyboard
{
    for (UIWindow *aWindow in [[UIApplication sharedApplication] windows]) {

        for (UIView *possibleKeyboard in [aWindow subviews]) {
            UIView *keyboardView = [self getPeripheralHostViewFromView:possibleKeyboard];
            if (keyboardView) {
                [keyboardView setHidden:YES];
            }
        }
    }
}

+ (void)unhideKeyboard
{
    for (UIWindow *aWindow in [[UIApplication sharedApplication] windows]) {

        for (UIView *possibleKeyboard in [aWindow subviews]) {
            UIView *keyboardView = [self getPeripheralHostViewFromView:possibleKeyboard];
            if (keyboardView) {
                [keyboardView setHidden:NO];
            }
        }
    }
}

+ (UIView *)getPeripheralHostViewFromView:(UIView *)superView
{
    if ([superView.description hasPrefix:@"<UIPeripheralHostView"]) {
        return superView;
    }else if([superView.description hasPrefix:@"<UIKBInputBackdropView"]) {
        return superView.superview;
    }else {
        for (UIView *subView in superView.subviews) {
            UIView *keyboardHostView = [self getPeripheralHostViewFromView:subView];
            if (keyboardHostView) {
                return keyboardHostView;
            }
        }
    }
    return nil;
}


text:
Q: How long will it take the average person to finish a test with $X$ questions. I'm trying to create an algorithm that calculates the time spent on a test with the following data. The difficulty I'm having is that there are some outliers which skew the data. For instance a test with 4 question takes 6740 seconds while a test with 5 questions only takes 380. Also, it only goes up to 99 and I'd like it to go much higher even though my samples doesn't.
Average time on 4 tests with 99 questions: 1776 seconds (30 minutes)
Average time on 2 tests with 98 questions: 1418 seconds (24 minutes)
Average time on 7 tests with 97 questions: 1726 seconds (29 minutes)
Average time on 1 tests with 96 questions: 1233 seconds (21 minutes)
Average time on 3 tests with 95 questions: 4613 seconds (77 minutes)
Average time on 4 tests with 94 questions: 653 seconds (11 minutes)
Average time on 1 tests with 93 questions: 1415 seconds (24 minutes)
Average time on 3 tests with 92 questions: 4899 seconds (82 minutes)
Average time on 5 tests with 91 questions: 906 seconds (15 minutes)
Average time on 7 tests with 90 questions: 2218 seconds (37 minutes)

Average time on 12 tests with 89 questions: 2082 seconds (35 minutes)
Average time on 7 tests with 88 questions: 1042 seconds (17 minutes)
Average time on 3 tests with 87 questions: 1939 seconds (32 minutes)
Average time on 5 tests with 86 questions: 1098 seconds (18 minutes)
Average time on 4 tests with 85 questions: 4689 seconds (78 minutes)
Average time on 6 tests with 84 questions: 1498 seconds (25 minutes)
Average time on 7 tests with 83 questions: 912 seconds (15 minutes)
Average time on 7 tests with 82 questions: 4051 seconds (68 minutes)
Average time on 3 tests with 81 questions: 5219 seconds (87 minutes)
Average time on 12 tests with 80 questions: 1699 seconds (28 minutes)

Average time on 7 tests with 79 questions: 1869 seconds (31 minutes)
Average time on 7 tests with 78 questions: 2301 seconds (38 minutes)
Average time on 7 tests with 77 questions: 3950 seconds (66 minutes)
Average time on 8 tests with 76 questions: 38215 seconds (637 minutes)
Average time on 44 tests with 75 questions: 1748 seconds (29 minutes)
Average time on 8 tests with 74 questions: 1210 seconds (20 minutes)
Average time on 8 tests with 73 questions: 878 seconds (15 minutes)
Average time on 66 tests with 72 questions: 2903 seconds (48 minutes)
Average time on 18 tests with 71 questions: 1948 seconds (32 minutes)
Average time on 12 tests with 70 questions: 2179 seconds (36 minutes)

Average time on 12 tests with 69 questions: 655 seconds (11 minutes)
Average time on 12 tests with 68 questions: 1879 seconds (31 minutes)
Average time on 13 tests with 67 questions: 1747 seconds (29 minutes)
Average time on 15 tests with 66 questions: 2567 seconds (43 minutes)
Average time on 25 tests with 65 questions: 3719 seconds (62 minutes)
Average time on 19 tests with 64 questions: 2457 seconds (41 minutes)
Average time on 18 tests with 63 questions: 1090 seconds (18 minutes)
Average time on 23 tests with 62 questions: 1157 seconds (19 minutes)
Average time on 34 tests with 61 questions: 1227 seconds (20 minutes)
Average time on 29 tests with 60 questions: 3446 seconds (57 minutes)

Average time on 13 tests with 59 questions: 2113 seconds (35 minutes)
Average time on 22 tests with 58 questions: 4645 seconds (77 minutes)
Average time on 36 tests with 57 questions: 1177 seconds (20 minutes)
Average time on 79 tests with 56 questions: 2362 seconds (39 minutes)
Average time on 23 tests with 55 questions: 1142 seconds (19 minutes)
Average time on 47 tests with 54 questions: 3707 seconds (62 minutes)
Average time on 35 tests with 53 questions: 1138 seconds (19 minutes)
Average time on 67 tests with 52 questions: 1685 seconds (28 minutes)
Average time on 43 tests with 51 questions: 1049 seconds (17 minutes)
Average time on 78 tests with 50 questions: 1427 seconds (24 minutes)

Average time on 59 tests with 49 questions: 1042 seconds (17 minutes)
Average time on 52 tests with 48 questions: 1401 seconds (23 minutes)
Average time on 50 tests with 47 questions: 2648 seconds (44 minutes)
Average time on 79 tests with 46 questions: 1675 seconds (28 minutes)
Average time on 92 tests with 45 questions: 1645 seconds (27 minutes)
Average time on 75 tests with 44 questions: 1963 seconds (33 minutes)
Average time on 102 tests with 43 questions: 1953 seconds (33 minutes)
Average time on 100 tests with 42 questions: 1591 seconds (27 minutes)
Average time on 119 tests with 41 questions: 2934 seconds (49 minutes)
Average time on 124 tests with 40 questions: 2832 seconds (47 minutes)

Average time on 125 tests with 39 questions: 1796 seconds (30 minutes)
Average time on 147 tests with 38 questions: 1559 seconds (26 minutes)
Average time on 173 tests with 37 questions: 1120 seconds (19 minutes)
Average time on 189 tests with 36 questions: 1944 seconds (32 minutes)
Average time on 238 tests with 35 questions: 1558 seconds (26 minutes)
Average time on 185 tests with 34 questions: 1434 seconds (24 minutes)
Average time on 247 tests with 33 questions: 1337 seconds (22 minutes)
Average time on 262 tests with 32 questions: 1511 seconds (25 minutes)
Average time on 285 tests with 31 questions: 1403 seconds (23 minutes)
Average time on 496 tests with 30 questions: 1245 seconds (21 minutes)

Average time on 369 tests with 29 questions: 1370 seconds (23 minutes)
Average time on 445 tests with 28 questions: 1254 seconds (21 minutes)
Average time on 512 tests with 27 questions: 1289 seconds (21 minutes)
Average time on 574 tests with 26 questions: 1457 seconds (24 minutes)
Average time on 873 tests with 25 questions: 1271 seconds (21 minutes)
Average time on 806 tests with 24 questions: 1096 seconds (18 minutes)
Average time on 841 tests with 23 questions: 1146 seconds (19 minutes)
Average time on 922 tests with 22 questions: 1110 seconds (19 minutes)
Average time on 1211 tests with 21 questions: 1890 seconds (32 minutes)
Average time on 2034 tests with 20 questions: 889 seconds (15 minutes)

Average time on 1290 tests with 19 questions: 1074 seconds (18 minutes)
Average time on 1594 tests with 18 questions: 829 seconds (14 minutes)
Average time on 1754 tests with 17 questions: 895 seconds (15 minutes)
Average time on 2153 tests with 16 questions: 2446 seconds (41 minutes)
Average time on 3107 tests with 15 questions: 821 seconds (14 minutes)
Average time on 2483 tests with 14 questions: 722 seconds (12 minutes)
Average time on 2741 tests with 13 questions: 964 seconds (16 minutes)
Average time on 3074 tests with 12 questions: 713 seconds (12 minutes)
Average time on 3229 tests with 11 questions: 837 seconds (14 minutes)
Average time on 5299 tests with 10 questions: 939 seconds (16 minutes)

Average time on 3165 tests with 9 questions: 704 seconds (12 minutes)
Average time on 3749 tests with 8 questions: 650 seconds (11 minutes)
Average time on 3857 tests with 7 questions: 484 seconds (8 minutes)
Average time on 4605 tests with 6 questions: 574 seconds (10 minutes)
Average time on 5273 tests with 5 questions: 380 seconds (6 minutes)
Average time on 3833 tests with 4 questions: 6740 seconds (112 minutes)
Average time on 4046 tests with 3 questions: 261 seconds (4 minutes)
Average time on 4536 tests with 2 questions: 176 seconds (3 minutes)
Average time on 7740 tests with 1 questions: 210 seconds (4 minutes)

I thought about grouping them into sets of 10 the taking the median but I lose some details and it's still not as accurate.
99-90 median: 1418 seconds
89-80 median: 1939 seconds
79-70 median: 1948 seconds
69-60 median: 1747 seconds
59-50 median: 1685 seconds
49-40 median: 1675 seconds
39-30 median: 1511 seconds
29-20 median: 1271 seconds
19-10 median: 837 seconds
9-1 median: 529 seconds

Is there some kind of formula I can use where I can plug in the number of questions ($X$) and get the time the test should take to complete based on this data?


text:
Q: Select subset of dataframe based collected in the last N unique dates I am looking for a way to filter a dataframe such that I retain all data from the last N unique days in the dataset, not including NA's. My data is not collected on any known frequency - some days might contain 100 datapoints and then no data for weeks. The end goal is to do a regression analysis with respect to time, based on most recent data available. If I just do a tail function and pick last N rows (arranged by date), I sometimes get all data from 1-2 days, which doesn't lend itself to a good regression wrt time.
Any suggestions on how to accomplish this?
The data looks like attached. The only thing I attempted is tail(df, 30) function as below and then did the linear regression, which is when I realized the results looked odd because I apparently had more than 30 data points on 12/11.
all_data2 <- all_data2 %>%
        filter(!!sym(test_par[j]) < upper_q, !!sym(test_par[j]) > lower_q ) %>%
        mutate(week=difftime(code_date, as.Date(x_start), units = c("weeks")))

      all_data2 <- all_data2 %>%
        mutate(test_par_avg=SMA(all_data2[test_par[j]], n=nsmooth)) %>%
        filter(!is.na(test_par_avg)) %>%
        arrange(code_date) %>%
        tail(no_tail)

       model <- lm(test_par_avg ~ week, data=all_data2)

A: Is this what you're looking for ?
my_df <- data.frame("Date" = c("01/01/2021", "01/01/2021", "02/02/2021", "03/03/2021", "03/05/2021", NA, "03/03/2021"),
                "Value" = c(2, NA, NA, 2, 4, 4, 1),
                stringsAsFactors = FALSE)

my_df <- my_df[complete.cases(my_df),]
my_df <- my_df %>% group_by(dmy(Date)) %>% mutate(ID = cur_group_id())

my_number <- 2
my_value <- sort(unique(my_df$ID))
my_value <- tail(my_value, my_number)
my_var <- which(my_df$ID %in% my_value)
if (length(my_var)) {
  my_df <- my_df[my_var,]
}

So first complete.cases allow us to keep all rows that don't have any NA value.
Then we assign an unique ID for all unique Date value.
After the last part is for selecting the N unique days so here N = 2.


text:
Q: unable to use RODM to connect to Oracle database from R I am trying to connect to an Oracle database from R.
I used RODM_open_dbms_connection(dsn, uid = "", pwd = ""), but it doesn't work. I am not sure what kind of the error it is.
Here is the error screen from R.
> library(RODM) Loading required package: RODBC DB<-
> RODM_open_dbms_connection(dsn="****",uid="****", pwd="****") Error in
> typesR2DBMS[[driver]] <<- value[c("double", "integer", "character",  :
> cannot change value of locked binding for 'typesR2DBMS'

A: Have you tried ROracle?  After you get the instant client installed on your machine, connecting and fetching records from R looks like this:
library(ROracle)
con <- dbConnect(dbDriver("Oracle"), username="username", password="password", dbname = "dbname")
res <- dbSendQuery(con, "select * from schema.table")
dt <- data.table(fetch(res, n=-1))

A: I explored the RODM_open_dbms_connection. I commented out the part setSqlTYpeInfo(). After that I didn't receive that error.
Install RODM package from source then only you can edit the package.


text:
Q: git push heroku master in django working fine yet app crashed Code in Django The whole project is available in this drive link
This projects works perfectly fine when I executed it on my local host
When trying to deploy on heroku I get app crashed and when I run (heroku logs -- tail) the following error message was displayed as shown below .
(Note I didnt change the secret key because I felt it wasn't Important in the current state of the project as this is only for the educational/development purpose so please kindly take that into consideration ) . Kindly help !
I have been receiving that this is a similar question from the questions already asked . But the PIL is present in the requirements.txt file as Pillow==7.2.0
there were a few more answers on the same issues and I tried quite a few of them but non worked for me kindly help
2020-08-10T17:58:57.717239+00:00 app[web.1]: [2020-08-10 17:58:57 +0000] [10]
 [ERROR] Exception in worker process
    2020-08-10T17:58:57.717284+00:00 app[web.1]: Traceback (most recent call last):
    2020-08-10T17:58:57.717286+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
    2020-08-10T17:58:57.717288+00:00 app[web.1]: worker.init_process()
    2020-08-10T17:58:57.717288+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 119, in init_process
    2020-08-10T17:58:57.717288+00:00 app[web.1]: self.load_wsgi()
    2020-08-10T17:58:57.717289+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
    2020-08-10T17:58:57.717289+00:00 app[web.1]: self.wsgi = self.app.wsgi()
    2020-08-10T17:58:57.717291+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
    2020-08-10T17:58:57.717291+00:00 app[web.1]: self.callable = self.load()
    2020-08-10T17:58:57.717291+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
    2020-08-10T17:58:57.717291+00:00 app[web.1]: return self.load_wsgiapp()
    2020-08-10T17:58:57.717292+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
    2020-08-10T17:58:57.717292+00:00 app[web.1]: return util.import_app(self.app_uri)
    2020-08-10T17:58:57.717292+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/util.py", line 358, in import_app
    2020-08-10T17:58:57.717292+00:00 app[web.1]: mod = importlib.import_module(module)
    2020-08-10T17:58:57.717292+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/importlib/__init__.py", line 127, in import_module
    2020-08-10T17:58:57.717294+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
    2020-08-10T17:58:57.717294+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
    2020-08-10T17:58:57.717294+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 983, in _find_and_load
    2020-08-10T17:58:57.717295+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
    2020-08-10T17:58:57.717295+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
    2020-08-10T17:58:57.717295+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 728, in exec_module
    2020-08-10T17:58:57.717295+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
    2020-08-10T17:58:57.717295+00:00 app[web.1]: File "/app/Insta/wsgi.py", line 16, in <module>
    2020-08-10T17:58:57.717295+00:00 app[web.1]: application = get_wsgi_application()
    2020-08-10T17:58:57.717296+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
    2020-08-10T17:58:57.717296+00:00 app[web.1]: django.setup(set_prefix=False)
    2020-08-10T17:58:57.717296+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
    2020-08-10T17:58:57.717296+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS)
    2020-08-10T17:58:57.717296+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/registry.py", line 114, in populate
    2020-08-10T17:58:57.717297+00:00 app[web.1]: app_config.import_models()
    2020-08-10T17:58:57.717297+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/config.py", line 211, in import_models
    2020-08-10T17:58:57.717297+00:00 app[web.1]: self.models_module = import_module(models_module_name)
    2020-08-10T17:58:57.717297+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/importlib/__init__.py", line 127, in import_module
    2020-08-10T17:58:57.717297+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
    2020-08-10T17:58:57.717297+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
    2020-08-10T17:58:57.717298+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 983, in _find_and_load
    2020-08-10T17:58:57.717298+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
    2020-08-10T17:58:57.717298+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
    2020-08-10T17:58:57.717298+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 728, in exec_module
    2020-08-10T17:58:57.717298+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
    2020-08-10T17:58:57.717298+00:00 app[web.1]: File "/app/Angram/models.py", line 3, in <module>
    2020-08-10T17:58:57.717299+00:00 app[web.1]: from PIL import Image
    2020-08-10T17:58:57.717299+00:00 app[web.1]: ModuleNotFoundError: No module named 'PIL'
    2020-08-10T17:58:57.717545+00:00 app[web.1]: [2020-08-10 17:58:57 +0000] [10] [INFO] Worker exiting (pid: 10)
    2020-08-10T17:58:57.731434+00:00 app[web.1]: [2020-08-10 17:58:57 +0000] [11] [ERROR] Exception in worker process
    2020-08-10T17:58:57.731436+00:00 app[web.1]: Traceback (most recent call last):
    2020-08-10T17:58:57.731437+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
    2020-08-10T17:58:57.731438+00:00 app[web.1]: worker.init_process()
    2020-08-10T17:58:57.731438+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 119, in init_process
    2020-08-10T17:58:57.731439+00:00 app[web.1]: self.load_wsgi()
    2020-08-10T17:58:57.731439+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
    2020-08-10T17:58:57.731439+00:00 app[web.1]: self.wsgi = self.app.wsgi()
    2020-08-10T17:58:57.731440+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
    2020-08-10T17:58:57.731440+00:00 app[web.1]: self.callable = self.load()
    2020-08-10T17:58:57.731441+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
    2020-08-10T17:58:57.731441+00:00 app[web.1]: return self.load_wsgiapp()
    2020-08-10T17:58:57.731441+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
    2020-08-10T17:58:57.731442+00:00 app[web.1]: return util.import_app(self.app_uri)
    2020-08-10T17:58:57.731448+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/util.py", line 358, in import_app
    2020-08-10T17:58:57.731449+00:00 app[web.1]: mod = importlib.import_module(module)
    2020-08-10T17:58:57.731449+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/importlib/__init__.py", line 127, in import_module
    2020-08-10T17:58:57.731450+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
    2020-08-10T17:58:57.731450+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
    2020-08-10T17:58:57.731451+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 983, in _find_and_load
    2020-08-10T17:58:57.731451+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
    2020-08-10T17:58:57.731452+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
    2020-08-10T17:58:57.731452+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 728, in exec_module
    2020-08-10T17:58:57.731452+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
    2020-08-10T17:58:57.731453+00:00 app[web.1]: File "/app/Insta/wsgi.py", line 16, in <module>
    2020-08-10T17:58:57.731453+00:00 app[web.1]: application = get_wsgi_application()
    2020-08-10T17:58:57.731454+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
    2020-08-10T17:58:57.731454+00:00 app[web.1]: django.setup(set_prefix=False)
    2020-08-10T17:58:57.731454+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
    2020-08-10T17:58:57.731454+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS)
    2020-08-10T17:58:57.731455+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/registry.py", line 114, in populate
    2020-08-10T17:58:57.731455+00:00 app[web.1]: app_config.import_models()
    2020-08-10T17:58:57.731455+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/config.py", line 211, in import_models
    2020-08-10T17:58:57.731456+00:00 app[web.1]: self.models_module = import_module(models_module_name)
    2020-08-10T17:58:57.731456+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/importlib/__init__.py", line 127, in import_module
    2020-08-10T17:58:57.731456+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
    2020-08-10T17:58:57.731457+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
    2020-08-10T17:58:57.731457+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 983, in _find_and_load
    2020-08-10T17:58:57.731457+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
    2020-08-10T17:58:57.731457+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
    2020-08-10T17:58:57.731462+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 728, in exec_module
    2020-08-10T17:58:57.731462+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
    2020-08-10T17:58:57.731463+00:00 app[web.1]: File "/app/Angram/models.py", line 3, in <module>
    2020-08-10T17:58:57.731463+00:00 app[web.1]: from PIL import Image
    2020-08-10T17:58:57.731463+00:00 app[web.1]: ModuleNotFoundError: No module named 'PIL'
    2020-08-10T17:58:57.731730+00:00 app[web.1]: [2020-08-10 17:58:57 +0000] [11] [INFO] Worker exiting (pid: 11)
    2020-08-10T17:58:57.951050+00:00 app[web.1]: [2020-08-10 17:58:57 +0000] [4] [INFO] Shutting down: Master
    2020-08-10T17:58:57.951171+00:00 app[web.1]: [2020-08-10 17:58:57 +0000] [4] [INFO] Reason: Worker failed to boot.
    2020-08-10T17:58:58.069837+00:00 heroku[web.1]: Process exited with status 3
    2020-08-10T17:58:58.110789+00:00 heroku[web.1]: State changed from up to crashed
    2020-08-10T17:59:03.486724+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/login" host=anuraginstaclone.herokuapp.com request_id=faa21159-9450-4bc9-82e4-68930207196a fwd="60.243.148.124" dyno=web.1 connect=5000ms service= status=503 bytes= protocol=https
    2020-08-10T17:59:03.816920+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=anuraginstaclone.herokuapp.com request_id=9ae26860-abd6-4944-82a3-397069c8b532 fwd="60.243.148.124" dyno= connect= service= status=503 bytes= protocol=https
    2020-08-10T17:59:21.706244+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=anuraginstaclone.herokuapp.com request_id=a5412cbc-48e5-4ec9-b755-f70286ac3e48 fwd="60.243.148.124" dyno= connect= service= status=503 bytes= protocol=https
    2020-08-10T17:59:22.043910+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=anuraginstaclone.herokuapp.com request_id=37a20a82-b237-4f75-9b9d-4eda8b4b338f fwd="60.243.148.124" dyno= connect= service= status=503 bytes= protocol=https**


text:
Q: "Row not found or changed" when updating value of single attribute, but only for SOME rows Okay I will try to make this pretty brief. I have done a lot of searching the last 1-2 days and I can't find an answer to my problem so I will try to narrow it down. The most common cause of "row not found or changed" in LINQ/SQL appears to be a schema discrepancy between the database and the .dbml file (based on both my research and my personal experience). The database I'm working with is too complex for it to be worth sharing the full schema, so I just want to ask one main "hypothetical" question:
If the "Row not found or changed" error only occurs for SOME rows, despite them all having the exact same operation done on them, is it still possible that it could be an issue with .dbml discrepancies (nullable/non-nullable, data types being wrong, etc)?
I feel like if there was a normal schema issue in the .dbml file, it wouldn't let me update ANY rows in the table, but in this case it lets me update most of them without an error.
My guess right now, which I am about to investigate, is that it may be failing when the row is connected to another table via a foreign key and that table has an issue in the .dbml, but I wanted to post this question now because I have put a lot of hours into this issue and would like to resolve it pretty soon, so maybe there is a stupid reason that I'm unaware of.
Thanks for any help. I shouldn't really need help with this because it's kinda stupid, but I'm really frustrated


text:
Q: TFS 2010 and SSMS2012 i was trying to use TFS 2010 in SSMS 2012 and, even if i installed Team Foundation Server MSSCCI Provider 2012 64-bit and Visual Studio 2010 Team Explorer, there's no way  to see TFS under the Current source control plug-in of SSMS.
What can i do to solve this problem?
Thanks in advance
Simone


text:
Q: what is the scope of  in JSF? I've seen 2 times that a  variable from a page previously browsed can interfere with or replace a variable (for example a h:datatable "var") from a page viewed downstream.
So what is the scope of ui:param ? And is there a way to contain it ?

A: It basically sets a new variable mapping in the EL context. See also the source code of ParamHandler:
94     public void apply(FaceletContext ctx, UIComponent parent)
95             throws IOException {
96         String nameStr = this.name.getValue(ctx);
97         ValueExpression valueVE = this.value.getValueExpression(ctx,
98                 Object.class);
99         ctx.getVariableMapper().setVariable(nameStr, valueVE);
100    }

Note line 99 (as in Mojarra 2.1.0). This retrieves the VariableMapper from the EL context and then sets a variable mapping on it with a ValueExpression as value.
This has basically the "global" scope. So if the variable name is "foo", then every single EL expression which is evaluated in the same EL context (basically, the current HTTP request) which ever references "foo" will be evaluated by the value expression as specified in the variable mapper. This has a higher precedence than the var of the repeating components, if any. So this may indeed lead to conflicts and "empty" looking repeaters.
Better give either the <ui:param> or the <h:dataTable var> a different name. You could for example choose to prefix all <ui:param> (and <c:set>) variables with _ or so.


text:
Q: Can a  tag appear more than once inside the  tag? a. Can a Ad tag appear more than once inside the VAST tag?
b. Can a Creatives tag contain more than one Creative element?
Reference: http://ad3.liverail.com/?LR_PUBLISHER_ID=1331&LR_CAMPAIGN_ID=229&LR_SCHEMA=vast2

A: Within the <VAST> element there can be one or more root <Ad> elements (at least one is required).
While a single <Ad> element represents the most common VAST response, multiple ads may be included as either stand-alone ads or a pod of ads (aka Ad Pod -introduced in VAST 3.0-), or a mix of both. Ads in a pod are distinguished by using the sequence attribute for an <Ad>, denoting which ad plays first, second, and so on. If the player supports ad pods, sequenced ads are played in numerical order and all ads in the pod should be played to the best of the player's ability. All sequence values in a VAST response must be unique. Non-sequenced ads, are stand-alone ads and considered part of an "ad buffet" from which the player may select one or more ad to play in any order.
The <Creatives> container (required -- only one may appear) can hold one or more <Creative> elements, in the form of Linear, NonLinear, or CompanionAds.
See VAST 3.0 spec for full details.


text:
Q: Com4j and Proguard obfuscation Com4j integration works fine in my Java application, but not when using Proguard obfuscation (other options turned off). What could I be doing wrong ?
Program hangs at at the COM4J.createInstance(...). I have seen this code stop at the same position before, namely when the Com4j library could not find the underlying com4j.dll native file. However, this code is indeed working without Proguard.
package mypackage;

public abstract class ClassFactory {
  private ClassFactory() {}

  public static MyInterface createMyComObjectInstance() {
      return COM4J.createInstance(MyInterface.class, ComObject_idString );
  }
}

The interface is defined thus:
public interface MyInterface extends Com4jObject {....}
Ditto ProGuard config file (tried several variants).
-libraryjars myPath\com4j.jar

-keep public class mypackage.** {*;}

-keep public interface MyInterface {*;}

-keep public abstract class mypackage.ClassFactory {
   public static MyInterface createMyComObjectInstance();

//also tried this
    *;
}

Note also that Proguard works just fine on the rest of the code, including some JNI/native modules.


text:
Q: Could not read from TensorArray index 0. Possible you are working with resizeable TensorArray. stop_gradients isn't allowing gradients to be written I am trying to reproduce the multi-gpu version of the code, with little change in the model architecture of ResNet (rest same) as given here https://github.com/FlyEgle/keras-yolo3. under train_height_point.py.
direct link : https://github.com/FlyEgle/keras-yolo3/blob/master/train_height_point.py
Error seems to be in the Yolo_loss function
I have tried modifying the while_loop and other tricks mentioned in other stackoverflow solutions
Gradients error using TensorArray Tensorflow
TensorArray TensorArray_1_0: Could not read from TensorArray index 0 because it has not yet been written to
https://github.com/tensorflow/tensorflow/issues/3663
When I run the code, I get the following error on the 1st epoch
Train on 62880 samples, val on 6976 samples, with batch size 1.
Epoch 1/400
2019-06-28 18:39:30.247036: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at tensor_array_ops.cc:661 : Invalid argument: TensorArray replica_0/model_3/yolo_loss/TensorArray_3: Could not read from TensorArray index 0.  Furthermore, the element shape is not fully defined: [?,?,3].  It is possible you are working with a resizeable TensorArray and stop_gradients is not allowing the gradients to be written.  If you set the full element_shape property on the forward TensorArray, the proper all-zeros tensor will be returned instead of incurring this error.
2019-06-28 18:39:30.251868: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at tensor_array_ops.cc:661 : Invalid argument: TensorArray replica_0/model_3/yolo_loss/TensorArray_1_4: Could not read from TensorArray index 0.  Furthermore, the element shape is not fully defined: [?,?,3].  It is possible you are working with a resizeable TensorArray and stop_gradients is not allowing the gradients to be written.  If you set the full element_shape property on the forward TensorArray, the proper all-zeros tensor will be returned instead of incurring this error.
2019-06-28 18:39:30.251942: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at tensor_array_ops.cc:661 : Invalid argument: TensorArray replica_0/model_3/yolo_loss/TensorArray_2_5: Could not read from TensorArray index 0.  Furthermore, the element shape is not fully defined: [?,?,3].  It is possible you are working with a resizeable TensorArray and stop_gradients is not allowing the gradients to be written.  If you set the full element_shape property on the forward TensorArray, the proper all-zeros tensor will be returned instead of incurring this error.
2019-06-28 18:39:31.368047: I tensorflow/stream_executor/dso_loader.cc:152] successfully opened CUDA library libcublas.so.10.0 locally
Traceback (most recent call last):
  File "train.py", line 517, in <module>
    _main()
  File "train.py", line 177, in _main
    callbacks=[logging, lr_schedule, checkpoint]
  File "/opt/conda/lib/python3.7/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
    return func(*args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/keras/engine/training.py", line 1418, in fit_generator
    initial_epoch=initial_epoch)
  File "/opt/conda/lib/python3.7/site-packages/keras/engine/training_generator.py", line 217, in fit_generator
    class_weight=class_weight)
  File "/opt/conda/lib/python3.7/site-packages/keras/engine/training.py", line 1217, in train_on_batch
    outputs = self.train_function(ins)
  File "/opt/conda/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py", line 2715, in __call__
    return self._call(inputs)
  File "/opt/conda/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py", line 2675, in _call
    fetched = self._callable_fn(*array_vals)
  File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1439, in __call__
    run_metadata_ptr)
  File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/errors_impl.py", line 528, in __exit__
    c_api.TF_GetCode(self.status.status))

tensorflow.python.framework.errors_impl.InvalidArgumentError: TensorArray replica_0/model_3/yolo_loss/TensorArray_3: Could not read from TensorArray index 0.  Furthermore, the element shape is not fully defined: [?,?,3].  It is possible you are working with a resizeable TensorArray and stop_gradients is not allowing the gradients to be written.  If you set the full element_shape property on the forward TensorArray, the proper all-zeros tensor will be returned instead of incurring this error.
     [[{{node replica_0/model_3/yolo_loss/TensorArrayStack/TensorArrayGatherV3}}]]
     [[{{node loss/add_20}}]]

A: According to the stacktrace above, you need to pass a parameter named element_shape with fully defined like element_shape(10, 10, 10) instead of None or element_shape=(None, 10, 10). It seems that there could not be a unknown dimension.
I also have this problem, and try to find a better way to solve it.


text:
Q: Trying to do post or put using RestClient; getting 422 error I'm trying to write a small rake task / test script for a rails RESTful API.  I'm using the rest-client gem.
According to the doumentation the following should work (with app.domain obviously changed)
response =  RestClient.post "http://app.domain.com/company/v1", {'company_name' => 'Acme'}.to_json, :content_type => 'application/json', :accept => :json

However I'm getting a 422 Unprocessable Entity response.
I had gotten the same response earlier when using Net:HTTP and saw that I needed to do
request["Content-Type"] = "application/json"

to handle the CSRF issue. In worked in that case but now I'm trying to use RestClient.
The RestClient code above would seem to handle it but I'm not having any luck.  I'm fine doing either a put or a post but neither is working and I've been unable to find such examples online. Has anyone been able to get this to work?  I'm using the latest version RestClient 1.6.7

EDIT
Below is the production.log file for the above call
I, [2013-10-03T14:35:08.982428 #7677]  INFO -- : Started PUT "/company/v1.json" for XXX.XXX.XXX.XXX at 2013-10-03 14:35:08 +0000
I, [2013-10-03T14:35:08.992628 #7677]  INFO -- : Processing by CompaniesController#add_company as JSON
I, [2013-10-03T14:35:08.992709 #7677]  INFO -- :   Parameters: {"company_name"=>"Acme", "company"=>{"company_name"=>"Acme"}}
W, [2013-10-03T14:35:08.992974 #7677]  WARN -- : Can't verify CSRF token authenticity
I, [2013-10-03T14:35:08.993194 #7677]  INFO -- : Completed 422 Unprocessable Entity in 0ms
F, [2013-10-03T14:35:08.995424 #7677] FATAL -- :
ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):
  actionpack (4.0.0) lib/action_controller/metal/request_forgery_protection.rb:163:in `handle_unverified_request'
  actionpack (4.0.0) lib/action_controller/metal/request_forgery_protection.rb:170:in `handle_unverified_request'
  actionpack (4.0.0) lib/action_controller/metal/request_forgery_protection.rb:177:in `verify_authenticity_token'
  activesupport (4.0.0) lib/active_support/callbacks.rb:377:in `_run__389768266939471454__process_action__callbacks'
  activesupport (4.0.0) lib/active_support/callbacks.rb:80:in `run_callbacks'
  actionpack (4.0.0) lib/abstract_controller/callbacks.rb:17:in `process_action'
  actionpack (4.0.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
  activesupport (4.0.0) lib/active_support/notifications.rb:159:in `block in instrument'
  ...

It's also interesting to note that the parameters aren't correct although I though I was following the post example from the documentation. (Post and put both give me the same errors in the log.)

A: As a work around Alex Coco's blog post talks about using :null_session specifically
class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  #protect_from_forgery with: :exception                   # default code
  protect_from_forgery with: :null_session                 # modification
end

Which if you look at the file is what they suggest doing.
Caveat: from what I understand this sets the systems strategy which means if you like putting a head on your RESTful services (in Rail's it's cheap to get a head and it's an easy way to poke around, especially if you want your non-technical staff to be able to check on something but don't want to and/or can't give them data access) I believe this turns off protection for that, too.  Of course, web-access to the head for the service is likely behind a firewall in most cases so it's probably ok.

A: You can try skip_before_action :verify_authenticity_token in your controller where you are getting csrf token error


text:
Q: Python & Pandas: Will using many df.copy affect code's performance? I'm doing some data analysis, and the data are in pandas DataFrame, df.
There are several function that I defined to do process on the df.
For encapsulation purpose, I define the functions like this:
def df_process(df):
    df=df.copy()
    # do some process work on df
    return df

In Jupyter Notebook, I use the function as
df = df_process(df)

The reason for using df.copy() is that otherwise the original df would be modified, whether you assign it back or not. (see Python & Pandas: How to return a copy of a dataframe?)
My question is:

*

*Is using df=df.copy() proper here? If not, how should a function handle data be defined?

*Since I use several such data processing function, will it affect my program's performance? And how much?

A: Far better would be:
def df_process(df):
    # do some process work on df

def df_another(df):
    # other processing

def df_more(df):
    # yet more processing

def process_many(df):
    for frame_function in (df_process, df_another, df_more):
        df_copy = df.copy()
        frame_function(df_copy)
        # emit the results to a file or screen or whatever

The key here is if you must make a copy, make only one, process it, stash the results somewhere and then dispose of it by reassigning df_copy. Your question made no mention of why you are hanging onto processed copies so this assumes you need not.


text:
Q: How to access class in another project using eclipse? I am developing android app using eclipse for this I am creating data access layer as java project. Now I am trying to access this class from android app. So I have added the java project to build path of android project. Now I can able to access the class by importing that . But while running the app I am getting the ClassNotFoundException.
It may seems duplicate but I am new to eclipse and java and I did not understand what they are trying to explain in other questions. So I need help here.

A: Please put the JAR file for DataAcessLayer Project in Libs folder of your Android Project

A: Export your Java-project into a JAR. Specifically exporting only the src-folder. Then place the generated JAR on your Android-project under its libs-folder. It should be automatically added to your build path, else, right-click on your JAR, then Build Path > Add to Build Path.

A: *

*Right click on project > Export > java  > Jar File > your project > Finish

*Copy that jar and insert into libs folder and then Build Path > Add to Build Path


text:
Q: Нужна помощь с настройкой плагина - jquerymaskedinput Нужно выставить маску с конкретным кодом страны - +998, но в инпуте отображается только +__8, как это исправить?

A:

$.mask.definitions['9'] = '';
$.mask.definitions['d'] = '[0-9]';
$("#phone").mask("+998 ddd dd dd");
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.min.js"></script>
<input id="phone" type="text" />


text:
Q: Android maps v2 location in all aplication How to get current position in android maps v2, without having to see the map? Let all my application have access to the current location?

A: This is what LocationClient was created for.
See this training lesson for more details on getting current location: http://developer.android.com/training/location/retrieve-current.html

A: You use LocationManager to get location. Maps are just to display it.
This article explain how to use it.


text:
Q: Is there a workaround for: java.lang.RuntimeException: Could not generate DH keypair I am testing a Java application. I am trying to start an SSL handshake using DH ciphersuite. but I am getting the following error:
java.lang.RuntimeException: Could not generate DH keypair

Some people have suggested BouncyCastle, but many people have reported errors with it, so I am not encouraged to use it if there is another alternative.
One have suggested downloading Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files from http://www.oracle.com/technetwork/java/javase/downloads/index.html. I did replaced the following two files java.security and java.policy in C:\Program Files (x86)\Java\jre7\lib\security. Note that I also noticed that I have Java\jre7\security installed in: Program Files (x86) and Program Files and I replaced both. But, I still see the same error.
Is there any  workaround for this error ?
EDIT:
The stack trace:
javax.net.ssl.SSLException: java.lang.RuntimeException: Could not generate DH keypair
    at sun.security.ssl.Alerts.getSSLException(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.handleException(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at MyClass.MyClass.myFunction(MyProg.java:78)
    at MyClass.MyClass.main(MyClass.java:233)
Caused by: java.lang.RuntimeException: Could not generate DH keypair
    at sun.security.ssl.DHCrypt.<init>(Unknown Source)
    at sun.security.ssl.ClientHandshaker.serverKeyExchange(Unknown Source)
    at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
    at sun.security.ssl.Handshaker.processLoop(Unknown Source)
    at sun.security.ssl.Handshaker.process_record(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    ... 4 more
Caused by: java.security.InvalidAlgorithmParameterException: Prime size must be multiple of 64, and can only range from 512 to 1024 (inclusive)
    at com.sun.crypto.provider.DHKeyPairGenerator.initialize(DHKeyPairGenerator.java:120)
    at java.security.KeyPairGenerator$Delegate.initialize(Unknown Source)
    ... 11 more

EDIT2:
My code is acting as a client trying to initiate SSL handshake with a remote server (website). I set the client's cipher suite list to:
{
"TLS_ECDHE_RSA_WITH_RC4_128_SHA",
"TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA",
"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
"TLS_ECDHE_RSA_WITH_NULL_SHA",
"TLS_DHE_RSA_WITH_AES_128_CBC_SHA256",
"TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
"SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA",
"SSL_DHE_RSA_WITH_DES_CBC_SHA",
"SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA"
};

All ciphersuites in the client's list are supported by Java. How can configure the Java client to support initiating an SSL handshake when the server offers long DH keys ?

A: Yes, basically dupe of #6851461 also #9162249 and #10687200. Unlimited strength policy is NOT the solution.
The prime size for DHE (and other DH) in SSL/TLS client is and must be set from the parameters received from the server, the client can't choose something different. (That's the ClientHandshaker.serverKeyExchange in the stacktrace.)
You already have ECDHE-RSA (which works okay in Java 7, or 6 if you add an ECC provider such as but not necessarily BouncyCastle) prioritized over DHE-RSA, and the server didn't choose it. You aren't offering plain-RSA; if you are willing to go without Forward Secrecy and the server is also, try adding at least some suites like _RSA_WITH_AES_128_CBC_SHA _RSA_WITH_RC4_128_SHA before (or instead of) the _DHE_RSA ones.
Another possibility is to ask the server operator(s) to use DH 1024-bit, if they're willing and permitted. It's not actually broken yet, but it is prohibited by some important standards.


text:
Q: Amazon S3 Transferutility use FilePath or Stream? When uploading a file to S3 using the TransportUtility class, there is an option to either use FilePath or an input stream. I'm using multi-part uploads.
I'm uploading a variety of things, of which some are files on disk and others are raw streams. I'm currently using the InputStream variety for everything, which works OK, but I'm wondering if I should specialize the method further. For the files on disk, I'm basically using File.OpenRead and passing that stream to the InputStream of the transfer request.
Are there any performance gains or otherwise to prefer the FilePath method over the InputStream one where the input is known to be a file.
In short: Is this the same thing
using (var fs = File.OpenRead("some path"))
{
    var uploadMultipartRequest = new TransferUtilityUploadRequest
    {
        BucketName = "defaultBucket",
        Key = "key",
        InputStream = fs,
        PartSize = partSize
    };

    using (var transferUtility = new TransferUtility(s3Client))
    {
        await transferUtility.UploadAsync(uploadMultipartRequest);
    }
}

As:
    var uploadMultipartRequest = new TransferUtilityUploadRequest
    {
        BucketName = "defaultBucket",
        Key = "key",
        FilePath = "some path",
        PartSize = partSize
    };

    using (var transferUtility = new TransferUtility(s3Client))
    {
        await transferUtility.UploadAsync(uploadMultipartRequest);
    }

Or are there any significant difference between the two? I know if files are large or not, and could prefer one method or another based on that.
Edit: I've also done some decompiling of the S3Client, and there does indeed seem to be some difference in regards to the concurrency level of the transfer, as found in MultipartUploadCommand.cs
private int CalculateConcurrentServiceRequests()
{
  int num = !this._fileTransporterRequest.IsSetFilePath() || this._s3Client is AmazonS3EncryptionClient ? 1 : this._config.ConcurrentServiceRequests;
  if (this._totalNumberOfParts < num)
    num = this._totalNumberOfParts;
  return num;
}

A: From the TransferUtility documentation:

When uploading large files by specifying file paths instead of a
stream, TransferUtility uses multiple threads to upload multiple parts
of a single upload at once. When dealing with large content sizes and
high bandwidth, this can increase throughput significantly.

Which tells that using the file paths will use the MultiPart upload, but using the stream wont.
But when I read through this Upload Method (stream, bucketName, key):

Uploads the contents of the specified stream. For large uploads, the
file will be divided and uploaded in parts using Amazon S3's multipart
API. The parts will be reassembled as one object in Amazon S3.

Which means that MultiPart is used on Streams as well.
Amazon recommend to use MultiPart upload if the file size is larger than 100MB http://docs.aws.amazon.com/AmazonS3/latest/dev/uploadobjusingmpu.html

Multipart upload allows you to upload a single object as a set of
parts. Each part is a contiguous portion of the object's data. You can
upload these object parts independently and in any order. If
transmission of any part fails, you can retransmit that part without
affecting other parts. After all parts of your object are uploaded,
Amazon S3 assembles these parts and creates the object. In general,
when your object size reaches 100 MB, you should consider using
multipart uploads instead of uploading the object in a single
operation.
Using multipart upload provides the following advantages:
Improved throughput—You can upload parts in parallel to improve
throughput. Quick recovery from any network issues—Smaller part size
minimizes the impact of restarting a failed upload due to a network
error. Pause and resume object uploads—You can upload object parts
over time. Once you initiate a multipart upload there is no expiry;
you must explicitly complete or abort the multipart upload. Begin an
upload before you know the final object size—You can upload an object
as you are creating it.

So based on Amazon S3 there is no different between using Stream or File Path, but It might make a slightly performance difference based on your code and OS.

A: I think the difference may be that they both use Multipart Upload API, but using a FilePath allows for concurrent uploads, however,

When you're using a stream for the source of data, the TransferUtility
  class does not do concurrent uploads.

https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingTheMPDotNetAPI.html


text:
Q: Vector of Counts in R This is my table

booksRead     0  1  2  3  4  5  6  7  8   9
frequency  2  4  4  8  4  5  2  4  2   1

With frequency being the number of students having read x books for example. eg, 8 students read 3 books last week
Created with
> nTimes <- c(0:9)
> frequency <-c(2,4,4,8,4,5,2,4,2,1)
> xTable <- rbind(nTimes,frequency)

I want to find a way to get
vectorOfCounts <- c(0,0,1,1,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5,5,6,6,7,7,7,7,8,8,9)

without having to type it. Ideally, I would somehow use the variable I created previously.

A: Use rep
DATA
booksRead = c( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
frequency= c(2, 4, 4, 8, 4, 5, 2, 4, 2, 1)

COMMAND
vectorOfCounts = rep(x = booksRead,times = frequency)
vectorOfCounts
# [1] 0 0 1 1 1 1 2 2 2 2 3 3 3 3 3 3 3 3 4 4 4 4 5 5 5 5 5 6 6 7 7 7 7 8 8 9

A: You can achieve it iteratively, by using a for-loop:
booksRead <- 0:9
frequency <- c(2, 4, 4, 8, 4, 5, 2, 4, 2, 1)

length(booksRead) == length(frequency) #check: TRUE required

Counts <- c() #initialize by empty vector
for(i in 1:length(booksRead)) {
  Counts <- c(Counts, rep(booksRead[i], frequency[i]))
} #update iteratively

Counts

## [1] 0 0 1 1 1 1 2 2 2 2 3 3 3 3 3 3 3 3 4 4 4 4 5 5 5 5 5 6 6 7 7 7
## [33] 7 8 8 9


text:
Q: Как создать страницы для нужных языков после wp_insert_post() Ситуация такая...
Я добавляю пост через wp_insert_post(). После добавления поста, я получаю ID  поста. Нужно, чтобы в этот момент были добавлены и переводы для этого поста.
У меня плагин стоит polylang.
В инете искал решение для данной задачи, вроде есть, но оно не подходит, поскольку мне надо еще и получить ID переводов.
Мой код выглядит так.
$customfields = array(
    'name' => $name,
    'surname' => $surName,
    'email' => $email,
    'position' => $donorPosition,
    'phone' => $phone,
    'address' => $address,
    'currency' => $currencyType,
    'comment' => $notes,
    'paysystem' => $payMethod,
    'status' => 'pending',
    'projectid' => $projectId,
    'amount' => $amount,
    'anonymous' => $anonymous,
    'custom_amount' => $customAmount,
    'exchange' => $exchange
);

$postFields = array(
    'post_status'    => 'publish',         // Post status.
    'post_title'     => 'Donated by '.$name.' '.$surName, // Post title.
    'post_type'      => 'custompayments', // Post type.
    'meta_input'     => array( 'custompaymentsfields'=> $customfields )// Add meta fields
);
$post_id = wp_insert_post( $postFields);

Мне нужно, таким образом, сразу добавить и переводы.
Спасибо за помощь!

A: Вы должны создать перевод так же, как и основной пост
$post_id_ru = wp_insert_post( $postFieldsRU);

И затем указать Polylang, что посты связаны:
$translations = [
    'en' => $post_id,
    'ru' => $post_id_ru,
] ;

pll_save_post_translations( $translations );


text:
Q: Difference between coin (v.) and term (v.) I am working on my scholarship exam but, as a non-native, I found this question pretty confusing.

Some critics say the 1990s saw what could be (.....) a computer
  revolution. By the mid 1990s the number of people buying personal
  computers increased significantly. (A) changed (B) coined (C) termed
(D) viewed

The answer key provided is (C) termed which I think that makes sense by the definition of term (verb).

to give something a name or to describe it with a particular
  expression

However, I think "coined" is also correct by the definition of coin (verb).

to invent a new word or expression, or to use one in a particular way
  for the first time

Could you please elucidate why "coined" is inappropriate for this question?

A: Because 'coin', as a verb in this context, is only applied to the invention or creation of a new word or phrase and requires as an object a noun such as word, phrase, term, expression, but does not work with the definition of that expression alone.
The first example given in the Oxford Dictionary on line is in the active voice:

'he coined the term 'desktop publishing''

although it also provides examples in the passive:

'A new word was coined to describe such individuals: 'cybersquatters.''

And one can use the word adjectivally (my example):

''cybersquatters', a word coined to describe such individuals'

but, again, in relation to a word or phrase.
The incorrect adjectival usage in the example in the question would imply that you could say:

'This phenomenon was coined a 'computer revolution''

Although grammatical, this doesn't make sense. It is a phrase that was coined, and that phrase happened to be 'computer revolution', but 'computer revolution' alone refers to a phenomenon the occurred, irrespective of its name. It was not coined, it happened. So one must say something like:

'The phrase 'computer revolution' was coined to describe this phenomenon'

In contrast, term does not mean to invent a name or phrase, but rather to use a name or phrase to describe a phenomenon, and takes as its object the phrase literal. The Oxford entry is:

Give a descriptive name to; call by a specified term.
'he has been termed the father of modern theology'

The person that used the phrase did not necessarily invent it, and the sentence refers to the phrase itself, not to the action of inventing it.


text:
Q: Prove that $T$ is a contraction For $b\gt 0$ and $a \in \mathbb{R}$, define $T$ on $C[0,b]$ by $Tf(x)=a+\int_0^xf(t)xe^{xt}\,\mathrm dt$. Prove that $T$ is a contraction. From this, show that there is a unique solution for $f \in C[0,\infty)$ to the integral equation $f(x)=a+\int_0^xf(t)xe^{xt}\,\mathrm dt$.
Ok, so I first have to prove that $\lVert Tf(x) \rVert_{\infty}$ is bounded.
I have $\lVert Tf(x) \rVert_{\infty} \le a + \sup_{x \in [0,b]}\int_0^b|f(t)xe^{-xt}|\,\mathrm dt$ and I know that $\lVert f(x) \rVert_{\infty} \le R$ since $f$ is defined on a compact set, but I'm having trouble comming up with the bound for $\lVert Tf(x) \rVert_{\infty} \le a + \sup_{x \in [0,b]}\int_0^b|f(t)xe^{-xt}|\,\mathrm dt$ .
Any help would be appreciated.

A: You need to show that the $\|Tf -Tg\| \leq \lambda \|f-g\|$ for some $\lambda \in (0,1)$.
Let $x \in [0,b]$. Then
\begin{align}
|(Tf)(x)-(Tg)(x)| & =  \left|\int_0^x(f(t)-g(t))xe^{-xt}\,\mathrm dt \right| \\
& \leq  \int_0^x| f(t)-g(t)| xe^{-xt}\,\mathrm dt \\
& \leq  \int_0^xxe^{-xt}\,\mathrm dt\cdot \|f-g\|\\
&= (1-e^{-x^2}) \|f-g\|.
\end{align}
Hence $\|Tf-Tg\| \leq (1-e^{-b^2}) \|f-g\|$. Since $(1-e^{-b^2}) <1$, we see that $T$ is a contraction.


text:
Q: Not receiving PAYMENT_UPDATED event for payment webhooks I was able to use square's webhook API based on descriptions here, https://docs.connect.squareup.com/api/connect/v1#webhooks-overview
and payment webhook was working fine.
Recently, I noticed that after completing a cash payment my webhook event handler
is not receiving any PAYMENT_UPDATED notifications.
I'm able to get the Test Webhook Notification trigger with my event handler service and I did register the PAYMENT_UPDATED webhook for my location.
This service was working before, is there any new changes for square-connect api?

A: There is no guarantee that the webhooks notification will successfully go through. If it fails for any reason, Square will not attempt to resend it. You should definitely use alternate methods (such as the ListTransactions endpoint) to fully verify the data.


text:
Q: Why use "<&3", "3&-" and "3I'm going through a bash script, trying to figure out how it works and potentially patching it. The script in question is this cryptroot script from debian responsible for decrypting block devices at boot. Not being completely  at home in bash definitely makes it a challenge.
I found this piece of code and I'm not sure what it does.
if [ -r /conf/conf.d/cryptroot ]; then
    while read mapping <&3; do
        setup_mapping "$mapping" 3<&-
    done 3< /conf/conf.d/cryptroot
fi

My guess is that it reads each line in /conf/conf.d/cryptroot and passes it to setup_mapping. But I don't quite understand how, what the significance of <&3, 3&- and 3</conf/conf.d/cryptroot is, and what they do?
When I read lines from a file I usually do something like this:
while read LINE
    do COMMAND
done < FILE

Where the output of FILE is directed to read in the while loop and doing COMMAND until the last line.
I also know a little bit about redirection, as in, I sometimes use it to redirect STDOUT and STDERR to stuff like /dev/null for example. But I'm not sure what the redirection to 3 means.
After reading a little bit more about I/O redirection I've something close to an answer, according to tldp.org.

The file descriptors for stdin, stdout, and stderr are 0, 1, and 2,
  respectively. For opening additional files, there remain descriptors 3
  to 9.

So the 3 is "just" a reference to an open file or:

...simply a number that the operating system assigns to an open file
  to keep track of it. Consider it a simplified type of file pointer.

So from what I understand:

*

*The 3< /conf/conf.d/cryptroot opens /conf/conf.d/cryptroot for reading and assigns it to file descriptor 3.

*The read mapping <&3 seems to be reading the first line from file descriptor 3, which points to the open file /conf/conf.d/cryptroot.

*The setup_mapping "$mapping" 3<&- seems to be closing file descriptor 3, does this mean that it is opened again for every turn in the loop and pointing to the next line?

If the above is correct my question is why do this rather than the "normal" way? e.g.
while read mapping; do
    setup_mapping "$mapping"
done < /conf/conf.d/cryptroot

What advantage (if any) does the first version provide?

A: A common problem with
while read LINE
    do COMMAND
done < FILE

is that people forget the COMMAND is also reading from FILE, and potentially consuming data intended to be read by read in the control of the while loop.  To avoid this, a common idiom is to instead read from a different file descriptor.  That is accomplished with <&3.  But doing that opens file descriptor 3 for COMMAND.  That may not be an issue, but it's reasonable to explicitly close it with 3<&- . In short, the construction you're seeing is just a way to avoid having setup_mapping inadvertently read data intended for read.


text:
Q: File inputs&outputs Hey everyone.
I have an exe file that runs a console program that was programmed in C.
during the run of the program the user is asked to enter numbers (using the scanf function).
and the output is being printed to the screen by printf.
The thing is this. I want to make my own txt file with inputs and I want the program to use those inputs.
I also want that the output will be printed to a different txt file - and not in the command window (or in addition to the command windows - I don't care if it's both).
how can I do that, in c#? or can I create a *.bat file that will do that? - that would be best.
Another question:
Is there a way to create a *.bat file that will check if two txt files are the same?
Thanks!

A: Assuming that the program was written to read from stdin (standard input) and write to stdout (standard output), you should be able to use the following command line:
program.exe < input.txt > output.txt


text:
Q: MongoDB is much slower in comparision to MySQL - basic find() method It is my first Stackoverflow question but I'm long time reader.
I'm working on some home project and I tried to compare the speed of MongoDB and MySQL. Suprisingly.. MongoDB is almost 5 times slower even with very basic table? I was reading that they are almost the same speed but it got me thinking.
Can someone explain to me why is this happening?
The MongoDB code:
app.get('/mongodb', function(req, res, next) {
  var time = process.hrtime();
  User.find(function(err, users) {
    if (err) return next(err);
    var diff = process.hrtime(time);
    if(diff[0] == 0) {
      res.send(diff[1].toString());
    } else {
      res.send(diff[0]+"."+diff[1]);
    }
  });
});

The MySQL code:
app.get('/mysql', function(req, res, next) {
  var time = process.hrtime();
  mysql.query("SELECT * FROM users", function(err, results) {
    if (err) throw err;
    var diff = process.hrtime(time);
    if(diff[0] == 0) {
      res.send(diff[1].toString());
    } else {
      res.send(diff[0]+"."+diff[1]);
    }
  });
});

MySQL returns: 1.52201348
MongoDB returns: 9.746405351
Schema is:
User {
  id integer,
  name string,
  email string,
}

There are around 500000 of Users.
Index is on _id in MongoDB and id in MySQL.
MongoDB shell version: 2.4.6
MySQL version: 5.5.37
Any ideas? Any help or suggestions will be much appreciated.
Regards,
Wnzl.

A: I think the main problem here is that benchmarking should always be done with respect to a special use case.
The assumption, that they perfom with same speed is pretty unspecific.
So the use case you examine here is defined by your example and means getting all entities of a schema. Even if the use case is pretty simple,  the meaningfulness of your result won't be.
MongoDB and SQL are database systems designed for different use cases. This means that each system is optimized for different queries. This is where I think you should dig deeper to get the reason for different performances.
Also take into account, that based on hat, querying all entity's of one schema, perhaps could be realized with multiple but in total faster queries. Last think about bootstrap, caching and indexing mechanisms that may be  total different due to optimizations to system specific use cases.