instruction
stringlengths
0
30k
To maximize a window: Alt+Space, X To restore a window: Alt+Space, R To minimize a window: Alt+Space, N To close a window: Alt+Space, C
OK the twist of the gist is as follows: I was using the Process API to close the second virtual machine, but it wouldn't work. The reason is that my second application is an Eclipse RCP Application, and I launched it using the eclipse.exe launcher included. However, that means that the Process API destroy() me...
Ummm, look here: http://www.adobe.com/devnet/flex/articles/struts_06.html I think that sample implies that declaring your mxml file as iso-8859-1 might do the trick, but I really don't think so. I might be wrong but as far as I know the Flash player only handles UTF-8 encoding. I've searched for a link to an o...
Why you just do not extract the body of the for cycle into a separate function? Then you can do the funny stuff in the extracted function. void DrawScaleX(HDC dc, int step, int x0, int x1, int y0, int y1) { for(int x = x0; x < x1; x += step) { DrawScale(dc, x, y0, x, y1); ...
Check the return value of scanf()! From the man page: "scanf returns the number of input items assigned, which can be fewer than provided for, or even zero, in the event of a matching failure. Zero indicates that, while there was input available, no conversions were assigned; typically this is due to a...
Steve's answer works. The problem with your attempt to reproduce ESV's script is that you're using `$input`, which is a reserved variable (it automatically collects multiple piped input into a single variable). You should, however, use .Replace() unless you need the extra feature(s) of -replace (it handles regular e...
cscope has always been my favorite. There is also cbrowser, but I have not tried it. ctags is also used a lot.
How do I drag and drop files into C#?
|c#|drag-and-drop|
I've seen this done in Borland's Turbo C++ environment, but I'm not sure how to go about it for a C# app I'm working on. Are there best practices or gotchas to look out for?
|c#|winforms|drag-and-drop|
Another alternative: 1. Study for 10 years to become a really good programmer 2. Apply for (and get) a job at Microsoft in the Visual Studio team 3. Fix the bug
I've used [JavaService](http://forge.objectweb.org/projects/javaservice/) before with good success. It hasn't been updated in a couple of years, but was pretty rock solid back when I used it.
I would highly consider uninstalling and then installing Visual Studio again. Afterwards make sure you have installed available service packs for your VS version.
I am using the pre-rev-prop-change hook that allows to actually go back and edit comments and such information after the commit has been performed. This is very useful if there is missing/errorneous information in the commit comments. Here I post a pre-revprop-change batch file for Windows NT or later... You can ce...
Some UNIX implementations return the number of bytes that can be read in the <code>st_size</code> field after calling <code>fstat()</code>, but this is not portable.
I evaluated it recently, but had to reject it because it would not support the third party controls (janus grid) we were using.
If you are using any of the agile tenants in your coding practises then "a" is fine for now but as the complexity of your query grows you should consider reconsider refactoring, that is, build your code based on what you know now and refactor when necessary. If you do refactor I would suggest introducing the [factor...
If you are using any of the agile tenants in your coding practises then "a" is fine for now but as the complexity of your query grows you should consider refactoring, that is, build your code based on what you know now and refactor when necessary. If you do refactor I would suggest introducing the [factory pattern][...
You do that just to exit the while loop on new line. Else you would have to check it in while body and use break.
Recently I've started using a great little free windows app called **NextAction** which you can get from [here][1]. It's greatness comes from it's simplicity and it really helps to refocus and stay on track when dealing with all the days distractions ... email, co-workers, scrums, rss feeds, twitter, lunch, coffee b...
Write some JNI code to WM_QUERYENDSESSION message. You can get details for this from the MSDN documentation or by googling it. If you don't want to write too much C++ code to do this I can recommend the JNA library (https://jna.dev.java.net/) which gives you some nice Java abstractions for C code.
Especially with .NET 2.0 many things have changed in the .NET framework (not only at the language level). You will need version 1.1 to run programs linked against that version. Now, if parts of your program use .NET 3.5, and you have access to all the source, I would recommend you port the entire application to .NET...
|c#|.net-3.5|
What's a simple way to combine **feed** and **feed2**? I want the items from **feed2** to be added to **feed**. Also I want to avoid duplicates as **feed** might already have items when a question is tagged with both WPF and Silverlight. Uri feedUri = new Uri("http://stackoverflow.com/feeds/tag/silverlight"); ...
`id` is a built-in function that gives the memory address of an object. If you name one of your functions `id`, you will have to say `__builtins__.id` to get the original. Renaming `id` globally is confusing in anything but a small script. However, reusing built-in names as variables isn't all that bad as long as t...
Kdialog and dialog are both good, but I'd recommend Zenity. Quick, easy, and much better looking the xmessage or dialog.
@ageektrapped is on the right track, however FindWindow will not search child windows. For that you will need to use [FindWindowEx](http://pinvoke.net/default.aspx/user32/FindWindowEx.html)
Forgive my answering a question with a question, but doesn't [Perforce][1] provide tools for this? Or, at the very least, documentation? I'd be beating up my Perforce salesperson... [1]: http://www.perforce.com/
Try: echo "hello world" | (read var1 var2 ; echo $var1 ; echo $var2 ) The problem, as multiple people have stated, is that var1 and var2 are created in a subshell environment that is destroyed when that subshell exits. The above avoids destroying the subshell until the result has been echo'd. Another solution...
I agree with Stephen Wrighton. Domain security is the way to go. If you would like to use mashups and what-not, you can expose parts of the database via a machine-readable RESTful interface. [SubSonic][1] has one [built in][2]. [1]: http://subsonicproject.com [2]: http://subsonicproject.com/tips-and-tricks/we...
If you don't mind using the Windows API, you could use EnumWindowsProc, and check each of the handles that that turns up using GetWindowThreadProcessId (to see that it's in your process), and then maybe IsWindowVisible, GetWindowCaption and GetWindowTextLength to determine which hWnd in your process is the one you want...
You could of course just use Log4J with the appropriate pattern layout: > For example, for the class name "org.apache.xyz.SomeClass", the pattern %C{1} will output "SomeClass". [http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html][1] [1]: http://logging.apache.org/log4j/1...
Well, an obvious "solution" would be to make a single function and add one extra parameter (of enum-like type). And then do an if() or switch() inside, and perform the appropriate actions. Because hey, the *functionality* of the functions is different, so you have to do those different actions *somewhere*. However, ...
I am wondering whether you expecing some thing like this? <TextBlock> <Hyperlink> <Run Text="Test link"/> </Hyperlink > </TextBlock> </TextBlock>
I don't know how you could use the tags for navigation -- to me navigation implies that you are going through static content. I definitely think of them as filters. I can access information on a particular subject with one html link instead of going to a search form and going through the annoying process of either t...
I think I'd move: MoveToEx(dc, x0, y, NULL); LineTo(dc, x1, y); into their own function DrawLine(x0,y0,x0,y0), which you can call from each of the existing functions. Then there's one place to add extra drawing effects?
According to Vim's documentation, Ctrl+C does not check for abbreviations and does not trigger the |InsertLeave| autocommand event while Ctrl-[ does... One option is to use the following to remap Ctrl-C inoremap [C-c] [Esc][Esc]
I guess it adds a lot of overhead for every class. Every class has to be 'looked up'. You create new Throwable objects to do that... These throwables don't come for free.
I'd strongly recommend against continual reverse engineering. Reverse engineering is a great one time thing, but changes need to be managed as changes to both the hbm and the database. We use migrations to manage db changes, and we include the associated changes in the hbm. If Hibernate has it (I believe it does) yo...
Is there any way to detect the target class in PHP 5 static methods?
|php|oop|php5|
Below is an example class hierarchy and code. What I'm looking for is a way to determine if 'ChildClass1' or 'ChildClass2' had the static method whoAmI() called on it without re-implementing it in each child class. <?php abstract class ParentClass { public static function whoAmI () { ...
I have a method of creating and updating database projects in Visual Studio 2005 that I thought was common knowledge. After asking a few coworkers if they knew how to update their database projects with this method and receiving no's, I thought I would blog about it and pass along some helpful hints and best practices...
|qt|widget|
You should have a look at [SharpArchitecture][1] which uses ASP.NET MVC, and which is an open source architecture foundation for web applications. [1]: http://code.google.com/p/sharp-architecture/
- revision control system (eg. subversion, cvs, git)
As a preliminary answer, check out the Joel test: [http://www.joelonsoftware.com/articles/fog0000000043.html][1] [1]: http://www.joelonsoftware.com/articles/fog0000000043.html Just an appetizer: > 1. Do you use source control? 2. Can you make a build in one step? 3. Do you make daily builds? ...
How do I best convert a DbType to System.Type?
|.net|converters|
How do I best convert a System.Data.DbType enumeration value to the corresponding (or at least one of the possible corresponding) System.Type values? For example: DbType.StringFixedLength -> System.String DbType.String -> System.String DbType.Int32 -> System.Int32 I've only seen very "dirty" sol...
- What about documentation - how (comments in code, high-level specs), when, amount, who - How you will test - unit/acceptance/user testing - code versioning, some SVN/Git (or is it included in trac?) - team roles and responsibilities - need to be done in ocntext of your project
You're missing something :) Create a custom [ServiceHost][1] and [use that in the .svc file][2]; in the custom service host do all your configuration [1]: http://msdn.microsoft.com/en-us/library/system.servicemodel.servicehost.aspx [2]: http://msdn.microsoft.com/en-us/library/aa395224.aspx
I think you should not let the Game class handle IO. this way, the (blocking) TakeTurn method will hide from the game board the means of implementation. it can use other objects to communicate with the user. all the Game class should concern itself with is the state of the board and the turn. the players should al...
Knowledge management is crucial. As you already plan to use wiki (like [Trac](trac.edgewall.org) or [Redmine](http://www.redmine.org/)) you could use it for KM as well.
Instead of telling the game class there is only ever one human, why not let it get that input during the menu/initialization of the game? If there are more players, that can be decided via some form of input (select players in the menu), prior to the game class initialization.
Have a look at Red Gate [SQL Compare](http://www.red-gate.com/products/SQL_Compare/index.htm) and [SQL Data Compare](http://www.red-gate.com/products/SQL_Data_Compare/index.htm). You can download the trial and use them to build a script that will dump your objects to a .sql file.
Yes, it is definitively possible. If you have a form where you expect an integer to make your next SELECT statement, then you can enter anything similar: SELECT * FROM `thingy` WHERE attributeID= - 5 (good answer, no problem) - 5; DROP table `users`; (bad, bad, bad...) The following website details fu...
How do I Validate the File Type of a File Upload?
|asp.net|javascript|validation|file|upload|
I am using <code>&lt;input type="file" id="fileUpload" runat="server"&gt;</code> to upload a file in an asp.net app. I would like to limit the file type of the upload (example: limit to xls or xlsx extensions). Both Javascript or server-side validation are ok (as long as the server side validation would take place befo...
We use RMI via Spring and find it very easy to use, fairly robust and fast. Although our requirements were for a fairly responsive link and there was no real need to add a messaging component.
The single most valuable tool that I can recommend is a **"todo" list**. This may take the form of a specialised [app][1], [gadget][2] or pen and paper, however the most important thing to remember is that new tasks should be added to the *bottom* of the list and tasks to be started must be taken from the *top* - i...
I do not think it's possible. Pipes present stream-oriented protocol rather than packet-oriented one. IOW, if you write to a pipe twice, once with,say, 250 bytes and once with, say, 520 bytes, there is no way to tell how many bytes you'll get from the other end in one read request. You could get 256, 256, and then the ...
I'm not sure what remoting technology you're referring to, but this is a real problem with WCF, which only currently supports serializing DateTime as xs:DateTime, inappropriate for a date-only value where you are not interested in timezones. .NET 3.5 introduces the new DateTimeOffset type, which is good for transfer...
The real value in Team Foundation Build is that it associates changesets and work items with builds. This enables a couple of useful scenarios: - You can look at a work item and find out what build it is included in - You can look at a build and see which code changes (and work items) it includes Then of ...
How to convert Typed DataSet Scheme when one of the types was changed?
|c#|ado.net|dataset|
I got a typed (not connected) dataset, and many records (binary seriliazed) created with this dataset. I've added a property to one of the types, and I want to convert the old records with the new data set. I know how to load them: providing custom binder for the BinaryFormatter with the old schema dll. The questio...
MS SQL Integration Services may help: http://www.microsoft.com/sql/technologies/integration/default.mspx
how XQUERY is actually used?
|xquery|
I have been reading lot of XQUERY tutorial on the web site. Almost all of them are teaching me the XQUERY syntax. Let's say i have understood the XQUERY syntax, how am i going to actually implement XQUERY on my web site? For example, i have book.xml: <pre> &lt;?xml version="1.0" encoding="iso-8859-1" ?&gt; &lt;bo...
In SQL Server, just do: select distinct top n+1 column from table order by column desc And then throw away the first value, if you don't need it.
Where am I supposed to see FirePHP output?
|php|firebug|firephp|
Ok, so I am finally trying out FirePHP. I installed it and restarted firefox, enabled firebug for my localhost, moved the demo oo.php file that comes with the download into an IIS virtual directory, changed the include path, removed the apache_request_headers() call since I am running IIS and the only output I see? ...
Actually, I think this is the fault of the Win32 API. <http://blogs.msdn.com/ts/archive/2006/11/20/why-does-my-shared-clipboard-not-work-part-2.aspx> To set data in the clipboard, you have to <a href="http://msdn.microsoft.com/en-us/library/ms649048(VS.85).aspx">open it</a> first. Only one process can have the c...
ViewState by default is MIME encoded and hashed with a MAC key (either from the machine or from the web.config file), which helps prevent tampering (i.e. decoding blows up). You can also encrypt and compress ViewState if you like for further protection and less overhead, respectively. See [MS ViewState](http://msdn.mic...
C will guess int for unknown types. So, it probably thinks sleep has this prototype: int sleep(int); As for giving multiple parameters and linking...I'm not sure. That does surprise me. If that really worked, then what happened at run-time?
[Glenn Block][1] has a good example of implementing a `ForEach` extension method to `IEnumerable<T>`. From his [blog post][2]: public static class IEnumerableUtils { public static void ForEach<T>(this IEnumerable<T> collection, Action<T> action) { foreach(T item in collecti...
Since form submission on hitting the enter key is a part of life with HTML, you'll have to trap the Enter key using javascript and only allow it to go through when it's valid (such as within textareas). Check out <a href="http://brennan.offwhite.net/blog/2004/08/04/the-single-form-problem-with-aspnet/">http://brennan....
Microsoft's recommended approach is to use satellite assemblies, as described in [Packaging and Deploying Resources][1]. If you're using a ResourceManager to load resources, .NET will load the correct resources for the CurrentUICulture. This defaults to the user's current UI language setting in Windows. It is possib...
You don't need to define any parameters for a function. You can just use the function's arguments array. function sum() { var retval = 0; for (int i=0; i < arguments.length; ++i) { retval += arguments[i]; } return retval; } sum(1,2,3) //returns 6
You don't need to define any parameters for a function. You can just use the function's **arguments** array. function sum() { var retval = 0; for (int i=0; i < arguments.length; ++i) { retval += arguments[i]; } return retval; } sum(1,2,3) //returns 6
I like using Sql Server Profiler as well. I like to setup a trace on a client site on their database server for a good 15-30 minute chunk of time in the midst of the business day and log all queries/stored procs with an Duration > 100 milliseconds....thats my criteria anyway for "long-running" queries
For Windows, check out: [MFC Memory Leak Detection][1] [1]: http://msdn.microsoft.com/en-us/library/c99kz476(VS.80).aspx
Are you sure that there's a direct link here? Have you created a static HTML page with fixed elements to verify your theory? Given how widely these CSS properties are used, I'd think someone else would have noticed it by now, whatever browser/OS you're running.
Well, the short definition of the law shortens it too much. The real "law" (in reality an advice on good API design) basically says: Only access objects you created yourself, or were passed to you as an argument. Do not access objects indirectly through other objects. Methods of fluent interfaces often return the objec...
If you are using a debug Flash Player, you can have the Flash Player log trace messages to a file on your system. If you want real time messages, then you could tail the file. More info: <http://blog.flexexamples.com/2007/08/26/debugging-flex-applications-with-mmcfg-and-flashlogtxt/> mike chambers mesh@a...
This is <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=201307">bug #201307</a>.
Porting code from ASP.NET to Silverlight is not an easy task. As Nate points outs it depends on how much of ASP.NET application is AJAX based, and how much is based around server controls. Silverlight is a state full client side technology, meaning everything is running on the client inside the browser. ASP.NET is ...
This [code project paper][1] has a string similarity function using the [Levenshtein distance][2]. [1]: http://www.codeproject.com/KB/recipes/improvestringsimilarity.aspx [2]: http://en.wikipedia.org/wiki/Levenshtein_distance
this is VB.Net Dim objectQuery As New ObjectQuery("SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionId IS NOT NULL") Dim searcher As New ManagementObjectSearcher(scope, objectQuery) Dim os As ManagementObject Dim moColl As ManagementObjectCollection = searcher....
DataDude? [http://msdn.microsoft.com/en-us/vsts2008/db/default.aspx][1] [1]: http://msdn.microsoft.com/en-us/vsts2008/db/default.aspx
have you looked into [F#][1]? Also a neat blog post would be [here][2] that talks about how to use the new generic / lambda expressions built into c# 3.0. If you just add using System.Linq to the top of your source file there are a LOT of nice new functions added to working with collections such as folding / filt...
For static analysis tools <a href="http://virtualteamtls.sourceforge.net">my project</a> is currently using CPD, <a href="http://pmd.sourceforge.net">PMD</a>, <a href="http://findbugs.sourceforge.net">FindBugs</a>, and <a href="http://checkstyle.sourceforge.net">Checkstyle</a>. <p>CPD is the PMD "Copy/Paste Detector...
For static analysis tools <a href="http://virtualteamtls.sourceforge.net">my project</a> is currently using CPD, <a href="http://pmd.sourceforge.net">PMD</a>, <a href="http://findbugs.sourceforge.net">FindBugs</a>, and <a href="http://checkstyle.sourceforge.net">Checkstyle</a>. <p>CPD is the PMD "Copy/Paste Detector...
For static analysis tools <a href="http://virtualteamtls.sourceforge.net">my project</a> is currently using CPD, <a href="http://pmd.sourceforge.net">PMD</a>, <a href="http://findbugs.sourceforge.net">FindBugs</a>, and <a href="http://checkstyle.sourceforge.net">Checkstyle</a>. <p>CPD is the PMD "Copy/Paste Detector...
Can you use Boost String Algo? http://www.boost.org/doc/libs/1_35_0/doc/html/string_algo/usage.html#id1290573 erase_all(str, " ");