2018-10-22         Bowen

How to perform a fulltext search in django array field

I have an ArrayField of strings and I want to search if any of the items are containing any of the items within an intended set of strings.I have defined the field like this:class Path(models.Model): path = models.TextField() files = ArrayField(models.CharField(max_length=300)) server_name = models.CharField(max_length=50) def __str__(self): return self.pathAnd I want to check let's say if the files are containing any name that may contain one of these strings ['foo', 'bar', 'baz']. That means if the files is containing the following items:['example', 'ex...

 django                     1 answers                     93 view
 2018-10-22         Bowen

Creating dice simulator in Python, how to find most common roll

import random#Making sure all values are = to 0one = 0two = 0three = 0four = 0five = 0six = 0#Loop for rolling the die 100 timesfor r in range(0, 100): roll = random.randint(1, 6) if roll == 1: one += 1 elif roll == 2: two += 1 elif roll == 3: three += 1 elif roll == 4: four += 1 elif roll == 5: five += 1 elif roll == 6: six += 1#print how many times each number was rolledprint(one)print(two)print(three)print(four)print(five)print(six)#How many times the 3 was rolledprint("The 3 was rolled", three, "times!")#Ave...

 python                     1 answers                     39 view
 2018-10-22         Bowen

Bootstrap 4, thead and tr don't align

I have this page with jquery, bootstrap 4 tableHere is the urlhttp://vault.shopshop.space/When I hit the dropdown to select different days, my jquery will remove tbody and append some new data rows e.g. <tr><td>...</td></tr>Init load (full screen good)After select the filter (not good, thead not aligned) You append the <tbody> element in <thead>.You should empty the <tbody> and then append table rows in <tbody>.<table> <thead> <tr> <th>col 1</th> <th>col 2</th> <...

 jquery                     2 answers                     33 view
 2018-10-22         Bowen

AVAudioRecorder

I have been working on an Audio Application where a user can record and play the recorded audio file. In my app during recording a user can pause the recording and play it to listen what he has recorded and then again he can continue the recording.So now my question is that if a user have recorded a 20 seconds audio and when he plays the audio and wants to resume recording from over 10 seconds overlapping/discarding the next 10 seconds audio. ?I have looked into the AVAudioRecorder documentation and there is not property to set the duration of the recorder to start recordin...

 iphone                     1 answers                     81 view
 2018-10-22         Bowen

What controls logEvent.FormattedMessage?

I'm using a MethodCallTarget to capture log output and display it in a diagnostic window:MethodCallTarget target = new MethodCallTarget("MyTarget", (logEvent, parms) => WriteMessage(logEvent.FormattedMessage));MethodCallTarget does not include a Layout parameter. So how would I have FormattedMessage include the call stack in the case of exceptions?I realize I could make the target method format the message however I like, but I'm trying to understand the relationship between Layout and FormattedMessage and if I can change the default functionality. The easy way ...

 c#                     1 answers                     97 view
 2018-10-22         Bowen

Radiobutton.Checked not working for first button in group

I've got a check for the first radiobutton in my group of ASP.NET radiobuttons. For some reason, the page loads and that first button is automatically checked, not that we're setting it to be checked..it must naturally check itself since it's the first in the group.However, when I actually check that it's checked in an if statement (so that I can act on it) it returns false even though it's checked for sure when the page rendersmyRadioButton.Checked ends up with false. Not sure why. ended up being a logic problem. I was binding after my check logic. [XXX]My dollars...

 asp.net                     2 answers                     28 view
 2018-10-22         Bowen

How to use gapi in react

I want to use gapi to access people api resources from google, I tried many ways to do the job, but I still cannot get any response. It has not error, no warning. Here is my code.loadYoutubeApi() { const script = document.createElement("script"); script.src = "https://apis.google.com/js/client.js"; script.onload = () => { window.gapi.load('client', () => { window.gapi.client.setApiKey(types.API_KEY) window.gapi.client.setClientId(types.CLIENT_ID) window.gapi.client.setDiscoveryDocs(types.DISCOVERY_DOCS) window.gapi.client.setS...

 javascript                     1 answers                     15 view
 2018-10-22         Bowen

How to programmatically create a Java ResultSet from custom data with no database

I have some existing code that accepts a java.sql.ResultSet that contains info retrieved from an Oracle database. I would now like to reuse this code, but I'd like to pass it a ResultSet object that I create myself from some in-memory data that is not affiliated with any database. Is there an existing Java framework class that I can use for this? ResultSet has tons of methods, so implementing my own class for this seemed like overkill, even though I could ignore most of the methods for my specific case.I was thinking of something along the lines of the old Microsoft ADO ...

 java                     6 answers                     44 view
 2018-10-22         Bowen

debug ssis package - reload InnerPackage.dtsx

I used the wizard to build a package that loops through my tables does whatever. It has worked forever and now I have to change it. How on earth do I debug this thing? When I try to run it from bids, it opens InnerPackage.dtsx for editing and then asks me if I want to reload it (since it has changed since the last iteration of the loop). I can't press yes or no fast enough to prevent the package from failing because 'process cannot access the file because it is being used by another process'. How can I keep this from opening so that I can get to the point that it's act...

 sql                     2 answers                     70 view
 2018-10-22         Bowen

What is a minimal example of using Kafka with Python?

What I triedI cloned https://github.com/wurstmeister/kafka-docker and executed sudo docker-compuse up.I started the producer.py listed below.I started the consumer.py listed below.This didn't work. I changed the ports of the docker-compose.yml toversion: '2'services: zookeeper: image: wurstmeister/zookeeper ports: - "2181:2181" kafka: image: wurstmeister/kafka ports: - "9092:9092" environment: KAFKA_ADVERTISED_HOST_NAME: localhost KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 volumes: - /var/run/docker.sock:/var/run/docker.sockAfter st...

 python                     1 answers                     94 view
 2018-10-22         Bowen

How to Share Assembly Between .NET Core and .NET Framework Application

I have Application A that is developed in .NET Core 2.1 and Application B that is developed in .NET Framework 4.7.1. They have a shared library/assembly that is developed using .NET Standard 2.0. This works great, I can compile a single instance of this library and share it between Application A and Application B. But this requires two copies of the assembly in each applications bin folder. If Application A and Application B are deployed on the same machine I would like to update a single instance of the shared assembly in a single location and have both Application A a...

 c#                     1 answers                     84 view
 2018-10-22         Bowen

How to map form data in Symfony to a object only when form is valid?

Imagine example form in Symfony:public function buildForm(FormBuilderInterface $builder){ $builder ->add('email', EmailType::class, [ 'constraints' => new NotBlank(), new IsUnique(), ], ]) ->add('password', PasswordType::class, [ 'constraints' => new NotBlank(), new IsStrongEnough(), ], ])}Now when I submit the form and make sure it's valid, I'd like the $form->getData() to return my DTO called CreateAccountCommand:final cla...

 php                     2 answers                     72 view
 2018-10-22         Bowen

azure blob upload parquet file (a folder of files)

How can I upload a folder recursively to azure blob storage? I would want to upload a parquet file:abcd.parquet├── _SUCCESS├── myPart=20180101│   └── part-00179-660f71d6-ed44-41c7-acf0-008724dd923a.c000.gz.parquet├── myPart=20180102   └── part-00022-660f71d6-ed44-41c7-acf0-008724dd923a.c000.gz.parquetThe following:az storage blob upload -f abcd.parquet -c my_container -n abcdfails with: Is a directoryIt looks like recursive upload is available on windows using AZCopy https://stephanefrechette.com/upload-multiple-files-recursively-azure-blob-storage-azure-cli-2-0-macoslinux/...

 azure                     1 answers                     97 view
 2018-10-22         Bowen

Why cannot I view runtime errors on Application Insights?

I'm working on a Web API 2 project (.NET Full Framework 4.6.1) with Owin and Application Insights 2.7.2 version.I have one controller with a action like following:[HttpGet][AllowAnonymous][Route("Prova")]public void Prova(){ throw new Exception("Questa è l'eccezione.");}When I call this action I cannot view exception in Application Insights:Microsoft declare that, from Application Insights > SDK 2.6, action's not managed runtime exceptions are intercepted automatically (reference).Why I cannot view my runtime exceptions?Thanks As per this doc, for web api:Unhandled ex...

 c#                     1 answers                     4 view
 2018-10-22         Bowen

New issue Chrome opacity 0 not clickable

Hi i have a new issue with chrome , for some reason i want to click on element (iframe) when the opacity is set to 0 ! It was working some days ago but not anymore on Chrome ? But still working good on safari ! Any alternative to hide an element but still click on it ? I found a fix : put opacity:0.0000000001 did the trick ! [XXX]

 html                     1 answers                     83 view
 2018-10-22         Bowen

vectorized interpolation on array with nans

I am trying to interpolate an image cube NDIM=(dim_frequ, dim_spaxel1, dim_spaxel1) along the frequency axis. The aim is to oversample the frequency space. The array may contain nans. It would, of course, be possible to run two for loops over the array but that's definitely too slow. What I want in pseudo code:import numpy as npfrom scipy.interpolate import interp1ddim_frequ, dim_spaxel1, dim_spaxel2 = 2559, 70, 70cube = np.random.rand(dim_frequ, dim_spaxel1, dim_spaxel2)cube.ravel()[np.random.choice(cube.size, 1000, replace=False)] = np.nan wavelength = np.arange(1...

 python                     1 answers                     26 view

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