2018-10-22         Archer

Differentiate Users in Django

I am learning the Django framework.I have two groups of users: manager and employees.At the login page, I want to differentiate between these two groups.If the employee has logged in, then redirect it to the homepage, and if the manager logged in, redirect it to the '/manage' page.How should I do this in Django? Just check the user group in you login view :) [XXX]You need to look at your AccountAdapter... in your ALLAUTH settings in settings.py setACCOUNT_ADAPTER = 'apps.your_app_file.AccountAdapter'Then in the your_app_file.py:from allauth.account.adapter import Defa...

 python                     2 answers                     10 view
 2018-10-22         Archer

I do not understand this code

lines = []while True: s = input() if s: # i don't understand. # What does it have in the program? lines.append(s.upper()) else: breakfor sentence in lines: print(sentence)I want to understand it. Please help me. Thank you so much First of all, you need to add missing indentations (as Colonbracket has mentioned) lines = []while True: s = input() if s: lines.append(s.upper()) else: breakfor sentence in lines: print(sentence)You need to be careful with indentations in Python, since logic of Python program heavily depends on ...

 python                     5 answers                     76 view
 2018-10-22         Archer

Having xticks to display Months in a Seaborn regplot with Pandas

I can not figure how to make the xticks to display Months.For a reproducible example, my data is:import pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsjson = '{"index":{"0":0,"1":1,"2":2,"3":3,"4":4,"5":5,"6":6,"7":7,"8":8,"9":9,"10":10,"11":11,"12":12,"13":13,"14":14,"15":15,"16":16},"Date":{"0":1516147200000,"1":1516752000000,"2":1517788800000,"3":1520208000000,"4":1520985600000,"5":1522281600000,"6":1522886400000,"7":1523404800000,"8":1523491200000,"9":1524096000000,"10":1525305600000,"11":1525737600000,"12":1526428800000,"13":1527811200000,"14":15336864...

 python-3.x                     1 answers                     28 view
 2018-10-22         Archer

dynamically convert timestamp into naive datetime

Is this a valid solution to convert a string time into a naive datetime object in a dynamic manner?By dynamic i mean no matter where the server running this code is located i will always end up with a naive datetime object. I am afraid of missing something herefrom time import timezone as diff_to_utcfrom datetime import datetime, timedeltatime_str = "2018-09-15T15:30:00" # here for example CESTtime_dt_utc = datetime.strptime(time_str, "%Y-%m-%dT%H:%M:%S") + \ timedelta(seconds=diff_to_utc)time_dt_utc>> datetime.datetime(2018, 9, 15, 14, 30)Update to clar...

 python                     1 answers                     19 view
 2018-10-22         Archer

Reverse the order of legend

I use the following code to plot the bar graph. Need to present a legend in reverse order. How can I do it?colorsArr = plt.cm.BuPu(np.linspace(0, 0.5, len(C2)))p = numpy.empty(len(C2), dtype=object)plt.figure(figsize=(11,11))prevBar = 0for index in range(len(C2)): plt.bar(ind, C2[index], width, bottom=prevBar, color=colorsArr[index], label=C0[index]) prevBar = prevBar + C2[index]# positions of the x-axis ticks (center of the bars as bar labels)tick_pos = [i+(width/2) for i in ind]plt.ylabel('Home Category')plt.title('Affinity - Retail Details(Home category...

 python                     4 answers                     48 view
 2018-10-22         Archer

How to make static variable in a structure in C

I want to make a structure in C with one of the structure variable having an initial default valuestruct process{char process_name[2];int burst_time;int completion_time;int turn_around_time;int waiting_time;int priority;int arrival_time= 0;};in the above structure, i want to make arrival_time=0 but i gives me an errorPriority.c:11:19: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘=’ token In C, it's not possible. You can't initialize structure members inside a structure itself. First you need to create an instance or variable of the structure type; only ...

 c                     1 answers                     82 view
 2018-10-22         Archer

How to retrieve value of dynamically added entry control value?

I added controls dynamically and want to retrieve entry control values.Having an issue with retrieving the value. My Code: public void textBox1_TextChanged(object sender, EventArgs e) { RoundedEntry entry = (RoundedEntry)sender; Grid grid = (Grid)entry.Parent; RoundedEntry value0 = (RoundedEntry)grid.Children[2]; string entry0 = value0.Text; Debug.WriteLine(entry0); }Following this code getting only one entry control value. How I should get other value and store it. Loop through all the controls that are RoundedEntry within the Gr...

 c#                     1 answers                     12 view
 2018-10-22         Archer

display each category with their items from table in select option

I've one table products_tbl +----------+-----------+---------------+|product_id|ProductName|ProductCategory|+----------+-----------+---------------+|1 |Apple |fruits ||2 |Orange |fruits ||3 |Iphone X |Electronics ||4 |FJ-Eye Lens|Accessories |+----------+-----------+---------------+i want to display each categories items in separated group using HTML SELECT OPTIONproducts.php$productQ = "SELECT * FROM products_tbl ";try { $stmt2 = $db->prepare($productQ); $stmt2->execute();} catch(PDOException $e...

 php                     2 answers                     2 view
 2018-10-22         Archer

Add attribute to cube and reprocess without original database

Every year we keep a historical copy of one of our cubes. This year someone decided they wanted to pay us money to add an attribute to the cube which did not previously exists. Fine, I like money, but the issue is we don't have a backup of the database that we built this cube off of. So a question arises in my head, do we need that original database to add a new attribute to this cube? Is it possible for us to add a new attribute to the cube and only process this attribute without having the cube orignal datasource? Not having a great understanding of what is happening und...

 sql                     2 answers                     67 view
 2018-10-22         Archer

SQL Server 2008 default select top n row

In the MS SQL Management studio you can select top n row as an action in the table menu.I know how configuring the number of returned rows.I want to now if there is a way to configure to return rows in desc ordering ? If it were possible to determine if there was an identity primary key you could default to using that as the descending order, this would be usefull for showing the most recent items first? But there doesn't seem to be a way to get at the template used to generate the SQL so I think the answer is NO. [XXX]You have to modify the generated query and add ...

 sql-server                     3 answers                     75 view
 2018-10-22         Archer

Using Google's Channel API with Twitters Streaming API

I'm trying to use Google's App Engine with Twitter's streaming API (using twitter4j) to make an application where I can type in a word and it will display the tweets with that word in 'real time' on the page.I already have a lot of Java code to deal with the tweets, and I'm trying to put my code on the App Engine. I'm guessing the best way to do this would be with Google's ChannelAPI. Is that right?I understand that twitter4j creates a thread to handle the tweets that come through, and GAE doesn't support threads like this.Is it possible to have the server push tweets to th...

 twitter                     1 answers                     58 view
 2018-10-22         Archer

Spring-boot error: Consider defining a bean named 'entityManagerFactory' in your configuration

I am running my Spring Boot application but it gives me this error related with the EntityManagerFactory. Should I create my own EntityManager? Isn't it included in spring-boot-starter-data-jpa2018-08-21 12:27:18.993 WARN 2728 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'office365InstanceServiceImpl': Unsatisfied dependency expressed through field 'instanceRepository'; nested e...

 spring-boot                     1 answers                     59 view
 2018-10-22         Archer

Why won't this PHP code feed in to the link TAG href attribute? (local host, not using laravel)

Disclaimer: I haven't got a clue what I'm doing with PHP I'm just playing around with it.I have my css file in a folder named CSS and then my header.php and footer.php in the main site folder. If i include the header.php in other directories I am just using:<?php include('../header.php'); ?>I know this isn't the way to do it however I don't know how to configure it probably (with a config.php file etc..) but my issue is, once the header's included in files in any directory of course it will look for the css/main.css file in that folder so I've tried doing the followin...

 php                     1 answers                     51 view
 2018-10-22         Archer

This query contains transformations that cannot be used in DirectQuery

Invoking the following function in Power Query editor returns the error below:let Origem = (x, y) => x * yin OrigemInvoked Funtion:This query contains transformations that cannot be used in DirectQuery.This is the only query I have in this data model so I have no idea why this message..Can anyone help?Thanks! This is a Power BI bug with the new Composite Model Preview setting.If you turn it off, restart Power BI, then copy and paste the old query into a new one, and delete the old one, it should refresh fine.Reference:DirectQuery errors on imported tables. July ...

 powerbi                     1 answers                     76 view
 2018-10-22         Archer

Creating Excel File From Bash Script output with python

There is output file which created from bash script.output is; xyz|xxx.local|Protocol 2|Root Acces Denied xyz|xxx1.local|Protocol 2|Root Acces DeniedI am trying to create excel file from this which is going to be Column1 Column2 Column3 Column4 xyz xxx.local Protocol 2 Root Acces Denied xyz xxx.local Protocol 2 Root Acces DeniedHow can I do this with pyhton? You can do that pretty very elegantly with pandas Dataframes. Check pandas.read_csv and pandas.DataFrame.to_excel.If you are new to Python and you haven't worked with pandas so far, I rec...

 python                     1 answers                     38 view
 2018-10-22         Archer

Scrape a text that was written by javascript from website

I am using BeautifulSoup to scrape character info from a website. When trying to get the win rate of a character, BeautifulSoup can't find it.When I inspect the text, it is listed as under . All I can find in the sites source code and all that BeautifulSoup finds is "ranking-stats-placeholder".This is the code I am currently using.import bs4from urllib.request import urlopen as uReqfrom bs4 import BeautifulSoup as soupmy_url = "https://u.gg/lol/champions/darius/build/?role=top"#opening up connection, grabbing the pageuClient = uReq(my_url)page_html = uClient.read()uClient....

 javascript                     2 answers                     80 view

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