instruction stringlengths 0 30k ⌀ |
|---|
Using the [GetThumbnailImage ][1] from the .NET [Image][2] class?
[1]:http://msdn.microsoft.com/en-us/library/system.drawing.image.getthumbnailimage.aspx
[2]:http://msdn.microsoft.com/en-us/library/system.drawing.image.aspx |
I suppose your best solution would be using the [GetThumbnailImage ][1] from the .NET [Image][2] class.
// Example in C#, should be quite alike in ASP.NET
// Assuming filename as the uploaded file
using ( Image bigImage = new Bitmap( filename ) )
{
// Algorithm simplified for purpose o... |
It's probably not going to have a whole lot of benefit unless you have a direct application for it. If you're going for general knowledge, C/C++ is a fine place to start.
That said, the challenges that assembly poses are very interesting and it requires a pretty different mindset to get things done.
I spent a li... |
G'day,
We actually faced this problem at a site where I was contracting previously.
One bloke sat down and wrote tools, mainly shell scripts, to
1. check out the current code base every hour or so and do a build to check if it was broken, and
2. check out the latest good build and do a complete build and r... |
The first reason that comes to mind is **historical**:
Since most C, C++, and Java programmers are not accustomed to having such freedoms, they do not demand them.
But an actual, and more valid, reason is that the **language complexity would increase**:
First of all, should the objects be compared with `.Equal... |
The first reason that comes to mind is **historical**:
Since most C, C++, and Java programmers are not accustomed to having such freedoms, they do not demand them.
Another, more valid, reason is that the **language complexity would increase**:
First of all, should the objects be compared with `.Equals()` or wi... |
windows.h is declared at the top of IOCompletionPort.h as an include - I was sick of seeing 7 lines just to include 1 file so I have wrapped it its own file and includes that itself. This also contains some additional #defines (ie ULONG_PTR) as our main app won't compile with the Platform SDK installed:-(
1. That i... |
Big O notation is useful because it's easy to work with and hides unnecessary complications and details (for some definition of unnecessary). One nice way of working out the complexity of divide and conquer algorithms is the tree method. Let's say you have a version of quicksort with the median procedure, so you split ... |
You should never ever use the money datatype to store monetary values. If you do any calculations you will get truncated results. Run the following to see what I mean
DECLARE
@mon1 MONEY,
@mon2 MONEY,
@mon3 MONEY,
@mon4 MONEY,
@num1 DECIMAL(19,4),
@num2 DECIMAL(19,4),
@nu... |
Are you sure you have debug build? Or rather you have all PDB's enabled? Try WindDbg on your executable and check with !lmi command what is visible.
Is whole code properly instrumented?
Also consider using something else like [free Visual Leak Detector][1] or Microsoft's tool LeakDiag.
[1]: http://www.code... |
How to extract audio from video to MP3:
<http://www.dvdvideosoft.com/guides/dvd/extract-audio-from-video-to-mp3.htm>
How to Convert a Video Podcast to Audio Only:
<http://www.legalandrew.com/2007/03/10/how-to-convert-a-video-podcast-to-audio-only/> |
Via [WebServiceX][1], you can send SMS messages anywhere in the world. For phone calls I'd use [Asterisk][2].
[1]: http://www.webservicex.net/WCF/ServiceDetails.aspx?SID=20
[2]: http://www.codeproject.com/KB/IP/AsteriskIAXClientWrapper.aspx |
When you edit your video, doesn't your editor provide you an option to split out the audio? |
WPF Get Element(s) under mouse |
|wpf|element|visualtree|visualtreehelper| |
Is there a way with WPF to get an array of elements under the mouse on a MouseMove event? |
What platform is your own machine? What format is the video podcast?
You could possibly get [Handbrake][1] to do this (Windows, Linux and Mac), I don't know if it's scriptable at all but I think it can be used to separate audio and video.
edit: There *is* a commandline interface for Handbrake, but it appears I ... |
Record or create a macro:
Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module RefreshDependencies
Sub TemporaryMacro()
DTE.ActiveWindow.Object.GetItem("Project... |
Record or create a macro:
Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module RefreshDependencies
Sub TemporaryMacro()
DTE.ActiveWindow.Object.GetItem("Project... |
Use [Win32::Process->Create][1] with DETACHED_PROCESS parameter
[1]: http://search.cpan.org/~jdb/Win32-Process-0.14/Process.pm |
Can you use the [VisualTreeHelper.HitTest][1] ?
<http://lukieb.blogspot.com/2008/07/visualtreehelperhittest.html>
[1]: http://msdn.microsoft.com/en-us/library/system.windows.media.visualtreehelper.hittest.aspx |
For SQL 2005:
Assuming the following table definition:
CREATE TABLE [dbo].[Test](
[ID] [int] IDENTITY(1,1) NOT NULL,
[somevalue] [nchar](10) NULL,
)
You can use the following:
INSERT INTO Test(somevalue)
OUTPUT INSERTED.ID
VALUES('asdfasdf')
Which will return the val... |
a simple way to capitalise the first letter of each word (seperated by a space)
$words = explode(” “, $string);
for ($i=0; $i<count($words); $i++) {
$s = strtolower($words[$i]);
$s = substr_replace($s, strtoupper(substr($s, 0, 1)), 0, 1);
$result .= “$s “;
}
$string = trim($result);... |
The modern approach is to make use of the operating system to multiplex many network sockets for you, freeing your application to only processing active connections with traffic.
Whenever you open a socket it's associated it with a selector. You use a single thread to poll that selector. Whenever data arrives, the s... |
how to get the googlebot to get the correct GEOIPed content!? |
|google|seo|international| |
OK. This problem is doing my head in. And I dont know if there even IS a definitive answer.
We have a website, lets call it finalcog.com. It's a UK-based site, with UK based content. Google knows about it, and we have done a load of SEO on it. All is well.
**Except**, we are about to relaunch **final cog, the GLO... |
You do not mention which language you would like the solution in so here is some pseudo code.
Loop through each character
If the previous character was an alphabet letter
Make the character lower case
Otherwise
Make the character upper case
End loop |
I agree with Mark. I think it's similar to learning MSIL when writing in C#, VB.NET, or another .NET language. It helps to know what's going on under the hood, but you could go your entire life creating applications that work and never need it. |
[libxml2](http://xmlsoft.org/python.html) has a number of advantages:
1. Compliance to the [spec](http://www.w3.org/TR/xpath)
2. Active development and a community participation
3. Speed. This is really a python wrapper around a C implementation.
4. Ubiquity. The libxml2 library is pervasive and thus well teste... |
Tess' blog was a great resource. Eventually I managed to figure out how to do remote debugging which means I didn't have to look at the crash dump.
For the general community, here are some links I found useful:
- [Remote debugging][1], how to set up and run it.
- [Crash dumps][2], how to save and debug them.... |
No. Unless you want to for fun, you really don't need learn assembly.
There are some things you need to know assembly for, like driver creation, OS development, exploit development, but aside from that, I personally believe you can quite happily code forever without knowing it.
If you do need to learn assembly, y... |
SQL Group By with an Order By |
|sql|mysql| |
I have a table of tags and want to get the highest count tags from the list.
Sample data looks like this
id (1) tag ('night')
id (2) tag ('awesome')
id (3) tag ('night')
using
SELECT COUNT(*), `Tag` from `images-tags`
GROUP BY `Tag`
gets me back the data I'm looking for perfectly. ... |
You should be able to just do something like this:
using (SPSite site = new SPSite("http://yoursite/subsite"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["DocLibraryName"];
SPListItemCollection items = list.GetItems(list... |
The reason Stack Overflow has accurate view counts is that it only count each view/user once.
Third-party hit counter (and web statistics) application often filter out search engines and display them in a separate window/tab/section. |
How do you automatically set the focus to a textbox when a web page loads? |
|javascript|html| |
OK, this has to be insanely easy but I honestly don't know how to do it. How do you automatically set the focus to a textbox when a web page loads?
Is there an HTML tag to do it or does it have to be done via javascript? |
Keep in mind if your tests involve actual resources such as databases or filesystems then what you are doing are *integration tests* rather than *unit tests*. Integration tests by nature require some preliminary setup whereas unit tests should be able to run independently without the need for this.
You could look in... |
Keep in mind if your tests involve actual resources such as databases or filesystems then what you are doing are *integration tests* rather than *unit tests*. Integration tests require some preliminary setup whereas unit tests should be able to run independently.
You could look into the use of a dependency injection... |
While I understand the problem that Jeff, et. al. have with regions, what I *don't* understand is why hitting CTRL-M,CTRL-L to expand all regions in a file is so difficult to deal with. |
I prefer #regions myself, but an old coworker couldn't stand to have things hidden. I understood his point once I worked on a page with 7 #regions, at least 3 of which had been auto-generated and had the same name, but in general I think they're a useful way of splitting things up and keeping everything less cluttered. |
Check Tools | Options | Directories | Libraries (going from memory here) and ensure that you're not missing the common-all-garden variety lib directories (again, without VC6 in front of me, I can't tell you what they are) |
Presuming you haven't futzed around with the Project settings deleting something you ought not have (which is where I'd expect external dependencies like User32.lib to be):
Check Tools | Options | Directories | Libraries (going from memory here) and ensure that you're not missing the common-all-garden variety lib di... |
As with anything abstraction creates complexity, and so the complexity of doing N-tiered should be properly justified, e.g., does N-tiered actually benefit the system? There *will* be small systems that will work best with N-tiered, although a lot of them will not.
Also, even if your system is small at the moment, y... |
I work with a student management system which uses UUID's in the form of an integer. They have a table which hold the next unique ID.
Although this is probably a good idea for an architectural point of view, it makes working with on a daily basis difficult. Sometimes there is a need to do bulk inserts and having a U... |
I prefer partial classes as opposed to regions.
Extensive use of regions by others also give me the impression that someone, somewhere, is violating the Single Responsibility Principle and is trying to do too many things with one object. |
I can't say about the web side of your question. But uuids are great for n-tier applications. PK generation can be decentralized: each client generates it's own pk without risk of collision.
And the speed difference is generally small.
Make sure your database supports an efficient storage datatype (16 bytes, 128 b... |
If you want the context menu to be dependent on the selected item you're best move I think is to use Jonesinator's code to select the clicked item. Your context menu content can then be dependent on the selected item.
Selecting the item first as opposed to just using it for the context menu gives a few advantages. T... |
Does anyone have a good Proper Case algorithm |
|string|c#|algorithm| |
Does anyone have a trusted Proper Case or PCase algorithm (similar to a UCase or Upper)? I'm looking for something that takes a value such as "GEORGE BURDELL" or "george burdell" and turns it into "George Burdell".
I have a simple one that handles the simple cases. The ideal would be to have something that can han... |
|string|algorithm| |
|algorithm|string| |
Does anyone have a trusted Proper Case or PCase algorithm (similar to a UCase or Upper)? I'm looking for something that takes a value such as "GEORGE BURDELL" or "george burdell" and turns it into "George Burdell".
I have a simple one that handles the simple cases. The ideal would be to have something that can han... |
There's also this neat Perl script for title-casing text.
http://daringfireball.net/2008/08/title_case_update
But it sounds like by proper case you mean.. for people's names *only*. |
G'day,
I'd start by looking at the metaphor you want to use for your thread framework.
Maybe "leader follower" where a thread is listening for incoming requests and when a new request comes in it does the work and the next thread in the pool starts listening for incoming requests.
Or thread pool where the same... |
Have you thought about including links for different sites on the homepage? Google could follow those and index their content as well - in turn indexing the UK content. |
The answer from Ubiguchi had what I needed, except that I now think a redirect is the way to go, via the link to the HTTP 1.1 specifiction section on response codes. It turns out that I actually need a 301 redirect because the URI I'm redirecting to is more 'correct' and stable, and should therefore be used for future ... |
Sending Email in C#.NET Through Gmail |
|c#|email|gmail| |
Instead of relying on my host to send email, I was thinking of sending the messages though my gmail account. The emails are personalized emails to the bands I play on my show. Has anyone had success doing this? |
You are either going to have to do what you said in your question with AJAX. Or exclude out User-Agent strings that are known search engines. The only sure way to stop bots are with AJAX. |
I think all bets are off here; I certainly wouldn't depend on any given behaviour. The only safe thing to do is to get the node from its parent again. |
According to [Wikipedia][1] modern browsers can handle favicons in PNG format, so maybe you could just generate that?
Alternatively the [ICO article][2] describes the format...
[1]: http://en.wikipedia.org/wiki/Favicon
[2]: http://en.wikipedia.org/wiki/ICO_(icon_image_file_format) |
Raymond D. Hettinger did an excellent talk on this subject at PyCon 2008 called 'Core Python Containers - Under the Hood'. I haven't found a video of the talk online yet, but there are some photos of the pertinent slides from EuroPython in [a blog][1]. Also, it looks like Mr Hettinger is doing the same talk at [PyCon U... |
Raymond D. Hettinger does an excellent talk about Python's built-in collections called 'Core Python Containers - Under the Hood'. The version I saw focussed mainly on `set` and `dict`, but `list` was covered too.
I haven't found a video of the talk online yet, but there are some photos of the pertinent slides from E... |
Already answer, but when I took Operating Systems in college we started with an early linux kernel and added simplistic modern features (basic file systems, virtual memory, multitasking, mutexes). Good fun. You get to skip some of the REALLY crazy low level assembly only stuff for mucking w/ protected mode and page tab... |
If you want to do this in a platform independent way, [Proc::Background][1] is probably the best way.
[1]: http://search.cpan.org/~bzajac/Proc-Background/lib/Proc/Background.pm |
How many app.config files are you allowed to have per AppDomain? |
|.net|configuration| |
I'm hoping there's a way to avoid custom configuration files if an application runs in a single AppDomain. |
Most carriers provide an email address that you can send text messages to — for example, with Verizon, you can send an email to *phonenumber@vtext.com* and it will show up as a text message to that number.
[Wikipedia][1] has a full list of the carrier-provided email addresses.
By sending text messages as "e... |
|algorithm|codingstyle|camelcasing|pascalcasing| |
|algorithm|coding-style|camelcasing|pascalcasing| |
[@SqlMenace](#40297)
>>There are other problems with GUIDs, you see GUIDs are not sequential, so inserts will be scattered all over the place, this causes page splits and index fragmentation
Not true. **Primary key != clustered index.**
If the clustered index is another column ("inserted_on" springs to mind) t... |
Keep it in a configuration file. Use a robust data access strategy provided by tools like NHibernate or Linq to Sql. |
The way that I've seen this done in the past is have
Employees (EmployeeId, DateModified, < Employee Fields > , boolean isCurrent );
You never "update" on this table, just insert new rows. For any given EmployeeId, only 1 row can have isCurrent == 1.
The complexity of maintaining this can be hidden by v... |
The way that I've seen this done in the past is have
Employees (EmployeeId, DateModified, < Employee Fields > , boolean isCurrent );
You never "update" on this table, just insert new rows. For any given EmployeeId, only 1 row can have isCurrent == 1.
The complexity of maintaining this can be hidden by v... |
The way that I've seen this done in the past is have
Employees (EmployeeId, DateModified, < Employee Fields > , boolean isCurrent );
You never "update" on this table (except to change the valid of isCurrent), just insert new rows. For any given EmployeeId, only 1 row can have isCurrent == 1.
The complex... |
The way that I've seen this done in the past is have
Employees (EmployeeId, DateModified, < Employee Fields > , boolean isCurrent );
You never "update" on this table (except to change the valid of isCurrent), just insert new rows. For any given EmployeeId, only 1 row can have isCurrent == 1.
The complex... |
Check out this post by [Ted Dziuba][2]: [Practical Unique Identifiers][1]
[1]:http://teddziuba.com/2008/07/practical-unique-identifiers.html
[2]:http://stackoverflow.com/users/104/ted-dziuba |
Check out this post by [Ted Dziuba][2]: [Practical Unique Identifiers][1]
I think using a GUID would be the better choice in your situation. It takes up more space but it's more secure.
[1]:http://teddziuba.com/2008/07/practical-unique-identifiers.html
[2]:http://stackoverflow.com/users/104/ted-dziuba |
>What is a good example of when to use the bitwise operator instead of the "short-circuited boolean"?
Suppose you have flags, say for file attributes. Suppose you've defined READ as 4, WRITE as 2, and EXEC as 1. In binary, that's:
READ 0100
WRITE 0010
EXEC 0001
Each flag has one bit set, an... |
>What is a good example of when to use the bitwise operator instead of the "short-circuited boolean"?
Suppose you have flags, say for file attributes. Suppose you've defined READ as 4, WRITE as 2, and EXEC as 1. In binary, that's:
READ 0100
WRITE 0010
EXEC 0001
Each flag has one bit set, an... |
I can answer you that in SQL server if you use a uniqueidentifier (GUID) datatype and use the NEWID() function to create values you will get horrible fragmentation because of page splits. The reason is that when using NEWID() the value generated is not sequential. SQL 2005 added the NEWSEQUANTIAL() function to remedy t... |
Depending on your client, some of them offer a pre-commit hook that you can implement something that simply "touches" the file and flags it as changed. If your using something like Visual Studio you could create a post build task that would "touch" the file but you would have to make sure that you do a build before com... |
I'm not a fan of partial classes - I try to develop my classes such that each class has a very clear, single issue for which it's responsible. To that end, I don't believe that something with a clear responsibility should be split across multiple files. That's why I don't like partial classes.
With that said, I'm on... |
We use [DevPartner](http://www.compuware.com/solutions/default.htm) with Visual Studio 2005. It gives you performance analysis of the specific projects in your solution you want to look at. We also use it for memory management analysis, and error analysis. Is commercial tool, so it's not free. |
<html>
<head>
<script language="javascript" type="text/javascript">
function SetFocus(InputID)
{
document.getElementById(InputID).focus();
}
</script>
</head>
<body onload="SetFocus("Box2")">
<input id="Box1" size="30" /><br/>
<input id... |
You don't really need to use AJAX, just use JavaScript to add an iFrame off screen. KEEP IT SIMPLE<br/>
<script type="javascript">
document.write('<iframe src="myLogScript.php" style="visibility:hidden" width="1" height="1" frameborder="0">');
</script> |
If it's for a UK then [Esendex][1] provides a nice WebService although BT's Web21C does seem to be that little bit cheaper.
[1]: http://www.esendex.com/en/Developers/SDKs/NET-SMS-SDK/ |
The same ones you'd take for Safari, as they share the same rendering engine (with a slight version mismatch). |
As default the app config file of the default appdomain is in the process exe’s directory and named the same as the process exe + ".config". Also, note that a web.config file is an app.config - ASP.NET sets that as the config file for your appdomain.
To change the config file, set an AppDomainSetup.ConfigurationFi... |
I think first and foremost you should focus on using HTML and scripting that follows the standards.
After you have that running, file a bug report then make the browser-specific tweaks. If Chrome is worth a flip you <i>shouldn't</i> have to tweak things for it. |
An AJAX call will do it, but usually search engines will not load images, javascript or CSS files, so it may be easier to include one of those files in the page, and pass the URL of the page you want to log a request against as a parameter in the file request.
Even easier would be to use a log analytics tool like [a... |
An AJAX call will do it, but usually search engines will not load images, javascript or CSS files, so it may be easier to include one of those files in the page, and pass the URL of the page you want to log a request against as a parameter in the file request.
For example, in the page...
http://www.example.com/ex... |
ModalPopupExtender and SharePoint |