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 goo... |
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/... |
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 colu... |
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 co... |
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 co... |
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");
i... |
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 "change... |
|.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 ou... |
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 pa... |
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 out... |
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. ... |
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 wi... |
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 (<>) {
$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 bee... |
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 proje... |
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 ... |
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 wo... |
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 co... |
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... |
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... |
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(:win... |
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 l... |
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 adva... |
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... |
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 ... |
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 cu... |
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 cu... |
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 memor... |
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 o... |
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">
... |
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]
<styl... |
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 ne... |
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... |
[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, ... |
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();
... |
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 ... |
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' ? '' : 'hig... |
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 = HttpConte... |
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 = HttpConte... |
|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 ... |
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 t... |
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 ... |
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\)
... |
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 sugge... |
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... |
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 be... |
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... |
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 m... |
[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:
... |
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 de... |
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. The... |
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... |
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[Subm... |