2018-10-22         Blithe

dplyr replace by position in R

The value of the third row of mtcars$mpg is 22.8.library(tidyverse)mtcars$mpg[[3]]I go ahead and replace this 22.8 with the value 5,555 as shown below. It works but not at the third row as I command my computer to do! Instead the value shows up at the 22nd row of the mtcars$mpg column. mtreplace <- mtcars %>% mutate(mpg = replace(mpg, mpg[[3]], 5555))mtreplacemtreplace$mpg[[3]]mtreplace$mpg[[22]]How do I get this change to occur at precisely the third row of mtcars$mpg? And what went wrong? The code should bemtcars %>% mutate(mpg = replace(mpg, 3, 5555)) [XXX...

 r                     3 answers                     11 view
 2018-10-22         Blithe

Django annotate model and filter for specific value

I'm trying to get into djangos annotate, but can't quite figure out how it works exactly. I've got a function where I'd like to annotate a queryset of customers, filter them and return the number of customersdef my_func(self): received_signatures = self.customer_set.annotate(Count('registrations').filter().count()Now for the filter part, thats where I have a problem figuring out how to do that. The thing I'd like to filter for is my received_signatures, which is a function that is being called in my customer.py def received_signatures(self): signatures = [reg.brought_...

 python                     1 answers                     28 view
 2018-10-22         Blithe

django variable passing

I have a page that I'm rendering with Django call it example.html. In example.html I have some code that is something like{{ MyObject.Attribute }}How do I get MyObject to be passed into the page so that I can display it? I know that it's in urls.py, but I'm not exactly sure how it works. The tutorial has a section ...http://docs.djangoproject.com/en/dev/intro/tutorial03/#write-views-that-actually-do-something.. that walks you through it. [XXX]

 django                     1 answers                     0 view
 2018-10-22         Blithe

How to unfold a python dictionary of lists based on key-value "pairs"?

I have an algorithmic problem using a Python3.x dictionary of lists, though perhaps another data structure is more appropriate. Let's say I have the following Python dictionary:dict1 = {1:[4, 12, 22], 2:[4, 5, 13, 23], 3:[7, 15, 25]}The key 1 associate with the value [4, 12, 22] signifies that 1 is "associated with" 4. 1 is also associated with 12, and 1 associated with 22. Also, 2 is associated with 4, 2 is associated with 5, 2 associated with 13, and 1 associated with 23, etc. My question is, for this small example, how do I "unfold" this dictionary such that each element...

 python                     4 answers                     40 view
 2018-10-22         Blithe

Using redirect sends me to /tag/?search=input instead of /tag/input (Django URL argument from form)

I have a page where there is a path /tag/name_of_tag and you can see all posts tagged with that tag.Inside the page, you can also select another tag in a form and go to that tag.The problem is that instead of going to /tag/searched_tag, it goes to /tag/?search=searched_tagHow can I change it doesn't leave the ?search= part?urls.py:url(r'tag/(?P<input_tag>\w+)$', views.tag_view, name='tag'),views.py:def tag_view(request, input_tag): form = TagSearchForm() if request.method == 'GET': form = TagSearchForm(request.GET) if form.is_valid(): in...

 django                     2 answers                     31 view
 2018-10-22         Blithe

ServiceStack 4.0 with Microsoft Application Insights Telemetry

Working on MS project default Web Application Template and planning to use Application Insights to monitor WEB API. Is there any efficient way to configure Insights on root level like it's done for example in standard Web Application projects with controllers and views (adding a script in layout page)?Service stack has no views or controllers in project... None of ServiceStack Project Templates are configured to use Application Insights, so the easiest approach is to create an Empty ASP.NET Web Application that's pre-configured with App Insights and Install ServiceStack ...

 c#                     1 answers                     74 view
 2018-10-22         Blithe

Unity Sprites images not updating

I'm working on re-skinning a unity game. The game come with unitypackage and I've imported and run it successfully but when I updated images at sprites folder and re-run it won't update the images and strange things some images updated and most of the images are not. Here is the screenshotPlease help me. One big image holds the resources and I need to update that. [XXX]

 android                     1 answers                     34 view
 2018-10-22         Blithe

jquery: grab the values from multiple select menus each time a new option is chosen

I'm building a live price quote form with jQuery, using a series of select menus. I've come up with the code below, which grabs the default values from each select menu and adds them together:$(document).ready(function(){ $('select > option:selected').each(function() { var value = $(this).attr('label'); total = parseFloat(total) + parseFloat(value); total = total.toFixed(2); }); printTotal(total); // prints the total price});The only problem is that this only works when the page loads. I'd like the price to be updated each time a new value is selected in any of the se...

 jquery                     2 answers                     20 view
 2018-10-22         Blithe

Stored Procedure error "Must declare the scalar variable"

I have written a stored procedure to extract data from a table in SQL Server:SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[csp_OperatorVarianceMonthlyView]-- =============================================-- Procedure: csp_OperatorVarianceMonthlyView---- Summary: Produce the result table that is needed for the Operator Variance Tracker report.---- Params: @RetailStoreId - Store Id on which the results need to be filtered-- @StartDate - The start business day date for which results are to be collected (NULL = Today)-- @EndDate - The end bu...

 sql                     1 answers                     64 view
 2018-10-22         Blithe

Running a python (.py script) on sql server

I had been trying to run python from SSIS. SO i needed to create a package in sql server. I can run small scripts in sql server but I am not sure how to run scripts.Below works. But my python code is in test_db.py How do I run that python script in sql server?EXEC sp_execute_external_script @language = N'Python', @script = N'print(3+4)'STDOUT message(s) from external script: 7 If the Python engine is installed on the server where you are trying to run this script, you can use the execute process task and call the python.exe. Pass the .py file as an argument to the task a...

 python                     1 answers                     73 view
 2018-10-22         Blithe

Hazelcast - What are write and read methods of Map property for Portable serialization

I am implementing portable serialization in Hazelcast. I am saving a java object(Employee) to hazelcast, which contains a property of type Map. What methods to be used to serialize this map property here?public class Employee implements Serializable, Portable { private String name; private Map<Integer, Address> addresses; // getters and setters @Override public int getFactoryId() { return 1; } @Override public int getClassId() { return 1; } @Override public void writePortable(PortableWriter writer) throws IOException { ...

 java                     2 answers                     79 view
 2018-10-22         Blithe

Is it bad If I use the ServiceProvider interface to resolve my properties in .NET Core for Dependency Injection

Is it bad If I use the ServiceProvider interface to resolve my properties in .NET Core for Dependency Injectionlet say I have the following private readonly IRecipeRepository _recipeRepository; private readonly IMediaResource _resourceUpload; private readonly IAWSMedia _awsMedia;and then do this public RecipeService(IServiceProvider service) { _recipeRepository = service.GetService<IRecipeRepository>(); _resourceUpload = service.GetService<IMediaResource>(); _awsMedia = service.GetService<IAWSMedia>(); }instead of thi...

 c#                     1 answers                     65 view
 2018-10-22         Blithe

Is there a free JSF Webhost out there?

i am looking for a free Webhost for JSF sites..unfortunately i didn't find any by Google. It is just for testing .. i know .. i could test it with localhost.but i do want to have real time conditions. So I'm afraid they aren't free, but they are pretty close.Have you considered using a cloud computing service. You pay by the hour, typically pennies, that you use and when you don't need the machine instance it can be turned off. You would need to find a server instance that did what you needed or make your own but once done you have one or more machines available on dema...

 jsf                     3 answers                     76 view
 2018-10-22         Blithe

Get index number of item at the top of a Listview OnDisappear in Xamarin Forms

Is it possible to get the index number of a listview cell that is on the top of the ListView when OnDisappear?I am trying to store the position of the listview when a user tabs to clicks a modal, and restore it later OnAppear. I would use ItemAppearing eventvar listView = new ListView { ... };listView.ItemAppearing += async (sender, e) =>{ // get index of e.Item + add count of items available at visual}; [XXX]

 c#                     1 answers                     87 view
 2018-10-22         Blithe

how to update table size inside hash function

I was learning how to implement Hash table but i am bit confused here in because in the book below code was available and i understood well enough the code, but inside book there was no definition of HASH function ,i know we have to define it by own ,but according the below code that was given give inside book HASH is taking two arguments wherever i used the HASH like in HashInsert it is taking two arguments index=HASH(data,t->size) if we assume that return type of HASH as int now for eg we can define HASH as int HASH(int data,int tsize){return(data%7);}but according ...

 c                     1 answers                     69 view
 2018-10-22         Blithe

list instead of list of list

I have this code that returns a list of list, I would like to return only one list efficiently, how can I achieve that?def GetCast(path,key,Ids): list=[] for n in Ids: l=requests.get(path + str(n) + '/credits',key ) data= l.json() cast_Ids= [i['name'] for i in data['cast']] list.append(cast_Ids) return list just changelist.append(cast_Ids)bylist.extend(cast_Ids) # variant: list += cast_Ids(and don't use list from now on as it's the builtin name for the list type)or in one line with flattening list comprehension (I haven't tested this...

 python                     1 answers                     11 view

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