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
440,743
<p>i have an jpg where the height is larger than a regular 8.5x11 piece of paper (the height is around 2000px)</p> <p>here is the link <a href="http://i39.tinypic.com/121d7ur.jpg" rel="nofollow noreferrer">http://i39.tinypic.com/121d7ur.jpg</a></p> <p>so obviously when you try to print this picture its going to print...
[ { "answer_id": 440754, "author": "Ryan Guill", "author_id": 7186, "author_profile": "https://Stackoverflow.com/users/7186", "pm_score": 2, "selected": false, "text": "<p>I know this probably isn't the answer you are really looking for, but if you are intending on the users printing the i...
2009/01/13
[ "https://Stackoverflow.com/questions/440743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12564/" ]
i have an jpg where the height is larger than a regular 8.5x11 piece of paper (the height is around 2000px) here is the link <http://i39.tinypic.com/121d7ur.jpg> so obviously when you try to print this picture its going to print on more than 1 piece of paper ....however when i try to print the page (or even go to pri...
``` <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Blank XHTML 1 Transitional Page</title> <style> @media print { html { height: 100%; } img { height: 10...
440,745
<p>How do I create a horizontal JSeparator with a title label in Java Swing? </p> <p>Something like this:</p> <pre><code>--- Title XYZ -------------------- </code></pre>
[ { "answer_id": 440778, "author": "Bombe", "author_id": 43582, "author_profile": "https://Stackoverflow.com/users/43582", "pm_score": 2, "selected": false, "text": "<p>Hmm… without any testing and completely from the top of my head:</p>\n\n<pre><code>JPanel panel = new JPanel();\npanel.se...
2009/01/13
[ "https://Stackoverflow.com/questions/440745", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42659/" ]
How do I create a horizontal JSeparator with a title label in Java Swing? Something like this: ``` --- Title XYZ -------------------- ```
I found a solution: [SwingX JXTitledSeparator](http://javadesktop.org/swinglabs/build/weekly/latest/swingx-HEAD/javadoc/org/jdesktop/swingx/JXTitledSeparator.html). We already use SwingX in our project. I didn't know that SwingX provides a titled separator. **@Bombe** Thank you for your help.
440,755
<p>So for a while I've been using XslCompiledTransform because that's what Microsoft tells me I need to use as XslTransform is deprecated. Recently I had to use it with a transform that has nearly 100,000 lines (generated xsl - of course). When I used my application I was shocked to see an OOM pop up. No matter what...
[ { "answer_id": 440767, "author": "casperOne", "author_id": 50776, "author_profile": "https://Stackoverflow.com/users/50776", "pm_score": 0, "selected": false, "text": "<p>At first, I thought that you should file it at Microsoft Connect as a bug, but thinking about it now, it's not really...
2009/01/13
[ "https://Stackoverflow.com/questions/440755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44714/" ]
So for a while I've been using XslCompiledTransform because that's what Microsoft tells me I need to use as XslTransform is deprecated. Recently I had to use it with a transform that has nearly 100,000 lines (generated xsl - of course). When I used my application I was shocked to see an OOM pop up. No matter what I did...
ok, so now i think, maybe this is more 'microsoft being microsoft'... on a hunch i changed the target platform back to "Any CPU", closed ALL my visual studio instances open and reopened my project... i then cleaned, recompiled, and reran and i am again getting the OOM... i then set the target platform back to x86 and ...
440,756
<p>Trying to determine the Processor Queue Length (the number of processes that ready to run but currently aren't) on a linux machine. There is a WMI call in Windows for this metric, but not knowing much about linux I'm trying to mine /proc and 'top' for the information. Is there a way to determine the queue length for...
[ { "answer_id": 440763, "author": "Alastair", "author_id": 31038, "author_profile": "https://Stackoverflow.com/users/31038", "pm_score": 2, "selected": false, "text": "<p><code>uptime</code> will give you the recent load average, which is approximately the average number of active process...
2009/01/13
[ "https://Stackoverflow.com/questions/440756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Trying to determine the Processor Queue Length (the number of processes that ready to run but currently aren't) on a linux machine. There is a WMI call in Windows for this metric, but not knowing much about linux I'm trying to mine /proc and 'top' for the information. Is there a way to determine the queue length for th...
vmstat ``` procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu---- r b swpd free buff cache si so bi bo in cs us sy id wa 2 0 256368 53764 75980 220564 2 28 60 54 774 1343 15 4 78 2 ``` The first column (r) is the run queue - 2 on my machine right now E...
440,788
<p>Just dipping my toes into Linq2sql project after years of rolling my own SQL Server DB access routines.</p> <p>Before I spend too much time figuring out how to make linq2sql behave like my custom code used to, I want to check to make sure that it isn't already "built" in behavior that I can just use by setting up t...
[ { "answer_id": 440806, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 3, "selected": true, "text": "<p>This is normally what we would call child collections and they can be eager loaded or lazy loaded. Read these:</p>\n\...
2009/01/13
[ "https://Stackoverflow.com/questions/440788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53686/" ]
Just dipping my toes into Linq2sql project after years of rolling my own SQL Server DB access routines. Before I spend too much time figuring out how to make linq2sql behave like my custom code used to, I want to check to make sure that it isn't already "built" in behavior that I can just use by setting up the relatio...
This is normally what we would call child collections and they can be eager loaded or lazy loaded. Read these: <http://davidhayden.com/blog/dave/archive/2009/01/08/QuickExamplesLINQToSQLPerformanceTuningPerformanceProfilingORMapper.aspx> <http://www.thinqlinq.com/default/Fetching-child-records-using-Stored-Procedures...
440,799
<p>I'm trying to basically do a search through the database with Perl to tell if there is an item with a certain ID. This search can return no rows, but it can also return one.</p> <p>I have the following code:</p> <pre><code>my $th = $dbh-&gt;prepare(qq{SELECT bi_exim_id FROM bounce_info WHERE bi_exim_id = '$exid'})...
[ { "answer_id": 440820, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 5, "selected": true, "text": "<pre><code>my $th = $dbh-&gt;prepare(qq{SELECT bi_exim_id FROM bounce_info WHERE bi_exim_id = '$exid'});\n$th-&gt;execut...
2009/01/13
[ "https://Stackoverflow.com/questions/440799", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2128/" ]
I'm trying to basically do a search through the database with Perl to tell if there is an item with a certain ID. This search can return no rows, but it can also return one. I have the following code: ``` my $th = $dbh->prepare(qq{SELECT bi_exim_id FROM bounce_info WHERE bi_exim_id = '$exid'}); $th->execute(); if ($t...
``` my $th = $dbh->prepare(qq{SELECT bi_exim_id FROM bounce_info WHERE bi_exim_id = '$exid'}); $th->execute(); my $found = 0; while ($th->fetch()) { $found = 1; } ``` Your query won't return anything if the row doesn't exist, so you can't de-reference the fetch. **Update**: you might want to re-write that as ``...
440,854
<p>I have a asp.net web page with place holder control and Menu control when user select an item from the menu. It will dynamically load the control based on menu item's value.</p> <p>I got the control loaded but if i click on the a link button or anything on the web user control (.ascx) The web user control (.ascx) w...
[ { "answer_id": 440869, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 4, "selected": true, "text": "<p>Remember that each time you do a postback you are working with a brand new instance of your page class. If you adde...
2009/01/13
[ "https://Stackoverflow.com/questions/440854", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28647/" ]
I have a asp.net web page with place holder control and Menu control when user select an item from the menu. It will dynamically load the control based on menu item's value. I got the control loaded but if i click on the a link button or anything on the web user control (.ascx) The web user control (.ascx) will disapp...
Remember that each time you do a postback you are working with a brand new instance of your page class. If you added the control to the controls collection of a previous instance of your page class, you *need to add it again for every postback that follows.* Additionally, if you want ViewState to be restored for the c...
440,892
<p>I have a number of generated html tables that I need to output as an Excel file. The site is codded in classic ASP. Is this possible? Could it be done by somehow using the Open Office libraries?</p> <hr> <p>EDIT: Thus far, I have tried some of the suggestions, but it seems to fail. Ideally, I want the user to be a...
[ { "answer_id": 440942, "author": "Ryan Smith", "author_id": 10420, "author_profile": "https://Stackoverflow.com/users/10420", "pm_score": 0, "selected": false, "text": "<p>You can always just export the HTML table to an XLS document. Excel does a pretty good job understanding HTML table...
2009/01/13
[ "https://Stackoverflow.com/questions/440892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20770/" ]
I have a number of generated html tables that I need to output as an Excel file. The site is codded in classic ASP. Is this possible? Could it be done by somehow using the Open Office libraries? --- EDIT: Thus far, I have tried some of the suggestions, but it seems to fail. Ideally, I want the user to be able to clic...
It's AddHeader, not AppendHeader. ``` <%@ Language=VBScript %> <% Option Explicit Response.ContentType = "application/vnd.ms-excel" Response.AddHeader "Content-Disposition", "attachment; filename=excelTest.xls" %> <table> <tr> <td>Test</td> </tr> </table> ``` **Update:** I've written a blog post ab...
440,897
<p>I've seen a couple .net applications that allow you to select a C# .cs source file and the program itself will compile this code and run it. </p> <p>How is this done?</p>
[ { "answer_id": 440906, "author": "casperOne", "author_id": 50776, "author_profile": "https://Stackoverflow.com/users/50776", "pm_score": 5, "selected": true, "text": "<p>It probably uses the CSharpCodeProvider class in the Microsoft.CSharp namespace. You would want to look at the follow...
2009/01/13
[ "https://Stackoverflow.com/questions/440897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've seen a couple .net applications that allow you to select a C# .cs source file and the program itself will compile this code and run it. How is this done?
It probably uses the CSharpCodeProvider class in the Microsoft.CSharp namespace. You would want to look at the following methods to compile code: ``` CompileAssemblyFromDom CompileAssemblyFromFile CompileAssemblyFromSource ```
440,944
<p>A query runs fast:</p> <pre><code>DECLARE @SessionGUID uniqueidentifier SET @SessionGUID = 'BCBA333C-B6A1-4155-9833-C495F22EA908' SELECT * FROM Report_Opener WHERE SessionGUID = @SessionGUID ORDER BY CurrencyTypeOrder, Rank </code></pre> <p><strong>subtree cost: 0.502</strong></p> <p>But putting the same SQL in ...
[ { "answer_id": 440979, "author": "SqlRyan", "author_id": 8114, "author_profile": "https://Stackoverflow.com/users/8114", "pm_score": 1, "selected": false, "text": "<p>Though I'm usually against it (though in this case it seems that you have a genuine reason), have you tried providing any...
2009/01/13
[ "https://Stackoverflow.com/questions/440944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
A query runs fast: ``` DECLARE @SessionGUID uniqueidentifier SET @SessionGUID = 'BCBA333C-B6A1-4155-9833-C495F22EA908' SELECT * FROM Report_Opener WHERE SessionGUID = @SessionGUID ORDER BY CurrencyTypeOrder, Rank ``` **subtree cost: 0.502** But putting the same SQL in a stored procedure runs slow, and with a total...
I found the problem, here's the script of the slow and fast versions of the stored procedure: **`dbo.ViewOpener__RenamedForCruachan__Slow.PRC`** ``` SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS OFF GO CREATE PROCEDURE dbo.ViewOpener_RenamedForCruachan_Slow @SessionGUID uniqueidentifier AS SELECT * FROM Report_...
440,947
<p>I am curious about what methods do you use for complex searching with NHibernate ?</p> <p>I am using <a href="http://ayende.com/Blog/2006/12/07/ComplexSearchingQueryingWithNHibernate.aspx" rel="nofollow noreferrer">Ayende's</a></p> <p>What is yours ? Thanks for your advices and answers.</p>
[ { "answer_id": 440979, "author": "SqlRyan", "author_id": 8114, "author_profile": "https://Stackoverflow.com/users/8114", "pm_score": 1, "selected": false, "text": "<p>Though I'm usually against it (though in this case it seems that you have a genuine reason), have you tried providing any...
2009/01/13
[ "https://Stackoverflow.com/questions/440947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51734/" ]
I am curious about what methods do you use for complex searching with NHibernate ? I am using [Ayende's](http://ayende.com/Blog/2006/12/07/ComplexSearchingQueryingWithNHibernate.aspx) What is yours ? Thanks for your advices and answers.
I found the problem, here's the script of the slow and fast versions of the stored procedure: **`dbo.ViewOpener__RenamedForCruachan__Slow.PRC`** ``` SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS OFF GO CREATE PROCEDURE dbo.ViewOpener_RenamedForCruachan_Slow @SessionGUID uniqueidentifier AS SELECT * FROM Report_...
440,957
<p>I have a bunch of DB entities that are loaded into DB objects. The same DB entity may be loaded into more than DB object. Periodically a DB entity will require special processing. This processing must be performed by one thread at a time. Locking is in order here. </p> <p>EDIT: Important note: the process cal...
[ { "answer_id": 440990, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "<p>Well, you end up locking on a string, which isn't a good idea (although the concatenation means that interning sho...
2009/01/13
[ "https://Stackoverflow.com/questions/440957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a bunch of DB entities that are loaded into DB objects. The same DB entity may be loaded into more than DB object. Periodically a DB entity will require special processing. This processing must be performed by one thread at a time. Locking is in order here. EDIT: Important note: the process calls a slow web se...
Well, you end up locking on a string, which isn't a good idea (although the concatenation means that interning shouldn't be a huge issue). What is a bigger issue is that: * you don't seem to remove the locks from `padLocks` - is that an issue? * you access the dictionary outside the `padlockLock`; the `return` should ...
440,962
<p>So, I have a method that performs a parametrised LIKE query. The method takes in the search parameter/value in and then it is added to the command ready for the query.</p> <p>It is not working. It should work, and when I code the value to search for directly into the SQL string, sans parametrisation, it does work!...
[ { "answer_id": 440968, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 4, "selected": true, "text": "<p>Try this:</p>\n\n<pre><code>command.CommandText = \"SELECT * FROM TableOfAwesomeness WHERE BestTVShow LIKE @tvShow +...
2009/01/13
[ "https://Stackoverflow.com/questions/440962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35454/" ]
So, I have a method that performs a parametrised LIKE query. The method takes in the search parameter/value in and then it is added to the command ready for the query. It is not working. It should work, and when I code the value to search for directly into the SQL string, sans parametrisation, it does work! When I hav...
Try this: ``` command.CommandText = "SELECT * FROM TableOfAwesomeness WHERE BestTVShow LIKE @tvShow + '%'" ```
440,989
<p>I have my resource and they typical overridden method to handle POST requests.</p> <pre><code>public void acceptRepresentation(Representation rep) { if (MediaType.APPLICATION_XML.equals(rep.getMediaType())) { //Do stuff here } else { //complain! } } </code></pre> <p>What I want to know is the ...
[ { "answer_id": 441013, "author": "Rich Apodaca", "author_id": 54426, "author_profile": "https://Stackoverflow.com/users/54426", "pm_score": 0, "selected": false, "text": "<p>Through the <code>representation.getText()</code> method, you can get a String that can be fed into a SAX parser o...
2009/01/13
[ "https://Stackoverflow.com/questions/440989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5175/" ]
I have my resource and they typical overridden method to handle POST requests. ``` public void acceptRepresentation(Representation rep) { if (MediaType.APPLICATION_XML.equals(rep.getMediaType())) { //Do stuff here } else { //complain! } } ``` What I want to know is the best practice to handle my...
This is more of the kind of response I was looking for. Thanks to [Thierry Boileau](http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1024110) for the answer: > > You can use two kinds of "XML > representations": DomRepresentation > and SaxRepresentation. You can > instantiate both of them with t...
440,999
<p>I'm currently writing a class to handle all database-activity in my application, and so I've come to the method that performs UPDATE-queries.</p> <p>As of now I'm returning and displaying the content of the commandtext to check it, and it seems fine:</p> <pre><code>UPDATE news SET title = @title, newsContent = @ne...
[ { "answer_id": 441016, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "<p>Is it possible thatthe arg-value is null? If so the param won't be added. For nulls, you need to use <code>DBNull....
2009/01/13
[ "https://Stackoverflow.com/questions/440999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39785/" ]
I'm currently writing a class to handle all database-activity in my application, and so I've come to the method that performs UPDATE-queries. As of now I'm returning and displaying the content of the commandtext to check it, and it seems fine: ``` UPDATE news SET title = @title, newsContent = @newsContent, excerpt = ...
Thanks for the suggestions Joel Coehoorn, i will look into them. Still, i want to get my stuff to work :p Just noticed that the date-field actually have been updating itself all the time. None of the other fields, though. This just makes less sense the more i look at it. Maybe its better to try in the morning than at...
441,001
<p>Well here's my problem I have three tables; regions, countries, states. Countries can be inside of regions, states can be inside of regions. Regions are the top of the food chain.</p> <p>Now I'm adding a popular_areas table with two columns; region_id and popular_place_id. Is it possible to make popular_place_id...
[ { "answer_id": 441054, "author": "Abie", "author_id": 53166, "author_profile": "https://Stackoverflow.com/users/53166", "pm_score": 4, "selected": false, "text": "<p>This isn't the most elegant solution in the world, but you could use <a href=\"http://martinfowler.com/eaaCatalog/concrete...
2009/01/13
[ "https://Stackoverflow.com/questions/441001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/428190/" ]
Well here's my problem I have three tables; regions, countries, states. Countries can be inside of regions, states can be inside of regions. Regions are the top of the food chain. Now I'm adding a popular\_areas table with two columns; region\_id and popular\_place\_id. Is it possible to make popular\_place\_id be a f...
What you're describing is called Polymorphic Associations. That is, the "foreign key" column contains an id value that must exist in one of a set of target tables. Typically the target tables are related in some way, such as being instances of some common superclass of data. You'd also need another column along side th...
441,005
<p>I wonder if already exist a generic library of validator suitable for a iPhone project (or better, bussines objects) for obj-c.</p> <p>Things like:</p> <pre><code>Validator.IsNotEmpty.. Validator.IsValidEmail.. Validator.IsValidZipCode.. Validator.IsValidRegex.. Validator.IsInRange.. </code></pre>
[ { "answer_id": 441053, "author": "Marc Charbonneau", "author_id": 35136, "author_profile": "https://Stackoverflow.com/users/35136", "pm_score": 0, "selected": false, "text": "<p>I haven't heard of anything. If it's something you want I would use one of the regex libraries available for C...
2009/01/13
[ "https://Stackoverflow.com/questions/441005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53185/" ]
I wonder if already exist a generic library of validator suitable for a iPhone project (or better, bussines objects) for obj-c. Things like: ``` Validator.IsNotEmpty.. Validator.IsValidEmail.. Validator.IsValidZipCode.. Validator.IsValidRegex.. Validator.IsInRange.. ```
There is a standard *validation pattern* in Cocoa, including Cocoa Touch, called [Key-Value Validation](http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/Validation.html "Key-Value Validation (iPhone)") that you should conform to if you want to validate user input other th...
441,018
<p>I'm trying to use this code to replace spaces with _, it works for the first space in the string but all the other instances of spaces remain unchanged. Anybody know why?</p> <pre><code>function updateKey() { var key=$("#title").val(); key=key.replace(" ","_"); $("#url_key").val(key); } </code></pre>
[ { "answer_id": 441035, "author": "Crescent Fresh", "author_id": 45433, "author_profile": "https://Stackoverflow.com/users/45433", "pm_score": 11, "selected": true, "text": "<p>Try <code>.replace(/ /g,\"_\");</code> </p>\n\n<p><em>Edit</em>: or <code>.split(' ').join('_')</code> if you ha...
2009/01/13
[ "https://Stackoverflow.com/questions/441018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49153/" ]
I'm trying to use this code to replace spaces with \_, it works for the first space in the string but all the other instances of spaces remain unchanged. Anybody know why? ``` function updateKey() { var key=$("#title").val(); key=key.replace(" ","_"); $("#url_key").val(key); } ```
Try `.replace(/ /g,"_");` *Edit*: or `.split(' ').join('_')` if you have an aversion to REs *Edit*: [John Resig said](http://ejohn.org/blog/javascript-micro-templating/): > > If you're searching and replacing > through a string with a static search > and a static replace it's faster to > perform the action with...
441,021
<p>can someone tell me why the following behavior occurs (Oracle 10.2):</p> <pre><code>SQL&gt; create table part_test ( i int primary key, d date ) partition by range (d) (partition part_test_1 values less than (to_date(' 2 3 4 5 1980-01-01', 'yyyy-mm-dd'))); create public synonym part_test...
[ { "answer_id": 441940, "author": "Gary Myers", "author_id": 25714, "author_profile": "https://Stackoverflow.com/users/25714", "pm_score": 2, "selected": false, "text": "<p>It doesn't in 11.1.0.6\nIt could have been a bug that was fixed. It may have been something that was necessary (eg f...
2009/01/13
[ "https://Stackoverflow.com/questions/441021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27308/" ]
can someone tell me why the following behavior occurs (Oracle 10.2): ``` SQL> create table part_test ( i int primary key, d date ) partition by range (d) (partition part_test_1 values less than (to_date(' 2 3 4 5 1980-01-01', 'yyyy-mm-dd'))); create public synonym part_test for part_test; ...
I have tested it with Oracle 10.2 and the synonym becomes indeed invalid but when an other user uses the synonym by doing select count(\*) from part\_test; Oracle automatically compiles the synonym and the synonym becomes valid. It is the same with packages, procedures and functions. When you execute them and they...
441,023
<p>I have a data tier select method that returns a datatable. It's called from a business tier method that should then return a strongly typed generic List.</p> <p>What I want to do is very similar (but not the same as) this question:<br> <a href="https://stackoverflow.com/questions/208532/how-do-you-convert-a-datata...
[ { "answer_id": 441059, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": true, "text": "<p>Do you know the structure of the <code>DataTable</code> and the typed object ahead of time? You could use a delegat...
2009/01/13
[ "https://Stackoverflow.com/questions/441023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3043/" ]
I have a data tier select method that returns a datatable. It's called from a business tier method that should then return a strongly typed generic List. What I want to do is very similar (but not the same as) this question: [How do you convert a DataTable into a generic list?](https://stackoverflow.com/questions/2...
Do you know the structure of the `DataTable` and the typed object ahead of time? You could use a delegate to do the mapping. If you don't (i.e. all you know is a `Type` and properties) there are ways of accelerating dynamic member access (such as `HyperDescriptor`). Either way, consider an iterator block; that way you...
441,038
<p>I get this error when debugging my ASP.NET web application after I trigger an UpdatePanel:</p> <p><img src="https://i.stack.imgur.com/CqrGC.gif" alt="ASP.NET htmlfile: Unknown runtime error updatePanelElement.innerHTML=rendering"></p> <p>htmlfile: Unknown runtime error</p> <p>and "updatePanelElement.innerHTML=ren...
[ { "answer_id": 441050, "author": "Zack Peterson", "author_id": 83, "author_profile": "https://Stackoverflow.com/users/83", "pm_score": 1, "selected": true, "text": "<p>This seems to happen because I've got my UpdatePanel within an ordered list &lt;ol&gt; container. And I've got list ite...
2009/01/13
[ "https://Stackoverflow.com/questions/441038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/83/" ]
I get this error when debugging my ASP.NET web application after I trigger an UpdatePanel: ![ASP.NET htmlfile: Unknown runtime error updatePanelElement.innerHTML=rendering](https://i.stack.imgur.com/CqrGC.gif) htmlfile: Unknown runtime error and "updatePanelElement.innerHTML=rendering" is highlighted in a ScriptReso...
This seems to happen because I've got my UpdatePanel within an ordered list <ol> container. And I've got list item <li> tags within my UpdatePanel's ContentTemplate. ``` <ol> <li>...</li> <asp:UpdatePanel ...> <ContentTemplate> <li id="lione" runat="server">...</li> <li id="litw...
441,060
<p>I thought there was something in GExperts to do this, but I can't see it if there is.</p> <p>I have to change the SCALED property (from the default of TRUE to FALSE) in each form in a project that contains about 100 different forms. Because the default value of SCALED is TRUE, it doesn't actually appear as a line i...
[ { "answer_id": 441523, "author": "Jim McKeeth", "author_id": 255, "author_profile": "https://Stackoverflow.com/users/255", "pm_score": 3, "selected": false, "text": "<p>I would recommend changing all your forms to descend from a common ancestor. Then in the future you can just change th...
2009/01/13
[ "https://Stackoverflow.com/questions/441060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3897/" ]
I thought there was something in GExperts to do this, but I can't see it if there is. I have to change the SCALED property (from the default of TRUE to FALSE) in each form in a project that contains about 100 different forms. Because the default value of SCALED is TRUE, it doesn't actually appear as a line in the .DFM...
Provided that all your DFM files are not binary, but text (which is a good idea, unless you need to be compatible with Delphi 4 or earlier) you can of course use grep / sed / awk. The format of the DFM is not fixed, and instead of ``` OldCreateOrder = False Scaled = False ``` it could also contain ``` OldCre...
441,109
<p>Regardless of what the user's local time zone is set to, using C# (.NET 2.0) I need to determine the time (DateTime object) in the Eastern time zone.</p> <p>I know about these methods but there doesn't seem to be an obvious way to get a DateTime object for a different time zone than what the user is in.</p> <pre><...
[ { "answer_id": 441131, "author": "Charles Bretana", "author_id": 32632, "author_profile": "https://Stackoverflow.com/users/32632", "pm_score": 1, "selected": false, "text": "<p>How about</p>\n\n<pre><code> DateTime lclTime = DateTime.Now;\n DateTime ept = lclTime.ToUniversalTime().AddHou...
2009/01/13
[ "https://Stackoverflow.com/questions/441109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35229/" ]
Regardless of what the user's local time zone is set to, using C# (.NET 2.0) I need to determine the time (DateTime object) in the Eastern time zone. I know about these methods but there doesn't seem to be an obvious way to get a DateTime object for a different time zone than what the user is in. ``` DateTime.Now D...
As everyone else mentioned, .NET 2 doesn't contain any time zone information. The information is stored in the registry, though, and its fairly trivial to write a wrapper class around it: ``` SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones ``` contains sub-keys for all time zones. The TZI field value con...
441,110
<p>I'll be the first to admit that this is cut and past programming. I've never looked at AD before, and really don't understand it. I suppose that's my next study...</p> <p>Anyways, This is some test code, which should display the expiry date -- either as something readable, or in ticks -- it doesn't matter. (It's ...
[ { "answer_id": 441197, "author": "Dave Cluderay", "author_id": 30933, "author_profile": "https://Stackoverflow.com/users/30933", "pm_score": 4, "selected": true, "text": "<p>It's because the property value is represented using the ADSI IADsLargeInteger COM interface and needs to be conve...
2009/01/13
[ "https://Stackoverflow.com/questions/441110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18907/" ]
I'll be the first to admit that this is cut and past programming. I've never looked at AD before, and really don't understand it. I suppose that's my next study... Anyways, This is some test code, which should display the expiry date -- either as something readable, or in ticks -- it doesn't matter. (It's a web form, ...
It's because the property value is represented using the ADSI IADsLargeInteger COM interface and needs to be converted to a .NET date. Although I haven't tried it, there is a sample that shows how here: <http://www.simple-talk.com/dotnet/.net-framework/building-active-directory-wrappers-in-.net/>
441,121
<p>I am puzzling over some code given to me in a prior SO question I had. <a href="https://stackoverflow.com/questions/291445/f-beginner-retrieving-an-array-of-data-from-a-server#295788">Code here</a></p> <p>At this line, I get an error saying I have an invalid number of parameters. I don't completely understand what ...
[ { "answer_id": 442277, "author": "Robert", "author_id": 17864, "author_profile": "https://Stackoverflow.com/users/17864", "pm_score": 0, "selected": false, "text": "<p>The following type checks for me:</p>\n\n<pre><code>#light\nopen System.Data\nopen System.Data.SqlClient\nopen System.Co...
2009/01/13
[ "https://Stackoverflow.com/questions/441121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26227/" ]
I am puzzling over some code given to me in a prior SO question I had. [Code here](https://stackoverflow.com/questions/291445/f-beginner-retrieving-an-array-of-data-from-a-server#295788) At this line, I get an error saying I have an invalid number of parameters. I don't completely understand what the error is, since a...
This post is old and languishing, but are you sure the invalid number of parameters error isn't coming from the Oracle command? Basically: are you specifying a parameter in the SQL query? The opener function is not applying any parameters.
441,126
<p>I am trying to do an automated xml export from an access database using C# and OLE. Everything is working perfectly except that the startup form is shown and won't close without user intervention.</p> <p>Here's what I am doing so far:</p> <pre><code>objAccess = CreateObject("Access.Application"); objAccess.OpenCu...
[ { "answer_id": 441223, "author": "DJ.", "author_id": 10492, "author_profile": "https://Stackoverflow.com/users/10492", "pm_score": 1, "selected": true, "text": "<p>As far as I know the only way is to use the /nostartup switch on msaccess.exe</p>\n\n<p>So you have to use shell command to ...
2009/01/13
[ "https://Stackoverflow.com/questions/441126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29823/" ]
I am trying to do an automated xml export from an access database using C# and OLE. Everything is working perfectly except that the startup form is shown and won't close without user intervention. Here's what I am doing so far: ``` objAccess = CreateObject("Access.Application"); objAccess.OpenCurrentDatabase("C:\\MYD...
As far as I know the only way is to use the /nostartup switch on msaccess.exe So you have to use shell command to get the access object I have a function that opens a database and returns the object (This is VBA code which you will have to convert to C#) ``` Private Function OpenDatabaseWithShell(pDatabaseFullPath A...
441,127
<p>Everything works fine when the unit tests class is part of the main project (TestAccount). </p> <p>Every article I've read about unit testing recommends putting the tests in a separate project, so I... </p> <ul> <li>added another project (TestAccount.UnitTests) to the solution</li> <li>moved the unit tests class...
[ { "answer_id": 443416, "author": "Omar Kooheji", "author_id": 20400, "author_profile": "https://Stackoverflow.com/users/20400", "pm_score": 0, "selected": false, "text": "<p>This might sound silly but I'm going to go for the obvious have you given your test project a reference to the oth...
2009/01/13
[ "https://Stackoverflow.com/questions/441127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54804/" ]
Everything works fine when the unit tests class is part of the main project (TestAccount). Every article I've read about unit testing recommends putting the tests in a separate project, so I... * added another project (TestAccount.UnitTests) to the solution * moved the unit tests class (AccountTests.vb) to TestAcco...
I found a [bug report](https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=271421&wa=wsignin1.0) that says Visual Studio incorrectly expands the TargetPath and TargetDir macros. They expand to the obj\ directory, not bin\ [Update] The problem/solution is actually discussed in the [Visual S...
441,128
<p>I am trying to use Qt for a project in school but am running into problems. I started following the tutorials and I am running into Makefile problems. Most of the tutorials say to run <code>qmake -project</code>, then <code>qmake</code> and finally <code>make</code>. But when I try this I run into the error <code>ma...
[ { "answer_id": 441209, "author": "Arcane", "author_id": 54811, "author_profile": "https://Stackoverflow.com/users/54811", "pm_score": 2, "selected": false, "text": "<p>It sounds like there might be a problem with your Qt install. Did you build it yourself, or install a build from someon...
2009/01/13
[ "https://Stackoverflow.com/questions/441128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/435182/" ]
I am trying to use Qt for a project in school but am running into problems. I started following the tutorials and I am running into Makefile problems. Most of the tutorials say to run `qmake -project`, then `qmake` and finally `make`. But when I try this I run into the error `make: *** No targets specified and no makef...
qmake on OS X creates Xcode project files. You can create a Makefile with: ``` qmake -spec macx-g++ ``` If you don't want the Makefile to create an app bundle, you could also remove 'app\_bundle' your configuration, for example by adding the following lines to your project file. ``` mac { CONFIG -= app_bundle } ...
441,130
<p>Is it possible to use the <code>with</code> statement directly with CSV files? It seems natural to be able to do something like this:</p> <pre><code>import csv with csv.reader(open("myfile.csv")) as reader: # do things with reader </code></pre> <p>But csv.reader doesn't provide the <code>__enter__</code> and <...
[ { "answer_id": 441167, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 2, "selected": false, "text": "<p>Yes. The second way is correct.</p>\n\n<p>As to why? Who ever knows. You're right, it's probably an easy change. It'...
2009/01/13
[ "https://Stackoverflow.com/questions/441130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49559/" ]
Is it possible to use the `with` statement directly with CSV files? It seems natural to be able to do something like this: ``` import csv with csv.reader(open("myfile.csv")) as reader: # do things with reader ``` But csv.reader doesn't provide the `__enter__` and `__exit__` methods, so this doesn't work. I can h...
The primary use of `with` statement is an exception-safe cleanup of an object used in the statement. `with` makes sure that files are closed, locks are released, contexts are restored, etc. Does [csv.reader](http://docs.python.org/library/csv.html#csv.reader) have things to cleanup in case of exception? I'd go with: ...
441,141
<p>I am trying create a WCF service that leverages the WPF MediaPlayer on the server to generate thumbnails for a video that a user uploads. I found a lot oif info on how to render a frame and save it to a file. But the problem is the key event MediaOpened (actually none of the events) I need to tie into <strong>doesn'...
[ { "answer_id": 441257, "author": "Dominic Hopton", "author_id": 9475, "author_profile": "https://Stackoverflow.com/users/9475", "pm_score": 0, "selected": false, "text": "<p>You will likely need to render the data on screen, for those events to be fired -- it's all tied to being part of ...
2009/01/13
[ "https://Stackoverflow.com/questions/441141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54805/" ]
I am trying create a WCF service that leverages the WPF MediaPlayer on the server to generate thumbnails for a video that a user uploads. I found a lot oif info on how to render a frame and save it to a file. But the problem is the key event MediaOpened (actually none of the events) I need to tie into **doesn't** - EDI...
I decided to try and use the Expression Media Encoder 2 SDK and it worked great. Very little code to generate thumbnails from a video - here is a snippet ``` public void GenerateThumbnails(string fileName, int numberOfThumbnails) ``` { Queue \_positionsToThumbnail = new Queue(); Microsoft.Expression.Encoder.Media...
441,144
<p>I want to define a JavaScript class, Foo. </p> <pre><code>Foo = function(value){ this.value = value; }; </code></pre> <p>I will create "instances" of my Foo:</p> <pre><code>foo1 = new Foo(1); foo2 = new Foo(1); </code></pre> <p>and I want my instances of Foo to be comparable with each other using the standar...
[ { "answer_id": 441155, "author": "Georg Schölly", "author_id": 24587, "author_profile": "https://Stackoverflow.com/users/24587", "pm_score": 1, "selected": false, "text": "<p>I don't think this is possible using javascript. You have to write your own function e.g. <code>isEqual()</code><...
2009/01/13
[ "https://Stackoverflow.com/questions/441144", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54806/" ]
I want to define a JavaScript class, Foo. ``` Foo = function(value){ this.value = value; }; ``` I will create "instances" of my Foo: ``` foo1 = new Foo(1); foo2 = new Foo(1); ``` and I want my instances of Foo to be comparable with each other using the standard == equality operator: ``` foo1 == foo2; /...
JavaScript does not have operator overloading. See [this discussion](https://stackoverflow.com/questions/27030/comparing-arrays-of-objects-in-javascript) covering your question.
441,147
<p>I have a Python <a href="https://docs.python.org/library/datetime.html#datetime-objects" rel="noreferrer"><code>datetime.datetime</code></a> object. What is the best way to subtract one day?</p>
[ { "answer_id": 441152, "author": "Steve B.", "author_id": 19479, "author_profile": "https://Stackoverflow.com/users/19479", "pm_score": 12, "selected": true, "text": "<p>You can use a <a href=\"http://docs.python.org/library/datetime.html#timedelta-objects\" rel=\"noreferrer\"><code>time...
2009/01/13
[ "https://Stackoverflow.com/questions/441147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6007/" ]
I have a Python [`datetime.datetime`](https://docs.python.org/library/datetime.html#datetime-objects) object. What is the best way to subtract one day?
You can use a [`timedelta`](http://docs.python.org/library/datetime.html#timedelta-objects) object: ``` from datetime import datetime, timedelta d = datetime.today() - timedelta(days=days_to_subtract) ```
441,185
<p>When you create an aspx page as this one:</p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www...
[ { "answer_id": 441373, "author": "Joe Phillips", "author_id": 20471, "author_profile": "https://Stackoverflow.com/users/20471", "pm_score": 0, "selected": false, "text": "<p>You have to turn it off in your sound preferences on your operating system. It's an Internet Explorer thing.</p>\n...
2009/01/13
[ "https://Stackoverflow.com/questions/441185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54517/" ]
When you create an aspx page as this one: ``` <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head ru...
If it's related to the browser that your audience is using, then they're used to it happening, because it happens on every other site besides yours. I'd say it's not worth worrying about - kind of like people with JavaScript turned off. They know they've got it turned off, and they're accustomed to sites lacking certai...
441,203
<p>In general, what is the best way of storing binary data in C++? The options, as far as I can tell, pretty much boil down to using strings or vector&lt;char&gt;s. (I'll omit the possibility of char*s and malloc()s since I'm referring specifically to C++).</p> <p>Usually I just use a string, however I'm not sure if t...
[ { "answer_id": 441231, "author": "Doug T.", "author_id": 8123, "author_profile": "https://Stackoverflow.com/users/8123", "pm_score": 7, "selected": true, "text": "<p>vector of char is nice because the memory is contiguious. Therefore you can use it with a lot of C API's such as berkley s...
2009/01/13
[ "https://Stackoverflow.com/questions/441203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53315/" ]
In general, what is the best way of storing binary data in C++? The options, as far as I can tell, pretty much boil down to using strings or vector<char>s. (I'll omit the possibility of char\*s and malloc()s since I'm referring specifically to C++). Usually I just use a string, however I'm not sure if there are overhe...
vector of char is nice because the memory is contiguious. Therefore you can use it with a lot of C API's such as berkley sockets or file APIs. You can do the following, for example: ``` std::vector<char> vect; ... send(sock, &vect[0], vect.size()); ``` and it will work fine. You can essentially treat it just ...
441,240
<p>I hate the JavaBeans pattern with a passion that burns like the fire of a thousand suns. Why?</p> <ul> <li><strong>Verbose</strong>. It's 2009. I shouldn't have to write 7 LOC for a property. If they have event listeners then hold on to your hat.</li> <li><strong>No type-safe references</strong>. There is no type-s...
[ { "answer_id": 441262, "author": "Michael Borgwardt", "author_id": 16883, "author_profile": "https://Stackoverflow.com/users/16883", "pm_score": 2, "selected": false, "text": "<p>You may want to check out <a href=\"http://groovy.codehaus.org/\" rel=\"nofollow noreferrer\">Groovy</a> - a ...
2009/01/13
[ "https://Stackoverflow.com/questions/441240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43379/" ]
I hate the JavaBeans pattern with a passion that burns like the fire of a thousand suns. Why? * **Verbose**. It's 2009. I shouldn't have to write 7 LOC for a property. If they have event listeners then hold on to your hat. * **No type-safe references**. There is no type-safe way to reference a property. The whole poin...
I think you're pretty close with the declaration you have there (see below for a sketch). However, by using a non-beans approach, you'll probably lose support provided by most tools that assume the JavaBeans protocol is in effect. Please be kind. The code below is off the top of my head... ``` public class Property<T>...
441,251
<p>Taking this article on classes and structs as an example:</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms173109.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms173109.aspx</a></p> <pre><code>namespace ProgrammingGuide { // Class definition. public class MyCustomClass ...
[ { "answer_id": 441258, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": true, "text": "<pre><code>static MyCustomClass myClass;\npublic static MyCustomClass MyClass {get {return myClass;}}\nstatic void Mai...
2009/01/13
[ "https://Stackoverflow.com/questions/441251", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54760/" ]
Taking this article on classes and structs as an example: <http://msdn.microsoft.com/en-us/library/ms173109.aspx> ``` namespace ProgrammingGuide { // Class definition. public class MyCustomClass { // Class members: // Property. public int Number { get; set; } // Method. ...
``` static MyCustomClass myClass; public static MyCustomClass MyClass {get {return myClass;}} static void Main(string[] args) { // Create an object of type MyCustomClass. myClass = new MyCustomClass(); ... } ``` Now you can use `Program.MyClass`
441,265
<p>The general rule is that I want to say, "T has a method with a String parameter which will return List." Put verbosely, we might call the interface ICanCreateListOfObjectsFromString. A possible application might be search.</p> <p>It feels like it'd be nice to have a static method in my interface, but I know that'...
[ { "answer_id": 441283, "author": "Bombe", "author_id": 43582, "author_profile": "https://Stackoverflow.com/users/43582", "pm_score": 0, "selected": false, "text": "<p>Maybe the <a href=\"http://en.wikipedia.org/wiki/Factory_method_pattern\" rel=\"nofollow noreferrer\">factory pattern</a>...
2009/01/13
[ "https://Stackoverflow.com/questions/441265", "https://Stackoverflow.com", "https://Stackoverflow.com/users/337/" ]
The general rule is that I want to say, "T has a method with a String parameter which will return List." Put verbosely, we might call the interface ICanCreateListOfObjectsFromString. A possible application might be search. It feels like it'd be nice to have a static method in my interface, but I know that's not allowe...
Sounds like you're trying to implement a Mixin... Something of that sort exists in C# 3.0, and they are named "Extension Methods". What do allow you to do? Well, they allow you to create functions that work in types that you specify, and "add" methods to them. Since that type can be an interface, this lets you define...
441,279
<p>In my test, I have 2 spans both set to display:inline-block with a border for visibility. Firefox renders space between each span. Even setting margin:0;padding:0; doesn't do anything to fix this. My expectation when setting the inline span element to display:inline-block is that the 2 spans render flush against eac...
[ { "answer_id": 441285, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 6, "selected": true, "text": "<p>It's spacing them apart because you have space between them - the newline.</p>\n" }, { "answer_id": 442370, "aut...
2009/01/13
[ "https://Stackoverflow.com/questions/441279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/68788/" ]
In my test, I have 2 spans both set to display:inline-block with a border for visibility. Firefox renders space between each span. Even setting margin:0;padding:0; doesn't do anything to fix this. My expectation when setting the inline span element to display:inline-block is that the 2 spans render flush against each o...
It's spacing them apart because you have space between them - the newline.
441,289
<p>Namespace are pretty cool: with them, you can organize your libraries and you can avoid name conflicts.</p> <p>Well, this is the intention, I think. I think that a lot of people do not use it like it should be used... Every day, I see 95 char long namespaces scattering the code and hiding the really important infor...
[ { "answer_id": 441305, "author": "Ian Varley", "author_id": 37539, "author_profile": "https://Stackoverflow.com/users/37539", "pm_score": 1, "selected": false, "text": "<p>This depends on the language and the breadth of the organization and code. You're right that having a long list of n...
2009/01/13
[ "https://Stackoverflow.com/questions/441289", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54783/" ]
Namespace are pretty cool: with them, you can organize your libraries and you can avoid name conflicts. Well, this is the intention, I think. I think that a lot of people do not use it like it should be used... Every day, I see 95 char long namespaces scattering the code and hiding the really important information. ...
thats a lot of questions in one question post! 1) Why use Namespaces? as you stated in the question, they are AN orginizational method for code. there really is no "one way" to orginize code so commonly named objects arn't causing you issues. Creating one class library might use an entirely different mechinism than a...
441,293
<p>I have a collection called dbUsers of type IQueryable</p> <p>These are pulled from a linqtosql database context i.e.</p> <pre><code>IQueryable&lt;Data.LinqToSQL.User&gt; dbUsers = DBContext.Users </code></pre> <p>Calling ToList on this object:</p> <pre><code>IList&lt;Data.LinqToSQL.User&gt; users = dbUsers.ToLis...
[ { "answer_id": 441359, "author": "John Boker", "author_id": 2847, "author_profile": "https://Stackoverflow.com/users/2847", "pm_score": 2, "selected": false, "text": "<p>see if this works for you:</p>\n\n<pre><code>IList&lt;Data.LinqToSQL.User&gt; users = (from u in DBContext.Users selec...
2009/01/13
[ "https://Stackoverflow.com/questions/441293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46616/" ]
I have a collection called dbUsers of type IQueryable These are pulled from a linqtosql database context i.e. ``` IQueryable<Data.LinqToSQL.User> dbUsers = DBContext.Users ``` Calling ToList on this object: ``` IList<Data.LinqToSQL.User> users = dbUsers.ToList(); ``` Results in an exception: ExecuteReader requi...
see if this works for you: ``` IList<Data.LinqToSQL.User> users = (from u in DBContext.Users select u).ToList(); ``` if not you might need to do something like: ``` DBContext context = new DBContext(); IList<Data.LinqToSQL.User> users = (from u in context.Users select u).ToList(); ```
441,297
<p>I have an SVN repo at a hosted SVN service which I need to move to our locally hosted SVN service. The host offers an export feature, which I've used. But how do I take that exported file and import it into a new repository?</p> <p>EDIT</p> <p>I tried using svnadmin load, but got an error message:</p> <pre><code>...
[ { "answer_id": 441320, "author": "Bombe", "author_id": 43582, "author_profile": "https://Stackoverflow.com/users/43582", "pm_score": 4, "selected": true, "text": "<p>If the export was created using <code>svnadmin dump</code> you can import it into a new, empty repository using</p>\n\n<pr...
2009/01/13
[ "https://Stackoverflow.com/questions/441297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39539/" ]
I have an SVN repo at a hosted SVN service which I need to move to our locally hosted SVN service. The host offers an export feature, which I've used. But how do I take that exported file and import it into a new repository? EDIT I tried using svnadmin load, but got an error message: ``` % svnadmin load . < ~/ss2_14...
If the export was created using `svnadmin dump` you can import it into a new, empty repository using ``` # cd /path/to/new/repo # svnadmin load . < /path/to/dumpfile ```
441,304
<p>On my Mac and any other Unix machine, when I delete a file by any of the several available methods (<code>rm</code> on the command line, drag to trash, press delete key) it usually happens instantly. Occasionally it takes a few seconds if it's a huge file.</p> <p>On Windows, when I try to delete something a dialog ...
[ { "answer_id": 441318, "author": "Dirk Vollmar", "author_id": 40347, "author_profile": "https://Stackoverflow.com/users/40347", "pm_score": 3, "selected": true, "text": "<p>Have you tried on the command line?</p>\n\n<pre><code>del /q filename\n</code></pre>\n\n<p>Optionally you could als...
2009/01/13
[ "https://Stackoverflow.com/questions/441304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42595/" ]
On my Mac and any other Unix machine, when I delete a file by any of the several available methods (`rm` on the command line, drag to trash, press delete key) it usually happens instantly. Occasionally it takes a few seconds if it's a huge file. On Windows, when I try to delete something a dialog comes up with a progr...
Have you tried on the command line? ``` del /q filename ``` Optionally you could also install MinGW or Cygwin to get the same commands available in Windows as in Linux/Unix. Please note that file deletion might be **slow** if you keep **many files in your Recycle Bin**. Emptying the bin will solve the problem. You...
441,306
<p>in my code i would like boost::shared_ptr not to call delete but call ptr->deleteMe() instead.</p> <p>Also i have a few C styled functions that return a ptr. Can i make it call lib_freeXYZ(ptr); instead of trying to delete?</p>
[ { "answer_id": 441319, "author": "Doug T.", "author_id": 8123, "author_profile": "https://Stackoverflow.com/users/8123", "pm_score": 5, "selected": false, "text": "<p>You can give the shared_ptr template a custom deleter function which has the signature </p>\n\n<pre><code> void Deleter(...
2009/01/13
[ "https://Stackoverflow.com/questions/441306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
in my code i would like boost::shared\_ptr not to call delete but call ptr->deleteMe() instead. Also i have a few C styled functions that return a ptr. Can i make it call lib\_freeXYZ(ptr); instead of trying to delete?
Or how about using the stl to provide the wrapper functor - Doug T. description but without the custom caller. ``` boost::shared_ptr<T> ptr( new T, std::mem_fun_ref(&T::deleteMe) ); boost::shared_ptr<S> ptr( new S, std::ptr_fun(lib_freeXYZ) ); ```
441,345
<p>I am running creating an iPhone application which performs a costly operation and I wanted to create an activityIndicator to let the user know the application has not frozen.</p> <p>The operation is performed entirely in one event call... so there is no chance for the UI framework to receive control to actually dis...
[ { "answer_id": 441433, "author": "Stephan Burlot", "author_id": 53071, "author_profile": "https://Stackoverflow.com/users/53071", "pm_score": -1, "selected": false, "text": "<p>An UIProgressView (the progress bar) can not run by itself, you need to periodically increment its value.</p>\n...
2009/01/13
[ "https://Stackoverflow.com/questions/441345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40175/" ]
I am running creating an iPhone application which performs a costly operation and I wanted to create an activityIndicator to let the user know the application has not frozen. The operation is performed entirely in one event call... so there is no chance for the UI framework to receive control to actually display and a...
I just found someone asking a very similar question with a good answer on the apple iPhone forums. <https://devforums.apple.com/message/24220#24220> #Note: you have to have an appleID to view it. Essentially, yes, you do need to start your process running in a different thread, but its quite easy to do (as paraphrased...
441,358
<p>I have a Person class in the Model and want to assign 15 of its attributes to labels in the View. The View shouldn't access the Model. That means the Controller will handle creating the Person. How does the View get these Person attributes from the Controller? If the Controller contains a member of Type Person, ...
[ { "answer_id": 441368, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 0, "selected": false, "text": "<p>The person could be in the view-data. I don't personally think that there is a huge issue with the view accessing ...
2009/01/13
[ "https://Stackoverflow.com/questions/441358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40106/" ]
I have a Person class in the Model and want to assign 15 of its attributes to labels in the View. The View shouldn't access the Model. That means the Controller will handle creating the Person. How does the View get these Person attributes from the Controller? If the Controller contains a member of Type Person, the Vie...
Slightly off topic (on MVC) but on topic about your issue: Why not use a less cumbersome solution? If you need to simply assign to 15 labels 15 values you could give your controller an indexed property or method that uses your Label object's design time name as key to retrieve the appropriate value from your model usi...
441,400
<p>Well, I've been given an assignment to basically figure out how memory allocation works for whatever language I'll be using. After some research, I have some questions and doubts which I'd like to get some insight in. For example:</p> <p>I read <a href="http://en.citizendium.org/wiki/Stack_frame" rel="nofollow nore...
[ { "answer_id": 441432, "author": "Uri", "author_id": 23072, "author_profile": "https://Stackoverflow.com/users/23072", "pm_score": 2, "selected": false, "text": "<p>What exactly was the task that you were given?</p>\n\n<p>The main difference between Java and C++ is that Java is garbage c...
2009/01/14
[ "https://Stackoverflow.com/questions/441400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Well, I've been given an assignment to basically figure out how memory allocation works for whatever language I'll be using. After some research, I have some questions and doubts which I'd like to get some insight in. For example: I read [here](http://en.citizendium.org/wiki/Stack_frame) that Java specifies exactly ho...
> > Looking at the JVM spec structure, it basically says the stack contains frames, and that the frames contain whatever is inside the class by properly allocating the variables and functions. Maybe I am missing something here, but I don't understand how this is any different than what C++ does. I ask because the firs...
441,404
<p>I have a CMS that uses a syntax based on HTML comments to let the user insert flash video players, slideshows, and other 'hard' code that the user could not easily write. </p> <p>The syntax for one FLV movies looks like this: <code>&lt;!--PLAYER=filename.flv--&gt;</code></p> <p>I use this code:</p> <p><code>$find...
[ { "answer_id": 441417, "author": "spas", "author_id": 46999, "author_profile": "https://Stackoverflow.com/users/46999", "pm_score": 1, "selected": false, "text": "<pre><code>$find_players = preg_match(\"/&lt;!--PLAYER\\=(.*?)--&gt;/i\", $html_content, $match);\n</code></pre>\n\n<p>(.<str...
2009/01/14
[ "https://Stackoverflow.com/questions/441404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13113/" ]
I have a CMS that uses a syntax based on HTML comments to let the user insert flash video players, slideshows, and other 'hard' code that the user could not easily write. The syntax for one FLV movies looks like this: `<!--PLAYER=filename.flv-->` I use this code: `$find_players = preg_match("/<!--PLAYER\=(.*)-->/si...
You probably want the regex modifier U (PCRE\_UNGREEDY, to match ungreedily). This will fetch the shortest possible match, meaning that you won't match from the beginning of the first <!--PLAYER= to the end of the last --> An abbreviated example: ``` <?php $text = "blah\n<!-x=abc->blah<!-x=def->blah\n\nblah<!-x=ghi->...
441,412
<p>I use the following for a jQuery link in my <code>&lt;script&gt;</code> tags:</p> <pre><code>http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js </code></pre> <p>Is there a link to the "latest" version? Something like the following (which doesn't work):</p> <pre><code>http://ajax.googleapis.com/ajax/libs/...
[ { "answer_id": 441429, "author": "Brian Fisher", "author_id": 43816, "author_profile": "https://Stackoverflow.com/users/43816", "pm_score": 11, "selected": true, "text": "<p><strong>Up until jQuery 1.11.1</strong>, you could use the following URLs to get the latest version of jQuery:</p>...
2009/01/14
[ "https://Stackoverflow.com/questions/441412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4003/" ]
I use the following for a jQuery link in my `<script>` tags: ``` http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js ``` Is there a link to the "latest" version? Something like the following (which doesn't work): ``` http://ajax.googleapis.com/ajax/libs/jquery/latest/jquery.js ``` (Obviously not necessari...
**Up until jQuery 1.11.1**, you could use the following URLs to get the latest version of jQuery: * <https://code.jquery.com/jquery-latest.min.js> - jQuery hosted (minified) * <https://code.jquery.com/jquery-latest.js> - jQuery hosted (uncompressed) * <https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js> - Go...
441,420
<p>Compiler error <a href="http://msdn.microsoft.com/en-us/library/ms228656(VS.80).aspx" rel="noreferrer">CS0283</a> indicates that only the basic POD types (as well as strings, enums, and null references) can be declared as <code>const</code>. Does anyone have a theory on the rationale for this limitation? For instanc...
[ { "answer_id": 441428, "author": "Ed S.", "author_id": 1053, "author_profile": "https://Stackoverflow.com/users/1053", "pm_score": 1, "selected": false, "text": "<blockquote>\n <p>I believe that the concept of const is actually syntactic sugar in C#, and that it just replaces any uses o...
2009/01/14
[ "https://Stackoverflow.com/questions/441420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18529/" ]
Compiler error [CS0283](http://msdn.microsoft.com/en-us/library/ms228656(VS.80).aspx) indicates that only the basic POD types (as well as strings, enums, and null references) can be declared as `const`. Does anyone have a theory on the rationale for this limitation? For instance, it would be nice to be able to declare ...
From the [C# specification, chapter 10.4 - Constants](http://msdn.microsoft.com/en-us/library/aa645749(VS.71%29.aspx): *(10.4 in the C# 3.0 specification, 10.3 in the online version for 2.0)* > > A constant is a class member that represents a constant value: a value that can be computed at compile time. > > > ...
441,437
<p>My question is the antithesis of <a href="https://stackoverflow.com/questions/213901/in-perl-how-do-i-process-input-as-soon-as-it-arrives-instead-of-waiting-for-new">How do I process input immediately instead of waiting for newline</a>. I want to continue reading a growing log file, but stop after the file has not ...
[ { "answer_id": 441445, "author": "Dave Sherohman", "author_id": 18914, "author_profile": "https://Stackoverflow.com/users/18914", "pm_score": 4, "selected": true, "text": "<p>Have you tried <a href=\"http://search.cpan.org/~mgrabnar/File-Tail-0.99.3/Tail.pm\" rel=\"noreferrer\">File::Tai...
2009/01/14
[ "https://Stackoverflow.com/questions/441437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15168/" ]
My question is the antithesis of [How do I process input immediately instead of waiting for newline](https://stackoverflow.com/questions/213901/in-perl-how-do-i-process-input-as-soon-as-it-arrives-instead-of-waiting-for-new). I want to continue reading a growing log file, but stop after the file has not grown for a spe...
Have you tried [File::Tail](http://search.cpan.org/~mgrabnar/File-Tail-0.99.3/Tail.pm) to handle the actual tailing instead of trying to coerce <STDIN> to do the job? Or, if that piece does work, in what way is this failing?
441,448
<p>I'm using substring and IndexOf to locate a value within a string but my code doesn't work if the string (strOldValue) below contains any of the string in a different case. So if strOldValue contained Test or TEST then my substring fails. How would I add ToUpper in this scenario? Forgive my ignorance I'm new to .Net...
[ { "answer_id": 441452, "author": "Portman", "author_id": 1690, "author_profile": "https://Stackoverflow.com/users/1690", "pm_score": 2, "selected": false, "text": "<pre><code>String strValue \n = strOldValue.Substring(strOldValue.ToUpper().IndexOf(@\"TEST\"));\n</code></pre>\n\n<p>Not...
2009/01/14
[ "https://Stackoverflow.com/questions/441448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm using substring and IndexOf to locate a value within a string but my code doesn't work if the string (strOldValue) below contains any of the string in a different case. So if strOldValue contained Test or TEST then my substring fails. How would I add ToUpper in this scenario? Forgive my ignorance I'm new to .Net. ...
Using ToUpper, it would be done like this: ``` String strValue = strOldValue.Substring( strOldValue.ToUpper().IndexOf(@"TEST")); ``` However, the easiest would be to specify that the comparison should not be done case-sensitive: ``` String strValue = strOldValue.Substring(strOldValue.IndexOf(@"T...
441,496
<p>When sending the user to a checkout page, they are switched from <code>http://sitename.com</code> to <code>https://sitename.com</code>.</p> <p>As a result, <code>$_SESSION</code> variables are lost.</p> <p>The site has a valid SSL certificate which may or may not be of some use.</p>
[ { "answer_id": 441519, "author": "Allain Lalonde", "author_id": 2443, "author_profile": "https://Stackoverflow.com/users/2443", "pm_score": 0, "selected": false, "text": "<p>This may not be possible since the cookie seems to be getting lost. The browser you're using must think it's for ...
2009/01/14
[ "https://Stackoverflow.com/questions/441496", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5123/" ]
When sending the user to a checkout page, they are switched from `http://sitename.com` to `https://sitename.com`. As a result, `$_SESSION` variables are lost. The site has a valid SSL certificate which may or may not be of some use.
When you switch between the HTTP and HTTPS services on the same server, your HTTP session ID is not being passed to the HTTPS session. You can set it by passing the session ID from the HTTP page to the HTTPS page in one of three possible ways: From [PHP: session\_start](http://us.php.net/session_start): > > `session...
441,534
<p>I am looking for information on using a treeview in safethread manner. Does any one have experance with this or know of some online links to research.</p> <p>Thanks</p>
[ { "answer_id": 441551, "author": "Tamas Czinege", "author_id": 8954, "author_profile": "https://Stackoverflow.com/users/8954", "pm_score": 3, "selected": true, "text": "<p>From the <a href=\"http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.aspx\" rel=\"nofollow noref...
2009/01/14
[ "https://Stackoverflow.com/questions/441534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54009/" ]
I am looking for information on using a treeview in safethread manner. Does any one have experance with this or know of some online links to research. Thanks
From the [MSDN documentation on System.Windows.Forms.TreeView](http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.aspx): > > Any public **static** (**Shared** in Visual > Basic) members of this type are thread > safe. Any instance members are not > guaranteed to be thread safe. > > > Fortuna...
441,536
<p>I have a body of text returned from a search query, lets call it $body. Now, what I want to do is for the script to find the first occurrence of the search query, $query. I know I can find this first occurrence this with strripos. </p> <p>Once found, I want the script to return a couple of words before the first...
[ { "answer_id": 441560, "author": "Bob Fanger", "author_id": 19165, "author_profile": "https://Stackoverflow.com/users/19165", "pm_score": 2, "selected": false, "text": "<p>You could:</p>\n\n<pre><code>$words = explode(\" \", $body);\n</code></pre>\n\n<p>Creating an array of al the words ...
2009/01/14
[ "https://Stackoverflow.com/questions/441536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a body of text returned from a search query, lets call it $body. Now, what I want to do is for the script to find the first occurrence of the search query, $query. I know I can find this first occurrence this with strripos. Once found, I want the script to return a couple of words before the first occurrence o...
You could: ``` $words = explode(" ", $body); ``` Creating an array of al the words in $body. ``` $index = array_search($query, $words); $string = $words[$index - 1]." ".$words[$index]." ".$words[$index + 1]; ``` But you would get into trouble if the query consist out of more than 1 word. [explode](http://php....
441,552
<p>On <a href="https://stackoverflow.com/questions/438192/using-declaration-with-enum">this question</a>, there's <a href="https://stackoverflow.com/questions/438192/using-declaration-with-enum#439055">an answer</a> that states:</p> <blockquote> <p>You can use typedef to make Colour enumeration type accessible witho...
[ { "answer_id": 441626, "author": "Todd Gardner", "author_id": 54858, "author_profile": "https://Stackoverflow.com/users/54858", "pm_score": 2, "selected": false, "text": "<p>In standard c++, things to the left of \"::\" must be a class or namespace, enums don't count.</p>\n" }, { ...
2009/01/14
[ "https://Stackoverflow.com/questions/441552", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12193/" ]
On [this question](https://stackoverflow.com/questions/438192/using-declaration-with-enum), there's [an answer](https://stackoverflow.com/questions/438192/using-declaration-with-enum#439055) that states: > > You can use typedef to make Colour enumeration type accessible without specifying it's "full name". > > > >...
I tried the following code: ``` enum test { t1, t2, t3 }; void main() { test t = test::t1; } ``` Visual C++ 9 compiled it with the following warning: > > warning C4482: nonstandard extension > used: enum 'test' used in qualified > name > > > Doesn't look like it's standard.
441,559
<p>I'm writing a Windows Service for communication with a Serial Mag-stripe reader and a relay board (access control system).</p> <p>I run into problems where the code stops working (i get IOExceptions) after another program has "interrupted" the process by opening the same serial port as my service.</p> <p>Part of t...
[ { "answer_id": 441588, "author": "trampster", "author_id": 78561, "author_profile": "https://Stackoverflow.com/users/78561", "pm_score": 2, "selected": false, "text": "<p>You can't close someone elses connection to a port, the following code will never work:</p>\n\n<pre><code>if (serialP...
2009/01/14
[ "https://Stackoverflow.com/questions/441559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31491/" ]
I'm writing a Windows Service for communication with a Serial Mag-stripe reader and a relay board (access control system). I run into problems where the code stops working (i get IOExceptions) after another program has "interrupted" the process by opening the same serial port as my service. Part of the code is as fol...
@thomask Yes, Hyperterminal does in fact enable fAbortOnError in SetCommState's DCB, which explains for most of the IOExceptions thrown by the SerialPort object. Some PCs / handhelds also have UARTs that have the abort on error flag turned on by default - so it's imperative that a serial port's init routine clears it ...
441,565
<p>I want the title page to be changed so that a crawler can see it.</p> <p>The URL is of the format: public.sample.com/account/Disney</p> <p>I load a standard, global header include file using require()</p> <p>That's where the current default tags are defined.</p> <p>IF the URL is public.sample.com/account/Disney...
[ { "answer_id": 441573, "author": "John Boker", "author_id": 2847, "author_profile": "https://Stackoverflow.com/users/2847", "pm_score": 1, "selected": false, "text": "<p>im not sure exactly what you are looking for here, but to have a dynamic title you can do:</p>\n\n<pre><code>&lt;title...
2009/01/14
[ "https://Stackoverflow.com/questions/441565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43980/" ]
I want the title page to be changed so that a crawler can see it. The URL is of the format: public.sample.com/account/Disney I load a standard, global header include file using require() That's where the current default tags are defined. IF the URL is public.sample.com/account/Disney, I would like the tag to read, ...
Super simple example to get you started. ``` <title><?php if ( preg_match('/([^\/]+)\/([^\/]+)$/', $_SERVER['PHP_SELF'], $matches) ) { list($dummy, $profileType, $profileName) = $matches; $safeProfileType = htmlentities($profileType); $safeProfileName = htmlentities ($profileName); echo "This is an $sa...
441,568
<p>I'm playing around with gmock and noticed it contains this line:</p> <pre><code>#include &lt;tuple&gt; </code></pre> <p>I would have expected <code>tuple.h</code>.</p> <p>When is it okay to exclude the extension, and does it give the directive a different meaning? </p>
[ { "answer_id": 441578, "author": "Ferruccio", "author_id": 4086, "author_profile": "https://Stackoverflow.com/users/4086", "pm_score": 4, "selected": false, "text": "<p>If the file is named <code>tuple</code> then you need to <code>#include &lt;tuple&gt;</code>\nif it's named <code>tuple...
2009/01/14
[ "https://Stackoverflow.com/questions/441568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23071/" ]
I'm playing around with gmock and noticed it contains this line: ``` #include <tuple> ``` I would have expected `tuple.h`. When is it okay to exclude the extension, and does it give the directive a different meaning?
The C++ standard headers do not have a ".h" suffix. I believe the reason is that there were many, different pre-standard implementations that the standard would break. So instead of requiring that vendors change their exiting "iostream.h" (for example) header to be standards compliant (which would break their existing ...
441,576
<p>i have an <code>IList&lt;Animals&gt; farmAnimals;</code></p> <p>this list has three types,</p> <ul> <li>Cows</li> <li>Sheep</li> <li>Chickens</li> </ul> <p>how can i remove all the Chickens from the list using a <em>lambda query</em> or <em>linq-to-objects</em> so i have a separate list of chickens and the origin...
[ { "answer_id": 441589, "author": "Barbaros Alp", "author_id": 51734, "author_profile": "https://Stackoverflow.com/users/51734", "pm_score": 2, "selected": false, "text": "<pre><code>var chickens = farmAnimals.ToList().FindAll (c =&gt; c.Type == \"Chicken\");\nfarmAnimals.RemoveAll(a =&gt...
2009/01/14
[ "https://Stackoverflow.com/questions/441576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30674/" ]
i have an `IList<Animals> farmAnimals;` this list has three types, * Cows * Sheep * Chickens how can i remove all the Chickens from the list using a *lambda query* or *linq-to-objects* so i have a separate list of chickens and the original list now only has cows and sheep. Do i have to make three lists (the origina...
Assuming: ``` public abstract class Animal {} public class Chicken : Animal {} ``` you can do: ``` var chickens = animals.OfType<Chicken>().Cast<Animal>().ToList(); var nonChickens = animals.Except(chickens).ToList(); ``` **Edit** Any reasonable answer should be [O(n)](http://en.wikipedia.org/wiki/Big_O_notati...
441,581
<p>The best that I have been able to come up with is: </p> <p><code>strlen(preg_replace('/^([\\*]*)\s(.+)/',"$1",$line));</code><br> ^^That seems to give the length of the string.^^</p> <p>edit: I think that I should clarify that the character that I am trying to find is '*'</p>
[ { "answer_id": 441603, "author": "Michael Haren", "author_id": 29, "author_profile": "https://Stackoverflow.com/users/29", "pm_score": 2, "selected": false, "text": "<p>This is a little wonky but it might work--it counts the number of times the first character is repeated:</p>\n\n<pre><c...
2009/01/14
[ "https://Stackoverflow.com/questions/441581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26659/" ]
The best that I have been able to come up with is: `strlen(preg_replace('/^([\\*]*)\s(.+)/',"$1",$line));` ^^That seems to give the length of the string.^^ edit: I think that I should clarify that the character that I am trying to find is '\*'
preg\_match allows an output parameter which is filled with the matches, thus you can simply take the strlen of the match for the pattern /^\*\*/: ``` $matches = array(); preg_match("/^\**/", $string, $matches); $result = strlen($matches[0]) ; ``` ... ``` "***Hello world!*" -> 3 "Hello world!" -> 0 ```
441,599
<p>I have a camera that returns raw images that can easily be converted to a bitmap that can be saved to a file by the following C# method (that I did not write). From various sources, I have determined that the pictures have 8 bits per pixel, and may or may not be grayscale.</p> <pre><code>private void rawImgToBmp(by...
[ { "answer_id": 441888, "author": "erisu", "author_id": 47971, "author_profile": "https://Stackoverflow.com/users/47971", "pm_score": 1, "selected": false, "text": "<p>Typically I use CreateBitmap or CreateCompatibleBitmap to generate bitmaps in windows. I am unfamiliar with WinCE but the...
2009/01/14
[ "https://Stackoverflow.com/questions/441599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34910/" ]
I have a camera that returns raw images that can easily be converted to a bitmap that can be saved to a file by the following C# method (that I did not write). From various sources, I have determined that the pictures have 8 bits per pixel, and may or may not be grayscale. ``` private void rawImgToBmp(byte[] imgData, ...
This is the code that works for me. It is based on erisu's answer and [Wikipedia's description of the BMP format](http://en.wikipedia.org/wiki/BMP_file_format). For anyone else using this answer, I recommend that you understand the BMP format as fully as possible, so you can adjust the header fields accordingly. The ...
441,600
<p>How do you write a number with two decimal places for sql server?</p>
[ { "answer_id": 441606, "author": "AAA", "author_id": 1977, "author_profile": "https://Stackoverflow.com/users/1977", "pm_score": 5, "selected": false, "text": "<p>Generally you can define the precision of a number in SQL by defining it with parameters. For most cases this will be <code>N...
2009/01/14
[ "https://Stackoverflow.com/questions/441600", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do you write a number with two decimal places for sql server?
Try this ```sql SELECT CONVERT(DECIMAL(10,2),YOURCOLUMN) ``` such as ```sql SELECT CONVERT(DECIMAL(10,2),2.999999) ``` will result in output `3.00` ![enter image description here](https://i.stack.imgur.com/jmOD8.png)
441,614
<p>Is there any way to ask msbuild what build targets provided msbuild file support? If there is no way to do it in command prompt? May be it could be done programmatically?</p> <p>Are there no way to do it besides parsing msbuild XML?</p>
[ { "answer_id": 484528, "author": "Zac Thompson", "author_id": 58549, "author_profile": "https://Stackoverflow.com/users/58549", "pm_score": 4, "selected": false, "text": "<p>Certainly MS provides the api to do this without parsing the xml yourself. Look up microsoft.build.buildengine</p...
2009/01/14
[ "https://Stackoverflow.com/questions/441614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2313/" ]
Is there any way to ask msbuild what build targets provided msbuild file support? If there is no way to do it in command prompt? May be it could be done programmatically? Are there no way to do it besides parsing msbuild XML?
Updated for .NET Framework 4, since the above has been deprecated. Import microsoft.build.dll and code is as follows: ``` using System; using Microsoft.Build.Evaluation; class MyTargets { static void Main(string[] args) { Project project = new Project(args[0]); foreach (string target in project.Targets.Key...
441,618
<p>Say a user clicks on a link to download a file. The user gets the save as dialogue box but then clicks on cancel. How do you detect this? Meaning if the user hits the cancel link or doesn't get the whole file, the server should not record that the file was downloaded.</p>
[ { "answer_id": 441652, "author": "Sean", "author_id": 29941, "author_profile": "https://Stackoverflow.com/users/29941", "pm_score": 0, "selected": false, "text": "<p>Are you talking about any file? If it's a program you can have it make a call to the server on install? Other than that I ...
2009/01/14
[ "https://Stackoverflow.com/questions/441618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/438/" ]
Say a user clicks on a link to download a file. The user gets the save as dialogue box but then clicks on cancel. How do you detect this? Meaning if the user hits the cancel link or doesn't get the whole file, the server should not record that the file was downloaded.
In the past I have done this: ``` header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0...
441,622
<p>Form validation for check boxes only seems to be working in IE....? Anyone have a sample of it working in FF?</p> <p>Thanks.</p>
[ { "answer_id": 441632, "author": "AAA", "author_id": 1977, "author_profile": "https://Stackoverflow.com/users/1977", "pm_score": 0, "selected": false, "text": "<p>Um...Your question isn't exactly a clear one.</p>\n\n<p>If it's form validation as in checking then shouldn't you be doing th...
2009/01/14
[ "https://Stackoverflow.com/questions/441622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52256/" ]
Form validation for check boxes only seems to be working in IE....? Anyone have a sample of it working in FF? Thanks.
``` var isChecked = document.forms['myform'].elements['mycheckbox'].checked; if (!isChecked) { alert('You must agree'); } ```
441,631
<p>Is there a way to detect a right click followed by paste with JavaScript on IE and Firefox ?</p> <p>Update:</p> <p>I decided to use Jquery to do it:</p> <pre><code>$('#controlId').bind('paste', null, function() { // code }); </code></pre> <p>It's not exactly what I was looking (because it gets fired on 'ctrl...
[ { "answer_id": 441647, "author": "epascarello", "author_id": 14104, "author_profile": "https://Stackoverflow.com/users/14104", "pm_score": 4, "selected": true, "text": "<p>With IE you have onpaste</p>\n\n<p>With Mozilla you can look into\noninput\nand</p>\n\n<pre><code>elementReference.a...
2009/01/14
[ "https://Stackoverflow.com/questions/441631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1560/" ]
Is there a way to detect a right click followed by paste with JavaScript on IE and Firefox ? Update: I decided to use Jquery to do it: ``` $('#controlId').bind('paste', null, function() { // code }); ``` It's not exactly what I was looking (because it gets fired on 'ctrl + v' as well as in 'right click + paste...
With IE you have onpaste With Mozilla you can look into oninput and ``` elementReference.addEventListener("DOMCharacterDataModified", function(e){ foo(e);}, false); ``` There is no easy as pie solution. Eric
441,636
<p>I want to write some javascript and have it call into the DOM for a page I am loading from a 3rd party domain. Can this be done? <a href="https://stackoverflow.com/questions/335817">This</a> looks like what I've already tried using <code>IFRAME</code> but it would seem that doesn't work. Is these some other way like...
[ { "answer_id": 441660, "author": "epascarello", "author_id": 14104, "author_profile": "https://Stackoverflow.com/users/14104", "pm_score": 1, "selected": false, "text": "<p>JavaScript has a same domain policy. You are not going to be able to access the other domain. It is to protect you ...
2009/01/14
[ "https://Stackoverflow.com/questions/441636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
I want to write some javascript and have it call into the DOM for a page I am loading from a 3rd party domain. Can this be done? [This](https://stackoverflow.com/questions/335817) looks like what I've already tried using `IFRAME` but it would seem that doesn't work. Is these some other way like having FF run some javas...
If I understand the question correctly, you probably won't be able to do it using Javascript alone, because of the domain restriction that you experienced. However, if you have some knowlege on using shell scripts, or any scripting language, it should be no problem, all you need to do is invoke the good old curl. Exam...
441,651
<p>I have a list of email addresses, and I need to send an email notification to each address. I'd like to do this in blocks of 25 addresses at a time. Is there any quick way in a functional language like F# to "fold" (concatenate) 25 emails addresses together... each separated by a semicolon. I know there is the Strin...
[ { "answer_id": 441846, "author": "Juliet", "author_id": 40516, "author_profile": "https://Stackoverflow.com/users/40516", "pm_score": 0, "selected": false, "text": "<p>Its not overly pretty, but it works:</p>\n\n<pre><code>let breakWords separator groupSize (input : string) =\n let wo...
2009/01/14
[ "https://Stackoverflow.com/questions/441651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36590/" ]
I have a list of email addresses, and I need to send an email notification to each address. I'd like to do this in blocks of 25 addresses at a time. Is there any quick way in a functional language like F# to "fold" (concatenate) 25 emails addresses together... each separated by a semicolon. I know there is the String.S...
Here's a way to break into groups of at most N: ``` // break a sequence up into a sequence of arrays, // each of length at most 'n' let Break n (s:seq<_>) = seq { use e = s.GetEnumerator() while e.MoveNext() do let i = ref 0 yield [| yield e.Current ...
441,676
<p>I have a base form. I place Ok and Cancel buttons on the bottom right of the form and anchor them Bottom and Right.</p> <p>The inherited form does not honor the anchor properties of the Ok and Cancel buttons. Here are the exact steps to repro.</p> <p>1- Create a base form with a button located at bottom/right. ...
[ { "answer_id": 441703, "author": "Ray", "author_id": 233, "author_profile": "https://Stackoverflow.com/users/233", "pm_score": 1, "selected": false, "text": "<p>It works for me.</p>\n\n<p>How are you creating the inherited form? I go </p>\n\n<ol>\n<li>Build</li>\n<li>Add New -> Windows F...
2009/01/14
[ "https://Stackoverflow.com/questions/441676", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9382/" ]
I have a base form. I place Ok and Cancel buttons on the bottom right of the form and anchor them Bottom and Right. The inherited form does not honor the anchor properties of the Ok and Cancel buttons. Here are the exact steps to repro. 1- Create a base form with a button located at bottom/right. Anchor it there at B...
Mmm followed your steps and worked perfectly... Make sure that the inherited form isn't overriding some properties in the designer... Mine "Inherited Form" only has this: ``` private void InitializeComponent() { this.SuspendLayout(); // // Form2 // this.AutoScaleDimensions = new System.Drawing.S...
441,680
<p>How can I generate a assembly qualified type name?</p> <p>For an example, when configuring a membership provider, I would have to provide a assembly qualified type name for "SqlMembershipProvider" (in this example, i have copied the below configuration from somewhere) in "type" attribute.</p> <p>How do you generat...
[ { "answer_id": 441700, "author": "Andrew Hare", "author_id": 34211, "author_profile": "https://Stackoverflow.com/users/34211", "pm_score": 2, "selected": false, "text": "<p>The easiest way to find that information is to use <a href=\"http://www.red-gate.com/products/reflector/\" rel=\"no...
2009/01/14
[ "https://Stackoverflow.com/questions/441680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4035/" ]
How can I generate a assembly qualified type name? For an example, when configuring a membership provider, I would have to provide a assembly qualified type name for "SqlMembershipProvider" (in this example, i have copied the below configuration from somewhere) in "type" attribute. How do you generate that assembly q...
This is a nice [handy tool](http://www.lennybacon.com/CommentView,guid,d571c376-42d0-427a-a7d0-ef9d22eab52c.aspx) (shell extension with source code) for copying the fully qualified name to clipboard by right clicking on any assembly. **Update**: After seeing the comment from dance2die, thought of putting together a sa...
441,687
<p>I want to find the first span element after class counter, in code something like this:</p> <pre><code>&lt;div class="counter"&gt;&lt;/div&gt; &lt;p&gt;&lt;/p&gt; &lt;span&gt;&lt;/span&gt; </code></pre> <p>It seems like the next() function only finds the immediate next element, so something like this:</p> <pre><c...
[ { "answer_id": 441724, "author": "Allain Lalonde", "author_id": 2443, "author_profile": "https://Stackoverflow.com/users/2443", "pm_score": 1, "selected": false, "text": "<p>I'm not sure that the closest method will do the trick, but if so... maybe you can extract the closest method from...
2009/01/14
[ "https://Stackoverflow.com/questions/441687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29595/" ]
I want to find the first span element after class counter, in code something like this: ``` <div class="counter"></div> <p></p> <span></span> ``` It seems like the next() function only finds the immediate next element, so something like this: ``` $(".counter").next("span") ``` Won't work. The way I have been usin...
I think your method is the best way. And if you feel it doesn't look good just turn it into a plugin: ``` jQuery.fn.firstAfter = function(filter){ return this.nextAll(filter).eq(0); } ```
441,689
<p>I would like users to be able to double click anywhere on the screen to display a form that allows submission of feedback about that very spot. </p> <p>I can think of 2 solutions:</p> <ol> <li>Store X,Y coordinates. Had to rule this out since X,Y coordinates aren't supported on all browsers.</li> <li><p>Use Jquery...
[ { "answer_id": 441694, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 2, "selected": false, "text": "<p>you should be able to write/acquire a hit-test function to see what DOM element(s) are under the mouse cursor when...
2009/01/14
[ "https://Stackoverflow.com/questions/441689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26180/" ]
I would like users to be able to double click anywhere on the screen to display a form that allows submission of feedback about that very spot. I can think of 2 solutions: 1. Store X,Y coordinates. Had to rule this out since X,Y coordinates aren't supported on all browsers. 2. Use Jquery to bind an exhaustive list o...
you should be able to write/acquire a hit-test function to see what DOM element(s) are under the mouse cursor when it is double-clicked, and then associate the comments/feedback text with the ID of the selected element this assumes that all of your DOM elements have unique IDs (and that your users know that they can ...
441,692
<p>Let's say you have a domain entity User and you want to support the ability for a User to add an item to their shopping cart. Now, we want to make sure that the items in the shopping cart are unique, so we create the following function inside the User class:</p> <pre><code>function AddItemToCart(Item item) { /...
[ { "answer_id": 441695, "author": "Jobo", "author_id": 51915, "author_profile": "https://Stackoverflow.com/users/51915", "pm_score": 0, "selected": false, "text": "<p>Keep the method as is, Then create a service class to handle the transaction. When the call is made to the service class m...
2009/01/14
[ "https://Stackoverflow.com/questions/441692", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1574/" ]
Let's say you have a domain entity User and you want to support the ability for a User to add an item to their shopping cart. Now, we want to make sure that the items in the shopping cart are unique, so we create the following function inside the User class: ``` function AddItemToCart(Item item) { // Add business ...
Logic that is part of the domain logic of the User should stay in the user. This may or may not involve injecting the User entity with a service. I think it depends on whether the service is part of the business logic of the User class, and whether doing this adheres to your ubiquitous language. I would write this: `...
441,739
<p>Can a single regex be used to valdate urls and match all the parts, I have been working on one and what I have come up with so far is:</p> <pre><code>(?:(?P&lt;scheme&gt;[a-z]*?)://)?(?:(?P&lt;username&gt;.*?):?(?P&lt;password&gt;.*?)?@)?(?P&lt;hostname&gt;.*?)/(?:(?:(?P&lt;path&gt;.*?)\?)?(?P&lt;file&gt;.*?\.[a-z]...
[ { "answer_id": 441781, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 4, "selected": true, "text": "<p>Modified version of <a href=\"https://stackoverflow.com/questions/27745/getting-parts-of-a-url-regex#309360\">mingfai's ...
2009/01/14
[ "https://Stackoverflow.com/questions/441739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/115/" ]
Can a single regex be used to valdate urls and match all the parts, I have been working on one and what I have come up with so far is: ``` (?:(?P<scheme>[a-z]*?)://)?(?:(?P<username>.*?):?(?P<password>.*?)?@)?(?P<hostname>.*?)/(?:(?:(?P<path>.*?)\?)?(?P<file>.*?\.[a-z]{1,6})?(?:(?:(?P<query>.*?)#?)?(?P<fragment>.*?)?)...
Modified version of [mingfai's regular expression](https://stackoverflow.com/questions/27745/getting-parts-of-a-url-regex#309360): ``` /^((?P<scheme>https?|ftp):\/)?\/?((?P<username>.*?)(:(?P<password>.*?)|)@)?(?P<hostname>[^:\/\s]+)(?P<port>:([^\/]*))?(?P<path>(\/\w+)*\/)(?P<filename>[-\w.]+[^#?\s]*)?(?P<query>\?([^#...
441,744
<p>C++ is unable to make a template out of a typedef or typedef a templated class. I know if I inherit and make my class a template, it will work.</p> <p>Examples:</p> <pre><code>// Illegal template &lt;class T&gt; typedef MyVectorType vector&lt;T&gt;; //Valid, but advantageous? template &lt;class T&gt; class MyVec...
[ { "answer_id": 441776, "author": "Dave Ray", "author_id": 40310, "author_profile": "https://Stackoverflow.com/users/40310", "pm_score": 3, "selected": false, "text": "<p>Inheritance is not what you want. A more idiomatic approach to emulating a templated typedef is this:</p>\n\n<pre><cod...
2009/01/14
[ "https://Stackoverflow.com/questions/441744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23528/" ]
C++ is unable to make a template out of a typedef or typedef a templated class. I know if I inherit and make my class a template, it will work. Examples: ``` // Illegal template <class T> typedef MyVectorType vector<T>; //Valid, but advantageous? template <class T> class MyVectorType : public vector<T> { }; ``` Is...
C++0x will add template typedefs using the `using` keyword. Your solution declares a new type, not a type "alias", e.g. you cannot initialize a `MyVectorType &` (reference) with a `vector<T>`. This might not be a problem for you, but if it is, but you don't want to reference vector in your code, you can do: ``` templ...
441,755
<p>I need to write some javascript to strip the hostname:port part from a url, meaning I want to extract the path part only.</p> <p>i.e. I want to write a function getPath(url) such that getPath("<a href="http://host:8081/path/to/something" rel="noreferrer">http://host:8081/path/to/something</a>") returns "/path/to/so...
[ { "answer_id": 441764, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 5, "selected": true, "text": "<p>Quick 'n' dirty:</p>\n\n<pre>^[^#]*?://.*?(/.*)$</pre>\n\n<p>Everything after the hostname and port (including the initi...
2009/01/14
[ "https://Stackoverflow.com/questions/441755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18494/" ]
I need to write some javascript to strip the hostname:port part from a url, meaning I want to extract the path part only. i.e. I want to write a function getPath(url) such that getPath("<http://host:8081/path/to/something>") returns "/path/to/something" Can this be done using regular expressions?
Quick 'n' dirty: ``` ^[^#]*?://.*?(/.*)$ ``` Everything after the hostname and port (including the initial /) is captured in the first group.
441,758
<p>We have various spreadsheets that employ deliciously complicated macros and third party extensions to produce complicated models. I'm working on a project that involves slightly tweaking various inputs and seeing the results. Rather than doing this by hand or writing VBA, I'd like to see if I can write a python sc...
[ { "answer_id": 441786, "author": "igowen", "author_id": 53924, "author_profile": "https://Stackoverflow.com/users/53924", "pm_score": 4, "selected": false, "text": "<p>I've done this by using <a href=\"http://python.net/crew/mhammond/win32/Downloads.html\" rel=\"noreferrer\">pywin32</a>....
2009/01/14
[ "https://Stackoverflow.com/questions/441758", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54873/" ]
We have various spreadsheets that employ deliciously complicated macros and third party extensions to produce complicated models. I'm working on a project that involves slightly tweaking various inputs and seeing the results. Rather than doing this by hand or writing VBA, I'd like to see if I can write a python script ...
For controlling Excel, use pywin32, like @igowen suggests. Note that it is possible to use static dispatch. Use `makepy.py` from the pywin32 project to create a python module with the python wrappers. Using the generated wrappers simplifies development, since for instance ipython gives you tab completion and help duri...
441,760
<p>Let's say I have the following objects: </p> <pre><code>squirrel_table - name - country_of_origin - id nut_table - id - squirrel_who_owns_me[fk to squirrel] </code></pre> <p>I want to retrieve a list of all squirrels in a particular country. The returned squirrel objects can be in a QuerySet, but do no...
[ { "answer_id": 442064, "author": "James Bennett", "author_id": 28070, "author_profile": "https://Stackoverflow.com/users/28070", "pm_score": 3, "selected": true, "text": "<p>You probably want to read through <a href=\"http://docs.djangoproject.com/en/dev/ref/models/querysets/#extra-selec...
2009/01/14
[ "https://Stackoverflow.com/questions/441760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45226/" ]
Let's say I have the following objects: ``` squirrel_table - name - country_of_origin - id nut_table - id - squirrel_who_owns_me[fk to squirrel] ``` I want to retrieve a list of all squirrels in a particular country. The returned squirrel objects can be in a QuerySet, but do not need to be. A list will ...
You probably want to read through [the documentation for the "extra()" method](http://docs.djangoproject.com/en/dev/ref/models/querysets/#extra-select-none-where-none-params-none-tables-none-order-by-none-select-params-none), which includes an example of a similar "select something else and append it onto each object" ...
441,814
<p>Does anybody know of a fully thread-safe <code>shared_ptr</code> implementation? E.g. boost implementation of <code>shared_ptr</code> is thread-safe for the targets (refcounting) and also safe for simultaneous <code>shared_ptr</code> instance reads, but not writes or for read/write.</p> <p>(see <a href="http://www....
[ { "answer_id": 441858, "author": "Todd Gardner", "author_id": 54858, "author_profile": "https://Stackoverflow.com/users/54858", "pm_score": 2, "selected": false, "text": "<p>Simultaneous write to a built-in pointer is certainly not thread safe. Consider the implications of writing to the...
2009/01/14
[ "https://Stackoverflow.com/questions/441814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34220/" ]
Does anybody know of a fully thread-safe `shared_ptr` implementation? E.g. boost implementation of `shared_ptr` is thread-safe for the targets (refcounting) and also safe for simultaneous `shared_ptr` instance reads, but not writes or for read/write. (see [Boost docs](http://www.boost.org/doc/libs/1_37_0/libs/smart_pt...
Adding the necessary barriers for such a fully thread-safe shared\_ptr implementation would likely impact performance. Consider the following race (note: pseudocode abounds): Thread 1: global\_ptr = A; Thread 2: global\_ptr = B; Thread 3: local\_ptr = global\_ptr; If we break this down into its constituent opera...
441,821
<p><strong>How do you copy an event handler from one element to another?</strong> For example:</p> <pre><code>$('#firstEl') .click(function() { alert("Handled!"); }) ; // here's where the magic happens $('#secondEl').click = $('#firstEl').click; // ???? </code></pre> <p>Note that the second element ...
[ { "answer_id": 441835, "author": "Prestaul", "author_id": 5628, "author_profile": "https://Stackoverflow.com/users/5628", "pm_score": 2, "selected": false, "text": "<p>You can't easily (and probably shouldn't) \"copy\" the event. What you can do is use the same function to handle each:<...
2009/01/14
[ "https://Stackoverflow.com/questions/441821", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
**How do you copy an event handler from one element to another?** For example: ``` $('#firstEl') .click(function() { alert("Handled!"); }) ; // here's where the magic happens $('#secondEl').click = $('#firstEl').click; // ???? ``` Note that the second element is being processed at a different time ...
This question was already answered but for future reference: you could copy them by iterating the events of the original element and binding their handlers to the target. **> see edit below!** ``` // iterate event types of original $.each($('#original').data('events'), function() { // iterate registered handler of ...
441,831
<p>Ignoring programming style and design, is it "safe" to call delete on a variable allocated on the stack?</p> <p>For example:</p> <pre><code> int nAmount; delete &amp;nAmount; </code></pre> <p>or</p> <pre><code>class sample { public: sample(); ~sample() { delete &amp;nAmount;} int nAmount; } </co...
[ { "answer_id": 441837, "author": "Mr Fooz", "author_id": 25050, "author_profile": "https://Stackoverflow.com/users/25050", "pm_score": 8, "selected": true, "text": "<p><a href=\"https://msdn.microsoft.com/en-us/library/h6227113(v=vs.140).aspx\" rel=\"noreferrer\">No</a>, it is not safe t...
2009/01/14
[ "https://Stackoverflow.com/questions/441831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54883/" ]
Ignoring programming style and design, is it "safe" to call delete on a variable allocated on the stack? For example: ``` int nAmount; delete &nAmount; ``` or ``` class sample { public: sample(); ~sample() { delete &nAmount;} int nAmount; } ```
[No](https://msdn.microsoft.com/en-us/library/h6227113(v=vs.140).aspx), it is not safe to call `delete` on a stack-allocated variable. You should only call `delete` on things created by `new`. * For each `malloc` or `calloc`, there should be exactly one `free`. * For each `new` there should be exactly one `delete`. * ...
441,869
<p>I have a nullable DateTime column in my SQL Server 2005 table called DateTimeDeleted.</p> <p>I'd like to have a BIT type computed column that is 1 if DateTimeDeleted is not null, otherwise 0. However, I can't seem to get the syntax for the formula correct.</p> <p>I've tried:</p> <pre><code>(TsDeleted IS NULL) = 0...
[ { "answer_id": 441877, "author": "Jon", "author_id": 25111, "author_profile": "https://Stackoverflow.com/users/25111", "pm_score": 2, "selected": false, "text": "<p>I think this should work:</p>\n\n<pre><code>update table\nset IsDeleted = case when DateTimeDeleted is null then 0 else 1 e...
2009/01/14
[ "https://Stackoverflow.com/questions/441869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14537/" ]
I have a nullable DateTime column in my SQL Server 2005 table called DateTimeDeleted. I'd like to have a BIT type computed column that is 1 if DateTimeDeleted is not null, otherwise 0. However, I can't seem to get the syntax for the formula correct. I've tried: ``` (TsDeleted IS NULL) = 0 ``` but it gives me a syn...
``` Alter Table MyTableName Add IsDeleted As (Case When [DateTimeDeleted] Is Null Then (0) Else (1) End) ``` This will output as an integer... If you really want it to be a bit, then: ``` Alter Table MyTableName Add IsDeleted As cast( (Case When [DateTimeDeleted] Is Null Then (0) El...
441,893
<p>Pretty straightforward, but I just want to know which is faster.</p> <p>I think simply multiplying a number by <code>-1</code> is much faster than calling a predefined method, provided that you are sure that value is negative.</p> <p>But if that's the case then what is the <code>abs()</code> function for? Is it si...
[ { "answer_id": 441915, "author": "Jonathan Lonowski", "author_id": 15031, "author_profile": "https://Stackoverflow.com/users/15031", "pm_score": 4, "selected": false, "text": "<p>I suppose it depends on the implementation, but <code>Math.abs</code> could be as simple as:</p>\n\n<pre><cod...
2009/01/14
[ "https://Stackoverflow.com/questions/441893", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24744/" ]
Pretty straightforward, but I just want to know which is faster. I think simply multiplying a number by `-1` is much faster than calling a predefined method, provided that you are sure that value is negative. But if that's the case then what is the `abs()` function for? Is it simply for making sure that the value ret...
*Updated August, 2012*: I did some profiling with these implementations: ```js /* Test 1: */ b = Math.abs(a); /* Test 2: */ b = abs(a); //local copy: abs = Math.abs; /* Test 3: */ b = a < 0 ? a * -1 : a; /* Test 4: */ b = a < 0 ? -a : a; ``` I got the following result on Windows 7. Values are normalized after the f...
441,931
<p>I have been experimenting with directory structures and am currently using the one below:</p> <pre> | |_projects__ | | | |_blog.com_ | | |_mockups | | |_user stories | | |_.... | | | |_noteapp__ | ...
[ { "answer_id": 442069, "author": "kyle", "author_id": 2993381, "author_profile": "https://Stackoverflow.com/users/2993381", "pm_score": 3, "selected": false, "text": "<p>I'm a big fan of your more granular leaves, but at the top level I perform much better having the filesystem organized...
2009/01/14
[ "https://Stackoverflow.com/questions/441931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34991/" ]
I have been experimenting with directory structures and am currently using the one below: ``` | |_projects__ | | | |_blog.com_ | | |_mockups | | |_user stories | | |_.... | | | |_noteapp__ | ...
I'm a big fan of your more granular leaves, but at the top level I perform much better having the filesystem organized by project. I'm much more likely to be in a code directory and think, "Hey, what was the spec for this?" than be in the spec directory and think, "Which project did I want the spec for?" To rearrange y...
441,939
<p>I am joining three tables (performing a full outer join) so that I can retrieve all the records from all the tables. Problem that I am facing is with the order in which I join tables.</p> <p>Table Information</p> <p><a href="http://img235.imageshack.us/img235/7980/tableinfoow1.png" rel="nofollow noreferrer">alt te...
[ { "answer_id": 441957, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 0, "selected": false, "text": "<p>That's the definition of a FULL OUTER JOIN (which, when used, is almost invariably an indication of a poor design - I...
2009/01/14
[ "https://Stackoverflow.com/questions/441939", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38997/" ]
I am joining three tables (performing a full outer join) so that I can retrieve all the records from all the tables. Problem that I am facing is with the order in which I join tables. Table Information [alt text http://img235.imageshack.us/img235/7980/tableinfoow1.png](http://img235.imageshack.us/img235/7980/tableinf...
If this is what you need: ``` TEAM LEVEL Value1 Value2 Value3 A 1 1 NULL NULL B 1 NULL 1000 900 ``` Then you can achieve that with the following: ``` SELECT [TEAM], [LEVEL], MAX(v1) Value1, MAX(v2) Value2, MAX(v3) Value3 FROM ( SELECT [TEAM], [LEVEL], Value1 v1, NULL v2, NULL...
441,942
<p>I have a truckload of xsd with plain SQL queries. I want to migrate to LINQ.</p> <p>Is there a automated way to generate LINQ equivalents from SQL statements?</p>
[ { "answer_id": 442080, "author": "Tim Jarvis", "author_id": 10387, "author_profile": "https://Stackoverflow.com/users/10387", "pm_score": 1, "selected": false, "text": "<p>There are no libraries out there that I know of, but it would be possible to do with some work.</p>\n\n<p>I don't th...
2009/01/14
[ "https://Stackoverflow.com/questions/441942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30546/" ]
I have a truckload of xsd with plain SQL queries. I want to migrate to LINQ. Is there a automated way to generate LINQ equivalents from SQL statements?
If you just care about getting the results of your LINQ to SQL queries into `IEnumberable` or similar then you can wrap them in an `ExecuteQuery`: ``` var Space = db.ExecuteQuery<Astronaut>("SELECT TOP 10 * FROM dbo.Astronauts"); ``` If you want to actually have proper LINQ queries though then maybe an option, at le...
441,946
<p>I need to declare the query variable outside the switch statement that way I would only have one variable that would handle different result of the LINQ Query. Please see the code below. Problem here is that I cannot infer a variable without initializing it</p> <pre><code>var query; Switch(filter) { case 1: v...
[ { "answer_id": 441956, "author": "ScottS", "author_id": 51851, "author_profile": "https://Stackoverflow.com/users/51851", "pm_score": 4, "selected": true, "text": "<p>You probably want <code>IEnumerable&lt;Customer&gt;</code> or <code>IQueryable&lt;Customer&gt;</code> instead of var.</p>...
2009/01/14
[ "https://Stackoverflow.com/questions/441946", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54890/" ]
I need to declare the query variable outside the switch statement that way I would only have one variable that would handle different result of the LINQ Query. Please see the code below. Problem here is that I cannot infer a variable without initializing it ``` var query; Switch(filter) { case 1: var query = fro...
You probably want `IEnumerable<Customer>` or `IQueryable<Customer>` instead of var.
441,965
<pre><code>public myReturnObj MethodA(System.Linq.IGrouping&lt;string, MyObject&gt; group){ ... foreach (MyObject o in group) { //business process } ... return myReturnObj; } </code></pre> <p>I want to set up NUnit Mock object for passing as a paramter and then check the result of MethodA in my unittest.</p> <p>...
[ { "answer_id": 441997, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 2, "selected": false, "text": "<p>You might mock up a IGrouping(string, MyObject) the same way you'd mock up any interface?</p>\n\n<pre><code>DynamicMock myM...
2009/01/14
[ "https://Stackoverflow.com/questions/441965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35682/" ]
``` public myReturnObj MethodA(System.Linq.IGrouping<string, MyObject> group){ ... foreach (MyObject o in group) { //business process } ... return myReturnObj; } ``` I want to set up NUnit Mock object for passing as a paramter and then check the result of MethodA in my unittest. How do I mock this IGrouping?
You might mock up a IGrouping(string, MyObject) the same way you'd mock up any interface? ``` DynamicMock myMockGrouping = new DynamicMock(typeof IGrouping<string, MyObject>); ``` Or, you could go with a more live version: ``` List<MyObject> inputs = GetInputs(); IGrouping<string, MyObject> myLiveGrouping = inputs ...
441,976
<p>I do a lot of data analysis scripting, comparing two objects or strings to determine differences or come up with gaps that need to be filled.<br> When you're in a loop, comparing object a to object b, do you have a preferred coding standard that makes sense (i.e., it is self-documenting) and can travel nicely to oth...
[ { "answer_id": 441985, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 2, "selected": false, "text": "<p>I think <strong>variable names are not at all irrelevant</strong>, but also that there's no good generic name tha...
2009/01/14
[ "https://Stackoverflow.com/questions/441976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50640/" ]
I do a lot of data analysis scripting, comparing two objects or strings to determine differences or come up with gaps that need to be filled. When you're in a loop, comparing object a to object b, do you have a preferred coding standard that makes sense (i.e., it is self-documenting) and can travel nicely to other c...
Well, if you need 2 variable names, let's call them a and b, then you probably have 3 objects involved: self, a, b. Now, that's quite a bunch for me, I try to keep things smaller. So, consider your first example: ``` for (String a : TreeMapvar) { // Read b from data source if (a.equals(b)) { ...
441,983
<p>I have a class with implements 2 interfaces and inherits 1 class. So, generally it looks like this:</p> <pre><code>class T : public A, public IB, public IC { }; </code></pre> <p>There is one point in the code where I have an <code>IB *</code>, but could really use an <code>A *</code>. I was hoping that a dynamic c...
[ { "answer_id": 441987, "author": "Eclipse", "author_id": 8701, "author_profile": "https://Stackoverflow.com/users/8701", "pm_score": 2, "selected": false, "text": "<p>Cast to a T* first then to A:</p>\n\n<pre><code>IB *b_ptr = new T; // it's really more complicated, but serves the exampl...
2009/01/14
[ "https://Stackoverflow.com/questions/441983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13430/" ]
I have a class with implements 2 interfaces and inherits 1 class. So, generally it looks like this: ``` class T : public A, public IB, public IC { }; ``` There is one point in the code where I have an `IB *`, but could really use an `A *`. I was hoping that a dynamic cast would like this: ``` IB *b_ptr = new T; // ...
I finally figured it out, [Daniel Paull](https://stackoverflow.com/questions/441983/dynamic-cast-with-interfaces#442025) was correct in that a "sideways `dybnamic_cast`" should be allowed. My problem was because my code is involving shared libraries. The typeinfo from PluginA was not available in PluginB. My solution w...
441,990
<pre><code>import java.util.Iterator; import org.dom4j.Document; import org.dom4j.DocumentHelper; import org.dom4j.Element; import org.dom4j.io.XMLWriter; public class Main { public static void main(String[] args){ Company cp17 = new Company(); Person ps1 = new Person("Barry","15900000000"); ...
[ { "answer_id": 442301, "author": "bobince", "author_id": 18936, "author_profile": "https://Stackoverflow.com/users/18936", "pm_score": 2, "selected": false, "text": "<p>Use the standard DOM method Document.importNode to bring content from one document into another. <a href=\"http://www.d...
2009/01/14
[ "https://Stackoverflow.com/questions/441990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` import java.util.Iterator; import org.dom4j.Document; import org.dom4j.DocumentHelper; import org.dom4j.Element; import org.dom4j.io.XMLWriter; public class Main { public static void main(String[] args){ Company cp17 = new Company(); Person ps1 = new Person("Barry","15900000000"); Per...
Use the standard DOM method Document.importNode to bring content from one document into another. <http://www.dom4j.org/dom4j-1.6.1/apidocs/org/dom4j/dom/DOMDocument.html#importNode%28org.w3c.dom.Node,%20boolean%29> ``` Element companyElement2= document2.importNode(companyElement, true); companies.appendChild(companyEl...
442,009
<p>I have a control with an undo feature, when the user press Escape the control will revert the original value.</p> <p>The problem is when I integrated my control to DataGridView. The DataGridView "eats" the Escape key, hence my control cannot detect the Escape key.</p> <p>When I put "return true" on EditingControl...
[ { "answer_id": 442029, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>You should \"return true\" only when Keys.KeyCode == Keys.Escape; <br>otherwise return \n!dataGridViewWantsInputKey.</p>\n"...
2009/01/14
[ "https://Stackoverflow.com/questions/442009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11432/" ]
I have a control with an undo feature, when the user press Escape the control will revert the original value. The problem is when I integrated my control to DataGridView. The DataGridView "eats" the Escape key, hence my control cannot detect the Escape key. When I put "return true" on EditingControlWantsInputKey, my ...
I was able to solved my own problem. I made the **Undo** method of my **LookupBox** public, then on my DataGridView control (**class DgvLookupBoxEditingControl : LookupBox, IDataGridViewEditingControl**), I put the following code: ``` protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { ...
442,012
<p>In zsh, how do I pass anonymous arrays into functions? e.g. looking for something like:</p> <pre><code>foo() { echo ${1[2]} '\n'; } a=(abc def ghi) foo $a --&gt; def </code></pre> <p>Or ideally:</p> <pre><code>foo (abc def ghi) </code></pre>
[ { "answer_id": 442251, "author": "Aaron Fi", "author_id": 39529, "author_profile": "https://Stackoverflow.com/users/39529", "pm_score": -1, "selected": true, "text": "<p>Figured out a workaround:</p>\n\n<pre><code>foo() {\n local a=$1\n local b=$2\n\n echo ${(j:---:)${=b}}\n\n foreac...
2009/01/14
[ "https://Stackoverflow.com/questions/442012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39529/" ]
In zsh, how do I pass anonymous arrays into functions? e.g. looking for something like: ``` foo() { echo ${1[2]} '\n'; } a=(abc def ghi) foo $a --> def ``` Or ideally: ``` foo (abc def ghi) ```
Figured out a workaround: ``` foo() { local a=$1 local b=$2 echo ${(j:---:)${=b}} foreach d in ${${=b}} do echo $d done } ``` Where parameter2 is a string of white-separated text, e.g. 'a badkljf odod'
442,019
<p>I would like to have a list of all the time zones available on a Windows Machine. How can I do this in .NET? </p> <p>I know about the TimeZoneInfo.GetSystemTimeZones method, but this returns only the currently selected time zone(s)</p> <pre class="lang-cs prettyprint-override"><code>DateTimeOffset current = DateTi...
[ { "answer_id": 442047, "author": "Robert C. Barth", "author_id": 9209, "author_profile": "https://Stackoverflow.com/users/9209", "pm_score": 6, "selected": true, "text": "<p>No it doesn't, it returns every time zone the Windows machine knows about (in my installation, that's 91). The <co...
2009/01/14
[ "https://Stackoverflow.com/questions/442019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/260/" ]
I would like to have a list of all the time zones available on a Windows Machine. How can I do this in .NET? I know about the TimeZoneInfo.GetSystemTimeZones method, but this returns only the currently selected time zone(s) ```cs DateTimeOffset current = DateTimeOffset.Now; ReadOnlyCollection<TimeZoneInfo> timeZones...
No it doesn't, it returns every time zone the Windows machine knows about (in my installation, that's 91). The `if` statement you have there is what is limiting your output. Take that out but leave the `Console.WriteLine` part, and you'll see all 91 (or so) timezones. e.g. ```cs ReadOnlyCollection<TimeZoneInfo> timeZ...
442,022
<p>Im building a Threaded Comment System for a website of mine and I ran into a problem...</p> <p>I have a list PULLED FROM A DATABASE that has a ID field and a Parent ID Field. The parent ID field can be null, but the ID field will NEVER be null.</p> <p>Since this will be a threaded comment system, I organize the l...
[ { "answer_id": 442037, "author": "Robert C. Barth", "author_id": 9209, "author_profile": "https://Stackoverflow.com/users/9209", "pm_score": 0, "selected": false, "text": "<p>You need a recursive function, and, based on how it looks like you're traversing the list, it would probably be b...
2009/01/14
[ "https://Stackoverflow.com/questions/442022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7644/" ]
Im building a Threaded Comment System for a website of mine and I ran into a problem... I have a list PULLED FROM A DATABASE that has a ID field and a Parent ID Field. The parent ID field can be null, but the ID field will NEVER be null. Since this will be a threaded comment system, I organize the list to where the I...
Thanks all for your help guys. I do appreciate it. I did though, find something by a guy that wrote absolutely everything for it. <http://www.scip.be/index.php?Page=ArticlesNET23> <http://www.scip.be/index.php?Page=ArticlesNET09> <http://www.scip.be/index.php?Page=ArticlesNET18>
442,026
<p>Why don't more mainstream statically typed languages support function/method overloading by return type? I can't think of any that do. It seems no less useful or reasonable than supporting overload by parameter type. How come it's so much less popular?</p>
[ { "answer_id": 442036, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 5, "selected": false, "text": "<p>In such a language, how would you resolve the following:</p>\n\n<pre><code>f(g(x))\n</code></pre>\n\n<p>if <code>f</co...
2009/01/14
[ "https://Stackoverflow.com/questions/442026", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23903/" ]
Why don't more mainstream statically typed languages support function/method overloading by return type? I can't think of any that do. It seems no less useful or reasonable than supporting overload by parameter type. How come it's so much less popular?
Contrary to what others are saying, overloading by return type **is** possible and **is** done by some modern languages. The usual objection is that in code like ```default int func(); string func(); int main() { func(); } ``` you can't tell which `func()` is being called. This can be resolved in a few ways: 1. Hav...
442,040
<p>I'm working on an attendance entry form for a band. My idea is to have a section of the form to enter event information for a performance or rehearsal. Here's the model for the event table:</p> <pre><code>class Event(models.Model): event_id = models.AutoField(primary_key=True) date = models.DateField() ...
[ { "answer_id": 442061, "author": "James Bennett", "author_id": 28070, "author_profile": "https://Stackoverflow.com/users/28070", "pm_score": 6, "selected": true, "text": "<p>So, you're not going to like the answer, partly because I'm not yet done writing the code and partly because it's ...
2009/01/14
[ "https://Stackoverflow.com/questions/442040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10077/" ]
I'm working on an attendance entry form for a band. My idea is to have a section of the form to enter event information for a performance or rehearsal. Here's the model for the event table: ``` class Event(models.Model): event_id = models.AutoField(primary_key=True) date = models.DateField() event_type = m...
So, you're not going to like the answer, partly because I'm not yet done writing the code and partly because it's a lot of work. What you need to do, as I discovered when I ran into this myself, is: 1. Spend a lot of time reading through the formset and model-formset code to get a feel for how it all works (not helpe...
442,048
<p>Using jQuery, how would you find elements which have a particular style (eg: <code>float: left</code>), regardless of whether it's an inline style or one defined in a CSS file?</p>
[ { "answer_id": 442082, "author": "Eran Galperin", "author_id": 10585, "author_profile": "https://Stackoverflow.com/users/10585", "pm_score": 6, "selected": true, "text": "<p>Using the <a href=\"http://docs.jquery.com/Traversing/filter\" rel=\"noreferrer\">filter function</a>:</p>\n\n<pre...
2009/01/14
[ "https://Stackoverflow.com/questions/442048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
Using jQuery, how would you find elements which have a particular style (eg: `float: left`), regardless of whether it's an inline style or one defined in a CSS file?
Using the [filter function](http://docs.jquery.com/Traversing/filter): ``` $('*').filter(function() { return $(this).css('float') == 'left'; }); ``` Replace '\*' with the appropriate selectors for your case.
442,062
<p>I want to avoid hardcoding the port number as in the following:</p> <pre><code>httpd = make_server('', 8000, simple_app) </code></pre> <p>The reason I'm creating the server this way is that I want to use it as a 'kernel' for an Adobe AIR app so it will communicate using PyAMF. Since I'm running this on the client ...
[ { "answer_id": 442073, "author": "Claudiu", "author_id": 15055, "author_profile": "https://Stackoverflow.com/users/15055", "pm_score": 2, "selected": false, "text": "<p>Is <code>make_server</code> a function that you've written? More specifically, do you handle the code that creates the ...
2009/01/14
[ "https://Stackoverflow.com/questions/442062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47110/" ]
I want to avoid hardcoding the port number as in the following: ``` httpd = make_server('', 8000, simple_app) ``` The reason I'm creating the server this way is that I want to use it as a 'kernel' for an Adobe AIR app so it will communicate using PyAMF. Since I'm running this on the client side it is very possible t...
The problem is that you need a known port for the application to use. But if you give a port number of 0, I believe the OS will provide you with the first available unused port.
442,076
<p>I need to be able to display an animation over a static image. </p> <p>Given that MPMoviePlayer gives you no control over anything useful, the only way I can think to do this is to use multiple static images, which we display (one-by-one) to create a "movie like" animation.</p> <p>I know we could use UIImageView ...
[ { "answer_id": 447538, "author": "Brad Larson", "author_id": 19679, "author_profile": "https://Stackoverflow.com/users/19679", "pm_score": 4, "selected": true, "text": "<p>You could use a Core Animation CALayer to host your animation, and swap a series of CALayers in and out of that main...
2009/01/14
[ "https://Stackoverflow.com/questions/442076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54905/" ]
I need to be able to display an animation over a static image. Given that MPMoviePlayer gives you no control over anything useful, the only way I can think to do this is to use multiple static images, which we display (one-by-one) to create a "movie like" animation. I know we could use UIImageView to do this (by set...
You could use a Core Animation CALayer to host your animation, and swap a series of CALayers in and out of that main layer to perform your frame-by-frame animation. You can set the content of an image-frame-hosting CALayer to a CGImageRef using its contents property. A series of CALayers containing your images could be...