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
369,417
<p>I'm puzzling over how to map a set of sequences to consecutive integers.</p> <p>All the sequences follow this rule:</p> <pre><code>A_0 = 1 A_n &gt;= 1 A_n &lt;= max(A_0 .. A_n-1) + 1 </code></pre> <p>I'm looking for a solution that will be able to, given such a sequence, compute a integer for doing a lookup into ...
[ { "answer_id": 369453, "author": "Tzury Bar Yochay", "author_id": 9296, "author_profile": "https://Stackoverflow.com/users/9296", "pm_score": 0, "selected": false, "text": "<p>This is a python function which can do the job for you assuming you got these values stored in a file and you pa...
2008/12/15
[ "https://Stackoverflow.com/questions/369417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
I'm puzzling over how to map a set of sequences to consecutive integers. All the sequences follow this rule: ``` A_0 = 1 A_n >= 1 A_n <= max(A_0 .. A_n-1) + 1 ``` I'm looking for a solution that will be able to, given such a sequence, compute a integer for doing a lookup into a table and given an index into the tab...
There is a natural sequence indexing, but no so easy to calculate. Let look for A\_n for n>0, since A\_0 = 1. Indexing is done in 2 steps. Part 1: ------- Group sequences by places where A\_n = max(A\_0 .. A\_n-1) + 1. Call these places *steps*. * On steps are consecutive numbers (2,3,4,5,...). * On non-step plac...
369,424
<p>This is a follow-up question to <a href="https://stackoverflow.com/questions/369220/why-should-you-not-use-number-as-a-constructor">this one</a>.</p> <p>Take a look at these two examples: </p> <pre><code>var number1 = new Number(3.123); number1 = number1.toFixed(2); alert(number1); var number2 = 3.123; number2 =...
[ { "answer_id": 369479, "author": "Matthew Crumley", "author_id": 2214, "author_profile": "https://Stackoverflow.com/users/2214", "pm_score": 3, "selected": false, "text": "<p>Technically, no. You can treat it like it is a method of the primative value, because number2 is will be converte...
2008/12/15
[ "https://Stackoverflow.com/questions/369424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
This is a follow-up question to [this one](https://stackoverflow.com/questions/369220/why-should-you-not-use-number-as-a-constructor). Take a look at these two examples: ``` var number1 = new Number(3.123); number1 = number1.toFixed(2); alert(number1); var number2 = 3.123; number2 = number2.toFixed(2); alert(numbe...
In JavaScript, everything is an object, even functions and integers. It is perfectly OK to think of methods on numbers and strings. For example: ``` >>> (3.123).toString() "3.123" ```
369,448
<p>I'm having this problem, same as ever, but never try to find the <em>right</em> solution</p> <p>code:</p> <pre><code> &lt;div id="ListOfTextAndPhotos"&gt; &lt;div style="border-bottom: solid 1px silver;"&gt; &lt;img src="photo.jpg" style="float: left"&gt; Some text about the photo &...
[ { "answer_id": 369458, "author": "TJ L", "author_id": 12605, "author_profile": "https://Stackoverflow.com/users/12605", "pm_score": 2, "selected": false, "text": "<p>A quick and dirty way to do it would be to float the containing div as well.</p>\n" }, { "answer_id": 369465, ...
2008/12/15
[ "https://Stackoverflow.com/questions/369448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2385/" ]
I'm having this problem, same as ever, but never try to find the *right* solution code: ``` <div id="ListOfTextAndPhotos"> <div style="border-bottom: solid 1px silver;"> <img src="photo.jpg" style="float: left"> Some text about the photo </div> <div style="border-bottom: solid 1...
The more traditional way (other than clearing) is to set the overflow property of the containing div to hidden. ``` <div style="border-bottom: solid 1px silver; overflow: hidden;"> <img src="photo3.jpg" style="float: left"> <div>Some text about the photo3</div> </div> ``` Sometimes, IE6 does not honor th...
369,452
<p>I am being powerfully tempted to use an unchecked exception as a short-circuit control-flow construct in a Java program. I hope somebody here can advise me on a better, cleaner way to handle this problem.</p> <p>The idea is that I want to cut short the recursive exploration of sub-trees by a visitor without having ...
[ { "answer_id": 369466, "author": "Elie", "author_id": 23249, "author_profile": "https://Stackoverflow.com/users/23249", "pm_score": 0, "selected": false, "text": "<p>Is there a reason you aren't just returning a value? Such as NULL, if you really want to return nothing? That would be a l...
2008/12/15
[ "https://Stackoverflow.com/questions/369452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1412/" ]
I am being powerfully tempted to use an unchecked exception as a short-circuit control-flow construct in a Java program. I hope somebody here can advise me on a better, cleaner way to handle this problem. The idea is that I want to cut short the recursive exploration of sub-trees by a visitor without having to check a...
I think this is a reasonable approach for a few reasons: * You are using a 3rd party and are unable to add the checked exception * Checking return values everywhere in a large set of visitors when it's only necessary in a few is an unnecessary burden Also, there are those that have argued that [unchecked exceptions a...
369,460
<p>I am using Hibernate 3.x, MySQL 4.1.20 with Java 1.6. I am mapping a Hibernate Timestamp to a MySQL TIMESTAMP. So far so good. The problem is that MySQL stores the TIMESTAMP in seconds and discards the milliseconds and I now need millisecond precision. I figure I can use a BIGINT instead of TIMESTAMP in my table a...
[ { "answer_id": 369475, "author": "Elie", "author_id": 23249, "author_profile": "https://Stackoverflow.com/users/23249", "pm_score": 0, "selected": false, "text": "<p>Why not use it in addition to the TIMESTAMP field? You would have one field (which is already defined) for storing the dat...
2008/12/15
[ "https://Stackoverflow.com/questions/369460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4476/" ]
I am using Hibernate 3.x, MySQL 4.1.20 with Java 1.6. I am mapping a Hibernate Timestamp to a MySQL TIMESTAMP. So far so good. The problem is that MySQL stores the TIMESTAMP in seconds and discards the milliseconds and I now need millisecond precision. I figure I can use a BIGINT instead of TIMESTAMP in my table and co...
Also, look at creating a custom Hibernate Type implementation. Something along the lines of (psuedocode as I don't have a handy environment to make it bulletproof): ``` public class CalendarBigIntType extends org.hibernate.type.CalendarType { public Object get(ResultSet rs, String name) { return cal = new ...
369,495
<p>Are C-style macro names subject to the same naming rules as identifiers? After a compiler upgrade, it is now emitting this warning for a legacy application:</p> <pre><code>warning #3649-D: white space is required between the macro name "CHAR_" and its replacement text #define CHAR_&amp; 38 </code>...
[ { "answer_id": 369524, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 6, "selected": true, "text": "<p>Macro names should only consist of alphanumeric characters and underscores, i.e. <code>'a-z'</code>, <code>'A-Z'</...
2008/12/15
[ "https://Stackoverflow.com/questions/369495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17035/" ]
Are C-style macro names subject to the same naming rules as identifiers? After a compiler upgrade, it is now emitting this warning for a legacy application: ``` warning #3649-D: white space is required between the macro name "CHAR_" and its replacement text #define CHAR_& 38 ``` This line of code is...
Macro names should only consist of alphanumeric characters and underscores, i.e. `'a-z'`, `'A-Z'`, `'0-9'`, and `'_'`, and the first character should not be a digit. Some preprocessors also permit the dollar sign character `'$'`, but you shouldn't use it; unfortunately I can't quote the C standard since I don't have a ...
369,498
<p>Some websites have code to "break out" of <code>IFRAME</code> enclosures, meaning that if a page <code>A</code> is loaded as an <code>IFRAME</code> inside an parent page <code>P</code> some Javascript in <code>A</code> redirects the outer window to <code>A</code>.</p> <p>Typically this Javascript looks something li...
[ { "answer_id": 369571, "author": "Diodeus - James MacFarlane", "author_id": 12579, "author_profile": "https://Stackoverflow.com/users/12579", "pm_score": 0, "selected": false, "text": "<p>By doing so you'd be able to control any action of the framed page, which you cannot. <a href=\"http...
2008/12/15
[ "https://Stackoverflow.com/questions/369498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4926/" ]
Some websites have code to "break out" of `IFRAME` enclosures, meaning that if a page `A` is loaded as an `IFRAME` inside an parent page `P` some Javascript in `A` redirects the outer window to `A`. Typically this Javascript looks something like this: ``` <script type="text/javascript"> if (top.location.href != sel...
Try using the onbeforeunload property, which will let the user choose whether he wants to navigate away from the page. Example: <https://developer.mozilla.org/en-US/docs/Web/API/Window.onbeforeunload> In HTML5 you can use sandbox property. Please see Pankrat's answer below. <http://www.html5rocks.com/en/tutorials/sec...
369,510
<p>I have an Excel file that has a bunch of VBA and macro code in it. When I open the file in Excel I can choose not to 'enable' them - so the values in the fields all stay as they were during the last save. I need to manipulate the values as they were last saved - so I don't want the macros (which look at the curren...
[ { "answer_id": 369583, "author": "shahkalpesh", "author_id": 23574, "author_profile": "https://Stackoverflow.com/users/23574", "pm_score": 3, "selected": true, "text": "<pre><code>Application.AutomationSecurity = msoAutomationSecurity.msoAutomationSecurityForceDisable\n</code></pre>\n\n<...
2008/12/15
[ "https://Stackoverflow.com/questions/369510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37559/" ]
I have an Excel file that has a bunch of VBA and macro code in it. When I open the file in Excel I can choose not to 'enable' them - so the values in the fields all stay as they were during the last save. I need to manipulate the values as they were last saved - so I don't want the macros (which look at the current dat...
``` Application.AutomationSecurity = msoAutomationSecurity.msoAutomationSecurityForceDisable ``` Try opening the workbook after this statement. I think, this will disable macros at Application Level (not at workbook level) Hope that helps.
369,512
<p>Assume you have some objects which have several fields they can be compared by:</p> <pre><code>public class Person { private String firstName; private String lastName; private String age; /* Constructors */ /* Methods */ } </code></pre> <p>So in this example, when you ask if:</p> <pre><cod...
[ { "answer_id": 369518, "author": "Michael Haren", "author_id": 29, "author_profile": "https://Stackoverflow.com/users/29", "pm_score": 2, "selected": false, "text": "<p>I think it'd be more confusing if your comparison algorithm were \"clever\". I'd go with the numerous comparison method...
2008/12/15
[ "https://Stackoverflow.com/questions/369512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24545/" ]
Assume you have some objects which have several fields they can be compared by: ``` public class Person { private String firstName; private String lastName; private String age; /* Constructors */ /* Methods */ } ``` So in this example, when you ask if: ``` a.compareTo(b) > 0 ``` you might ...
You can implement a `Comparator` which compares two `Person` objects, and you can examine as many of the fields as you like. You can put in a variable in your comparator that tells it which field to compare to, although it would probably be simpler to just write multiple comparators.
369,519
<p>Is it better to use NOT or to use &lt;> when comparing values in VBScript?<br> is this:</p> <pre><code> If NOT value1 = value2 Then </code></pre> <p>or this:</p> <pre><code> If value1 &lt;&gt; value2 Then </code></pre> <p>better?<br></p> <p>EDIT: Here is my counterargument. <br> When looking to logically negate...
[ { "answer_id": 369525, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 7, "selected": true, "text": "<p>The latter (<code>&lt;&gt;</code>), because the meaning of the former isn't clear unless you have a perfect understa...
2008/12/15
[ "https://Stackoverflow.com/questions/369519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38695/" ]
Is it better to use NOT or to use <> when comparing values in VBScript? is this: ``` If NOT value1 = value2 Then ``` or this: ``` If value1 <> value2 Then ``` better? EDIT: Here is my counterargument. When looking to logically negate a Boolean value you would use the NOT operator, so this is correct: ...
The latter (`<>`), because the meaning of the former isn't clear unless you have a perfect understanding of the order of operations as it applies to the `Not` and `=` operators: a subtlety which is easy to miss.
369,543
<p>I'm working on a small project in VB.Net where I get a input from a textbox, and need to verify that this is an e-email address.</p> <p>I found this expression "^[_a-z0-9-]+(.[_a-z0-9-]+)<em>@[a-z0-9-]+(.[a-z0-9-]+)</em>(.[a-z]{2,4})$", but i cant find any way to test if it passes.</p> <p>I want some code like: <...
[ { "answer_id": 369554, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 6, "selected": true, "text": "<p>Use the <code>System.Text.RegularExpressions.Regex</code> class:</p>\n\n<pre><code>Function IsEmail(Byval email as s...
2008/12/15
[ "https://Stackoverflow.com/questions/369543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41807/" ]
I'm working on a small project in VB.Net where I get a input from a textbox, and need to verify that this is an e-email address. I found this expression "^[\_a-z0-9-]+(.[\_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,4})$", but i cant find any way to test if it passes. I want some code like: ``` if not txtEmail.te...
Use the `System.Text.RegularExpressions.Regex` class: ``` Function IsEmail(Byval email as string) as boolean Static emailExpression As New Regex("^[_a-z0-9-]+(.[a-z0-9-]+)@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,4})$") return emailExpression.IsMatch(email) End Function ``` The most important thing to understand a...
369,570
<p>I have included a resource in my Visual Studio 2005 solution that was a file on the hard drive. It is a text file, that contains text, and has a <strong>.htm</strong> extension.</p> <p>For months it worked fine, until I wanted to edit the contents of the text file. Suddenly Visual Studio insists on syntax checking ...
[ { "answer_id": 369578, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 2, "selected": true, "text": "<p>This obviously begs the question – why do you use a wrong file extension on a system, where file type is determined...
2008/12/15
[ "https://Stackoverflow.com/questions/369570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
I have included a resource in my Visual Studio 2005 solution that was a file on the hard drive. It is a text file, that contains text, and has a **.htm** extension. For months it worked fine, until I wanted to edit the contents of the text file. Suddenly Visual Studio insists on syntax checking the file as though it w...
This obviously begs the question – why do you use a wrong file extension on a system, where file type is determined by these extensions? Sorry, the answer is of course wrong. I was pretty sure I had done it that way already. Still, I think the above comment is still valid, even if not applicable universally. Marking t...
369,572
<p>For some reason, when using two sums on a group by, i run into the error "invalid column name 'id'. When i only do one sum, it works as expected.</p> <p>The following <strong>fails</strong> and throws the error:</p> <pre><code>from pd in PrDetails.Where(_pd =&gt; _pd.PrId == 46) group pd by new { pd.ProgramFun...
[ { "answer_id": 369880, "author": "Cameron MacFarland", "author_id": 3820, "author_profile": "https://Stackoverflow.com/users/3820", "pm_score": 2, "selected": true, "text": "<p>About the only think I can think it might be is a conflict with the names of your parameters. Try this:</p>\n\n...
2008/12/15
[ "https://Stackoverflow.com/questions/369572", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5203/" ]
For some reason, when using two sums on a group by, i run into the error "invalid column name 'id'. When i only do one sum, it works as expected. The following **fails** and throws the error: ``` from pd in PrDetails.Where(_pd => _pd.PrId == 46) group pd by new { pd.ProgramFund, pd.ProjectDetail.CostCenter, pd.Pr...
About the only think I can think it might be is a conflict with the names of your parameters. Try this: ``` from pd in PrDetails.Where(_pd => _pd.PrId == 46) group pd by new { pd.ProgramFund, pd.ProjectDetail.CostCenter, pd.ProjectDetail.Wbs } into g select new { g.Key.ProgramFund, g.Key.CostCenter, g.Key....
369,573
<p>I have a strongly typed user control ("partial") and I'd like to be able to pass it some additional information from its containing view. For example, I have view that's bound to a product class and i have a partial that also is strongly typed to that same model, but I also need to pass an additional parameter for ...
[ { "answer_id": 369584, "author": "Craig Stuntz", "author_id": 7714, "author_profile": "https://Stackoverflow.com/users/7714", "pm_score": 4, "selected": true, "text": "<p>Change the type of the partial model:</p>\n\n<pre><code>class PartialModel \n{\n public int ImageSize { get; set; ...
2008/12/15
[ "https://Stackoverflow.com/questions/369573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4541/" ]
I have a strongly typed user control ("partial") and I'd like to be able to pass it some additional information from its containing view. For example, I have view that's bound to a product class and i have a partial that also is strongly typed to that same model, but I also need to pass an additional parameter for imag...
Change the type of the partial model: ``` class PartialModel { public int ImageSize { get; set; } public ParentModelType ParentModel { get; set; } } ``` Now pass it: ``` <% Html.RenderPartial("_ProductImage", new PartialModel() { ImageSize = 100, ParentModel = ViewData.Model }); %> ```
369,591
<p>I have an SSIS package that does the following: Selects the connection strings from a table of servers. The connection string is either the name of the server along with the domain (i.e. Dalin.myhouse.com) or is the direct IP to a server.</p> <p>The package iterates through each connection string and populates a d...
[ { "answer_id": 371667, "author": "Derek B. Bell", "author_id": 8944, "author_profile": "https://Stackoverflow.com/users/8944", "pm_score": 2, "selected": true, "text": "<p>I can't see how this can be accomplished without the variables being set within a Script Task, since ExecuteSQL task...
2008/12/15
[ "https://Stackoverflow.com/questions/369591", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have an SSIS package that does the following: Selects the connection strings from a table of servers. The connection string is either the name of the server along with the domain (i.e. Dalin.myhouse.com) or is the direct IP to a server. The package iterates through each connection string and populates a defined 'glo...
I can't see how this can be accomplished without the variables being set within a Script Task, since ExecuteSQL tasks have to be set to a database connection. Script Tasks work for this because their connection is within the context of the server that's executing them. That being said, you could use a Script Task prior...
369,594
<p>I have a WebBrowser control which is being instantiated dynamically from a background STA thread because the parent thread is a BackgroundWorker and has lots of other things to do.</p> <p>The problem is that the Navigated event never fires, unless I pop a MessageBox.Show() in the method that told it to .Navigate()....
[ { "answer_id": 369623, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": true, "text": "<p><code>WebBrowser</code> won't do much unless it is shown and has a UI thread associated; are you showing the form o...
2008/12/15
[ "https://Stackoverflow.com/questions/369594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11112/" ]
I have a WebBrowser control which is being instantiated dynamically from a background STA thread because the parent thread is a BackgroundWorker and has lots of other things to do. The problem is that the Navigated event never fires, unless I pop a MessageBox.Show() in the method that told it to .Navigate(). I shall e...
`WebBrowser` won't do much unless it is shown and has a UI thread associated; are you showing the form on which it resides? You need to, to use the DOM etc. The form could be off-screen if you don't want to display it to the user, but it won't work well in a service (for example). For scraping purposes, you can normal...
369,595
<p>I have found ASP.Net PageMethods very handy and easy to use, but I have just started developing using MVC and am not sure how to use them?</p> <p>What is the equivalent of <code>PageMethods.MyFunction()</code> in MVC where MyFunction is a Controller action?</p> <p>I know I can use the <code>Json</code> function t...
[ { "answer_id": 369640, "author": "Gabe Moothart", "author_id": 13356, "author_profile": "https://Stackoverflow.com/users/13356", "pm_score": 2, "selected": false, "text": "<p>I don't think you need page methods. Page methods in asp.net are a way to expose methods in the page class to you...
2008/12/15
[ "https://Stackoverflow.com/questions/369595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18107/" ]
I have found ASP.Net PageMethods very handy and easy to use, but I have just started developing using MVC and am not sure how to use them? What is the equivalent of `PageMethods.MyFunction()` in MVC where MyFunction is a Controller action? I know I can use the `Json` function to return a value, but how do I call the ...
> > I know I can use the Json function to > return a value, but how do I call the > action from the client? > > > I think you're looking for either [getJSON](http://docs.jquery.com/Ajax/jQuery.getJSON) ``` $.getJSON("/controller/action", function(json) { alert("JSON Data: " + json.users[3].name); }); ``` or...
369,602
<p>Is there an easy way to delete an element from an array using PHP, such that <code>foreach ($array)</code> no longer includes that element?</p> <p>I thought that setting it to <code>null</code> would do it, but apparently it does not work.</p>
[ { "answer_id": 369608, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 13, "selected": true, "text": "<p>There are different ways to delete an array element, where some are more useful for some specific tasks than other...
2008/12/15
[ "https://Stackoverflow.com/questions/369602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11522/" ]
Is there an easy way to delete an element from an array using PHP, such that `foreach ($array)` no longer includes that element? I thought that setting it to `null` would do it, but apparently it does not work.
There are different ways to delete an array element, where some are more useful for some specific tasks than others. Deleting a single array element ------------------------------- If you want to delete just one array element you can use [`unset()`](https://secure.php.net/manual/en/function.unset.php) or alternativel...
369,678
<p>I'm looking for a reliable design for handling assignments that have asynchronous requests involved. To further clarify, I have a class which handles Data Management. It is a singleton and contains a lot of top level data for me which is used throughout my iPhone application.</p> <p>A view controller might do somet...
[ { "answer_id": 369822, "author": "August", "author_id": 30966, "author_profile": "https://Stackoverflow.com/users/30966", "pm_score": 1, "selected": false, "text": "<p>You can either use a delegate pattern or a notification pattern here.</p>\n\n<p>A delegate would let a particular object...
2008/12/15
[ "https://Stackoverflow.com/questions/369678", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40882/" ]
I'm looking for a reliable design for handling assignments that have asynchronous requests involved. To further clarify, I have a class which handles Data Management. It is a singleton and contains a lot of top level data for me which is used throughout my iPhone application. A view controller might do something such ...
I solved this problem a couple ways in different apps. One solution is to pass an object and selector along to notify such as: ``` - (id)getUsersAndNotifyObject:(id)object selector:(SEL)selector ``` This breaks the nice property behavior however. If you want to keep the methods as properties, have them return imme...
369,702
<p>What is the best way to create a DataTable with the same structure as a table in my SqlServer database? At present, I am using SqlDataAdapter.Fill() with a query that brings back the columns but no rows. That's works fine, but it seems klutzy. </p> <p>Is there a better way?</p>
[ { "answer_id": 369711, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 0, "selected": false, "text": "<p>Well, don't you already know the structure?</p>\n\n<p>The \"SET FMT_ONLY ON\", or \"WHERE 1 = 0\" tricks are both ...
2008/12/15
[ "https://Stackoverflow.com/questions/369702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19267/" ]
What is the best way to create a DataTable with the same structure as a table in my SqlServer database? At present, I am using SqlDataAdapter.Fill() with a query that brings back the columns but no rows. That's works fine, but it seems klutzy. Is there a better way?
Well, if you use Linq2Sql, you can reflect over the entity class, and create the datatable based on the properties name and datatype. ``` Type type = typeof(Product); //or whatever the type is DataTable table = new DataTable(); foreach(var prop in type.GetProperties()) {...
369,714
<p>I normally build my solution with MSBuild in order to keep Visual Studio responsive and save a bit of time. Right now, what I run at the command line is very simple:</p> <pre><code>MSBuild.exe /m "C:\MyProject\MyProject.sln" </code></pre> <p>Up until now, this has worked just fine. However, today I added a class...
[ { "answer_id": 369731, "author": "Tim", "author_id": 10755, "author_profile": "https://Stackoverflow.com/users/10755", "pm_score": 1, "selected": false, "text": "<p>I have found that historically MS IDE does not always save project and solution files when you ask it to... This may have ...
2008/12/15
[ "https://Stackoverflow.com/questions/369714", "https://Stackoverflow.com", "https://Stackoverflow.com/users/767/" ]
I normally build my solution with MSBuild in order to keep Visual Studio responsive and save a bit of time. Right now, what I run at the command line is very simple: ``` MSBuild.exe /m "C:\MyProject\MyProject.sln" ``` Up until now, this has worked just fine. However, today I added a class to a class library project ...
This probably sounds like a stupid question, but are you sure the new class file was saved? Rebuild usually automatically saves all files, whereas MSBuild does not.
369,736
<p>I am trying to hide the button based on the user's role using the following code: </p> <pre><code> &lt;asp:Button ID="btndisplayrole" Text="Admin Button" Visible='&lt;%= WebApplication1.SiteHelper.IsUserInRole("Admin") %&gt;' runat="server" OnClick="DisplayRoleClick" /&gt; </code></pre> <p>But when I run the above...
[ { "answer_id": 369746, "author": "shahkalpesh", "author_id": 23574, "author_profile": "https://Stackoverflow.com/users/23574", "pm_score": -1, "selected": false, "text": "<pre><code>Visible='&lt;%= WebApplication1.SiteHelper.IsUserInRole(\"Admin\").ToString() %&gt;'\n</code></pre>\n\n<p>...
2008/12/15
[ "https://Stackoverflow.com/questions/369736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3797/" ]
I am trying to hide the button based on the user's role using the following code: ``` <asp:Button ID="btndisplayrole" Text="Admin Button" Visible='<%= WebApplication1.SiteHelper.IsUserInRole("Admin") %>' runat="server" OnClick="DisplayRoleClick" /> ``` But when I run the above code I get the following error messag...
Kind of an interesting issue.. But as the error message states, the string `<%= WebApplication1.SiteHelper.IsUserInRole("Admin") %>` cannot be converted to a boolean. Unfortunately i cannot explain why the expression isn't evaluated, but instead is treated like a string. The reason why your `<%# %>` expression works ...
369,739
<p>For the following example:</p> <p><a href="http://developer.yahoo.com/yui/examples/tabview/frommarkup_clean.html" rel="nofollow noreferrer">http://developer.yahoo.com/yui/examples/tabview/frommarkup_clean.html</a></p> <p>I would like to make the tabs right aligned and still retain the current order.</p> <p>I'm ce...
[ { "answer_id": 369747, "author": "da5id", "author_id": 14979, "author_profile": "https://Stackoverflow.com/users/14979", "pm_score": 0, "selected": false, "text": "<p>Have you tried applying \"text-align: right;\" to the container div :</p>\n\n<pre><code>&lt;div id=\"demo\" class=\"yui-n...
2008/12/15
[ "https://Stackoverflow.com/questions/369739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2621/" ]
For the following example: <http://developer.yahoo.com/yui/examples/tabview/frommarkup_clean.html> I would like to make the tabs right aligned and still retain the current order. I'm certain its something simple - just too close to it to see the solution.
Off the top my head, how about: ``` <div id="demo" class="yui-navset"> <ul class="yui-nav" style="text-align:right;"> <li><a href="#tab1"><em>Tab One Label</em></a></li> <li class="selected"><a href="#tab2"><em>Tab Two Label</a></li> <li><a href="#tab3"><em>Tab Three Label</em></a></li> ...
369,755
<p>My users will import through cut and paste a large string that will contain company names. </p> <p>I have an existing and growing MYSQL database of companies names, each with a unique company_id.</p> <p>I want to be able to parse through the string and assign to each of the user-inputed company names a fuzzy match...
[ { "answer_id": 369766, "author": "dkretz", "author_id": 31641, "author_profile": "https://Stackoverflow.com/users/31641", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://us3.php.net/soundex\" rel=\"nofollow noreferrer\">Here's a link to the php discussion of the soundex fu...
2008/12/15
[ "https://Stackoverflow.com/questions/369755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43980/" ]
My users will import through cut and paste a large string that will contain company names. I have an existing and growing MYSQL database of companies names, each with a unique company\_id. I want to be able to parse through the string and assign to each of the user-inputed company names a fuzzy match. Right now, ju...
You can start with using [`SOUNDEX()`](http://en.wikipedia.org/wiki/Soundex), this will probably do for what you need (I picture an auto-suggestion box of already-existing alternatives for what the user is typing). The drawbacks of `SOUNDEX()` are: * its inability to differentiate longer strings. Only the first few c...
369,758
<p>I have a shell script with this code:</p> <pre><code>var=`hg st -R "$path"` if [ -n "$var" ]; then echo $var fi </code></pre> <p>But the conditional code always executes, because <code>hg st</code> always prints at least one newline character.</p> <ul> <li>Is there a simple way to strip whitespace from <code>...
[ { "answer_id": 369768, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 5, "selected": false, "text": "<p>I've always done it with sed</p>\n\n<pre><code> var=`hg st -R \"$path\" | sed -e 's/ *$//'`\n</code></pre>\n\n<p>I...
2008/12/15
[ "https://Stackoverflow.com/questions/369758", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28835/" ]
I have a shell script with this code: ``` var=`hg st -R "$path"` if [ -n "$var" ]; then echo $var fi ``` But the conditional code always executes, because `hg st` always prints at least one newline character. * Is there a simple way to strip whitespace from `$var` (like `trim()` in [PHP](http://en.wikipedia.org...
Let's define a variable containing leading, trailing, and intermediate whitespace: ``` FOO=' test test test ' echo -e "FOO='${FOO}'" # > FOO=' test test test ' echo -e "length(FOO)==${#FOO}" # > length(FOO)==16 ``` --- How to remove all whitespace (denoted by `[:space:]` in `tr`): ``` FOO=' test test test ' FOO_NO...
369,760
<p>I googled for this for a while but can't seem to find it and it should be easy. I want to append a CR to then end of an XML file that I am creating with a Transformer. Is there a way to do this></p> <p>I tried the following but this resulted in a blank file?</p> <pre><code> Transformer xformer = TransformerFactory...
[ { "answer_id": 369781, "author": "PhiLho", "author_id": 15459, "author_profile": "https://Stackoverflow.com/users/15459", "pm_score": 0, "selected": false, "text": "<p>I didn't know this Transformer class. But I see no connection between your writer/file variables and your xformer/source...
2008/12/15
[ "https://Stackoverflow.com/questions/369760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/673/" ]
I googled for this for a while but can't seem to find it and it should be easy. I want to append a CR to then end of an XML file that I am creating with a Transformer. Is there a way to do this> I tried the following but this resulted in a blank file? ``` Transformer xformer = TransformerFactory.newInstance().newTra...
Simple... just add the [append](http://java.sun.com/j2se/1.4.2/docs/api/java/io/FileOutputStream.html#FileOutputStream(java.io.File,%20boolean)) option: ``` new FileOutputStream(f, true /* append */); ```
369,762
<p>I learned that by trying to use the tablesorter plug in from jquery the table needs to use the &lt; thead> and<br> &lt; tbody> tags. I am using an html table, and I use the runat="server" attribute because I need to bind data to the table on the server side. but by using the runat= server attribute the code is rend...
[ { "answer_id": 369819, "author": "Russ Cam", "author_id": 1831, "author_profile": "https://Stackoverflow.com/users/1831", "pm_score": 4, "selected": true, "text": "<p>You should take a look here -<a href=\"http://www.codeproject.com/KB/aspnet/SortableGridViewjQuery.aspx\" rel=\"noreferr...
2008/12/15
[ "https://Stackoverflow.com/questions/369762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39809/" ]
I learned that by trying to use the tablesorter plug in from jquery the table needs to use the < thead> and < tbody> tags. I am using an html table, and I use the runat="server" attribute because I need to bind data to the table on the server side. but by using the runat= server attribute the code is rendered in a d...
You should take a look here -[Code Project Sortable Gridview using JQuery Tablesorter](http://www.codeproject.com/KB/aspnet/SortableGridViewjQuery.aspx) Essentially, you need to use the [UseAccessibleHeader property](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.useaccessibleheader.aspx) o...
369,764
<p>I use the <a href="http://oss.coresecurity.com/projects/pcapy.html" rel="nofollow noreferrer">pcapy</a>/<a href="http://oss.coresecurity.com/projects/impacket.html" rel="nofollow noreferrer">impacket</a> library to decode network packets in Python. It has an IP decoder which knows about the syntax of IPv4 packets bu...
[ { "answer_id": 384375, "author": "Fernando Miguélez", "author_id": 34880, "author_profile": "https://Stackoverflow.com/users/34880", "pm_score": -1, "selected": false, "text": "<p>I have never used pcapy before, but I do have used libpcap in C projects. As the pcapy page states it is not...
2008/12/15
[ "https://Stackoverflow.com/questions/369764", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15625/" ]
I use the [pcapy](http://oss.coresecurity.com/projects/pcapy.html)/[impacket](http://oss.coresecurity.com/projects/impacket.html) library to decode network packets in Python. It has an IP decoder which knows about the syntax of IPv4 packets but apparently no IPv6 decoder. Does anyone get one? In a private correspond...
Scapy, recommended by the Impacket maintainers, has no IPv6 decoding at this time. But there is an [unofficial extension](http://namabiiru.hongo.wide.ad.jp/scapy6/) to do so. With this extension, it works: ``` for packet in traffic: if packet.type == ETH_P_IPV6 or packet.type == ETH_P_IP: ip = packet.payload ...
369,777
<p>I've have searched on this and it seems to be a catch all, unfortunately everything I've read doesn't help figure it out. Here is the class:</p> <pre><code>public interface IMockInterface { MockClass MockedMethod(); MockClass MockThis(); } public class MockClass : IMockInterface { public virtual MockCla...
[ { "answer_id": 369830, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": true, "text": "<p>You're telling the mock framework to stub the MockedMethod class on the provider object, but you never inject the pro...
2008/12/15
[ "https://Stackoverflow.com/questions/369777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21691/" ]
I've have searched on this and it seems to be a catch all, unfortunately everything I've read doesn't help figure it out. Here is the class: ``` public interface IMockInterface { MockClass MockedMethod(); MockClass MockThis(); } public class MockClass : IMockInterface { public virtual MockClass MockedMethod...
You're telling the mock framework to stub the MockedMethod class on the provider object, but you never inject the provider into the mainClass object to be used. It's not clear to me what you are trying to accomplish but if you want the mocked method to be called then it has to be called on the object on which the stub ...
369,788
<p>I created a simple dialog-based application, and in the default CDialog added three buttons (by drag-and-dropping them) using the Visual Studio editor. </p> <p>The default OK and Cancel buttons are there too.</p> <p>I want to set the focus to button 1 when I click button 3.</p> <p>I set the property Flat to true ...
[ { "answer_id": 369818, "author": "Mark Ransom", "author_id": 5987, "author_profile": "https://Stackoverflow.com/users/5987", "pm_score": 0, "selected": false, "text": "<p>By calling UpdateWindow, the button is being redrawn before the focus change can take effect. The Invalidate should ...
2008/12/15
[ "https://Stackoverflow.com/questions/369788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14022/" ]
I created a simple dialog-based application, and in the default CDialog added three buttons (by drag-and-dropping them) using the Visual Studio editor. The default OK and Cancel buttons are there too. I want to set the focus to button 1 when I click button 3. I set the property Flat to true in the properties for mu...
This draws the thick border around the button: ``` static_cast<CButton*>(GetDlgItem(IDC_BUTTON1))->SetButtonStyle(BS_DEFPUSHBUTTON); ``` A more elegant way to do this would be to define a CButton member variable in CbuttonfocusDlg and associate it to the IDC\_BUTTON1 control, and then calling ``` this->m_myButton.S...
369,790
<p>I am creating a little testing component and am running into a problem</p> <p>Basically the component is a decorator on a class that controls all access to the database, it creates a form with a two buttons on it: "Simulate Lost Connection" and "Reconnect". Press the button, and instead of letting function calls p...
[ { "answer_id": 369829, "author": "Cory Foy", "author_id": 4083, "author_profile": "https://Stackoverflow.com/users/4083", "pm_score": 0, "selected": false, "text": "<p>It sounds like you aren't holding on to your thread. It's an object, like everything else, so if it is scoped to your me...
2008/12/15
[ "https://Stackoverflow.com/questions/369790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
I am creating a little testing component and am running into a problem Basically the component is a decorator on a class that controls all access to the database, it creates a form with a two buttons on it: "Simulate Lost Connection" and "Reconnect". Press the button, and instead of letting function calls pass through...
You will need to start a message loop on the newly created thread. You can do that by calling Application.Run(form).
369,792
<p>Here's a fictitious example of the problem I'm trying to solve. If I'm working in C#, and have XML like this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;Cars&gt; &lt;Car&gt; &lt;StockNumber&gt;1020&lt;/StockNumber&gt; &lt;Make&gt;Nissan&lt;/Make&gt; &lt;Model&gt;Sentra&lt;/Model&...
[ { "answer_id": 369841, "author": "Tim Jarvis", "author_id": 10387, "author_profile": "https://Stackoverflow.com/users/10387", "pm_score": 2, "selected": false, "text": "<p>You can control how your serialization is done by implementing the ISerializable interface in your class. Note this ...
2008/12/15
[ "https://Stackoverflow.com/questions/369792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5198/" ]
Here's a fictitious example of the problem I'm trying to solve. If I'm working in C#, and have XML like this: ``` <?xml version="1.0" encoding="utf-8"?> <Cars> <Car> <StockNumber>1020</StockNumber> <Make>Nissan</Make> <Model>Sentra</Model> </Car> <Car> <StockNumber>1010</StockNumber> <Make>To...
It might be a bit old thread, but i will post anyway. i had the same problem (needed to deserialize like 10kb of data from a file that had more than 1MB). In main object (which has a InnerObject that needs to be deserializer) i implemented a IXmlSerializable interface, then changed the ReadXml method. We have xmlText...
369,794
<p>I've seen a few examples of RSS Feeds in ASP.NET MVC, like <a href="https://stackoverflow.com/questions/11915/rss-feeds-in-aspnet-mvc">this</a>, and some samples in projects (like Oxite), but none of them are complete. </p> <p>Eg. None of them check for the header </p> <pre><code> If-Modified-Since </code></pre> ...
[ { "answer_id": 370014, "author": "Trevor de Koekkoek", "author_id": 41783, "author_profile": "https://Stackoverflow.com/users/41783", "pm_score": 2, "selected": false, "text": "<p>I haven't seen it implement HTTP_IF_MODIFIED_SINCE, but I would look into using the SyndicationFeed class. ...
2008/12/15
[ "https://Stackoverflow.com/questions/369794", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2385/" ]
I've seen a few examples of RSS Feeds in ASP.NET MVC, like [this](https://stackoverflow.com/questions/11915/rss-feeds-in-aspnet-mvc), and some samples in projects (like Oxite), but none of them are complete. Eg. None of them check for the header ``` If-Modified-Since ``` in the request, to save bandwidth. I do...
I ended up with this. Please comment or edit the post if you find any error or better way to do it. RssController ------------- ``` Imports System.ServiceModel.Syndication Imports System.Xml Imports System.Web.HttpContext Function MasterRSS() Dim baseURL As String = "http://www.mysite.com" Dim feed As New Sy...
369,850
<p>So I am following this guide: <a href="http://technotes.1000lines.net/?p=23" rel="noreferrer">http://technotes.1000lines.net/?p=23</a> and I am going through the steps. I have a VPN (slicehost.com) with Debian Etch, serving a website (static so far) with nginx. I used wget to download FastCGI and I did the usual mak...
[ { "answer_id": 369885, "author": "Leon Timmermans", "author_id": 4727, "author_profile": "https://Stackoverflow.com/users/4727", "pm_score": 5, "selected": true, "text": "<p>The webserver needs a Unix domain socket to connect to the FastCGI application, but the socket can't be created. M...
2008/12/15
[ "https://Stackoverflow.com/questions/369850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44346/" ]
So I am following this guide: <http://technotes.1000lines.net/?p=23> and I am going through the steps. I have a VPN (slicehost.com) with Debian Etch, serving a website (static so far) with nginx. I used wget to download FastCGI and I did the usual make make install routine. So I guess since FastCGI can't normally run...
The webserver needs a Unix domain socket to connect to the FastCGI application, but the socket can't be created. Most likely the directory you want it to be in doesn't exist (because they are automatically created when you do a `bind`).
369,898
<p>In python, is there a difference between calling <code>clear()</code> and assigning <code>{}</code> to a dictionary? If yes, what is it? Example:<pre><code>d = {"stuff":"things"} d.clear() #this way d = {} #vs this way </code></pre></p>
[ { "answer_id": 369925, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 9, "selected": true, "text": "<p>If you have another variable also referring to the same dictionary, there is a big difference:</p>\n\n<pre><code>&gt;&g...
2008/12/15
[ "https://Stackoverflow.com/questions/369898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22724/" ]
In python, is there a difference between calling `clear()` and assigning `{}` to a dictionary? If yes, what is it? Example: ``` d = {"stuff":"things"} d.clear() #this way d = {} #vs this way ```
If you have another variable also referring to the same dictionary, there is a big difference: ``` >>> d = {"stuff": "things"} >>> d2 = d >>> d = {} >>> d2 {'stuff': 'things'} >>> d = {"stuff": "things"} >>> d2 = d >>> d.clear() >>> d2 {} ``` This is because assigning `d = {}` creates a new, empty dictionary and ass...
369,908
<p>I have a database which gets updated with 200-1000 new rows per day. Now, I'd like to have an SQL-statement which returns the data day-by-day, hour-by-hour so I can give a rough estimate for the current trend, i.e. how many rows will be added to the database today, just by taking a quick look at those historical gra...
[ { "answer_id": 369929, "author": "mat", "author_id": 42083, "author_profile": "https://Stackoverflow.com/users/42083", "pm_score": 3, "selected": false, "text": "<p>Hum, depending on your database engine, you'll get different results, but with PostgreSQL, I would do something like that :...
2008/12/15
[ "https://Stackoverflow.com/questions/369908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a database which gets updated with 200-1000 new rows per day. Now, I'd like to have an SQL-statement which returns the data day-by-day, hour-by-hour so I can give a rough estimate for the current trend, i.e. how many rows will be added to the database today, just by taking a quick look at those historical graphs...
Hum, depending on your database engine, you'll get different results, but with PostgreSQL, I would do something like that : ``` SELECT date_trunc('hour', table.date), count(table.id) FROM table GROUP BY date_trunc('hour', table.date) ORDER BY date_trunc('hour', table.date) ``` The [`date_trunc`](http://www.postgresq...
369,948
<p>I am working through some of the exercises in The C++ Programming Language by Bjarne Stroustrup. I am confused by problem 11 at the end of Chapter 12:</p> <blockquote>(*5) Design and implement a library for writing event-driven simulations. Hint: &lt;task.h&gt;. ... An object of class task should be able to save...
[ { "answer_id": 369970, "author": "krusty.ar", "author_id": 43981, "author_profile": "https://Stackoverflow.com/users/43981", "pm_score": 1, "selected": false, "text": "<p>(I'm not a C++ dev)</p>\n\n<p>Probably what it means is that you need to create a class Task (as in Event) that will ...
2008/12/15
[ "https://Stackoverflow.com/questions/369948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18091/" ]
I am working through some of the exercises in The C++ Programming Language by Bjarne Stroustrup. I am confused by problem 11 at the end of Chapter 12: > (\*5) Design and implement a library for writing event-driven simulations. Hint: <task.h>. ... An object of class task should be able to save its state and to have th...
> > Hint: <task.h>. > > > is a reference to an old cooperative multi-tasking library that shipped with [early versions of CFront](http://www.softwarepreservation.org/projects/c_plus_plus#release_e) (you can also download at that page). If you read the paper "[A Set of C++ Classes for Co-routine Style Programming]...
369,965
<p>I'm making list of items in categories, problem is that item can be in multiple categories. What is your best practice to store items in categories and how list all items within category and its child categories? I am using Zend Framework and MySQL to solve this issue.</p> <p>Thanks for your replies.</p> <p>Sorry ...
[ { "answer_id": 369980, "author": "Ian Varley", "author_id": 37539, "author_profile": "https://Stackoverflow.com/users/37539", "pm_score": 4, "selected": true, "text": "<p>So, you have a hierarchy in the categories, yes? Is it one level (category and child category) or any number (childre...
2008/12/15
[ "https://Stackoverflow.com/questions/369965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43182/" ]
I'm making list of items in categories, problem is that item can be in multiple categories. What is your best practice to store items in categories and how list all items within category and its child categories? I am using Zend Framework and MySQL to solve this issue. Thanks for your replies. Sorry for my English :)
So, you have a hierarchy in the categories, yes? Is it one level (category and child category) or any number (children can have children, etc)? That will impact what the solution is. Generally, you'd model something like this with a many-to-many relationship, like: ``` CREATE TABLE Item( item_id INT NOT NULL, i...
369,971
<p>Let's pretend I have the following xaml...</p> <p></p> <pre><code>&lt;UserControl.Resources&gt; &lt;local:ViewModel x:Name="viewModel" /&gt; &lt;local:LoadChildrenValueConverter x:Name="valueConverter" /&gt; &lt;/UserControl.Resources&gt; &lt;UserControl.DataContext&gt; &lt;Binding Source="{StaticReso...
[ { "answer_id": 370468, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 3, "selected": true, "text": "<p>Since you're using a ViewModel to sit between your actual model and your view, I wonder if it's easier just to impleme...
2008/12/15
[ "https://Stackoverflow.com/questions/369971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13181/" ]
Let's pretend I have the following xaml... ``` <UserControl.Resources> <local:ViewModel x:Name="viewModel" /> <local:LoadChildrenValueConverter x:Name="valueConverter" /> </UserControl.Resources> <UserControl.DataContext> <Binding Source="{StaticResource viewModel}" /> </UserControl.DataContext> <Grid x:...
Since you're using a ViewModel to sit between your actual model and your view, I wonder if it's easier just to implement the IValueConverter logic directly in there. Sort of like: ``` public class ViewModel { public ObservableCollection Root { get; set: } public ObservableCollection Children { get...
369,981
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/200545/attempted-sql-injection-attack-what-are-they-trying-to-do">Attempted SQL injection attack - what are they trying to do?</a> </p> </blockquote> <p>I have seen this SQL injection attempt on my site many ti...
[ { "answer_id": 369992, "author": "Jimmy", "author_id": 4435, "author_profile": "https://Stackoverflow.com/users/4435", "pm_score": 5, "selected": true, "text": "<p>Note: my first explanation was incorrect because I didn't actually read through the whole thing...</p>\n\n<p>here's what tha...
2008/12/15
[ "https://Stackoverflow.com/questions/369981", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10420/" ]
> > **Possible Duplicate:** > > [Attempted SQL injection attack - what are they trying to do?](https://stackoverflow.com/questions/200545/attempted-sql-injection-attack-what-are-they-trying-to-do) > > > I have seen this SQL injection attempt on my site many times in the last few months. ``` ';DECLARE @S CHAR...
Note: my first explanation was incorrect because I didn't actually read through the whole thing... here's what that translates to. It searches your database for text or varchar columns (b.xtype in 99,35,231,167) and then injects a javascript file into all text columns in your database. A bit more malicious than I firs...
369,990
<p>I find the standard Powershell display of errors (red text, multi-line display) a bit distracting. Is it possible to customize this?</p>
[ { "answer_id": 370052, "author": "Don Jones", "author_id": 40405, "author_profile": "https://Stackoverflow.com/users/40405", "pm_score": 5, "selected": true, "text": "<p>Yes and yes.</p>\n\n<p>You can use the built-in <code>$host</code> object if all you want to do is change the text col...
2008/12/15
[ "https://Stackoverflow.com/questions/369990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34438/" ]
I find the standard Powershell display of errors (red text, multi-line display) a bit distracting. Is it possible to customize this?
Yes and yes. You can use the built-in `$host` object if all you want to do is change the text color. However, you can't change the error message itself - that's hardcoded. What you could do is (a) suppress the error messages, and instead (b) trap the errors and display your own. Accomplish (a) by setting `$ErrorActi...
370,001
<p>The docs for <a href="http://msdn.microsoft.com/en-us/library/bb347013.aspx" rel="noreferrer">Dictionary.TryGetValue</a> say:</p> <blockquote> <p>When this method returns, [the value argument] contains the value associated with the specified key, if the key is found; otherwise, the <strong>default value for the t...
[ { "answer_id": 370006, "author": "Szymon Rozga", "author_id": 7583, "author_profile": "https://Stackoverflow.com/users/7583", "pm_score": 4, "selected": false, "text": "<pre><code>default(T);\n</code></pre>\n" }, { "answer_id": 370009, "author": "Nathan W", "author_id": 6...
2008/12/15
[ "https://Stackoverflow.com/questions/370001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
The docs for [Dictionary.TryGetValue](http://msdn.microsoft.com/en-us/library/bb347013.aspx) say: > > When this method returns, [the value argument] contains the value associated with the specified key, if the key is found; otherwise, the **default value for the type of the value parameter**. This parameter is passed...
You are looking for this: ``` default(T); ``` so: ``` public T Foo<T>(T Bar) { return default(T); } ```
370,004
<p>Using Java, I need to encode a Map&lt;String, String&gt; of name value pairs to store into a String, and be able to decode it again. These will be stored in a database column, and will probably usually be short and simple, so the common case should produce a simple nice looking line, but shouldn't corrupt the data...
[ { "answer_id": 370021, "author": "Uri", "author_id": 23072, "author_profile": "https://Stackoverflow.com/users/23072", "pm_score": 0, "selected": false, "text": "<p>Some additional context for the question would help.</p>\n\n<p>If you're going to be encoding and decoding at the entire-ma...
2008/12/15
[ "https://Stackoverflow.com/questions/370004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3093/" ]
Using Java, I need to encode a Map<String, String> of name value pairs to store into a String, and be able to decode it again. These will be stored in a database column, and will probably usually be short and simple, so the common case should produce a simple nice looking line, but shouldn't corrupt the data, even if i...
As @Uri says, additional context would be good. I think your primary concerns are less about the particular encoding scheme, as rolling your own for most encodings is pretty easy for a simple `Map<String, String>`. An interesting question is: what will this intermediate string encoding be used for? * if it's purely i...
370,013
<p>Using jQuery, how do I delete all rows in a table except the first? This is my first attempt at using index selectors. If I understand the examples correctly, the following should work:</p> <pre><code>$(some table selector).remove("tr:gt(0)"); </code></pre> <p>which I would read as "Wrap some table in a jQuery o...
[ { "answer_id": 370031, "author": "Strelok", "author_id": 2788, "author_profile": "https://Stackoverflow.com/users/2788", "pm_score": 10, "selected": true, "text": "<p>This should work: </p>\n\n<pre><code>$(document).ready(function() {\n $(\"someTableSelector\").find(\"tr:gt(0)\").re...
2008/12/15
[ "https://Stackoverflow.com/questions/370013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26671/" ]
Using jQuery, how do I delete all rows in a table except the first? This is my first attempt at using index selectors. If I understand the examples correctly, the following should work: ``` $(some table selector).remove("tr:gt(0)"); ``` which I would read as "Wrap some table in a jQuery object, then remove all 'tr' ...
This should work: ``` $(document).ready(function() { $("someTableSelector").find("tr:gt(0)").remove(); }); ```
370,024
<p>I have a SQL Server 2005 database that I'm trying to access as a limited user account, using Windows authentication. I've got BUILTIN\Users added as a database user (before I did so, I couldn't even open the database). I'm working under the assumption that everybody is supposed to have permissions for the "public"...
[ { "answer_id": 370127, "author": "Nathan Griffiths", "author_id": 46239, "author_profile": "https://Stackoverflow.com/users/46239", "pm_score": 0, "selected": false, "text": "<p>Assuming \"UserTest\" is a domain user account, connect as a member of the sysadmin role and run</p>\n\n<pre><...
2008/12/15
[ "https://Stackoverflow.com/questions/370024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26286/" ]
I have a SQL Server 2005 database that I'm trying to access as a limited user account, using Windows authentication. I've got BUILTIN\Users added as a database user (before I did so, I couldn't even open the database). I'm working under the assumption that everybody is supposed to have permissions for the "public" role...
You only need to have SELECT rights. In raw SQL (see the "script" icon/button in your dialogue box), it's `GRANT SELECT ON dbo.tblFoo to public`. This is the only permission needed to view the data, In this case, the error message explicitly mentions "deny". "DENY" is a right in itself, so it mentions it, If you had ...
370,030
<p>I have just start using git and i can't get it to remember my passphrase I'm using cmd.exe elevated and my git host is github and i have create a ssh key like that guide on github</p> <p>but i still get </p> <pre><code>*\subnus.mvc&gt;git push origin master Enter passphrase for key '/c/Users/Subnus/.ssh/id_rsa': ...
[ { "answer_id": 370050, "author": "Grant Limberg", "author_id": 27314, "author_profile": "https://Stackoverflow.com/users/27314", "pm_score": 3, "selected": false, "text": "<p>If you set a password for your key file, you'll always need to type in that password when connecting. If you cre...
2008/12/15
[ "https://Stackoverflow.com/questions/370030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31296/" ]
I have just start using git and i can't get it to remember my passphrase I'm using cmd.exe elevated and my git host is github and i have create a ssh key like that guide on github but i still get ``` *\subnus.mvc>git push origin master Enter passphrase for key '/c/Users/Subnus/.ssh/id_rsa': ```
I realize that this question is coming up on two years old, but I had the same issue and several answers here did not completely answer the question for me. Here are three step-by-step solutions, depending on whether you use TortoiseGit in addition to msysgit or not. **First solution** Assumes Windows, msysgit, and Pu...
370,047
<p>Or more generally, how do I remove an item from a colon-separated list in a Bash environment variable?</p> <p>I thought I had seen a simple way to do this years ago, using the more advanced forms of Bash variable expansion, but if so I've lost track of it. A quick search of Google turned up surprisingly few releva...
[ { "answer_id": 370056, "author": "mat", "author_id": 42083, "author_profile": "https://Stackoverflow.com/users/42083", "pm_score": 2, "selected": false, "text": "<p>Well, in bash, as it supports regular expression, I would simply do :</p>\n\n<pre><code>PATH=${PATH/:\\/home\\/user\\/bin/}...
2008/12/15
[ "https://Stackoverflow.com/questions/370047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46387/" ]
Or more generally, how do I remove an item from a colon-separated list in a Bash environment variable? I thought I had seen a simple way to do this years ago, using the more advanced forms of Bash variable expansion, but if so I've lost track of it. A quick search of Google turned up surprisingly few relevant results ...
A minute with awk: ``` # Strip all paths with SDE in them. # export PATH=`echo ${PATH} | awk -v RS=: -v ORS=: '/SDE/ {next} {print}'` ``` ### Edit: It response to comments below: ``` $ export a="/a/b/c/d/e:/a/b/c/d/g/k/i:/a/b/c/d/f:/a/b/c/g:/a/b/c/d/g/i" $ echo ${a} /a/b/c/d/e:/a/b/c/d/f:/a/b/c/g:/a/b/c/d/g/i ## R...
370,055
<p>How would one change the view on the screen programmatically in an iPhone app?</p> <p>I've been able to create navigation view's and programmatically push/pop them to produce this behaviour, but if I wanted to simply change the current view (not using a UINavigation controller object), what is the neatest way to ac...
[ { "answer_id": 370143, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>How about pushing a generic UIView into the UINavigationController?</p>\n\n<p>When you want one particular view shown, simp...
2008/12/15
[ "https://Stackoverflow.com/questions/370055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40175/" ]
How would one change the view on the screen programmatically in an iPhone app? I've been able to create navigation view's and programmatically push/pop them to produce this behaviour, but if I wanted to simply change the current view (not using a UINavigation controller object), what is the neatest way to achieve this...
I use `presentModalViewController:animated:` to bring up a settings view from my main window's `UIViewController` and then when the user presses "done" in the settings view I call `dismissModalViewControllerAnimated:` from the settings view (reaching back to the parent view) like this: ``` [[self parentViewController]...
370,075
<p>Is there a script to display a simple world clock (time in various places around the world) on a *nix terminal?</p> <p>I was thinking of writing a quick Python script, but I have a feeling that's gonna be more work than I think (e.g. due to config and output format) - not to mention reinventing the wheel...</p>
[ { "answer_id": 370100, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>If you do still want to write it in Python, consider Pytz:</p>\n\n<p><a href=\"http://pytz.sourceforge.net/\" rel=\"nofollo...
2008/12/15
[ "https://Stackoverflow.com/questions/370075", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there a script to display a simple world clock (time in various places around the world) on a \*nix terminal? I was thinking of writing a quick Python script, but I have a feeling that's gonna be more work than I think (e.g. due to config and output format) - not to mention reinventing the wheel...
I have this bourne shell script: ``` #!/bin/sh PT=`env TZ=US/Pacific date` CT=`env TZ=US/Central date` AT=`env TZ=Australia/Melbourne date` echo "Santa Clara $PT" echo "Central $CT" echo "Melbourne $AT" ```
370,079
<p>I'm trying to write some C# code that calls a method from an unmanaged DLL. The prototype for the function in the dll is:</p> <pre><code>extern "C" __declspec(dllexport) char *foo(void); </code></pre> <p>In C#, I first used:</p> <pre><code>[DllImport(_dllLocation)] public static extern string foo(); </code></pre...
[ { "answer_id": 370093, "author": "Strelok", "author_id": 2788, "author_profile": "https://Stackoverflow.com/users/2788", "pm_score": 5, "selected": false, "text": "<p>You can use the Marshal.PtrToStringAuto method.</p>\n\n<pre><code>IntPtr ptr = foo();\nstring str = Marshal.PtrToStringAu...
2008/12/15
[ "https://Stackoverflow.com/questions/370079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5959/" ]
I'm trying to write some C# code that calls a method from an unmanaged DLL. The prototype for the function in the dll is: ``` extern "C" __declspec(dllexport) char *foo(void); ``` In C#, I first used: ``` [DllImport(_dllLocation)] public static extern string foo(); ``` It seems to work on the surface, but I'm get...
You must return this as an IntPtr. Returning a System.String type from a PInvoke function requires great care. The CLR must transfer the memory from the native representation into the managed one. This is an easy and predictable operation. The problem though comes with what to do with the native memory that was return...
370,086
<p>I'm loading the XML in, and I'm able to read the XML nodes into text fields in my flash. It is also loading the URL, but the last one from the loop. It's not loading the one that I click on. I tried using <code>event.target</code>, but that is not working. I'm pretty close to figuring it out, I'm just not sure where...
[ { "answer_id": 372090, "author": "jrutter", "author_id": 28454, "author_profile": "https://Stackoverflow.com/users/28454", "pm_score": 0, "selected": false, "text": "<p>I found a solution to my problem!</p>\n\n<p>My solution was to create an array which stored all the URLs by <code>track...
2008/12/15
[ "https://Stackoverflow.com/questions/370086", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28454/" ]
I'm loading the XML in, and I'm able to read the XML nodes into text fields in my flash. It is also loading the URL, but the last one from the loop. It's not loading the one that I click on. I tried using `event.target`, but that is not working. I'm pretty close to figuring it out, I'm just not sure where to look. ```...
It seems to me that you have made this hard on yourself. I may be incorrect as it is hard to traverse through the code you have presented. The concept of an XML playlist and clicking a display object to play sounds is quite easy and I will demonstrate. The XML ``` <?xml version="1.0" encoding="utf-8"?> <xml> <ite...
370,087
<p>I currently have an INSERT TRIGGER which in Oracle 10g runs a custom defined function that generates a funky alpha-numeric code that is used as part of the insert.</p> <p>I really need to make sure that the function (or even trigger) is thread safe so that if two users activate the trigger at once, the function use...
[ { "answer_id": 370107, "author": "BQ.", "author_id": 4632, "author_profile": "https://Stackoverflow.com/users/4632", "pm_score": 3, "selected": false, "text": "<p>No need to work out the exclusivity here. Oracle does that by managing your transactions.</p>\n\n<p>The key is that each invo...
2008/12/15
[ "https://Stackoverflow.com/questions/370087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26310/" ]
I currently have an INSERT TRIGGER which in Oracle 10g runs a custom defined function that generates a funky alpha-numeric code that is used as part of the insert. I really need to make sure that the function (or even trigger) is thread safe so that if two users activate the trigger at once, the function used within t...
No need to work out the exclusivity here. Oracle does that by managing your transactions. The key is that each invocation of your "custom defined function" needs to return a unique code. That means NOT using the system date/time, but something else to ensure uniqueness. I recommend this: ``` select sys_guid() from ...
370,108
<p>I'd love to use PHP variables in my CSS files but I don't want to load up the whole Symfony stack for each file load. Any one have any best practices and/or plugins to manage their CSS files in Symfony?</p>
[ { "answer_id": 370290, "author": "thrashr888", "author_id": 46443, "author_profile": "https://Stackoverflow.com/users/46443", "pm_score": 2, "selected": false, "text": "<p>Here's one good Plugin that tries to manage and/or combine your assets:</p>\n\n<p><a href=\"http://www.symfony-proje...
2008/12/15
[ "https://Stackoverflow.com/questions/370108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46443/" ]
I'd love to use PHP variables in my CSS files but I don't want to load up the whole Symfony stack for each file load. Any one have any best practices and/or plugins to manage their CSS files in Symfony?
but you dont need full symfony stack for that ( except if you need some internal symfony state / variable ). You just use ``` <link rel="stylesheet" type="text/css" media="screen" href="/css/mycss.php" /> ``` and then you can use php inside your css. you could add appropriate headers (text/css) with header in php.
370,113
<pre><code>SaveFileDialog savefileDialog1 = new SaveFileDialog(); DialogResult result = savefileDialog1.ShowDialog(); switch(result == DialogResult.OK) case true: //do something case false: MessageBox.Show("are you sure?","",MessageBoxButtons.YesNo,MessageBoxIcon.Question); </code></pre> <p>Ho...
[ { "answer_id": 370132, "author": "lubos hasko", "author_id": 275, "author_profile": "https://Stackoverflow.com/users/275", "pm_score": 1, "selected": false, "text": "<p>You can't do that with <code>SaveFileDialog</code> class.</p>\n" }, { "answer_id": 370157, "author": "Lenny...
2008/12/15
[ "https://Stackoverflow.com/questions/370113", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42564/" ]
``` SaveFileDialog savefileDialog1 = new SaveFileDialog(); DialogResult result = savefileDialog1.ShowDialog(); switch(result == DialogResult.OK) case true: //do something case false: MessageBox.Show("are you sure?","",MessageBoxButtons.YesNo,MessageBoxIcon.Question); ``` How to show the messa...
If the reason for needing the message box on Cancel of the File Save dialogue is because you're shutting things down with unsaved changes, then I suggest putting the call to the File Save dialogue in a loop that keeps going until a flag is set to stop the loop and call the message box if you don't get OK as the result....
370,114
<p>How would one go about adding a submenu item to the windows explorer context menu (like for example 7-Zip does) for a Java application?</p>
[ { "answer_id": 370130, "author": "Jayden", "author_id": 44873, "author_profile": "https://Stackoverflow.com/users/44873", "pm_score": 5, "selected": true, "text": "<p>I am aware of two ways to do it. The fancy way is to write a windows shell extension, which is how powerarchiver, winzip ...
2008/12/15
[ "https://Stackoverflow.com/questions/370114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14955/" ]
How would one go about adding a submenu item to the windows explorer context menu (like for example 7-Zip does) for a Java application?
I am aware of two ways to do it. The fancy way is to write a windows shell extension, which is how powerarchiver, winzip etc do it I believe (this involves running code to determine what the context menu items will be dependent on the file chosen). The simple way, for simple functionality, is you can add an entry in t...
370,124
<p>Are there any pre-written component-like Silverlight web widgets like there are for Flash? </p> <p>Flash examples:<br> <a href="http://musicplayer.sourceforge.net/" rel="nofollow noreferrer">XSPF Web Music Player</a><br> <a href="http://wpaudioplayer.com/" rel="nofollow noreferrer">WordPress Audio Player</a><br> <...
[ { "answer_id": 370130, "author": "Jayden", "author_id": 44873, "author_profile": "https://Stackoverflow.com/users/44873", "pm_score": 5, "selected": true, "text": "<p>I am aware of two ways to do it. The fancy way is to write a windows shell extension, which is how powerarchiver, winzip ...
2008/12/15
[ "https://Stackoverflow.com/questions/370124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36590/" ]
Are there any pre-written component-like Silverlight web widgets like there are for Flash? Flash examples: [XSPF Web Music Player](http://musicplayer.sourceforge.net/) [WordPress Audio Player](http://wpaudioplayer.com/) [FLAMPlayer](http://www.flamplayer.com/flamplayer_demo/pages/demo.html) [Aflax](http:/...
I am aware of two ways to do it. The fancy way is to write a windows shell extension, which is how powerarchiver, winzip etc do it I believe (this involves running code to determine what the context menu items will be dependent on the file chosen). The simple way, for simple functionality, is you can add an entry in t...
370,165
<p>I am having trouble retrieving results from my datareader in visual studio 2008. I have several stored Procs in the same database. I am able to retrieve values from those that dont receive input parameters. However, when i use the executreReader() method on a stored proc with input parameters i get an empty dataread...
[ { "answer_id": 370177, "author": "Kevin Tighe", "author_id": 39461, "author_profile": "https://Stackoverflow.com/users/39461", "pm_score": 0, "selected": false, "text": "<p>When do you get the \"IEnumerable returned no results\" error? Could you show an example of how you're accessing t...
2008/12/16
[ "https://Stackoverflow.com/questions/370165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am having trouble retrieving results from my datareader in visual studio 2008. I have several stored Procs in the same database. I am able to retrieve values from those that dont receive input parameters. However, when i use the executreReader() method on a stored proc with input parameters i get an empty datareader....
Are you ever adding the parameters to the SqlCommand's Parameter collection? You mentioned that the ones that aren't working are the ones that take input params, yet in your code you don't have anything like this: ``` cmdPopulateFilterDropDowns.Parameters.AddWithValue(...); ```
370,174
<p>I've got several function where I need to do a one-to-many join, using count(), group_by, and order_by. I'm using the sqlalchemy.select function to produce a query that will return me a set of id's, which I then iterate over to do an ORM select on the individual records. What I'm wondering is if there is a way to ...
[ { "answer_id": 370654, "author": "Charles Duffy", "author_id": 14122, "author_profile": "https://Stackoverflow.com/users/14122", "pm_score": 1, "selected": false, "text": "<p>What you're trying to do maps directly to a SQLAlchemy join between a subquery [made from your current select cal...
2008/12/16
[ "https://Stackoverflow.com/questions/370174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45076/" ]
I've got several function where I need to do a one-to-many join, using count(), group\_by, and order\_by. I'm using the sqlalchemy.select function to produce a query that will return me a set of id's, which I then iterate over to do an ORM select on the individual records. What I'm wondering is if there is a way to do ...
I've found the best way to do this. Simply supply a `from_statement` instead of a `filter_by` or some such. Like so: ``` meta.Session.query(Location).from_statement(query).all() ```
370,186
<p>This is on the Mac:</p> <p>If I have two filenames /foo/foo and /foo/FOO they may refer to the same file or the may be different files depending on the file system. How do I figure out if they are both pointing to the same file? And if they are, how do I get the correct representation of the filename?</p> <p>My pr...
[ { "answer_id": 370191, "author": "Grant Limberg", "author_id": 27314, "author_profile": "https://Stackoverflow.com/users/27314", "pm_score": -1, "selected": false, "text": "<p>AFAIK, by default the filesystem in Mac OS X is Case Insensitive, thus the case of the link or filename shouldn'...
2008/12/16
[ "https://Stackoverflow.com/questions/370186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39138/" ]
This is on the Mac: If I have two filenames /foo/foo and /foo/FOO they may refer to the same file or the may be different files depending on the file system. How do I figure out if they are both pointing to the same file? And if they are, how do I get the correct representation of the filename? My problem is caused b...
There's really a couple of different parts to your question. By my reading, you want: > > **1** a way to tell if two different paths are the same on-disk file > > > **2** a canonical name for the file on disk, with the proper casing > > > There's a third issue that gets mixed in, as well, having to do with [Dis...
370,195
<p>I know that the compiler will sometimes initialize memory with certain patterns such as <code>0xCD</code> and <code>0xDD</code>. What I want to know is <strong>when</strong> and <strong>why</strong> this happens.</p> <p><H2>When</H2></p> <p>Is this specific to the compiler used?</p> <p>Do <code>malloc/new</code>...
[ { "answer_id": 370217, "author": "Martin Beckett", "author_id": 10897, "author_profile": "https://Stackoverflow.com/users/10897", "pm_score": 3, "selected": false, "text": "<p>It's compiler and OS specific, Visual Studio sets different kinds of memory to different values so that in the d...
2008/12/16
[ "https://Stackoverflow.com/questions/370195", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22489/" ]
I know that the compiler will sometimes initialize memory with certain patterns such as `0xCD` and `0xDD`. What I want to know is **when** and **why** this happens. When ---- Is this specific to the compiler used? Do `malloc/new` and `free/delete` work in the same way with regard to this? Is it platform specific? ...
A quick summary of what Microsoft's compilers use for various bits of unowned/uninitialized memory when compiled for debug mode (support may vary by compiler version): ```none Value Name Description ------ -------- ------------------------- 0xCD Clean Memory Allocated memory via malloc o...
370,202
<p>I'm using Grails to send a large number of HTML emails. I use the SimpleTemplateEngine to create my email bodies in this fashion:</p> <pre><code>def ccIdToEmailMap = [:] def emailTemplateFile = Utilities.retrieveFile("email${File.separator}emailTemplate.gtpl") def engine = new SimpleTemplateEngine() def clientCont...
[ { "answer_id": 370727, "author": "Siegfried Puchbauer", "author_id": 46301, "author_profile": "https://Stackoverflow.com/users/46301", "pm_score": 1, "selected": false, "text": "<p>Sounds like a synchronization issue. As a first step, you should create the template outside of the loop. S...
2008/12/16
[ "https://Stackoverflow.com/questions/370202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21832/" ]
I'm using Grails to send a large number of HTML emails. I use the SimpleTemplateEngine to create my email bodies in this fashion: ``` def ccIdToEmailMap = [:] def emailTemplateFile = Utilities.retrieveFile("email${File.separator}emailTemplate.gtpl") def engine = new SimpleTemplateEngine() def clientContacts = ClientCo...
It appears that there was an issue with lazy loading my client contact owners in the template. Instead of expecting the owners to be loaded (inefficiently), while SimpleTemplateEngine is making the email body, I eagerly fetch the owners before binding/making the body. My above code now looks like this: ``` def em...
370,211
<p>I wanna stop the reading of my text input file when the word "synonyms" appears. I'm using ifstream and I don't know how to break the loop. I tried using a stringstream "synonyms" but it ended up junking my bst. I included the complete project files below in case you wanna avoid typing. </p> <p>Important part:</p>...
[ { "answer_id": 370225, "author": "SoapBox", "author_id": 36384, "author_profile": "https://Stackoverflow.com/users/36384", "pm_score": 2, "selected": false, "text": "<p>You should make an operator == on WordInfo to compare it to a string, then you can just this in the reading loop:</p>\n...
2008/12/16
[ "https://Stackoverflow.com/questions/370211", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45963/" ]
I wanna stop the reading of my text input file when the word "synonyms" appears. I'm using ifstream and I don't know how to break the loop. I tried using a stringstream "synonyms" but it ended up junking my bst. I included the complete project files below in case you wanna avoid typing. Important part: ``` for(;;) ...
You can do it like ``` /* here, it stops when reading "synonyms" or when failing to extract a word. */ while(inStream >> word && word != "synonym") { wordTree.insert(word); } wordTree.graph(cout); ``` Note that when it fails to read a sequence of non-whitespace characters, it sets the fail-bit of the stream. inS...
370,215
<p>I am trying to process an uploaded file in a Perl program, using CGI::Application. I need to get the content type of the uploaded file. From what I read, the following should work, but it doesn't for me:</p> <pre><code>my $filename = $q-&gt;param("file"); my $contenttype = $q-&gt;uploadInfo($filename)-&gt;{'Conte...
[ { "answer_id": 370342, "author": "ysth", "author_id": 17389, "author_profile": "https://Stackoverflow.com/users/17389", "pm_score": 4, "selected": true, "text": "<p>You trust whatever did the upload to give you a good content type? I just save the uploaded file to disk and do:</p>\n\n<p...
2008/12/16
[ "https://Stackoverflow.com/questions/370215", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4257/" ]
I am trying to process an uploaded file in a Perl program, using CGI::Application. I need to get the content type of the uploaded file. From what I read, the following should work, but it doesn't for me: ``` my $filename = $q->param("file"); my $contenttype = $q->uploadInfo($filename)->{'Content-Type'}; ``` As it tu...
You trust whatever did the upload to give you a good content type? I just save the uploaded file to disk and do: ``` chomp(my $mime_type = qx!file -i $uploaded!); $mime_type =~ s/^.*?: //; $mime_type =~ s/;.*//; ``` though you could use File::Type, File::MMagic, or File::MimeInfo instead.
370,218
<p>I'm trying to setup a second ruby install in my home directory (a different version of ruby for testing). I've compiled ruby into <code>~/bin/</code> and everything is working until I try to install rubygems.</p> <p>I have <code>GEM_HOME</code> set to <code>~/gems</code> directory and <code>GEM_PATH</code> set to t...
[ { "answer_id": 370355, "author": "Gordon Wilson", "author_id": 23071, "author_profile": "https://Stackoverflow.com/users/23071", "pm_score": 3, "selected": true, "text": "<p>In addition to setting <code>GEM_HOME</code> you need to run <code>config</code> with your path. Here are the ste...
2008/12/16
[ "https://Stackoverflow.com/questions/370218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46505/" ]
I'm trying to setup a second ruby install in my home directory (a different version of ruby for testing). I've compiled ruby into `~/bin/` and everything is working until I try to install rubygems. I have `GEM_HOME` set to `~/gems` directory and `GEM_PATH` set to the same. Then I try to install rubygems with ``` ~/bi...
In addition to setting `GEM_HOME` you need to run `config` with your path. Here are the steps from [rubygems.org](http://www.rubygems.org/read/chapter/3#page83). ``` $ export GEM_HOME=/home/mygemrepository $ ruby setup.rb config --prefix=/home/mystuff $ ruby setup.rb setup $ ruby setup.rb install ```
370,222
<p>How can instantiated classes <strong>access the Document class?</strong></p> <p>Even after I <strong>name the Document class</strong> using the Properties bar in Flash, attempting to access it from other classes usually fails, saying <em>"attempting to access an undefined property...</em></p> <p>One solution is al...
[ { "answer_id": 371625, "author": "Matt W", "author_id": 32396, "author_profile": "https://Stackoverflow.com/users/32396", "pm_score": 2, "selected": false, "text": "<p>The document class is not inherently a globally accessible object. If you want to call methods that are in the document ...
2008/12/16
[ "https://Stackoverflow.com/questions/370222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41021/" ]
How can instantiated classes **access the Document class?** Even after I **name the Document class** using the Properties bar in Flash, attempting to access it from other classes usually fails, saying *"attempting to access an undefined property...* One solution is always **casting the Document class to itself!** eg....
You can use a singleton for your document class (`Main`, in your example), which allows you to access the instance from anywhere. ``` public class Main extends Sprite { private static var _instance:Main; public static function get instance():Main { return _instance; } public function Main() { _ins...
370,258
<p>I've been reading about the <a href="http://en.wikipedia.org/wiki/Open/closed_principle" rel="noreferrer">OCP principle</a> and how to use the strategy pattern to accomplish this.</p> <p>I was going to try and explain this to a couple of people, but the only example I can think of is using different validation class...
[ { "answer_id": 370270, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": 7, "selected": false, "text": "<p>What about this: </p>\n\n<p>You have to encrypt a file. </p>\n\n<p>For small files, you can use \"in memory\" strategy...
2008/12/16
[ "https://Stackoverflow.com/questions/370258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've been reading about the [OCP principle](http://en.wikipedia.org/wiki/Open/closed_principle) and how to use the strategy pattern to accomplish this. I was going to try and explain this to a couple of people, but the only example I can think of is using different validation classes based on what status an "order" is...
What about this: You have to encrypt a file. For small files, you can use "in memory" strategy, where the complete file is read and kept in memory ( let's say for files < 1 gb ) For large files, you can use another strategy, where parts of the file are read in memory and partial encrypted results are stored in tm...
370,267
<p>This may seem like a stupid question, so here goes:</p> <p>Other than parsing the string of FileInfo.FullPath for the drive letter to then use DriveInfo("c") etc to see if there is enough space to write this file. Is there a way to get the drive letter from FileInfo?</p>
[ { "answer_id": 370279, "author": "Joel Martinez", "author_id": 5416, "author_profile": "https://Stackoverflow.com/users/5416", "pm_score": -1, "selected": false, "text": "<p>Nothing wrong with a little string parsing :-)</p>\n\n<pre><code>FullPath.Substring(0,1);\n</code></pre>\n" }, ...
2008/12/16
[ "https://Stackoverflow.com/questions/370267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28717/" ]
This may seem like a stupid question, so here goes: Other than parsing the string of FileInfo.FullPath for the drive letter to then use DriveInfo("c") etc to see if there is enough space to write this file. Is there a way to get the drive letter from FileInfo?
``` FileInfo f = new FileInfo(path); string drive = Path.GetPathRoot(f.FullName); ``` This will return "C:\". That's really the only other way.
370,268
<p>Is this</p> <pre><code>... T1 join T2 using(ID) where T2.VALUE=42 ... </code></pre> <p>the same as</p> <pre><code>... T1 join T2 on(T1.ID=T2.ID) where T2.VALUE=42 ... </code></pre> <p>for all types of joins?</p> <p>My understanding of <code>using(ID)</code> is that it's just shorthand for <code>on(T1.ID=T2.ID)<...
[ { "answer_id": 370276, "author": "Federico A. Ramponi", "author_id": 18770, "author_profile": "https://Stackoverflow.com/users/18770", "pm_score": 1, "selected": false, "text": "<p>Your interpretation seems correct. <a href=\"http://www.xaprb.com/blog/2006/11/28/how-to-write-sql-join-cla...
2008/12/16
[ "https://Stackoverflow.com/questions/370268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21838/" ]
Is this ``` ... T1 join T2 using(ID) where T2.VALUE=42 ... ``` the same as ``` ... T1 join T2 on(T1.ID=T2.ID) where T2.VALUE=42 ... ``` for all types of joins? My understanding of `using(ID)` is that it's just shorthand for `on(T1.ID=T2.ID)`. Is this true? Now for another question: Is the above the same as ``...
I don't use the USING syntax, since 1. most of my joins aren't suited to it (not the same fieldname that is being matched, and/or multiple matches in the join) and 2. it isn't immediately obvious what it translates to in the case with more than two tables ie assuming 3 tables with 'id' and 'id\_2' columns, does ```...
370,273
<p>I have a whole bunch of POV-RAY files from a molecular dynamics simulation with the general name "frameXX.pov" where "XX" is the number of the frame. I want to render them all but I have like 500 so I really don't wanna do it by hand. I'm sure there is a way to do this from the command line or a batch file...what w...
[ { "answer_id": 370278, "author": "Pyrolistical", "author_id": 21838, "author_profile": "https://Stackoverflow.com/users/21838", "pm_score": 2, "selected": false, "text": "<p>Its directly supported apparently:</p>\n\n<p><a href=\"http://news.povray.org/povray.animations/message/%3C4732442...
2008/12/16
[ "https://Stackoverflow.com/questions/370273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41718/" ]
I have a whole bunch of POV-RAY files from a molecular dynamics simulation with the general name "frameXX.pov" where "XX" is the number of the frame. I want to render them all but I have like 500 so I really don't wanna do it by hand. I'm sure there is a way to do this from the command line or a batch file...what would...
Since your question is 2 months old, I presume your problem will be solved by now. But I want to explain for other SOers interested in the matter. You can run a POV-Ray script a number of times in a parameterized loop. A typical way to describe the loop parameters is by writing a .ini-file. ``` Input_File_Name=somegr...
370,283
<p>I noticed C++ will not compile the following:</p> <pre><code>class No_Good { static double const d = 1.0; }; </code></pre> <p>However it will happily allow a variation where the double is changed to an int, unsigned, or any integral type:</p> <pre><code>class Happy_Times { static unsigned const u = 1; }; </co...
[ { "answer_id": 370293, "author": "Mark Ransom", "author_id": 5987, "author_profile": "https://Stackoverflow.com/users/5987", "pm_score": 2, "selected": false, "text": "<p>I don't know why it would treat a double different from an int. I thought I had used that form before. Here's an al...
2008/12/16
[ "https://Stackoverflow.com/questions/370283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29703/" ]
I noticed C++ will not compile the following: ``` class No_Good { static double const d = 1.0; }; ``` However it will happily allow a variation where the double is changed to an int, unsigned, or any integral type: ``` class Happy_Times { static unsigned const u = 1; }; ``` My solution was to alter it to read...
The problem is that with an integer, the compiler *usually* doesn't have to ever create a memory address for the constant. It doesn't exist at runtime, and every use of it gets inlined into the surrounding code. It can still decide to give it a memory location - if its address is ever taken (or if it's passed by const ...
370,286
<p>The code below pretty much sums up what I want to achieve. </p> <p>We have a solution which comprises many different projects however we have a need to be able to call methods in projects from projects which are not referenced (would cause circular reference).</p> <p>I have posted previous questions and the code b...
[ { "answer_id": 370302, "author": "Andrew Kennan", "author_id": 22506, "author_profile": "https://Stackoverflow.com/users/22506", "pm_score": 1, "selected": false, "text": "<p>You need the Link project to provide a way of registering and constructing concrete implementations of the interf...
2008/12/16
[ "https://Stackoverflow.com/questions/370286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The code below pretty much sums up what I want to achieve. We have a solution which comprises many different projects however we have a need to be able to call methods in projects from projects which are not referenced (would cause circular reference). I have posted previous questions and the code below is pretty mu...
I used `Activator.CreateInstance` to do this. You load the assembly from a path and then create an instance of the class. For example, you could use this to load gadgets assemblies in a host application where the host doesnt know about the gadgets at compile time. Sample Pseudo Code (no error handling) Create an inte...
370,291
<p>I'm deserializing a class called <code>Method</code> using .NET Serialization. <code>Method</code> contains a list of objects implementing <code>IAction</code>. I originally used the <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlincludeattribute.aspx" rel="nofollow noreferrer"><code>[X...
[ { "answer_id": 370395, "author": "David Norman", "author_id": 34502, "author_profile": "https://Stackoverflow.com/users/34502", "pm_score": 4, "selected": true, "text": "<p>XmlSerializer has a constructor that accepts an array of types that will be accepted when deserializing:</p>\n\n<pr...
2008/12/16
[ "https://Stackoverflow.com/questions/370291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/165305/" ]
I'm deserializing a class called `Method` using .NET Serialization. `Method` contains a list of objects implementing `IAction`. I originally used the [`[XmlInclude]`](http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlincludeattribute.aspx) attribute to specify all classes which implement `IAction`. ...
XmlSerializer has a constructor that accepts an array of types that will be accepted when deserializing: ``` public XmlSerializer( Type type, Type[] extraTypes ); ``` You should be able to pass your array of assemblyTypes as the second argument.
370,292
<p>Is it worth changing my code to be "more portable" and able to deal with the horror of magic quotes, or should I just make sure that it's always off via a .htaccess file?</p> <pre><code>if (get_magic_quotes_gpc()) { $var = stripslashes($_POST['var']); } else { $var = $_POST['var']; } </code></pre> <p>Versu...
[ { "answer_id": 370297, "author": "Eran Galperin", "author_id": 10585, "author_profile": "https://Stackoverflow.com/users/10585", "pm_score": 2, "selected": false, "text": "<p>I would make sure it's off if that's possible (requires access to .htaccess or apache configuration). It's better...
2008/12/16
[ "https://Stackoverflow.com/questions/370292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
Is it worth changing my code to be "more portable" and able to deal with the horror of magic quotes, or should I just make sure that it's always off via a .htaccess file? ``` if (get_magic_quotes_gpc()) { $var = stripslashes($_POST['var']); } else { $var = $_POST['var']; } ``` Versus ``` php_flag magic_quot...
Don't accommodate both situations. Two code paths = twice the headaches, plus there's a good chance you'll slip up and forget to handle both situations somewhere. I used to check if magic quotes were on or off, and if they were on, undo their magic (as others in the thread have suggested). The problem with this is, yo...
370,310
<p>I have a JPanel full of JTextFields...</p> <pre><code>for (int i=0; i&lt;maxPoints; i++) { JTextField textField = new JTextField(); points.add(textField); } </code></pre> <p>How do I later get the JTextFields in that JPanel? Like if I want their values with </p> <pre><code>TextField.getText(); </code></p...
[ { "answer_id": 370318, "author": "Uri", "author_id": 23072, "author_profile": "https://Stackoverflow.com/users/23072", "pm_score": 4, "selected": false, "text": "<p>Every JPanel in Java is also an AWT container. Thus, you should be able to use getComponents to get the array of contained ...
2008/12/16
[ "https://Stackoverflow.com/questions/370310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51518/" ]
I have a JPanel full of JTextFields... ``` for (int i=0; i<maxPoints; i++) { JTextField textField = new JTextField(); points.add(textField); } ``` How do I later get the JTextFields in that JPanel? Like if I want their values with ``` TextField.getText(); ``` Thanks
Well bear in mind they didn't get there by them selves ( I think a read some questions about dynamically creating these panels at runtime ) In the answers posted there, someone said you should kept reference to those textfields in an array. That's exactly what you need here: ``` List<JTextField> list = new ArrayList...
370,322
<p>How can I remove the very first "1" from any string if that string starts with a "1"?</p> <pre><code>"1hello world" =&gt; "hello world" "112345" =&gt; "12345" </code></pre> <p>I'm thinking of doing</p> <pre><code>string.sub!('1', '') if string =~ /^1/ </code></pre> <p>but I' wondering there's a better way. Thank...
[ { "answer_id": 370331, "author": "Zach Langley", "author_id": 45230, "author_profile": "https://Stackoverflow.com/users/45230", "pm_score": 7, "selected": true, "text": "<p>Why not just include the regex in the <code>sub!</code> method?</p>\n\n<pre><code>string.sub!(/^1/, '')\n</code></p...
2008/12/16
[ "https://Stackoverflow.com/questions/370322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How can I remove the very first "1" from any string if that string starts with a "1"? ``` "1hello world" => "hello world" "112345" => "12345" ``` I'm thinking of doing ``` string.sub!('1', '') if string =~ /^1/ ``` but I' wondering there's a better way. Thanks!
Why not just include the regex in the `sub!` method? ``` string.sub!(/^1/, '') ```
370,340
<p>Say I wanted to have a project, and one-to-many with to-do items, and wanted to re-order the to-do items arbitrarily? </p> <p>In the past, I've added a numbered order field, and when someone wants to change the order, had to update all the items with their new order numbers. This is probably the worst approach, si...
[ { "answer_id": 370349, "author": "dkretz", "author_id": 31641, "author_profile": "https://Stackoverflow.com/users/31641", "pm_score": 1, "selected": false, "text": "<p>I've run into this so many times that I've settled on managing these dynamically in the BL or UI, and then just persisti...
2008/12/16
[ "https://Stackoverflow.com/questions/370340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35922/" ]
Say I wanted to have a project, and one-to-many with to-do items, and wanted to re-order the to-do items arbitrarily? In the past, I've added a numbered order field, and when someone wants to change the order, had to update all the items with their new order numbers. This is probably the worst approach, since it's no...
I hate this problem ... and I run into it all the time. For my most recent Django site we had a Newsletter which contained N Articles and, of course, order was important. I assigned the default order as ascending Article.id, but this failed if Articles were entered in something other than "correct" order. On the News...
370,357
<p>The following code works as expected in both Python 2.5 and 3.0:</p> <pre><code>a, b, c = (1, 2, 3) print(a, b, c) def test(): print(a) print(b) print(c) # (A) #c+=1 # (B) test() </code></pre> <p>However, when I uncomment line <strong>(B)</strong>, I get an <code>UnboundLocalError: 'c' not...
[ { "answer_id": 370363, "author": "recursive", "author_id": 44743, "author_profile": "https://Stackoverflow.com/users/44743", "pm_score": 9, "selected": true, "text": "<p>Python treats variables in functions differently depending on whether you assign values to them from inside or outside...
2008/12/16
[ "https://Stackoverflow.com/questions/370357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46521/" ]
The following code works as expected in both Python 2.5 and 3.0: ``` a, b, c = (1, 2, 3) print(a, b, c) def test(): print(a) print(b) print(c) # (A) #c+=1 # (B) test() ``` However, when I uncomment line **(B)**, I get an `UnboundLocalError: 'c' not assigned` at line **(A)**. The values of ...
Python treats variables in functions differently depending on whether you assign values to them from inside or outside the function. If a variable is assigned within a function, it is treated by default as a local variable. Therefore, when you uncomment the line, you are trying to reference the local variable `c` befor...
370,359
<p>I'm creating HTML with a loop that has a column for Action. That column is a Hyperlink that when the user clicks calls a JavaScript function and passes the parameters...</p> <p>example:</p> <pre><code>&lt;a href="#" OnClick="DoAction(1,'Jose');" &gt; Click &lt;/a&gt; &lt;a href="#" OnClick="DoAction(2,'Juan');" &g...
[ { "answer_id": 370391, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 8, "selected": true, "text": "<p>Using POST</p>\n\n<pre><code>function DoAction( id, name )\n{\n $.ajax({\n type: \"POST\",\n url: ...
2008/12/16
[ "https://Stackoverflow.com/questions/370359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46522/" ]
I'm creating HTML with a loop that has a column for Action. That column is a Hyperlink that when the user clicks calls a JavaScript function and passes the parameters... example: ``` <a href="#" OnClick="DoAction(1,'Jose');" > Click </a> <a href="#" OnClick="DoAction(2,'Juan');" > Click </a> <a href="#" OnClick="DoAc...
Using POST ``` function DoAction( id, name ) { $.ajax({ type: "POST", url: "someurl.php", data: "id=" + id + "&name=" + name, success: function(msg){ alert( "Data Saved: " + msg ); } }); } ``` Using GET ``` function DoAction( id, nam...
370,366
<p>I noticed for a while now the following syntax in some of our code:</p> <pre><code>if( NULL == var){ //... } </code></pre> <p>or</p> <pre><code>if( 0 == var){ //... } </code></pre> <p>and similar things.</p> <p>Can someone please explain why did the person who wrote this choose this notation instead of the...
[ { "answer_id": 370370, "author": "jpoh", "author_id": 4368, "author_profile": "https://Stackoverflow.com/users/4368", "pm_score": 3, "selected": false, "text": "<p>To avoid the </p>\n\n<pre><code>if (var = NULL)\n</code></pre>\n\n<p>bug</p>\n" }, { "answer_id": 370373, "autho...
2008/12/16
[ "https://Stackoverflow.com/questions/370366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14587/" ]
I noticed for a while now the following syntax in some of our code: ``` if( NULL == var){ //... } ``` or ``` if( 0 == var){ //... } ``` and similar things. Can someone please explain why did the person who wrote this choose this notation instead of the common `var == 0` way)? Is it a matter of style, or do...
It's a mechanism to avoid mistakes like this: ``` if ( var = NULL ) { // ... } ``` If you write it with the variable name on the right hand side the compiler will be able catch certain mistakes: ``` if ( NULL = var ) { // not legal, won't compile // ... } ``` Of course this won't work if variable names appea...
370,369
<p>I have a <code>JTable</code> with a custom <code>TableModel</code> called <code>DataTableModel</code>. I initialized the table with a set of column names and no data as follows:</p> <pre><code>books = new JTable(new DataTableModel(new Vector&lt;Vector&lt;String&gt;&gt;(), title2)); JScrollPane scroll1 = new JScroll...
[ { "answer_id": 370565, "author": "Daniel Hiller", "author_id": 16193, "author_profile": "https://Stackoverflow.com/users/16193", "pm_score": 2, "selected": true, "text": "<p>Have you implemented the other methods for <code>TableModel</code>? If so, how does your implementation look? Mayb...
2008/12/16
[ "https://Stackoverflow.com/questions/370369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23249/" ]
I have a `JTable` with a custom `TableModel` called `DataTableModel`. I initialized the table with a set of column names and no data as follows: ``` books = new JTable(new DataTableModel(new Vector<Vector<String>>(), title2)); JScrollPane scroll1 = new JScrollPane(books); scroll1.setEnabled(true); scroll1.setVisible(t...
Have you implemented the other methods for `TableModel`? If so, how does your implementation look? Maybe you should post your table model code to let us inspect it? BTW: My main error when implementing `TableModel` was to override `getRowCount()` and `getColumnCount()` to `return 0`. This will tell the table that ther...
370,379
<p>If php code like below how it's like as mysql stored procedure equivalent. If any links tutorial on advance stored procedure mysql please put.</p> <pre><code>$sql = " SELECT a,b FROM j "; $result = mysql_query($sql); if(mysql_num_rows($result) &gt; 0) { while($row = mysql_fetch_array($result)) { $sql_...
[ { "answer_id": 370423, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 1, "selected": false, "text": "<p>There's a pretty complete example here. The article is about Qcodo, but there's a good example using the <code>mys...
2008/12/16
[ "https://Stackoverflow.com/questions/370379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
If php code like below how it's like as mysql stored procedure equivalent. If any links tutorial on advance stored procedure mysql please put. ``` $sql = " SELECT a,b FROM j "; $result = mysql_query($sql); if(mysql_num_rows($result) > 0) { while($row = mysql_fetch_array($result)) { $sql_update = "UPDATE ...
There's a pretty complete example here. The article is about Qcodo, but there's a good example using the `mysqli` API. <http://amountaintop.com/php-5-and-mysql-5-stored-procedures-error-and-solution-qcodo> You can't do it with the `mysql` extension. Stored procedures can return multiple result sets, so you must use t...
370,401
<p>been searching for a quick example of sorting a IQueryable (Using Linq To SQL) using a Aggregate value.</p> <p>I basically need to calculate a few derived values (Percentage difference between two values etc) and sort the results by this.</p> <p>i.e.</p> <p>return rows.OrderBy(Function(s) CalcValue(s.Visitors, s....
[ { "answer_id": 370409, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 0, "selected": false, "text": "<p>My VB is pretty bad, but I think this is what it should look like. This assumes that CalcValues returns a double an...
2008/12/16
[ "https://Stackoverflow.com/questions/370401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30576/" ]
been searching for a quick example of sorting a IQueryable (Using Linq To SQL) using a Aggregate value. I basically need to calculate a few derived values (Percentage difference between two values etc) and sort the results by this. i.e. return rows.OrderBy(Function(s) CalcValue(s.Visitors, s.Clicks)) I want to call...
My solution: ``` Dim stats = rows.OrderBy(Function(s) If(s.Visitors > 0, s.Clicks / s.Visitors, 0)) ``` This also catches any divide by zero exceptions
370,432
<p>I have a div called NAV and inside of NAV I have an UL with 5 li which I float to the left, the li's that is but when I do that the NAV collapses. I know this because I put a border around NAV to see if it collapses and it does. Here is the example.</p> <p><a href="http://img401.imageshack.us/img401/8867/collapsed...
[ { "answer_id": 370434, "author": "dylanfm", "author_id": 38795, "author_profile": "https://Stackoverflow.com/users/38795", "pm_score": 2, "selected": false, "text": "<p>Try floating the containing element to the left too.</p>\n" }, { "answer_id": 370439, "author": "Community"...
2008/12/16
[ "https://Stackoverflow.com/questions/370432", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36682/" ]
I have a div called NAV and inside of NAV I have an UL with 5 li which I float to the left, the li's that is but when I do that the NAV collapses. I know this because I put a border around NAV to see if it collapses and it does. Here is the example. [collapsed http://img401.imageshack.us/img401/8867/collapsedze4.png](...
Add any `overflow` value other than `visible` to your container: ``` div#nav { overflow:auto; } ``` Then add `width` to restore the width ``` div#nav { width: 100%; overflow:auto; } ```
370,451
<p>In my app I have 2 divs, one with a long list of products that can be dragged into another div (shopping cart). The product div has the overflow but it breaks prototype draggable elements. The prototype hacks are very obtrusive and not compatible with all browsers.</p> <p>So I am taking a different approach, is it ...
[ { "answer_id": 370456, "author": "thrashr888", "author_id": 46443, "author_profile": "https://Stackoverflow.com/users/46443", "pm_score": 1, "selected": false, "text": "<p>You can use a frame with content larger than its window. Might make it hard to pass JS events though.</p>\n" }, ...
2008/12/16
[ "https://Stackoverflow.com/questions/370451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10258/" ]
In my app I have 2 divs, one with a long list of products that can be dragged into another div (shopping cart). The product div has the overflow but it breaks prototype draggable elements. The prototype hacks are very obtrusive and not compatible with all browsers. So I am taking a different approach, is it possible t...
Theres a css property to control that. ``` <div style="width:100px;height:100px;overflow:scroll"> </div> ``` <http://www.w3schools.com/Css/pr_pos_overflow.asp>
370,454
<p>I need to include or exclude a subreport based on a condition. I'm using iReport to create JasperReports. I.e., if a subreport has values, I need to include that subreport, otherwise not. Can anyone please send a sample or tell me how to resolve this.</p>
[ { "answer_id": 388097, "author": "Jamie Love", "author_id": 27308, "author_profile": "https://Stackoverflow.com/users/27308", "pm_score": 3, "selected": false, "text": "<p>you can in the master report get data from your data source that allows you to identify if the subreport should be i...
2008/12/16
[ "https://Stackoverflow.com/questions/370454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to include or exclude a subreport based on a condition. I'm using iReport to create JasperReports. I.e., if a subreport has values, I need to include that subreport, otherwise not. Can anyone please send a sample or tell me how to resolve this.
you can in the master report get data from your data source that allows you to identify if the subreport should be included, then use the 'printWhenExpression' field on the subreport element to check that data. I use this regularly - for example the printWhenExpression field may contain: ``` new Boolean($F{TOTAL_STAT...
370,499
<p>I have been trying to do a fill using the open source <a href="http://srecord.sourceforge.net/" rel="nofollow noreferrer">Srecord</a> Program. I need to do a fill that is <code>0xC2AF00</code>. It appears the program can only do fills that are a byte long (ex: <code>0xff</code>). If this is not possible with the <...
[ { "answer_id": 370777, "author": "Sparr", "author_id": 13675, "author_profile": "https://Stackoverflow.com/users/13675", "pm_score": 4, "selected": true, "text": "<p>The -repeat-data generator can take multiple bytes as parameters.\nThe following will fill bytes 16 through 31 with C2AF00...
2008/12/16
[ "https://Stackoverflow.com/questions/370499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34531/" ]
I have been trying to do a fill using the open source [Srecord](http://srecord.sourceforge.net/) Program. I need to do a fill that is `0xC2AF00`. It appears the program can only do fills that are a byte long (ex: `0xff`). If this is not possible with the [Srecord](http://srecord.sourceforge.net/) program, then how wou...
The -repeat-data generator can take multiple bytes as parameters. The following will fill bytes 16 through 31 with C2AF00C2AF00... ``` srec_cat -Output -Intel -generate 0x10 0x20 -repeat-data 0xC2 0xAF 0x00 ``` Combine with your actual input, or other generators, to fill the appropriate ranges.
370,500
<p>Is it possible to inherit from both ViewPage and ViewPage&lt;T&gt;?? Or do I have to implement both. Currently this is what I have for ViewPage. Do i need to repeat myself and do the same for ViewPage&lt;T&gt;??</p> <pre><code> public class BaseViewPage : ViewPage { public bool LoggedIn { ...
[ { "answer_id": 370579, "author": "Todd Smith", "author_id": 31624, "author_profile": "https://Stackoverflow.com/users/31624", "pm_score": 3, "selected": true, "text": "<p>Create both versions:</p>\n\n<pre><code>public class BaseViewPage : ViewPage\n{\n // put your custom code here\n}...
2008/12/16
[ "https://Stackoverflow.com/questions/370500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29376/" ]
Is it possible to inherit from both ViewPage and ViewPage<T>?? Or do I have to implement both. Currently this is what I have for ViewPage. Do i need to repeat myself and do the same for ViewPage<T>?? ``` public class BaseViewPage : ViewPage { public bool LoggedIn { get {...
Create both versions: ``` public class BaseViewPage : ViewPage { // put your custom code here } public class BaseViewPage<TModel> : BaseViewPage where TModel : class { // code borrowed from MVC source private ViewDataDictionary<TModel> _viewData; [System.Diagnostics.CodeAnalysis.SuppressMessage("Mi...
370,504
<p>I'm implementing a math library in C++. The library will be compiled to a DLL so those who use it will only need the header files the classes' definitions.</p> <p>The users of my classes will be people who are new to the language. However, there are some objects that might be referenced in several parts of their pr...
[ { "answer_id": 370520, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 4, "selected": false, "text": "<p>What you tried was to overload an operator for scalar types. C++ doesn't allow you to do that except for...
2008/12/16
[ "https://Stackoverflow.com/questions/370504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm implementing a math library in C++. The library will be compiled to a DLL so those who use it will only need the header files the classes' definitions. The users of my classes will be people who are new to the language. However, there are some objects that might be referenced in several parts of their programs. Si...
What you tried was to overload an operator for scalar types. C++ doesn't allow you to do that except for enumerations (beside the point that operator= has to be a member). At least one of the types has to be a user defined type. Thus, what you want to do is to wrap the raw pointer into a user defined class, which overl...
370,512
<p>I'm guessing the StackOverflow code has something along the lines of a UsersController that defines a function like this:</p> <pre><code>public ActionResult Profile(string id, string username, string sort) { } </code></pre> <p>From what I can tell, there's two ways to go about implementing the Profile function...
[ { "answer_id": 370558, "author": "John Sheehan", "author_id": 1786, "author_profile": "https://Stackoverflow.com/users/1786", "pm_score": 2, "selected": true, "text": "<p>Personally, I would create an action and view for each tab section and use a partial view for the top part that is sh...
2008/12/16
[ "https://Stackoverflow.com/questions/370512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1574/" ]
I'm guessing the StackOverflow code has something along the lines of a UsersController that defines a function like this: ``` public ActionResult Profile(string id, string username, string sort) { } ``` From what I can tell, there's two ways to go about implementing the Profile function. One is to use a switch s...
Personally, I would create an action and view for each tab section and use a partial view for the top part that is shared across the others. I'm just getting started with MVC though, so I don't have a lot of experience to back up that suggestion. The URL route scheme I would use is /{controller}/{id}/{section} e.g. /u...
370,518
<p>I'm new to this SCM, but since SVN is gaining popularity I was going to give it a try.</p> <p>Things I noticed:</p> <ol> <li>SVN is only the backbone of the SCM, no front-end?</li> <li>Why is there several versions of Windows Binaries? Tigris? SlikSVN? VisualSVN?</li> <li>Do I need a Web Server like Apache in orde...
[ { "answer_id": 370525, "author": "WOPR", "author_id": 46255, "author_profile": "https://Stackoverflow.com/users/46255", "pm_score": 0, "selected": false, "text": "<p>Set up svn on a windows or linux box somewhere and enable the SVN: protocol. This pretty simple to install and configure. ...
2008/12/16
[ "https://Stackoverflow.com/questions/370518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30787/" ]
I'm new to this SCM, but since SVN is gaining popularity I was going to give it a try. Things I noticed: 1. SVN is only the backbone of the SCM, no front-end? 2. Why is there several versions of Windows Binaries? Tigris? SlikSVN? VisualSVN? 3. Do I need a Web Server like Apache in order to use SVN? 4. There's dozens ...
[Here's a great guide](http://blog.excastle.com/2007/04/09/subversion-in-delphis-tools-menu/) for integrating TortoiseSVN with Delphi's "Tools" menu. This site shows how to add the following into the IDE: 1. `svn Commit`: Opens the TortoiseSVN commit window. 2. `svn Diff`: Shows diffs for the file currently being edi...
370,524
<p>I've got an interface which i've used <code>StructureMap</code> to <em>Dependency Inject</em>.</p> <pre><code>public interface IFileStorageService { void SaveFile(string fileName, byte[] data); } </code></pre> <p>The interface doesn't care WHERE the data is saved. Be it to the memory, a file, a network resourc...
[ { "answer_id": 370526, "author": "Tarik", "author_id": 44852, "author_profile": "https://Stackoverflow.com/users/44852", "pm_score": 1, "selected": false, "text": "<p>you can see what's wrong using FireBug with Firefox.</p>\n" }, { "answer_id": 370770, "author": "tcurdt", ...
2008/12/16
[ "https://Stackoverflow.com/questions/370524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30674/" ]
I've got an interface which i've used `StructureMap` to *Dependency Inject*. ``` public interface IFileStorageService { void SaveFile(string fileName, byte[] data); } ``` The interface doesn't care WHERE the data is saved. Be it to the memory, a file, a network resource, a satellite in space.... So, i've got tw...
This will hardly be a Smarty problem. Just save both HTML pages and locally and compare. What's the difference? Maybe you could even use a diff tool for this. Have you tried to validate the [HTML](http://validator.w3.org/) and the [CSS](http://jigsaw.w3.org/css-validator/)? It might also give you some hints. This is a...
370,547
<p>How can I get a record id after saving it into database. Which I mean is actually something like that.</p> <p>I have Document class (which is entity tho from DataBase) and I create an instance like </p> <pre><code>Document doc = new Document() {title="Math",name="Important"}; dataContext.Documents.InsertOnSubmit(d...
[ { "answer_id": 370563, "author": "ChrisHDog", "author_id": 25719, "author_profile": "https://Stackoverflow.com/users/25719", "pm_score": 5, "selected": true, "text": "<p>Once you have run .SubmitChanges then doc.docId should be populated with the Id that was created on the database.</p>\...
2008/12/16
[ "https://Stackoverflow.com/questions/370547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44852/" ]
How can I get a record id after saving it into database. Which I mean is actually something like that. I have Document class (which is entity tho from DataBase) and I create an instance like ``` Document doc = new Document() {title="Math",name="Important"}; dataContext.Documents.InsertOnSubmit(doc); dataContext.Subm...
Once you have run .SubmitChanges then doc.docId should be populated with the Id that was created on the database.
370,548
<p>I have a row of divs that must all be the same height, but I have no way of knowing what that height might be ahead of time (the content comes from an external source). I initially tried placing the divs in an enclosing div and floated them left. I then set their height to be "100%", but this had no perceptible effe...
[ { "answer_id": 370559, "author": "seanb", "author_id": 3354, "author_profile": "https://Stackoverflow.com/users/3354", "pm_score": 2, "selected": false, "text": "<p>Making them exactly the same height can be a tricky thing, but if they just have to appear to be the same height, you may w...
2008/12/16
[ "https://Stackoverflow.com/questions/370548", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a row of divs that must all be the same height, but I have no way of knowing what that height might be ahead of time (the content comes from an external source). I initially tried placing the divs in an enclosing div and floated them left. I then set their height to be "100%", but this had no perceptible effect....
Here is one of those moments where you can get stuck between being idealistic or realistic. I understand that there is no semantic value to placing non-tabular data in a table strictly for formatting reasons but I don't want to see you bending over backwards to create a non-tabular solution to this problem simply for i...
370,571
<p>I am creating a pdf document using C# code in my process. I need to protect the docuemnt with some standard password like "123456" or some account number. I need to do this without any reference dlls like pdf writer.</p> <p>I am generating the PDF file using SQL Reporting services reports.</p> <p>Is there are ea...
[ { "answer_id": 370888, "author": "Darin Dimitrov", "author_id": 29407, "author_profile": "https://Stackoverflow.com/users/29407", "pm_score": 6, "selected": true, "text": "<blockquote>\n <p>I am creating a pdf document using C#\n code in my process</p>\n</blockquote>\n\n<p>Are you usin...
2008/12/16
[ "https://Stackoverflow.com/questions/370571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22162/" ]
I am creating a pdf document using C# code in my process. I need to protect the docuemnt with some standard password like "123456" or some account number. I need to do this without any reference dlls like pdf writer. I am generating the PDF file using SQL Reporting services reports. Is there are easiest way.
> > I am creating a pdf document using C# > code in my process > > > Are you using some library to create this document? The [pdf specification](http://www.adobe.com/devnet/acrobat/pdfs/PDF32000_2008.pdf) (8.6MB) is quite big and all tasks involving pdf manipulation could be difficult without using a third party ...
370,586
<p>Why is the following?:</p> <pre><code> const int i0 = 5; //int i1 = const_cast&lt;int&gt;(i0); // compilation error int i2 = (int)i0; // okay int i3 = 5; //const int i4 = const_cast&lt;const int&gt;(i3); // compilation error const int i5 = (const int)i3; ...
[ { "answer_id": 370590, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": 0, "selected": false, "text": "<p>For the first error. const_cast can only be used on pointer or reference types. \"int\" is neither. This may or may...
2008/12/16
[ "https://Stackoverflow.com/questions/370586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Why is the following?: ``` const int i0 = 5; //int i1 = const_cast<int>(i0); // compilation error int i2 = (int)i0; // okay int i3 = 5; //const int i4 = const_cast<const int>(i3); // compilation error const int i5 = (const int)i3; // okay ```
``` const int i0 = 5; //int i1 = const_cast<int>(i0); // compilation error int i2 = (int)i0; // okay int i3 = 5; //const int i4 = const_cast<const int>(i3); // compilation error const int i5 = (const int)i3; // okay ``` The compilation errors are caused b...
370,601
<p>In a bunch o' places in my code, I have something like this: </p> <pre><code>public Class mySpecialMethod() { return MySpecialClass.class; } </code></pre> <p>which causes the warning </p> <blockquote> <p>Class is a raw type. References to generic type Class should be parameterized.</p> </blockquote> <p>B...
[ { "answer_id": 370613, "author": "guerda", "author_id": 32043, "author_profile": "https://Stackoverflow.com/users/32043", "pm_score": 3, "selected": false, "text": "<p>Yes, it's totally right.</p>\n\n<p>It's a requirement that you specify the type. And if you can't, you have to specify t...
2008/12/16
[ "https://Stackoverflow.com/questions/370601", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46277/" ]
In a bunch o' places in my code, I have something like this: ``` public Class mySpecialMethod() { return MySpecialClass.class; } ``` which causes the warning > > Class is a raw type. References to > generic type Class should be > parameterized. > > > But, if I replace `Class` with `Class<? extends ...
It's the correct thing to do only if there really is no common base class or interface that the Class object needs to represent. Also `Class<?>` is effectively the same as `Class<? extends Object>`.
370,622
<p>I have written a simple C++ program like this:</p> <pre><code>#include &lt;iostream&gt; using namespace std; int main() { cout &lt;&lt; "Hello."; return 0; } </code></pre> <p>Now I want to debug it. So what will be the command for it so my control goes to every line?</p>
[ { "answer_id": 370627, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 5, "selected": false, "text": "<p>You can use <a href=\"http://www.gnu.org/software/gdb/\" rel=\"noreferrer\"><code>gdb</code></a> for this:</p>\n\n<pre...
2008/12/16
[ "https://Stackoverflow.com/questions/370622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have written a simple C++ program like this: ``` #include <iostream> using namespace std; int main() { cout << "Hello."; return 0; } ``` Now I want to debug it. So what will be the command for it so my control goes to every line?
You can use [`gdb`](http://www.gnu.org/software/gdb/) for this: ``` $ gdb hello ``` This will start `gdb` and prompt you for what to do next. The `next` command executes one line of source and stops at the next line. I found a basic [GDB tutorial](http://www.cs.cmu.edu/~gilpin/tutorial/) that may be helpful.
370,624
<p>I'm learning C# by writing a home library manager.</p> <p>I have a BookController that will store the books in a data structure and perform operations on them.</p> <p>Does C# have a way of saving the data in the dictionary to a local file perhaps in an XML fashion to load later, or am I going to have to write it m...
[ { "answer_id": 370630, "author": "Ed S.", "author_id": 1053, "author_profile": "https://Stackoverflow.com/users/1053", "pm_score": 3, "selected": false, "text": "<p>Look at <a href=\"http://www.codeproject.com/KB/cs/objserial.aspx\" rel=\"noreferrer\">Serialization</a> and the <a href=\"...
2008/12/16
[ "https://Stackoverflow.com/questions/370624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46534/" ]
I'm learning C# by writing a home library manager. I have a BookController that will store the books in a data structure and perform operations on them. Does C# have a way of saving the data in the dictionary to a local file perhaps in an XML fashion to load later, or am I going to have to write it myself? What is t...
Actually, C# (the language) doesn't know **anything** about serialization, but .NET (the framework) provides lots of ways... `XmlSerializer`, `BinaryFormatter`, `DataContractSerializer` (.NET 3.0) - or there are a few bespoke serialization frameworks too. Which to use depends on your requirements; `BinaryFormatter` is...
370,632
<p>Is it possible to use Mark of the Web in XML file which is parsed by a local XSL file?</p> <p>When I insert MOTW mark:</p> <pre><code>&lt;!-- saved from url=(0014)about:internet --&gt; </code></pre> <p>i get following message:<br> Access is Denied. Error Processing Resource.</p> <hr> <p>Ok, I see that I was try...
[ { "answer_id": 370657, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 1, "selected": false, "text": "<p>From the looks of it - no. MOTW here forces the \"Internet\" Zone upon the whole process, so accessing local resources ...
2008/12/16
[ "https://Stackoverflow.com/questions/370632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22174/" ]
Is it possible to use Mark of the Web in XML file which is parsed by a local XSL file? When I insert MOTW mark: ``` <!-- saved from url=(0014)about:internet --> ``` i get following message: Access is Denied. Error Processing Resource. --- Ok, I see that I was trying to do it wrong - I wanted to insert this com...
From the looks of it - no. MOTW here forces the "Internet" Zone upon the whole process, so accessing local resources is off limits. The error message you get expresses this fact. If *testing* your page is what you try to do, you will have to fetch it from a web server, alongside with the XSL. The IIS on your machine, ...
370,641
<p>I have a client and server program (both in Obj-C) and I am transferring files between two devices using the programs.</p> <p>The transferring is working fine, but I would like to display to the user what transfer rate they are getting.</p> <p>So I know the total size of the file, and how much of the file has been...
[ { "answer_id": 370651, "author": "Marc Novakowski", "author_id": 27020, "author_profile": "https://Stackoverflow.com/users/27020", "pm_score": 5, "selected": true, "text": "<p>As soon as you start the download, capture the current system time and store it as the \"start time\". Then, al...
2008/12/16
[ "https://Stackoverflow.com/questions/370641", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26728/" ]
I have a client and server program (both in Obj-C) and I am transferring files between two devices using the programs. The transferring is working fine, but I would like to display to the user what transfer rate they are getting. So I know the total size of the file, and how much of the file has been transferred, is ...
As soon as you start the download, capture the current system time and store it as the "start time". Then, all you need to do to calculate transfer speed at any point during the transfer is to look at the system time again and use it as the "current time" to calculate the total time spent so far: ``` transfer_speed = ...