2018-10-22         Harriet

How to handle clashing virtual environments in Python

We have an application that uses Python 3.6.1 (and other things like Django, mod_wsgi, Rabbitmq). The manager for the app was originally built on Windows and I've been transferring it to Linux. To get everything running, I moved the app into a virtual environment. The problem I'm having now is that I'm trying to call the various third party apps that we've used before and one of them is set up in its own virtual environment (using Python 2.7). I can't get that app to run from within the new Python 3 environment. When I run the code that calls the 3rd party app, the import f...

 python                     1 answers                     74 view
 2018-10-22         Harriet

Rename Folders matching pattern using foreach loop

I'm building a simple Powershell script that recursively loops though a directory and removes the "My " prefix from specific folders but I can't seem to get this to work.I can list the directories just fine but Rename-Item has no affect.Any help would be grealy appreciated!Clear-Hostpushd$homeDrivesDir = 'E:\test\users'$reportmode = $false foreach($homeFolder in (Get-ChildItem -Recurse $homeDrivesDir | Where {$_.psIsContainer -eq $true} | Where-Object {($_.Name.contains("My Documents") -or $_.Name.contains("My Music") -or $_.Name.contains("My Pictures") -or $...

 powershell                     1 answers                     13 view
 2018-10-22         Harriet

returning 0 if strings are same in c, where is happening in the code?

I found a function which performs the same as strcmp but I was unable to see where the comparison s1 == s2 is happening. I need help. Thanks.int MyStrcmp (const char *s1, const char *s2){ int i; for (i = 0; s1[i] != 0 && s2[i] != 0; i++) { if (s1[i] > s2[i]) return +1; if (s1[i] < s2[i]) return -1; } if (s1[i] != 0) return +1; if (s2[i] != 0) return -1; return 0;} If s1 == s2, it also means that the length of the two strings are equal. Keeping this in mind, going through the for loop, no...

 c                     2 answers                     91 view
 2018-10-22         Harriet

Display Django form inputs on thanks page

I'm attempting to take 4-5 fields from a large django form and display them on the thanks page.I want to disply the values with a good degree of control, as i'll be building an iFrame with parameterd querystrings based on the form inputs.Currently I have:forms.py -----*- encoding: utf-8 -*-from django import formsfrom django.forms import extras, ModelFormfrom django.utils.safestring import mark_safefrom siteapp.compare.models import CompareHOWMUCH_CHOICES = ( ('', '--------------------------'), ('20000', '20,000'), ('30000', '30,000'),... ('2000000', '2,000,000'...

 python                     2 answers                     41 view
 2018-10-22         Harriet

Can I use arbitrary metrics to search KD-Trees?

I just finished implementing a kd-tree for doing fast nearest neighbor searches. I'm interested in playing around with different distance metrics other than the Euclidean distance. My understanding of the kd-tree is that the speedy kd-tree search is not guaranteed to give exact searches if the metric is non-Euclidean, which means that I might need to implement a new data structure and search algorithm if I want to try out new metrics for my search.I have two questions:Does using a kd-tree permanently tie me to the Euclidean distance?If so, what other sorts of algorithms sho...

 algorithm                     2 answers                     92 view
 2018-10-22         Harriet

Define API for Django-Templates?

I think a template is comparable to a method.It does IPO (input-processing-output):it takes some input.it does some processingit outputs something. Most likely HTML.In Python, a method has required and optional arguments (with default values).Is there a way to define (I call it) API for Django-templates?I want some arguments to be required.I want some arguments to have defaults.Use case: The customer can edit templates via a web interface. I want to tell the customer if changes to the template are valid or not.I could render the template see if an error happens, but this do...

 python                     2 answers                     83 view
 2018-10-22         Harriet

Gmail API encoding - how to get rid of 3D and &amp

I am trying to extract the body of GMAIL emails via GMAIL API, using Python well.I am able to extract the messages using the commands below. However, there seems to be an issue with the encoding of the email text (Original email has html in it) - for some reason, every time before each quote 3D appears. Also, within the a href="my_url", I have random equal signs = appearing, and at the end of the link, there is &amp character which is not in the original HTML of the email.Any idea how to fix this? Code I use to extract the email:from __future__ import print_functionfr...

 python                     1 answers                     39 view
 2018-10-22         Harriet

if we have transaction management at database level than why we put the transaction management in our code

I was going through the transaction management provided by Spring , but just for curiosity want to know if we transaction management is provided by Database than why we are using the transnational management provide by JTA, Spring etc. Indeed, you can completely avoid using transactional annotations in your code (and basically you should stick this approach). Because every transaction will be committed on each successful DB call implicitly.But sometimes you have to make several operations (queries) in a single transaction: withdraw money (from account table) and ship go...

 spring                     1 answers                     52 view
 2018-10-22         Harriet

How can i give alternating row background color and alternating column background color to the listview in WPF?

And also i want to color the background of headers.Please help.Thanks You need to set up a style with the AlternationIndex set. This page gives an example(defining the style)<Style x:Key="CustomListViewItemStyle" TargetType="{x:Type ListViewItem}"> <Style.Triggers> <Trigger Property="ItemsControl.AlternationIndex" Value="0"> <Setter Property="Background" Value="#2C2C2C"></Setter> </Trigger> <Trigger Property="ItemsControl.AlternationIndex" Value="1"> <Setter Property="Background" V...

 wpf                     2 answers                     87 view
 2018-10-22         Harriet

Count from a table, but stop counting at a certain number

Is there a way in MySQL to COUNT(*) from a table where if the number is greater than x, it will stop counting there? Basically, I only want to know if the number of records returned from a query is more or less than a particular number. If it's more than that number, I don't really care how many rows there are, if it's less, tell me the count.I've been able to fudge it like this:-- let x be 100SELECT COUNT(*) FROM ( SELECT `id` FROM `myTable` WHERE myCriteria = 1 LIMIT 100) AS temp...but I was wondering if there was some handy built-in way to do this?Thanks for the...

 mysql                     3 answers                     64 view
 2018-10-22         Harriet

Calculating number of trips without using a loop

I am currently working on postgres and below is the question that I have.We have a customer ID and the date when the person visited a property. Based on this I need to calculate the number of trips. Consecutive dates are considered as one trip. Eg: If a person visits on first date the trip no is first, post that he visits consecutively for three days that will counted as trip two. Below is the input ID Date 1 1-Jan 1 2-Jan 1 5-Jan 1 1-Jul 2 1-Jan 2 2-Feb 2 5-Feb 2 6-Feb 2 7-Feb 2 12-Feb Expected output ID Date Trip no 1 1-Jan 1 ...

 sql                     1 answers                     88 view
 2018-10-22         Harriet

XML question in SQL Server

In one of my sql scripts, I need to execute a stored procedure with the following xml string<Collection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Field> <Attributes> <Attribute Name="CODE1" IsRequired="true" Order="1" IsVisible="true"/> <Attribute Name="CODE2" IsRequired="true" Order="2" IsVisible="true"/> </Attributes> <Rows> <Row ProductState="5"> <Items> <Item Name="P...

 sql-server                     1 answers                     15 view
 2018-10-22         Harriet

SQL Convert Nvarchar(255) to DateTime problem

I'm using SQL server 2008.I have 2 Tables: Table 1 and Table 2.Table 1 has 1 column called: OldDate which is nvarchar(255), nullTable 2 has 1 column called: NewDate which is datetime, not null Example data in Table 1:26/07/03NULLNULL23/07/20037/26/2003NULL28/07/03When i try CAST(OldDate as datetime)I get this error: Arithmetic overflow error converting expression to data type datetime.I need to insert OldDate into NewDate with no errors. I can't skip some rows. try usingCONVERT(datetime,OldDate ,103)the "103" tells the converter that the format is dd/mm/yyyyEDIThere is...

 sql                     2 answers                     47 view
 2018-10-22         Harriet

php connection to the local database with wamp

As part of my internship, I try to change the dynamic website of the company. To do this, I installed Wamp and I transferred locally, the website of the company with filezilla I exported three databases in the hebergeur site. I imported these databases give in phpMyadmin.When I try to work locally, I displays errors that I can not interpret (please see the next picture).[a link] https://docs.google.com/file/d/0B6PyFANH4lYqNC1USm9oOEhEMGs/edit?usp=sharingIn (1) is normally a dropdown list that displays the zip code of cities. In local it shows me : (!) Notice: Undefined inde...

 php                     4 answers                     31 view
 2018-10-22         Harriet

Retrieve objects in Oracle

I have a Oracle object called Menu which has a object type as an attribute.menu typeCreate Type Menu as Object( beer REF beertype, price float )beertypeCreate Type beertype as object( name char(20), seller char(20) )table created using menu typeCreate table Sells of Menutable created using beertypeCreate table beer of beertypeNow what I want to do is I want to write a select query which retrieves the name of the beer which has price more than 3.5.I triedSELECT beer.name FROM Sells; andSELECT Sells.beer.name FROM Sells; Here's an example: test case first:SQL> crea...

 oracle                     1 answers                     49 view
 2018-10-22         Harriet

ANSI C: Declare a pointer of type "array of string"

I have a structure like thisstruct { int id; char str00[10]; char str01[10]; char str03[10]; char str04[10]; ...} myStructure;All strXX have the same size. I would like to access them via an array (strArray), like this :strcpy(strArray[i], strValue);How to declare strArray ?I used this:char (*strArray)[][10] = (void *)&myStructure.str00;It's working, but I have to code the strcpy like thisstrcpy((*strArray)[i], strValue);... and I don't like this :-)Is there another way to declare strArray ?Thanks for your ideas and help. You almost had it, the c...

 c                     2 answers                     43 view

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