2018-10-22         Maggie

How to define a custom name for delegate method in Rails 5?

I have a model with a delegate method,class Card < ApplicationRecord has_one :meta_sm2 delegate :next_repetition, to: :meta_sm2endBecause the underlying model (currently is meta_sm2) might change in the future, so I would like to make the delegate method next_repetition to a custom name, like priority for example.How can I defined a custom name delegate method, so that I can call the next_repetition like card.priority? You can use alias_method to achieve this.class Card < ApplicationRecord has_one :meta_sm2 delegate :next_repetition, to: :me...

 ruby-on-rails                     1 answers                     63 view
 2018-10-22         Maggie

How to create a new window and set UseShellExecute false in powershell?

The requirement is a bit strange, I've encountered a strange stuck problem in multi-thread in powershell. So I want to create a new window and don't use shell Execute. But I cannot make it with below code, the window doesn't show up.$approot is desktop, in start.bat, just do "dir /s .\"I want the dir result shows in another window instead of the window execute this script, and I don't want use shell execute.$startInfo = New-Object system.Diagnostics.ProcessStartInfo$startInfo.UseShellExecute = $false$startinfo.FileName = $env:ComSpec$startInfo.CreateNoWindow = $false$startI...

 .net                     1 answers                     61 view
 2018-10-22         Maggie

Adding Tags to an extension/module

im trying to get the product tags to show on the featured module, and in fact, anywhere on the site! I've managed to get the tags to work, but for some reason, its only showing 1 tag on all products (the same tag) rather than using individual tags per item. Each product i have has its own tag, only, the same tag is showing where i have entered this!I have this in my featured.php controller : $data['tags'] = array(); if ($product_info['tag']) { $tags = explode(',', $product_info['tag']); foreach ($tags as $tag) { $d...

 opencart                     1 answers                     28 view
 2018-10-22         Maggie

How can join two django querysets in one?

I need order a Queryset by date in desc order, but i need put in the end the objects at the end, I do this:qs1 = Model.objects.exclude(date=None).order_by('-date')qs2 = Model.objects.filter(date=None).order_by('-date')and my list is:l = list(qs1)+list(qs2)There is a more efficiently way for this? Model.objects.extra(select={'nodate':'ISNULL(date)'}, order_by=['nodate', '-date']) [XXX]So, you're looking for all the objects that have a date ... and all the objects that don't have a date?Wouldn't this work better:Model.objects.order_by('-date)Anyway, here's a good place ...

 django                     2 answers                     89 view
 2018-10-22         Maggie

Combining multiple GET endpoints into a single resource

I'm using flask restful to create an API and I want to refactor my code. I have something as shown below:class Makequestions(Resource): def get(self): #somecodeclass Managequestions(Resource): def get(self, user_id): #somecodeAPI.add_resource(MakeQuestions, '/MakeQuestions')API.add_resource(ManageQuestions, '/ManageQuestions/<int:user_id>')I need to combine these two into a single resource with multiple endpoints say forexample:class Makequestions(Resource): def get(self): #somecode def get(self, user_id): #somecodemaybe with a final url along ...

 python                     2 answers                     36 view
 2018-10-22         Maggie

Bootstrap columns aren't displayed next to each other

I'm using Bootstrap 4 and having some problem with the Footer part, I want to create three columns with the same width, using class col-md-6 as described in the documentation, this is my code:<footer class="footer"> <div class="container-fluid"> <div class="row"> <div class="col-md-6"> <p>2018 © Hello World!</p> </div> <div class="col-md-6"> <div class="text-md-right footer-links d-none d-md-block"> <a href="javascript: void(0);">About</a> <a href="javasc...

 html                     4 answers                     29 view
 2018-10-22         Maggie

copying pixels from camera input

I want to get the pixels of the image from the camera.I am using CoreFoundation and OpenGL and I can render the image but I want to do some other other things (in other place/thread) so I need to copy them.This is what I have tried:(part of AVCaptureVideoDataOutputSampleBufferDelegate method)CVImageBufferRef tmpPixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);CVPixelBufferLockBaseAddress( tmpPixelBuffer, 0 );//APPROACH ACFRetain(tmpPixelBuffer);if(pixelBuffer!= 0) CFRelease(pixelBuffer);pixelBuffer = tmpPixelBuffer;//create and bind textureHandle if(m_textureHandle=...

 iphone                     1 answers                     77 view
 2018-10-22         Maggie

Difference between Properties dictionary and Variables dictionary in NLog

With NLog I can add a property with:eventInfo = new LogEventInfo();eventInfo.Properties.Add(name, value);and a variable with:loggerInstance = LogManager.GetLogger(typeName);loggerInstance?.Factory.Configuration.Variables.Add(name, value);and then I ask myself: what is the difference? Have looked around but have not found a clear explanation just warnings that gdc, mdc, and mdlc are obsolete. Which one these should I use for what purpose - I may need both (or neither.) what is the differenceeventInfo.Properties: the context on the scope of one logEvent. You can render t...

 c#                     1 answers                     96 view
 2018-10-22         Maggie

throw exception when files doesn't exist in GCS using apache beam sdk 2.2

In version 2.1 of apache beam, when a dataflow does not find the files in GCS of google cloud platform, it throws a FileNotFound exception and stops the execution.since version 2.2 even if the dataflow does not find the files, it continues the execution.is there a simple way to stop the dataflow when the files do not exist in GCS even using version 2.2 of apache beam ? problem is resolved in version 2.6 of apache beam. now if DataFlow doesn't find file it throw exception. [XXX]

 google-cloud-platform                     1 answers                     10 view
 2018-10-22         Maggie

Close SQL connection Java Webservice

I am programming a WebService in Java that create and call this class : public class Manager{ private Connection aConnection; public CacheManager(){ //We get a connection aConnection = java.sql.DriverManager.getConnection("jdbc:mysql://localhost/mydb?user=root&password="; }// Insert a datalist into a table public void insertIntoDB(List listData, String tableName, StringData previousData) { // Some code using database }The main problem is that the connection is not closed right after the call of the web...

 java                     2 answers                     41 view
 2018-10-22         Maggie

Getting MIN Price in Subquery in SQL Server (using DISTINCT)?

I am trying to get a Minimun price from a car in a table i have.. I am using DISTINCTSELECT DISTINCT datepart(year,[Registration]) AS YearRegistered,MIN(SalePrice), Model, MakeFROM [VehicleSales] But its not working, for example without distinct returns many car makes and models so i use distinct so i get unique cars that are the same make and model and year....I wish to incorporate a "Startign from price ..." hence the SalePrice can also be different for same model and make ... so i want to do a MIN.. But i am bit confused, the above is working working...Any ideas? Yo...

 sql                     2 answers                     67 view
 2018-10-22         Maggie

Using cfcontent in ColdFusion 7, how do I output an MS Word doc in landscape mode?

The title is pretty self explanatory. I'm using cfcontent in ColdFusion 7 to output a page as an application/msword file type and I want to know how to make it default to landscape mode without resorting to downloading a third party library. If the content is just html, you could use the mso/xml schemas. There is a bit more to it than this, but the "mso-page-orientation" property should do the trick. <html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"> ... <style>...

 coldfusion                     2 answers                     81 view
 2018-10-22         Maggie

How do i resolve this ambiguous Azure error?

I am using run commands to execute bash scripts via the Azure CLI bash scripts in RHEL 7 VM.I am getting an error when there is a snippet of the run command: az vm run-command invoke --name ${THIS_VM_NAME} \ --command-id RunShellScript \ --resource-group ${RSC_GRP_NAME} \ --query "output[].message | join('\n\n', @)" \ --scripts "cat > /etc/init.d/parity <<'EOF'${INIT_D_PARITY}exit 0EOFchmod +x /etc/init.d/parityservice parity restartsleep 5ls -la /var/log/parity.errls -la /var/log/parity.logls -la /var/log/parity.node.l...

 bash                     1 answers                     93 view
 2018-10-22         Maggie

How to get Current Transaction Id in SQL Azure

In Non-Azure, I can get the current transaction details by using following query but the support to this view is removed from SQL Azure and I did not find anything similar which can tell me current transaction Id. select * from sys.dm_tran_current_transaction I had the exact same issue and I was able to solve it using the following SQL statement in my triggerselect @TransactionId = transaction_Id from sys.dm_tran_session_transactions where session_id = @@spidThis seems to give me what I was looking for and I hope it will help you. [XXX]Is this not a more correct way o...

 transactions                     2 answers                     100 view
 2018-10-22         Maggie

How to Make my Image Stretch All the Way?

I'm styling the home page of my website; I want the image (see photo below) to stretch all the way below the header. Is there any way I can do that?Here's my index.pug file code:extends _component/layout/layoutblock super-config - var active = '/'block awesome-content .img img(src="/asset/image/pink-computer.jpg") img{ width: 100%; height: 100%; }You can use this code absolutely, but the content you place after this div will appear below the imageThere is also another method, you can call it as background-image img{ backgroun...

 html                     4 answers                     84 view
 2018-10-22         Maggie

Understanding constraint in scipy's optimize

I am trying to understand constraints in the scipy optimize function. I want to minimize the function under the assumption, that input values would always be positive. So I have my constraint function defined as follows:def apply_constraint(inputs): return inputs[0] - inputs[0]What would happen if all my inputs are negative? I tried with negative inputs but could not understand the result. What is the constraint attribute really meant for? It also gives results with negative values.Here is my complete code.from __future__ import divisionimport numpy as npfrom scipy.optim...

 python                     1 answers                     24 view

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