2018-10-22         Lyndon

Inheriting from variable class in python

I have a class foo that inherits from bar. However I also want to have the option when initializing foo to have it inherit from wall instead of bar. I am thinking something like this:class Foo(): def __init__(self, pclass): self.inherit(pclass) super().__init__()Foo(Bar) # child of BarFoo(Wall) # child of WallIs this possible in Python? It's not really possible easily, because classes are defined at the time of executing the class block, not at the time of creating an instance.A popular design pattern to use instead would be to put the common code into a...

 python                     1 answers                     92 view
 2018-10-22         Lyndon

Django - Designing Model Relationships - Admin interface and Inline

I think my understanding of Django's FK and admin is a bit faulty, so I'd value any input on how to model the below case.Firstly, we have generic Address objects. Then, we have User's, who each have a UserProfile. Through this, Users belong to departments, as well as having addresses.Departments themselves can also have multiple addresses, as well as a head of department. So it might be something like (this is something I'm just hacking up now):class Address(models.Model): street_address = models.CharField(max_length=20) etc...class Department(models.Model): name =...

 database                     2 answers                     63 view
 2018-10-22         Lyndon

How to test for order of superclass in python?

Giving following code:class X(Mixin, Y): passHow can I write a unittest to ensure Mixin class is before Y in superclass declaration of X? Don't test it. Unless you're writing tests for a Python implementation itself. It's not the responsibility of your library's test suite to verify that the Python interpreter is working as designed. Mixin appears before Y in the declaration is self-evident when reading the code, and the fact that Python evaluates initializers left to right in a multiple inheritance is documented here. Note: I'm not saying this behaviour should not be...

 python                     2 answers                     1 view
 2018-10-22         Lyndon

add float number in template (django)

Maybe i'm missing something but i'm looking to add a float number, something like this:{%floatnumber|add:3.4%}Filter add round my result so I don't want to write my filter, but if is the only way, i'll copy add filter Now i'm doing this:def addf(value, arg): """Adds the arg to the value.""" return float(value) + float(arg)addf.is_safe = Falseregister.filter(addf) Right now it turns it into int. There is an open ticket and I even sent a patch, but it haven't been commited yet ;-) Here is the ticket. [XXX]

 django                     1 answers                     97 view
 2018-10-22         Lyndon

Can I block receiving iOS Push Notifications during specified hours (night time) programmatically in Swift

my client wants to have an UISwitch control in Settings view in his app which is: 'Disable Notifications during night time'. He would like pushes that his API will be sending to mobile to be ignored if this option is turned on and it's a night time. Is this possible? I know that I can register and unregister for remote notifications, but this requires an App to be turned on. Is it possible to have it working like he wants? The only way to do this is to have a configuration in the back-end. Notifications are sent from a server, and only handled in the app. There is no way...

 ios                     2 answers                     32 view
 2018-10-22         Lyndon

Firefox window.opener issue

"window.opener" works fine in both IE and Firefox as long as 'Open in New Tab' is used from the right-click menu; Error console says "window.opener" is null. Is there any other way the opener can be accessed?Edit:Error console says "window.opener" is null only when "Open in New Tab" is clicked. For all other cases, there is no such error. Hence, what i would like to know is if an alternate other than "window.opener" exists. window.opener only works if the window (or tab, if it was diverted into a tab) was opened with window.open or via a target attribute or similar. In p...

 javascript                     2 answers                     60 view
 2018-10-22         Lyndon

Simplest way to get initial text input in pygame

So, Iv'e got a pygame application. Right now, it takes a command line argument to specify which display to show the main screen on. However, I'm running it on windows, where it's hard to specify command line input to a graphical application.So, I'd like to have a very very very simple dialog box which pops up, prompts the user for an integer, then closes. My research has shown that pygame can't do a dialog box like this, and I can't get input in a pygame window, because the program doesn't know yet which monitor to draw the pygame window to.So, my question is, what is the s...

 python                     3 answers                     98 view
 2018-10-22         Lyndon

Dynamic queries with BigQuery from R

I want to subset my data based on a list of items I'm looping through, and add the item that is currently indexed to the query I'm sending to BigQuery from R.ex.Item001002003i=2 => item '002'instead of having to manually put 002, I want to be able to construct the following query:sql_string <- "SELECT * FROM MAN WHERE item_code = item[i]"But currently, I have an argument type mismatch. Could someone show me how this is done through the bigrquery package? the paste function did the jobsql_string <- paste("SELECT * FROM MAN WHERE item_code =", item[i] ) [XXX]P...

 r                     2 answers                     77 view
 2018-10-22         Lyndon

VBA select not returning any rows

Below query is not returning any rows into the listbox.There is no error message:lstDiff.RowSource = "select TestScenario,TestId from tblTesting where empid= '" & Me.txtEmpId.Value & "' and testid= '" & Me.txtAutoNumber.Value & "'"Could anyone help? Personally, whenever I use SQL statements in code, I prefer to store the statement in a variable. While testing, on the line after you assign your statement to a variable, you can use Debug.Print to see what your SQL statement looks like after parsing your txtempid and txtautonumber. It would look something li...

 sql                     5 answers                     21 view
 2018-10-22         Lyndon

Which is faster? Multiple DELETE statements or a single DELETE Statement using "IN ('x', ''y')"

Just wondering which is faster:DELETE FROM table_name WHERE X='1'DELETE FROM table_name WHERE X='2'DELETE FROM table_name WHERE X='3'orDELETE FROM table_name WHERE X IN ('1', '2', '3')Any ideas, hints, or references where to read?Thank you all! The single delete will be faster for a few reasons:Only one plan will need to begeneratedOnly one transaction will beinvolved (if you are using them)If you are running these from code,then there is less overhead withODBC calls and network trafficAny indexes will need to berefreshed just once, not many times. [XXX]A single delet...

 sql-server                     7 answers                     40 view
 2018-10-22         Lyndon

Is stateful processing possible with the apache beam python sdk?

I have been following the Timely (and Stateful) Processing with Apache Beam article and though comprehensive and well written it does not specify how to achieve the same with python. More specifically it states: State and timers are not yet supported in Beam's Python SDK.It does not state the reason for this though ... is there an innate reason why this is not possible?I am looking to implement a replay buffer / windowing system for a signal processing system that I am aiming to implement. Whereby a sliding window / historical frame buffer of features of length W is consta...

 python                     1 answers                     47 view
 2018-10-22         Lyndon

Upgrade to NuGet 3.4.4-rtm-final breaks package restore

I recently updated my version of NuGet to 3.4.4-rtm-final usingnuget update -selfNow that I've done this, nuget restore MySolution.sln fails with the following error:Error reading 'c:\...MySolution\MyProject.NetCore.Tests\project.json' at line 15 column 23 : TODO: unknown keyword platform TODO: unknown keyword platformHere's the relevant part of project.json. When I remove the platform specifier, the build fails:"frameworks": { "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { "type": "platform", "version": "1.0.1" } } }},What ...

 .net                     1 answers                     40 view
 2018-10-22         Lyndon

Accessing a Word(.docx) file's content with Microsoft Graph REST API?

Is there a way to obtain the content of a Word document stored in the cloud through the Microsoft Graph API without having to download the file locally? The goal is to build an app that analyzes a Word document's inner content and produce some interesting data from it. However after searching through Microsoft's Dev Center, Graph Explorer, and their API's documentation repository, I can't find any API endpoints that can serve me that data.I can find some endpoints that deal with manipulating Excel's contents, but not one that deals with Word. Does Microsoft Graph not suppor...

 api                     1 answers                     65 view
 2018-10-22         Lyndon

How to add android attributes like android:id on Xamarin Forms(XAML)?

I've already tried setting android attributes like contentdescription by creating a custom element and setting the attribute on the renderer using the control.Control.ContentDescription = ((MyEntry)e.NewElement).ContentDescription;Is there a way to do it on the XAML rather than custom renderer?Another, how can I set the android:id attribute? I've tried it change it on custom render but I think it's not working.Sidenote: I'm using a RealWear device which can generats a script which has the UI elements of the page. The UI elements will contain the id attribute if it exists. ...

 xamarin.forms                     1 answers                     60 view
 2018-10-22         Lyndon

Zookeeper doesn't work with JRE installed on 32 bit Windows

I have installed JRE on a 32-bit Windows machine and trying to run Zookeeper.It shows following error:Error: missing `server' JVM at `C:\Program Files\Java\jre1.8.0_181\bin\server\jvm.dll'.Please install or use the JRE or JDK that contains these missing components.Versions used:KAFAKA/Zookeeper: kafka_2.11-1.1.0JRE: jre1.8.0_181I tried to use server folder from 64-bit machine but obviously it doesn't work.Any help will be appreciated. You need a server JRE, which you can acquire and install from Oracle: http://www.oracle.com/technetwork/java/javase/downloads/server-jre8-...

 java                     1 answers                     42 view
 2018-10-22         Lyndon

Swift 4, iOS how to detect label height after added string value

in UICollectionView my cell's size must be 150+label.height. Now I'm using custom layout to calculate height = 150 if image exists inImageView if not height = 100. It's easy. But how to calculate label.height when i don't know what text i'll fetch from Api? Is there any function to get that?customLayout.swiftlet photoHeight = delegate.collectionView(collectionView, heightForPhotoAtIndexPath: indexPath) > 0 ? 150 : 100let height = cellPadding * 2 + CGFloat(photoHeight) + (labelHeight??????) You can calculate label height using below function extension UILabel { func...

 ios                     1 answers                     82 view

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