w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
python 2D matrix simple logic works but matrix print logic doesnt show correct matrix
You can use zip here: >>> lis = [['a','b','c'],['d','e','f']] >>> [ x[::-1] for x in zip(*lis) ] [('d', 'a'), ('e', 'b'), ('f', 'c')] #or >>> [ list(reversed(x)) for x in zip(*lis)] [['d', 'a'], ['e', 'b'], ['f', 'c']]

Categories : Python

print out django request.META in a template
Well, the right way to inspect the request.META objects would be using pdb in the view, or using tools like django-debugtoolbar. In my opinion, django debug toolbar is an extremely handy tools for debugging purposes. Regardless, Your issue is, REQ_META is a dictionary, and the way to parse the elements of the dictionary is: {% for k, v in REQ_META %} {{ k }} = {{ v }} <br /> {% endfor %} Documentation here

Categories : Django

Django 1.5 - url template tag and reverse function not generating correct url based on current_app instance
I've come up with a successful work around for anyone interested. For the blog_new view function that I listed in the opening question, the desired preview_url can be acquired by doing the following: def blog_new(request, *args, **kwargs): ... r = resolve(request.path) context = { ... 'current_namespace': r.namespace, 'preview_url': reverse(r.namespace + ':new_preview') ... } return render(request, template_name, context, current_app=r.namespace) Notice the change in the call to reverse(). This time I constructed the viewname parameter to use the current namespace rather than a default one. The same goes for using the url template tag. In the following I use the "with" tag to construct the viewname based on the current_namespace cont

Categories : Django

Search the correct data with the correct date and print it in excel vba
you could filter it by the date column using Autofilter then copy those records to your destination sheet. maybe like this: Dim xSheet1 As Worksheet Dim xSheet2 As Worksheet Dim iLastRow As Integer Set xSheet1 = Sheets("sheet1") Set xSheet2 = Sheets("Sheet2") iLastRow = xSheet1.Range("A" & xSheet1.Rows.Count).End(xlUp).Row xSheet2.Cells.Clear Range("F1").Value = "check" Range("F2:F" & iLastRow).Formula = "=IF(AND(B:B=""Nike"",TEXT(D:D,""DD/MM/YYYY"")=""23/05/2013""),1,0)" Range("F1").AutoFilter Field:=1, Criteria1:="1" Range("A2:D" & iLastRow).Copy xSheet2.Range("A2").PasteSpecial Paste:=xlPasteAll, SkipBlanks:=True With xSheet1 .Range("F1").AutoFilter .Range("F1:F" & Range("A1").End(xlDown).Row).Clear End With

Categories : Excel

Template Django application extending template django project
django-admin.py collectstatic Read docs Files are searched by using the enabled finders. The default is to look in all locations defined in STATICFILES_DIRS and in the 'static' directory of apps specified by the INSTALLED_APPS setting.

Categories : Django

How to print product labels from PHP
Thanks @Orangepill I followed your advice and now have it working. Sorry for the late reply Since @Orangepill provided a comment , i am putting the answer to mark the question as solved. What i did in short was converted the code to pdf. set page size of pdf to label size and it printed correctly on a label printer.

Categories : PHP

Labels with correct indices and values
It isn't entirely clear what you want to do. But most likely you will need to use ?expression and ?substitute to get this done. This should get you started: plot(1:4) value<-c(10,20) index<-c("a","b") lab <- rep(expression(paste("n"[index], "=", value, sep="")),2) for (i in 1:length(lab)) { lab[i] <- eval(substitute(substitute(expr, list(value=value[i], index=index[i])), list(expr= as.call(lab[i])))) } axis(3,at=c(2,3),labels=lab)

Categories : R

Print factor analysis from factanal() with item labels
The issue is that miniset is a cast_df and factanal calls as.matrix(x). The as.matrix.cast_df method uses rrownames and rcolnames (all reshape functions) to extract "special dimension names". For miniset these are NULL (hence the rownames are lost). Without knowing how you constructed miniset I can't help further here. (You must have used reshape to construct miniset at some point as you have created a cast_df object. Good news is that factanal(as.data.frame(miniset)) Works as you wish

Categories : R

django.template.loaders.app_directories.Loader fails to find the template file
Add them to your settings file. import os PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) TEMPLATE_DIRS = ( os.path.join(PROJECT_ROOT, "/apps/myapp/templates/"), )

Categories : Django

Django: Is there a way to display a variable in a Django template like foo.inspect in Rails?
There is a similar thread that has a number of good suggestions. If {% debug %} is unappealing, then it might be easier to inspect the variables in the view prior to the template rendering the page with the variables in question.

Categories : Django

Why aren't labels appearing in my Django ModelForm?
You have to put the field label inside a <label> tag. So: <div> <label for="id_{{field.html_name}}">{{field.label}}:</label> {{ field }} </div>

Categories : Django

Django how to modify checkbox labels for MultipleChoiceField?
You can use Widget.attrs, specifically: questions = forms.MultipleChoiceField( required=False, label='', widget=forms.CheckboxSelectMultiple(attrs={'class': 'my-class'}), choices=CHOICES, ) This would apply my-class to the radio select. If you still need to add class to the label as rendered, you'll need to customize forms.RadioSelect.

Categories : Python

getting template syntax error in django template
Since your artwork_url is a list, the reasonable way would be to access it like this: artwork_url.forloop.counter but it won't work. The Django template language isn't that advanced unfortunately. You should access it like this. {% for track in tracks %} <li><div class="genre-image"> <img src="{{ track.artwork_url }}"> </div> {% endfor %} But that requires that the tracks are mutable and require you to change it in the backend. So if you're not able to modify the track you'd have to implement a custom template filter something like this {{ track.artwork_url|myFormatter:'t300' }} A very small and simple formatter: @register.filter(name='myDate') def myFormatter(value, arg): if arg == 't300': arg = 't300x300' return str(value).replace("lar

Categories : Python

Django: edit template inside another template
If you want your user to be able to edit the template, then you should store the template in the database. There are some packages that do this for you, but it's easy enough to do by yourself # in models.py class EmailTemplate(models.Model): name = models.CharField(max_length=50) template = models.TextField() Then when you need to send an email, you can render it like so: # in views.py from django.template import Template, Context #in your view email_template = get_object_or_404(EmailTemplate, id = template_id) #You should know how to get this somewhere template = Template(email_template.template) email_body = template.render(Context({'my_context':'my_context'}))

Categories : Django

A bug of using for loop to print out matrix in my program
The problem is in the way you get result from findmatrixsize and normalmultiplication functions: they keep the result of calculation in stack and return a pointer to it, but the stack is destroyed soon after these functions finish their work. Reimplement these functions so that the place in memory is valid outside of these functions. For example, int p1[2]; findmatrixsize("inputmatrix.txt","A", p1) and put the result inside of findmatrixsize into the last argument, eg. void findmatrixsize(const char* fileName, const char* matrixName, int* result) { // routine result[0] = someValue1; result[1] = someValue2; }

Categories : C++

How to print a row wise sorted matrix in C++
This code might help! unsigned char arr[columnsize][rowsize]; unsigned char out[columnsize*rowsize]; for(unsigned int i=0; i<columnsize*rowsize; i++){ char buffer=1; bool brk=false; for(unsigned int y=0; y<rowsize; y++){ for(unsigned int x=0; x<columnsize; x++){ if(arr[x][y] <= buffer){ buffer = arr[x][y]; arr[x][y] = 0; brk = true; } if(brk) break; } if(brk) break; } out[i] = buffer; }

Categories : C++

How to print a sorted column from matrix in C
Look at the third "for" loop in your main(). for(int i=0;i<fil;i++){ for(int j=0;j<col;j++){ if(j==a){ aux[j]=matrix[0][j]; //Should be aux[i]=matrix[i][j] here, or you're actually putting everything in aux[a], since j==a. } bubble(aux); } } Also, you should define aux as aux[fil]. Since fil==col, it's ok here. But aux is intended to be used to store a column instead of a row, so if your fil isn't eqaul to col, there would be problems. You can write it like this: int aux[fil]; for(int i=0;i<fil;i++) aux[i]=matrix[i][a]; bubble(aux);

Categories : C

How to post to a view in django from a django template?
In the template unsub.html rendering the form with the button, you should pass the url of your view using the reverse method from django.code.urlresolvers import reverse def unsub_view(request, viewid): if request.method == 'POST': if user_is_subscribed: #Unsubscribe the user. submit_url = reverse('unsub_view', viewid) return direct_to_template(request, '/app/unsub.html', {'user': user, 'submit_url'}) else: #Show error meessage. in your template you can then render the form like follows : ... <form method='post' action='{{ submit_url }}'> {% csrf_token %} <input type="hidden" value="{{ user_id }}" name="user_id" /> <input type="submit" value="unsu

Categories : Python

Correct way to use a matrix to zoom an imageview around a focal point
After much pain, I have discovered the solution. Here is the code: @Override public boolean onScale(ScaleGestureDetector detector) { scaleFactor *= detector.getScaleFactor(); scaleFactor = Math.max(ZOOM_4, Math.min(scaleFactor, ZOOM_LEVEL_0)); float xDiff = initialFocalPoints[0] - currentFocalPoints[0]; float yDiff = initialFocalPoints[1] - currentFocalPoints[1]; transformMatrix.setScale(scaleFactor, scaleFactor, currentFocalPoints[0], currentFocalPoints[1]); transformMatrix.postTranslate(xDiff, yDiff); child.setImageMatrix(transformMatrix); return true; } @Override public boolean onScaleBegin(ScaleGestureDetector detector){ float startX = detector.getFocusX() + getScrollX(); float startY = detector.getFoc

Categories : Android

Creating custom error message labels in html with Django framework
In your form you can define custom error messages. https://docs.djangoproject.com/en/dev/ref/forms/fields/#error-messages Something along the lines of: class MyForm(ModelForm): my_field=forms.CharField(... error_messages={'required': 'My Field',}) EDIT: Try the following: {% for field in form%} {% for error in field.errors %} <li>{{ error }}</li> {% endfor %} {% endfor %}

Categories : Python

how to print for loop results in a upper triangular matrix in R
upper.tri is probably what you're looking for: #Generating a reproducible 7x7 matrix: set.seed(1) m <- matrix(rexp(49, rate=.1), ncol=7) diag(m) <- rep(0, ncol(m)) #The calculation you're looking for: m[upper.tri(m, diag = FALSE)]

Categories : Arrays

print values of CV_8UC4 matrix type in OpenCV
Access your CV_8UC4 matrix properly: image.at<cv::Vec4b>(j,i)[0]; image.at<cv::Vec4b>(j,i)[1]; image.at<cv::Vec4b>(j,i)[2]; image.at<cv::Vec4b>(j,i)[3];

Categories : C

How to print a char matrix in Java so that the columns are alligned?
This should work: javax.swing.UIManager.put("OptionPane.font", new Font("Courier", Font.PLAIN, 16)); final StringBuilder wordSearch = new StringBuilder(); for (int i = 0; i < 20; i++){ for (int j = 0; j < 20; j++){ wordSearch.append(matrix[i][j]).append(' '); } wordSearch.append(' '); } JOptionPane.showMessageDialog(null, wordSearch.toString()); (not tested)

Categories : Java

Nearly Correct Matrix Decomposition Code Fails in Negative Case
This if (Math.Abs(decomposedMatrix.GetElement(rowIndex,columnIndex)) > maxOfColumn) { maxOfColumn = decomposedMatrix.GetElement(rowIndex, columnIndex); should be: if (Math.Abs(decomposedMatrix.GetElement(rowIndex,columnIndex)) > maxOfColumn) { maxOfColumn = Math.Abs(decomposedMatrix.GetElement(rowIndex, columnIndex));

Categories : C#

Working with neuralnet in R for the first time: get "requires numeric/complex matrix/vector arguments" but don't know how to correct
Before blindly giving the data to the computer, it is a good idea to look at it: d <- read.csv("train.csv") str(d) # 'data.frame': 891 obs. of 12 variables: # $ PassengerId: int 1 2 3 4 5 6 7 8 9 10 ... # $ Survived : int 0 1 1 1 0 0 0 0 1 1 ... # $ Pclass : int 3 1 3 1 3 3 1 3 3 2 ... # $ Name : Factor w/ 891 levels "Abbing, Mr. Anthony",..: 109 191 358 277 16 559 520 629 417 581 ... # $ Sex : Factor w/ 2 levels "female","male": 2 1 1 1 2 2 2 2 1 1 ... # $ Age : num 22 38 26 35 35 NA 54 2 27 14 ... # $ SibSp : int 1 1 0 1 0 0 0 3 0 1 ... # $ Parch : int 0 0 0 0 0 0 0 1 2 0 ... # $ Ticket : Factor w/ 681 levels "110152","110413",..: 524 597 670 50 473 276 86 396 345 133 ... # $ Fare : num 7.25 71.28 7.92 53.1 8.05 ... # $

Categories : R

Print using c++ variadic template
You end up get something similar to: a.append(pass("7.5"), pass("4"), pass("11.5")) which appends an "End" to a. First of all, obviously, cout won't accept your "array" here, even you actually give it an array. And you need output the parameters one by one. So you have to extract every single one by recursion.

Categories : C++

Print data from text box on same page into hidden field in correct format
EDITED As you have jquery available o the page this makes things much simpler <script> function changeDate() { var $ = jQuery; //for some reason $ is not already defined as jQuery var date = $('select#edit-panes-webform-nid5-0-date-month').val() + '-' + $('select#edit-panes-webform-nid5-0-date-day').val() + '-' + $('select#edit-panes-webform-nid5-0-date-year').val(); $('input#edit-panes-billing-address-billing-ucxf-date-of-game').val(date); } </script> I have tried this on your page and it works when using the select boxes but not from the popup calander without editing the jquery date picker and it depends on what the licence allows you to do with that this is assuming that your hidden date box is a div or span not an input, if it is

Categories : PHP

Print page from HTML template
I am not quite sure how your HTML works, but a simpler way of doing this would be to add a separate media to your CSS. Then you would only need your original page, no need for opening a pop-up and moving data around: @media print { /*Put the way you want to format your page on printing here*/ } See the W3C reference here.

Categories : Javascript

Marionette.js template not print completly
Wrap everything inside the script template with DIV Tag... that will solve your problem <script id = "my-template" type = "text/template"> <div> <div>test</div> <%=console.log( "ENFIN")%> </div> </script>

Categories : Javascript

Spring Matrix Variables require at least one template variable to work?
According to Spring documentation If a URL is expected to contain matrix variables, the request mapping pattern must represent them with a URI template. This ensures the request can be matched correctly regardless of whether matrix variables are present or not and in what order they are provided. In your first example you use no templates (like {articles}) in URL mapping, so Spring is unable to detect matrix parameters. I'd rather call it not a bug, but an implemnetation side effect. We have it just because @MatrixVariable support is build on the top of the old @PathVariable parsing mechanism.

Categories : Spring

Template is being parsed, data is correct, but no elements are added to DOM
One problem I can think of could be that your services.index route needs some content, so when doing this.transitionToRoute('services.index'); without passing along the model/content the transition would succeed but no content is displayed. So continuing guessing you need to pass along also some content/model to be used, like this.transitionToRoute('services.index', this.get('content')); or whatever content your services.index route needs. Hope it helps.

Categories : Ember Js

Print report template after replacing placeholders
I used the OpenXMLSDK and you can simply add the DocumentFormat.OpenXml.dll to your bin directory and don't need to install anything extra. Other than that I'd know of 2 more possibilities to achieve it without OpenXML: you could use Word Interop - you don't really want to do it .docx is simply few compressed xml files, so you could unzip it and handle the files directly. You need to get to know the tags and files a bit, but if the keywords are easy to detect you could also just try it with a find/replace which would be much easier

Categories : C#

How can I print a MongoDB list in a jinja2 template?
You probably need a nested loop in Jinja, try this: {% for change in changes %} {{ change._id }} {% for affect in change.affects %} {{ affect }} {% endfor %} {% endfor %}

Categories : Python

Cannot get Django App to serve correct URL
As I said, django is running index() for both URLs. Given your code, when you go to /testweb, Django matches the second line from testweb/urls.py and then the first line in foo/urls.py. Try /testweb/testweb. You'll see that this runs (lambda x: HttpResponse("testweb!")). That's happening because you're pointing both URLs to include('foo.urls'). Going to /testweb/ matches the second URL in testweb/urls.py, and which includes foo.urls and looks for a match there. Since you've got nothing in your URL after /testweb/, the resolver then hits the first URL in foo.urls, which is for the index lambda. include a different URLConf or just reference the views directly, like: # testweb/urls.py urlpatterns = patterns('', url(r'^$', (lambda x: HttpResponse("index!")), name='index'), url(r

Categories : Python

Correct root url in Django views.py
Just hide your staging/dev logic into settings.py like this: DOMAIN = 'www.mysite.com' # Production DOMAIN if os.environ['ENV'] != 'staging': DOMAIN = 'localhost:8000' # Dev DOMAIN Or add this into the end of your settings.py from settings_local import * And define DOMAIN in your settings_local.py: DOMAIN = 'localhost:8000' And finally in your view: from settings import DOMAIN, STATIC_URL img_url = 'http://{domain}/{static}/img/logo.png'.format( domain=DOMAIN, static=STATIC_URL ) graph.post( path = fb_event_path, source = urllib2.urlopen(img_url) )

Categories : Django

Django correct applications distribution
The individual sets of functionality (such as the ones you listed) should be applications. When you group several applications together, you form a project. However, the individual applications are usually self-contained enough that they could be picked up and dropped into another application. In this manner, you can re-use your 'login' application in several projects.

Categories : Python

I need place values in the correct location on the newly created template sheet
With some changes, you can rewrite your code to make it start filling up values from row 4 and prevent duplicate insertions if it already has the column F value on the template sheet, this way: Sub Redemption() Dim wsDatatable As Worksheet Dim wsTempelate As Worksheet Dim rangeFound As Range Dim rangeNames As Range Dim NameCells As Range Dim stringFirst As String Dim stringNames As String Dim stringUniqueNames As String Set wsDatatable = Sheets("DATA INPUT TABLE") Set wsTempelate = Sheets("CLASS GROUPING ID") Set rangeNames = wsDatatable.Range("A2", wsDatatable.Cells(Rows.Count, "A").End(xlUp)) For Each NameCells In rangeNames.Cells If InStr(1, "|" & stringUniqueNames & "|", "|" & NameCells.Text & "|", vbTextCompare) = 0 Then stringUniqueNames = stringUniqu

Categories : Vba

Getting ostream template to print instance attributes in list of pointers
Firstly, don't use shared_ptr here. Your code doesn't give us any reason to use memory management: std::list<SomeClass> myListofPtrs; Then you need to provide your own implementation of the stream insertion operator for your class: std::ostream& operator <<(std::ostream& os, SomeClass const& obj) { return os << obj.myVal; } If you must use pointers then you can create your own loop: for (auto a : myListOfPtrs) { std::cout << (*a).myVal << " "; }

Categories : C++

Correct path/url for media files in django
User-uploaded files (by admins or site users) go to media directory. Static files are files provided by developers (or from third-party apps). Set something like this: # Local disk paths MEDIA_ROOT = '/Users/username/Projects/django_books/media/' STATIC_ROOT = '/Users/username/Projects/django_books/static/' # URLs visible in the browser's address bar MEDIA_URL = '/media/' STATIC_URL = '/static/' And in Your template use the STATIC_URL variable: <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/beers.css" /> And move your styles to the django_books/static/ directory.

Categories : Python

Using the correct settings constant in Django view
Instead of from myproj import settings do from django.conf import settings That's why DEBUG works: https://docs.djangoproject.com/en/dev/topics/settings/#using-settings-in-python-code

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.