instruction
stringlengths
0
30k
PHP - command line arguments in WIndows
|php|php5|command-line|parameters|
I'm trying to run PHP from the command line under Windows XP. That works nice, except for the fact that I am not able to provide parameters to my PHP script. My test case: <?php echo "param = ".$param."\n"; var_dump($argv); ?> I want to call this as: php.exe -f test.php -- param=test But ...
Does your floating point code actually make use of the decimal point? If so: First you have to read Randy Yates's paper on Intro to Fixed Point Math: <http://www.digitalsignallabs.com/fp.pdf> Then you need to do "profiling" on your floating point code to figure out the appropriate range of fixed-point values re...
In modern C++ implementations, there will be no performance penalty for using simple and lean abstractions, such as concrete classes. Therefore you should write a FixedPoint8 class, test and debug it thoroughly, and use it. It will save you from many a trouble. If you like, you can further increase the utility of...
In modern C++ implementations, there will be no performance penalty for using simple and lean abstractions, such as concrete classes. Fixed-point computation is **precisely** the place where using a properly engineered class will save you from lots of bugs. Therefore, **you should write a FixedPoint8 class**. Test a...
Namespaces are actually rather passive in the design of the runtime and serve primarily as organizational tools. The Full Name of a type in .NET consists of the Namespace and Class/Enum/Etc. combined. If you only wish to go through a specific assembly, you would simply loop through the types returned by assembly.[GetEx...
Unless you are moving a large amount of data, a simple stored procedure should do the trick. A [sql server job][1] can manage the timing of when to call the proc. [1]: http://msdn.microsoft.com/en-us/library/ms187910.aspx
If your class uses the pimpl idiom, you can avoid changing the header file on the public class. This allows you to add/remove private/protected methods to the pimpl class, without modifying the external class's header file. You can also add/remove #includes to the pimpl too. When you change the external class's h...
If your class uses the pimpl idiom, you can avoid changing the header file on the public class. This allows you to add/remove methods to the pimpl class, without modifying the external class's header file. You can also add/remove #includes to the pimpl too. When you change the external class's header file, you ha...
I think what he actually wanted was the replacement in the match for the "current" node, not a match in the person node: <xsl:variable name="login" select="//current/login_name/text()"/> <xsl:template match="current/login_name"> <xsl:value-of select='concat(../../people/person[login_name=$login]/...
You want [`current()`](http://www.w3.org/TR/xslt#function-current) function <xsl:template match="current/login_name"> <xsl:value-of select="../../people/person[login_name = current()]/first"/> <xsl:text> </xsl:text> <xsl:value-of select="../../people/person[login_name = current()]/last"/> ...
Apache Fall Back When PHP Fails
|php|apache|configuration|
I was wondering if anybody knew of a method to configure apache to fall back to returning a static HTML page, should it (Apache) be able to determine that PHP has died? This would provide the developer with a elegant solution to displaying an error page and not (worst case scenario) the source code of the PHP page tha...
I would assume that this typically results in a 500 error, and you can configure apaches 500 handler to show a static page: ErrorDocument 500 /500error.html You can also read about error handlers on [apaches documentation site][1] [1]: http://httpd.apache.org/docs/2.0/custom-error.html
Copy/Pasting parts of my [own Blogpost][1], as I switched from Ankh to VisualSVN: > Why did I switch? Because i was a bit unhappy with the overall stability of Ankh, since it has some problems actually tracking Solution changes. VisualSVN is “just” a TortoiseSVN Frontend, which means it leaves all the “heavy lifting...
How can I convince Firefox (3.0.1, if it matters) to send an If-Modified-Since header in an HTTPS request? It sends the header if the request uses plain HTTP and my server dutifully honors it. But when I request the same resource from the same server using HTTPS instead (i.e., simply changing the http:// in the URL t...
How can I convince Firefox (3.0.1, if it matters) to send an If-Modified-Since header in an HTTPS request? It sends the header if the request uses plain HTTP and my server dutifully honors it. But when I request the same resource from the same server using HTTPS instead (i.e., simply changing the http:// in the URL t...
Having one executable has a few downsides: <ul> <li>You can't patch it as easy (i.e. replace one class file) <li>I don't think it can be called a webapp -- I assume it won't run in Tomcat. <li>It is non-standard so that increases your maintenance costs. <li>It is non-standard so tool support is reduced. </ul> If...
Win32_OperatingSystem is not a singleton class - if you check its qualifiers, you'll see that there is no Singleton qualifier defined for it, so you'll have to use ManagementObjectSearcher.Get() or ManagementClass.GetInstances() even though there is only one instance of the class. Win32_OperatingSystem key property is ...
release.major.minor.revivsion would be my guess. But it can vary greatly between products.
I think that given jdk1.5 (or greater) and your concatenation is thread-safe you should use StringBuilder instead of StringBuffer http://java4ever.blogspot.com/2007/03/string-vs-stringbuffer-vs-stringbuilder.html As for the gains in speed: http://www.about280.com/stringtest.html Personally I'd code for readabilit...
Because Strings are immutable, each call to the + operator creates a new String object and copies the String data over to the new String. Since copying a String takes time linear in the length of the String, a sequence of N calls to the + operator results in O(N<sup>2</sup>) running time (quadratic). Conversely, si...
Bear in mind that Resharper (and probably other similar tools as well) will not highlight unused methods if the methods are marked `public`. There is no way a static code analysis tool will be able to check whether the methods of your assembly are used by other assemblies outside your solution. So the first step in wee...
major.minor[.maintenance[.build]] http://en.wikipedia.org/wiki/Software_versioning#Numeric
Another canonical answer. This, I believe, from Ron Jeffries: Only test the code that you want to work.
I think the simplest answer is: it's faster. If you really want to know all the under-the-hood stuff, you could always have a look at the source yourself: http://www.sun.com/software/opensource/java/getinvolved.jsp http://download.java.net/jdk6/latest/archive/
I'm trying to run PHP from the command line under Windows XP. That works nice, except for the fact that I am not able to provide parameters to my PHP script. My test case: echo "param = ".$param."\n"; var_dump($argv); I want to call this as: `php.exe -f test.php -- param=test` But I never get the...
I'm trying to run PHP from the command line under Windows XP. That works nice, except for the fact that I am not able to provide parameters to my PHP script. My test case: echo "param = ".$param."\n"; var_dump($argv); I want to call this as: `php.exe -f test.php -- param=test` But I never get t...
PHP - command line arguments in Windows
I'm trying to run PHP from the command line under Windows XP. That works, except for the fact that I am not able to provide parameters to my PHP script. My test case: echo "param = ".$param."\n"; var_dump($argv); I want to call this as: `php.exe -f test.php -- param=test` But I never ge...
|php|command-line|parameters|php5|
I'm trying to run PHP from the command line under Windows XP. That works, except for the fact that I am not able to provide parameters to my PHP script. My test case: echo "param = ".$param."\n"; var_dump($argv); I want to call this as: `php.exe -f test.php -- param=test` But I never ge...
I'm trying to run PHP from the command line under Windows XP. That works, except for the fact that I am not able to provide parameters to my PHP script. My test case: echo "param = ".$param."\n"; var_dump($argv); I want to call this as: `php.exe -f test.php -- param=test` But I never ge...
It's not going to make much difference to memory use, so you might as well make the code clean. Since R has copy-on-modify for variables, modifying the global object will have the same memory implications as passing something up in return values. If you store the outputs in a database (or even in a file) you won'...
If you feel you are worrying more about workflow transitioning between various states, then state machine workflow is ideal. Otherwise, sequence is just fine. The main problem you are trying to solve is that the workflow should not tie up a thread while waiting for the human interaction (thread agility). If the wo...
If you feel you are worrying more about workflow transitioning between various states, then state machine workflow is ideal. Otherwise, sequence is just fine. The main problem you are trying to solve is that the workflow should not tie up a thread while waiting for the human interaction (thread agility). If the wo...
Update: Panos makes a good point about Suspend Activity. I agree it has a different purpose in the workflow automaton. If you feel you are worrying more about workflow transitioning between various states, then state machine workflow is ideal. Otherwise, sequence is just fine. The main problem you are trying to...
Update: Panos makes a good point about Suspend Activity. I agree it has a different purpose in the workflow automaton. If you feel you are worrying more about workflow transitioning between various states, then state machine workflow is ideal. Otherwise, sequence is just fine. The main problem you should be try...
Following code prints names of classes in specified ns defined in current assembly. As other guys pointed, namespace can scattered between different modules, so you need to get a list of assemblies first. string @namespace = "..."; var q = from t in Assembly.GetExecutingAssembly().GetTypes() ...
Try changing your XSL so you call 'ourFunction(/)'. That should pass the root node to the function. You could also try . or .. You'll presumably need to change the signature of the implementing function, I'll let someone else help with that.
Do you mean from the server-side? - You can't! **You'll have to do it on the client side.** Say, use a javascript that sends an *AJAX request* and then embed your response information in the *AJAX response*. And have the javascript read the response and changes the page in the intended frame accordingly
According to this link http://www.macfixit.com/article.php?story=20060621071707921 I need to have a Power PC Mac to run Mac classic. Is this right? I have a Intel Mac running Mac OS 10.4.11 . Are there any other tools capable of running on Intel Mac and could help me create CURS rsrc files. I tried using ResKnife but i...
Is Async Messaging (In particular pub/sub style messaging) viable as a domain service architecture or only in an SOA-focused environment?
|soa|messaging|
I have been researching asynchronous messaging, and I like the way it elegantly deals with some problems within certain domains and how it makes domain concepts more explicit. But is it a viable pattern for general domain-driven development (at least in the service/application/controller layer), or is the design overhe...
It'll depend a lot on what your host offers. MediaTemple and Slicehost both offer snapshot backups for a nominal fee. Contact your host and ask if they offer such a solution. If your host doesn't offer anything, you could always backup the critical stuff regularly to something like Amazon's S3 storage service.
A more common approach I have seen when exceptions aren't available is to store the error type in a 'last_error' variable somewhere and then when a failure happens (ie it returns false) look up the error. Another approach is to use the venerable unix tool approach numbered error codes - return 0 for success and any...
A more common approach I have seen when exceptions aren't available is to store the error type in a 'last_error' variable somewhere and then when a failure happens (ie it returns false) look up the error. Another approach is to use the venerable unix tool approach numbered error codes - return 0 for success and any...
Except for a scan on the "raise" keyword, there's no language construct in Delphi that tells the casual reader which exceptions can be expected from a method. At runtime, one could add a catch-all exception handler in every method, but that's not advisable, as it will slow down the speed of execution. (And it's cumb...
Passing more parameters in C function pointers
|c|pointer|architecture|
Let's say I'm creating a chess program. I have a function void foreachMove( void (*action)(chess_move*), chess_game* game); which will call the function pointer action on each valid move. This is all well and good, but what if I need to pass more parameters to the action function? For example: chess_m...
|c|architecture|pointer|
Let's say I'm creating a chess program. I have a function void foreachMove( void (*action)(chess_move*), chess_game* game); which will call the function pointer action on each valid move. This is all well and good, but what if I need to pass more parameters to the action function? For example: chess_m...
|c|architecture|pointers|
Does Amazon S3 fails sometimes?
|amazon|amazon-s3|experience|download|
We just added an autoupdater in our software and got some bug report saying that the autoupdate wouldn't complete properly because the downloaded file's sha1 checksum wasn't matching. We're hosted on Amazon S3... That's either something wrong with my code or something wrong with S3. I reread my code for suspicio...
Does Amazon S3 fail sometimes?
|amazon|download|amazon-s3|
|amazon|download|amazon-s3|
What is the most efficient graph data structure in Python?
|python|datastructure|performance|graph|
I need to be able to manipulate a large (10^7 nodes) graph in python. The data corresponding to each node/edge is minimal, say, a small number of strings. What is the most efficient, in terms of ***memory and speed***, way of doing this? A dict of dicts is more flexible and simpler to implement, but I intuitively e...
Major.minor.point.build usually. Major and minor are self-explanatory, point is a release for a few minor bugfixes, and build is just a build identifier.
@Balloon If you are using TortoiseSVN, you can use the packaged [SubWCRev](http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-subwcrev.html) program. It queries a working copy and tells you just the highest revision number. Admittedly, this seems to be a client-side approach to a server-side problem, but since it...
I have a very similar setup, and below is the code I'm currently using to test this stuff. In each of the `describe`s I put in: it_should_behave_like "login-required object" def attempt_access; do_post; end If all you need is a login, or it_should_behave_like "ownership-required object" def l...
What is the deployment rate of the .NET framework?
|c#|.net|deployment|statistics|
I've been looking for this information for my commercial desktop product, with no avail. Specifically, what I'm look for, is deployment statistics of the .NET framework for end-users (both granny "I'm just browsing the internet" XP, and high-end users, if possible), and in the commercial/business sector.
Regression Testing with Rational Robot
|build-process|build-automation|rational-number|
Is it possible to run a pre-recorded Rational Robot script on a continuous integration server in a manner that doesn't require the machine to be physically logged into?
My initial tests have shown that Robot won't work without an active, visible desktop. For example, while a scheduled task (or executed command from the continuous integration server) may be able to start robot as a command-line process, Robot will actually fail to execute the recorded script. Logging into the build ...
The PHP source code is only displayed when apache is not configured correctly to handle php files. That is, when a proper handler has not been defined. On errors, what is shown can be configured on php.ini, mainly the display_errors variable. That should be set to off and log_errors to on on a production environmen...
@VolkerK is right, they are using the printable version. Here is an easy way to find out when you know the site is displaying the page in an iframe. In Firefox right click anywhere inside the iframe, from the context menu select "This Frame" then "View frame info" You get the info you need including the Addres...
I'd say you should just hard-code the full path to the database. Not pretty, but it will always work. There are tools, like GExperts, that will ensure your database components are set to inactive when you save them, and that way you can be sure to set them correctly on the live computer at runtime. It would be nice ...
VS2008 Command Prompt + Cygwin
|command-line|cygwin|
I use the VS2008 command prompt for builds, TFS access etc. and the cygwin prompt for grep, vi and unix-like tools. Is there any way I can 'import' the vcvars32.bat functionality into the cygwin environment so I can call "tfs checkout" from cygwin itself?
> Many of my users are moving to Vista > which may run the app in compatibility > mode or may have GPF problems > depending on how their PC is > configured by their IT department, so > I have to do some maintenance on the > application. I'm wondering if I should > jump to a more familiar stack. Unless you are...
Unit Testing Monorail's RedirectToReferrer()
|c#|unit-testing|castle-monorail|
I am trying to write a unit test for an action method which calls the Controller.RedirectToReferrer() method, but am getting a "No referrer available" message. How can I isolate and mock this method? Thanks, -- rauchy
I'll second Zend_Form; it has an excellent ini style implementation that allows you to define a form extremely quickly: [main] vessel.form.method = "post" vessel.form.elements.name.type = "text" vessel.form.elements.name.name = "name" vessel.form.elements.name.options.label = "Name: " ...
Following code prints names of classes in specified ns defined in current assembly. As other guys pointed, namespace can be scattered between different modules, so you need to get a list of assemblies first. string @namespace = "..."; var q = from t in Assembly.GetExecutingAssembly().GetTypes() ...
One quick note before I jump into this. Typically you want to avoid the use of a "Strict" mock because it makes for a brittle test. A strict mock will throw an exception if anything occurs that you do not explicitly tell Rhino will happen. Also I think you may be misunderstanding exactly what Rhino is doing when you ma...
One quick note before I jump into this. Typically you want to avoid the use of a "Strict" mock because it makes for a brittle test. A strict mock will throw an exception if anything occurs that you do not explicitly tell Rhino will happen. Also I think you may be misunderstanding exactly what Rhino is doing when you ma...
Here is an implementation in Python: orcl = cx_Oracle.connect('ohd/john@ohddb') curs = orcl.cursor() csv_file_dest = "C:\\test.csv" output = csv.writer(open(csv_file_dest,'wb')) sql = "select * from parameter" curs.execute(sql) headers_printed = False ...
Here is an implementation in Python: import cx_Oracle, csv orcl = cx_Oracle.connect('ohd/john@ohddb') curs = orcl.cursor() csv_file_dest = "C:\\test.csv" output = csv.writer(open(csv_file_dest,'wb')) sql = "select * from parameter" curs.execute(sql) ...
Unhandled Exception Logging for Winforms
|.net|winforms|exception|logging|
Is there anything like [elmah][1] for Winforms? I'm looking for a standard way to process unhandled exceptions and grab a screenshot and other environment information before packaging that up for support. [1]: http://code.google.com/p/elmah/
I wrap the results returned by Lucene into my own collection of custom objects. Then I can populate it with extra info/context information (and use things like the highlighter class to pull out a snippet of the matches), plus add paging. If you took a similar route you could create a "result" class/object, add somethi...
If you want to update the version number in a projects AssemblyInfo.cs you may be interested in this article: [CodeProject: Use Subversion Revision numbers in your Visual Studio Projects][1] > If you enable SVN Keywords then every time you check in the project Subversion scans your files for certain "keywords" an...
I find listing column names is particually important if other developers are likely to work with the code, or the database is likely to change, so that you are always getting consistent data.
If you use modx it has a built in function to export static files.
Except for a scan on the "raise" keyword, there's no language construct in Delphi that tells the casual reader which exceptions can be expected from a method. At runtime, one could add a catch-all exception handler in every method, but that's not advisable, as it will slow down the speed of execution. (And it's cumb...