instruction
stringlengths
0
30k
I think you are confused. You should re-check the meaning of "class" and "instance". I think you are trying to first declare a Instance of a certain Class, and then declare a instance of other Class, use the data from the first one, and then find a way to convert the data in the second instance and use it on the fir...
How to upgrade database schema built with an ORM tool?
|java|orm|database|migration|
I'm looking for a general solution for upgrading database schema with ORM tools, like JPOX or Hibernate. How do you do it in your projects? The first solution that comes to my mind is to create my own mechanism for upgrading databases, with SQL scripts doing all the work. But in this case I'll have to remember about...
|java|database|orm|migration|
I'm looking for a general solution for upgrading database schema with ORM tools, like JPOX or Hibernate. How do you do it in your projects? The first solution that comes to my mind is to create my own mechanism for upgrading databases, with SQL scripts doing all the work. But in this case I'll have to remember about...
Two things stand out in my head: 1) You can turn Trace on and off from the code: if (Context.Request.QueryString["DoTrace"] == "true") { Trace.IsEnabled = true; Trace.Write("Application:TraceStarted"); } 2) You can build multiple ....
Two things stand out in my head: 1) You can turn Trace on and off from the code: #ifdef DEBUG if (Context.Request.QueryString["DoTrace"] == "true") { Trace.IsEnabled = true; Trace.Write("Application:TraceStarted"); ...
You might want to take a look at [Iesi.Collections][1] and [Extended Generic Iesi.Collections][2] (because the first edition was made in 1.1 when there were no generics yet). Extended Iesi has an ISet<T> class which acts exactly as a HashSet: it enforces unique members and does not allow duplicates. The nifty thi...
What is the best way to parse html in C#?
|c#|.net|html|parsing|
I'm looking for a library/method to parse an html file with more html specific features than generic xml parsing libraries.
I just wrote up a quick test, try this: IEnumerable<Object> myList = new List<Object>(); Stopwatch watch = new Stopwatch(); int x; watch.Start(); for (var i = 0; i <= 1000000; i++) { if (myList.Count() == 0) x = i; } watch.Stop(); Stopwatch watch...
I just wrote up a quick test, try this: IEnumerable<Object> myList = new List<Object>(); Stopwatch watch = new Stopwatch(); int x; watch.Start(); for (var i = 0; i <= 1000000; i++) { if (myList.Count() == 0) x = i; } watch.Stop(); Stopwatch watch...
I just wrote up a quick test, try this: IEnumerable<Object> myList = new List<Object>(); Stopwatch watch = new Stopwatch(); int x; watch.Start(); for (var i = 0; i <= 1000000; i++) { if (myList.Count() == 0) x = i; } watch.Stop(); Stopwatch watch...
You could maybe create the file with a temporary name ("data.xml_TMP"), and when it's ready change the name to what it is supposed to be. That way, no other process will be accessing it before it is ready.
A number of people have recommended using source control and I totally agree. However you also need do the following. - Exclude your personal options files from the repository (eg your .suo files) - Exclude your App.config files from the repository. - Not entirely but you need to have a Template.App.config. You...
Just gave this a run and it seemed to work nicely. My coworker had a version which used a Thread object, but I find the BeginInvoke() method of delegate types to be a bit more elegant. namespace TimedReadLine { public static class Console { private delegate string ReadLineInvoker (); ...
Just gave this a run and it seemed to work nicely. My coworker had a version which used a Thread object, but I find the BeginInvoke() method of delegate types to be a bit more elegant. namespace TimedReadLine { public static class Console { private delegate string ReadLineInvoker (); ...
**EDIT**: fixed the problem by having the actual work be done in a separate process and killing that process if it times out. See below for details. Whew! Just gave this a run and it seemed to work nicely. My coworker had a version which used a Thread object, but I find the BeginInvoke() method of delegate types ...
Can I get some clarification first to make sure I get the problem? `document.write` calls will add content to the markup at the point in the markup at which they occur. For example if you include `document.write` calls in a function but call the function elsewhere, the `document.write` output will happen at the poin...
You should be able to set $itunes to $null. Alternatively, $itunes should have a quit method you can call. $itunes.quit()
Why would you need 100+ lines of code? Using something like [swfobject][1] reduces this amout quite some (and generally you don't want to do plugin detection, etc. by hand anyway). [1]: http://code.google.com/p/swfobject/
You also lose external control of the SWF. When it's embedded in HTML you can use javascript to communicate with the SWF. If the SWF is loaded directly that may not be possible. Your 100+ lines quote seems pretty high to me. The HTML that FlashDevelop generates for embedding a SWF is only around 35 lines, with an...
Returning an element from a List in Scala
|list|scala|
I've recently been working on a beginner's project in Scala, and have a beginner question about Scala's Lists. Say I have a list of tuples ( `List[Tuple2[String, String]]`, for example). Is there a convenience method to return the first occurence of a specified tuple from the List, or is it necessary to iterate thro...
I'm sure it's very hard. Huge existing GUI-heavy non-threaded code base to multi-threaded. Sounds like a 10 to me. ***But*** it seems to use multi-cores to me. The Intellesense seems threaded. The build system has multi-project building and for C++ multi-file building as well. You problems with these tools sounds...
I have VS2008 running on all 4 CPUs. Just set this environment variable / project flag. /MP (It can be set in C/C++ Settings, Advanced. In project settings) Edit: The MP flag can also accept a number, e.g. /MP2 which means it will only run on 2 cores. Leaving it as just /MP means it will run on the maximum amo...
I have VS2008 running on all 4 CPUs. Just set this environment variable / project flag. /MP (It can be set in C/C++ Settings, Advanced. In project settings) Edit: The MP flag can also accept a number, e.g. /MP2 which means it will only run on 2 cores. Leaving it as just /MP means it will run on the maximum amo...
What you have there is a pointer-to-member-function. It will solve your problem. I am surprised that your "TestSwitch" function compiles, as the calling syntax is slightly different to what you might expect. It should be: bool res = (this->*CaseMethod)( 999, "hello world" ); However, you might find a combinat...
I think [`HashSet<T>`][1] is a great help. > The `HashSet<T>` class provides > high performance set operations. A set > is a collection that contains no > duplicate elements, and whose elements > are in no particular order. Just add items to it and then use CopyTo. [1]: http://msdn.microsoft.com/en-us/li...
I think [`HashSet<T>`][1] is a great help. > The `HashSet<T>` class provides > high performance set operations. A set > is a collection that contains no > duplicate elements, and whose elements > are in no particular order. Just add items to it and then use CopyTo. ---------- **Update**: `HashSet<T>` ...
Triangle Trigonometry (ActionScript 3)
|actionscript-3|trigonometry|hypotenuse|
I am trying to write a formula in ActionScript 3 that will give me var "z" (please see image below) in degrees, which I will then convert to radians. I will already know the value of vars "x" and "y". Using trigonometry, how can I calculate the length of the hypotenuse and therefore the variable angle of var z? A s...
**It is important to keep your pfx file secret as it contains the private key.** If that key is made available to others then anyone can sign assemblies or programs that masquerade as you. To associate your name with your assemblies (in the eyes of Windows) you'll need to get a digital certificate (The portion of...
IPC Mechanisms in C# - Usage and Best Practices..
|c#|.net|ipc|
How can I tab accross a ButtonBar component in Flex?
|apache-flex|actionscript-3|
I have a button bar inf flex along with several other input controls, I have set the tabIndex property for each control and all goes well until I tab to the ButtonBar. The ButtonBar has 3 buttons but tabbing to it, only the first button gets focus, tab again and the focus goes back to the top control... How can ...
The one and only [tortoiseSVN][1]! It is integrated in Windows Explorer, you invoke it with a right click. All commands are under the TortoiseSVN menu, except for frequently used commands such as **update**, **commit** or **diff** (it's configurable). For some reason, the SVN proterties are located in a tab in th...
A couple of things that I've learned: - Absolutely and brutally minimize the number of images you have that contain text. Doing so will make your life a billion percent easier since you won't have to get a new set of images for every friggin' language. - Be very wary of css positioning that relies on things alway...
|internationalization|
A while back I was reading the W3C article on '[Re-using Strings in Scripted Content][1]', which contains some useful advice on internationalisation, but which strikes me as at odds iwth the DRY (Don't Repeat Yourself) principle of eliminating repetitive code. To take their example, we might have some code like this...
|internationalization|
How do you retrieve items from a dictionary in the order that they're inserted?
|python|
Is it possible to retrieve items from a Python dictionary in the order that they were inserted?
|python|dictionary|
If you have the current CTP release in Visual Studio it lets you create a F# Tutorial project, which gives you a Tutorial.fs, exactly containing what it's name suggests. That tutorial also points to a larger collection of [F# examples at Microsoft][1]. Also, there is an F# samples project going on at [CodePlex][...
If you have $99.00 to spare you may want to take a look at [http://www.isapirewrite.com/][1] [Excerpt from thier website] **Product overview** ISAPI_Rewrite is a powerful URL manipulation engine based on regular expressions. It acts mostly like Apache's mod_Rewrite, but is designed specifically for Microsoft'...
A number of people have recommended using source control and I totally agree. However you also need do the following. - Exclude your personal options files from the repository (eg your .suo files) - Exclude your App.config files from the repository. - Not entirely but you need to have a Template.App.config. You...
Dynamic programming with WCF
|.net|wcf|
Has anybody got any kind of experience with dynamic programming using WCF. By dynamic programming I mean runtime consumption of WSDL's. I have found one blog entry/tool: http://blogs.msdn.com/vipulmodi/archive/2006/11/16/dynamic-programming-with-wcf.aspx Has anybody here found good tools for this?
The whole concept of re-thinking a UI of an existing application is dependent on the target audience. For a boring business application, like accounting or budgeting, it may even be counter-productive. For one, users of those kinds of apps may have used a similar looking and feeling UI for years and years, and second, ...
You can download GNU Emacs NT from [here](http://ftp.gnu.org/gnu/emacs/windows/emacs-22.2-bin-i386.zip) direct. It works fine in windows, make sure you create a shortcut to the runemacs.exe file rather than the emacs.exe file so it doesn't show a command prompt before opening! XEmacs is less stable than GNU Emacs, a...
Jeff and Joel discuss scaling in the [Stack Overflow Podcast #19][1]. [1]: http://blog.stackoverflow.com/2008/08/podcast-19/
> LINQ itself must be doing some serious optimization around the Count() method somehow. Does this surprise you? I imagine that for `IList` implementations, `Count` simply reads the number of elements directly while `Any` has to query the `IEnumerable.GetEnumerator` method, create an instance and call `MoveNext` at ...
> LINQ itself must be doing some serious optimization around the Count() method somehow. Does this surprise you? I imagine that for `IList` implementations, `Count` simply reads the number of elements directly while `Any` has to query the `IEnumerable.GetEnumerator` method, create an instance and call `MoveNext` at ...
A couple of things that I've learned: - Absolutely and brutally minimize the number of images you have that contain text. Doing so will make your life a billion percent easier since you won't have to get a new set of images for every friggin' language. - Be very wary of css positioning that relies on things alway...
[SmartSVN][1] is nice if you want a client that doesn't integrate with Explorer and is instead a standalone app. (Although I think later version offer an Explorer integration as well.) [1]: http://www.syntevo.com/smartsvn/index.html
If you could send an SMS within a program on the iPhone, you'll be able to write games that spam people in the background. I'm sure you really want to have spams from your friends, "Try out this new game! It roxxers my boxxers, and yours will be too! http://roxxersboxxers.com!!!! If you sign up now you'll get 3,200 R...
I have used IPC in win32 code a while ago. [Critical sections, events & semaphores] How is the scene in .NET enviroment? Are there any tutorial explaining all available options and when to use and why?
There's an example in the WiX tutorial: http://www.tramontana.co.hu/wix/lesson1.php <Property Id="INSTALLDIR"> <RegistrySearch Id='AcmeFoobarRegistry' Type='raw' Root='HKLM' Key='Software\Acme\Foobar 1.0' Name='InstallDir' /> </Property> Of course, you've got to set the registry key as pa...
z is equivalent to 180 - angle of yH. Or: 180 - arctan(x/y) //Degrees pi - arctan(x/y) //radians Also, if actionscript's math libraries have it, use arctan2, which takes both the x and y and deals with signs correctly.
Try recreating the index on that table, and try regenerating the statistics. [DBCC REINDEX][1]<br/> [UPDATE STATISTICS][2] [1]: http://msdn.microsoft.com/en-us/library/aa258828(SQL.80).aspx [2]: http://msdn.microsoft.com/en-us/library/aa260645(SQL.80).aspx
There's nothing intrinsically wrong with the localised example you've given here, but class method pointers can often be tricky to keep 'safe' if you use them in a wider context, such as outside the class they're a pointer of, or in conjunction with a complex inheritance tree. The way compilers typically manage method ...
What @Patrick said, also the hypotenuse is `sqrt(x^2 + y^2)`.
I honestly doubt it, for a number of reasons, but the most important one is that there are some instructions that are allowed in 32-bit mode, but not in 64-bit mode. Specifically, the REX prefix that is used to encode some instructions and registers in 64-bit mode is a byte of the form 0x4f:0x40, but in 32 bit mode th...
From the PostgreSQL point of view, in pseudo-code: * $insert_id = INSERT...RETURNING foo_id;-- only works for PostgreSQL >= 8.2. * INSERT...; $insert_id = SELECT lastval(); -- works for PostgreSQL >= 8.1 * $insert_id = SELECT nextval('foo_seq'); INSERT INTO table (foo...) values ($insert_id...) for older P...
I'd recommend looking into a pure javascript framework (probably <a href="jquery.com">Jquery</a>) for your client-side code, and write <a href="json.org">JSON</a> services in python- that seems to be the easiest / bestest way to go. Google Web Toolkit lets you write the UI in Java and compile it to javascript. As Da...
Postgres is doing a lot more than it looks like (maintaining data consistency for a start!) If the values don't have to be 100% spot on, or if the table is updated rarely, but you are running this calculation often, you might want to look into Materialized Views to speed it up. (Note, I have not used materialized...
Postgres is doing a lot more than it looks like (maintaining data consistency for a start!) If the values don't have to be 100% spot on, or if the table is updated rarely, but you are running this calculation often, you might want to look into Materialized Views to speed it up. (Note, I have not used materialized...
Postgres is doing a lot more than it looks like (maintaining data consistency for a start!) If the values don't have to be 100% spot on, or if the table is updated rarely, but you are running this calculation often, you might want to look into Materialized Views to speed it up. (Note, I have not used materialized...
##Perl expanded version Note use of `/x` modifier. /^( ( ( # 31 day months (0[13578]) | ([13578]) | (1[02]) ) [\/] ( ([1-9]) | ([0-2][0-9]) | (3[01]) ...
Have a look at URLRewriter. Used it in production once without problems. But don't rely on that as the only quality check: <http://www.codeplex.com/urlrewriter> > Managed Fusion URL Rewriter is a powerful URL manipulation engine based on the Apache mod_rewrite extension. It is designed, from the ground up to brin...
Have a look at URLRewriter. Used it in production once without problems. But don't rely on that as the only quality check: <http://www.codeplex.com/urlrewriter> *(It's free and has a Microsoft Public License)* > Managed Fusion URL Rewriter is a powerful URL manipulation engine based on the Apache mod_rewrite e...
Assuming you have a client named "CLIENT", a directory named "foo" (located at your project root), and you wish to ignore all .dll files in that directory tree, you can add the following lines to your workspace view to accomplish this: <pre> -//depot/foo/*.dll //CLIENT/foo/*.dll -//depot/foo.../*.dll //CLIENT/foo......
Assuming you have a client named "CLIENT", a directory named "foo" (located at your project root), and you wish to ignore all .dll files in that directory tree, you can add the following lines to your workspace view to accomplish this: <pre> -//depot/foo/*.dll //CLIENT/foo/*.dll -//depot/foo/.../*.dll //CLIENT/foo/....
Removing web.config from subversion (ASP.NET Project)
|subversion|visualsvn|web-config|
I have a project which is source controlled using Subversion and VisualSVN. Since the version of web.config is different on the server and the developers' computers I want the file to remain on the computers but to be ignored by Subversion. I added it to the svn:ignore but it still remains (and still has a red exclamat...
|svn|visualsvn|web-config|
|asp.net|svn|web-config|
for key in sorted(d): print d[key]
Pointers to C++ class mthods
|c++|
Whilst refactoring some legacy C++ code I found that I could potentially remove some code duplication by somehow defining a variable that could point to any class method that shared the same signature. After a little digging, I found that I could do something like the following: class MyClass { protec...
Whilst refactoring some legacy C++ code I found that I could potentially remove some code duplication by somehow defining a variable that could point to any class method that shared the same signature. After a little digging, I found that I could do something like the following: class MyClass { protec...
In C# (and probaly Java) it would be best to create a Temperature class that stores temperatures privately as Celcius (or whatever) and which has Celcius, Fahrenheit, and Kelvin properties that do all the conversions for you in their get and set statements?
From [here][1]. I couldn't have said it better. > Hello, > > Responding to your question seems > fraught with peril by starting a flame > war, so I'll proceed cautiously. > > > > There are a number of fundamental > technical similarities between the > Java Runtime and the Common Language > Runtime, i...
From [here][1]. I couldn't have said it better (Well, with the exception of a flame war, this is a flameless place :-) ). > Hello, > > Responding to your question seems > fraught with peril by starting a flame > war, so I'll proceed cautiously. > > > > There are a number of fundamental > technical simi...
Absolutely none. But it doesn't matter. I've posted a response before: It's unfortunate, but people, even programmers, are just too emotional to be easily be swayed by argument. Once he's invested in his position (and, if you're posting here, he is) you're not likely to convince him with facts alone. What you ne...
Absolutely none. But it doesn't matter. I've posted a similar response before: It's unfortunate, but people, even programmers, are just too emotional to be easily be swayed by argument. Once he's invested in his position (and, if you're posting here, he is) you're not likely to convince him with facts alone. Wha...
You want backslashes in the regular expression, not forward slashes. The starting and ending pipes **are** needed (or another delimiter for the regex) $x = "hello world 1007;"; echo preg_replace('|(\D)(\s+)(\d+)(;)|','$1,$3',$x); echo preg_replace('/(\D)(\s+)(\d+)(;)/','$1,$3',$x); echo ...
Linking directly to a SWF, what are the downsides?
|apache-flex|flash|embed|