天道酬勤,学无止境

问答

Simultaneous multitasking in Django

I have in my web project a time consuming function. While the function is doing its computations, a web page should be rendered informing the user that the results will be sent by email once the computation is done. If I put the rendering after the function call, the web page wont be rendered until after the time_consuming_function() had finished and that would make the response senseless. views.py: def web_function(request): ... time_consuming_function() return HttpResponse() Is python threading the only way to go? Update Ended up using cellery, since it seemed better documented than ztaskd

2022-01-25 05:37:27   python   django

Trouble Installing Ruby 1.9.3 on Mac OSX 10.9.4

I am fairly amateur when it comes to Terminal and command line therefore I thought I might pose my question here and hopefully one of the many intelligent folks roaming this board would be so kind as to help me understand what I am doing wrong here. I am trying to install 1.9.3 on my Mac for a project on Team Treehouse. I already have 2.0.0 installed. Any help would be great. Thank you. Here is the read out from the log. roberts-imac:~ Jones$ rvm install 1.9.3 Searching for binary rubies, this might take some time. No binary rubies available for: osx/10.9/x86_64/ruby-1.9.3-p547. Continuing

2022-01-25 05:37:17   ruby-on-rails   ruby   macos   terminal

bootstrap 3 navbar-top-fixed issue in android webview

I am working on a webapp which uses the latest bootstrap (3.1.1). I use this carousel sample app to build the main skeleton of the app. In each of the slides I will have my actual page content. In one of the slides I generate tables with a different width. The problem seems to appear only in Android Webview when the width of the table is bigger than the actual width of the device. The navbar gets white or invisible. I am not sure, but I can not see it. I am able to click on the navbar toggle(even though doesn't appear) and it does show the navbar items. Did anybody else had this problem before

2022-01-25 05:37:12   android   css   twitter-bootstrap

Is a configuration of clang QtC 4.7 checks per config file possible?

QtC 4.7 offers the inline CLANG code checks, as shown in the screenshots. I can configure those from options/C++. But I wonder if I can have a config file which I can commit (git) so everyone in the team is using the same checks. Is that possible (e.g. similar to Artistic style where I can use a file or the config in QtC)? The checks I mean: Configure in C++ options, can I do the same in a config file? --- Edit --- I could use the annotations like [[clang::fallthrough]] which silence the warning, but cause other issues like VS2017 "attribute not supported warnings" (we compile on 3 compilers).

2022-01-25 05:37:08   qt   clang   qt-creator

ChromeDriver does not start through CMD with "testng.xml"

I was trying to run a TestNG.xml file from CMD but there are no errors shown and it seems that ChromeDriver is not starting. Note: if i go to Eclipse -> right click on testng.xml -> run as TestNG suite it will work perfectly. Below is the message i get when executing through cmd. The bat file contains: java -cp "D:\Java Applications\WebDriverProject\lib*;D:\Java Applications\WebDriverProject\bin" org.testng.TestNG testng.xml pause The testng.xml contains: The project structure from eclipse is:

2022-01-25 05:36:57   selenium-webdriver   cmd   testng

Private inner module returning private item gives "private type in public interface" error

In the below example, the module outer has a private type Private and a private inner module inner. inner is able to access Private (because child modules can access their parent's private items, even if they are not parked as public). inner defines a function not_really_public_interface(). While it is marked as public, it is really only available to outer because inner itself is not public. outer.rs struct Private; mod inner { use super::Private; pub fn not_really_public_interface() -> Private { Private } } This compiles without any problems. outer should be able to use inner::not_really

2022-01-25 05:36:42   module   interface   rust   private   public

Switching on a string/implementing button actions

Full disclaimer: I'm a CS student, and this question is related to a recently assigned Java program for Object-Oriented Programming. Although we've done some console stuff, this is the first time we've worked with a GUI and Swing or Awt. We were given some code that created a window with some text and a button that rotated through different colors for the text. We were then asked to modify the program to create radio buttons for the colors instead—this was also intended to give us practice researching an API. I've already handed in my assignment and received permission from my instructor to

2022-01-25 05:36:37   java   swing   awt

Querying nested object arrays

I have a category schema and an example data like below : { categories: [], -- array of category object id: String, name: String } { "id" : 1, "name" : "cat1", "categories" : [ { "id:2, "name": "cat2", "categories" : [ { "id":3, "name": "cat3, }] }] } I want to get categories by their name, but I can only reach the first level if say something like categories.findOne({"name": "cat1"}) -- returns cat1 correctly categories.findOne({"name": "cat2"}) -- returns nothing How can I search within subcategories ?

2022-01-25 05:36:28   mongodb   mongoose

Unable to retrieve saved image in flutter (issue reproducible only on iOS)

I'm saving the image using SQflite, when I restart app from scratch I couldn't locate the image file again. Below is the code for your reference. File _storedImage; Future<void> _takePicture() async { final imageFile = await ImagePicker.pickImage( source: ImageSource.gallery, maxWidth: 600, ); if (imageFile == null) { return; } setState(() { _storedImage = imageFile; }); final appDir = await syspaths.getApplicationDocumentsDirectory(); final fileName = path.basename(imageFile.path); final savedImage = await imageFile.copy('${appDir.path}/$fileName'); widget.onSelectImage(savedImage); } Below

2022-01-25 05:36:22   flutter   flutter-dependencies

Attaching a current User object to Django form

I am working on an app that has a section with with a file upload form for .txt fiels. I would like for the current user that is uploading the file to be added along with the file and the file name. Currently, I can do this successfully in the admin section but I just cant get it to save via the form itself. Any Ideas? Here are the models: class UploadedTextFile(models.Model): file = models.FileField(upload_to="textfiles") filename = models.CharField(max_length = 50) username = models.ForeignKey(User, blank=True, null=True) class UploadedTextFileForm(ModelForm): class Meta: model =

2022-01-25 05:36:17   python   django   forms