2018-10-22         Merlin

In Rails how to get the average of the substract of two datetime columns

I need to get the average of updated_at - created_at datetime columnsI tried this way but it does not work as I expected:User.average('updated_at - created_at')It is giving this sql query:SELECT AVG(updated_at-created_at) FROM `users`When I filter by one ID getting one object it is revealing me different result than user.updated_at - user.created_at. That is why I think my sql query is not correct.User.where(id: 3).average('updated_at - created_at').to_f => 29183.0user = User.find(3) # (created_at: "2018-07-25 09:58:56", updated_at: "2018-07-25 12:50:39")user.updated_at ...

 mysql                     1 answers                     47 view
 2018-10-22         Merlin

Creating "Pivot Table" in R Populated with Factor Value for Each Row

I would like to take date input like this:library(plyr)names(ChickWeight) <- tolower(names(ChickWeight))ChickWeight$diet.name <- as.factor(revalue(ChickWeight$diet, c("1" = "Grain", "2" = "Grubs", "3" = "Scraps", "4" = "Free Range")))which creates:> head(ChickWeight) weight time chick diet diet.name1 42 0 1 1 Grain2 51 2 1 1 Grain3 59 4 1 1 Grain4 64 6 1 1 Grain5 76 8 1 1 Grain6 93 10 1 1 Grain> tail(ChickWeight) weight time chick diet diet.name573 ...

 r                     1 answers                     14 view
 2018-10-22         Merlin

Can an arbitrary target fps range be specified with Camera2 API?

In our mobile application, camera capture on the Android device is sent as a video stream to a remote server.I need to automatically adapt my camera fps to the network speed. Basically, if I detect that the network is slow, I need to reduce the fps and keep reducing it until a balance is reached.I obtain available fps ranges using the field CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES on Camera2 API. I set the target fps using CONTROL_AE_TARGET_FPS_RANGE field. Let's say the possible list of ranges, for example, is (30, 30) and (15, 30).I started by setting the target with the hi...

 android                     1 answers                     56 view
 2018-10-22         Merlin

Can I configure Google Vision to recognize vulgar fraction symbols (e.g. ½, ¼, etc...)?

When I run this image containing various vulgar fraction symbols through the Google Vision demo, it recognizes all of the characters correctly except for those symbols. The same is true when I consume the API whether it be with TEXT_DETECTION or DOCUMENT_TEXT_DETECTION. Is there some way I can configure Google Vision to accurately recognize these symbols? Vision API doesn't have a specific configuration to detect this kind of characters. The OCR feature has been developed to perform text recognition; however, in some cases, the fraction symbols are not identified as char...

 google-cloud-vision                     1 answers                     1 view
 2018-10-22         Merlin

TSNE - 3D graph

Imagine data ncoll and wcoll as 4000ish random numbers.I want to run them through TSNE, then create a 3-dimensional plot.If I plot this I end up with essentially a 2D graph, so something is going wrong, but I'm not entirely sure what.Ultimately I want to plot the first half in red and the second in blue on the same 3D graph.print(__doc__)from time import timeimport numpy as npimport matplotlib.pyplot as pltfrom mpl_toolkits.mplot3d import Axes3Dfrom matplotlib.ticker import NullFormatterfrom sklearn import manifoldfrom sklearn.utils import check_random_statec = 1000 # Open ...

 python                     1 answers                     43 view
 2018-10-22         Merlin

Converting a nested dictionary to a list

I know there are many dict to list questions on here but I can't quite find the information I need for my situation so I'm asking a new quetion.Some background: I'm using a hierarchical package for my models and the built-in function which generates the tree structure outputs a nested loop to indicate parents, children, etc. My goal is to keep the logic in views and output a list so that I can simply loop over it in my templates.Here is my data, in the tree structure:1-1.1--1.1.1---1.1.1.1--1.1.2-1.2--1.2.1--1.2.2-1.3Here is the nested dictionary I am getting as a result{ &...

 python                     5 answers                     35 view
 2018-10-22         Merlin

Graphical open source text editor for large text files (> 200 MBytes)

Is there an open source alternative (similar to ultraedit) to handle files with filesize >200 MBytes? vim or gvim (graphical vim) should handle that with pleasure. [XXX]Duplicate of Best Free Text Editor Supporting More Than 4G Files? and even Editor to open big text files (XML export files), even if you added "open source" (most are). [XXX]Well, no one else had said it, so:emacsAlways emacs. [XXX]textpad will probably swallow itoops, just clocked the "open source" requirement. Typing before thinking. [XXX]Notepad++ is open source and has good support for ed...

 open-source                     12 answers                     95 view
 2018-10-22         Merlin

Stretching my rotated player forwards

I'm trying to recreate a movement system to use in my game. It's from a DS game called Dragon Quest Heroes Rocket Slime and one of the things players can do is hold down the A button and move in a direction to stretch their slime. Letting go of A while stretched would sling their slime off in the direction they were stretching.Here's a gif that shows that off:I have a bunch of state enums for the player (walking, idle, stretching, blasting(after stretching)). When the player is stretching (holding down space while idle) they rotate in the inputted direction but I'm not sure...

 c#                     1 answers                     38 view
 2018-10-22         Merlin

select value from table != value in array

array from 1 to 10i want to make a drop down to select values that in array excludeing values in the table in the databaseex:id=3 is in the table ==>drop down choices(1,2,4,5,6,7,8,9,10)ex:id=4 is in the table ==>drop down choices(1,2,3,5,6,7,8,9,10)<select name="Alert_Severtiy_No" class="form-control"><option value="">select</option> $no=array(1,2,3,4,5,6,7,8,9,10);foreach($no as $key): $hh="select * from Alert_Severtiy where Alert_Severtiy_No Not <>$no"; $stmt = sqlsrv_query($connect, $hh);echo '<option value="'.$hh.'">'.$hh.'</option>...

 php                     1 answers                     21 view
 2018-10-22         Merlin

How to make a middle step between 2 execute sql task in ssis package

I have a package that looks like this: When I add a constrain between the for loop and the SQL Task on the left side, it will stop the package at the execute sql task on the middle.Like this:How to make this work? I tried lots of ways but nothing is working. Set one of the constraints to 'Logical OR'. You have multiple constraints leading to 'Sql task - Set ExecutionLock'. If you left the constraint with the default value of 'Logical AND', both paths would have to evaluate to true in order for this task to execute. [XXX]

 sql-server                     1 answers                     77 view
 2018-10-22         Merlin

how to test hazelcast Eviction in 3.9.3 Eviction not working

I am using hazelcast 3.9.3 version. Hazelcast Client and server as springboot application with single node server and single node client.Configuration:MapConfig h = new MapConfig(); h.setEvictionPolicy(EvictionPolicy.LFU);h.setTimeToLiveSeconds(Integer.parseInt("60"));h.setMaxIdleSeconds(Integer.parseInt("60")); h.setMaxSizeConfig(new MaxSizeConfig(Integer.parseInt(9000), MaxSizeConfig.MaxSizePolicy.PER_NODE));config.getMapConfigs().put("hsr",hsrMap);Default partition is 271 as per documentation.how many items in each partition can hold.How to reduce and test the pa...

 hazelcast                     1 answers                     81 view
 2018-10-22         Merlin

Angular / Web API unable to communicate on endpoint

I'm running into an issue where Angular is unable to make a successful request on 2 of 3 endpoints but I have confirmed all work with postman and that the proxy is successfully routing the calls. Chrome - Network tab shows "blocked:other" and output of "ng serve" doesn't indicate anything in regards to proxy. Is there an issue with my angular service and/or server side controller?Controller[Route("api/[controller]")][ApiController]public class AffiliationController : ControllerBase{ public AffiliationController( IQueryHandler<GetAffiliationsQuery, IQueryable<...

 c#                     1 answers                     68 view
 2018-10-22         Merlin

Hosting/transferring a web site on Google App Engine

I have my website currently hosted on paid server, but i want to transfer it on GAE.How can i do it? Can anyone please help me in this case.I'd appreciate your help.Thanks:) 1) First you will have to adapt your website to the GAE framework (python with django or the new Java environment). You can test your work by downloading the SDK of GAE which offer a local server.2) Then create an account on appengine.google.com and upload your application on something.appspot.com, test it.3) If you have a domain name, create a google apps account on this domain, and finally bind thi...

 google-app-engine                     3 answers                     77 view
 2018-10-22         Merlin

How can I make a template binding that accepts a string for a color?

I am using a template like this:    <template:ButtonTemplate ButtonType="2" Grid.Column="0" Text="{Binding FBtnText}"      LabelTextColor="{Binding FBtnLabelTextColor, Converter={StaticResource StringToColorConverter}"      TapCommand="{Binding FBtnCmd }" />So the value of the color is entered as "#FF0000" and the converter then converts this into a color. Is there a way that I could do this conversion in the binding itself so that I would not need to use the StringToColor converter? Here's my binding that I am using right now:public static readonly BindableProperty L...

 xamarin                     1 answers                     88 view
 2018-10-22         Merlin

How to fix "error:assignment to expression with array type"?

I'm getting an error: error:assignment to expression with array typein this program, which should print words that have 4-8 letters:#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){ char rec[300]; int zbroj1=0, br=0, zbroj2=0; while((rec=getchar()) != '\n') { zbroj1++; } if(zbroj1>=4 || zbroj1<=8) printf("Nova recenica je: %s", zbroj1); return 0;}How can I fix this? Below is the code to print words of size >= 4 and <= 8#include<stdio.h>int main(void) { char rec[9]; //you may need to adjust the ...

 c                     4 answers                     73 view
 2018-10-22         Merlin

How to set self argument into decorator?

Can someone help me?I have something like:class MyClass: def __init__(self, *, arg1, arg2): self.arg1 = arg1 self.arg2 = arg2 @test_dec('some param', self.arg2) def test_func(): passBut it doesn't work.So, how can I put self.arg2 to test_dec?I want to do something like:import socketiosio = socketio.AsyncServer()class MyClass: def __init__(self, options): self.options = options @sio.on('connect', namespace=self.options['namespace']) def func(): pass At first when there is nothing, there is no self. if you want to do it you...

 python                     2 answers                     14 view

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