2018-10-22         Louis

Dynamically generate column names

I would like to dynamically generate columns based on the width of a cut statement.How can I dynamically generate the AGE1 to AGEn as in the example below?library(dplyr)df <- data.frame(AGE = 10:19, NUM = rnorm(n=10))# for 2num_by <- 2df_out2 <- df %>% mutate(AGEGROUP = cut(AGE, breaks = seq(10, 20, by = num_by), right = F)) %>% group_by(AGEGROUP) %>% summarise(SUM.NUM = sum(NUM))%>% mutate(AGELOW = as.numeric(substr(as.character(AGEGROUP), 2, 3)), AGE1 = AGELOW + 1)%>% select(-AGEGROUP) %>% gather(AGE, AGELOW:AGE1, -c(SUM.NUM))# for...

 r                     1 answers                     20 view
 2018-10-22         Louis

Can't import google.cloud.vision

I'm using Anaconda, and I'm trying to use google cloud vision, but I cannot import google cloud vision. I can import google cloud, but it throws an error below. from google.cloud import visionImportError: cannot import name 'vision'What module should I import with anaconda? (I've already imported google-api-core, google-auth, google-cloud-bigquery, google-cloud-core, google-cloud-sdk, google-cloud-storage, google-resumable-media, google-resumable-media, googleapis-common-protos)Could anyone solve this? Thanks in advance. You may need to add a dependency to google-cloud-v...

 python                     1 answers                     8 view
 2018-10-22         Louis

Creating a dynamic sql query using variables and in some cases their values (with joins)

I need to create a dynamic SQL query that changes based on different arguments/variables existence and value: So, I have something like this:def create_query(user=None, max=None, list=None)qs = 'SELECT N.status'if user: qs = qs.join('U.email')qs = join('from notes as N)'if user: qs = 'LEFT JOIN users AS U on N.user_id=U.id'if max: qs = qs.join('where max=') + maxif list: qs = qs.join('where fame_values in list')....I have around 20 variables that can change the query, so I'm looking for something more pythonic(like list comprehensions with conditions) but for string...

 python                     2 answers                     48 view
 2018-10-22         Louis

Slug field error in django

I am trying to integrate the following Blog app to my site,I get the following error for the slug field ,how to resolve this issue TypeError at /login/ __init__() got an unexpected keyword argument 'prepopulate_from' Request Method: GET Request URL: http://192.168.254.35/accounts/login/new_wind/ Django Version: 1.2.1 SVN-1957 Exception Type: TypeError Exception Value: __init__() got an unexpected keyword argument 'prepopulate_from'This is my models.pyfrom django.db import modelsfrom datetime import datetimeclass BlogPost(models.Model)...

 python                     2 answers                     42 view
 2018-10-22         Louis

ServiceStack OrmLite using Sqlite64 as memory database results in missing auth tables

I am trying to use Sqlite as a memory database with ServiceStack ORMlite in my unit tests. If I run my tests with SQLite saving to a file, ie. using the connectionstring "Data Source=|DataDirectory|unittest.db;Version=3;", it works fine and auth tables are generated fine by ServiceStacks userRepository.CreateMissingTables(); However, when I try using SQLite as a memory database by using this connectionstring":memory:"I get an exception when sayingSQLite errorno such table: UserAuththe first time I try to fetch a user by doing thisuserRepository.GetUserAuthByUserName(...)Thi...

 sqlite                     1 answers                     82 view
 2018-10-22         Louis

In Eclipse, how do I replace a character by a new line?

In Eclipse 3.3.2, I would like to replace a character (say ',') by a new line in a file.What should I write in the "Replace with" box in order to do so ?EDIT : Many answers seems to be for Eclipse 3.4. Is there a solution for Eclipse 3.3.X ? Check box 'Regular Expressions' and use '\R' in the 'Replace with' boxIt's a new feature introduced with Eclipse 3.4, See What's New in 3.4 [XXX]Like the others said, just use regular expression, but instead of just \r, put \r\n [XXX]Check box 'Regular Expressions' and use '\n' in the 'Replace with' box [XXX]I'm using Helios...

 eclipse                     6 answers                     3 view
 2018-10-22         Louis

adding image on a panel

uhhmm. ive been finding ways on adding images(Image object) on a panel. Basically, what i want to do is to create a page - a panel with moving objects (animation using sprites). but i can't. everytime i try to add the images to the panel, the screen goes on like "blinking". anyone can help me with this? I need this ASAP.. thanks in advance. :) Just a wild guess here, but it sounds like the ubiquitous vertical sync problem experienced in any animated graphical endeavour. In some languages you have to engage a 'double buffer' to correct this. Your panel might have such a p...

 java                     1 answers                     44 view
 2018-10-22         Louis

SQL Stored Procedure: Conditional Return

Hi I want to create a simple stored proecudre which does the following:Psudocode@tempSelect = "SELECT * FROM Table"if (@Param is NULL) then exec @tempSelectelse exec @tempSelect + ' WHERE id = ' + @Param + 'Is this method efficent? Thank you. Try select *from tablewhere id=isnull(@param, id) [XXX]Select * from TableWhere (ID = @Param or @Param is null)OrSelect * from TableWhere ID=Coalesce(@Param, ID)[And if you are aiming for efficiency, replace * with the specific field you want to return.] [XXX]Yes - I certainly see nothing wrong with it. You could make it eve...

 sql                     5 answers                     73 view
 2018-10-22         Louis

(403) Forbidden error when using webclient

This question already has an answer here: WebClient 403 Forbidden 9 answers i just added this line and problem solvedwebClient.Headers.Add("User-Agent: Other"); [XXX]

 c#                     1 answers                     82 view
 2018-10-22         Louis

Connect Hazelcast Mancenter to externally Hazelcast server by using jar instead of setting hazelcast server config

I started hazelcast server using java -jar hazelcast-3.10.1/lib/hazelcast-3.10.1.jarwhich started server on Members {size:1, ver:1} [ Member [127.0.0.1]:5701 - f7cf5a82-c89c-4341-8e72-0f446df422ad this]after that I started mancenter as below java -jar hazelcast-management-center-3.10.1/mancenter-3.10.1.war 8080 mancenterthen I tried to connect my spring boot application to mancenter as below @Bean public Config mancenterConfig() { Config cfg = new Config(); cfg.getManagementCenterConfig().setEnabled(true).setUrl("http://localhost:8080/mancenter"); ...

 java                     1 answers                     89 view
 2018-10-22         Louis

Are there multiple LDTs?

The following Wikibooks page states: The GDT contains pointers to each LDT.I'm currently learning about segmentation, and this implies that there are multiple LDTs. As far as I can tell there is only one: multiple references I've read refer to "the LDT", implying there is only one. Is the referenced page correct in its implication? Did it mean "LDT entry"? While the lgdt instruction - used to set up the GDT - takes a m16&32/64 as an operand - the lldt instruction takes a r/m16 operand. Deciphering the jargon this means that lgdt takes a pointer to a structure holdi...

 x86                     2 answers                     74 view
 2018-10-22         Louis

godaddy webhosting root directory

im using go-daddy to learn web hosting ...so i had problem and i reset my account because i thought something change some settings in the server..after i reset the account i still have the same problem that my web root DIR is in (ht-docs owned by root) which i cant edit ...this is the effective root directory .. i dont know why its not (public_html)i ve allready asked in godaddy before about this and figured out my self the root directory by searching html code in all files in my server (grep -isr "html code" /*)https://uk.godaddy.com/community/Managing-Web-Hosting/public-h...

 linux                     1 answers                     85 view
 2018-10-22         Louis

Microsoft Academic Graph API currently accepting new subscribers?

I am attempting to subscribe to the Project Academic Knowledge API at this linkhttps://dev.labs.cognitive.microsoft.com/products/5636d970e597ed0690ac1b3fI'm getting: We're unable to complete your requestMicrosoft account is experiencing technical problems. Please try again later.I'm wondering if this is actually a technical problem or if they have disabled new subscribers to this API. You're getting this message because you're using the wrong portal to subscribe, try subscribing here and then you'll be able to use the keys generated by that portal here [XXX]

 microsoft-cognitive                     1 answers                     102 view
 2018-10-22         Louis

Xamarin Forms IPA generation on Jenkins

I'm having some trouble to generate an IPA for my Xamarin Forms iOS project on Jenkins. I follow the documentation (http://developer.xamarin.com/guides/cross-platform/ci/jenkins_walkthrough/) and post a question on the xamarin forums for my problem, but it's really difficult to have an answer there so i'll try here.I'm able to build the application with mdtool but there isn't any IPA file in my project after the end of Jenkins' job.I see some discussion on the forum that tell to use the archive method instead of the build for mdtool. But that didn't change anything either.I...

 ios                     1 answers                     96 view
 2018-10-22         Louis

Output not shown correctly

I am a beginner in C programming and I have written the following code but it is producing an error at the output. The code is-:#include <stdio.h>#include <conio.h>void main(){ int n=0; int i,k; char name; printf("\t\t Program to find the overtime of 10 workers\n\n"); for(i=0;i<=10;i++){ printf("Enter the name of worker"); scanf("%char",&name); printf("Enter the number of hours worked"); scanf("%d",&n); if(n>10){ k=n-10; printf("He is eligible for overtime for overtime of rs %d\n",k*12); } else{ k=0; p...

 c                     4 answers                     78 view
 2018-10-22         Louis

JavaScript - Accessing a child variable in a parent class

In JavasScript, is it possible to define a variable in a child class, then access it in a parent class? I imagine the child class would look something like this:export default class ChildClass extends ParentClass { constructor() { this.path = 'register'; }}A use-case scenario is an HTTP service class as the parent that contains general, reusable methods and a child class that defines the exact route that will be accessed. Assuming it's possible, how could I then access this.path in the parent class? You don't need to do anything special, it just works.As men...

 javascript                     1 answers                     21 view

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