qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
390,389
<p>I only have 1 line of code, and this is:</p> <pre><code>pcrecpp::RE re("abc"); </code></pre> <p>inside a function <code>OnBnClickedButtonGo()</code>. And this function fails in Release mode, but it works OK in debug mode.</p> <p>(I am using Visual Studio 8 on Windows XP.)</p> <p>The error message is:</p> <pre><...
[ { "answer_id": 390477, "author": "codelogic", "author_id": 43427, "author_profile": "https://Stackoverflow.com/users/43427", "pm_score": 0, "selected": false, "text": "<p>If it's happening only in release mode, it's possible that something is getting \"optimized\" out. Try doing somethin...
2008/12/23
[ "https://Stackoverflow.com/questions/390389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48778/" ]
I only have 1 line of code, and this is: ``` pcrecpp::RE re("abc"); ``` inside a function `OnBnClickedButtonGo()`. And this function fails in Release mode, but it works OK in debug mode. (I am using Visual Studio 8 on Windows XP.) The error message is: ``` A buffer overrun has occurred in testregex.exe which has ...
I had the same error message in my case. In debug is everything fine, but in release I get the error message. I have a native C/C++ library like `native.dll`. I have created a mixed unmanaged/managed C++ library, which is a wrapper for that library to .net. Somewhere in this `mixed.dll` I have an unmanaged function sig...
390,391
<p>I am doing some significant refactoring and feature-adding on a project, and have just broken backwards compatibility with my data. I did it by creating a bunch of subclasses from the class that I used to house my data in, and loading in old serialized objects no longer works..</p> <p>What kind of pre-engineering o...
[ { "answer_id": 390423, "author": "dacracot", "author_id": 13930, "author_profile": "https://Stackoverflow.com/users/13930", "pm_score": 2, "selected": true, "text": "<p>I use XML. One of the little talked about aspects of XML is that it can be extended without breaking backward compatib...
2008/12/23
[ "https://Stackoverflow.com/questions/390391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6054/" ]
I am doing some significant refactoring and feature-adding on a project, and have just broken backwards compatibility with my data. I did it by creating a bunch of subclasses from the class that I used to house my data in, and loading in old serialized objects no longer works.. What kind of pre-engineering or strategi...
I use XML. One of the little talked about aspects of XML is that it can be extended without breaking backward compatibility. In other words... ``` <root> <something one="1" two="2"/> </root> ``` ...from revision A, has no problem being backwardly compatible with... ``` <root> <something one="1" two="2" three="...
390,409
<p>So far I've found it impossible to produce usable tracebacks when Mako templates aren't coded correctly.</p> <p>Is there any way to debug templates besides iterating for every line of code?</p>
[ { "answer_id": 390603, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 1, "selected": false, "text": "<p>I break them down into pieces, and then reassemble the pieces when I've found the problem.</p>\n\n<p>Not good, but it's ...
2008/12/23
[ "https://Stackoverflow.com/questions/390409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/853/" ]
So far I've found it impossible to produce usable tracebacks when Mako templates aren't coded correctly. Is there any way to debug templates besides iterating for every line of code?
Mako actually provides a [VERY nice way to track down errors in a template](http://docs.makotemplates.org/en/latest/usage.html#handling-exceptions): ``` from mako import exceptions try: template = lookup.get_template(uri) print template.render() except: print exceptions.html_error_template().render() ```
390,420
<p>Hi I need to create a query in MSAccess 2003 through code (a.k.a. VB) -- how can I accomplish this?</p>
[ { "answer_id": 390439, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": 6, "selected": true, "text": "<p>A vague answer for a vague question :)</p>\n\n<pre><code>strSQL=\"SELECT * FROM tblT WHERE ID =\" &amp; Forms!Form1!txtI...
2008/12/23
[ "https://Stackoverflow.com/questions/390420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/428190/" ]
Hi I need to create a query in MSAccess 2003 through code (a.k.a. VB) -- how can I accomplish this?
A vague answer for a vague question :) ``` strSQL="SELECT * FROM tblT WHERE ID =" & Forms!Form1!txtID Set qdf=CurrentDB.CreateQueryDef("NewQuery",strSQL) DoCmd.OpenQuery qdf.Name ```
390,448
<p>I have a single windows shell command I'd like to run (via EXEC master..xp_cmdshell) once for each row in a table. I'm using information from various fields to build the command output.</p> <p>I'm relativity new to writing T-SQL programs (as opposed to individual queries) and can't quite get my head around the syn...
[ { "answer_id": 390489, "author": "jrcs3", "author_id": 3819, "author_profile": "https://Stackoverflow.com/users/3819", "pm_score": 4, "selected": true, "text": "<p>You could always use a cursor:</p>\n\n<pre><code>USE Northwind\n\nDECLARE @name VARCHAR(32)\nDECLARE @command VARCHAR(100)\n...
2008/12/24
[ "https://Stackoverflow.com/questions/390448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4668/" ]
I have a single windows shell command I'd like to run (via EXEC master..xp\_cmdshell) once for each row in a table. I'm using information from various fields to build the command output. I'm relativity new to writing T-SQL programs (as opposed to individual queries) and can't quite get my head around the syntax for th...
You could always use a cursor: ``` USE Northwind DECLARE @name VARCHAR(32) DECLARE @command VARCHAR(100) DECLARE shell_cursor CURSOR FOR SELECT LastName FROM Employees OPEN shell_cursor FETCH NEXT FROM shell_cursor INTO @name WHILE @@FETCH_STATUS = 0 BEGIN SET @command = 'echo ' + @name EXEC master.dbo.x...
390,475
<p>I have a problem that just started happening after I reinstalled my website's server.</p> <p>In the past I could do do this:</p> <p>Code:</p> <pre><code>&lt;% set msgSet = conn.execute("select * from base_scroller where scroller_num = 1" %&gt; </code></pre> <p>check if it's not empty or anything else</p> <p>C...
[ { "answer_id": 390529, "author": "AnonJr", "author_id": 25163, "author_profile": "https://Stackoverflow.com/users/25163", "pm_score": 0, "selected": false, "text": "<p>Never seen that problem before, nor am I sure why (more information on the error would be helpful) - but, as a relativel...
2008/12/24
[ "https://Stackoverflow.com/questions/390475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a problem that just started happening after I reinstalled my website's server. In the past I could do do this: Code: ``` <% set msgSet = conn.execute("select * from base_scroller where scroller_num = 1" %> ``` check if it's not empty or anything else Code: ``` <% if msgSet("scroller_name") <> "" then %>...
There are two things you should do to ensure you have a value in a field: 1. Make sure the recordset is not empty. 2. Make sure the field in the current does not have a NULL value. I am not away of any changes in the drivers that have affected your code, but I assume the difference is that your string actually return...
390,481
<p>I often use this code pattern:</p> <pre><code>while(true) { //do something if(&lt;some condition&gt;) { break; } } </code></pre> <p>Another programmer told me that this was bad practice and that I should replace it with the more standard:</p> <pre><code>while(!&lt;some condition&gt;) { ...
[ { "answer_id": 390493, "author": "yfeldblum", "author_id": 12349, "author_profile": "https://Stackoverflow.com/users/12349", "pm_score": 2, "selected": false, "text": "<p>The first is OK if there are many ways to break from the loop, or if the break condition cannot be expressed easily a...
2008/12/24
[ "https://Stackoverflow.com/questions/390481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
I often use this code pattern: ``` while(true) { //do something if(<some condition>) { break; } } ``` Another programmer told me that this was bad practice and that I should replace it with the more standard: ``` while(!<some condition>) { //do something } ``` His reasoning was ...
There is a discrepancy between the two examples. The first will execute the "do something" at least once every time even if the statement is never true. The second will only "do something" when the statement evaluates to true. I think what you are looking for is a do-while loop. I 100% agree that `while (true)` is not...
390,491
<p>I want to add a "Select One" option to a drop down list bound to a <code>List&lt;T&gt;</code>. </p> <p>Once I query for the <code>List&lt;T&gt;</code>, how do I add my initial <code>Item</code>, not part of the data source, as the FIRST element in that <code>List&lt;T&gt;</code> ? I have:</p> <pre><code>// popula...
[ { "answer_id": 390501, "author": "x0n", "author_id": 6920, "author_profile": "https://Stackoverflow.com/users/6920", "pm_score": 5, "selected": false, "text": "<p>Update: a better idea, set the \"AppendDataBoundItems\" property to true, then declare the \"Choose item\" declaratively. The...
2008/12/24
[ "https://Stackoverflow.com/questions/390491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35615/" ]
I want to add a "Select One" option to a drop down list bound to a `List<T>`. Once I query for the `List<T>`, how do I add my initial `Item`, not part of the data source, as the FIRST element in that `List<T>` ? I have: ``` // populate ti from data List<MyTypeItem> ti = MyTypeItem.GetTypeItems(); ...
Use the [Insert](http://msdn.microsoft.com/en-us/library/sey5k5z4.aspx) method: ``` ti.Insert(0, initialItem); ```
390,512
<p>I want to add a new time-field to a an existing MySQL-table that is formated like this "MM:SS". The field is supposed to hold duration-data. What is the correct MySQL syntax to do this? Couldn't find anything that covers this on the MySQL-site.</p>
[ { "answer_id": 390501, "author": "x0n", "author_id": 6920, "author_profile": "https://Stackoverflow.com/users/6920", "pm_score": 5, "selected": false, "text": "<p>Update: a better idea, set the \"AppendDataBoundItems\" property to true, then declare the \"Choose item\" declaratively. The...
2008/12/24
[ "https://Stackoverflow.com/questions/390512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24218/" ]
I want to add a new time-field to a an existing MySQL-table that is formated like this "MM:SS". The field is supposed to hold duration-data. What is the correct MySQL syntax to do this? Couldn't find anything that covers this on the MySQL-site.
Use the [Insert](http://msdn.microsoft.com/en-us/library/sey5k5z4.aspx) method: ``` ti.Insert(0, initialItem); ```
390,534
<p>Simply put, I have a table with, among other things, a column for timestamps. I want to get the row with the most recent (i.e. greatest value) timestamp. Currently I'm doing this:</p> <pre><code>SELECT * FROM table ORDER BY timestamp DESC LIMIT 1 </code></pre> <p>But I'd much rather do something like this:</p> <p...
[ { "answer_id": 390542, "author": "SquareCog", "author_id": 15962, "author_profile": "https://Stackoverflow.com/users/15962", "pm_score": 5, "selected": true, "text": "<pre><code>SELECT * from foo where timestamp = (select max(timestamp) from foo)\n</code></pre>\n\n<p>or, if SQLite insist...
2008/12/24
[ "https://Stackoverflow.com/questions/390534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/658/" ]
Simply put, I have a table with, among other things, a column for timestamps. I want to get the row with the most recent (i.e. greatest value) timestamp. Currently I'm doing this: ``` SELECT * FROM table ORDER BY timestamp DESC LIMIT 1 ``` But I'd much rather do something like this: ``` SELECT * FROM table WHERE ti...
``` SELECT * from foo where timestamp = (select max(timestamp) from foo) ``` or, if SQLite insists on treating subselects as sets, ``` SELECT * from foo where timestamp in (select max(timestamp) from foo) ```
390,554
<p>I'm trying to install SQL Server 2005 Express SP3 on two of my machines. When I try to do this I get this error message: "None of the selected features can be installed or upgraded. Setup cannot proceed since no effective change is being made to the machine. To continue, click Back and then select features to instal...
[ { "answer_id": 390542, "author": "SquareCog", "author_id": 15962, "author_profile": "https://Stackoverflow.com/users/15962", "pm_score": 5, "selected": true, "text": "<pre><code>SELECT * from foo where timestamp = (select max(timestamp) from foo)\n</code></pre>\n\n<p>or, if SQLite insist...
2008/12/24
[ "https://Stackoverflow.com/questions/390554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29821/" ]
I'm trying to install SQL Server 2005 Express SP3 on two of my machines. When I try to do this I get this error message: "None of the selected features can be installed or upgraded. Setup cannot proceed since no effective change is being made to the machine. To continue, click Back and then select features to install."...
``` SELECT * from foo where timestamp = (select max(timestamp) from foo) ``` or, if SQLite insists on treating subselects as sets, ``` SELECT * from foo where timestamp in (select max(timestamp) from foo) ```
390,565
<p>I have been testing out the <code>yield return</code> statement with some of the code I have been writing. I have two methods:</p> <pre><code>public static IEnumerable&lt;String&gt; MyYieldCollection { get { wrapper.RunCommand("Fetch First From Water_Mains"); for (int row =...
[ { "answer_id": 390592, "author": "Robert Wagner", "author_id": 10784, "author_profile": "https://Stackoverflow.com/users/10784", "pm_score": -1, "selected": false, "text": "<p>As far as I understand it, \"yield return\" will keep looping until it runs our of stuff to do and the function/...
2008/12/24
[ "https://Stackoverflow.com/questions/390565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6335/" ]
I have been testing out the `yield return` statement with some of the code I have been writing. I have two methods: ``` public static IEnumerable<String> MyYieldCollection { get { wrapper.RunCommand("Fetch First From Water_Mains"); for (int row = 0; row < tabinfo.GetNumberOfRow...
How have you done your timings? Are you in the debugger? In debug mode? It looks like you are using `DataTable`, so I used your code as the template for a test rig (creating 1000 rows each time), and used the harness as below, in release mode **at the command line**; the results were as follows (the number in brackets ...
390,575
<p>I am fairly new to PHP. What is the best way to control access to a class throughout a PHP application and where is the best place to store these classes that will need to be accessed throughout the entire application? Example; I have a user class that is created on during the login process, but each time the pa...
[ { "answer_id": 390593, "author": "UnkwnTech", "author_id": 115, "author_profile": "https://Stackoverflow.com/users/115", "pm_score": 2, "selected": false, "text": "<p>This kind of data is going to have to be stored in a session, the only thing that is carried from page to page is Session...
2008/12/24
[ "https://Stackoverflow.com/questions/390575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am fairly new to PHP. What is the best way to control access to a class throughout a PHP application and where is the best place to store these classes that will need to be accessed throughout the entire application? Example; I have a user class that is created on during the login process, but each time the page post...
You're right, the state of your application is not carried over from request to request. Contrarily to desktop applications, web applications won't stay initialized because to the server, every time it can be a another visitor, wanting something completely different. You know who's using the desktop application, but y...
390,578
<p>Take the following class as an example:</p> <pre><code>class Sometype { int someValue; public Sometype(int someValue) { this.someValue = someValue; } } </code></pre> <p>I then want to create an instance of this type using reflection:</p> <pre><code>Type t = typeof(Sometype); object o = Ac...
[ { "answer_id": 390596, "author": "Jason Jackson", "author_id": 13103, "author_profile": "https://Stackoverflow.com/users/13103", "pm_score": 8, "selected": true, "text": "<p>I originally posted this answer <a href=\"https://stackoverflow.com/questions/178645/how-does-wcf-deserialization-...
2008/12/24
[ "https://Stackoverflow.com/questions/390578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37472/" ]
Take the following class as an example: ``` class Sometype { int someValue; public Sometype(int someValue) { this.someValue = someValue; } } ``` I then want to create an instance of this type using reflection: ``` Type t = typeof(Sometype); object o = Activator.CreateInstance(t); ``` Norm...
I originally posted this answer [here](https://stackoverflow.com/questions/178645/how-does-wcf-deserialization-instantiate-objects-without-calling-a-constructor#179486), but here is a reprint since this isn't the exact same question but has the same answer: `FormatterServices.GetUninitializedObject()` will create an i...
390,584
<p>I have a question regarding a data binding(of multiple properties) for custom DataGridViewColumn. Here is a schema of what controls that I have, and I need to make it bindable with DataGridView datasource. Any ideas or a link to an article discussing the matter? </p> <p><strong>Controls</strong></p> <ul> <li>Grap...
[ { "answer_id": 425146, "author": "Malfist", "author_id": 12243, "author_profile": "https://Stackoverflow.com/users/12243", "pm_score": 0, "selected": false, "text": "<p>See my question <a href=\"https://stackoverflow.com/questions/389737/databinding-with-a-datagridview-c\">Here</a></p>\n...
2008/12/24
[ "https://Stackoverflow.com/questions/390584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48802/" ]
I have a question regarding a data binding(of multiple properties) for custom DataGridViewColumn. Here is a schema of what controls that I have, and I need to make it bindable with DataGridView datasource. Any ideas or a link to an article discussing the matter? **Controls** * Graph Control(custom): Displayed in th...
Thank you for your answer. My data sources is not a SQL data source, and as a matter of fact I was talking about datagridview for win-forms(I'm not sure that was clear). As I did not get the reply on any of the forums I was asking the question, I figured, I would outline a solution I came up with, for those who may h...
390,595
<p>I have an web application where I have a requirement to encrypt and store the connection string in the web.config. </p> <p>What is the best way to retrieve this and use this connection string with IBATIS.NET instead of storing the connection string in the SqlMap.config?</p>
[ { "answer_id": 410215, "author": "Nicholas Piasecki", "author_id": 32187, "author_profile": "https://Stackoverflow.com/users/32187", "pm_score": 3, "selected": true, "text": "<p>The last three messages of <a href=\"http://www.mail-archive.com/user-cs@ibatis.apache.org/msg01556.html\" rel...
2008/12/24
[ "https://Stackoverflow.com/questions/390595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10830/" ]
I have an web application where I have a requirement to encrypt and store the connection string in the web.config. What is the best way to retrieve this and use this connection string with IBATIS.NET instead of storing the connection string in the SqlMap.config?
The last three messages of [this discussion thread](http://www.mail-archive.com/user-cs@ibatis.apache.org/msg01556.html) discuss what you want. Essentially, you're overwriting the connection string iBATIS loads from the config file before your call to Configure(). For example, in your SqlMap.config: ``` <databas...
390,602
<p><strong>Question:</strong> How could I find out the M-x equivalent commands for doing GUI-based operations in Emacs, in those cases where my Emacs-variant uses OS-specific desktop functionality?</p> <p><strong>Background:</strong> Conventional understanding states that everything in Emacs is a command, and that com...
[ { "answer_id": 390617, "author": "Charlie Martin", "author_id": 35092, "author_profile": "https://Stackoverflow.com/users/35092", "pm_score": 2, "selected": false, "text": "<p>Wow, I'm glad you asked that. I've been meaning for a while to look it up myself.</p>\n\n<p><code>C-h k</code> ...
2008/12/24
[ "https://Stackoverflow.com/questions/390602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42223/" ]
**Question:** How could I find out the M-x equivalent commands for doing GUI-based operations in Emacs, in those cases where my Emacs-variant uses OS-specific desktop functionality? **Background:** Conventional understanding states that everything in Emacs is a command, and that commands can be invoked via M-x, as lon...
You need to trick Emacs into thinking that the keyboard was not being used, which is not as intuitive as tricking it into thinking that the mouse *was* used. :) ``` (defadvice find-file-read-args (around find-file-read-args-always-use-dialog-box act) "Simulate invoking menu item as if by the mouse; see `use-dialog-b...
390,615
<p>Is this a good way to implement a Finally-like behavior in standard C++? (Without special pointers)</p> <pre><code>class Exception : public Exception { public: virtual bool isException() { return true; } }; class NoException : public Exception { public: bool isException() { return false; } }; Object *myO...
[ { "answer_id": 390623, "author": "David Norman", "author_id": 34502, "author_profile": "https://Stackoverflow.com/users/34502", "pm_score": 6, "selected": true, "text": "<p>The standard answer is to use some variant of <a href=\"http://en.wikipedia.org/wiki/Resource_acquisition_is_initia...
2008/12/24
[ "https://Stackoverflow.com/questions/390615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47064/" ]
Is this a good way to implement a Finally-like behavior in standard C++? (Without special pointers) ``` class Exception : public Exception { public: virtual bool isException() { return true; } }; class NoException : public Exception { public: bool isException() { return false; } }; Object *myObject = 0; try...
The standard answer is to use some variant of [resource-allocation-is-initialization](http://en.wikipedia.org/wiki/Resource_acquisition_is_initialization) abbreviated RAII. Basically you construct a variable that has the same scope as the block that would be inside the block before the finally, then do the work in the ...
390,632
<p>Suppose I have the following class:</p> <pre><code>public class TestBase { public bool runMethod1 { get; set; } public void BaseMethod() { if (runMethod1) ChildMethod1(); else ChildMethod2(); } protected abstract void ChildMethod1(); protected abstract void ChildMethod2(); } </co...
[ { "answer_id": 390657, "author": "flukus", "author_id": 407256, "author_profile": "https://Stackoverflow.com/users/407256", "pm_score": 0, "selected": false, "text": "<p>It seems like your testing the behaviour rather than the public interface. If this is intended then you could probably...
2008/12/24
[ "https://Stackoverflow.com/questions/390632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/571/" ]
Suppose I have the following class: ``` public class TestBase { public bool runMethod1 { get; set; } public void BaseMethod() { if (runMethod1) ChildMethod1(); else ChildMethod2(); } protected abstract void ChildMethod1(); protected abstract void ChildMethod2(); } ``` I also have ...
You can also set the expectation/setup as Verifiable and do without a strict mock: ``` //expect that ChildMethod1() will be called once. (it's protected) testBaseMock.Protected().Expect("ChildMethod1") .AtMostOnce() .Verifiable(); ... //make sure the method was called testBase.Verify(); ``` **Edi...
390,641
<p>In erlang, there are bitwise operations to operate on integers, for example:</p> <pre><code>1&gt 127 bsl 1. 254 </code></pre> <p>there is also the ability to pack integers into a sequence of bytes</p> <pre><code>&lt&lt 16#7F, 16#FF &gt&gt</code></pre> <p>is it possible, or are there any operators or BIFs that c...
[ { "answer_id": 390714, "author": "Mike Hamer", "author_id": 42050, "author_profile": "https://Stackoverflow.com/users/42050", "pm_score": 0, "selected": false, "text": "<p>Using Erlang's unbounded integer sizes we can accomplish this:</p>\n\n<pre><code>1&gt; Bits = &lt;&lt;16#0FFFFFFF:(4...
2008/12/24
[ "https://Stackoverflow.com/questions/390641", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42050/" ]
In erlang, there are bitwise operations to operate on integers, for example: ``` 1> 127 bsl 1. 254 ``` there is also the ability to pack integers into a sequence of bytes ``` << 16#7F, 16#FF >> ``` is it possible, or are there any operators or BIFs that can perform bitwise operations (eg AND, OR, XOR, SHL, SHR) o...
Try out this way: ``` bbsl(Bin,Shift) -> <<_:Shift,Rest/bits>> = Bin, <<Rest/bits,0:Shift>>. ```
390,675
<p>I am using AS3 to create a tween affect between multiple images that have a drop shadow around them - it works great, except after 3+ tweens the drop shadow starts getting darker and darker - that makes sense, but not really want i want to happen.</p> <p>Ideally i would like to tween between 2 images, on the 3rd cl...
[ { "answer_id": 390652, "author": "Jon Limjap", "author_id": 372, "author_profile": "https://Stackoverflow.com/users/372", "pm_score": 4, "selected": false, "text": "<p>Because Windows Server and SQL Server licenses cost a <em>lot</em> of money, per <em>CPU Core</em> (and not just per mac...
2008/12/24
[ "https://Stackoverflow.com/questions/390675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26685/" ]
I am using AS3 to create a tween affect between multiple images that have a drop shadow around them - it works great, except after 3+ tweens the drop shadow starts getting darker and darker - that makes sense, but not really want i want to happen. Ideally i would like to tween between 2 images, on the 3rd clear it out...
Because Windows Server and SQL Server licenses cost a *lot* of money, per *CPU Core* (and not just per machine), and so your hosting provider needs to recuperate costs for the license. This is on top of the usual operating overhead (which is the only thing Linux servers cover). I also feel your pain, because I maint...
390,693
<p>I've been fiddling with ASP.NET MVC since the CTP, and I like a lot of things they did, but there are things I just don't get.</p> <p>For example, I downloaded beta1, and I'm putting together a little personal site/resume/blog with it. Here is a snippet from the ViewSinglePost view:</p> <pre><code> &lt;% /...
[ { "answer_id": 390704, "author": "mson", "author_id": 36902, "author_profile": "https://Stackoverflow.com/users/36902", "pm_score": -1, "selected": false, "text": "<p>The implementation ASP.NET MVC is horrible. The product plain sucks. I've seen several demos of it and I'm ashamed of M...
2008/12/24
[ "https://Stackoverflow.com/questions/390693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965/" ]
I've been fiddling with ASP.NET MVC since the CTP, and I like a lot of things they did, but there are things I just don't get. For example, I downloaded beta1, and I'm putting together a little personal site/resume/blog with it. Here is a snippet from the ViewSinglePost view: ``` <% // Display the "Next and ...
Compared to Web Forms, MVC is simultaneously a lower-level approach to HTML generation with greater control over the page output *and* a higher-level, more architecturally-driven approach. Let me capture Web Forms and MVC and show why I think that the comparison favors Web Forms in many situations - as long as you don'...
390,702
<p>I have to following code:</p> <p><a href="http://www.nomorepasting.com/getpaste.php?pasteid=22987" rel="nofollow noreferrer">http://www.nomorepasting.com/getpaste.php?pasteid=22987</a></p> <p>If <code>PHPSESSID</code> is not already in the table the <code>REPLACE INTO</code> query works just fine, however if <code...
[ { "answer_id": 391085, "author": "Zoredache", "author_id": 20267, "author_profile": "https://Stackoverflow.com/users/20267", "pm_score": 1, "selected": false, "text": "<p>Why are you trying to doing your prepare in the session open function? I don't believe the write function is called ...
2008/12/24
[ "https://Stackoverflow.com/questions/390702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13834/" ]
I have to following code: <http://www.nomorepasting.com/getpaste.php?pasteid=22987> If `PHPSESSID` is not already in the table the `REPLACE INTO` query works just fine, however if `PHPSESSID` exists the call to execute succeeds but sqlstate is set to 'HY000' which isn't very helpful and `$_mysqli_session_write->errno...
So as it turns out there are other issues with using REPLACE that I was not aware of: [Bug #10795: REPLACE reallocates new AUTO\_INCREMENT](http://bugs.mysql.com/bug.php?id=10795) (Which according to the comments is not actually a bug but the 'expected' behaviour) As a result my id field keeps getting incremented so ...
390,703
<p>While looking at online code samples, I have sometimes come across an assignment of a String constant to a String object via the use of the new operator.</p> <p>For example:</p> <pre><code>String s; ... s = new String("Hello World"); </code></pre> <p>This, of course, compared to</p> <pre><code>s = "Hello World";...
[ { "answer_id": 390722, "author": "Charlie Martin", "author_id": 35092, "author_profile": "https://Stackoverflow.com/users/35092", "pm_score": -1, "selected": false, "text": "<p>Generally, this indicates someone who isn't comfortable with the new-fashioned C++ style of declaring when init...
2008/12/24
[ "https://Stackoverflow.com/questions/390703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23072/" ]
While looking at online code samples, I have sometimes come across an assignment of a String constant to a String object via the use of the new operator. For example: ``` String s; ... s = new String("Hello World"); ``` This, of course, compared to ``` s = "Hello World"; ``` I'm not familiar with this syntax and...
The one place where you may *think* you want `new String(String)` is to force a distinct copy of the internal character array, as in ``` small=new String(huge.substring(10,20)) ``` However, this behavior is unfortunately undocumented and implementation dependent. I have been burned by this when reading large files...
390,723
<p>I am trying to install an app inside of another web app. I have my .aspx pages and some code that I was putting into the main app's app_code folder. I've added my own web.config file for my connection string and such but I think there's a conflict. So my question is a two parter. First, what is the best way to insta...
[ { "answer_id": 390722, "author": "Charlie Martin", "author_id": 35092, "author_profile": "https://Stackoverflow.com/users/35092", "pm_score": -1, "selected": false, "text": "<p>Generally, this indicates someone who isn't comfortable with the new-fashioned C++ style of declaring when init...
2008/12/24
[ "https://Stackoverflow.com/questions/390723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45429/" ]
I am trying to install an app inside of another web app. I have my .aspx pages and some code that I was putting into the main app's app\_code folder. I've added my own web.config file for my connection string and such but I think there's a conflict. So my question is a two parter. First, what is the best way to install...
The one place where you may *think* you want `new String(String)` is to force a distinct copy of the internal character array, as in ``` small=new String(huge.substring(10,20)) ``` However, this behavior is unfortunately undocumented and implementation dependent. I have been burned by this when reading large files...
390,727
<p>I'm just finishing a web page for our sales guy to quickly go through a list of contacts. </p> <p>Is it possible to initiate a call from our Vonage line via a Hyperlink?</p> <p>They offer an application called "Click-2-Call" but I hope it's possible to initiate it using only a Hyperlink.</p>
[ { "answer_id": 390791, "author": "EndangeredMassa", "author_id": 106, "author_profile": "https://Stackoverflow.com/users/106", "pm_score": 2, "selected": true, "text": "<p>This would probably require an addon to support a custom protocol that allows your Vonage system to function in this...
2008/12/24
[ "https://Stackoverflow.com/questions/390727", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3747/" ]
I'm just finishing a web page for our sales guy to quickly go through a list of contacts. Is it possible to initiate a call from our Vonage line via a Hyperlink? They offer an application called "Click-2-Call" but I hope it's possible to initiate it using only a Hyperlink.
This would probably require an addon to support a custom protocol that allows your Vonage system to function in this way. I imagine that something like ``` Call <a href="phone: 123-456-7890">123-456-7890</a> ``` Where the "phone" protocol would be recognized as a phone number that could be called by some default v...
390,730
<p>I'm quite new to database design and have some questions about best practices and would really like to learn. I am designing a database schema, I have a good idea of the requirements and now its a matter of getting it into black and white.</p> <p>In this pseudo-database-layout, I have a table of customers, table of...
[ { "answer_id": 390745, "author": "dtc", "author_id": 32892, "author_profile": "https://Stackoverflow.com/users/32892", "pm_score": 3, "selected": false, "text": "<p>The most common way would be to store the order items in another table.</p>\n\n<pre><code>TBL_ORDER:\nID\nTBL_CUSTOMER.ID\n...
2008/12/24
[ "https://Stackoverflow.com/questions/390730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29820/" ]
I'm quite new to database design and have some questions about best practices and would really like to learn. I am designing a database schema, I have a good idea of the requirements and now its a matter of getting it into black and white. In this pseudo-database-layout, I have a table of customers, table of orders an...
The most common way would be to store the order items in another table. ``` TBL_ORDER: ID TBL_CUSTOMER.ID TBL_ORDER_ITEM: ID TBL_ORDER.ID TBL_PRODUCTS.ID Quantity UniqueDetails ``` The same can apply to your Order audit trail. It can be a new table such as ``` TBL_ORDER_AUDIT: ID TBL_ORDER.ID AuditDetails ```
390,731
<p>how do we call a C function from an SQL script?</p> <pre><code>int get_next_fbill_b2kId_seq_num(b2kIdType seq_val,bankIdPtrType bank_id) { validate_dc_alias(dcAlias); tbaDateType sysDate; tbaGetSystemDateTime(sysDate,NULL,NULL); /* returns in TBA date format */ sysDate[10] = EOS; get_seq_value(...
[ { "answer_id": 391055, "author": "devio", "author_id": 21336, "author_profile": "https://Stackoverflow.com/users/21336", "pm_score": 0, "selected": false, "text": "<p>If your function is plain C, you need to create an executable and invoke it via <a href=\"http://www.orafaq.com/wiki/SQL*...
2008/12/24
[ "https://Stackoverflow.com/questions/390731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
how do we call a C function from an SQL script? ``` int get_next_fbill_b2kId_seq_num(b2kIdType seq_val,bankIdPtrType bank_id) { validate_dc_alias(dcAlias); tbaDateType sysDate; tbaGetSystemDateTime(sysDate,NULL,NULL); /* returns in TBA date format */ sysDate[10] = EOS; get_seq_value(next_num_char,...
I assume the OP uses Oracle because he/she writes about PL/SQL. It is possible to call an external c procedure. <http://www.shutdownabort.com/quickguides/c_extproc.php>
390,736
<p>How do you open a file from a java application when you do not know which application the file is associated with. Also, because I'm using Java, I'd prefer a platform independent solution.</p>
[ { "answer_id": 390750, "author": "Dave Ray", "author_id": 40310, "author_profile": "https://Stackoverflow.com/users/40310", "pm_score": 2, "selected": false, "text": "<p>You could hack something together with a bat file on Windows and equivalent on Unix, but that wouldn't be that fun. </...
2008/12/24
[ "https://Stackoverflow.com/questions/390736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36858/" ]
How do you open a file from a java application when you do not know which application the file is associated with. Also, because I'm using Java, I'd prefer a platform independent solution.
With JDK1.6, the [`java.awt.Desktop`](http://java.sun.com/javase/6/docs/api/java/awt/Desktop.html) class can be useful. ``` public static void open(File document) throws IOException { Desktop dt = Desktop.getDesktop(); dt.open(document); } ```
390,748
<p>let's say that I have an XML file containing this :</p> <pre><code>&lt;description&gt;&lt;![CDATA[ &lt;h2&gt;lorem ipsum&lt;/h2&gt; &lt;p&gt;some text&lt;/p&gt; ]]&gt;&lt;/description&gt; </code></pre> <p>that I want to get and parse in ActionScript 2 as HTML text, and setting some CSS before displaying it...
[ { "answer_id": 392307, "author": "gltovar", "author_id": 2855, "author_profile": "https://Stackoverflow.com/users/2855", "pm_score": 1, "selected": false, "text": "<p>its been a while since I've tinkered with AS2.</p>\n\n<pre><code>someXML = new XML();\nsomeXML.ignoreWhite = true;\n</cod...
2008/12/24
[ "https://Stackoverflow.com/questions/390748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26721/" ]
let's say that I have an XML file containing this : ``` <description><![CDATA[ <h2>lorem ipsum</h2> <p>some text</p> ]]></description> ``` that I want to get and parse in ActionScript 2 as HTML text, and setting some CSS before displaying it. Problem is, Flash takes those whitespaces (line feed and tab) and ...
Several ways to approach this. Perhaps the simplest answer is, in one sense your Flash developer is probably right, and you should move your whitespace outside of the CDATA container. The reason being, many people (me at least) tend to assume that everything inside a CDATA is "real data", as opposed to markup. On the o...
390,753
<p>Or is it okay to do something like this:</p> <pre><code>new Thread( new ThreadStart( delegate { DoSomething(); } ) ).Start(); </code></pre> <p>?</p> <p>I seem to recall that under such a scenario, the Thread object would be garbage collected, but the underlying OS thread would continue to run until the end of the...
[ { "answer_id": 390767, "author": "Gant", "author_id": 12460, "author_profile": "https://Stackoverflow.com/users/12460", "pm_score": 2, "selected": false, "text": "<p>It depends. In the situation where the user can cancel the operation of your thread, you should keep the reference so the ...
2008/12/24
[ "https://Stackoverflow.com/questions/390753", "https://Stackoverflow.com", "https://Stackoverflow.com/users/238948/" ]
Or is it okay to do something like this: ``` new Thread( new ThreadStart( delegate { DoSomething(); } ) ).Start(); ``` ? I seem to recall that under such a scenario, the Thread object would be garbage collected, but the underlying OS thread would continue to run until the end of the delegate passed into it. I'm bas...
I have generally found that if I need to directly start a new thread the way you are in your example, rather than grabbing one from the thread pool, then it is a long running thread and I will need a reference to it later to kill it, monitor it, etc. For short run threads like invoking IO on a background thread, etc, I...
390,798
<p>I have a business case whereby I need to be able to specify my own calling convention when using P/Invoke. Specifically, I have a legacy dll which uses a non-standard ABI, and I need to able to specify the calling convention for each function. </p> <p>For example, one function in this dll accepts its first two argu...
[ { "answer_id": 391992, "author": "Joel Lucsy", "author_id": 645, "author_profile": "https://Stackoverflow.com/users/645", "pm_score": 0, "selected": false, "text": "<p>I'm fairly certain there is no builtin way of accomplishing what you want without a separate dll. I've not seen a way to...
2008/12/24
[ "https://Stackoverflow.com/questions/390798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48821/" ]
I have a business case whereby I need to be able to specify my own calling convention when using P/Invoke. Specifically, I have a legacy dll which uses a non-standard ABI, and I need to able to specify the calling convention for each function. For example, one function in this dll accepts its first two arguments via ...
I don't understand what you mean with custom P/Invoke, but I can't see how you could get away without non-managed C++ with inline assembly. However, since almost everything is passed as 32-bit values, you might get away with writing only one proxy for each function signature, as apposed to one per function. Or you coul...
390,800
<p>Create a class (call it FormElement). That class should have some properties like the metadata they have with data elements (name, sequence number, value—which is just a string, etc).</p> <p>This class has as attributes of type Validation Application Block Validation classes.</p> <p>I want to serialize it to xml ...
[ { "answer_id": 390811, "author": "Uri", "author_id": 23072, "author_profile": "https://Stackoverflow.com/users/23072", "pm_score": 0, "selected": false, "text": "<p>By saying serialize, do you mean use the official Serialization mechanism, or achieve a similar effect?</p>\n\n<p>If your o...
2008/12/24
[ "https://Stackoverflow.com/questions/390800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48824/" ]
Create a class (call it FormElement). That class should have some properties like the metadata they have with data elements (name, sequence number, value—which is just a string, etc). This class has as attributes of type Validation Application Block Validation classes. I want to serialize it to xml and deserialize it...
The .NET framework has this built in, using C# you would do it like this: ``` // This code serializes a class instance to an XML file: XmlSerializer xs = new XmlSerializer(typeof(objectToSerialize)); using (TextWriter writer = new StreamWriter(xmlFileName)) { xs.Serialize(writer, InstanceOfObjectToSerialize); } ...
390,819
<p>How would you refactor this, keeping in mind that you have dozens more of such measurements to represent? It's kind of like changing an int to short or long or byte. Generic <code>unit&lt;T&gt;</code>? Implicit type conversion by via operator overloading? <code>ToType()</code> pattern? Abstract base class? <code>ICo...
[ { "answer_id": 390827, "author": "Jon Limjap", "author_id": 372, "author_profile": "https://Stackoverflow.com/users/372", "pm_score": 0, "selected": false, "text": "<p>I think I'll just turn it into an <code>struct</code>, which most primitives are anyway.</p>\n" }, { "answer_id"...
2008/12/24
[ "https://Stackoverflow.com/questions/390819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11574/" ]
How would you refactor this, keeping in mind that you have dozens more of such measurements to represent? It's kind of like changing an int to short or long or byte. Generic `unit<T>`? Implicit type conversion by via operator overloading? `ToType()` pattern? Abstract base class? `IConvertible`? ``` public class lb { ...
I wouldn't create separate classes for each weight. Instead, have one class that represents a unit and another that represents a number with a unit: ``` /// <summary> /// Class representing a unit of weight, including how to /// convert that unit to kg. /// </summary> class WeightUnit { private readonly float conv...
390,838
<p>I started a new WPF project in VS2008 and then added some code to trap <code>DispatcherUnhandledException</code>. Then I added a throw exception to <code>Window1</code> but the error is not trapped by the handler. Why?</p> <pre><code> public App() { this.DispatcherUnhandledException += new DispatcherU...
[ { "answer_id": 390973, "author": "Malcolm", "author_id": 40568, "author_profile": "https://Stackoverflow.com/users/40568", "pm_score": 1, "selected": false, "text": "<p>For those interested</p>\n\n<p>It seems that the IDE is still breaking on exceptions and that if you click continue in ...
2008/12/24
[ "https://Stackoverflow.com/questions/390838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40568/" ]
I started a new WPF project in VS2008 and then added some code to trap `DispatcherUnhandledException`. Then I added a throw exception to `Window1` but the error is not trapped by the handler. Why? ``` public App() { this.DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(App_Di...
This can happen because of the way you have the debugger handling exceptions -- Debug/Exceptions... should allow you to configure exactly how you want it handled.
390,852
<p>For example, files, in Python, are iterable - they iterate over the lines in the file. I want to count the number of lines. </p> <p>One quick way is to do this:</p> <pre><code>lines = len(list(open(fname))) </code></pre> <p>However, this loads the whole file into memory (at once). This rather defeats the purpose ...
[ { "answer_id": 390861, "author": "mcrute", "author_id": 33786, "author_profile": "https://Stackoverflow.com/users/33786", "pm_score": 5, "selected": false, "text": "<p>If you need a count of lines you can do this, I don't know of any better way to do it:</p>\n\n<pre><code>line_count = su...
2008/12/24
[ "https://Stackoverflow.com/questions/390852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
For example, files, in Python, are iterable - they iterate over the lines in the file. I want to count the number of lines. One quick way is to do this: ``` lines = len(list(open(fname))) ``` However, this loads the whole file into memory (at once). This rather defeats the purpose of an iterator (which only needs ...
Short of iterating through the iterable and counting the number of iterations, no. That's what makes it an iterable and not a list. This isn't really even a python-specific problem. Look at the classic linked-list data structure. Finding the length is an O(n) operation that involves iterating the whole list to find the...
390,860
<p>I use WiX3 to generate MSI installation package. I have specified comression flag on in both the <code>&lt;Package&gt;</code> and <code>&lt;Media&gt;</code> elements:</p> <pre><code>&lt;Package InstallerVersion="200" Compressed="yes"/&gt; &lt;Media Id="1" Cabinet="MySetup.cab" EmbedCab="yes" CompressionLevel="high...
[ { "answer_id": 391233, "author": "wimh", "author_id": 33499, "author_profile": "https://Stackoverflow.com/users/33499", "pm_score": 3, "selected": true, "text": "<p>There is something missing in your question. But how do you know it is not compressed. If Winzip can compress it further, i...
2008/12/24
[ "https://Stackoverflow.com/questions/390860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48829/" ]
I use WiX3 to generate MSI installation package. I have specified comression flag on in both the `<Package>` and `<Media>` elements: ``` <Package InstallerVersion="200" Compressed="yes"/> <Media Id="1" Cabinet="MySetup.cab" EmbedCab="yes" CompressionLevel="high" /> ``` but the resulting MSI is not compressed at all...
There is something missing in your question. But how do you know it is not compressed. If Winzip can compress it further, it does not always mean it is not compressed. You can use [7-zip](http://7-zip.org/) to investigate the resulting msi file. There should be a cab inside, extract it, and look at the size before and ...
390,889
<p>What is the difference between a Function and a Procedure in SQL Server?</p>
[ { "answer_id": 390927, "author": "Charles Graham", "author_id": 7705, "author_profile": "https://Stackoverflow.com/users/7705", "pm_score": 1, "selected": false, "text": "<p>You can embed functions in SQL statements just like you would any native SQL funcion like COALESCE, CONVERT, etc. ...
2008/12/24
[ "https://Stackoverflow.com/questions/390889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48581/" ]
What is the difference between a Function and a Procedure in SQL Server?
You can embed functions in SQL statements just like you would any native SQL funcion like COALESCE, CONVERT, etc. Procs can return a value, but the values that an be returned are limited. For example, if I recall correctly, you can return a table variable from a function, but not a stored proc. **So with a function, y...
390,891
<p>I use C# to make connection to a db and then a Ad hoc SQL to get data. This simple SQL query is very convenient to debug since I can log the SQL query string. If I use parametrized SQL query command, is there any way to log sql query string for debug purpose?</p>
[ { "answer_id": 391151, "author": "bortzmeyer", "author_id": 15625, "author_profile": "https://Stackoverflow.com/users/15625", "pm_score": 1, "selected": false, "text": "<p>Using the \"debug\" flag of your library is often the simplest solution. But you're dependent on the library which c...
2008/12/24
[ "https://Stackoverflow.com/questions/390891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62776/" ]
I use C# to make connection to a db and then a Ad hoc SQL to get data. This simple SQL query is very convenient to debug since I can log the SQL query string. If I use parametrized SQL query command, is there any way to log sql query string for debug purpose?
I think this is about it. Place this code where you have configured the query command and you'll have the into `debugSQL` the SQL statement which will be executed ``` string debugSQL = cmd.CommandText; foreach (SqlParameter param in cmd.Parameters) { debugSQL = debugSQL.Replace(param.ParameterName, param.Value.To...
390,900
<p>According to the documentation of the <code>==</code> operator in <a href="http://msdn.microsoft.com/en-us/library/53k8ybth.aspx" rel="noreferrer">MSDN</a>, </p> <blockquote> <p>For predefined value types, the equality operator (==) returns true if the values of its operands are equal, false otherwise. For ...
[ { "answer_id": 390916, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 4, "selected": false, "text": "<p>The compile can't know T couldn't be a struct (value type). So you have to tell it it can only be of ref...
2008/12/24
[ "https://Stackoverflow.com/questions/390900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41283/" ]
According to the documentation of the `==` operator in [MSDN](http://msdn.microsoft.com/en-us/library/53k8ybth.aspx), > > For predefined value types, the > equality operator (==) returns true if > the values of its operands are equal, > false otherwise. For reference types > other than string, == returns true if...
"...by default == behaves as described above for both predefined and user-defined reference types." Type T is not necessarily a reference type, so the compiler can't make that assumption. However, this will compile because it is more explicit: ``` bool Compare<T>(T x, T y) where T : class { return x ...
390,921
<p>Just wondering if anyone has any ideas on how to test ones data access methods. I have found testing retrieval data access methods is much easier because i can just mock out the <code>ExecuteReader</code> and return a populated <code>dataTable.CreateDataReader()</code>. By doing this I can test to see if my object i...
[ { "answer_id": 390916, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 4, "selected": false, "text": "<p>The compile can't know T couldn't be a struct (value type). So you have to tell it it can only be of ref...
2008/12/24
[ "https://Stackoverflow.com/questions/390921", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30572/" ]
Just wondering if anyone has any ideas on how to test ones data access methods. I have found testing retrieval data access methods is much easier because i can just mock out the `ExecuteReader` and return a populated `dataTable.CreateDataReader()`. By doing this I can test to see if my object is populating correctly if...
"...by default == behaves as described above for both predefined and user-defined reference types." Type T is not necessarily a reference type, so the compiler can't make that assumption. However, this will compile because it is more explicit: ``` bool Compare<T>(T x, T y) where T : class { return x ...
390,923
<p>I want to self-draw the title bar of a window with MFC. So I override the OnNcPaint() method of CMainFrame. Everything seems alright, until I click the item in the control menu to make it minimize or maximize. During the minizing or maximizing process, I can see the original title bar appeared. I don't know why this...
[ { "answer_id": 390933, "author": "Windows programmer", "author_id": 23705, "author_profile": "https://Stackoverflow.com/users/23705", "pm_score": 0, "selected": false, "text": "<p>You can use Spy++ to see what messages a window received. I have vague memories of OnSize coming earlier th...
2008/12/24
[ "https://Stackoverflow.com/questions/390923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26404/" ]
I want to self-draw the title bar of a window with MFC. So I override the OnNcPaint() method of CMainFrame. Everything seems alright, until I click the item in the control menu to make it minimize or maximize. During the minizing or maximizing process, I can see the original title bar appeared. I don't know why this ha...
*During* the minimize/maximize process? Sounds like min/max animations. You could verify this by disabling the animations via My Computer > Properties > Advanced > (Performance) Settings. As for the title question, you will get WM\_SIZE. Take a look at the docs for [CWnd::OnSize](http://msdn.microsoft.com/en-us/librar...
390,930
<p>I'm creating an asp.net mvc application that has the concept of users. Each user is able to edit their own profile. For instance: </p> <ul> <li>PersonID=1 can edit their profile by going to <a href="http://localhost/person/edit/1" rel="noreferrer">http://localhost/person/edit/1</a></li> <li>PersonID=2 can edit t...
[ { "answer_id": 390942, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 6, "selected": false, "text": "<p>Maybe you could organize the controller action such that the URL is more like <a href=\"http://localhost/person/editm...
2008/12/24
[ "https://Stackoverflow.com/questions/390930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29092/" ]
I'm creating an asp.net mvc application that has the concept of users. Each user is able to edit their own profile. For instance: * PersonID=1 can edit their profile by going to <http://localhost/person/edit/1> * PersonID=2 can edit their profile by going to <http://localhost/person/edit/2> Nothing particularly exci...
Maybe you could organize the controller action such that the URL is more like <http://localhost/person/editme> and it displays the edit form for the currently-logged-in user. That way there's no way a user could hack the URL to edit someone else.
390,932
<p><a href="https://stackoverflow.com/questions/390192">I was trying to get my Netbeans to autocomplete with PHP</a>, and I learned that this code is valid in PHP:</p> <pre><code>function blah(Bur $bur) {} </code></pre> <p>A couple of questions:</p> <ol> <li><strong>Does this actually impose any limits</strong> on w...
[ { "answer_id": 390939, "author": "J Cooper", "author_id": 38803, "author_profile": "https://Stackoverflow.com/users/38803", "pm_score": 3, "selected": false, "text": "<p>It's called type hinting, added with PHP 5. It isn't quite what you may be expecting if you are coming from a language...
2008/12/24
[ "https://Stackoverflow.com/questions/390932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8047/" ]
[I was trying to get my Netbeans to autocomplete with PHP](https://stackoverflow.com/questions/390192), and I learned that this code is valid in PHP: ``` function blah(Bur $bur) {} ``` A couple of questions: 1. **Does this actually impose any limits** on what type of variable I can pass to the blah method? 2. If th...
This type-hinting only works for validating function arguments; you can't declare that a PHP variable must always be of a certain type. This means that in your example, $bur must be of type Bur when "blah" is called, but $bur could be reassigned to a non-Bur value inside the function. Type-hinting only works for class...
390,944
<p>It's basically one app that is installed on multiple PC's, each install maintaining it's own database which is sync'd with other's as &amp; when they are up (connected to the same network) at the same time.</p> <p>I've tested this using simple socket connections and custom buffers, but want to make the comms betwee...
[ { "answer_id": 390964, "author": "gimel", "author_id": 6491, "author_profile": "https://Stackoverflow.com/users/6491", "pm_score": 3, "selected": false, "text": "<p>See <a href=\"http://en.wikipedia.org/wiki/Publish_subscribe\" rel=\"nofollow noreferrer\">Publish / Subscribe</a> asynchro...
2008/12/24
[ "https://Stackoverflow.com/questions/390944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15161/" ]
It's basically one app that is installed on multiple PC's, each install maintaining it's own database which is sync'd with other's as & when they are up (connected to the same network) at the same time. I've tested this using simple socket connections and custom buffers, but want to make the comms between the apps con...
Hmm, This is a bit like a math problem. The question of how two computers **establish a connection** once they find each other is fairly straightforward. You can use any number of P2P or client-server protocols. [SSL](http://www.apache-ssl.org/) is almost universally available but you could also serve [SSH](http://ww...
390,945
<p>I have a set of tables in Oracle and I would like to identify the table that contains the maximum number of rows.</p> <p>So if, A has 200 rows, B has 345 rows and C has 120 rows I want to be able to identify table B.</p> <p>Is there a simple query I can run to achieve this?</p> <p>Edit: There are 100 + tables so ...
[ { "answer_id": 390949, "author": "friol", "author_id": 23034, "author_profile": "https://Stackoverflow.com/users/23034", "pm_score": 1, "selected": false, "text": "<pre><code>select max(select count(*) from A union select count(*) from B...)\n</code></pre>\n\n<p>should work.</p>\n\n<p>ed...
2008/12/24
[ "https://Stackoverflow.com/questions/390945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41766/" ]
I have a set of tables in Oracle and I would like to identify the table that contains the maximum number of rows. So if, A has 200 rows, B has 345 rows and C has 120 rows I want to be able to identify table B. Is there a simple query I can run to achieve this? Edit: There are 100 + tables so I am looking for somethi...
Given that you said you were using Oracle I would just query the meta-data. ``` select table_name, max(num_rows) from all_tables where table_name in ('A', 'B', 'C'); ``` Just saw your edit. Just run the above without the where clause and it will return the largest table in the database. Only problem may be that you...
390,993
<p>I am building a rails app to test our flagship product (also web based). The problem is that part of the testing requires using the production app's web interface to upload files. So what i need to do is have the rails app upload these files to the production application (not rails). Is there a way to have rails ...
[ { "answer_id": 390998, "author": "diclophis", "author_id": 32678, "author_profile": "https://Stackoverflow.com/users/32678", "pm_score": 2, "selected": false, "text": "<p>Sure, use the net/http library...</p>\n\n<p><a href=\"http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net...
2008/12/24
[ "https://Stackoverflow.com/questions/390993", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5004/" ]
I am building a rails app to test our flagship product (also web based). The problem is that part of the testing requires using the production app's web interface to upload files. So what i need to do is have the rails app upload these files to the production application (not rails). Is there a way to have rails post t...
If you just need to upload files, I think it's pointless to use a plugin for this. File upload is very, very simple. ``` class Upload < ActiveRecord::Base before_create :set_filename after_create :store_file after_destroy :delete_file validates_presence_of :uploaded_file attr_accessor :uploaded_file def...
390,997
<p>I have a weird error in my C++ classes at the moment. I have an ActiveX wrapper class (as part of wxWidgets) that i added a new virtual function to. I have another class that inherits from the ActiveX one (wxIEHtmlWin) however the ActiveX class always calls its own function instead of the one in wxIEHtmlWin which ov...
[ { "answer_id": 391015, "author": "richq", "author_id": 4596, "author_profile": "https://Stackoverflow.com/users/4596", "pm_score": 4, "selected": true, "text": "<p>You are calling the virtual method from within the class's constructor (via another call). This will call the method on the ...
2008/12/24
[ "https://Stackoverflow.com/questions/390997", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23339/" ]
I have a weird error in my C++ classes at the moment. I have an ActiveX wrapper class (as part of wxWidgets) that i added a new virtual function to. I have another class that inherits from the ActiveX one (wxIEHtmlWin) however the ActiveX class always calls its own function instead of the one in wxIEHtmlWin which overr...
You are calling the virtual method from within the class's constructor (via another call). This will call the method on the current class as the sub-class hasn't been constructed yet. The fix is to use an init() method and call it after constructing the class. i.e something like this: ``` class wxActivex { wxActive...
391,000
<p>I have a date variable as <code>24-dec-08</code>. I want only the <code>08</code> component from it.</p> <p>How do I do it in a select statement?</p> <p>e.g.:</p> <pre><code>select db||sysdate --(this is the component where I want only 08 from the date) from gct; </code></pre>
[ { "answer_id": 391009, "author": "splattne", "author_id": 6461, "author_profile": "https://Stackoverflow.com/users/6461", "pm_score": 4, "selected": true, "text": "<p>The easiest way is to use the <code>to_char</code> function this way:</p>\n\n<pre><code>to_char(sysdate, 'YY')\n</code></...
2008/12/24
[ "https://Stackoverflow.com/questions/391000", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a date variable as `24-dec-08`. I want only the `08` component from it. How do I do it in a select statement? e.g.: ``` select db||sysdate --(this is the component where I want only 08 from the date) from gct; ```
The easiest way is to use the `to_char` function this way: ``` to_char(sysdate, 'YY') ``` as [documented here](http://www.techonthenet.com/oracle/functions/to_char.php). If you need the integer value, you could use the `extract` function for dates too. Take a look [here](http://www.techonthenet.com/oracle/functions...
391,006
<p>Have a use case where </p> <pre><code>Class foo { public: static std::string make(std::string a) { .. } } </code></pre> <p>I want to make foo an abstract base class but obviously make cannot be in this abstract base since virtual functions cannot be static. </p> <p>Like this</p> <pre><code>Class foo { publ...
[ { "answer_id": 391010, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>You can make the destructor a pure virtual function:</p>\n\n<pre>\nclass foo {\n public:\n virtual ~foo() = 0;\n}\n</pr...
2008/12/24
[ "https://Stackoverflow.com/questions/391006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43756/" ]
Have a use case where ``` Class foo { public: static std::string make(std::string a) { .. } } ``` I want to make foo an abstract base class but obviously make cannot be in this abstract base since virtual functions cannot be static. Like this ``` Class foo { public: static virtual std::string make (std:...
You can make the destructor a pure virtual function: ``` class foo { public: virtual ~foo() = 0; } ``` You just need to make sure to provide an implementation for the destructor anyway: ``` foo::~foo() {} ``` Edit: Therefore you have a class that can be derived from, but itself cannot be instantiated.
391,022
<p>In C++Builder, I wrote the following code (in Button1Click handler), When I run in debug mode, I get the "Int3 DbgBreakPoint" (Stack corrupted?). This doesn't happen for AnsiSting (Maybe reference counting).</p> <pre><code>WideString boshluq; boshluq=L" "; </code></pre> <p>Is this normal? What do you suggest me to...
[ { "answer_id": 391010, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>You can make the destructor a pure virtual function:</p>\n\n<pre>\nclass foo {\n public:\n virtual ~foo() = 0;\n}\n</pr...
2008/12/24
[ "https://Stackoverflow.com/questions/391022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38856/" ]
In C++Builder, I wrote the following code (in Button1Click handler), When I run in debug mode, I get the "Int3 DbgBreakPoint" (Stack corrupted?). This doesn't happen for AnsiSting (Maybe reference counting). ``` WideString boshluq; boshluq=L" "; ``` Is this normal? What do you suggest me to fix this code?
You can make the destructor a pure virtual function: ``` class foo { public: virtual ~foo() = 0; } ``` You just need to make sure to provide an implementation for the destructor anyway: ``` foo::~foo() {} ``` Edit: Therefore you have a class that can be derived from, but itself cannot be instantiated.
391,023
<p>How to make <code>NameValueCollection</code> accessible to LINQ query operator such as where, join, groupby?</p> <p>I tried the below:</p> <pre><code>private NameValueCollection RequestFields() { NameValueCollection nvc = new NameValueCollection() { ...
[ { "answer_id": 391028, "author": "Frans Bouma", "author_id": 44991, "author_profile": "https://Stackoverflow.com/users/44991", "pm_score": 2, "selected": false, "text": "<p>The problem is that the collection implements <code>IEnumerable</code> (as opposed to <code>IEnumerable&lt;T&gt;</c...
2008/12/24
[ "https://Stackoverflow.com/questions/391023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3834/" ]
How to make `NameValueCollection` accessible to LINQ query operator such as where, join, groupby? I tried the below: ``` private NameValueCollection RequestFields() { NameValueCollection nvc = new NameValueCollection() { {"emailOption: blah B...
You need to "lift" the non-generic `IEnumerable` to an `IEnumerable<string>`. It has been suggested that you use `OfType` but that is a filtering method. What you're doing is the equivalent of a cast, for which there is the `Cast` operator: ``` var fields = RequestFields().Cast<string>(); ``` As Frans pointed out, t...
391,027
<p>is there a way to add the results of 2 different queries to a resultset?</p> <p>something like that:</p> <pre><code>ResultSet rs ; i=0; while(i&lt;=l) ResultSet rs1 = select * from tablei; rs = rs + rs1; i++; } </code></pre> <p>I know that I can do it with union, but I have a lot queries and if I use...
[ { "answer_id": 391079, "author": "Gareth", "author_id": 47690, "author_profile": "https://Stackoverflow.com/users/47690", "pm_score": 0, "selected": false, "text": "<p>I don't believe there is any way to add a ResultSet to another. They have no method in the class that does such a thing...
2008/12/24
[ "https://Stackoverflow.com/questions/391027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48850/" ]
is there a way to add the results of 2 different queries to a resultset? something like that: ``` ResultSet rs ; i=0; while(i<=l) ResultSet rs1 = select * from tablei; rs = rs + rs1; i++; } ``` I know that I can do it with union, but I have a lot queries and if I use UNION the query is too slow. Any i...
Are you doing a UNION or a UNION ALL? The latter shouldn't be much different from doing it yourself (although I'd expect doing it yourself to be slower).
391,057
<p>I'm encrypting and Base64 a string. Everything works great, until I retrieve the encrypted string from the QueryString collection. The Encrypted text contains a plus symbol. When I retrieve the encrypted string, where a plus once was there is now a space. As you can imagine this doesn't decrypt.</p> <p>I have tried...
[ { "answer_id": 391082, "author": "Funky81", "author_id": 37509, "author_profile": "https://Stackoverflow.com/users/37509", "pm_score": 2, "selected": true, "text": "<p>I had problems like you few years ago. Here's my code to decode base64 query string to string and vise versa </p>\n\n<pr...
2008/12/24
[ "https://Stackoverflow.com/questions/391057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17360/" ]
I'm encrypting and Base64 a string. Everything works great, until I retrieve the encrypted string from the QueryString collection. The Encrypted text contains a plus symbol. When I retrieve the encrypted string, where a plus once was there is now a space. As you can imagine this doesn't decrypt. I have tried both Serv...
I had problems like you few years ago. Here's my code to decode base64 query string to string and vise versa ``` public static String DoDecryption(String Value) { Decryptor dec = new Decryptor(EncryptionAlgorithm.TripleDes ); dec.IV = Encoding.ASCII.GetBytes("funky"); byte [] DecValue ...
391,117
<pre><code>Declare @BadDecimal varchar(5) Set @BadDecimal = '4.5' Declare @GoodDecimal Decimal Set @GoodDecimal = @BadDecimal Select @GoodDecimal --Outputs 5 </code></pre> <p>Why?</p>
[ { "answer_id": 391128, "author": "user48864", "author_id": 48864, "author_profile": "https://Stackoverflow.com/users/48864", "pm_score": 1, "selected": false, "text": "<p>Try <code>Set @BadDecimal = '4,5'</code></p>\n" }, { "answer_id": 391132, "author": "devio", "author_...
2008/12/24
[ "https://Stackoverflow.com/questions/391117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5055/" ]
``` Declare @BadDecimal varchar(5) Set @BadDecimal = '4.5' Declare @GoodDecimal Decimal Set @GoodDecimal = @BadDecimal Select @GoodDecimal --Outputs 5 ``` Why?
Try ``` Declare @GoodDecimal Decimal(2,1) ``` edit: changed to (2,1) after request.
391,125
<p>I have a dialog in MFC with a CStatusBar. In a separate thread, I want to change the pane text of status bar. However MFC complains with asserts? How is it done? An example code would be great.</p>
[ { "answer_id": 391196, "author": "Gant", "author_id": 12460, "author_profile": "https://Stackoverflow.com/users/12460", "pm_score": 2, "selected": false, "text": "<p>Maybe this can help you: <a href=\"http://www.codeguru.com/forum/showthread.php?t=312454\" rel=\"nofollow noreferrer\">How...
2008/12/24
[ "https://Stackoverflow.com/questions/391125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36830/" ]
I have a dialog in MFC with a CStatusBar. In a separate thread, I want to change the pane text of status bar. However MFC complains with asserts? How is it done? An example code would be great.
You could post a private message to the main frame window and 'ask' it to update the status bar. The thread would need the main window handle (don't use the CWnd object as it won't be thread safe). Here is some sample code: ``` static UINT CMainFrame::UpdateStatusBarProc(LPVOID pParam); void CMainFrame::OnCreateTestT...
391,127
<p>I'm a beginner in Java. I'm reading data from the serial port. I got</p> <pre><code>serialPort.setSerialPortParams( 9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); </code></pre> <p>What is the meaning of <code>9600</code>, <code>DATABITS_8,STOPBITS_1</code> and <code>PARITY_NON...
[ { "answer_id": 391149, "author": "Miserable Variable", "author_id": 18573, "author_profile": "https://Stackoverflow.com/users/18573", "pm_score": 2, "selected": false, "text": "<p>When you say you \"got serialPort.setSerialPortParams(....\", where did you get it? If you want to understan...
2008/12/24
[ "https://Stackoverflow.com/questions/391127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm a beginner in Java. I'm reading data from the serial port. I got ``` serialPort.setSerialPortParams( 9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); ``` What is the meaning of `9600`, `DATABITS_8,STOPBITS_1` and `PARITY_NONE`?
> > 9600, DATABITS\_8,STOPBITS\_1 and > PARITY\_NONE > > > **9600 [BAUD](http://en.wikipedia.org/wiki/Baud)**: Baud is synonymous with symbols or pulses per second. In this case it refers to the number of bits transferred per second. **[DATABITS](http://en.wikipedia.org/wiki/Serial_port#Data_Bits)\_8**: 8-bits o...
391,139
<p>I am currently working on a website that is an advertisement portal for businesses. Advertisers can create an account, select various options for listing (State, caregory, etc) and upload a graphic is measured in a multiples of an "unit". An "unit" is an image or a flash file that is <code>180px</code> wide and <cod...
[ { "answer_id": 391242, "author": "Zhaph - Ben Duguid", "author_id": 33051, "author_profile": "https://Stackoverflow.com/users/33051", "pm_score": 0, "selected": false, "text": "<p>Have you had a look for any TreeMap controls? Most of them will be commercial offerings, but there may be an...
2008/12/24
[ "https://Stackoverflow.com/questions/391139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32649/" ]
I am currently working on a website that is an advertisement portal for businesses. Advertisers can create an account, select various options for listing (State, caregory, etc) and upload a graphic is measured in a multiples of an "unit". An "unit" is an image or a flash file that is `180px` wide and `120` high. An adv...
That's a tough one. If you want to use divs and css you can try floating the ads. The only problem is that you can't render the divs in an arbitrary order since they won't always try to take up the available room. The same would be true if you were using tables though. ``` <html> <head> <style> div.adconta...
391,195
<p>Is there a way to call Static Classes / Methods by name?</p> <p>Example:</p> <pre><code>$name = 'StaticClass'; ($name)::foo(); </code></pre> <p>I have classes which I keep all static methods in and I'd like to call them this way.</p>
[ { "answer_id": 391218, "author": "Anthony", "author_id": 18641, "author_profile": "https://Stackoverflow.com/users/18641", "pm_score": 3, "selected": false, "text": "<p>You can do something like this using the <a href=\"http://php.net/call_user_func\" rel=\"nofollow noreferrer\">call_use...
2008/12/24
[ "https://Stackoverflow.com/questions/391195", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26566/" ]
Is there a way to call Static Classes / Methods by name? Example: ``` $name = 'StaticClass'; ($name)::foo(); ``` I have classes which I keep all static methods in and I'd like to call them this way.
``` $name::foo() ``` is possible since PHP5.3. In earlier versions you have to use ``` call_user_func(array($classname,$methodname)) ```
391,200
<p>Basically, is it possible to identify if some-one hooks up my program to SQL server Compact or Express Edition? I want to be able to restrict different versions of my product to different versions of SQL Server.</p>
[ { "answer_id": 391205, "author": "Gareth", "author_id": 47690, "author_profile": "https://Stackoverflow.com/users/47690", "pm_score": 2, "selected": false, "text": "<p>Run this SQL statement</p>\n\n<pre><code>SELECT @@VERSION\n</code></pre>\n\n<p>and it'll give you a ReultSet (one column...
2008/12/24
[ "https://Stackoverflow.com/questions/391200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22712/" ]
Basically, is it possible to identify if some-one hooks up my program to SQL server Compact or Express Edition? I want to be able to restrict different versions of my product to different versions of SQL Server.
After connection to a database, you can always run the T-Sql: ``` SELECT SERVERPROPERTY ('edition') ``` This should give you the different editions Other useful info may come from: ``` SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel') ```
391,224
<p>We have an application that uses a dual monitor setup - User A will work with Monitor 1, and user B will work with Monitor 2 simultaneously. Monitor 2 is a touch screen device.</p> <p>Now, the problem is, when User A types something in his screen, if User B tries to do something, User A will end up in losing the fo...
[ { "answer_id": 391231, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "<p>To me, it sounds like you might want 2 PC's... or maybe host a VM on the PC, and give the VM access to the second ...
2008/12/24
[ "https://Stackoverflow.com/questions/391224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45956/" ]
We have an application that uses a dual monitor setup - User A will work with Monitor 1, and user B will work with Monitor 2 simultaneously. Monitor 2 is a touch screen device. Now, the problem is, when User A types something in his screen, if User B tries to do something, User A will end up in losing the focus from h...
It is possible with some elbow grease. Paste this code in the form that you show on the touch screen: ``` protected override CreateParams CreateParams { get { const int WS_EX_NOACTIVATE = 0x08000000; CreateParams param = base.CreateParams; param.ExStyle |= WS_EX_NOACTIVATE; return param; } } ``` ...
391,227
<p>Can somebody advise me what this code does and how can I convert it to Ruby in most simple way?</p> <pre><code> #!perl use Convert::ASN1; my $asn1 = Convert::ASN1-&gt;new(encoding =&gt; 'DER'); $asn1-&gt;prepare(q&lt; Algorithm ::= SEQUENCE { oid OBJECT IDENTIFIER, o...
[ { "answer_id": 391241, "author": "Keltia", "author_id": 16143, "author_profile": "https://Stackoverflow.com/users/16143", "pm_score": 0, "selected": false, "text": "<p>Have you looked at <a href=\"http://rubyforge.org/projects/net-asn1/\" rel=\"nofollow noreferrer\">Net::ASN1</a>?</p>\n"...
2008/12/24
[ "https://Stackoverflow.com/questions/391227", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6258/" ]
Can somebody advise me what this code does and how can I convert it to Ruby in most simple way? ``` #!perl use Convert::ASN1; my $asn1 = Convert::ASN1->new(encoding => 'DER'); $asn1->prepare(q< Algorithm ::= SEQUENCE { oid OBJECT IDENTIFIER, opt ANY OPTIONAL } ...
This particular example can be converted as ``` data = ["308191300b06092a864886f70d01010d03818100" + body.unpack("H*")].pack("H*") ``` where "308191300b06092a864886f70d01010d03818100" is prefix made from that ASN expression up to BIT STRING field (including size of BIT STRING), pack("H") converts binary data to hex...
391,237
<p>Alright, I'll preface this with the fact that I'm a GTK <em>and</em> Python newb, but I haven't been able to dig up the information I needed. Basically what I have is a list of Radio Buttons, and based on which one is checked, I need to connect a button to a different function. I tried creating all my radio buttons,...
[ { "answer_id": 391288, "author": "miles82", "author_id": 48882, "author_profile": "https://Stackoverflow.com/users/48882", "pm_score": 0, "selected": false, "text": "<p>First, I presume that's a typo and you're actually calling get_active() in your code and not set_active()? Other than t...
2008/12/24
[ "https://Stackoverflow.com/questions/391237", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14838/" ]
Alright, I'll preface this with the fact that I'm a GTK *and* Python newb, but I haven't been able to dig up the information I needed. Basically what I have is a list of Radio Buttons, and based on which one is checked, I need to connect a button to a different function. I tried creating all my radio buttons, and then ...
Edit: (since you posted some code), just use: ``` active = [r for r in self.updatePageRadio.get_group() if r.get_active()][0] ``` and use that to look up in a dict of functions and call it: ``` my_actions[active]() ``` --- Edit: I totally forgot to mention that this is not a good use-case at all for RadioButtons...
391,252
<p>I want to model messages between users, here is the requirement:</p> <ol> <li><p>User has received and sent messages, and should be retrieved by <code>user.received_messages</code> and <code>user.sent_messages</code></p></li> <li><p>Message has sender and receiver, and should be retrieved by <code>message.sender</c...
[ { "answer_id": 391318, "author": "Milan Novota", "author_id": 26123, "author_profile": "https://Stackoverflow.com/users/26123", "pm_score": 3, "selected": true, "text": "<p>Just as in the Message model:</p>\n\n<pre><code>class User &lt; ActiveRecord::Base\n has_many :sent_messages, :cla...
2008/12/24
[ "https://Stackoverflow.com/questions/391252", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44512/" ]
I want to model messages between users, here is the requirement: 1. User has received and sent messages, and should be retrieved by `user.received_messages` and `user.sent_messages` 2. Message has sender and receiver, and should be retrieved by `message.sender` and `message.receiver`. I have created the User model as...
Just as in the Message model: ``` class User < ActiveRecord::Base has_many :sent_messages, :class_name => "Message", :foreign_key => "sender_id" has_many :received_messages, :class_name => "Message", :foreign_key => "receiver_id" end ```
391,269
<p>The customer wants us to "log" the "actions" that a user performs on our system: creation, deletion and update, mostly. I already have an aspect that logs the trace, but that works at a pretty low level logging every method call. So if a user clicked on the button "open medical file" the log would read:</p> <ol> <...
[ { "answer_id": 391282, "author": "Miserable Variable", "author_id": 18573, "author_profile": "https://Stackoverflow.com/users/18573", "pm_score": 1, "selected": false, "text": "<p>I recently post-processed logs to generate summary. You may want to consider that approach, especially if #2...
2008/12/24
[ "https://Stackoverflow.com/questions/391269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4690/" ]
The customer wants us to "log" the "actions" that a user performs on our system: creation, deletion and update, mostly. I already have an aspect that logs the trace, but that works at a pretty low level logging every method call. So if a user clicked on the button "open medical file" the log would read: 1. closePrevi...
Sounds like your client wants an audit trail of the user's actions in the system. Consider that at each action's entry point (from the web request) to start an audit entry with an enum/constant on the action. Populate it with information user has provided if possible. At exit/finally, indicate in the audit if it is ...
391,284
<p>we are using SharePoint Server (MOSS 2007) with Windows Integrated Security.</p> <p>A few computers in the company (managers) are using Apple Macs.</p> <p>These people can't run the application on their machines! I think the problem is due the windows integrated security. How can we solve this problem?</p> <p>T...
[ { "answer_id": 391414, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": true, "text": "<p>We use Sharepoint 2007 for our intranet portal using Windows integrated authentication with no (or few) problems for ...
2008/12/24
[ "https://Stackoverflow.com/questions/391284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/247597/" ]
we are using SharePoint Server (MOSS 2007) with Windows Integrated Security. A few computers in the company (managers) are using Apple Macs. These people can't run the application on their machines! I think the problem is due the windows integrated security. How can we solve this problem? Thanks for your help.
We use Sharepoint 2007 for our intranet portal using Windows integrated authentication with no (or few) problems for Macintosh users. I just logged on to ours from my MacBook and was able to access it with no problems. Can you describe what the problems are in more detail? Not able to log on (should they be specifying ...
391,292
<p>how do i shrink datafiles in oracle 10G?</p>
[ { "answer_id": 391453, "author": "Dave Costa", "author_id": 6568, "author_profile": "https://Stackoverflow.com/users/6568", "pm_score": -1, "selected": false, "text": "<p>For standard datafiles in Oracle, you can't shrink them. You would have to do something like:</p>\n\n<ol>\n<li>Move ...
2008/12/24
[ "https://Stackoverflow.com/questions/391292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
how do i shrink datafiles in oracle 10G?
Caveat: I am not an Oracle system administrator, other than for personal installs. Take everything I say with a large grain of salt. I'm assuming that you created the datafiles with auto-extend, and they've been extended past what you feel they should contain. There is a clause to ALTER DATABASE that will resize a fi...
391,295
<p>What is the most preferred format of unicode strings in memory when they are being processed? And why?</p> <p>I am implementing a programming language by producing an executable file image for it. Obviously a working programming language implementation requires a protocol for processing strings.</p> <p>I've though...
[ { "answer_id": 391453, "author": "Dave Costa", "author_id": 6568, "author_profile": "https://Stackoverflow.com/users/6568", "pm_score": -1, "selected": false, "text": "<p>For standard datafiles in Oracle, you can't shrink them. You would have to do something like:</p>\n\n<ol>\n<li>Move ...
2008/12/24
[ "https://Stackoverflow.com/questions/391295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21711/" ]
What is the most preferred format of unicode strings in memory when they are being processed? And why? I am implementing a programming language by producing an executable file image for it. Obviously a working programming language implementation requires a protocol for processing strings. I've thought about using dyn...
Caveat: I am not an Oracle system administrator, other than for personal installs. Take everything I say with a large grain of salt. I'm assuming that you created the datafiles with auto-extend, and they've been extended past what you feel they should contain. There is a clause to ALTER DATABASE that will resize a fi...
391,306
<p>I have a JavaScript function, <code>pop_item</code>. I have to call this from PHP, so my PHP code is the following:</p> <pre><code>echo '&lt;a href="javascript:pop_item('.$_code.',1)"&gt;Link &lt;/a&gt;'; </code></pre> <p>It provides no error, but <code>pop_item</code> is not functioning,</p> <p>The HTML output f...
[ { "answer_id": 391311, "author": "Pim Jager", "author_id": 35197, "author_profile": "https://Stackoverflow.com/users/35197", "pm_score": 4, "selected": true, "text": "<p>I think the problem is in the pop_item function since the call seems to be correct. Try this:</p>\n\n<pre><code>echo \...
2008/12/24
[ "https://Stackoverflow.com/questions/391306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44984/" ]
I have a JavaScript function, `pop_item`. I have to call this from PHP, so my PHP code is the following: ``` echo '<a href="javascript:pop_item('.$_code.',1)">Link </a>'; ``` It provides no error, but `pop_item` is not functioning, The HTML output for the above is: ``` <a href="javascript:pop_item('ABC',1)">Link <...
I think the problem is in the pop\_item function since the call seems to be correct. Try this: ``` echo " <a href='#' onclick=\"pop_item(".$_code."', 1)\">link</a>"; ``` Or ``` echo '<a href="javascript:alert('.$_code.')">Link</a>'; ``` See if that works.
391,314
<p>I'm trying to insert an li element into a specific index on a ul element using jQuery. I only seem to be able to insert an element on the end of the list. I am very new to jQuery, so I may just not be thinking properly.</p>
[ { "answer_id": 391320, "author": "Andreas Grech", "author_id": 44084, "author_profile": "https://Stackoverflow.com/users/44084", "pm_score": 7, "selected": true, "text": "<p>Try something like this:</p>\n\n<pre><code>$(\"#thelist li\").eq(3).after(\"&lt;li&gt;A new item&lt;/li&gt;\");\n<...
2008/12/24
[ "https://Stackoverflow.com/questions/391314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48886/" ]
I'm trying to insert an li element into a specific index on a ul element using jQuery. I only seem to be able to insert an element on the end of the list. I am very new to jQuery, so I may just not be thinking properly.
Try something like this: ``` $("#thelist li").eq(3).after("<li>A new item</li>"); ``` With the `eq` function, you can get a specific index of the elements retrieved...then, insert the new list item after it. In the above function, I am inserting a new item at position 4 (index 3). More info about the function at t...
391,348
<p>I have a query in Delphi using DBExpress TSQLQuery that looks like so </p> <pre><code>ActiveSQL.sql.add('SELECT * FROM MYTABLE where MYFIELD=(:AMYFIELD) '); ActiveSQL.ParamByName('AMYFIELD').AsString := 'Some random string that is to long for the field'; ActiveSQL.Open; </code></pre> <p>If I run it, when it e...
[ { "answer_id": 391351, "author": "Sean", "author_id": 26095, "author_profile": "https://Stackoverflow.com/users/26095", "pm_score": 0, "selected": false, "text": "<p>The bigest \"hurdle\" will probably be that you'll be responsible for releasing the memory you allocate</p>\n" }, { ...
2008/12/24
[ "https://Stackoverflow.com/questions/391348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2098/" ]
I have a query in Delphi using DBExpress TSQLQuery that looks like so ``` ActiveSQL.sql.add('SELECT * FROM MYTABLE where MYFIELD=(:AMYFIELD) '); ActiveSQL.ParamByName('AMYFIELD').AsString := 'Some random string that is to long for the field'; ActiveSQL.Open; ``` If I run it, when it executes the open command I...
The main difference I can think of is that C++ is far more of a multi-paradigm language than C and C#. In C#, OOP is still *the* paradigm. It's a OOP language before anything else, and if you're not doing OOP, the C# community will tell you you're doing it wrong. (although C# has added quite good support for a few bits...
391,363
<p>I started maintenance on some poorly written XAMLs. I am relatively new to XAML. </p> <p>One thing I need is - grid columns should automatically adjust their width per the text contents.</p> <p>The MSDN documentation on GridViewColumn.Width says - set it to Auto to enable auto-sizing behavior. However even though ...
[ { "answer_id": 391372, "author": "Blounty", "author_id": 33944, "author_profile": "https://Stackoverflow.com/users/33944", "pm_score": 0, "selected": false, "text": "<p>Auto does work fine as below. </p>\n\n<pre><code> &lt;ListView&gt;\n &lt;ListView.View&gt;\n ...
2008/12/24
[ "https://Stackoverflow.com/questions/391363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I started maintenance on some poorly written XAMLs. I am relatively new to XAML. One thing I need is - grid columns should automatically adjust their width per the text contents. The MSDN documentation on GridViewColumn.Width says - set it to Auto to enable auto-sizing behavior. However even though the code reads as...
The `GridView` recalculates column content sizes only when the template or internal column collection change, that's why `Width="Auto"` only works on loading the `GridView`. [Here](http://leghumped.com/blog/2009/03/11/wpf-gridview-column-width-calculator/)'s an article about a possible approach to a solution.
391,390
<p>I use phpUnit on a integration server to run all tests and if I launch phpunit command from the command line, I receive:</p> <pre><code>PHPUnit 3.2.18 by Sebastian Bergmann. F..III..I......I.IIII... Time: 6 seconds There was 1 failure: 1) Warning(PHPUnit_Framework_Warning) No tests found in class &quot;TU&quot;. FA...
[ { "answer_id": 391521, "author": "phihag", "author_id": 35070, "author_profile": "https://Stackoverflow.com/users/35070", "pm_score": 0, "selected": false, "text": "<p>Looks like you are using two different <code>php.ini</code> files for command line and Apache.</p>\n\n<p>On most unixoid...
2008/12/24
[ "https://Stackoverflow.com/questions/391390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8404/" ]
I use phpUnit on a integration server to run all tests and if I launch phpunit command from the command line, I receive: ``` PHPUnit 3.2.18 by Sebastian Bergmann. F..III..I......I.IIII... Time: 6 seconds There was 1 failure: 1) Warning(PHPUnit_Framework_Warning) No tests found in class "TU". FAILURES Tests: 24, Failu...
For the class wich extends PHPUnit\_Framework\_TestCase, it should be abstract, and the warning disapear. For the first problem, it seems it is a bug.
391,391
<p>I don't know if this is too specific a question, if that is possible, but I'm having to port an app that uses Castle Windsor to Unity so that there isn't a reliance on non-microsoft approved libraries. I know I know but what are you going to do.</p> <p>Anyway I've managed it but I'm not happy with what I've got. In...
[ { "answer_id": 392546, "author": "smaclell", "author_id": 22914, "author_profile": "https://Stackoverflow.com/users/22914", "pm_score": 1, "selected": true, "text": "<p>Cool. This feature is not in unity yet but if you felt a bit ambitious you could setup your own convention based regist...
2008/12/24
[ "https://Stackoverflow.com/questions/391391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I don't know if this is too specific a question, if that is possible, but I'm having to port an app that uses Castle Windsor to Unity so that there isn't a reliance on non-microsoft approved libraries. I know I know but what are you going to do. Anyway I've managed it but I'm not happy with what I've got. In Windsor I...
Cool. This feature is not in unity yet but if you felt a bit ambitious you could setup your own convention based registration. Found below is a snipped that works for the executing assembly and interfaces. Good luck. P.S. This feels like a big hack, I would probably continue just registering all types by hand. ``` us...
391,411
<p>The following test case fails in rhino mocks:</p> <pre><code>[TestFixture] public class EnumeratorTest { [Test] public void Should_be_able_to_use_enumerator_more_than_once() { var numbers = MockRepository.GenerateStub&lt;INumbers&gt;(); numbers.Stub(x =...
[ { "answer_id": 391572, "author": "Dror Helper", "author_id": 11361, "author_profile": "https://Stackoverflow.com/users/11361", "pm_score": 1, "selected": false, "text": "<p><em>Disclaimer: I work at Typemock</em></p>\n<p>I don't know if you can use Rhino to do this but you can use <a hre...
2008/12/24
[ "https://Stackoverflow.com/questions/391411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5289/" ]
The following test case fails in rhino mocks: ``` [TestFixture] public class EnumeratorTest { [Test] public void Should_be_able_to_use_enumerator_more_than_once() { var numbers = MockRepository.GenerateStub<INumbers>(); numbers.Stub(x => x.GetEnumerator())...
The WhenCalled() api lets you dynamically resolve return values. Changing the test case to the following will allow it to pass: ``` numbers.Stub(x => x.GetEnumerator()) .Return(null) .WhenCalled(x => x.ReturnValue = new List<int> { 1, 2, 3...
391,440
<p>Is there a way to make a <code>&lt;div&gt;</code> container resizeable with drag &amp; drop?</p>
[ { "answer_id": 391773, "author": "Georg Schölly", "author_id": 24587, "author_profile": "https://Stackoverflow.com/users/24587", "pm_score": 6, "selected": false, "text": "<p>The best method would be to use CSS3. It supported by at least Webkit and Gecko.</p>\n\n<p>According to the <a hr...
2008/12/24
[ "https://Stackoverflow.com/questions/391440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43960/" ]
Is there a way to make a `<div>` container resizeable with drag & drop?
The best method would be to use CSS3. It supported by at least Webkit and Gecko. According to the [w3c spec](http://www.w3.org/TR/css3-ui/#resize): ``` div.my_class { resize:both; overflow:auto; /* something other than visible */ } ``` Webkit and Firefox do not interpret the specs the same way. In Webkit th...
391,450
<p>I have a DataBound GridView. However I have one column where the value comes from a calculation in the code behind - it is displayed within a TemplateField.</p> <p>How can a sort my grid based on this calculated value ?</p>
[ { "answer_id": 391471, "author": "wulimaster", "author_id": 21749, "author_profile": "https://Stackoverflow.com/users/21749", "pm_score": 0, "selected": false, "text": "<p>One possible solution would be to populate a datatable instead of binding the grid. Then use a dataview with the sor...
2008/12/24
[ "https://Stackoverflow.com/questions/391450", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2839/" ]
I have a DataBound GridView. However I have one column where the value comes from a calculation in the code behind - it is displayed within a TemplateField. How can a sort my grid based on this calculated value ?
Put your initial returned data into a DATASET or a DATATABLE. Add to the DATATABLE a new column for you calculated field. Walked that data doing the necessary calculation, and putting the result into said calculated field. Create a new view based on the datatable, and sort the view by the calculated field. Bind the g...
391,462
<p>C# 3.0 introduced the <code>var</code> keyword. And when compiled, the compiler will insert the right types for you. This means that it will even work on a 2.0 runtime. So far so good. But the other day I found a case where, the <code>var</code> keyword would be replaced with just object and thus not specific enough...
[ { "answer_id": 391475, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 2, "selected": false, "text": "<p>This:</p>\n\n<pre><code>using System;\n\nnamespace Test\n{\n public class X\n {\n public String Bleh;...
2008/12/24
[ "https://Stackoverflow.com/questions/391462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13995/" ]
C# 3.0 introduced the `var` keyword. And when compiled, the compiler will insert the right types for you. This means that it will even work on a 2.0 runtime. So far so good. But the other day I found a case where, the `var` keyword would be replaced with just object and thus not specific enough. Say you have something ...
I think I see the problem. DataRowCollection is non-generic and thus the only thing the compiler knows is that contains objects of type Object. If it had been a generic datastructure this would have worked.
391,485
<p>I've added the following code to my masterpage (Page_Load) so once a user logs out they will not be able to use the back button to see the page they were previously at.</p> <pre><code> Response.Buffer = true; Response.ExpiresAbsolute = DateTime.Now.AddDays(-1); Response.Expires = -1; Response.CacheControl = "no-...
[ { "answer_id": 391512, "author": "Mauricio Scheffer", "author_id": 21239, "author_profile": "https://Stackoverflow.com/users/21239", "pm_score": 0, "selected": false, "text": "<p>See:</p>\n\n<ul>\n<li><a href=\"https://stackoverflow.com/questions/87422/disabling-back-button-on-the-browse...
2008/12/24
[ "https://Stackoverflow.com/questions/391485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47895/" ]
I've added the following code to my masterpage (Page\_Load) so once a user logs out they will not be able to use the back button to see the page they were previously at. ``` Response.Buffer = true; Response.ExpiresAbsolute = DateTime.Now.AddDays(-1); Response.Expires = -1; Response.CacheControl = "no-cache"; ``` ...
Is the objective to prevent an un-authenticated user from surreptitiously visiting a previously-used computer and seeing what the authenticated user was doing? If the latter, then you should redirect the user to a logout page that has a window.close(); command along with strong language about this being a **requirement...
391,498
<p>How to create a pragraph &lt;p&gt; tag in ASP.NET using the HtmlGenericControl class?</p>
[ { "answer_id": 391514, "author": "gius", "author_id": 19712, "author_profile": "https://Stackoverflow.com/users/19712", "pm_score": -1, "selected": false, "text": "<pre><code>new HtmlGenericControl(\"p\");\n</code></pre>\n\n<p>PS. Try using Intellisense...</p>\n" }, { "answer_id"...
2008/12/24
[ "https://Stackoverflow.com/questions/391498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32582/" ]
How to create a pragraph <p> tag in ASP.NET using the HtmlGenericControl class?
``` HtmlGenericControl para = new HtmlGenericControl ( "p" ); ``` Although I would leave it as a container control for the extra properties/methods. ``` HtmlContainerControl para = (HtmlContainerControl)new HtmlGenericControl ( "p" ); ```
391,503
<p>I know this is a matter of style, hence the subjective tag. I have a small piece of code, with two nested conditions. I could code it in two ways, and I'd like to see how more experienced developers think it should look like.</p> <p><em>Style 1</em>:</p> <pre><code>while (!String.IsNullOrEmpty(msg = reader.readMsg...
[ { "answer_id": 391511, "author": "Oddthinking", "author_id": 8014, "author_profile": "https://Stackoverflow.com/users/8014", "pm_score": 5, "selected": false, "text": "<p>I prefer Style 1 - with the indenting.</p>\n" }, { "answer_id": 391513, "author": "Oddthinking", "aut...
2008/12/24
[ "https://Stackoverflow.com/questions/391503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41283/" ]
I know this is a matter of style, hence the subjective tag. I have a small piece of code, with two nested conditions. I could code it in two ways, and I'd like to see how more experienced developers think it should look like. *Style 1*: ``` while (!String.IsNullOrEmpty(msg = reader.readMsg())) { RaiseMessageRecei...
In principle I agree with the majority who prefer style 1. This is what Steve Mcconnell endorses in "Code Complete" - say what you mean, i.e. if you are more interested in the condition being true, while the false state is rarer or not preferred, then state the preferred version. In practice though I often find myself...
391,550
<p>I'been doing some inheritance in js in order to understand it better, and I found something that confuses me.</p> <p>I know that when you call an 'constructor function' with the new keyword, you get a new object with a reference to that function's prototype.</p> <p>I also know that in order to make prototypal inhe...
[ { "answer_id": 391626, "author": "Kenan Banks", "author_id": 43089, "author_profile": "https://Stackoverflow.com/users/43089", "pm_score": 3, "selected": false, "text": "<p>You cannot change an object's prototype once it's been instantiated with <code>new</code>.</p>\n\n<p>In your exampl...
2008/12/24
[ "https://Stackoverflow.com/questions/391550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7595/" ]
I'been doing some inheritance in js in order to understand it better, and I found something that confuses me. I know that when you call an 'constructor function' with the new keyword, you get a new object with a reference to that function's prototype. I also know that in order to make prototypal inheritance you must ...
> > 1) Why if all new objects contain a > reference to the creator function's > prototype, fido.prototype is > undefined? > > > All new objects do hold a reference to the prototype that was present on their constructor at the time of construction. However the property name used to store this reference is not `p...
391,621
<p>I have a method which should be delayed from running for a specified amount of time.</p> <p>Should I use</p> <pre><code>Thread thread = new Thread(() =&gt; { Thread.Sleep(millisecond); action(); }); thread.IsBackground = true; thread.Start(); </code></pre> <p>Or</p> <pre><code>Timer timer = new Timer(o =&gt;...
[ { "answer_id": 391643, "author": "Shawn", "author_id": 26, "author_profile": "https://Stackoverflow.com/users/26", "pm_score": 4, "selected": false, "text": "<p>I think Thread.Sleep is fine if you really want to pause the application for a specified amount of time. I think the reason peo...
2008/12/24
[ "https://Stackoverflow.com/questions/391621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2398110/" ]
I have a method which should be delayed from running for a specified amount of time. Should I use ``` Thread thread = new Thread(() => { Thread.Sleep(millisecond); action(); }); thread.IsBackground = true; thread.Start(); ``` Or ``` Timer timer = new Timer(o => action(), null, millisecond, -1); ``` I had...
One difference is that `System.Threading.Timer` dispatches the callback on a thread pool thread, rather than creating a new thread every time. If you need this to happen more than once during the life of your application, this will save the overhead of creating and destroying a bunch of threads (a process which is very...
391,637
<pre><code>select * from myTable where myInt </code></pre> <p>will not show any possible_keys when explaining the query even though there is an index on myInt field.</p> <p><strong>Edit:</strong><br> The index in question is not unique.</p>
[ { "answer_id": 391638, "author": "Senseful", "author_id": 35690, "author_profile": "https://Stackoverflow.com/users/35690", "pm_score": 4, "selected": true, "text": "<p>For MySQL to use the index, you have to explicitly compare the int field to a value (e.g. true, 1).</p>\n\n<pre><code>s...
2008/12/24
[ "https://Stackoverflow.com/questions/391637", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35690/" ]
``` select * from myTable where myInt ``` will not show any possible\_keys when explaining the query even though there is an index on myInt field. **Edit:** The index in question is not unique.
For MySQL to use the index, you have to explicitly compare the int field to a value (e.g. true, 1). ``` select * from myTable where myInt = true ```
391,649
<p>While browsing some code I found a call to <a href="http://msdn.microsoft.com/en-us/library/dd162751.aspx" rel="nofollow noreferrer">OpenPrinter()</a>. The code compiles and works fine. But, we are passing a <code>HANDLE</code> instead of <code>LPHANDLE</code> (as specified in MSDN). I found out that in <code>windef...
[ { "answer_id": 391658, "author": "ctacke", "author_id": 13154, "author_profile": "https://Stackoverflow.com/users/13154", "pm_score": 3, "selected": false, "text": "<p>\"LP\" stands for Long Pointer.</p>\n\n<p>HANDLE != LPHANDLE, just as DWORD != DWORD* (or LPDWORD)</p>\n" }, { "...
2008/12/24
[ "https://Stackoverflow.com/questions/391649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43701/" ]
While browsing some code I found a call to [OpenPrinter()](http://msdn.microsoft.com/en-us/library/dd162751.aspx). The code compiles and works fine. But, we are passing a `HANDLE` instead of `LPHANDLE` (as specified in MSDN). I found out that in `windef.h` the following declaration exists: ``` typedef HANDLE FAR ...
LP stands for Long Pointer. It's a pointer to a handle in this case. ``` HANDLE h = <winapi function>(); LPHANDLE ph = &h; ``` You can use it the same way you would a handle by dereferencing the pointer: ``` HANDLE anotherh = *ph; or <winapi function>(*ph, ...); ```
391,710
<p>I want to join all lines in a file into a single line. What is the simplest way of doing this? I've had poor luck trying to use substitution (<code>\r\n</code> or <code>\n</code> doesn't seem to get picked up correctly in the case of <code>s/\r\n//</code> on Windows). Using <code>J</code> in a range expression do...
[ { "answer_id": 391719, "author": "Jordan Parmer", "author_id": 20133, "author_profile": "https://Stackoverflow.com/users/20133", "pm_score": 7, "selected": true, "text": "<p>Ah, I found the answer.</p>\n\n<pre><code>:1,$join\n</code></pre>\n\n<p>Works like a charm.</p>\n\n<p><strong>EDIT...
2008/12/24
[ "https://Stackoverflow.com/questions/391710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20133/" ]
I want to join all lines in a file into a single line. What is the simplest way of doing this? I've had poor luck trying to use substitution (`\r\n` or `\n` doesn't seem to get picked up correctly in the case of `s/\r\n//` on Windows). Using `J` in a range expression doesn't seem to work either (probably because the ra...
Ah, I found the answer. ``` :1,$join ``` Works like a charm. **EDIT**: As pointed out in the comment: ``` :%join -or- :%j ``` ...removes the range.
391,744
<p>We have a situation where our application calls some stored procedures on a sql 2000 server. Now we must get some of the data from another sql 2000 box connected by a vpn.</p> <p>What would the syntax look like for performing CRUD operations from one sql server to another sql server?</p> <p>Both database servers a...
[ { "answer_id": 391750, "author": "splattne", "author_id": 6461, "author_profile": "https://Stackoverflow.com/users/6461", "pm_score": 3, "selected": true, "text": "<p>You could use the <a href=\"http://msdn.microsoft.com/en-us/library/aa213778.aspx\" rel=\"nofollow noreferrer\">Linked Se...
2008/12/24
[ "https://Stackoverflow.com/questions/391744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4096/" ]
We have a situation where our application calls some stored procedures on a sql 2000 server. Now we must get some of the data from another sql 2000 box connected by a vpn. What would the syntax look like for performing CRUD operations from one sql server to another sql server? Both database servers are SQL 2000 and r...
You could use the [Linked Server feature](http://msdn.microsoft.com/en-us/library/aa213778.aspx) of SQL Server. > > A linked server configuration allows > Microsoft SQL Server to execute > commands against OLE DB data sources > on different servers. Linked servers > offer these advantages: > > > * Remote server...
391,756
<p>Is this allowed? :</p> <pre><code>class A; void foo() { static A(); } </code></pre> <p>I get signal 11 when I try to do it, but the following works fine:</p> <pre><code>class A; void foo() { static A a; } </code></pre> <p>Thank you.</p>
[ { "answer_id": 391763, "author": "Charlie Martin", "author_id": 35092, "author_profile": "https://Stackoverflow.com/users/35092", "pm_score": 3, "selected": true, "text": "<p>Nope. There is no such thing as an \"anonymous object\" in C++. There is such a thing as defining an object to ...
2008/12/24
[ "https://Stackoverflow.com/questions/391756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44673/" ]
Is this allowed? : ``` class A; void foo() { static A(); } ``` I get signal 11 when I try to do it, but the following works fine: ``` class A; void foo() { static A a; } ``` Thank you.
Nope. There is no such thing as an "anonymous object" in C++. There is such a thing as defining an object to type A that is immediately discarded; what you've written is an expression that returns an A object that's never assigned to a variable, like the return code of printf usually is never assigned or used. In that...
391,757
<p>Is it possible to determine styles in a CSS file through Javascript?</p> <p>I am trying to detect CSS properties that will be applied to an element in a certain state, <code>:hover</code> in this case, but without those properties currently being active on the element. I had thought about cloning the element, appen...
[ { "answer_id": 391820, "author": "Manu", "author_id": 2133, "author_profile": "https://Stackoverflow.com/users/2133", "pm_score": 0, "selected": false, "text": "<p>the hover style is applied by the browser, dependnt on the mouse movement. I don't think you can force it through JS. But wh...
2008/12/24
[ "https://Stackoverflow.com/questions/391757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/270/" ]
Is it possible to determine styles in a CSS file through Javascript? I am trying to detect CSS properties that will be applied to an element in a certain state, `:hover` in this case, but without those properties currently being active on the element. I had thought about cloning the element, appending the clone as a s...
I believe you are interested in the `styleSheets` array that is a property of the `document` (`document.styleSheets`) This array indexes all of the style sheets referenced by the current page and allows you to iterate over all of the style rules in each sheet. The W3C array (Firefox, Opera, Safari) for accessing css ru...
391,759
<p>I need to get text aligned right and left on the same line. This should be possible, but i can't seem to find a way. I'm using Apache FOP to convert xml to pdf.</p> <p>Can someone help me to get this right?</p>
[ { "answer_id": 391775, "author": "Martijn Laarman", "author_id": 47020, "author_profile": "https://Stackoverflow.com/users/47020", "pm_score": -1, "selected": false, "text": "<p>This is possible i'm not sure what the exact output is but have you tried:</p>\n\n<pre><code>&lt;fo:block-cont...
2008/12/24
[ "https://Stackoverflow.com/questions/391759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20261/" ]
I need to get text aligned right and left on the same line. This should be possible, but i can't seem to find a way. I'm using Apache FOP to convert xml to pdf. Can someone help me to get this right?
Elegance wasn't a stated requirement, but this should fit the bill: ``` <fo:block text-align-last="justify"> LEFT TEXT <fo:leader leader-pattern="space" /> RIGHT TEXT </fo:block> ``` This works by justifying the last line of text in the block, so that the text begins at the left of the line and ends at the rig...
391,784
<p>What is the best way to redirect to the login page when the session expires. I'm using </p> <pre><code>sessionState mode="InProc" </code></pre> <p>Can I set this in the web.config file?</p>
[ { "answer_id": 391804, "author": "Dillie-O", "author_id": 71, "author_profile": "https://Stackoverflow.com/users/71", "pm_score": 3, "selected": true, "text": "<p>The trick to remember about the session expiration is that this happens in the the worker process running behind the scenes a...
2008/12/24
[ "https://Stackoverflow.com/questions/391784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1688440/" ]
What is the best way to redirect to the login page when the session expires. I'm using ``` sessionState mode="InProc" ``` Can I set this in the web.config file?
The trick to remember about the session expiration is that this happens in the the worker process running behind the scenes and there is no direct way to notify the user without going back to the server to check the state of things. What I do is I have the page register a Javascript block that will redirect the user t...
391,857
<p>Has anyone run into this problem? All I am doing in tabbing from one TextInput component to another.</p> <p>I have reduced my TitleWindow (the container for the TextInputs) down to only these two components and I still get this error. I assumed that it had something to do with my flashplayer install, so I uninstall...
[ { "answer_id": 392709, "author": "fenomas", "author_id": 10651, "author_profile": "https://Stackoverflow.com/users/10651", "pm_score": 0, "selected": false, "text": "<p>Do you have any handlers for, say, focus events or the like on the text fields? As far as Flash is concerned, all that ...
2008/12/24
[ "https://Stackoverflow.com/questions/391857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48934/" ]
Has anyone run into this problem? All I am doing in tabbing from one TextInput component to another. I have reduced my TitleWindow (the container for the TextInputs) down to only these two components and I still get this error. I assumed that it had something to do with my flashplayer install, so I uninstalled and re-...
I'm using FlashPlayer 10 and just tried the following without any errors. ``` <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:TitleWindow> <mx:TextInput id="textA"> </mx:TextInput> <mx:TextInput id="textB"> <...
391,874
<p>I need to update the comments field in a table for a large list of customer_ids. The comment needs to be updated to include the existing comment and appending some text and the password which is in another table. I'm not quite sure how to do this.</p> <p>Here is some code that does this for a single customer id. ...
[ { "answer_id": 391895, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": true, "text": "<p>Well, assuming Contract_comment has a customer_id, or is easily joined to a table that does have one....</p>\n\n<pre><code>u...
2008/12/24
[ "https://Stackoverflow.com/questions/391874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to update the comments field in a table for a large list of customer\_ids. The comment needs to be updated to include the existing comment and appending some text and the password which is in another table. I'm not quite sure how to do this. Here is some code that does this for a single customer id. How would I...
Well, assuming Contract\_comment has a customer\_id, or is easily joined to a table that does have one.... ``` update contract c set contract_comment = contract_comment || '; 12/29/2008 Password ' || (select password from WLogin w where w.default_customer_id = c.customer_id) ||''|| ' reinstated per Mickey Mouse;' WHER...
391,879
<p>I'm starting a Python project and expect to have 20 or more classes in it. As is good practice I want to put them in a separate file each. However, the project directory quickly becomes swamped with files (or will when I do this).</p> <p>If I put a file to import in a folder I can no longer import it. How do I impo...
[ { "answer_id": 391899, "author": "Kenan Banks", "author_id": 43089, "author_profile": "https://Stackoverflow.com/users/43089", "pm_score": 6, "selected": true, "text": "<p>Create an <code>__init__.py</code> file in your projects folder, and it will be treated like a module by Python.</p>...
2008/12/24
[ "https://Stackoverflow.com/questions/391879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1384652/" ]
I'm starting a Python project and expect to have 20 or more classes in it. As is good practice I want to put them in a separate file each. However, the project directory quickly becomes swamped with files (or will when I do this). If I put a file to import in a folder I can no longer import it. How do I import a file ...
Create an `__init__.py` file in your projects folder, and it will be treated like a module by Python. Classes in your package directory can then be imported using syntax like: ``` from package import class import package.class ``` Within `__init__.py`, you may create an `__all__` array that defines `from package im...
391,888
<p>If you set the Visible property of a Windows Forms control to true, that property still returns false if any of the control's parent windows are hidden. Is there a way to get the true, underlying visibility flag of the control in case the parent window is hidden?</p>
[ { "answer_id": 391908, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 5, "selected": true, "text": "<p>Well, the regular implementation <em>does</em> check up the control stack, to ensure that all parents are visible. ...
2008/12/24
[ "https://Stackoverflow.com/questions/391888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22820/" ]
If you set the Visible property of a Windows Forms control to true, that property still returns false if any of the control's parent windows are hidden. Is there a way to get the true, underlying visibility flag of the control in case the parent window is hidden?
Well, the regular implementation *does* check up the control stack, to ensure that all parents are visible. The only way I know to dodge this is to cheat with reflection, and ask for `GetState(2)`, but that is brittle: ``` // dodgy; not recommended Panel query; Form form = new Form { Controls =...
391,913
<p>Will the following code result in a deadlock using C# on .NET?</p> <pre><code> class MyClass { private object lockObj = new object(); public void Foo() { lock(lockObj) { Bar(); } } public void Bar() { lock(lockObj) { // Do s...
[ { "answer_id": 391919, "author": "Neil Barnwell", "author_id": 26414, "author_profile": "https://Stackoverflow.com/users/26414", "pm_score": 8, "selected": true, "text": "<p>No, not as long as you are locking on the same object. The recursive code effectively <strong>already has the loc...
2008/12/24
[ "https://Stackoverflow.com/questions/391913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
Will the following code result in a deadlock using C# on .NET? ``` class MyClass { private object lockObj = new object(); public void Foo() { lock(lockObj) { Bar(); } } public void Bar() { lock(lockObj) { // Do something ...
No, not as long as you are locking on the same object. The recursive code effectively **already has the lock** and so can continue unhindered. `lock(object) {...}` is shorthand for using the [Monitor](http://msdn.microsoft.com/en-us/library/system.threading.monitor.aspx) class. As [Marc points out](https://stackoverfl...
391,915
<p>I have a ComboBox hosted in a ListView and I need changes in the CombBox to update the supporing class that the ListView is bound to. </p> <p>Here is my DataTemplate</p> <pre><code>&lt;DataTemplate x:Key="Category"&gt; &lt;ComboBox IsSynchronizedWithCurrentItem="False" Style="{StaticResource Dro...
[ { "answer_id": 391981, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 2, "selected": true, "text": "<p>Why have you set <code>SelectedValuePath</code> in your <code>ComboBox</code>? It's difficult to say without seeing ...
2008/12/24
[ "https://Stackoverflow.com/questions/391915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38349/" ]
I have a ComboBox hosted in a ListView and I need changes in the CombBox to update the supporing class that the ListView is bound to. Here is my DataTemplate ``` <DataTemplate x:Key="Category"> <ComboBox IsSynchronizedWithCurrentItem="False" Style="{StaticResource DropDown}" ItemsSo...
Why have you set `SelectedValuePath` in your `ComboBox`? It's difficult to say without seeing your data structures, but that doesn't look right to me.
391,917
<p>I was recently trying to update <a href="http://kentb.blogspot.com/2008/12/kentis.html" rel="nofollow noreferrer">my game</a> to store graphics in compressed formats (JPEG and PNG).</p> <p>Whilst I ended up settling on a different library, my initial attempt was to incorporate <a href="http://www.ijg.org/" rel="nof...
[ { "answer_id": 392586, "author": "Hernán", "author_id": 48026, "author_profile": "https://Stackoverflow.com/users/48026", "pm_score": 0, "selected": false, "text": "<p>To work with images in multiple formats, let me recommend you DevIL as a library <a href=\"http://openil.sourceforge.net...
2008/12/24
[ "https://Stackoverflow.com/questions/391917", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5380/" ]
I was recently trying to update [my game](http://kentb.blogspot.com/2008/12/kentis.html) to store graphics in compressed formats (JPEG and PNG). Whilst I ended up settling on a different library, my initial attempt was to incorporate [ijg](http://www.ijg.org/) to do JPEG decompression. However, I was unable to get eve...
I've just encountered the same problem (although I was trying to encode an image). Apparently, FILE\* are not portable between DLLs so you can't use any libjpeg API that takes a FILE\* as a parameter. There are several solutions, but they all come down to having to rebuild the library: * Build the library as a static...
391,920
<p>I've got a project that I started in Turbo Delphi, which I recently updated to D2009, and I've noticed a bit of a quirk in the form designer. All the old forms have a Win98 style applied to them. The buttons are gray with sharp square edges, for example. But any new form I've created since the upgrade displays its ...
[ { "answer_id": 392031, "author": "Cesar Romero", "author_id": 36875, "author_profile": "https://Stackoverflow.com/users/36875", "pm_score": 2, "selected": false, "text": "<p>You should enable run time themes.</p>\n\n<p>Did you check?</p>\n\n<pre><code>Project | Options | Application | [ ...
2008/12/24
[ "https://Stackoverflow.com/questions/391920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32914/" ]
I've got a project that I started in Turbo Delphi, which I recently updated to D2009, and I've noticed a bit of a quirk in the form designer. All the old forms have a Win98 style applied to them. The buttons are gray with sharp square edges, for example. But any new form I've created since the upgrade displays its cont...
You should enable run time themes. Did you check? ``` Project | Options | Application | [ ] Enable Run Time Themes ```
391,955
<p>I am knocking together a WPF demo for our department at work to show them the advantages of WPF whilst <em>trying</em> to adhere to our development standards (dependency injection and developing objects to an explicit interface).</p> <p>I have come to a bit of a wall now. I am implementing the View using the MVVM d...
[ { "answer_id": 392346, "author": "Mark Heath", "author_id": 7532, "author_profile": "https://Stackoverflow.com/users/7532", "pm_score": 4, "selected": true, "text": "<p>I'm not entirely sure if I understood your question right, but why not simply use <code>INotifyPropertyChanged</code> o...
2008/12/24
[ "https://Stackoverflow.com/questions/391955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21682/" ]
I am knocking together a WPF demo for our department at work to show them the advantages of WPF whilst *trying* to adhere to our development standards (dependency injection and developing objects to an explicit interface). I have come to a bit of a wall now. I am implementing the View using the MVVM design pattern and...
I'm not entirely sure if I understood your question right, but why not simply use `INotifyPropertyChanged` on your ViewModel? for example: ``` interface MyInterface : INotifyPropertyChanged { string Text { get; set; } } class MyViewModel : MyInterface { private string text; public string Text { ...