instruction stringlengths 0 30k ⌀ |
|---|
I'm looking for a .Net library that will accept an image or filename and an aspect ratio, and crop the image to that aspect ratio. That's the easy part: I could do it myself. But I also want it to show a little intelligence in choosing exactly what content gets cropped, even if it's just picking which edge to slice.
... |
WPF DatePicker: Whats the best? |
|wpf| |
I need a Datepicker for a WPF application. What is considered to be the best one?
Thank you
|
WPF DatePicker: What is the best? |
He may be correct for the specific use case he is thinking of. A stored procedure will probably execute faster for some complex set of SQL, that can be arbitrarily tuned. However, something you get from things like hibernate is caching. This may prove much faster for the lifetime of your actual application. |
Multimap in Scala |
|generics|scala| |
The term slug comes from the newspaper/publishing business. It's a short title that's used to identify a story in progress. People interested in URL semantics started using a short, abbreviated title in their URLs. It also pays off in SEO land, as keywords in URLs add importance to a page.
Ironically, lots of web... |
If I understand correctly, you want a heuristic to estimate the number of comments in an HTML page which is known to be a blog post, yes?
Very often, a specific blog will have some features which make it easy to work out. If you look at mine over at [http://kstruct.com/][1] you'll see that all the pages with comment... |
To elaborate on Accordion Guy's response:
Notice that `Proc.new` creates a proc out by being passed a block. I believe that `lambda {...}` is parsed as a sort of literal, rather than a method call which passes a block. `return`ing from inside a block attached to a method call will return from the method, not the b... |
I sure as hell can't. Small errors explode into pages and pages of unreadable junk. Usually early in the morning, before coffee. :(
My only advice is to take a deep breath, start at the top and try and parse the important pieces of information. (I know, easier said than done, right?). |
In the embedded world, the "modulus" operations you need to do are often the ones that break down nicely into bit operations that you can do with '&' and '|' and sometimes '>>'.
|
I want to look into emacs further, but I just can't use it for long stretches of time; it hurts my hands. Am I doing something horribly wrong? |
Is there an alternative to using % (modulus) in C/C++? |
|c|c++|modulo| |
I read somewhere once that the modulus operator is inefficient on small embedded devices such as 8 bit micros without integer division operator. Perhaps someone can confirm this but I thought the difference is 5-10 time slower than with an integer division operation.<p>
Is there another way to do this other than kee... |
How to make the process of debugging an APS.NET application less time consuming? |
|asp.net|debugging| |
I'm comparing it Java where you can start your application server in debug mode, then attach your IDE to the server. And you can change your code "on the fly" without restarting the serer. As long as your changes don't affect any method signatures or fields you can just hit recompile for a class and the application ser... |
How to make the process of debugging an ASP.NET Sharepoint applications less time consuming? |
|asp.net|debugging|sharepoint| |
I'm comparing it Java where you can start your application server in debug mode, then attach your IDE to the server. And you can change your code "on the fly" without restarting the server. As long as your changes don't affect any method signatures or fields you can just hit recompile for a class and the application se... |
How to make the process of debugging ASP.NET Sharepoint applications less time consuming? |
|asp.net|sharepoint|debugging| |
I posted a question which might help you as it discusses some of the issues:
[should-i-be-worried-about-obfuscating-my-net-code][1]
[1]: http://beta.stackoverflow.com/questions/12075/should-i-be-worried-about-obfuscating-my-net-code |
I would look at the configuration of your logger. (Or provide it with one, if it is using a default config)
For example, when using Hibernate with an active Log4J setup, Hibernate will automatically join in with the Log4J instance that you set up in your own application
It can be tuned, as per the normal Log4J co... |
This will be per-sign-up and not per-post, right? Because that would just kill the site, even with jQuery automation. |
Use [libxml](http://xmlsoft.org/), which performs validation *and* has a streaming mode. |
You can use WMI to figure this out. The [Win32_BootConfiguration][1] class will tell you both the logical drive and the physical device from which Windows boots. Specifically, the Caption property will tell you which *device* you're booting from.
For example, in powershell, just type **gwmi Win32_BootConfiguration... |
Request.RawUrl
|
From <http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.dc34982_1500/html/mig_gde/mig_gde160.htm>:
Inner and outer tables
The terms outer table and inner table describe the placement of the tables in an outer join:
* In a left join, the outer table and inner table are the left and right tables resp... |
You need to change the ProductCode between each version, if you don't do this you will get the behavior you are seeing. The ProductCode is seen in the project properties. Check out the [MSDN Online Help for ProductCode][1] to understand better.
[1]: http://msdn.microsoft.com/en-us/library/aafz9hx4.aspx |
Use a simple text captcha and then ask the users to enter the answer backwards or only the first letter, or the last, or another random thing.
Another idea is to make a ascii image, like this (from Portal game end sequence):
.,---.
,/XM#MMMX;,
... |
Insert current date in Excel template at creation |
|excel|templates| |
I'm building an excel template (*.xlt) for a user here, and one of the things I want to do is have it insert the current date when a new document is created (ie, when they double-click the file in windows explorer). How do I do this? |
If it works without a hitch then you don't need .NET 3.5 Framework for now. Installing .NET 3.5 Framework is easy enough to do along with later versions of your software *if and only if your software stops working at that point*. |
So there are two levels of "work with Boo". One would be all the code (namely, the Controllers), and the other would be the views.
For the code, I assume Boo compiles to standard .NET assemblies, so simply properly following the naming conventions using by ASP.NET MVC should allow you to write Controllers. You will ... |
Yeah - In a way you're both asking and answering the question your self.. But that is one of the two options I can think of. The reasons that might be a problem is that you loose some of the features/control you get from the MediaElement control. Another option is to do this:
1. Add your MediaElement to your page.
... |
Yeah - In a way you're both asking and answering the question your self.. But that is one of the two options I can think of. The reasons that might be a problem is that you loose some of the features/control you get from the MediaElement control. Another option is to do this:
1. Add your MediaElement to your page.
... |
Kibbee, you were right! It was two files with the same name in different folders. I was setting the breakpoint in the correct file on line 58 - it was putting the breakpoint on the other file at line 58. I was finally able to set a breakpoint by using the "Debug-->New Breakpoint-->Break at Function Name" menu option... |
If you just use GET and POST, it's still RESTful. Your web service may only do things which only required GET or POST, so that's fine. |
What language is this? It doesnt overflow anything in c...
Also, you can try creating a lookup table on the heap, or use a map |
Why is String.Format static? |
|.net|string| |
Compare
String.Format("Hello {0}", "World");
with
"Hello {0}".Format("World");
Why .Net designers choose static method over instance method? What do you think? |
|.net|string| |
Compare
String.Format("Hello {0}", "World");
with
"Hello {0}".Format("World");
Why did the .Net designers choose a static method over an instance method? What do you think? |
Yes, you can live without PUT and DELETE.
This article tells you why:
<http://www.artima.com/lejava/articles/why_put_and_delete.html>
While to true RESTafrians this may be heresy, in the real world you do what you can, with what you have. Be as rational as you can and as consistent with your own convention as y... |
If its not hurting the performance of the site, I think its a good thing. If you had 1000 clients to the same site all doing that, yeah, block it.
But if the site was built for that client, I think its fair enough they do that. |
caching is generally a good idea for this kind of thing. Since fibonacci numbers are constant, you can cache the result once you have calculated it. A quick c/pseudocode example
class fibstorage {
bool has-result(int n) { return fibresults.contains(n); }
int get-result(int n) { return fib... |
Try [ruby2ruby][1]
[1]: http://seattlerb.rubyforge.org/ruby2ruby/ |
The first thing I did when I got to upgrade to VS2008 and C#3, was to do this
public static string F( this string format, params object[] args )
{
return String.Format(format, args);
}
So I can now change my code from
String.Format("Hello {0}", Name);
to
"Hello {0}".F(Name)... |
|c++|c|modulo| |
I read somewhere once that the modulus operator is inefficient on small embedded devices such as 8 bit micros without integer division operator. Perhaps someone can confirm this but I thought the difference is 5-10 time slower than with an integer division operation.<p>
Is there another way to do this other than kee... |
These are the ones I use daily.
- prop
- try
- if
- else
- for
- foreach
- mbox - Message box stub
- The ability to role your own. I have one for Property that are saved in the view state, methods a custom class example. |
Depending on how you code, you *may* see a productivity increase. For background, I'm also a long-time vim user, but I learned emacs about 2 years ago, and now use them interchangeably.
What drove me to the point of actually learning emacs was its useful ability to have a large number of files open at once, and to ... |
I've always used the term "magic number" differently, as an obscure value stored within a data structure which can be verified as a quick validity check. For example gzip files contain 0x1f8b08 as their first three bytes, Java class files start with 0xcafebabe, etc.
You often see magic numbers embedded in file forma... |
I'm trying to mixin the MultiMap trait with a HashMap like so:
val children:MultiMap[Integer, TreeNode] =
new HashMap[Integer, Set[TreeNode]] with MultiMap[Integer, TreeNode]
The definition for the MultiMap trait is:
trait MultiMap[A, B] extends Map[A, Set[B]]
Meaning that a MultiMap of ty... |
[CompareIt][1] is good, I find using the command line interface for svn, that it merges more for me, where tortoise picks up on things and asks you.
[1]: http://www.grigsoft.com/wincmp3.htm |
It's risky to spawn threads from the code-behind of an ASP.NET page, because the worker process will get recycled occasionally and your thread will die.
If you need to kick off long-running processes as a result of user actions on web pages, your best bet is to drop a message off in MSMQ and have a separate backgrou... |
If all you need is source control, TFS is overkill. My previous employer had TFS, VSS, and Subversion in their enterprise. We didn't have Active Directory or Exchange Server 2003 in our enterprise, so we ended up creating separate users on the TFS server so developers could use it. We had the same sorts of problems ... |
To me primary difference between BDD and TDD is focus and wording. And words are important for communicating your intent.
TDD directs focus on testing. And since in "old waterfall world" tests come after implementation, then this mindset leads to wrong understanding and behaviour.
BDD directs focus on behaviour a... |
Int32.TryParse is probably a tad easier:
public static int? ToNullableInt32(this string s)
{
int i;
if (Int32.TryParse(s, out i)) return i;
return null;
}
**Edit** @Glenn Int32.TryParse is "built into the framework". It and Int32.Parse are *the* way to parse strings to int... |
How do you retrieve the commit message and file list for a particular revision? |
|svn|version-control| |
I need to deploy a few files that were checked in sometime ago (can't remember the exact ones), so I'm looking to get a list so I can deploy just those files. What is the svn command to do this? |
>>> import datetime
>>> datetime.date (2000, 2, 1) - datetime.timedelta (days = 1)
datetime.date(2000, 1, 31)
>>>
|
EDIT: See @[Blair Conrad's answer](#43663) for a cleaner solution
---
>>> import datetime
>>> datetime.date (2000, 2, 1) - datetime.timedelta (days = 1)
datetime.date(2000, 1, 31)
>>>
|
`svn log` has a `--verbose` parameter. I don't have a repository here to test with, but does that return a list of modified files?
You can also use `svn diff -r <revision>` to retrieve the full change details, which you can parse or read manually to find out which files were changed. |
Not in the case you describe,
But the GC will call the **Finalizer** for you, if you have one.
HOWEVER. The next garbage collection ,instead of being collected, the object will go into the finalization que, everything gets collected, then it's finalizer called. The next collection after that it will be freed.
... |
The .Net Garbage Collector calls the Object.Finalize method of an object on garbage collection. By **default** this does **nothing** and must be overidden if you want to free additional resources.
Dispose is NOT automatically called and must be **explicity** called if resources are to be released, such as within a ... |
No, it's not called.
But this makes easy to don't forget to dispose your objects. Just use the `using` keyword.
I did the following test for this:
class Program
{
static void Main(string[] args)
{
Foo foo = new Foo();
foo = null;
Console.WriteLi... |
reassign value to query string parameter |
I'm building an excel template (*.xlt) for a user here, and one of the things I want to do is have it insert the current date when a new document is created (ie, when they double-click the file in windows explorer). How do I do this?
**Update:** I should have added that I would prefer not to use any vba (macro). I... |
You could also make the ListView ownerdraw. You then have complete control over how the items look whether they are selected or not or whether the ListView itself is enabled or not. The DrawListViewItemEventArgs provides a way to ask the ListView to draw individual parts of the item so you only have to draw the bits yo... |
@Thomas Kammeyer:
Note that Atan(1.0) is quite often hardcoded, so 4*Atan(1.0) is not really an 'algorithm' if you're calling a library Atan function (an quite a few already suggested indeed proceed by replacing Atan(x) by a series (or infinite product) for it, then evaluating it at x=1.
Also, **there are very fe... |
Possible to create REST web service with ASP.NET 2.0 |
|web-services|rest| |
Is it possible to create a REST web service using ASP.NET 2.0? The articles and blog entries I am finding all seem to indicate that ASP.NET 3.5 with WCF is required to create REST web services with ASP.NET.
If it is possible to create REST web services in ASP.NET 2.0 can you provide an example.
Thanks! |
if you need the full URL as everything from the http to the querystring you will need to concatenate the following variables
Request.ServerVariables("HTTPS") // to check if it's HTTP or HTTPS
Request.ServerVariables("SERVER_NAME")
Request.ServerVariables("SCRIPT_NAME")
Request.ServerVariables("Q... |
[This][1] is a good article (be sure to read the other linked article in it) that discusses looking at th scheduled tasks on remote machines. It is not exactly what you were asking for but it should get you headed in the right direction.
[1]: http://myitforum.com/cs2/blogs/yli628/archive/2008/07/28/powershell-sc... |
Having a single exit point reduces [Cyclomatic Complexity][1] and therefore, *in theory*, reduces the probability that you will introduce bugs into your code when you change it. Practice however, tends to suggest that a more pragmatic approach is needed. I therefore tend to aim to have a single exit point, but allow ... |
I would only add a couple things to Rob's answer:
First, Make sure the amount of data involved in the test cases is similiar to production values. In other words if your queries are normally against tables with hundreds of thousands or rows, then create such a test environment.
Second, make everything else eq... |
WScript.Shell and blocking execution? |
|shell|vbscript|wsh| |
I'm using WScript to automate some tasks, by using WScript.Shell to call external programs.
However, right now it does not wait for the external program to finish, and instead moves on. This causes issues because I have some tasks dependant on others finishing first.
I am using code like:
ZipCommand = "7za... |
Using JQuery, what is the best way to set onclick event listeners for radio buttons? |
|javascript|jquery| |
For the following HTML:
<form name="myForm">
<label>One<input name="area" type="radio" value="S" /></label>
<label>Two<input name="area" type="radio" value="R" /></label>
<label>Three<input name="area" type="radio" value="O" /></label>
<label>Four<input name="area" type="radio" val... |
For the following HTML:
<form name="myForm">
<label>One<input name="area" type="radio" value="S" /></label>
<label>Two<input name="area" type="radio" value="R" /></label>
<label>Three<input name="area" type="radio" value="O" /></label>
<label>Four<input name="area" type="radio" val... |
For the following HTML:
<form name="myForm">
<label>One<input name="area" type="radio" value="S" /></label>
<label>Two<input name="area" type="radio" value="R" /></label>
<label>Three<input name="area" type="radio" value="O" /></label>
<label>Four<input name="area" type="radio" val... |
I can think of situations where either of the first two flavours makes sense:
1. If the needle needs pre-processing, like in the Knuth-Morris-Pratt algorithm, <code>needle.findIn(haystack)</code> (or <code>pattern.findIn(text)</code>)makes sense, because the needle object holds the intermediate tables created for th... |
Use [lxml][1] which is the best xml/html library for python.
import lxml.html
t = lxml.html.fromstring("...")
t.text_content()
And if you just want to sanitize the html look at the lxml.html.clean [module][2]
[1]: http://codespeak.net/lxml/lxmlhtml.html
[2]: http://codespeak.net/lxml/lxmlh... |
Is this minimum spanning tree algorithm correct? |
|algorithm|correctness| |
The minimum spanning tree problem is to take a connected weighted graph and find the sub set of it's edges with the lowest total weight that keeps the connected restriction but results in an acyclic graph.
The algorithm I am considering is:
- Find all cycles.
- remove the largest edge from each cycle.
The... |
The minimum spanning tree problem is to take a connected weighted graph and find the sub set of it's edges with the lowest total weight that keeps the connected restriction but results in an acyclic graph.
The algorithm I am considering is:
- Find all cycles.
- remove the largest edge from each cycle.
The... |
The minimum spanning tree problem is to take a connected weighted graph and find the sub set of it's edges with the lowest total weight that keeps the connected restriction but results in an acyclic graph.
The algorithm I am considering is:
- Find all cycles.
- remove the largest edge from each cycle.
The... |