instruction
stringlengths
0
30k
The solution was to call the C++ Win32 API function CreateProcess from kernel32.dll from the C# code. This site was very helpful in getting the correct function signature for C#: [http://www.pinvoke.net/default.aspx/kernel32/CreateProcess.html][1] [1]: http://www.pinvoke.net/default.aspx/kernel32/CreateProce...
The way I currently work is that I (the developer) build the functionality using a dummy FLA file, using only external class files. When the designer(s) finish up the layout, they send me a FLA with all the imported assets, and linked buttons and MovieClips. I then attach my document class to the new FLA, and make sur...
What's with the love of dynamic Languages
|dynamic|ruby|.net|static|
It seems that everybody is jumping on the dynamic, non-compiled bandwagon lately. I've mostly only worked in compiled, static typed languages (C, Java, .Net). The experience I have with dynamic languages is stuff like ASP (Vb Script), JavaScript, and PHP. Using these technologies has left a bad taste in my mouth whe...
|off-topic|
|dynamic-languages|off-topic|
|dynamic-languages|off-topic|religious-debate|
|dynamic-languages|off-topic|
|offtopic|dynamic-languages|
|dynamic-languages|
We are using a setup with Visual Studio 2008, Resharper 4.1, Subversion for sourcecontrol, Cruise control for automated builds and the build in unit testing for all our automated tests. and Linq2Sql for or mapping. You could swap out anything but VS (obviously) and resharper (it's so cool) but you could easily use anot...
[This solution][1] is about forms authentication, but it details the 401 issue. > The solution was simply to attach a > handler to the Application's > EndRequest event by putting the > following in Global.asax: protected void Application_EndRequest(object sender, EventArgs e) { if (Context.Item...
I am assuming you want to get the name of the process owning the currently focused window. With some pinvoke: // The GetForegroundWindow function returns a handle to the foreground window // (the window with which the user is currently working). [System.Runtime.InteropServices.DllImport("u...
I am assuming you want to get the name of the process owning the currently focused window. With some P/Invoke: // The GetForegroundWindow function returns a handle to the foreground window // (the window with which the user is currently working). [System.Runtime.InteropServices.DllImport("...
If you're curious what the names for the various code formatting styles are, Wikipedia has an article on on [Indent Styles][1]. [1]: http://en.wikipedia.org/wiki/Indent_style
This should be pretty resilient, and handle stuff like delimiters at the end of the string ("foo and bar and ", for example) \s*(?:\band\b|,)\s*
Perfmon in my opinion is one of the best tools to do this but make sure you properly configure the sampling interval according to the time you wish to monitor. For example if you want to monitor a process: - for 1 hour : I would use 1 second intervals (this will generate 60*60 samples) - for 1 day : I would ...
This is perfectly legal C++ and any compiler should accept it. What makes you think it might be doing something wrong?
Let's say we'll ignore obvious things like header guards. Sometimes, you want to generate code that needs to be copy/pasted by the precompiler: #define RAISE_ERROR_STL(p_strMessage) \ do \...
Let's say we'll ignore obvious things like header guards. Sometimes, you want to generate code that needs to be copy/pasted by the precompiler: #define RAISE_ERROR_STL(p_strMessage) \ do \...
I might be confused or missing something here... But doesn't apple provide all the Foundation / Cocoa / AppKit / CoreAudio / Qtkit / etc libraries that should provide all of the very basic functions you are looking for? Other than what xcode comes with or is on the apple dev site, there are no centralized repo's for...
Recognizing synonyms and semantic connections is something that <i>humans are good at</i>; a solution to organizing an open-ended taxonomy like what SO is featuring would probably be well served by finding a way to leave the matching to humans. One general approach: someone (or some team) reviews <i>new</i> tags o...
Documentation Sucks. It alludes to DROP DATABASE being recoverable, but only in odd conditions i'm not familiar with <http://dev.mysql.com/doc/refman/5.0/en/binary-log.html> Aparently you can recover from a last known good and then apply a sequence of binlogs ( Binlogs appear to function in this case like /patches...
Documentation Sucks. It alludes to DROP DATABASE being recoverable, but only in odd conditions i'm not familiar with <http://dev.mysql.com/doc/refman/5.0/en/binary-log.html> According to Docs, binlogs are just a sequence of commands executed based on a given reference point. So that when you did "DROP DATABASE", in...
Use a floating point number to represent the position of each item: Item 1 -> 0.0 Item 2 -> 1.0 Item 3 -> 2.0 Item 4 -> 3.0 You can place any item between any other two items by simple bisection: Item 1 -> 0.0 Item 4 -> 0.5 Item 2 -> 1.0 Item 3 -> 2.0 (Moved item 4 between items 1 and 2). ...
Well I can't provide specific guidance without knowing more about your particular case. It seems like you're using Hibernate's JPA implementation. You might try other JPA implementations if there is something about Hibernate's you don't like. As far as the query interface, if JPA's queries aren't doing what you want, y...
I'm not certain, but I can tell you this: tricks relying on the underlying nature of TRUE and FALSE are prone to error because the definition of these values is left up to the implementer of the language (or, at the very least, the specifier).
What about? SELECT * FROM mod_a WHERE section_id=value UNION ALL SELECT * FROM mod_b WHERE section_id=value UNION ALL SELECT * FROM mod_c WHERE section_id=value
Works starting with windows XP, not available in win 2000 or lower: This is the quickest way to do it: Process.Start("shutdown","/s /t 0"); Otherwise use P/Invoke or WMI like others have said.
Here's how I set my parameters in Crystal (that came with .NET -- don't know if it helps you). Dim dv As New ParameterDiscreteValue dv.Value = showphone rpt.ParameterFields("showphone").CurrentValues.Add(dv)
Put the following where you need it: System.Diagnostics.Debugger.Break();
you can use `System.Diagnostics.Debugger.Break()` to break in a specific place.. this can help in situations like debugging a service.
All the previous responses are great answers - here's one gottcha with Cassini that might require IIS on the destkop. Cassini runs in the context of the developer, not as the IIS user (IUSR_<machine>, IWAM, or in WinXP x64, the w3wp process). This can be a bit painful if you've got a web site that is accessing exte...
After a bit more looking, I found this in the [java doc][1] (emphasis mine): > Note that this implementation is not > synchronized. **If multiple threads > access a hash map concurrently, and at > least one of the threads modifies the > map structurally, it must be > synchronized externally.** (A structural >...
You will still need locks if you share state between threads. The GIL only protects the interpreter internally. You can still have inconsistent updates in your own code. For example: #!/usr/bin/env python import threading shared_balance = 0 class Deposit(threading.Thread): ...
It's easy to be confused when bash's true/false return statements are the other way around: $ false; echo $? 1 $ true; echo $? 0
It's easy to get confused when bash's true/false return statements are the other way around: $ false; echo $? 1 $ true; echo $? 0
You should populate the [MsiFileHash][1] table for these files. Look at WiFilVer.vbs thtat is part of the Microsoft Platform SDK to see how to do this. My other suggestion would be to look at [WiX][2] instead of Visual Studio 2003 for doing installs. Visual Studio 2003 has very limited MSI support and you can en...
Yes, you can using the <import resource=""/> tag inside the "Master" bean file. But what about the why? Why not listing the files in the contextConfigLocation context param of the wab.xml or als locations array of the bean factory? I think mutliple files are much easier to handle. You may choose only some of them fo...
As suggested [here][1], I could check out the [CERT Database][2]. [1]: http://stackoverflow.com/questions/87393/what-are-the-major-vulnerabilities-of-windows-2003-iis [2]: http://www.kb.cert.org/vuls/
fstream are great but I will go a little deeper and tell you about [RAII](http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization). The problem with a classic example is that you are forced to close the file by yourself, meaning that you will have to bend your architecture to this need. RAII makes use of...
Let's say we'll ignore obvious things like header guards. Sometimes, you want to generate code that needs to be copy/pasted by the precompiler: #define RAISE_ERROR_STL(p_strMessage) \ do \...
These two comparisons serve different purposes. The former checks for boolean value of something, the second checks for identity with None value.
For one the first example is shorter and looks nicer. As per the other posts what you choose also depends on what you really want to do with the comparison.
I find it really helps to use well-known frameworks such as Hibernate because it fits your code into a specific mold, or a way of thinking. Meaning, since you're using Hibernate, you write code a certain way, and most if not all developers who know Hibernate will be able to follow your line of thinking quite easily. ...
On Windows, you have [CamTasia][1] (commercial), [CamStudio][2] (GPL), [FRAPS][3] (commercial with free trial). FRAPS will definitely do your job, it was designed to capture videos of 3D games. CamTasia might, it has a low-level custom codec (TechSmith Capture Codec). CamStudio probably won't, at least not smoothl...
[Style guide][1] recommends to use is or is not if you are testing for None-ness > - Comparisons to singletons like None should always be done with > 'is' or 'is not', never the equality operators. On the other hand if you are testing for more than None-ness, you should use the boolean operator. [...
There is MojoPortal (<http://www.mojoportal.com/>) : * well designed * css template & valid html => ok for all browsers * open source * perhaps not very modern (no MVC, no LINK...) * but runs on Mono For a more up-to-date project, there is Dropthings (<http://www.dropthings.com/>) : an open source Web 2.0 st...
A language lawyer question. Hmkay. My personal top3: 1. violating the strict aliasing rule 2. violating the strict aliasing rule 3. violating the strict aliasing rule :-)
We just finished up an internal IT project banking heavily on Linq2Sql and it paid off. I was a bit skeptical at first, but I think it worked out great in the end. Just remember, the fundamentals don't change. 1) try to stay as stateless as possible 2) keep clean lines between your services and data access 3)...
Practical limit to length of SQL query (specifically MySQL)
|sql|mysql|optimization|query|
Is it particularly bad to have a very, very large SQL query with lots of (potentially redundant) WHERE clauses? For example, here's a query I've generated from my web application with everything turned off, which should be the largest possible query for this program to generate: SELECT * FROM 4e_magic_items I...
where T : MyBaseClass, new() only works w/ parameterless public constructor. beyond that, back to activator.CreateInstance (which really isn't THAT bad).
Nope. If you weren't passing in parameters, then you could constrain your type param to require a parameterless constructor. But, if you need to pass arguments you are out of luck.
Vista has proper support for icons in menus, for pre Vista, you must use owner draw menu items (MF_OWNERDRAW) if you want real 16x16 full color icons [Vista style menus...][1] [1]: http://shellrevealed.com/blogs/shellblog/archive/2007/02/06/Vista-Style-Menus_2C00_-Part-1-_2D00_-Adding-icons-to-standard-menus....
Vista has proper support for icons in menus, for pre Vista, you must use owner draw menu items (MF_OWNERDRAW) if you want real 16x16 full color icons [Vista style menus...][1] [Vista style+pre Vista callback][2] [1]: http://shellrevealed.com/blogs/shellblog/archive/2007/02/06/Vista-Style-Menus_2C00_-Part-1-_...
Just out of curiosity, would changing your url paths be out of the question? Instead of 1234/vbpage and 1234/cspage how about something like 1234/vb/page and 1234/cs/page ? I know you said same web root, but I'm just curious :)
http://msdn.microsoft.com/en-us/library/system.diagnostics.debugger.break.aspx #if DEBUG System.Diagnostics.Debugger.Break(); #endif
How to convert an XML file into a .Net class?
|xml|.net|
Can someone please remind me how to create a .Net class from an XML file?<br> I would prefer the batch commands, or a way to integrate it into the shell.<br> Otherwise, just the exe names will due. Thanks!
|.net|xml|
Can someone please remind me how to create a .Net class from an XML file?<br> I would prefer the batch commands, or a way to integrate it into the shell.<br> Thanks!
Have you checked the preferences under Flex/Editors/Design Mode? That has a skin rendering option, could that be it?
Try removing the borderless behavior of your window and see if that helps. Also, are you BeginInvoke()'ing or Invoke()'ing any long running operations? Another thing to look at: When you break into your code, try looking at threads other than your main thread. One of them may be blocking the UI thread.
I can't recall `TRUE` being `0`. `0` is something a C programmer would return to indicate success, though. This can be confused with `TRUE`. It's not always `1` either. It can be `-1` or just non-zero.
One great tool is [Snoop][1]. Really nice for looking at what WPF objects are displayed on the visual tree at a given time. I'm not sure how much it will help, but it's possible you're jamming the UI thread with a lot of extra things it has to do. Snoop may be able to help you track down what is on the screen to give y...
Has TRUE always had a value of 1?
|history|true|false|boolean|
I have a co-worker that maintains that TRUE used to be defined as 0 and all other values were FALSE. I could swear that every language I've worked with, if you could even get a value for a boolean, that the value for FALSE is 0. Did TRUE used to be 0? If so, when did we switch?
Has TRUE always had a non-zero value?
|history|boolean|true|false|
For languages without a built in boolean type, the only convention that I have seen is to define TRUE as 1 and FALSE as 0. For example, in C, the <code>if</code> statement will execute the if clause if the conditional expression evaluates to anything other than 0. I even once saw a coding guidelines document which ...
_"Microsoft Excel's ceiling function does not follow the mathematical definition, but rather as with (int) operator in C, it is a mixture of the floor and ceiling function: for x ≥ 0 it returns ceiling(x), and for x < 0 it returns floor(x). This has followed through to the Office Open XML file format. For example, CEIL...
How do you override the string representation the HTML helper methods use for a model’s properties?
|asp.net-mvc|
The html helper methods check the ViewDataDictionary for a value. The value can either be in the dictionary or in the Model, as a property. To extract the value, an internal sealed class named the ViewDataEvaluator uses PropertyDescriptor to get the value. Then, Convert.ToString() is called to convert the object return...
The html helper methods check the ViewDataDictionary for a value. The value can either be in the dictionary or in the Model, as a property. To extract the value, an internal sealed class named the ViewDataEvaluator uses PropertyDescriptor to get the value. Then, Convert.ToString() is called to convert the object return...
I use Komodo Edit, which might be a little less sophisticated than full Komodo. I create a "New Command" with `%(python) -i %f` as the text of the command. I have this run in a "New Console". I usually have the starting directory as %p, the top of the project directory. The -i option runs the file and drops int...
Assuming your first week is week 1: int getWeekOfMonth() { time_t my_time; struct tm *ts; my_time = time(NULL); ts = localtime(&my_time); return ts->tm_mday / 7 + 1; } For 0-index, drop the `+1` in the return statement.
Assuming your first week is week 1: int getWeekOfMonth() { time_t my_time; struct tm *ts; my_time = time(NULL); ts = localtime(&my_time); return ((ts->tm_mday -1) / 7) + 1; } For 0-index, drop the `+1` in the return statement.
This might be useful... $ip = "XXX.XXX.XXX.XXX" # IPV4 address. my @numbers = split (/\./, $ip); if (scalar(@numbers) != 4) { print "$ip is not a valid IP address.\n"; next; } my $ip_addr = pack("C4", @numbers); # First element of the array returned by gethostbyadd...
In your GotFocus handler, use: textbox.Select(0, textbox.Text.Length);
It's a bit kludgey, but in your click event, use SendKeys.Send( "{HOME}+{END}" );
You may find this [article by Joel][1] instructive. As an aside, if you've been "working in C++ for some time" and have graduated in CS, you may have gone to a JavaSchool (I'd argue that you haven't been working in C++ at all; you've been working in C but using the C++ compiler). [1]: http://www.joelonsoftware....
How to force Maven2 to copy dependencies into target/lib
|java|maven2|
How do I get my project's runtime dependencies copied into the target/lib folder? As it is right now, after 'mvn clean install' the target folder contains only my project's jar, but none of the runtime depencies. Thanks, Michael
The following funcs will probably be what you want, they are all documented on MSDN. CreateMutex(...) WaitForSingleObject(...) ReleaseMutex(...)
Try `FIELDTERMINATOR='","'`
Try `FIELDTERMINATOR='","'` Here is a great link to help with the first and last quote...look how he used the substring the SP http://www.sqlteam.com/article/using-bulk-insert-to-load-a-text-file
Within the Java language, the only way to create an object is by calling it's constructor, be it explicitly or implicitly. Using reflection still results in a call to the constructor method and deserialization also uses reflection to call the constructor.
Within the Java language, the only way to create an object is by calling it's constructor, be it explicitly or implicitly. Using reflection results in a call to the constructor method, deserialization uses reflection to call the constructor, factory methods wrap the call to the constructor to abstract the actual constr...
Arial Font doesn't display properly in Mac
|macos|flash|fonts|
I have a flash movie with a dynamic text that supposedly is Arial, and in my windows machine it displays as Arial. But when I tried it in a Mac, it shows as something like Times New Roman. I tried every property available and can't seem to get it to show as Arial on the Mac. I found another movie I had that didn'...
The only useful exception specifier is "throw()", as in "doesn't throw".
Write a Servelt that Talks to JMS (ActiveMQ)