2018-10-22         Darnell

Replace Zero by value of another variable

This question already has an answer here: Replace empty values with value from other column in a dataframe 2 answers Create a logical vector and use that to subset both the replacement column and the replacee column to get the lengths equal while doing the assignment operationi1 <- mydat$X6 == 0mydat$X6[i1] <- mydat$X5[i1]The 0(mydat$X6) syntax is not clear - may be representation of a pseudo function [XXX]You can also use replace, i.e.mydat$X6 <- with(mydat, replace(X6, X6 ...

 r                     3 answers                     9 view
 2018-10-22         Darnell

Java Fx arrow buttons

I am trying to arrange triangular buttons(like 3d arrow keys) around a circle. I tried to do via css with code below. but did not work out. It does not apply the settings to the button. I checked Jfxtras and jfoenix but could not find anything useful. Any ideas please?#triangle-down {width: 0;height: 0;border-left: 50px solid transparent;border-right: 50px solid transparent;border-top: 100px solid red;} You could use a StackPane to achieve it. Inside add a Circle as a background (or an ImageView) and then add 4 buttons. To align them you need to call :StackPane.setAlignm...

 java                     1 answers                     50 view
 2018-10-22         Darnell

How to zoom camera using android camera2 API

I m using Camera2 Api for my app. I have a zoom in out function. I am able to zoom in and zoom out using pinch gesture. But how do I implement the same using a seekbar. The code to zoom:int mProgress;{ minZoom = getMinZoom(); maxZoom = getMaxZoom() - 1; final int zoomStep = 1; seekBarCardZoom.setMax(Math.round(maxZoom - minZoom)); seekBarCardZoom.setOnSeekBarChangeListener( new SeekBar.OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { setCurrentZoo...

 android                     1 answers                     56 view
 2018-10-22         Darnell

Django URL.py and the index

I want to know what is the best way to write in the URL.py. I am trying to get the index in this way: www.example.com with (r'',index). But when I try r'', all pages in the website are going to the home page.Part of my url.py:(r'^index',homepages),(r'',homepages),Thanks :) Like this: #... (r'^$', index), #... [XXX]Django URL matching is very powerful if not always as convenient as it could be. As Brian says, you need to use the pattern r'^$' to force your pattern to match the entire string. With r'', you are looking for an empty string anywhere in the URL, which is ...

 python                     2 answers                     99 view
 2018-10-22         Darnell

How to calculate dictionaries of lists using pandas DataFrame?

I have two strings in Python3.x, which are defined to be the same length:string1 = 'WGWFTSJKPGP'string2 = 'DORKSRQKYJG'I am also given an integer which is meant to represent the "starting index" of string2. In this case, start_pos = 51. The goal is to create a dictionary based on the indices. So, string1 begins at 0, string2 begins at 51. The dictionary "converting" these coordinates is as follows:{0: 51, 1: 52, 2: 53, 3: 54, 4: 55, 5: 56, 6: 57, 7: 58, 8: 59, 9: 60, 10: 61}which can be constructed (give the variables above) with:convert_dict = {i: i + start_pos for i, _ in...

 python                     3 answers                     39 view
 2018-10-22         Darnell

ServiceStack client add attachment

I'm using ServiceStack.ServiceClient.Web.XmlServiceClient to connect to a webservice. Is there a way to add an attachment to the request?More info:What I am trying to do is avoid using Microsoft.Web.Services2 because I am using Mono. I'm trying to upload an XML datafile, along with an XML request. Just like in this question:Upload report unit via webservice in C# .net to jasperserver To upload files the best (and fastest) way is to not encode it as a normal request variable but simply upload it to the web service as a normal HTTP Upload with ContentType multipart/form-d...

 c#                     1 answers                     73 view
 2018-10-22         Darnell

How to color Ada procedure/function calls in GNAT GPS

Is there a way to color the calling Ada procedures or functions in Gnat GPS IDE?Is there any custom solution to this?Check the comment in the following code to see what I mean:package body Pkg is function Get_Amount (a : b) return Integer is begin return 0; end Get_Amount; procedure Print_Owing is begin Get_Amount (x); --This call here shall be colored if possible but its not. end Print_Owing;end Pkg; Right-click the name, try "Name is called by" menu item. [XXX]The coloration of procedures and functions is not supported.Even for types, you'll no...

 editor                     2 answers                     92 view
 2018-10-22         Darnell

jQuery / Programmatically Select an Option in Select Box

I'm currently using jQuery to return some JSON results. Once these results are returned, I'm using them to pre-populate fields in my form.However, I need some help in pre-selecting items in a drop down box. For example, I have a select box (this is shortened):<select id="startTime"><option value="14:00:00">2:00 pm</option><option value="15:00:00">3:00 pm</option><option value="16:00:00">4:00 pm</option><option value="17:00:00">5:00 pm</option><option value="18:00:00">6:00 pm</option></select>And if my...

 javascript                     8 answers                     17 view
 2018-10-22         Darnell

SQLAlchemy- Execute Stored Procedure and Populate Class

Is there any way to execute a stored procedure and get back a class?I have tried:session.query(MyClass).from_statement(...)Where myclass is defined as:MyClass(Base): id = Column(Integer) name = Column(String) ...I know that I should put:__tablename__ ‘sometable’But there is no table as all the rows are the result of a stored procedure call. Do you know any way to get around this? Michael Bayer REPO OWNERSQLAlchemy does not have support for OUT parameters on any backend except Oracle at this time. In order to use OUT parameters now, you need to use the DBAPI fu...

 python                     1 answers                     61 view
 2018-10-22         Darnell

What to use for SQL Server instead of "Key"?

I have a script of MySQL queries that I use and that work.I'm trying to execute the same queries in Microsoft SQL server and there's one thing I don't understand.MySql uses "key" to define a key made up of different fields.What is the way to do the same thing in SQL Server?Thanks!-Adeena You can declare a primary key that consists of multiple columns in TSQL (SQL server's query language)ALTER TABLE product ADD CONSTRAINT prim_prod PRIMARY KEY(product_foo, product_bar)If you use SQL Server Management studio, you can also achieve this via "Modify Table". [XXX]In MySQ...

 sql                     2 answers                     71 view
 2018-10-22         Darnell

Can't access hazelcast mancenter using kubernetes

I'm trying to investigate and learn a little more about kubernetes and I followed the guide https://blog.hazelcast.com/deploy-monitor/ to install the hazelcast monitor in my kubernetes cluster.If I see the kubernetes dashboard it has the 2 deployments, 3 pods and my-service as green.Running this:λ kubectl get service my-serviceNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEmy-service NodePort <none> 8080:30476/TCP 2hBut when I runλ minikube service my-serviceOpening kubernetes service default/my-service in default ...

 kubernetes                     1 answers                     83 view
 2018-10-22         Darnell

How to Overcome Entity Framework Caching/Tracking Using MassTransit?

Forgive my ignorance, but it appears that MassTransit treats singleton and scoped dependencies effectively the same. At least in the case of an Entity Framework DbContext and, therefore, the UserManager registered via the extension method AddEntityFrameworkStores.This means that any entities loaded with tracking or otherwise added to the context are cached for the duration of the application lifetime. That, in turn, means that changes to these entities via anything outside of the context (say ad-hoc scripts) won't be recognized until the service is recycled.Is there a best ...

 dependency-injection                     1 answers                     65 view
 2018-10-22         Darnell

DNS and domain hosting

I registered a domain www.xyz.comI hosted my files at xxx.hosting.comNow i made a redirect at www.xyz.com pointing to xxx.hosting.comQuestion:Now when i load xyz.com the hosted index.php is loaded. When i click on page2.php the page gets loaded but the url www.xyz.com remians same.But it should be like xyz.com/page2.php. How to do it? Any idea? Can't you register a DNS CNAME entry that redirects www.xyz.com to xxx.hosting.com? Of course xxx.hosting.com would have to accept different host headers, but I assume the xxx subdomain is your own, so it should work. [XXX]...

 web-hosting                     2 answers                     71 view
 2018-10-22         Darnell

Test with ISearchIndexClient

I want to test my functions. All of them depend from ISearchIndexClient. I tried to create a Mock<ISearchIndexClient> but I can't use it because the mock is not accepted from ISearchIndexClient.In my function I'm callingDocumentSearchResult<SearchData> result = await client.Documents.SearchAsync<SearchData>(searchText, sp);Then, I tried to create my custom client aspublic class CustomSearchIndexClient : ISearchIndexClient { }andpublic class CustomDocumentsOperations : IDocumentsOperations { }but I can't override SearchAsync<T&...

 c#                     1 answers                     96 view
 2018-10-22         Darnell

Automatic storage duration struct initialization

Some of this may be a duplicate, but I am sorry for that.Let's say I have this struct:struct foo{ int a; int b; int c;};1. If struct foo type object is declared in the way that it has automatic storage duration and without initializers, is it guaranteed that all it's members will be force initialized to zero?{ // other stuff struct foo bar; // other stuff}2. If struct foo type object is declared in the way that it has automatic storage duration and with some initializers, is it guaranteed that members, which are not explicitly initialized, will be force ...

 c                     2 answers                     68 view
 2018-10-22         Darnell

Algorithm of searching for a pair of integers in a list

I'm quite new to algorithm and I encountered a question to which my approach does not works properly. Here's the precondition:You are given a list L=[(a1,b1),…,(an,bn)] of n pairs of integers. For any two pairs (ai,bi)∈L and (aj,bj)∈L such that 1≤i≤j≤n , we have (at least) one of three cases:ai=aj and bi=bj ai < aj bi < bj For example, the list L=[(1,2),(1,1)] would not be valid. An example of a valid list is: L = [(0,1), (1, 0), (0, 1), (1, 1), (1, 2), (3, 1), (3, 1), (2, 2), (2, 3), (3, 2), (2, 3), (4, 3), (3, 4), (4, 4), (4, 5), (5, 5)]The question is: Write ...

 python                     1 answers                     11 view

Page 1 of 144  |  Show More Pages:  Top Prev Next Last