Search Results

Search found 1863 results on 75 pages for 'matt fordham'.

Page 47/75 | < Previous Page | 43 44 45 46 47 48 49 50 51 52 53 54  | Next Page >

  • Can I compare a template variable to an integer in Django/App Engine templates?

    - by matt b
    Using Django templates in Google App Engine (on Python), is it possible to compare a template variable to an integer in an {% if %} block? views.py: class MyHandler(webapp.RequestHandler): def get(self): foo_list = db.GqlQuery(...) ... template_values['foos'] = foo_list template_values['foo_count'] = len(foo_list) handler.response.out.write(template.render(...)) My template: {% if foo_count == 1 %} There is one foo. {% endif %} This blows up with 'if' statement improperly formatted. What I was attempting to do in my template was build a simple if/elif/else tree to be grammatically correct to be able to state #foo_count == 0: There are no foos. #foo_count == 1: There is one foo. #else: There are {{ foos|length }} foos. Browsing the Django template documents (this link provided in the GAE documentation appears to be for versions of Django far newer than what is supported on GAE), it appears as if I can only actually use boolean operators (if in fact boolean operators are supported in this older version of Django) with strings or other template variables. Is it not possible to compare variables to integers or non-strings with Django templates? I'm sure there is an easy way to workaround this - built up the message string on the Python side rather than within the template - but this seems like such a simple operation you ought to be able to handle in a template. It sounds like I should be switching to a more advanced templating engine, but as I am new to Django (templates or any part of it), I'd just like some confirmation first.

    Read the article

  • xml dom node children

    - by matt
    Need some help I've got lots of code and i want to make it shorter i know there's a way but I can't remember it this is code example: <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="cooking"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book category="children"> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> <book category="web"> <title lang="en">XQuery Kick Start</title> <author>James McGovern</author> <author>Per Bothner</author> <author>Kurt Cagle</author> <author>James Linn</author> <author>Vaidyanathan Nagarajan</author> <year>2003</year> <price>49.99</price> </book> <book category="web" cover="paperback"> <title lang="en">Learning XML</title> <author>Erik T. Ray</author> <year>2003</year> <price>39.95</price> </book> </bookstore As you can see the different nodes, children now is there a way to make this code smaller so I don't have to keep writing the nodes and children

    Read the article

  • Blocks and Yields in Ruby

    - by Matt
    I am trying to understand blocks and yields and how they work in Ruby. How is a yield used and most of the rails applications use yields in a weird way. Can someone explain to me or show me where to go to understand them.

    Read the article

  • Function call within XAML code?

    - by Matt H.
    I'd like to set a style on all my TextBox controls that does the following when it receives keyboard focus: 1) Change the background color 2) Call .SelectAll() to highlight all text I have this so far: <Style TargetType="TextBox"> <Style.Triggers> <Trigger Property="IsKeyboardFocusWithin" Value="True"> <Setter Property="Background"> <Setter.Value> <SolidColorBrush Color="#FFFFD1D9"/> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style> Is there a way to also call .SelectAll() ? Thanks.

    Read the article

  • Access Denied Java FileWriter / FileInputStream

    - by Matt
    My program downloads a websites source code, modifies it, creates the file, and then reuploads it through the FTP. However, I receive the following error when trying to open the created file: java.io.FileNotFoundException: misc.html (Access is denied) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(Unknown Source) at Manipulator.uploadSource(Manipulator.java:63) at Start.addPicture(Start.java:130) at Start$2.actionPerformed(Start.java:83) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) When I navigate to the folder directory and attempt to open "misc.html" with Notepad I receive Access is Denied. My code is fairly simple: File f = new File(page.sourceFileName); try { FileWriter out = new FileWriter(f); out.write(page.source); out.close(); } catch (IOException e) { e.printStackTrace(); } InputStream input = new FileInputStream(f); This is the vital excerpt from my program. I have copied this into a different test program and it works fine, I create a misc.html file and reopen it with both FileInputStream and manually. I would be worried about Administrator rights but the Test program works fine when I run it RIGHT after the problem program. I also have checked if the file exists and is a file with File methods and it is as well. Is this a result of me not closing a previous Input/Output properly? I've tried to check everything and I am fairly positive I close all streams as soon as they finish... Help! :)

    Read the article

  • What causes memory fragmentation in .NET

    - by Matt
    I am using Red Gates ANTS memory profiler to debug a memory leak. It keeps warning me that: Memory Fragmentation may be causing .NET to reserver too much free memory. or Memory Fragmentation is affecting the size of the largest object that can be allocated Because I have OCD, this problem must be resolved. What are some standard coding practices that help avoid memory fragmentation. Can you defragment it through some .NET methods? Would it even help?

    Read the article

  • Web Application Loading Screen

    - by Matt Charlton
    I have a web app that has several tree views. When the page loads i see the unordered lists and after a small latency the styling of the tree is rendered into the DOM. Is there a way to mask the webapp, and have a spinner in the middle of the screen, and when everything on the page is fully rendered the spinner goes away and the mask fades out? Kind of like a semi transparent mask that you would see on a lightbox pop-up dialog.

    Read the article

  • If you delete a DOM element, do any events that started with that element continue to bubble?

    - by Matt
    What behavior should I expect if I delete a DOM element that was used to start an event bubble, or whose child started the event bubble - will it continue to bubble if the element is removed? For example - lets say you have a table, and want to detect click events on the table cells. Another piece of JS has executed an AJAX request that will eventually replace the table, in full, once the request is complete. What happens if I click the table, and immediately after the table gets replaced by a successful completion of an AJAX request? I ask because I am seeing some behavior where the click events don't seem to be bubbling - but it is hard to duplicate. I am watching the event on a parent element of the table (instead of attaching the event to every TD), and it just doesn't seem to reach it sometimes.

    Read the article

  • Nested luabind classes declared in Lua

    - by Matt Fichman
    I am trying to declare a class B in a namespace A using Luabind (from the Lua side). I figure that if Luabind has a clean way to do this, it would look something like this: class 'A.B' (Super) function A.B:__init() Super.__init(self) end Notice that the B class is defined in the A table. I know the following hackish way of doing this: class 'A.B' (Super) A = {} A.B = _G['A.B'] However, I would really like to know if Luabind provides this feature explicitly.

    Read the article

  • How to access static members in a Velocity template?

    - by matt b
    I'm not sure if there is a way to do this in Velocity or not: I have a User POJO which a property named Status, which looks like an enum (but it is not, since I am stuck on Java 1.4), the definition looks something like this: public class User { // default status to User private Status status = Status.USER; public void setStatus(Status status) { this.status = status; } public Status getStatus() { return status; } And Status is a static inner class: public static final class Status { private String statusString; private Status(String statusString) { this.statusString = statusString; } public final static Status USER = new Status("user"); public final static Status ADMIN = new Status("admin"); public final static Status STATUS_X = new Status("blah"); //.equals() and .hashCode() implemented as well } With this pattern, a user status can easily be tested in a conditional such as if(User.Status.ADMIN.equals(user.getStatus())) ... ... without having to reference any constants for the status ID, any magic numbers, etc. However, I can't figure out how to test these conditionals in my Velocity template with VTL. I'd like to just print a simple string based upon the user's status, such as: Welcome <b>${user.name}</b>! <br/> <br/> #if($user.status == com.company.blah.User.Status.USER) You are a regular user #elseif($user.status == com.company.blah.User.Status.ADMIN) You are an administrator #etc... #end But this throws an Exception that looks like org.apache.velocity.exception.ParseErrorException: Encountered "User" at webpages/include/dashboard.inc[line 10, column 21] Was expecting one of: "[" ... From the VTL User Guide, there is no mention of accessing a Java class/static member directly in VTL, it appears that the right hand side (RHS) of a conditional can only be a number literal, string literal, property reference, or method reference. So is there any way that I can access static Java properties/references in a Velocity template? I'm aware that as a workaround, I could embed the status ID or some other identifier as a reference in my controller (this is a web MVC application using Velocity as the View technology), but I strongly do not want to embed any magic numbers or constants in the view layer.

    Read the article

  • Find a name in a list if the name is spelt wrong

    - by Matt
    I've got a list of names which some code checks against to see if the person exists, and if so do some stuff.. My issue is that I want to handle the case of the name being entered incorrectly.. I.e. I have a list of names Bob Frank Tom Tim John If I type in Joohn, I want it to ask me if I meant John. If I type Tm, I get asked if I meant Tim, if I say no, it asks if i meant Tom.. Etc.. Has anyone done something like this before?

    Read the article

  • Frontend Intertag Communication

    - by Matt
    Hey all, I've had a question that I've been wondering for a while. I'm making a templating system for front-ends where tags are interpretted (like Smarty). I was wondering if there is value in having the tags be able to communicate with the HTML document and other "Smartyish" tags. I was hoping that the community would have some thoughts on this situation. Benefits: More power (tags can tell other tags how to look) Better structure (smartyish tags behave and look just like html tags) Tags can manipulate any element on the page Drawbacks: Tags can manipulate any element on the page Tags can interfere with other tags Code time will increase

    Read the article

  • Edit very large xml files

    - by Matt
    I would like to create a text box which loads xml files and let users edit them. However, I cannot use XmlDocument to load since the files can be very large. I am looking for options to stream/load the xml document in chunks so that I do not get out of memory errors -- at the same time, performance is important too. Could you let me know what would be good options?

    Read the article

  • Getting anchor text from a webpage using xpath within YQL

    - by Matt
    SELECT content FROM html WHERE url="http://en.wikipedia.org/wiki/List_of_United_States_National_Parks_by_state" AND xpath="//a/text()" does not work, whereas SELECT * FROM html WHERE url="http://en.wikipedia.org/wiki/List_of_United_States_National_Parks_by_state" AND xpath="//a/text()" does. SELECT content FROM html WHERE url="http://en.wikipedia.org/wiki/List_of_United_States_National_Parks_by_state" AND xpath="//a" also works, it seems YQL has a bug, or am I missing something?

    Read the article

  • Looping through siblings of a specific row/setting up function

    - by Matt
    Trying to work through my javascript book I am referencing to learn the language and got stuck on looping through siblings of a specific row. W3schools and W3 didnt have what i was looking for. Below is a function walk-through... It reads: Create the countRecords() function. The purpose of this function is to count the number of visible rows in the data table after the table headings. The total is then displayed in the table cell with the id "records". Add the follow commands to the function: a. Create a object named headRow that points to the table row with the id "titleRow". Create a variable named rowCount, setting its initial value to 0. b. Create a for loop that uses familial references starting with the first sibling of headRow and moving to the next sibling until there are no siblings left. Within the for loop. test whether the node name of the currentnext sibling until there are no sibilings left. Within the for loop test whether the node name of the current node is equal to "TR". If it is, test wheter the value of its display style is equal to an empty text string. If it is (indicating that it is visible in the document) increate the value of the rowCount variable by 1. c. Change the text of the "records" table cell to the value of the rowCount variable. Don't use innerHTML. Create a text node that contains the value of the rowCount variable and assign it to a variable called txt. Create a variable called record to store the reference to the element "records" table cell. d. Insert an if condition that test whether the "records" cell has any child nodes. If it does, replace the replace the text node of the "record" table cell with the created text node (txt). If it doesn't append the text node to the cell. var headRow; // part a var rowCount = 0; //part b this is where I get lost. I know I need to access the id titleRow but unsure how to set my loop up specifically for this headRow = document.getElementById("titleRow"); for(var i=0; i<headrow.length; i++) { if (something is not equal == "TH") { make code happen here } if (is "TR" == ""){ rowCount = +1; } //part c var txt = document.createTextNode(rowCount); var record = document.getElementsById("records") //part d holding off on this part until I get a,b,c figured out. The HTML supporting snippet: <table id="filters"> <tr><th colspan="2">Filter Product List</th></tr> <tr> <td>Records: </td> <td id="records"></td> </tr> <table id="prodTable"> <tr><th colspan="8">Digital Cameras</th></tr> <tr id="titleRow"> <th>Model</th> <th>Manufacturer</th> <th>Resolution</th> <th>Zoom</th> <th>Media</th> <th>Video</th> <th>Microphone</th> </tr> Thanks for the help!

    Read the article

  • what are the advantages of C# over Python

    - by Matt
    I like Python mostly for the great portability and the ease of coding, but I was wondering, what are some of the advantages that C# has over Python? The reason I ask is that one of my friends runs a private server for an online game (UO), and he offered to make me a dev if I wanted, but the software for the server is all written in C#. I'd love to do this, but I don't really have time to do multiple languages, and I was just after a few more reasons to justify taking C# over Python to myself. I'm doing this all self-taught as a hobby, btw

    Read the article

  • C - circular character buffer w/ pthreads

    - by Matt
    I have a homework assignment where I have to implement a circular buffer and add and remove chars with separate threads: #include <pthread.h> #include <stdio.h> #define QSIZE 10 pthread_cond_t full,/* count == QSIZE */ empty,/* count == 0 */ ready; pthread_mutex_t m, n; /* implements critical section */ unsigned int iBuf, /* tail of circular queue */ oBuf; /* head of circular queue */ int count; /* count characters */ char buf [QSIZE]; /* the circular queue */ void Put(char s[]) {/* add "ch"; wait if full */ pthread_mutex_lock(&m); int size = sizeof(s)/sizeof(char); printf("size: %d", size); int i; for(i = 0; i < size; i++) { while (count >= QSIZE) pthread_cond_wait(&full, &m);/* is there empty slot? */ buf[iBuf] = s[i]; /* store the character */ iBuf = (iBuf+1) % QSIZE; /* increment mod QSIZE */ count++; if (count == 1) pthread_cond_signal(&empty);/* new character available */ } pthread_mutex_unlock(&m); } char Get() {/* remove "ch" from queue; wait if empty */ char ch; pthread_mutex_lock(&m); while (count <= 0) pthread_cond_wait(&empty, &m);/* is a character present? */ ch = buf[oBuf]; /* retrieve from the head of the queue */ oBuf = (oBuf+1) % QSIZE; count--; if (count == QSIZE-1) pthread_cond_signal(&full);/* signal existence of a slot */ pthread_mutex_unlock(&m); return ch; } void * p1(void *arg) { int i; for (i = 0; i < 5; i++) { Put("hella"); } } void * p2(void *arg) { int i; for (i = 0; i < 5; i++) { Put("goodby"); } } int main() { pthread_t t1, t2; void *r1, *r2; oBuf = 0; iBuf = 0; count=0; /* all slots are empty */ pthread_cond_init(&full, NULL); pthread_cond_init(&empty, NULL); pthread_mutex_init(&m, NULL); pthread_create(&t1, NULL, p1, &r1); pthread_create(&t2, NULL, p2, &r2); printf("Main"); char c; int i = 0; while (i < 55) { c = Get(); printf("%c",c); i++; } pthread_join(t1, &r1); pthread_join(t2, &r2); return 0; } I shouldn't have to change the logic much at all, the requirements are pretty specific. I think my problem lies in the Put() method. I think the first thread is going in and blocking the critical section and causing a deadlock. I was thinking I should make a scheduling attribute? Of course I could be wrong. I am pretty new to pthreads and concurrent programming, so I could really use some help spotting my error.

    Read the article

  • ASP.NET MVC - Disable Html Helper control using boolean value from Model

    - by The Matt
    I am outputting a textbox to the page using the Html helpers. I want to add the disabled attribute dynamically based on whether or not a boolean value in my model is true or false. My model has a method that returns a boolean value: <% =Model.IsMyTextboxEnabled() %> I currently render the textbox like follows, but I want to now enabled or disable it: <% =Html.TextBox("MyTextbox", Model.MyValuenew { id = "MyTextbox", @class = "MyClass" })%> If the return value of Model.IsMyTextboxEnabled() == true I want the following to be output: <input class="MyClass" id="MyTextbox" name="MyTextbox" type="text" value="" /> If it == false, I want it to output as: <input class="MyClass" id="MyTextbox" name="MyTextbox" type="text" value="" disabled /> What is the cleanest way to do this?

    Read the article

  • rake db:migrate not executing new migrations

    - by Matt H
    Hi guys. I'm trying to add some columns to an existing table, so I generated a migration that did so. When I run db:migrate the new migration isn't run and the table isn't updated. I've had this problem many times before, and it's getting bloody annoying. Output from rake db:migrate $ rake db:migrate --trace (in /Users/one/app) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate ** Invoke db:schema:dump (first_time) ** Invoke environment ** Execute db:schema:dump

    Read the article

  • Why does this explicit call of a Scala method allow it to be implicitly resolved?

    - by Matt R
    Why does this code fail to compile, but compiles successfully when I uncomment the indicated line? (I'm using Scala 2.8 nightly). It seems that explicitly calling string2Wrapper allows it to be used implicitly from that point on. class A { import Implicits.string2Wrapper def foo() { //string2Wrapper("A") ==> "B" // <-- uncomment } def bar() { "A" ==> "B" "B" ==> "C" "C" ==> "D" } object Implicits { implicit def string2Wrapper(s: String) = new Wrapper(s) class Wrapper(s: String) { def ==>(s2: String) {} } } }

    Read the article

  • NullPointerException using datanucleus-json with S3

    - by Matt
    I'm using datanucleus 3.2.7 from Maven, trying to use the Amazon S3 JPA provider. I can successfully write data into S3, but querying either by using "SELECT u FROM User u" or "SELECT u FROM User u WHERE id = :id" causes a NullPointerException to be thrown. Using the RDBMS provider, everything works perfectly. Is there something I'm doing wrong? Main.java EntityManagerFactory factory = Persistence.createEntityManagerFactory("MyUnit"); EntityManager entityManager = factory.createEntityManager(); Query query = entityManager.createQuery("SELECT u FROM User u", User.class); List<User> users = query.getResultList(); // Null pointer exception here for(User u:users) System.out.println(u); User.java package test; import javax.persistence.*; @Entity @Table(name = "User") public class User { @Id public String id; public String name; public User(String id, String name) { this.id = id; this.name = name; } public String toString() { return id+" : "+name; } } persistence.xml <?xml version="1.0" encoding="UTF-8" ?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0"> <persistence-unit name="MyUnit"> <class>test.User</class> <exclude-unlisted-classes /> <properties> <properties> <property name="datanucleus.ConnectionURL" value="amazons3:http://s3.amazonaws.com/" /> <property name="datanucleus.ConnectionUserName" value="xxxxx" /> <property name="datanucleus.ConnectionPassword" value="xxxxx" /> <property name="datanucleus.cloud.storage.bucket" value="my-bucket" /> </properties> <property name="datanucleus.autoCreateSchema" value="true" /> </properties> </persistence-unit> </persistence> Exception java.lang.NullPointerException at org.datanucleus.NucleusContext.isClassWithIdentityCacheable(NucleusContext.java:1840) at org.datanucleus.ExecutionContextImpl.getObjectFromLevel2Cache(ExecutionContextImpl.java:5287) at org.datanucleus.ExecutionContextImpl.getObjectFromCache(ExecutionContextImpl.java:5191) at org.datanucleus.ExecutionContextImpl.findObject(ExecutionContextImpl.java:3137) at org.datanucleus.store.json.CloudStoragePersistenceHandler.getObjectsOfCandidateType(CloudStoragePersistenceHandler.java:367) at org.datanucleus.store.json.query.JPQLQuery.performExecute(JPQLQuery.java:94) at org.datanucleus.store.query.Query.executeQuery(Query.java:1786) at org.datanucleus.store.query.Query.executeWithMap(Query.java:1690) at org.datanucleus.api.jpa.JPAQuery.getResultList(JPAQuery.java:194) at test.Main.main(Main.java:16)

    Read the article

  • MySQL query pulling from two tables, display in correct fields

    - by Matt Nathanson
    I'm trying to select all fields in two separate tables as long as they're sharing a common ID. //mysql query $result = mysql_query("SELECT * FROM project, links WHERE project.id = links.id and project.id = $clientID") //displaying the link if ($row['url'] != null){ echo "<div class='clientsection' id='links'>Links</div>"; echo "<a class='clientlink' id='link1' href='" . $row['url'] . "'>" . $row['name'] . "</a>"; } else { echo "<a class='clientlink' id='link1' href='" . $row['url'] . "' style='display:none;'>" . $row['name'] . "</a>"; }; As you can see, my tables are "projects", and "links" Each is sharing a common field "id" for reference. It looks as though where both links.id and project.id are equal, it outputs anything, but when there is no links.id associated with a given $clientID the container relative to the $clientID doesn't display at all. Essentially I'm using this to add links dynamically to a specific client in this CMS and if there are no links, I want the container to show up anyway. Hopefully I've expressed myself clearly, any pointers in the right direction are appreciated. Thanks!

    Read the article

  • VBA: Difference in two ways of declaring a new object? (Trying to understand why my solution works)

    - by Matt
    I was creating a new object within a loop, and adding that object to a collection; but when I read back the collection after, it was always filled entirely with the last object I had added. I've come up with two ways around this, but I simply do not understand why my initial implementation was wrong. Original: Dim oItem As Variant Dim sOutput As String Dim i As Integer Dim oCollection As New Collection For i = 0 To 10 Dim oMatch As New clsMatch oMatch.setLineNumber i oCollection.Add oMatch Next For Each oItem In oCollection sOutput = sOutput & "[" & oItem.lineNumber & "]" Next MsgBox sOutput This resulted in every lineNumber being 10; I was obviously not creating new objects, but instead using the same one each time through the loop, despite the declaration being inside of the loop. So, I added Set oMatch = Nothing immediately before the Next line, and this fixed the problem, it was now 0 to 10. So if the old object was explicitly destroyed, then it was willing to create a new one? I would have thought the next iteration through the loop would cause anything declared within the loop do be destroyed due to scope? Curious, I tried another way of declaring a new object: Dim oMatch As clsMatch: Set oMatch = New clsMatch. This, too, results in 0 to 10. Can anyone explain to me why the first implementation was wrong?

    Read the article

< Previous Page | 43 44 45 46 47 48 49 50 51 52 53 54  | Next Page >