instruction
stringlengths
0
30k
Interesting question! I would do this by picking combinations, something like the following in python. The hardest part is probably first pass verification, i.e. if f(1,2,3) returns true, is that a correct result? Once you have verified that, then this is a good basis for regression testing. Probably it's a good idea to make a set of test cases that you know will be all true (e.g. 3,4,5 for this triangle case), and a set of test cases that you know will be all false (e.g. 0,1,inf). Then you can more easily verify the tests are correct. <pre> # xpermutations from http://code.activestate.com/recipes/190465 from xpermutations import * lengths=[-1,0,1,5,10,0,1000,'inf'] for c in xselections(lengths,3): # or xuniqueselections print c </pre> <pre> (-1,-1,-1); (-1,-1,0); (-1,-1,1); (-1,-1,5); (-1,-1,10); (-1,-1,0); (-1,-1,1000); (-1,-1,inf); (-1,0,-1); (-1,0,0); ... </pre>
I'm not a PHP dev but Google says that PHP 5+ can instantiate COM components. If you can install Outlook on a box you could write a PHP web service around the COM component to handle the requests you need. $outlook = COM("Outlook.Application") [Outlook API referance][1] [1]: http://msdn.microsoft.com/en-us/library/aa193231.aspx
In Ruby on Rails, there's a concept of [migration](http://wiki.rubyonrails.org/rails/pages/UnderstandingMigrations) -- a quick script to change the database. You generate a migration file, which has rules to increase the db version (such as adding a column) and rules to downgrade the version (such as removing a column). Each migration is numbered, and a table keeps track of your db version. To _migrate up_, you run a command called "db:migrate" which looks at your version and applies the needed scripts. You can migrate down in a similar way. The migration scripts themselves are kept in a version control system -- whenever you change the database you check in a new script, and any developer can apply it to bring the db to the latest version.
In Ruby on Rails, there's a concept of a [migration](http://wiki.rubyonrails.org/rails/pages/UnderstandingMigrations) -- a quick script to change the database. You generate a migration file, which has rules to increase the db version (such as adding a column) and rules to downgrade the version (such as removing a column). Each migration is numbered, and a table keeps track of your db version. To _migrate up_, you run a command called "db:migrate" which looks at your version and applies the needed scripts. You can migrate down in a similar way. The migration scripts themselves are kept in a version control system -- whenever you change the database you check in a new script, and any developer can apply it to bring the db to the latest version.
In Ruby on Rails, there's a concept of a [migration](http://wiki.rubyonrails.org/rails/pages/UnderstandingMigrations) -- a quick script to change the database. You generate a migration file, which has rules to increase the db version (such as adding a column) and rules to downgrade the version (such as removing a column). Each migration is numbered, and a table keeps track of your current db version. To _migrate up_, you run a command called "db:migrate" which looks at your version and applies the needed scripts. You can migrate down in a similar way. The migration scripts themselves are kept in a version control system -- whenever you change the database you check in a new script, and any developer can apply it to bring the db to the latest version.
How do I convert a file path to a URL in ASP.NET
|asp.net|image|url|
Basically I have some code to check a specific directory to see if an image is there and if so I want to assign a URL to the image to an ImageControl. if (System.IO.Directory.Exists(photosLocation)) { string[] files = System.IO.Directory.GetFiles(photosLocation, "*.jpg"); if (files.Length > 0) { // TODO: return the url of the first file found; } }
Generate sitemap on the fly
|sitemap|
I'm trying to generate a sitemap.xml on the fly for a particular asp.net website. I found a couple solutions:<br /> 1. [chinookwebs][1] 2. [cervoproject][2] 3. [newtonking][3] Chinookwebs is working great but seems a bit inactive right now and it's impossible to personalize the "priority" and the "changefreq" tags of each and every page, they all inherit the same value from the config file. What solutions do you guys use? Thanks a lot for support! [1]: http://sitemap.chinookwebs.com/ [2]: http://www.cervoproject.info/sitemaps.aspx [3]: http://www.codeplex.com/Sitemaps
|.net|asp.net|sitemap|
The c2 [Wiki][1] kicks butt. Great combination of concise definitions and examples, plus discussions that break it down when there are different interpretations. [1]: http://c2.com/cgi/wiki
@[Nicolas][1] > > Some of them are broken, or were before they were edited. Most damning is the fact that > > people are having to think quite hard about how to write the code without labels and not > > break anything. > I have a different point of view: some of them are broken because it is hard to figure out > the behavior of the original algorithm. I realise that it's subjective, but I don't have any trouble reading the original algorithm. It's shorter and clearer than the proposed replacements. What all the refactorings in this thread do is emulate the behaviour of a label using other language features - as if you were porting the code to a language that didn't have labels. [1]: http://stackoverflow.com/questions/15851?sort=newest#15981
It's for conditional compilation, so you can include or remove bits of code based upon project attributes which tend to be: - Intended platform (Windows/Linux/XB360/PS3/Iphone.... etc) - Release or Debug (Generally logging, asserts etc are only included in a debug build) They can also be used to disable large parts of a system quickly, for example, during development of a game, I might define #define PLAYSOUNDS and then wrap the final call to play a sound in: #ifdef PLAYSOUNDS // Do lots of funk to play a sound return true; #else return true; So it's very easy for me to turn on and off the playing of sounds for a build. (Typically I don't play sounds when debugging because it gets in the way of my personal music :) ) The benefit is that you're not introducing a branch through adding an if statement....
CLR integration with SQL 2005 is particularly useful for user-defined functions/stored procs written in .NET and also user-defined data types. e.g. You could write a heavy duty data type that allows SQL to define objects and reference properties. You could write some super-duper datetime variation, for instance.
We use Apache's [Log4cxx][1] for logging which isn't perfect, but provides a lot of infrastructure and a consistent approach across projects. I believe it is cross-platform, though we only use it on Windows. It provides for run time configuration via an ini file which allows you to control how the log file is output, and you could write your own appenders if you want specific behaviour (e.g. an error dialog under the UI). If clients of your library also adopt it then it would integrate their logging output into the same log file(s). Differentiation between instances of the main class could be supported using the nested diagnostic context (NDC) feature. [1]: http://logging.apache.org/log4cxx/index.html
An extensive use of [Visual Assist](http://www.wholetomato.com/)'s snippets (bits of pre-formatted codes) may help...
Recycle shuts down the process hosting the appdomain. You'll notice that the PID changes when you recycle it. Unloading the AppDomin simply unloads all of the assemblies in the AppDomain, which can then be reused. The important thing to remember is that once the CLR is loaded into a process, it can't be removed. So if you needed to do something as soon as the CLR is loaded, then simply unloading the AppDomain won't help, because the CLR won't be reloaded. Also not that IIS isn't the only process which can host the AppDomain - any process can, and you don't always want to kill the whole process just to unload your assemblies.
I second Luke's answer. StyleCop can help you enforce common coding style across your team. If you want to share formatting rules take a look at ReSharper AFAIK it allows you to export and share this settings.
System.Web. HttpContext.Current.Handler HttpContext.Current.Request.Server.Transfer
Editor settings are stored in the registry, so no luck having a single source for them. You'll need to go with an external tool to ensure uniformity. A free, quick solution would be exporting the relevant registry settings and loading them up on everyone's machine. They'll still be able to change them (and they will -- naughty developers!), but you'll at least have a common starting point.
You could use something like this as your pre-commit script: <pre> #! /usr/bin/perl while (<>) { $last = $_; } if (! ($last =~ m/\n$/)) { print STDERR "File doesn't end with \\n!\n"; exit 1; } </pre>
You could use something like this as your pre-commit script: <pre> #! /usr/bin/perl while (&lt;&gt;) { $last = $_; } if (! ($last =~ m/\n$/)) { print STDERR "File doesn't end with \\n!\n"; exit 1; } </pre>
Remote Debugging Server Side of a Web Application with Visual Studio 2008
OK, first is dead easy. date ('Y-m-d', mktime(0,0,0,MM,01,YYYY)); Last is a little trickier, but not much. date ('Y-m-d', mktime(0,0,0,MM + 1,-1,YYYY)); If I remember my PHP date stuff correctly... **edit - Gah! Beaten to it about a million times... Edit by Pat: Last day should have been date ('Y-m-d', mktime(0,0,0,$MM + 1,0,$YYYY)); // Day zero instead of -1
So, just as a final update for anyone reading this later - the tool I ended up using was "livecd-creator". My reason for choosing this tool was that it is available for RedHat-based distributions like CentOs, Fedora and RHEL - which are all distributions that my company supports already. In addition, while the project is very poorly documented it is extremely customizable. I was able to create a minimal LiveCD and edit the boot sequence so that it booted directly into the firmware updater instead of a bash shell. The whole job would have only taken an hour or two if there had been a README explaining the configuration file!
To sort out the confusion between the apparently conflicting answers above, this is my current understanding of the answer: - Use the 2.0 version, as DAC and Codeslayer recommended - If you don't *have* the 2.0 version (mine was helpfully uninstalled when I removed VS2005 and installed VS2008), then you can either install VS2005, or download the Windows SDK, as per GateKiller's link On my PC, even downloading the SDK didn't work; it installed mscorcfg.msc but not mscorcfg.dll. Digging about in the GAC, I notice mscorcfg.dll v3.5, which confuses me even more. Anyway, there is an iffy-looking copy-dlls-and-hack-registry solution at http://home.hot.rr.com/graye/Articles/CodeAccessSecurity.htm, and that's what I'm going to try next. Wish me luck!
If you do not want/need to use a transaction, you could create a stored procedure that first updates the view count and then selects the values and return them to the user.
.NET is very easy to decompile. The best tool to do that would be the [.NET reflector][1] recently acquired by RedGate. [1]: http://www.red-gate.com/products/reflector/
here's ya problem: > 3.2GHz P4 Hyperthreaded, 2GB RAM Hypertheaded means "doesn't actually have two CPU's, but it fakes it". If you have a process with just one thread running, then you get bad performance. It was a good short-term measure, but compared to having two REAL CPU's, it's a slow hack. 2GB of RAM would be an issue too, based on what you said you run. If you have a basic 5400RPM disk, then it's going to make it all worse. I'd recommend, based on what you posted: - A good core2 machine, maybe a quad if you have the budget. - 3GB of ram if you are running a 32bit OS, 4+GB if you are running x64. 4GB means you waste 1GB under 32bit. - Get 7200RPM disks, or better. If you can, RAID0 them (stripe) or RAID0+1 (stripe+mirror) if you can get 4 drives (stripe == split content over the two disks, so you can read from both at the same time. stripe+mirror == the safe version of striping, so your code is on TWO disks at all times) I have a 2.0ghz Core2 (so roughly 3-4x the performance of your P4, if you count 2 CPU's(cores) to be 2x) with 2GB, and the most I can run well is 2 instances of VS.NET 2008. This is normal - nothing wrong with VS.NET, it's just a huge app. More RAM. More CPU. More Screen. More. More. More :)
In Ruby on Rails, there's a concept of a [migration](http://wiki.rubyonrails.org/rails/pages/UnderstandingMigrations) -- a quick script to change the database. You generate a migration file, which has rules to increase the db version (such as adding a column) and rules to downgrade the version (such as removing a column). Each migration is numbered, and a table keeps track of your current db version. To _migrate up_, you run a command called "db:migrate" which looks at your version and applies the needed scripts. You can migrate down in a similar way. The migration scripts themselves are kept in a version control system -- whenever you change the database you check in a new script, and any developer can apply it to bring their local db to the latest version.
I'll add to the excellent answers given above, and talk about boxing and unboxing, and how this applies to Java (although C# has it too). I'll use just Java terminology, because I am more _au fait_ with that. As the answers mentioned, `int` is just a number (called the _unboxed_ type), whereas `Integer` is an object (which encloses the number, hence a _boxed_ type). In Java terms, that means (apart from not being able to call methods on `int`), you cannot store `int` or other non-object types in collections (`List`, `Map`, etc.). In order to store them, you must first box them up in its corresponding boxed type. Java 5 onwards have something called _auto-boxing_ and _auto-unboxing_ which allow the boxing/unboxing to be done behind the scenes. Compare and contrast: Java 5 version: Deque<Integer> queue; void add(int n) { queue.add(n); } int remove() { return queue.remove(); } Java 1.4 or earlier: Deque<Integer> queue; void add(int n) { queue.add(new Integer(n)); } int remove() { return queue.remove().intValue(); } Auto-boxing and auto-unboxing is very convenient because it means you don't have to think about writing out the boxing and unboxing by hand every time. However, these operations _do_ happen behind the scenes, with the same runtime costs, so you still have to be aware of them. Hope this helps!
I'll add to the excellent answers given above, and talk about boxing and unboxing, and how this applies to Java (although C# has it too). I'll use just Java terminology, because I am more _au fait_ with that. As the answers mentioned, `int` is just a number (called the _unboxed_ type), whereas `Integer` is an object (which encloses the number, hence a _boxed_ type). In Java terms, that means (apart from not being able to call methods on `int`), you cannot store `int` or other non-object types in collections (`List`, `Map`, etc.). In order to store them, you must first box them up in its corresponding boxed type. Java 5 onwards have something called _auto-boxing_ and _auto-unboxing_ which allow the boxing/unboxing to be done behind the scenes. Compare and contrast: Java 5 version: Deque<Integer> queue; void add(int n) { queue.add(n); } int remove() { return queue.remove(); } Java 1.4 or earlier (no generics either): Deque queue; void add(int n) { queue.add(new Integer(n)); } int remove() { return ((Integer) queue.remove()).intValue(); } It must be noted that despite the brevity in the Java 5 version, both versions generate identical bytecode. Thus, although auto-boxing and auto-unboxing is very convenient because you write less code, these operations _do_ happen behind the scenes, with the same runtime costs, so you still have to be aware of their existence. Hope this helps!
You have to use JavaScript for this: <script type="text/javascript"> window.name = "MyWindow"; </script> Of course you could easily package this up into a Rails helper method. For example, in `app/helpers/application_helper.rb` add a new method: def window_name(name) content_for(:window_name) do "<script type=\"text/javascript\">window.name = \"#{name}\";</script>" end end Next, in your layout file, add this line somewhere within the HTML `<head>` element: <%= yield :window_name %> Finally, in your view templates, simply add a line like this (can be anywhere you want) to output the correct JavaScript: <% window_name 'MyWindow' %>
How do I set the name of a window in ROR?
|html|ruby|ruby-on-rails|target|
How do I "name" a browser window in ROR, such that I can open a page in it later, from another (popup) window (using the target="name" html parameter)
|javascript|html|ruby|ruby-on-rails|
I'm not sure I understand your question. In C any data that's not overwritten is carried over into the next iteration of the loop, and imagine that C++ works much the same way.
There's an excellent book written by John Robbins which tackles many difficult debugging questions. The book is called [Debugging Applications for Microsoft .NET and Microsoft Windows][1]. Despite the title, the book contains a host of information about debugging native C++ applications. In this book, there is a lengthy section all about how to get the call stack for exceptions that are thrown. If I remember correctly, some of his advice involves using *structured exception handling* (SEH) instead of (or in addition to) C++ exceptions. I really cannot recommend the book highly enough. [1]: http://www.amazon.com/Debugging-Applications-Microsoft-Windows-Pro-Developer/dp/0735615365
You could trying using the MS-DOS [subst][1] command to assign your source code directory to the D: drive. [1]: http://www.computerhope.com/substhlp.htm
How do I sort a list of strings in Python?
|python|string|sorting|
What is the best way of creating an alphabetically sorted list in Python?
As an addition to dlamblin's answer it is often best to use the clickTAG technique to open URLS from a flash movie. More information can be found here: [http://www.adobe.com/resources/richmedia/tracking/designers_guide/][1] [1]: http://www.adobe.com/resources/richmedia/tracking/designers_guide/ The advantage of using the clickTAG technique is that you can set the URL to jump to in the HTML page. This means that you can set the flash movie to link to different places without modifying the flash file (beyond adding the initial clickTAG code). You can use link tracking on the URL as well.
You can use the one built in, `hg view`. I believe you just have to enable it in your `.hgrc`. You'll also need tcl installed. I find it sometimes lags for a few seconds, but overall it's pretty decent. Apparently it is a bit difficult to get everything working on a mac, [try this quick guide][1] > Here's how to get it to work: > 1. Download and install a new version of Mercurial using the link above. > 2. Clone the Mercurial repository, then update it to the revision that you had just installed, and finally copy the hgk script to your personal bin directory: > `$ hg clone http://selenic.com/hg hg-upstream > $ hg up -r b7f44f01a632 > $ cp hg-upstream/contrib/hgk ~/bin` > You could also copy it to your system-wide bin directory: > `$ sudo cp hg-upstream/contrib/hgk /usr/local/bin` > 3. Edit your ~/.hgrc file to turn on the extension and point it to the location of your hgk script: > `[extensions] > hgk=` > `[hgk] > path=/Users/myusername/bin/hgk` > (If you copied it to your system-wide bin directory, use /usr/local/bin/hgk for the path value.) [1]: http://goldenspud.com/rotr/index.php/2008/02/06/get-hg-view-to-work-in-mac-os-x/
I don't think the [pre-commit][1] hook can actually change the data that is being committed - it can disallow a commit, but I don't think it can do the conversion for you. It sounds like you want the [property][2] 'svn:eol-style' set to 'native' - this will automatically convert newlines to whatever is used on your platform (use 'CRLF', 'CR' or 'LF' to get those regardless of what the OS wants). You can use [auto-properties][3] so that all future files you create will have this property set (auto props are handled client-side, so you'd have to set this up for each user). [1]: http://svnbook.red-bean.com/nightly/en/svn.ref.reposhooks.pre-commit.html [2]: http://svnbook.red-bean.com/nightly/en/svn.ref.properties.html [3]: http://subversion.tigris.org/faq.html#auto-props
How about an XPath based approach? I like this approach as the logic is super-easy to understand. The code is pretty much self-documenting. If your xml document is available to you as an org.w3c.dom.Document object (as most parsers return), then you could do something like the following: // get the list of customdata nodes NodeList customDataNodeSet = findNodes(document, "//customdata" ); Node customDataNode; NodeList locationNodeSet; for (int i=0 ; i < customDataNodeSet.getLength() ; i++) { customDataNode = customDataNodeSet.item( i ); // get the location nodes (if any) within this one customdata node locationNodeSet = findNodes(customDataNode, "location" ); if (locationNodeSet.getLength() > 0) { // replace locationNodeSet.item( 0 ).setTextContent( "http://www.whatiwant.com/" ); } else { // insert Element newLocationNode = document.createElement( "location" ); newLocationNode.setTextContent("http://www.whatiwant.com" ); customDataNode.appendChild( newLocationNode ); } } /** * helper method to do xpath search */ private NodeList findNodes( Object obj, String xPathString ) throws XPathExpressionException { XPath xPath = XPathFactory.newInstance().newXPath(); XPathExpression expression = xPath.compile( xPathString ); return (NodeList) expression.evaluate( obj, XPathConstants.NODESET ); }
How about an XPath based approach? I like this approach as the logic is super-easy to understand. The code is pretty much self-documenting. If your xml document is available to you as an org.w3c.dom.Document object (as most parsers return), then you could do something like the following: // get the list of customdata nodes NodeList customDataNodeSet = findNodes(document, "//customdata" ); for (int i=0 ; i < customDataNodeSet.getLength() ; i++) { Node customDataNode = customDataNodeSet.item( i ); // get the location nodes (if any) within this one customdata node NodeList locationNodeSet = findNodes(customDataNode, "location" ); if (locationNodeSet.getLength() > 0) { // replace locationNodeSet.item( 0 ).setTextContent( "http://stackoverflow.com/" ); } else { // insert Element newLocationNode = document.createElement( "location" ); newLocationNode.setTextContent("http://stackoverflow.com/" ); customDataNode.appendChild( newLocationNode ); } } And here's the helper method findNodes that does the XPath search. private NodeList findNodes( Object obj, String xPathString ) throws XPathExpressionException { XPath xPath = XPathFactory.newInstance().newXPath(); XPathExpression expression = xPath.compile( xPathString ); return (NodeList) expression.evaluate( obj, XPathConstants.NODESET ); }
Recently I've had both Visual Studio 2008 and Visual Studio 2005 on my machine, and I agree that VS2005 is really heavy. They improved upon it in VS2008, although I'm not sure if you'll consider the performance improvements enough.
One suggestion to Tithonium's answer above: If you are want to assign different values to the same variable, this might be better (the copy-book way): $a = ($condition) ? 2 : 3;
Most languages can be decompiled but some are easier to decompile than others. .Net and Java put more information about the original program in the executables (method names, variable names etc.) so you get more of your original information back. C++ for example will translate variables and functions etc. to memory adresses (yeah I know this is a gross simplification) so the decompiler won't know what stuff was called. But you can still get some of the structure of the program back though.
In general, languages like Java, C#, and VB.NET are relatively easy to decompile because they are compiled to an intermediary language, not pure machine language. In their IL form, they retain more metadata than C code does when compiled to machine language. Technically you aren't getting the original source code out, but a variation on the source code that, when compiled, will give you the compiled code back. It isn't identical to the source code, as things like comments, annotations, and compiler directives usually aren't carried forward into the compiled code.
VB6 if compiled to pcode is also possible to decompile to almost full source using [P32Dasm][1], Flash (or actionscript) is also possible to decompile to full source using something like [Flare][2] [1]: http://progress-tools.110mb.com/p32dasm.html [2]: http://www.nowrap.de/flare.html
This will get your buttons and labels next to each other, at least. I believe the second part can't be done in css alone, and will need javascript. <style type="text/css"> .input input { float: left; } .input label { margin: 5px; } </style> <div class="input radio"> <fieldset> <legend>What color is the sky?</legend> <input type="hidden" name="data[Submit][question]" value="" id="SubmitQuestion" /> <input type="radio" name="data[Submit][question]" id="SubmitQuestion1" value="1" /> <label for="SubmitQuestion1">A strange radient green.</label> <input type="radio" name="data[Submit][question]" id="SubmitQuestion2" value="2" /> <label for="SubmitQuestion2">A dark gloomy orange</label> <input type="radio" name="data[Submit][question]" id="SubmitQuestion3" value="3" /> <label for="SubmitQuestion3">A perfect glittering blue</label> </fieldset> </div>
This will get your buttons and labels next to each other, at least. I believe the second part can't be done in css alone, and will need javascript. I found a page that might help you with that part as well, but I don't have time right now to try it out: [http://www.webmasterworld.com/forum83/6942.htm][1] <style type="text/css"> .input input { float: left; } .input label { margin: 5px; } </style> <div class="input radio"> <fieldset> <legend>What color is the sky?</legend> <input type="hidden" name="data[Submit][question]" value="" id="SubmitQuestion" /> <input type="radio" name="data[Submit][question]" id="SubmitQuestion1" value="1" /> <label for="SubmitQuestion1">A strange radient green.</label> <input type="radio" name="data[Submit][question]" id="SubmitQuestion2" value="2" /> <label for="SubmitQuestion2">A dark gloomy orange</label> <input type="radio" name="data[Submit][question]" id="SubmitQuestion3" value="3" /> <label for="SubmitQuestion3">A perfect glittering blue</label> </fieldset> </div> [1]: http://www.webmasterworld.com/forum83/6942.htm
Take a look at Raymond Chens solution: [http://blogs.msdn.com/oldnewthing/archive/2005/02/01/364563.aspx][1] and here's the PINVOKE for .NET: [http://www.pinvoke.net/default.aspx/kernel32/IsWow64Process.html?diff=y][2] **Update:** I'd take issue with checking for 'x86'. Who's to say what intel's or AMD's next 32 bit processor may be designated as. The probability is low but it is a risk. You should ask the OS to determine this via the correct API's, not by querying what could be a OS version/platform specific value that may be considered opaque to the outside world. Ask yourself the questions, 1 - is the registry entry concerned properly documented by MS, 2 - If it is do they provide a definitive list of possible values that is guaranteed to permit you as a developer to make the informed decision between whether you are running 32 bit or 64 bit. If the answer is no, then call the API's, yeah it's a but more long winded but it is documented and definitive. Just my 2c. [1]: http://blogs.msdn.com/oldnewthing/archive/2005/02/01/364563.aspx [2]: http://www.pinvoke.net/default.aspx/kernel32/IsWow64Process.html?diff=y
This might be a bit of a long shot, but if you're using (or planning on using) SQL Server 2008 I'd recommend having a look at the new [FileStream][1] data type. [1]: http://msdn.microsoft.com/en-us/library/bb933993(SQL.100).aspx
I've worked with RedGate's profiler in the past. Did the job for me.
I've been working with JetBrains dotTrace for WinForms and Console Apps (not tested on ASP.net yet), and it works quite well: [http://www.jetbrains.com/profiler/][1] They recently also added a "Personal License" that is significantly cheaper than the corporate one. Still, if anyone else knows some cheaper or even free ones, I'd like to hear as well :-) [1]: http://www.jetbrains.com/profiler/
[ANTS Profiler][1]. I haven't used many, but I don't really have any complaints about ANTS. The visualization is really helpful. [1]: http://www.red-gate.com/products/ants_profiler/index.htm
Don't forget [nProf][1] - a prefectly good, freeware profiler. [1]: http://nprof.sourceforge.net/Site/Description.html "SourceForge"
I aim for XHTML 1.0 Trans. It's better to conform so when bugs are fixed in the browsers you won't suddenly be working against the clock trying to figure out what actually needs changing. In my opinion 1.1 is borked and 2.0 has been smashed to smithereens: Do I really need/want a header/footer tag?
So you want to download a webpage as an XML object using javascript, but you don't want to use a webpage? Since you have no control over what the user will do (closing tabs or windows or whatnot) you would need to do this in like a OSX Dashboard widget or some separate application. A Firefox extension would also work, unless you have to worry about the user closing the browser.
I use the approach described by Greg in his [answer][1] and populate the audit table with a stored procedure called from the table triggers. [1]: http://stackoverflow.com/questions/3823/suggestions-for-implementing-audit-tables-in-sql-server#3848
Here's an example using the stronger typing. Not sure if it's necessarily the best way though. static void Main(string[] args) { IList list = new List<int>() { 1, 3, 2, 5, 4, 6, 9, 8, 7 }; List<int> stronglyTypedList = new List<int>(Cast<int>(list)); stronglyTypedList.Sort(); } private static IEnumerable<T> Cast<T>(IEnumerable list) { foreach (T item in list) { yield return item; } } The Cast function is just a reimplementation of the extension method that comes with 3.5 written as a normal static method. It is quite ugly and verbose unfortunately.
I'd have a look at [GLAM][1] and [GLGooey][2] [1]: http://glam.sourceforge.net/ [2]: http://glgooey.sourceforge.net/
If you've got Greasemonkey installed you might want to try the XSS Assistant user script: [http://www.whiteacid.org/greasemonkey/#xss_assistant][1] [1]: http://www.whiteacid.org/greasemonkey/#xss_assistant
So far as I know there's no single function which does this (maybe you were looking for the inverse of [MapPath](http://msdn.microsoft.com/en-us/library/ms524632.aspx)?). I'd love to know if such a function exists. Until then, I would just take the filename(s) returned by GetFiles, remove the path, and prepend the URL root. This can be done generically.
I think this should work. It might be off on the slashes. Not sure if they are needed or not. string url = Request.ApplicationPath + "/" + photosLocation + "/" + files[0];
The [DOM Inspector][1] will let you add/edit/remove inputs - copying existing ones is the easiest way of adding new ones. I highly recommend getting [Inspect This][2] as well. [1]: https://addons.mozilla.org/en-US/firefox/addon/6622 [2]: https://addons.mozilla.org/en-US/firefox/addon/1913
You might find your code is more maintainable if you keep all your styles, etc. in CSS and just set / unset class names in JavaScript. Your CSS would obviously be something like: .highlight { background:#ff00aa; } Then in JavaScript: element.className = (element.className === 'highlight' ? '' : 'highlight');
Afaik, there's no method to do what you want directly. I'd store the photosLocation as a path relative to the application; f.ex. "~/Images/". This way, you could use MapPath to get the physical location, and ResolveUrl to get the url (with a bit of help from System.IO.Path): string photosLocationPath = HttpContext.Current.Server.MapPath(photosLocation); if (Directory.Exists(photosLocationPath)) { string[] files = Directory.GetFiles(photosLocationPath, "*.jpg"); if (files.Length > 0) { string filenameRelative = photosLocation + Path.GetFilename(files[0].FullName) return HttpContext.Current.Request.ResolveUrl(filenameRelative); } }
Afaik, there's no method to do what you want directly. I'd store the photosLocation as a path relative to the application; f.ex. "~/Images/". This way, you could use MapPath to get the physical location, and ResolveUrl to get the url (with a bit of help from System.IO.Path): string photosLocationPath = HttpContext.Current.Server.MapPath(photosLocation); if (Directory.Exists(photosLocationPath)) { string[] files = Directory.GetFiles(photosLocationPath, "*.jpg"); if (files.Length > 0) { string filenameRelative = photosLocation + Path.GetFilename(files[0]) return HttpContext.Current.Request.ResolveUrl(filenameRelative); } }
|asp.net|visual-studio|debugging|asp-classic|
So, I've read that it is not a good idea to install VS2008 on my test server machine as it changes the run time environment too much. I've never attempted remote debugging with Visual Studio before, so what is the "best" way to get line by line remote debugging of server side web app code. I'd like to be able to set a breakpoint, attach, and start stepping line by line to verify code flow and, you know, debug and stuff :). I'm sure most of the answers will pertain to ASP.NET code, and I'm interested in that, but my current code base is actually Classic ASP and ISAPI Extensions, so I care about that a little more. Also, my test server is running in VMWare, I've noticed in the latest VMWare install it mentioning something about debugging support, but I'm unfamiliar with what that means...anyone using it, what does it do for you?
There is a tool called [NArrange][1] which will arrange your code. This is particular useful to avoid conflicts in source control systems, but also has several other advantages. Check out the web site. [1]: http://narrange.sourceforge.net/
In the example given, there's no real difference between the two - and no significant advantages or disadvantages to either. However, in larger schemas things can get very untidy and difficult to manage when the practice for choosing nested over global isn't clearly defined. The obvious reasons for using global types (primarily reuse, also nesting) tend to dictate - in general I prefer one mode or the other. I.e. if you're reusing some complexTypes but not others, make them all global. If you're not reusing anything, make them all nested. The exception to this (and this is something I've come across frequently) is if the definition of the types make up the bulk of the complexity (!) of your schema, and the their containment is relatively simple. In this case, regardless of whether they're reused, I'd recommend making them global as it's far easier to restructure/reorder your document when you don't have to wade through massive complexType definitions. They're also theoretically more portable. There are also cases where you can't acheive certain document structures with nested types - an example of this is using two complexTypes in a sequence that can contain 0 to unbounded instances of each type, in any mixed order. This isn't possible with nested types, but it is with referenced global types.
I've also realized than Intellisense is sometime 'lost', on some big project. Why? No idea. This is why we have bought Visual Assist (from Tomato software) and disabled Intellisense by deleting the dll feacp.dll in the Visual studio subdirectory (C:\Program Files\Microsoft Visual Studio 8\VC\vcpackages\) This is not a solution, just a workaround.
I've also realized than Intellisense is sometime 'lost', on some big project. Why? No idea. This is why we have bought [Visual Assist][1] (from [Tomato software][1]) and disabled Intellisense by deleting the dll feacp.dll in the Visual studio subdirectory (C:\Program Files\Microsoft Visual Studio 8\VC\vcpackages\) This is not a solution, just a workaround. [1]: http://www.wholetomato.com/
The best way to start is with the book **World of Warcraft Programming**. It covers LUA, XML, WarcraftAddOnStudio and the WoW API. The book also has sections on best practices and avoiding common mistakes.
<a href="http://winterdrache.de/freeware/png2ico/">png2ico</a> is what I've always used, and perfect for your situation.
The IE8 beta comes with what I think is the IE Developer toolbar, but it seems to be a lot more powerful than the last time I tried the toolbar on IE7
This has not been tested but I think this should work using mod_rewrite RewriteEngine On RewriteCond %{HTTPS} on RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} Edit: markdown mangled the code but I think you get the idea.
Seconded for e-texteditor. I use it daily and it's great. For the rails side of things though, I'd actually suggest a virtual machine running linux. Ubuntu works well, the only caveat is that you have to install `rubygems` manually, as it does not adhere to the great debian filesystem naming ideology :-( I suggest this because if you want to do "advanced" things, such as installing ImageMagick/RMagick, or memcached, or a number of other plugins which require native C libraries, it becomes very painful very quickly if you're on windows. Microsoft Virtual PC and VMWare both have free options, which work well, and are plenty fast, so this is not a problem.
Seconded for e-texteditor. I use it daily and it's great (although not without it's share of BUGS). For the rails side of things though, I'd actually suggest a virtual machine running linux. Ubuntu works well, the only caveat is that you have to install `rubygems` manually, as it does not adhere to the great debian filesystem naming ideology :-( I suggest this because if you want to do "advanced" things, such as installing ImageMagick/RMagick, or memcached, or a number of other plugins which require native C libraries, it becomes very painful very quickly if you're on windows. A second reason is that unless you are *very* atypical, your production server will likely be running linux too. It's good practice to have your development environment match your deployment environment as closely as possible, to help you find and fix bugs earlier and more easily, and avoid fixing bugs that won't affect your production site (like windows specific ones) Microsoft Virtual PC and VMWare both have free options, which work well, and are plenty fast, so this is not a problem.
There is apaches mod_rewrite, or you could setup apache to direct https://dbadmin.example.com to path/to/example.com/dbadmin on the server <VirtualHost *> ServerName subdomain.domain.com DocumentRoot /home/httpd/htdocs/subdomain/ </VirtualHost>
I would have to say that this is pretty bad practice. Whilst some people might be happy to say that looping through the collection is less efficient to throwing an exception, there is an overhead to throwing an exception. I would also question why you are using a collection to access an item by key when you would be better suited to using a dictionary or hashtable. My main problem with this code however, is that regardless of the type of exception thrown, you are always going to be left with the same result. For example, an exception could be thrown because the object doesn't exist in the collection, or because the collection itself is null or because you can't case myCollect[myObject] to aObject. All of these exceptions will get handled in the same way, which may not be your intention. These are a couple of nice articles on when and where it is usally considered acceptable to throw exceptions: * [Foundations of Programming][1] * [Throwing exceptions in c#][2] I particularly like this quote from the first article: > It is important that exceptions are > thrown only when an unexpected or > invalid activity occurs that prevents > a method from completing its normal > function. Exception handling > introduces a small overhead and lowers > performance so should not be used for > normal program flow instead of > conditional processing. It can also be > difficult to maintain code that > misuses exception handling in this > way. [1]: http://codebetter.com/blogs/karlseguin/archive/2008/05/29/foundations-of-programming-pt-8-back-to-basics-exceptions.aspx [2]: http://www.blackwasp.co.uk/CSharpThrowingExceptions.aspx
I'll add to the excellent answers given above, and talk about boxing and unboxing, and how this applies to Java (although C# has it too). I'll use just Java terminology, because I am more _au fait_ with that. As the answers mentioned, `int` is just a number (called the _unboxed_ type), whereas `Integer` is an object (which contains the number, hence a _boxed_ type). In Java terms, that means (apart from not being able to call methods on `int`), you cannot store `int` or other non-object types in collections (`List`, `Map`, etc.). In order to store them, you must first box them up in its corresponding boxed type. Java 5 onwards have something called _auto-boxing_ and _auto-unboxing_ which allow the boxing/unboxing to be done behind the scenes. Compare and contrast: Java 5 version: Deque<Integer> queue; void add(int n) { queue.add(n); } int remove() { return queue.remove(); } Java 1.4 or earlier (no generics either): Deque queue; void add(int n) { queue.add(Integer.valueOf(n)); } int remove() { return ((Integer) queue.remove()).intValue(); } It must be noted that despite the brevity in the Java 5 version, both versions generate identical bytecode. Thus, although auto-boxing and auto-unboxing is very convenient because you write less code, these operations _do_ happen behind the scenes, with the same runtime costs, so you still have to be aware of their existence. Hope this helps!
It's been awhile since I used FCGI but I think a FCGI process could throw a SystemExit if the thread was taking too long. This could be the web service not responding or even a slow DNS query. Some google results show a similar error with Python and FCGI so moving to mongrel would be a good idea. [This post][1] is my reference I used to setup mongrel and I still refer back to it. Eric [1]: http://blog.codahale.com/2006/06/19/time-for-a-grown-up-server-rails-mongrel-apache-capistrano-and-you/
[The Sieve of Atkin](http://en.wikipedia.org/wiki/Sieve_of_Atkin) is probably what you're looking for, its upper bound running time is O(N/log log N).
I found [this page][1] which shows what the difference between Proc.new and lambda are. According to the page, the only difference is that a lambda is strict about the number of arguments it accepts, whereas Proc.new converts missing arguments to nil. Here is an example IRB session illustrating the difference: irb(main):001:0> l = lambda { |x, y| x + y } => #<Proc:0x00007fc605ec0748@(irb):1> irb(main):002:0> p = Proc.new { |x, y| x + y } => #<Proc:0x00007fc605ea8698@(irb):2> irb(main):003:0> l.call "hello", "world" => "helloworld" irb(main):004:0> p.call "hello", "world" => "helloworld" irb(main):005:0> l.call "hello" ArgumentError: wrong number of arguments (1 for 2) from (irb):1 from (irb):5:in `call' from (irb):5 from :0 irb(main):006:0> p.call "hello" TypeError: can't convert nil into String from (irb):2:in `+' from (irb):2 from (irb):6:in `call' from (irb):6 from :0 The page also recommends using lambda unless you specifically want the error tolerant behavior. I agree with this sentiment. Using a lambda seems a tad more concise, and with such an insignificant difference, it seems the better choice in the average situation. As for Ruby 1.9, sorry, I haven't looked into 1.9 yet, but I don't imagine they would change it all that much (don't take my word for it though, it seems you have heard of some changes, so I am probably wrong there). [1]: http://raulparolari.com/Ruby2/lambda_Proc
You could inject the class (better: method/**delegate**) you use for `DateTime.Now` in the class being tested. Have `DateTime.Now` be a default value and only set it in testing to a dummy method that returns a constant value. **EDIT:** What Blair Conrad said (he has some code to look at). Except, I tend to prefer delegates for this, as they don't clutter up your class hierarchy with stuff like `IClock`...
GetProcessPID is what you need. This takes a ProcessSerialNumber, which you can obtain from GetCurrentProcess.
Managed languages can be easily decompiled because executable must contain a lot of metadata to support reflection. Languages like C++ can be compiled to native code. Program structure can be totally changed during compilation\translation processes. Compiler can easily replace\merge\delete parts of your code. There is no 1 to 1 relationship between original and compiled (native) code.
Managed languages can be easily decompiled because executable must contain a lot of metadata to support [reflection][1]. Languages like C++ can be compiled to native code. Program structure can be totally changed during compilation\translation processes. Compiler can easily replace\merge\delete parts of your code. There is no 1 to 1 relationship between original and compiled (native) code. [1]: http://en.wikipedia.org/wiki/Reflection_%28computer_science%29
How do I style (css) radio buttons and labels?
|html|css|style|radio-button|
Given the code bellow, how do I style the radio buttons to be next to the labels and style the label of the selected radio button differently than the other labels? <div class="input radio"> <fieldset> <legend>What color is the sky?</legend> <input type="hidden" name="data[Submit][question]" value="" id="SubmitQuestion" /> <input type="radio" name="data[Submit][question]" id="SubmitQuestion1" value="1" /> <label for="SubmitQuestion1">A strange radient green.</label> <input type="radio" name="data[Submit][question]" id="SubmitQuestion2" value="2" /> <label for="SubmitQuestion2">A dark gloomy orange</label> <input type="radio" name="data[Submit][question]" id="SubmitQuestion3" value="3" /> <label for="SubmitQuestion3">A perfect glittering blue</label> </fieldset> </div>