I want to conditionally output HTML to generate a page, so what's the easiest way to echo multiline snippets of HTML in PHP 4+? Would I need to use a template framework like Smarty? echo '<html>', "\n"; // I'm sure there's a better way! echo '<head>', "\n"; echo '</head>', "\n"; echo '<body>', "\n"; echo '</body>', "\n"; echo '</html>', "\n";
I am an embedded SW Engineer, with less than 3 yrs of experience. I aim to "sharpen the saw" continuously. I was wondering if there was anything specific to low level programming that C/C++ coders should be proficient with. What comes to my mind is familiarity with the hardware's architecture and instruction set. Knowing how to fiddle with bits is also important, resource management and performance have been part of my job, is there anything else? EDIT: I work with an in-house customized RTOS, not embedded Linux.
I am making a jython application that needs a config/settings file (and probably eventually directory) but I want it be stored in the expected/correct directory for each os. ~/.app_name/config in linux c:/documents and Settings/User/app_name ?? in windows. I have found this: http://snipplr.com/view/7354/home-directory-crossos/ but this is for python and I have feeling that this might not necessary work for jython/windows and I don't have any dev stuff set up in my windows VM to test at this moment If someone could provide any insight into the "best practices" (for jython) for achieving this I
I have a situation as follows <body> Test<br /> test<br /> test1<br /> </body> I need to add a tab after the 2nd test and 3rd test so that it looks similar to this. Test test test1 Is there a special HTML entity or special character for TAB. eg. Non-breaking space == & nbsp ; thanks
What is the difference between type(obj) and obj.__class__? Is there ever a possibility of type(obj) is not obj.__class__? I want to write a function that works generically on the supplied objects, using a default value of 1 in the same type as another parameter. Which variation, #1 or #2 below, is going to do the right thing? def f(a, b=None): if b is None: b = type(a)(1) # #1 b = a.__class__(1) # #2
I want to run a script remotely. But the system doesn't recognize the path. It complains that "no such file or directory". Am I using it right? ssh kev@server1 `./test/foo.sh`
I'm using Java's SSLSocket to secure communications between a client and a server program. The server program also serves up HTTPS requests from web browsers. According to "Beginning Cryptography with Java", page 371, you should always call setEnabledCipherSuites on your SSLSocket / SSLServerSocket to ensure that the cipher suite that ends up being negotiated is sufficiently strong for your purposes. That being said, a call to my SSLSocketFactory's getDefaultCipherSuites method yields some 180 options. These options range from TLS_RSA_WITH_AES_256_CBC_SHA (which I think is fairly secure) to SS
What's a fast way to sort a given set of images by their similarity to each other? At the moment, I have a system that does histogram analysis between two images, but this is a very expensive operation and seems too overkill. Optimally, I am looking for a algorithm that would give each image a score (for example, a integer score, such as the RGB average), and I can just sort by that score. Identical scores or scores next to each other are possible duplicates. 0299393 0599483 0499994 <- possible dupe 0499999 <- possible dupe 1002039 4995994 6004994 RGB average per image sucks. Is there somethin
What's the best way to determine the first key in a possibly associative array? My first thought it to just foreach the array and then immediately breaking it, like this: foreach ($an_array as $key => $val) break; Thus having $key contain the first key, but this seems inefficient. Does anyone have a better solution?
I am using Java 1.5.0_16 (JBoss-4.2.3.GA application). My application implements a WS client which needs to integrate with an external Web Service. This communication needs to be handled through https.I am getting following error when i trying to call remote Api via web services.can anybosy help me out what could be the cause 14:25:17,609 WARN [HTTPClientInvoker] Unable to create SSL Socket Factory for client invoker: Error initializing socket factory SSL context: Can not find truststore url. 14:25:18,203 INFO [STDOUT] ERROR: 14:25:18,203 ERROR [STDERR] javax.xml.ws.WebServiceException: java.i
How could you remove all characters that are not alphabetic from a string? What about non-alphanumeric? Does this have to be a custom function or are there also more generalizable solutions?
I am creating some suspended connections to an HTTP server (comet, reverse AJAX, etc). It works ok, but I see the browser only allows two suspended connections to a given domain simultaneously. So if a user is looking at my website in Tab1 of their browser, then also tries loading it in Tab2, they've used up the two allowed connections to my site. I think I can do some wildcard domain thing, where I have my HTTP server resolve any address to my site like: *.example.com/webapp -> 192.0.2.1 (the actual ip of my server) so: a.example.com/webapp b.example.com/webapp c.example.com/webapp all still
I want to migrate my iPhone app to a new database version. Since I don't have some version saved, I need to check if certain column names exist. This answer suggests: SELECT sql FROM sqlite_master WHERE tbl_name = 'table_name' AND type = 'table' And to parse the result. Is that the common way? Alternatives?
I wish to get a list of all strings that are used in a .NET assembly including the “static” values that local variables are set to, parameters passed to methods, fields at set to, etc. I recall from something I read a long time ago that a .NET assembly contains a tables of all strings it uses (or they can be "interned")– or am I just dreaming? Using .NET Reflector is a good ideal (thanks thijs), I will also have a look at its API if no one comes up with an already written tool. (This is so I can write a tool to check we have not missed any strings that should be translated. I could process the
(Not to be confused with Xunit, a popular .Net unit testing library.) Today in a fit of boredom I started inspecting Gmails DOM (yes, I was very bored). Everything looked pretty straightforward until I noticed an interesting specification on the widths of certain elements. The illustrious Googlites had specified a number of table cols using the rare 'ex' unit. width: 22ex; At first I was stumped ("what's an 'ex'?"), then it came back to me: I seem to remember something from years ago when first I was learning about CSS. From the CSS3 spec: [The ex unit is] equal to the used x-height of the fir
In my particular case: callback instanceof Function or typeof callback == "function" does it even matter, what's the difference? Additional Resource: JavaScript-Garden typeof vs instanceof
What are eigenvalues, vectors and expansions and as an algorithm designer, how can I use them? I want to know how you have used it in your program, so that I get an idea.
What are eigen values, vectors and expansions and as an algorithm designer how can I use them? EDIT: I want to know how YOU have used it in your program so that I get an idea. Thanks.
I'm building a web application with Django. The reasons I chose Django were: I wanted to work with free/open-source tools. I like Python and feel it's a long-term language, whereas regarding Ruby I wasn't sure, and PHP seemed like a huge hassle to learn. I'm building a prototype for an idea and wasn't thinking too much about the future. Development speed was the main factor, and I already knew Python. I knew the migration to Google App Engine would be easier should I choose to do so in the future. I heard Django was "nice". Now that I'm getting closer to thinking about publishing my work, I st
I want to bind the columns of my WPF DataGrid to some objects in a Dictionary like this: Binding Path=Objects[i] where Objects is my Dictionary of objects, so that each cell will represent an Object element. How can I do that? I suppose that I need to create a template for my cell, which I did, but how to get the result of column binding in my template? I know that by default the content of a DataGridCell is a TextBlock and it's Text property is set through column binding result, but if that result is an object I guess that I have to create a ContentTemplate. How do I do that, as the stuff I t
I searched the web for examples of draggable Swing components, but I found either incomplete or non-working examples. What I need is a Swing component that can be dragged by the mouse inside an other component. While being dragged, it should already change its position, not just 'jump' to its destination. I would appreciate examples which work without non-standard APIs. Thank you.
I'm very fond of vim and really would like to enhance my bash experience with vi-mode. However one thing I'm so accustomed to the emacs behavior in that, when browsing the shell history with cursor up/down, the cursor is positioned at the end of the line. In vi-mode it's the other way around; the cursor is always positioned at the beginning of the line. It's really burned in the brain to expect the cursor at the end, having used bash in emacs mode for ... way too long. Any chance to get the cursor position by default at the end of the line in bash vi-mode when browsing through the shell histor
In an ASP.NET MVC view I have the following code: <% Page.Title = ViewData.Model.MyPageTitle; %> and when I step through it I see the Page.Title value changing to the title that I want but when you look at the page's title shown in the browser it has not been modified. It appears that this value is overwritten by something later on. Any ideas how the page title should be set if you want to do it dynamically?
I'm sure many people have already seen demos of using genetic algorithms (GAs) to generate an image that matches a sample image. You start off with noise, and gradually it comes to resemble the target image more and more closely, until you have a more or less exact duplicate. All of the examples I've seen, however, use a fairly straightforward pixel-by-pixel comparison, resulting in a fairly predictable 'fade in' of the final image. I'm looking for something more novel: A fitness measure that comes closer to what we see as 'similar' than the naive approach. I don't have a specific result in mi