Search Results

Search found 483 results on 20 pages for 'dole doug'.

Page 12/20 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Calling PHP functions within HEREDOC strings

    - by Doug Kavendek
    In PHP, the HEREDOC string declarations are really useful for outputting a block of html. You can have it parse in variables just by prefixing them with $, but for more complicated syntax (like $var[2][3]), you have to put your expression inside {} braces. In PHP 5, it is possible to actually make function calls within {} braces inside a HEREDOC string, but you have to go through a bit of work. The function name itself has to be stored in a variable, and you have to call it like it is a dynamically-named function. For example: $fn = 'testfunction'; function testfunction() { return 'ok'; } $string = <<< heredoc plain text and now a function: {$fn()} heredoc; As you can see, this is a bit more messy than just: $string = <<< heredoc plain text and now a function: {testfunction()} heredoc; There are other ways besides the first code example, such as breaking out of the HEREDOC to call the function, or reversing the issue and doing something like: ?> <!-- directly outputting html and only breaking into php for the function --> plain text and now a function: <?PHP print testfunction(); ?> The latter has the disadvantage that the output is directly put into the output stream (unless I'm using output buffering), which might not be what I want. So, the essence of my question is: is there a more elegant way to approach this? Edit based on responses: It certainly does seem like some kind of template engine would make my life much easier, but it would require me basically invert my usual PHP style. Not that that's a bad thing, but it explains my inertia.. I'm up for figuring out ways to make life easier though, so I'm looking into templates now.

    Read the article

  • How to implement menuitems that depend on current selection in WPF MVVM explorer-like application

    - by Doug
    I am new to WPF and MVVM, and I am working on an application utilizing both. The application is similar to windows explorer, so consider an app with a main window with menu (ShellViewModel), a tree control (TreeViewModel), and a list control (ListViewModel). I want to implement menu items such as Edit - Delete, which deletes the currently selected item (which may be in the tree or in the list). I am using Josh Smith's RelayCommand, and binding the menuitem to a DeleteItemCommand in the ShellViewModel is easy. It seems like implementing the DeleteItemCommand, however, requires some fairly tight coupling between the ShellViewModel and the two child view models (TreeViewModel and ListViewModel) to keep track of the focus/selection and direct the action to the proper child for implementation. That seems wrong to me, and makes me think I'm missing something. Writing a focus manager and/or selection manager to do the bookkeeping does not seem too hard, and could be done without coupling the classes together. The windowing system is already keeping track of which view has the focus, and it seems like I'd be duplicating code. What I'm not sure about is how I would route the command from the ShellViewModel down to either the ListViewModel or the TreeViewModel to do the actual work without making a mess of the code. Some day, the application will be extended to include more than two children, and I want the shell to be as ignorant of the children as possible to make that extension as painless as possible. Looking at some sample WPF/MVVM applications (Karl Shifflett's CipherText, Josh Smith's MVVM Demo, etc.), I haven't seen any code that does this (or I didn't understand it). Regardless of whether you think my approach is way off base or I'm just missing a small nuance, please share your thoughts and help me get back on track. Thanks!

    Read the article

  • In Rails, how should I implement a Status field for a Tasks app - integer or enum?

    - by Doug
    For a Rails 3.0 Todo app, I have a Tasks model with a Status field. What's the best way to store the Status field data (field type) and still display a human-readable version in a view (HTML table)? Status can be: 0 = Normal 1 = Active 2 = Completed Right now I have this: Rails Schema Here: create_table "tasks", :force = true do |t| t.integer "status", :limit = 1, :default = 0, :null = false Rails Model Here: class Task < ActiveRecord::Base validates_inclusion_of :status, :in => 0..2, :message => "{{value}} must be 0, 1, or 2" Rails View Here: <h1>Listing tasks</h1> <table> <tr> <th>Status</th> <th>Name</th> <th></th> <th></th> <th></th> </tr> <% @tasks.each do |task| %> <tr> <td><%= task.status %></td> <td><%= task.name %></td> <td><%= link_to 'Show', task %></td> <td><%= link_to 'Edit', edit_task_path(task) %></td> <td><%= link_to 'Delete', task, :confirm => 'Are you sure?', :method => :delete %></td> </tr> <% end %> </table> Requirements Store a Task's status in the db such that the values are easily localizable, i.e. I'm not sure I want to store "normal", "active", "completed" as a string field. Solution must work with Rails 3.0. Questions: Should I store the field as an integer (see above)? If so, how do I display the correct human readable status in an HTML table in my Rails view, e.g. show "Active" instead of "1" in the HTML table. Should I use an enum? If so, is this easy to localize later? Should I use straight strings, e.g. "Normal", "Active", "Completed" Can you provide a quick code sample of the view helper, controller or view code to make this work?

    Read the article

  • git: How to diff changed files versus previous versions after a pull?

    - by doug
    I'm new to git, using it via Terminal on Snow Leopard. When I run "git pull" I often want to know what changed between the last version of a file and the new one. Say I want to know what someone else committed to a particular file. How is that done? I'm assuming it's "git diff" with some parameters for commit x versus commit y but I can't seem to get the syntax. I also find "git log" confusing a bit and am not sure where to get the commit ID of my latest version of the file versus the new one.

    Read the article

  • Background not changing to red

    - by Doug
    http://dougymak.com/jquery/# First time playing with jQuery, and kind of stuck already. I'm expecting the background to change to red on hover, but it's not for some reason. Can anyone give me a hand? Thanks!

    Read the article

  • date() is showing December 1969

    - by Doug
    $sql = "SELECT * FROM news ORDER BY `news_id` DESC LIMIT 1"; $result = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_assoc($result); $date = $row['time_posted']; echo "<i> " .date("Y/m/d", $date) . "</i>: "; I used timestamp in mysql. So, what's the problem?

    Read the article

  • How can I launch a missile?

    - by doug.stanhope
    I am working on an open-source missile launcher application. I have added a big red button to a Form that says "Launch Missile". When I click the button, the event handler gets called. From the event handler I call a method named LaunchMissile(). So far so good, but how do you launch a missile from C# code? Will I have to write this code myself or is there an API or third party library for launching missiles? Please add sample code for various launch scenarios: orbit, moon, mars, etc.

    Read the article

  • FindControl in DataList Edit Mode

    - by Doug
    As a new .net/C# web begginner, I always get tripped up when I try to use FindControl. Blam -flat on my face. Here is my current FindControl problem: I have an .aspx page and Form, then ajax updatePanel, inside it there is my DataList (DataList1) that has an EditItemTemplate: that has the following: <EditItemTemplate> <asp:Label ID="thumbnailUploadLabel" runat="server" text="Upload a new thumbnail image:"/><br /> <asp:FileUpload ID="thumbnailImageUpload" runat="server" /> <asp:Button ID="thunbnailImageUploadButton" runat="server" Text="Upload Now" OnClick="thumbnailUpload"/><br /> </EditItemTemplate> In my C# code behind I have the OnClick code for the fileUpload object: protected void thumbnailUpload(object s, EventArgs e) { if (thumbnailImageUpload.HasFile) { //get name of the file & upload string imageName = thumbnailImageUpload.FileName; thumbnailImageUpload.SaveAs(MapPath("../../images/merch_sm/" + imageName)); //let'em know that it worked (or didn't) thumbnailUploadLabel.Text = "Image " + imageName + "has been uploaded."; } else { thumbnailUploadLabel.Text = "Please choose a thumbnail image to upload."; } So of course I'm getting "Object reference not set to an instance of an object" for the FileUpload and the Label. What is the correct syntax to find these controls, before dealing with them in the OnClick event? The only way Ive used FindControl is something like: label thumbnailUploadLabel = DataList1.FindControl("thumbnailUploadLabel") as Label; But of course this is throwing the "Object reference not set to an instance of an object" error. Any help is very much appreciated. (I've also seen the 'recursive' code out there that is supposed to make using FindControl easier. Ha! I'm so green at C# that I don't even know how to incorporate those into my project.) Thanks to all for taking a look at this.

    Read the article

  • Why do System.IO.Log SequenceNumbers have variable length?

    - by Doug McClean
    I'm trying to use the System.IO.Log features to build a recoverable transaction system. I understand it to be implemented on top of the Common Log File System. The usual ARIES approach to write-ahead logging involves persisting log record sequence numbers in places other than the log (for example, in the header of the database page modified by the logged action). Interestingly, the documentation for CLFS says that such sequence numbers are always 64-bit integers. Confusingly, however, the .Net wrapper around those SequenceNumbers can be constructed from a byte[] but not from a UInt64. It's value can also be read as a byte[], but not as a UInt64. Inspecting the implementation of SequenceNumber.GetBytes() reveals that it can in fact return arrays of either 8 or 16 bytes. This raises a few questions: Why do the .Net sequence numbers differ in size from the CLFS sequence numbers? Why are the .Net sequence numbers variable in length? Why would you need 128 bits to represent such a sequence number? It seems like you would truncate the log well before using up a 64-bit address space (16 exbibytes, or around 10^19 bytes, more if you address longer words)? If log sequence numbers are going to be represented as 128 bit integers, why not provide a way to serialize/deserialize them as pairs of UInt64s instead of rather-pointlessly incurring heap allocations for short-lived new byte[]s every time you need to write/read one? Alternatively, why bother making SequenceNumber a value type at all? It seems an odd tradeoff to double the storage overhead of log sequence numbers just so you can have an untruncated log longer than a million terabytes, so I feel like I'm missing something here, or maybe several things. I'd much appreciate it if someone in the know could set me straight.

    Read the article

  • CSS Extra Small Spacing

    - by Doug
    http://www.dougymak.com/cnit133/hw8.part4.html So if you look at the tabs and look at hw2, you'll notice it has a little extra spacing that overlaps the spacing on the right. That's because wrapped the div in the <li>. You will notice the others not having it. I don't understand why is it making that extra little spacing after I wrap it. Just for the record, this is for CSS spacing which has nothing to do with the JS.

    Read the article

  • What are some models that you know of for PHP OOP?

    - by Doug
    I recently learned a lot about MVC model which is a very interesting concept. I would assume there are a lot more models out there, and I thought it would be great for people to share some models. Here's my contribution: MVC Model: http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller

    Read the article

  • Computer science advances in the past 5 years

    - by Doug Stanhope
    I don't have a computer science background and only have a rudimentary knowledge of what CS is all about. However, I wonder, what are the most significant CS advances of the last five years? To give you an idea of how clueless I am, I couldn't name one of these advances. But, please don't spare me all the gory details. I'm not looking for an education in CS or a story about the history of CS. As far as this question is concerned only the past five years matter! :-)

    Read the article

  • Unable to view ChildWindows in Silverlight

    - by Doug Nelson
    So here is the deal. I have created a silverlight dll that contains two ChildWindow dialogs. These dialogs are self contained with a WCF service reference. I want to reuse these dialogs across multiple projects. I have added a reference to the dll in another project. I am able to new up the childWindow, however, I am not able to set the public properties on it and when I call the Show method, nothing is displayed. Not really sure where to start to figure out why this is not working.

    Read the article

  • JavaScript: Change to Absolute Positioning

    - by Doug
    I'm trying to center a page on any resolution while still being able to use absolute positioning to move pictures. I figure that the best way would be to have a table positioned relatively in the beginning in the center of the page, then change it to absolute positioning in the onload of the page. I think the correct line is: document.getElementById("Object").style.position = "absolute"; However, I put an alert box after it asking where the left side of the object is, I get undefined. But, if I directly assign it to a position (Object.style.left = 500) I will get that number. So I can assign it a value, meaning it is in absolute position, but I cannot pull a value out of that. Kind of confusing but hopefully it makes sense and someone knows what to do. Thanks.

    Read the article

  • populate textboxs with xml node attributes

    - by Doug
    I have Data.xml: <?xml version="1.0" encoding="utf-8" ?> <data> <album> <slide title="Autum Leaves" description="Leaves from the fall of 1986" source="images/Autumn Leaves.jpg" thumbnail="images/Autumn Leaves_thumb.jpg" /> <slide title="Creek" description="Creek in Alaska" source="images/Creek.jpg" thumbnail="images/Creek_thumb.jpg" /> </album> </data> I'd like to be able to edit the attributes of each Slide node via GridView (that has a "Select" column added.) And so far I have: protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { int selectedIndex = GridView1.SelectedIndex; LoadXmlData(selectedIndex); } private void LoadXmlData(int selectedIndex) { XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(MapPath(@"..\photo_gallery\Data.xml")); XmlNodeList nodelist = xmldoc.DocumentElement.ChildNodes; XmlNode xmlnode = nodelist.Item(selectedIndex); titleTextBox.Text = xmlnode.Attributes["title"].InnerText; descriptionTextBox.Text = xmlnode.Attributes["description"].InnerText; sourceTextBox.Text = xmlnode.Attributes["source"].InnerText; thumbTextBox.Text = xmlnode.Attributes["thumbnail"].InnerText; The code for LoadXmlData is just a guess on my part - I'm new to working with xml in this way. I'd like have the user to slected the row from the gridview, then populate a set of text boxes with each slide attributed for updating back to the Data.xml file. The error I'm getting is "Object reference not set to an instance of an object" at the line: titleTextBox.Text = xmlnode.Attributes["@title"].InnerText; - so I'm not reaching the attribute "title" of the slide node. Thanks for any ideas you may have.

    Read the article

  • JSP request parameter is returning null on a jsp include with Weblogic.

    - by doug
    Hello, I am having trouble with the jsp:include tag. I have code like the following: <jsp:include page="./Address.jsp"> <jsp:param value="30" name="tabIndex"/> <jsp:param value="true" name="showBox"/> <jsp:param value="none" name="display"/> </jsp:include> The page is included fine, but when I try to access the parameters on the Address.jsp page, they are null. I have tried accessing them the following ways (with jstl): <c:out value="${param.tabIndex}" /> <c:out value="${param['tabIndex']} /> <%= request.getParameter("tabIndex") %> <c:out value="${pageScope.param.tabIndex} /> ${param.tabIndex} etc... Here is the kicker, The above works fine in tomcat 5.5. However, when I deploy the application in Weblogic 10, it does not. Also, the code works fine in other areas of my application (on weblogic) just not a particular page. Any Ideas? Thanks!

    Read the article

  • Can Anyone point me to a Android Market catalog or application list.

    - by Doug
    I'm up and running in Eclipse, have worked through several tutorials and would like to start developing my first marketable app. Is there anyplace I can find a comprehensive list or catalog of what's available on the Android marketplace? I'd hate to waste a lot of development time building an app that has twelve free versions already available.

    Read the article

  • How do I cause the controller buttons to display for an Apple Quicktime video embedded in Firefox?

    - by Doug Treadwell
    I am trying to embed a Quicktime video in Firefox, but when I do the controller buttons do not appear. I've tried both the old style embed tag and the new style object tags, but when I set the "controller" option to true there is no change in the appearance of the plugin. The video loads, but it is zoomed in on some portion of the video and there are no buttons to play, pause, etc.

    Read the article

  • Good suggestions for learning OOP PHP

    - by Doug
    I've been trying to learn PHP OOP and have looked at multiple articles, but have yet to find a good resource for learning. I want to learn from the user of setters and getters, $this-, constructors, and so on...! Can anyone please suggest me something? I noticed MOST teachings leave out the explanation of $this-. I want to learn magic methods, decorators, encapsulation, etc... Feel free to suggest something that I haven't explicitly listed.

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >