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
195,991
<p>For explanation imagine a simple address. Written in a HTML paragraph with line breaks it would like this:</p> <pre><code>Street: Example Street 1 City: Vienna Zip Code: 1010 Country: Austria </code></pre> <p>Most of the time that's completely okay, but sometimes I have to achieve the following output:</p> <pre><...
[ { "answer_id": 196004, "author": "Henrik Paul", "author_id": 2238, "author_profile": "https://Stackoverflow.com/users/2238", "pm_score": 2, "selected": false, "text": "<p>Tables are the way to go.</p>\n" }, { "answer_id": 196007, "author": "Kornel", "author_id": 27009, ...
2008/10/12
[ "https://Stackoverflow.com/questions/195991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20467/" ]
For explanation imagine a simple address. Written in a HTML paragraph with line breaks it would like this: ``` Street: Example Street 1 City: Vienna Zip Code: 1010 Country: Austria ``` Most of the time that's completely okay, but sometimes I have to achieve the following output: ``` Street: Example Street 1 City:...
I find that definition lists make much more sense than tables here. Float the `dt` to the left with a specific width and have it clear on the left. If either the label or the data are going to wrap, you'll have to do some post-element-float-clearing trickery to make this work, but it doesn't sound like you'll need that...
196,017
<p>I'd like to generate unique random numbers between 0 and 1000 that never repeat (i.e. 6 doesn't show up twice), but that doesn't resort to something like an O(N) search of previous values to do it. Is this possible?</p>
[ { "answer_id": 196022, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 6, "selected": false, "text": "<p>You can do this:</p>\n\n<ol>\n<li>Create a list, 0..1000.</li>\n<li>Shuffle the list. (See <a href=\"http://en.wikipedia....
2008/10/12
[ "https://Stackoverflow.com/questions/196017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3886/" ]
I'd like to generate unique random numbers between 0 and 1000 that never repeat (i.e. 6 doesn't show up twice), but that doesn't resort to something like an O(N) search of previous values to do it. Is this possible?
Initialize an array of 1001 integers with the values 0-1000 and set a variable, max, to the current max index of the array (starting with 1000). Pick a random number, r, between 0 and max, swap the number at the position r with the number at position max and return the number now at position max. Decrement max by 1 and...
196,020
<p>I need to create a 'slider' for a client's site. The slider should allow people to select how many items they want of x item, and show what the price will be based on that. The weird(ish) part is that the ratio of the price increase will go down as the amount of items goes up:</p> <ul> <li>1 item: $100</li> <li>2 i...
[ { "answer_id": 196034, "author": "Dimitry", "author_id": 27073, "author_profile": "https://Stackoverflow.com/users/27073", "pm_score": 3, "selected": false, "text": "<p>Check out Yahoo! UI. they have a slider widget: <a href=\"http://developer.yahoo.com/yui/slider/\" rel=\"noreferrer\">h...
2008/10/12
[ "https://Stackoverflow.com/questions/196020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12765/" ]
I need to create a 'slider' for a client's site. The slider should allow people to select how many items they want of x item, and show what the price will be based on that. The weird(ish) part is that the ratio of the price increase will go down as the amount of items goes up: * 1 item: $100 * 2 items: +90 = $190 * 3 ...
Check out Yahoo! UI. they have a slider widget: <http://developer.yahoo.com/yui/slider/> The following example should get you started: <http://developer.yahoo.com/yui/examples/slider/slider-ticks.html>. All JavaScript frameworks ([jQuery](http://docs.jquery.com/UI/Slider), [MooTools](http://demos.mootools.net/Slider)...
196,037
<p>How can I access a public static member of a Java class from ColdFusion?</p>
[ { "answer_id": 196107, "author": "Turnkey", "author_id": 13144, "author_profile": "https://Stackoverflow.com/users/13144", "pm_score": 5, "selected": true, "text": "<p>You run the createObject but don't call the \"init\" before running the static method. For example:</p>\n\n<pre><code>&l...
2008/10/12
[ "https://Stackoverflow.com/questions/196037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2484/" ]
How can I access a public static member of a Java class from ColdFusion?
You run the createObject but don't call the "init" before running the static method. For example: ``` <cfset systemObject = createObject("java", "java.lang.System") /> <cfoutput>#systemObject.currentTimeMillis()#</cfoutput> ``` In this case "currentTimeMillis()" is a static method of the System class.
196,088
<p>Assume I have a function template like this:</p> <pre><code>template&lt;class T&gt; inline void doStuff(T* arr) { // stuff that needs to use sizeof(T) } </code></pre> <p>Then in another <code>.h</code> filee I have a template class <code>Foo</code> that has:</p> <pre><code>public: operator T*() const; </code></...
[ { "answer_id": 196103, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": -1, "selected": false, "text": "<p>I'm not sure why the conversion doesn't work but you could use an overload to fix the problem</p>\n\n<pre><code>\ntem...
2008/10/12
[ "https://Stackoverflow.com/questions/196088", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18721/" ]
Assume I have a function template like this: ``` template<class T> inline void doStuff(T* arr) { // stuff that needs to use sizeof(T) } ``` Then in another `.h` filee I have a template class `Foo` that has: ``` public: operator T*() const; ``` Now, I realize that those are different Ts. But If I have a variable...
GCC is correct. In template arguments only exact matches are considered, type conversions are not. This is because otherwise an infinite (or at least exponential) amount of conversions could have to be considered. If Foo<T> is the only other template that you're going to run in to, the best solution would be to add: ...
196,097
<p>On a site of mine in which a textarea is used for submission, I have code that can appear something along the lines of the following:</p> <pre><code>&lt;textarea&gt;&lt;p&gt;text&lt;/p&gt;&lt;/textarea&gt; </code></pre> <p>When validating (XHTML 1.0 Transitional), this error arises,</p> <pre><code>line 88 column ...
[ { "answer_id": 196105, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 4, "selected": true, "text": "<p>is there a reason you're trying to put a <code>&lt;p&gt;</code> within <code>&lt;textarea&gt;</code>? as you found out it's n...
2008/10/12
[ "https://Stackoverflow.com/questions/196097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23666/" ]
On a site of mine in which a textarea is used for submission, I have code that can appear something along the lines of the following: ``` <textarea><p>text</p></textarea> ``` When validating (XHTML 1.0 Transitional), this error arises, ``` line 88 column 50 - Error: document type does not allow element "p" here ``...
is there a reason you're trying to put a `<p>` within `<textarea>`? as you found out it's not valid. if it's for display purposes (ie, showing code) it should be translated: ``` <textarea>&lt;p&gt;text&lt;/p&gt;</textarea> ``` beyond validation issues, allowing arbitrary tags (which are not properly encoded as above...
196,109
<p>Does anybody know of a good media framework for Flex?<br/> I'd like to be able to create apps that can play not only those formats that the Flex framework provides support for, but other formats as well (like wav, wma, ogg and other...).</p> <p><strong>EDIT 13.10.2008.:</strong> It was recently pointed out to me in...
[ { "answer_id": 196105, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 4, "selected": true, "text": "<p>is there a reason you're trying to put a <code>&lt;p&gt;</code> within <code>&lt;textarea&gt;</code>? as you found out it's n...
2008/10/12
[ "https://Stackoverflow.com/questions/196109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19911/" ]
Does anybody know of a good media framework for Flex? I'd like to be able to create apps that can play not only those formats that the Flex framework provides support for, but other formats as well (like wav, wma, ogg and other...). **EDIT 13.10.2008.:** It was recently pointed out to me in the answers section that...
is there a reason you're trying to put a `<p>` within `<textarea>`? as you found out it's not valid. if it's for display purposes (ie, showing code) it should be translated: ``` <textarea>&lt;p&gt;text&lt;/p&gt;</textarea> ``` beyond validation issues, allowing arbitrary tags (which are not properly encoded as above...
196,114
<p>I chmod'ed the directory to 777, same with the directory contents. Still, I get a "permission denied" error. Does PHP throw this error if apache is not the group/owner, regardless of the file permissions? Here's the call that's failing:</p> <pre><code>rename('/correct/path/to/dir/1', '/correct/path/to/dir/2'); </co...
[ { "answer_id": 196118, "author": "Ross", "author_id": 2025, "author_profile": "https://Stackoverflow.com/users/2025", "pm_score": 0, "selected": false, "text": "<p>Try running the following script:</p>\n\n<pre><code>print_r(posix_getpwuid(getmyuid()));\nprint_r(pathinfo($YOUR_PATH));\n</...
2008/10/12
[ "https://Stackoverflow.com/questions/196114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11577/" ]
I chmod'ed the directory to 777, same with the directory contents. Still, I get a "permission denied" error. Does PHP throw this error if apache is not the group/owner, regardless of the file permissions? Here's the call that's failing: ``` rename('/correct/path/to/dir/1', '/correct/path/to/dir/2'); ```
You're editing the higher level directory, so the PHP user needs to have write access to that directory.
196,171
<p>Is it possible to use a CHECK constraint to prevent any date that falls on a Sunday? I don't want to use a trigger.</p>
[ { "answer_id": 196190, "author": "Mark", "author_id": 26310, "author_profile": "https://Stackoverflow.com/users/26310", "pm_score": 1, "selected": false, "text": "<p>Not sure about the actual constraint, but you can use the function:</p>\n\n<pre><code>TO_CHAR(sysdate, 'D'); \n</code></pr...
2008/10/12
[ "https://Stackoverflow.com/questions/196171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3401/" ]
Is it possible to use a CHECK constraint to prevent any date that falls on a Sunday? I don't want to use a trigger.
Yes, a check constraint can check that the day of the week is not Sunday. Here's an example: ``` create table date_test (entry_date date); alter table date_test add constraint day_is_not_sunday check ( to_char(entry_date,'DAY','NLS_DATE_LANGUAGE = ENGLISH') not like 'SUNDAY%'); ``` --There are blank spaces t...
196,173
<p>Modern UI's are starting to give their UI elments nice inertia when moving. Tabs slide in, page transitions, even some listboxes and scroll elments have nice inertia to them (the iphone for example). What is the best algorythm for this? It is more than just gravity as they speed up, and then slow down as they fal...
[ { "answer_id": 196178, "author": "Nils Pipenbrinck", "author_id": 15955, "author_profile": "https://Stackoverflow.com/users/15955", "pm_score": 0, "selected": false, "text": "<p>It's playing with the numbers.. What feels good is good.</p>\n\n<p>I've tried to develop magic formulas myself...
2008/10/12
[ "https://Stackoverflow.com/questions/196173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3798/" ]
Modern UI's are starting to give their UI elments nice inertia when moving. Tabs slide in, page transitions, even some listboxes and scroll elments have nice inertia to them (the iphone for example). What is the best algorythm for this? It is more than just gravity as they speed up, and then slow down as they fall into...
You're talking about two different things here. One is momentum - giving things residual motion when you release them from a drag. This is simply about remembering the velocity of a thing when the user releases it, then applying that velocity to the object every frame and also reducing the velocity every frame by some...
196,177
<p>I have code like this:</p> <pre><code>var newMsg = new Msg { Var1 = var1, Var2 = var2 }; using (AppDataContext appDataContext = new AppDataContext(ConnectionString)) { appDataContext.CClass.InsertOnSubmit(newMsg); appDataContext.SubmitChanges(); } </code></pre> <p>After reading <a href="https://st...
[ { "answer_id": 196195, "author": "liggett78", "author_id": 19762, "author_profile": "https://Stackoverflow.com/users/19762", "pm_score": 4, "selected": true, "text": "<p>The second answer in the post you're referencing says it:</p>\n\n<blockquote>\n <p>LINQ to SQL uses <em>execute_sql</...
2008/10/12
[ "https://Stackoverflow.com/questions/196177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
I have code like this: ``` var newMsg = new Msg { Var1 = var1, Var2 = var2 }; using (AppDataContext appDataContext = new AppDataContext(ConnectionString)) { appDataContext.CClass.InsertOnSubmit(newMsg); appDataContext.SubmitChanges(); } ``` After reading [this post](https://stackoverflow.com/questio...
The second answer in the post you're referencing says it: > > LINQ to SQL uses *execute\_sql* with > parameters. > > > It does not concatenate property values into a one big INSERT ... VALUES('...', '...')
196,179
<p>I'm having a problem understanding the shift/reduce confict for a grammar that I know has no ambiguity. The case is one of the if else type but it's not the 'dangling else' problem since I have mandatory END clauses delimiting code blocks.</p> <p>Here is the grammar for gppg (Its a Bison like compiler compiler ... ...
[ { "answer_id": 196201, "author": "1800 INFORMATION", "author_id": 3146, "author_profile": "https://Stackoverflow.com/users/3146", "pm_score": 2, "selected": false, "text": "<p>I think the problem is in the elseifs clause.</p>\n\n<pre><code>elseifs : elseifs '#' ELSEIF statements else\n ...
2008/10/12
[ "https://Stackoverflow.com/questions/196179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23190/" ]
I'm having a problem understanding the shift/reduce confict for a grammar that I know has no ambiguity. The case is one of the if else type but it's not the 'dangling else' problem since I have mandatory END clauses delimiting code blocks. Here is the grammar for gppg (Its a Bison like compiler compiler ... and that w...
Your revised ELSEIF rule has no markers for a condition -- it should nominally have '(' and ')' added. More seriously, you now have a rule for ``` elsebody : else | elseifs else ; ``` and ``` elseifs : /* Nothing */ | elseifs ...something... ; ``` The 'nothing' is not needed; i...
196,216
<p>I am new to strut/web programming and I thought I could learn a lot by reading a sample app. On google, I searched and found a sample app at <a href="http://www.roseindia.net/struts/struts2/struts2tutorial.zip" rel="nofollow noreferrer">http://www.roseindia.net/struts/struts2/struts2tutorial.zip</a> , the tutorial i...
[ { "answer_id": 196258, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 2, "selected": false, "text": "<p>You will learn a lot by reading sample apps. If your sample doesn't work, perhaps your sample is wrong.</p>\n\n<p>Perha...
2008/10/12
[ "https://Stackoverflow.com/questions/196216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17085/" ]
I am new to strut/web programming and I thought I could learn a lot by reading a sample app. On google, I searched and found a sample app at <http://www.roseindia.net/struts/struts2/struts2tutorial.zip> , the tutorial is really nice and it gives a sample login page. However, I couldn't run this sample app. I tried pos...
You will learn a lot by reading sample apps. If your sample doesn't work, perhaps your sample is wrong. Perhaps you need the actual authoritative documentation. See [How to setup a basic struts project using Eclipse](http://struts.apache.org/1.2.4/faqs/eclipse.html). This is the as official as any Eclipse - Struts doc...
196,224
<p>I have a component which writes/generates javascript from a server side renderer. This component can be used in multiple times in a same page. However, once the page is loaded I have to collect all the variables or JSO written by this multiple components in the page. How can I do this so that I will have a collectio...
[ { "answer_id": 196271, "author": "Vincent Robert", "author_id": 268, "author_profile": "https://Stackoverflow.com/users/268", "pm_score": 2, "selected": true, "text": "<p>You will need to be a little more specific about your problem, maybe with an example page but here are some thoughts....
2008/10/12
[ "https://Stackoverflow.com/questions/196224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3627/" ]
I have a component which writes/generates javascript from a server side renderer. This component can be used in multiple times in a same page. However, once the page is loaded I have to collect all the variables or JSO written by this multiple components in the page. How can I do this so that I will have a collection o...
You will need to be a little more specific about your problem, maybe with an example page but here are some thoughts. If you have a server-side component that writes JavaScript during page generation, I would generate a function call each time, something like: ``` Component_appendArray(['First', 'Second']); ... Compo...
196,294
<p>I'm trying to learn about catamorphisms and I've read <a href="http://en.wikipedia.org/wiki/Catamorphism" rel="noreferrer">the Wikipedia article</a> and the first couple posts in <a href="http://lorgonblog.spaces.live.com/Blog/cns!701679AD17B6D310!256.entry" rel="noreferrer">the series of the topic for F#</a> on the...
[ { "answer_id": 196309, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 4, "selected": false, "text": "<p>I've been doing more reading, including a Micorosft Research paper on <a href=\"http://research.microsoft.com/~emeije...
2008/10/12
[ "https://Stackoverflow.com/questions/196294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1659/" ]
I'm trying to learn about catamorphisms and I've read [the Wikipedia article](http://en.wikipedia.org/wiki/Catamorphism) and the first couple posts in [the series of the topic for F#](http://lorgonblog.spaces.live.com/Blog/cns!701679AD17B6D310!256.entry) on the *Inside F#* blog. I understand that it's a generalizatio...
LINQ's `Aggregate()` is just for `IEnumerables`. Catamorphisms in general refer to the pattern of folding for an arbitrary data type. So `Aggregate()` is to `IEnumerables` what `FoldTree` (below) is to `Trees` (below); both are catamorphisms for their respective data types. I translated some of the code in [part 4 of ...
196,302
<p>Since I keep showing up late for answering questions tagged php where i actually know the answer i figured i'd try asking a question myself.</p> <p>I've been working on so many complete rewrites of a custom template engine in php for so long and so many times that i thought i'd ask for opinions.</p> <p>In short, t...
[ { "answer_id": 197119, "author": "SchizoDuckie", "author_id": 18077, "author_profile": "https://Stackoverflow.com/users/18077", "pm_score": 3, "selected": false, "text": "<p>Why not just use PHP as your templating system. PHP <em>IS</em> the template system.</p>\n\n<p>What is wrong with ...
2008/10/12
[ "https://Stackoverflow.com/questions/196302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18565/" ]
Since I keep showing up late for answering questions tagged php where i actually know the answer i figured i'd try asking a question myself. I've been working on so many complete rewrites of a custom template engine in php for so long and so many times that i thought i'd ask for opinions. In short, this is the most i...
Why not just use PHP as your templating system. PHP *IS* the template system. What is wrong with just dumping `<?php=$variable;?>` in an HTML template? You can use foreach loops, etc. Just make sure that you run it from within a scope that cannot access any variables you do not want. I have a really deep founded hate...
196,326
<p>.NET newbie here... I'd like to make a button in a Windows form that displays a progress or "cooldown" effect. That is, when the button is pressed, it becomes disabled. As some event or timer is progressing, the button shows the progress graphically. When the progress is finished, the graphic completes and the bu...
[ { "answer_id": 196330, "author": "Phil Wright", "author_id": 6276, "author_profile": "https://Stackoverflow.com/users/6276", "pm_score": 1, "selected": false, "text": "<p>The easiest approach is to create an instance of the progress bar control and then you do not need to perform any cus...
2008/10/13
[ "https://Stackoverflow.com/questions/196326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3696/" ]
.NET newbie here... I'd like to make a button in a Windows form that displays a progress or "cooldown" effect. That is, when the button is pressed, it becomes disabled. As some event or timer is progressing, the button shows the progress graphically. When the progress is finished, the graphic completes and the button b...
If you really need to have it on the button, I'd go with a custom paint event. something similar to: ``` button += new buttonPaintEvent(buttonPaintEventHandlerMethod); ```
196,345
<p>I want to I check whether a string is in ASCII or not.</p> <p>I am aware of <code>ord()</code>, however when I try <code>ord('é')</code>, I have <code>TypeError: ord() expected a character, but string of length 2 found</code>. I understood it is caused by the way I built Python (as explained in <a href="http://docs...
[ { "answer_id": 196360, "author": "Steve Moyer", "author_id": 17008, "author_profile": "https://Stackoverflow.com/users/17008", "pm_score": 2, "selected": false, "text": "<p>You could use the regular expression library which accepts the Posix standard [[:ASCII:]] definition.</p>\n" }, ...
2008/10/13
[ "https://Stackoverflow.com/questions/196345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3504/" ]
I want to I check whether a string is in ASCII or not. I am aware of `ord()`, however when I try `ord('é')`, I have `TypeError: ord() expected a character, but string of length 2 found`. I understood it is caused by the way I built Python (as explained in [`ord()`'s documentation](http://docs.python.org/library/functi...
``` def is_ascii(s): return all(ord(c) < 128 for c in s) ```
196,382
<p>I see that the SML/NJ includes a queue structure. I can't figure out how to use it. How do I use the additional libraries provided by SML/NJ?</p>
[ { "answer_id": 224000, "author": "Vincent Ramdhanie", "author_id": 27439, "author_profile": "https://Stackoverflow.com/users/27439", "pm_score": 1, "selected": false, "text": "<p>I don't have a complete answer for you but I could point you in the right direction. You should look up using...
2008/10/13
[ "https://Stackoverflow.com/questions/196382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6013/" ]
I see that the SML/NJ includes a queue structure. I can't figure out how to use it. How do I use the additional libraries provided by SML/NJ?
The [`Queue` structure](http://www.smlnj.org/doc/smlnj-lib/Manual/queue.html) is not specified by SML '97, but it is present in SML/NJ's top-level environment. ``` $ sml Standard ML of New Jersey v110.69 [built: Fri Mar 13 16:02:47 2009] - Queue.mkQueue (); [autoloading] [library $SMLNJ-LIB/Util/smlnj-lib.cm is stabl...
196,407
<p>From within a DLL that's being called by a C#.NET web app, how do you find the base url of the web app?</p>
[ { "answer_id": 196414, "author": "TheSmurf", "author_id": 1975282, "author_profile": "https://Stackoverflow.com/users/1975282", "pm_score": 0, "selected": false, "text": "<p>You can use Assembly.GetExecutingAssembly() to get the assembly object for the DLL.</p>\n\n<p>Then, call Server.Ma...
2008/10/13
[ "https://Stackoverflow.com/questions/196407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
From within a DLL that's being called by a C#.NET web app, how do you find the base url of the web app?
Will this work? ``` HttpContext.Current.Request.Url ``` UPDATE: To get the base URL you can use: ``` HttpContext.Current.Request.Url.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped) ```
196,415
<p>For a current project I am working I need to return an aggregate report based on date ranges. </p> <p>I have 3 types of reports, yearly, monthly and daily.</p> <p>To assist in returning this report I need a function that will return all of the sub-ranges of datetimes, within a big range.</p> <p>So for example if ...
[ { "answer_id": 196416, "author": "Sam Saffron", "author_id": 17174, "author_profile": "https://Stackoverflow.com/users/17174", "pm_score": 3, "selected": true, "text": "<p>There are quite a few tricks in here, hope you find it useful</p>\n\n<pre><code>create function dbo.fnGetDateRanges\...
2008/10/13
[ "https://Stackoverflow.com/questions/196415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17174/" ]
For a current project I am working I need to return an aggregate report based on date ranges. I have 3 types of reports, yearly, monthly and daily. To assist in returning this report I need a function that will return all of the sub-ranges of datetimes, within a big range. So for example if I as for all the daily r...
There are quite a few tricks in here, hope you find it useful ``` create function dbo.fnGetDateRanges ( @type char(1), @start datetime, @finish datetime ) returns @ranges table(start datetime, finish datetime) as begin declare @from datetime declare @to datetime set @from = @start if ...
196,420
<p>Nightly, I need to fill a SQL Server 2005 table from an ODBC source with over 8 million records. Currently I am using an insert statement from linked server with syntax select similar to this:</p> <pre><code>Insert Into SQLStagingTable from Select * from OpenQuery(ODBCSource, 'Select * from SourceTable') </code></p...
[ { "answer_id": 196433, "author": "Sam Saffron", "author_id": 17174, "author_profile": "https://Stackoverflow.com/users/17174", "pm_score": 3, "selected": true, "text": "<p>The easiest way would be to use ExecuteReader() against your odbc data source and pass the <a href=\"http://msdn.mic...
2008/10/13
[ "https://Stackoverflow.com/questions/196420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5458/" ]
Nightly, I need to fill a SQL Server 2005 table from an ODBC source with over 8 million records. Currently I am using an insert statement from linked server with syntax select similar to this: ``` Insert Into SQLStagingTable from Select * from OpenQuery(ODBCSource, 'Select * from SourceTable') ``` This is really ine...
The easiest way would be to use ExecuteReader() against your odbc data source and pass the [IDataReader](http://msdn.microsoft.com/en-us/library/system.data.idatareader.aspx) to the [WriteToServer(IDataReader)](http://msdn.microsoft.com/en-us/library/434atets.aspx) overload. Most data reader implementations will only ...
196,424
<p>Should I be using this method of throwing errors:</p> <pre><code>if (isset($this-&gt;dbfields[$var])) { return $this-&gt;dbfields[$var]; } else { throw new FieldNotFoundException($var); } </code></pre> <p>or this style:</p> <pre><code>try { return $this-&gt;dbfields[$var]; } catch (Exception $e) { ...
[ { "answer_id": 196428, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 4, "selected": true, "text": "<p>The second example is bad. You're taking a lot of overhead to catch an exception when, as you demonstrate, it's just...
2008/10/13
[ "https://Stackoverflow.com/questions/196424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
Should I be using this method of throwing errors: ``` if (isset($this->dbfields[$var])) { return $this->dbfields[$var]; } else { throw new FieldNotFoundException($var); } ``` or this style: ``` try { return $this->dbfields[$var]; } catch (Exception $e) { throw new FieldNotFoundException($var); } ``...
The second example is bad. You're taking a lot of overhead to catch an exception when, as you demonstrate, it's just as easy to prevent the exception in the first place. Plus you also assume you know why that exception was thrown - if there was some other exception, like say an out of memory or something, you're report...
196,465
<p>The <a href="http://en.wikipedia.org/wiki/Effect_system" rel="noreferrer">Wikipedia article on <em>Effect system</em></a> is currently just a short stub and I've been wondering for a while as to what is an effect system. </p> <ul> <li>Are there any languages that have an effect system in addition to a type system? ...
[ { "answer_id": 196489, "author": "Brian", "author_id": 19299, "author_profile": "https://Stackoverflow.com/users/19299", "pm_score": 3, "selected": false, "text": "<p>(This is not an authoritative answer; just trying to trawl my memory.)</p>\n\n<p>In a sense, any time you code a 'state m...
2008/10/13
[ "https://Stackoverflow.com/questions/196465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1659/" ]
The [Wikipedia article on *Effect system*](http://en.wikipedia.org/wiki/Effect_system) is currently just a short stub and I've been wondering for a while as to what is an effect system. * Are there any languages that have an effect system in addition to a type system? * What would a possible (hypothetical) notation i...
A "type and effect system" describes not only the kinds of values in a program, but the changes in those values. "Typestate" checking is a related idea. An example might be a type system that tracks file handles: instead of having a function `close` with return type `void`, the type system would record the *effect* of...
196,468
<p>I am using the Maven (2) Cobertura plug-in to create reports on code coverage, and I have the following stub I am using in a method:</p> <pre><code>try { System.exit(0); } catch (final SecurityException exception) { exception.printStackTrace(); } System.err.println("The program never exited!"); </code></pre...
[ { "answer_id": 196490, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": false, "text": "<p>I would look at the coverage report. Double check my tests. Notice that the code really is getting covered and not...
2008/10/13
[ "https://Stackoverflow.com/questions/196468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8026/" ]
I am using the Maven (2) Cobertura plug-in to create reports on code coverage, and I have the following stub I am using in a method: ``` try { System.exit(0); } catch (final SecurityException exception) { exception.printStackTrace(); } System.err.println("The program never exited!"); ``` I know that I need t...
I haven't used Cobertura in a while (2005?), and saw this behavior back then. A similar problem exists with NCover for C# and curly braces following catch/finally blocks. My suggestion would be to add to [this Cobertura bug report detailing a similar issue](http://sourceforge.net/tracker/index.php?func=detail&aid=1474...
196,480
<p>I have a table with two fields of interest for this particular exercise: a CHAR(3) ID and a DATETIME. The ID identifies the submitter of the data - several thousand rows. The DATETIME is not necessarily unique, either. (The primary keys are other fields of the table.)</p> <p>Data for this table is submitted ever...
[ { "answer_id": 196499, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 1, "selected": false, "text": "<p>From your description, I wouldn't worry about the efficiency of the query since apparently it only needs to run tw...
2008/10/13
[ "https://Stackoverflow.com/questions/196480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27290/" ]
I have a table with two fields of interest for this particular exercise: a CHAR(3) ID and a DATETIME. The ID identifies the submitter of the data - several thousand rows. The DATETIME is not necessarily unique, either. (The primary keys are other fields of the table.) Data for this table is submitted every six months....
I later realised that I was supposed to check to make sure that there was data for *both* July to December and January to June. So this is what I wound up in v2: ``` SELECT @avgmonths = AVG(x.[count]) FROM ( SELECT CAST(COUNT(DISTINCT DATEPART(month, DATEADD(mont...
196,488
<p>Hey all I'm hoping someone has enough experience with Cake PHP to make this work. </p> <p>I'm working on something that at the moment could affectionately be called a twitter clone. Essentially I have a set up like this. </p> <p>Users have many friends. This is a many to many relationship to the user table. It is ...
[ { "answer_id": 196496, "author": "Edward Z. Yang", "author_id": 23845, "author_profile": "https://Stackoverflow.com/users/23845", "pm_score": 0, "selected": false, "text": "<p>In CakePHP speak, many to many is \"Has And Belongs To Many\" (HABTM). Assuming you've set up the relations prop...
2008/10/13
[ "https://Stackoverflow.com/questions/196488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7018/" ]
Hey all I'm hoping someone has enough experience with Cake PHP to make this work. I'm working on something that at the moment could affectionately be called a twitter clone. Essentially I have a set up like this. Users have many friends. This is a many to many relationship to the user table. It is stored in a link ...
If all you need in the results of the query is a list of tips, I'd be tempted to do this in 2 queries. The first to find a list of user ids of this user and their friends, the second to find the tips that belong to any one of these ids. So, in your Tip model: ``` function findTipsByUserAndFriends($userId) { //Friend...
196,498
<p>I have a text file in the root of my web app <em><a href="http://localhost/foo.txt" rel="noreferrer">http://localhost/foo.txt</a></em> and I'd like to load it into a variable in javascript.. in groovy I would do this:</p> <pre><code>def fileContents = 'http://localhost/foo.txt'.toURL().text; println fileContents; <...
[ { "answer_id": 196510, "author": "Edward Z. Yang", "author_id": 23845, "author_profile": "https://Stackoverflow.com/users/23845", "pm_score": 8, "selected": true, "text": "<p>XMLHttpRequest, i.e. AJAX, without the XML.</p>\n<p>The precise manner you do this is dependent on what JavaScrip...
2008/10/13
[ "https://Stackoverflow.com/questions/196498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2031/" ]
I have a text file in the root of my web app *<http://localhost/foo.txt>* and I'd like to load it into a variable in javascript.. in groovy I would do this: ``` def fileContents = 'http://localhost/foo.txt'.toURL().text; println fileContents; ``` How can I get a similar result in javascript?
XMLHttpRequest, i.e. AJAX, without the XML. The precise manner you do this is dependent on what JavaScript framework you're using, but if we disregard interoperability issues, your code will look something like: ```js var client = new XMLHttpRequest(); client.open('GET', '/foo.txt'); client.onreadystatechange = funct...
196,500
<p>I have a WordPress installation with an <code>.htaccess</code> file that looks like this:</p> <pre><code># BEGIN WordPress &lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] &lt;/IfModule&gt; # END WordPr...
[ { "answer_id": 196553, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 2, "selected": false, "text": "<p><strong>Edit#2</strong>: ok i think i figured this out, but it's pretty messy.</p>\n\n<p>modify your base wordpress install'...
2008/10/13
[ "https://Stackoverflow.com/questions/196500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12765/" ]
I have a WordPress installation with an `.htaccess` file that looks like this: ``` # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress ``` I tried installing a fresh ...
For future reference, you may want to try this: ``` # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /blog2/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /blog2/index.php [L] </IfModule> # END WordPress ```
196,505
<p>Is there a way to use <strong>THE LOOP</strong> in <strong>Wordpress</strong> to load pages instead of posts?</p> <p>I would like to be able to query a set of child pages, and then use <strong>THE LOOP</strong> function calls on it - things like <code>the_permalink()</code> and <code>the_title()</code>.</p> <p>Is ...
[ { "answer_id": 196742, "author": "Simon Lehmann", "author_id": 27011, "author_profile": "https://Stackoverflow.com/users/27011", "pm_score": 7, "selected": true, "text": "<p>Yes, that's possible. You can create a new WP_Query object. Do something like this:</p>\n\n<pre><code>query_posts(...
2008/10/13
[ "https://Stackoverflow.com/questions/196505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22306/" ]
Is there a way to use **THE LOOP** in **Wordpress** to load pages instead of posts? I would like to be able to query a set of child pages, and then use **THE LOOP** function calls on it - things like `the_permalink()` and `the_title()`. Is there a way to do this? I didn't see anything in `query_posts()` documentation...
Yes, that's possible. You can create a new WP\_Query object. Do something like this: ``` query_posts(array('showposts' => <number_of_pages_to_show>, 'post_parent' => <ID of the parent page>, 'post_type' => 'page')); while (have_posts()) { the_post(); /* Do whatever you want to do for every page... */ } wp_reset_...
196,509
<p>I want to delete <strong>all</strong> the previously created indices. I am using <code>Lucene.net</code>.</p> <p>I tried the following:</p> <pre><code>Term term = new Term(); //empty because I want to delete all the indices IndexReader rdr = IndexReader.Open(_directory); rdr.DeleteDocuments(term); rdr.Close(); </...
[ { "answer_id": 229800, "author": "Jokin", "author_id": 27369, "author_profile": "https://Stackoverflow.com/users/27369", "pm_score": 4, "selected": false, "text": "<p>The best way to delete an index is to wipe the filesystem directory. However, if you wan't to regenerate the index, the e...
2008/10/13
[ "https://Stackoverflow.com/questions/196509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to delete **all** the previously created indices. I am using `Lucene.net`. I tried the following: ``` Term term = new Term(); //empty because I want to delete all the indices IndexReader rdr = IndexReader.Open(_directory); rdr.DeleteDocuments(term); rdr.Close(); ``` But I get error. Any idea how to go about...
The best way to delete an index is to wipe the filesystem directory. However, if you wan't to regenerate the index, the easiest way is to open a new indexwriter with the create parameter as true. It will start a new index deleting the contents of the existing one.
196,518
<p>Problem with dynamic controls</p> <p>Hello all,</p> <p>I'm wanting to create some dynamic controls, and have them persist their viewstate across page loads. Easy enough, right? All I have to do is re-create the controls upon each page load, using the same IDs. HOWEVER, here's the catch - in my PreRender event, ...
[ { "answer_id": 196532, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 1, "selected": false, "text": "<blockquote>\n <p>I'm already re-creating the controls in my OnLoad event.</p>\n</blockquote>\n\n<p>That's your probl...
2008/10/13
[ "https://Stackoverflow.com/questions/196518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27293/" ]
Problem with dynamic controls Hello all, I'm wanting to create some dynamic controls, and have them persist their viewstate across page loads. Easy enough, right? All I have to do is re-create the controls upon each page load, using the same IDs. HOWEVER, here's the catch - in my PreRender event, I'm wanting to clear...
ViewState-backed properties are only persisted to ViewState if the control is currently tracking ViewState. This is by design to keep ViewState as small as possible: it should only contain data that is truly dynamic. The upshot of this is that: ViewState propeties set during the Init event are *not* backed to ViewStat...
196,520
<p>What's the best/most efficient way to extract text set between parenthesis? Say I wanted to get the string "text" from the string "ignore everything except this (text)" in the most efficient manner possible.</p> <p>So far, the best I've come up with is this:</p> <pre><code>$fullString = "ignore everything except t...
[ { "answer_id": 196536, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 8, "selected": true, "text": "<p>i'd just do a regex and get it over with. unless you are doing enough iterations that it becomes a huge performance issue, it...
2008/10/13
[ "https://Stackoverflow.com/questions/196520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5291/" ]
What's the best/most efficient way to extract text set between parenthesis? Say I wanted to get the string "text" from the string "ignore everything except this (text)" in the most efficient manner possible. So far, the best I've come up with is this: ``` $fullString = "ignore everything except this (text)"; $start =...
i'd just do a regex and get it over with. unless you are doing enough iterations that it becomes a huge performance issue, it's just easier to code (and understand when you look back on it) ``` $text = 'ignore everything except this (text)'; preg_match('#\((.*?)\)#', $text, $match); print $match[1]; ```
196,567
<p>I have a mockup layout for something <a href="http://www.mylittlepwnage.com/misc/forms-editor.html" rel="nofollow noreferrer">here</a>. Essentially there are sections, columns and fields, which are all written as a combination of <code>&lt;ul&gt;</code> and <code>&lt;li&gt;</code> elements. This is done specifically...
[ { "answer_id": 196571, "author": "Joe Basirico", "author_id": 20795, "author_profile": "https://Stackoverflow.com/users/20795", "pm_score": 2, "selected": false, "text": "<p>In your <code>&lt;UL&gt;</code> tag use the css attribute \"list-style:none;\" and in the <code>&lt;li&gt;</code> ...
2008/10/13
[ "https://Stackoverflow.com/questions/196567", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1666/" ]
I have a mockup layout for something [here](http://www.mylittlepwnage.com/misc/forms-editor.html). Essentially there are sections, columns and fields, which are all written as a combination of `<ul>` and `<li>` elements. This is done specifically for later parsing. A snippet of the HTML: ``` <li class="layout"><span...
I just added this to your css: ``` ul .section-children li.layout { display : inline-block; } ``` Unfortunately, I don't know how well supported inline-block is nowadays.
196,585
<p>I've got some LINQ to SQL that sometimes throws a </p> <blockquote> <p>"Cannot insert duplicate key row in object 'dbo.Table' with unique index 'IX_Indexname'.The statement has been terminated."</p> </blockquote> <p>Is there some way I can turn on logging or at least debug into the datacontext to see what sql ...
[ { "answer_id": 196590, "author": "ChrisHDog", "author_id": 25719, "author_profile": "https://Stackoverflow.com/users/25719", "pm_score": 2, "selected": false, "text": "<p>When running into these type issues I've been using the SQL profiler. Basically turning on the profiler, putting a b...
2008/10/13
[ "https://Stackoverflow.com/questions/196585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2975/" ]
I've got some LINQ to SQL that sometimes throws a > > "Cannot insert duplicate key row in object 'dbo.Table' with unique index > 'IX\_Indexname'.The statement has been terminated." > > > Is there some way I can turn on logging or at least debug into the datacontext to see what sql is being executed at the time ...
A simple way to do this is to use the [DataContext.Log](http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.log.aspx) property: ``` using (MyDataContext ctx = new MyDataContext()) { StringWriter sw = new StringWriter(); ctx.Log = sw; // execute some LINQ to SQL operations... string s...
196,591
<p>I need to pad the output of an integer to a given length.</p> <p>For example, with a length of 4 digits, the output of the integer 4 is "0004" instead of "4". How can I do this in C# 2.0?</p>
[ { "answer_id": 196599, "author": "Stephen Wrighton", "author_id": 7516, "author_profile": "https://Stackoverflow.com/users/7516", "pm_score": 6, "selected": true, "text": "<p>Use the string.Format command.</p>\n\n<pre><code>output = String.Format(\"{0:0000}\", intVariable); \n</code></pr...
2008/10/13
[ "https://Stackoverflow.com/questions/196591", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20910/" ]
I need to pad the output of an integer to a given length. For example, with a length of 4 digits, the output of the integer 4 is "0004" instead of "4". How can I do this in C# 2.0?
Use the string.Format command. ``` output = String.Format("{0:0000}", intVariable); ``` More details: <http://msdn.microsoft.com/en-us/library/fht0f5be.aspx>
196,603
<p>My company has a large application written in VB6, and for historical reasons, the application is navigated with the Enter key instead of with the Tab key. I don't know VB6, but I know that they currently set the focus for each control in a big select statement in the Form's KeyUp event if it's an EnterKey. Now we...
[ { "answer_id": 196599, "author": "Stephen Wrighton", "author_id": 7516, "author_profile": "https://Stackoverflow.com/users/7516", "pm_score": 6, "selected": true, "text": "<p>Use the string.Format command.</p>\n\n<pre><code>output = String.Format(\"{0:0000}\", intVariable); \n</code></pr...
2008/10/13
[ "https://Stackoverflow.com/questions/196603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12897/" ]
My company has a large application written in VB6, and for historical reasons, the application is navigated with the Enter key instead of with the Tab key. I don't know VB6, but I know that they currently set the focus for each control in a big select statement in the Form's KeyUp event if it's an EnterKey. Now we are ...
Use the string.Format command. ``` output = String.Format("{0:0000}", intVariable); ``` More details: <http://msdn.microsoft.com/en-us/library/fht0f5be.aspx>
196,610
<p>I've been given some code with commenting unlike anything I've come across before:</p> <pre><code>//{{{ Imports import imports; //}}} </code></pre> <p>It is the same for each method block, </p> <pre><code>//{{{ above the code block //}}} below the code block </code></pre> <p>Also see: <a href="http://en.wikip...
[ { "answer_id": 196613, "author": "Glitch", "author_id": 324306, "author_profile": "https://Stackoverflow.com/users/324306", "pm_score": -1, "selected": false, "text": "<p>Maybe it's to emphasize a code block?</p>\n\n<p><em>shrugs</em></p>\n" }, { "answer_id": 196620, "author"...
2008/10/13
[ "https://Stackoverflow.com/questions/196610", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4857/" ]
I've been given some code with commenting unlike anything I've come across before: ``` //{{{ Imports import imports; //}}} ``` It is the same for each method block, ``` //{{{ above the code block //}}} below the code block ``` Also see: <http://en.wikipedia.org/wiki/Folding_editor>
A quick search for *"triple curly" comment* suggests it's "[Emacs folding mode](http://www.emacswiki.org/cgi-bin/wiki/FoldingMode)". Or some other code folding marker in any case.
196,626
<p>I need to do a query that search for a text with <strong>'Nome % teste \ / '</strong> as prefix. I'm doing the query using:</p> <p><strong>where "name" ILIKE 'Nome a% teste \ /%' ESCAPE 'a'</strong> (using a as escape character).</p> <p>There is a row that match this, but this query returns nothing. Removing the ...
[ { "answer_id": 196631, "author": "Adam Pierce", "author_id": 5324, "author_profile": "https://Stackoverflow.com/users/5324", "pm_score": 1, "selected": false, "text": "<p>Have you tried just using the backslash to escape it like this:</p>\n\n<pre><code>where \"name\" ILIKE 'Nome \\% test...
2008/10/13
[ "https://Stackoverflow.com/questions/196626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18403/" ]
I need to do a query that search for a text with **'Nome % teste \ / '** as prefix. I'm doing the query using: **where "name" ILIKE 'Nome a% teste \ /%' ESCAPE 'a'** (using a as escape character). There is a row that match this, but this query returns nothing. Removing the slash (**'Nome % teste \'**), it works. But ...
Use the "ESCAPE" specifier ``` WHERE "name" ILIKE 'Nome ~% teste \\/' ESCAPE '~' ``` <http://www.postgresql.org/docs/8.2/static/functions-matching.html> Note: you still need to have the \ twice for the string parser. Without the ESCAPE you would need to do ``` WHERE "name" ILIKE 'Nome \% test \\\\/' ``` ( ...
196,628
<p>I have the following problem in my <i>Data Structures and Problem Solving using Java</i> book:</p> <blockquote> <p>Write a routine that uses the Collections API to print out the items in any Collection in reverse order. Do not use a ListIterator.</p> </blockquote> <p>I'm not putting it up here because I want so...
[ { "answer_id": 196633, "author": "Karan", "author_id": 11110, "author_profile": "https://Stackoverflow.com/users/11110", "pm_score": 0, "selected": false, "text": "<p>Well you could have a routine that delegates to other routines based on the input type, however I'm not sure there is a g...
2008/10/13
[ "https://Stackoverflow.com/questions/196628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14013/" ]
I have the following problem in my *Data Structures and Problem Solving using Java* book: > > Write a routine that uses the Collections API to print out the items in any Collection in reverse order. Do not use a ListIterator. > > > I'm not putting it up here because I want somebody to do my homework, I just can't...
Regardless from the question not making much sense as half of the collections have no gstable ordering of have fixed-ordering (i.e. TreeSet or PriorityQueue), you can use the following statement for printing the contents of a collection in reverse-natural order: ``` List temp = new ArrayList(src); Collections.reverse(...
196,661
<p>I was hoping to do something like this, but it appears to be illegal in C#:</p> <pre><code>public Collection MethodThatFetchesSomething&lt;T&gt;() where T : SomeBaseClass { return T.StaticMethodOnSomeBaseClassThatReturnsCollection(); } </code></pre> <p>I get a compile-time error:</p> <blockquote> <p>'T' is a...
[ { "answer_id": 196670, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 2, "selected": false, "text": "<p>As of now, you can't. You need a way of telling the compiler that T has that method, and presently, there's no wa...
2008/10/13
[ "https://Stackoverflow.com/questions/196661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8169/" ]
I was hoping to do something like this, but it appears to be illegal in C#: ``` public Collection MethodThatFetchesSomething<T>() where T : SomeBaseClass { return T.StaticMethodOnSomeBaseClassThatReturnsCollection(); } ``` I get a compile-time error: > > 'T' is a 'type parameter', which is not valid in the...
In this case you should just call the static method on the constrainted type directly. C# (and the CLR) do not support virtual static methods. So: ``` T.StaticMethodOnSomeBaseClassThatReturnsCollection ``` ...can be no different than: ``` SomeBaseClass.StaticMethodOnSomeBaseClassThatReturnsCollection ``` Going th...
196,668
<p>I'm working on a system that includes a large number of reports, generated using <a href="http://jasperforge.org/plugins/project/project_home.php?group_id=102" rel="noreferrer">JasperReports</a>. One of the newer features is that you can define styles for reports.</p> <p>From the available docs I believe there is s...
[ { "answer_id": 206403, "author": "Jamie Love", "author_id": 27308, "author_profile": "https://Stackoverflow.com/users/27308", "pm_score": 6, "selected": true, "text": "<p>Use <a href=\"http://jasperreports.sourceforge.net/sample.reference/templates/#templates\" rel=\"nofollow noreferrer\...
2008/10/13
[ "https://Stackoverflow.com/questions/196668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27308/" ]
I'm working on a system that includes a large number of reports, generated using [JasperReports](http://jasperforge.org/plugins/project/project_home.php?group_id=102). One of the newer features is that you can define styles for reports. From the available docs I believe there is some way to have an external file defin...
Use [JasperReport templates](http://jasperreports.sourceforge.net/sample.reference/templates/#templates). A JasperReports template is one that ends in `.jrtx`, and may look similar to this (`styles.jrtx`): ``` <?xml version="1.0"?> <!DOCTYPE jasperTemplate PUBLIC "-//JasperReports//DTD Template//EN" "http://jasper...
196,684
<p>All right, say I have this:</p> <pre><code>&lt;select id='list'&gt; &lt;option value='1'&gt;Option A&lt;/option&gt; &lt;option value='2'&gt;Option B&lt;/option&gt; &lt;option value='3'&gt;Option C&lt;/option&gt; &lt;/select&gt; </code></pre> <p>What would the selector look like if I wanted to get "Opti...
[ { "answer_id": 196687, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 11, "selected": true, "text": "<p>It's looking for an element with id <code>list</code> which has a property <code>value</code> equal to <code>2</code>.<br>\...
2008/10/13
[ "https://Stackoverflow.com/questions/196684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16417/" ]
All right, say I have this: ``` <select id='list'> <option value='1'>Option A</option> <option value='2'>Option B</option> <option value='3'>Option C</option> </select> ``` What would the selector look like if I wanted to get "Option B" when I have the value '2'? Please note that this is not asking how ...
It's looking for an element with id `list` which has a property `value` equal to `2`. What you want is the `option` child of the `list`: ``` $("#list option[value='2']").text() ```
196,702
<p>Say I have a fairly hefty JavaScript file, packed down to roughly 100kb or so. By file I mean it’s an external file that would be linked in via <code>&lt;script src="..."&gt;</code>, not pasted into the HTML itself.</p> <p>Where’s the best place to put this in the HTML?</p> <pre><code>&lt;html&gt; &lt;head&gt; ...
[ { "answer_id": 196708, "author": "Levi Rosol", "author_id": 23458, "author_profile": "https://Stackoverflow.com/users/23458", "pm_score": 6, "selected": false, "text": "<p>The best place for it is just before you need it and no sooner. </p>\n\n<p>Also, depending on your users' physical l...
2008/10/13
[ "https://Stackoverflow.com/questions/196702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
Say I have a fairly hefty JavaScript file, packed down to roughly 100kb or so. By file I mean it’s an external file that would be linked in via `<script src="...">`, not pasted into the HTML itself. Where’s the best place to put this in the HTML? ``` <html> <head> <!-- here? --> <link rel="stylesheet" href="s...
The Yahoo! Exceptional Performance team recommend [placing scripts at the bottom of your page](http://developer.yahoo.com/performance/rules.html#js_bottom) because of the way browsers download components. Of course Levi's comment "just before you need it and no sooner" is really the correct answer, i.e. "it depends".
196,713
<p>I need to match something in the form </p> <pre><code>&lt;a href="pic/5" id="piclink"&gt;&lt;img src="thumb/5" /&gt;&lt;/a&gt; </code></pre> <p>to find the number, in this case 5, using JavaScript. I have no idea how to use regexes, so I was wondering if anyone here could help out.</p>
[ { "answer_id": 196717, "author": "num1", "author_id": 306, "author_profile": "https://Stackoverflow.com/users/306", "pm_score": 1, "selected": false, "text": "<p>Nevermind, I solved it with a simple </p>\n\n<pre><code>'&lt;a href=\"pic/5\" id=\"piclink\"&gt;&lt;img src=\"thumb/5\" /&gt;&...
2008/10/13
[ "https://Stackoverflow.com/questions/196713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/306/" ]
I need to match something in the form ``` <a href="pic/5" id="piclink"><img src="thumb/5" /></a> ``` to find the number, in this case 5, using JavaScript. I have no idea how to use regexes, so I was wondering if anyone here could help out.
Just to make sure you know what's going on, the pattern you posted in your own answer will match exactly **one** digit between 0 and 9. If you want to match integers with one or more digits, you might try the pattern ``` /[0-9]+/ ``` Check out [Wikipedia's article on Regular Expressions](http://en.wikipedia.org/wik...
196,721
<p>I'm trying to configure my WAR project build to fail if the line or branch coverage is below given thresholds. I've been using the configuration provided on page 455 of the excellent book <a href="http://oreilly.com/catalog/9780596527938/" rel="noreferrer">Java Power Tools</a>, but with no success. Here's the releva...
[ { "answer_id": 197014, "author": "Brian Matthews", "author_id": 1969, "author_profile": "https://Stackoverflow.com/users/1969", "pm_score": 2, "selected": false, "text": "<p>Add the following to the &lt;check/&gt; configuration.</p>\n\n<pre>\n&lt;haltOnFailure&gt;true&lt;/haltOnFailure&g...
2008/10/13
[ "https://Stackoverflow.com/questions/196721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10433/" ]
I'm trying to configure my WAR project build to fail if the line or branch coverage is below given thresholds. I've been using the configuration provided on page 455 of the excellent book [Java Power Tools](http://oreilly.com/catalog/9780596527938/), but with no success. Here's the relevant snippet of my project's Mave...
To my knowledge, *if the `<haltOnFailure>` element is set to true and any of the specified checks fails, then Cobertura will cause the build to fail* which is what you're asking for. But actually, this element defaults to `true` if you do not specify it so you **don't have to** add it to your [configuration checks](htt...
196,730
<p>I need to extract only the 2nd level part of the domain from request.servervariables("HTTP_HOST") what is the best way to do this?</p>
[ { "answer_id": 196752, "author": "Brian Boatright", "author_id": 3747, "author_profile": "https://Stackoverflow.com/users/3747", "pm_score": 1, "selected": false, "text": "<pre><code>If Len(strHostDomain) &gt; 0 Then \n aryDomain = Split(strHostDomain,\".\")\n\n If uBound(aryD...
2008/10/13
[ "https://Stackoverflow.com/questions/196730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3747/" ]
I need to extract only the 2nd level part of the domain from request.servervariables("HTTP\_HOST") what is the best way to do this?
This can be solved through a regular expression. Since the `HTTP_HOST` server variable can contain only valid host names, we don't need to care about *validating* the string, only about finding out its structure. Therefore the regex is kept fairly simple, but would not work reliably in broader contexts. And the struc...
196,732
<p>I've inherited a piece of code with a snippet which empties the database as follows:</p> <pre><code>dbmopen (%db,"file.db",0666); foreach $key (keys %db) { delete $db{$key}; } dbmclose (%db); </code></pre> <p>This is usually okay but sometimes the database grows very large before this cleanup code is called and ...
[ { "answer_id": 196816, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 3, "selected": false, "text": "<p>Actually, a workmate has pointed me to a solution. You can apparently do:</p>\n\n<pre><code>dbmopen (%db,\"file.db\"...
2008/10/13
[ "https://Stackoverflow.com/questions/196732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14860/" ]
I've inherited a piece of code with a snippet which empties the database as follows: ``` dbmopen (%db,"file.db",0666); foreach $key (keys %db) { delete $db{$key}; } dbmclose (%db); ``` This is usually okay but sometimes the database grows very large before this cleanup code is called and it's usually when a user w...
You can just delete the file: ``` unlink $file; ``` Since your third argument to [dbmopen](http://perldoc.perl.org/functions/dbmopen.html) is a file mode and not `undef`, `dbmopen` will recreate the file the next time it's called: ``` dbmopen my %db, $file, 0666; ```
196,733
<p>I have code like this:</p> <pre><code>class RetInterface {...} class Ret1: public RetInterface {...} class AInterface { public: virtual boost::shared_ptr&lt;RetInterface&gt; get_r() const = 0; ... }; class A1: public AInterface { public: boost::shared_ptr&lt;Ret1&gt; get_r() const {...} ....
[ { "answer_id": 196744, "author": "Mr Fooz", "author_id": 25050, "author_profile": "https://Stackoverflow.com/users/25050", "pm_score": 2, "selected": false, "text": "<p>You can't change return types (for non-pointer, non-reference return types) when overloading methods in C++. <code>A1:...
2008/10/13
[ "https://Stackoverflow.com/questions/196733", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19501/" ]
I have code like this: ``` class RetInterface {...} class Ret1: public RetInterface {...} class AInterface { public: virtual boost::shared_ptr<RetInterface> get_r() const = 0; ... }; class A1: public AInterface { public: boost::shared_ptr<Ret1> get_r() const {...} ... }; ``` **This code do...
Firstly, this is indeed how it works in C++: the return type of a virtual function in a derived class must be the same as in the base class. There is the special exception that a function that returns a reference/pointer to some class X can be overridden by a function that returns a reference/pointer to a class that de...
196,754
<p>I've seen some horrific code written in Perl, but I can't make head nor tail of this one:</p> <pre><code>select((select(s),$|=1)[0]) </code></pre> <p>It's in some networking code that we use to communicate with a server and I assume it's something to do with buffering (since it sets <code>$|</code>).</p> <p>But I...
[ { "answer_id": 196768, "author": "Dan", "author_id": 17121, "author_profile": "https://Stackoverflow.com/users/17121", "pm_score": 7, "selected": true, "text": "<p>It's a nasty little idiom for setting autoflush on a filehandle other than STDOUT. </p>\n\n<p><code>select()</code> takes th...
2008/10/13
[ "https://Stackoverflow.com/questions/196754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14860/" ]
I've seen some horrific code written in Perl, but I can't make head nor tail of this one: ``` select((select(s),$|=1)[0]) ``` It's in some networking code that we use to communicate with a server and I assume it's something to do with buffering (since it sets `$|`). But I can't figure out why there's multiple `sele...
It's a nasty little idiom for setting autoflush on a filehandle other than STDOUT. `select()` takes the supplied filehandle and (basically) replaces STDOUT with it, and it returns the old filehandle when it's done. So `(select($s),$|=1)` redirects the filehandle (remember `select` returns the old one), and sets aut...
196,755
<p>Given a string of keywords, such as "Python best practices", I would like to obtain the first 10 Stack Overflow questions that contain that keywords, sorted by relevance (?), say from a Python script. My goal is to end up with a list of tuples (title, URL).</p> <p>How can I accomplish this? Would you consider query...
[ { "answer_id": 196758, "author": "Xenph Yan", "author_id": 264, "author_profile": "https://Stackoverflow.com/users/264", "pm_score": 1, "selected": false, "text": "<p>You could screen scrape the returned HTML from a valid HTTP request. But that would result in bad karma, and the loss of ...
2008/10/13
[ "https://Stackoverflow.com/questions/196755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18770/" ]
Given a string of keywords, such as "Python best practices", I would like to obtain the first 10 Stack Overflow questions that contain that keywords, sorted by relevance (?), say from a Python script. My goal is to end up with a list of tuples (title, URL). How can I accomplish this? Would you consider querying Google...
``` >>> from urllib import urlencode >>> params = urlencode({'q': 'python best practices', 'sort': 'relevance'}) >>> params 'q=python+best+practices&sort=relevance' >>> from urllib2 import urlopen >>> html = urlopen("http://stackoverflow.com/search?%s" % params).read() >>> import re >>> links = re.findall(r'<h3><a href...
196,771
<p>I have a PHP application which needs to output a python script, more specifically a bunch of variable assignment statements, eg.</p> <pre><code>subject_prefix = 'This String From User Input' msg_footer = """This one too.""" </code></pre> <p>The contents of subject_prefix et al need to be written to take user input...
[ { "answer_id": 196783, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": -1, "selected": false, "text": "<p>I suggest writing a function that will take two arguments: the text to be escaped and the type of quotes the string is...
2008/10/13
[ "https://Stackoverflow.com/questions/196771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3528/" ]
I have a PHP application which needs to output a python script, more specifically a bunch of variable assignment statements, eg. ``` subject_prefix = 'This String From User Input' msg_footer = """This one too.""" ``` The contents of subject\_prefix et al need to be written to take user input; as such, I need to esca...
**Do not** try write this function in PHP. You will inevitably get it wrong and your application will inevitably have an arbitrary remote execution exploit. First, consider what problem you are actually solving. I presume you are just trying to get data from PHP to Python. You might try to write a .ini file rather tha...
196,788
<p>I'm trying to implement search result highlighting for pdfs in a web app. I have the original pdfs, and small png versions that are used in search results. Essentially I'm looking for an api like:</p> <pre><code>pdf_document.find_offsets('somestring') # =&gt; { top: 501, left: 100, bottom: 520, right: 150 }, { ... ...
[ { "answer_id": 200768, "author": "msanders", "author_id": 1002, "author_profile": "https://Stackoverflow.com/users/1002", "pm_score": 1, "selected": false, "text": "<p>I think you can do this using the Adobe Acrobat SDK, a Linux version of which can be <a href=\"http://www.adobe.com/devn...
2008/10/13
[ "https://Stackoverflow.com/questions/196788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3624/" ]
I'm trying to implement search result highlighting for pdfs in a web app. I have the original pdfs, and small png versions that are used in search results. Essentially I'm looking for an api like: ``` pdf_document.find_offsets('somestring') # => { top: 501, left: 100, bottom: 520, right: 150 }, { ... another box ... }...
Try to look at PdfLib TET <http://www.pdflib.com/products/tet/> (it's not free) Fabrizio
196,824
<p>How do you process information in Java that was input from a file. For Example: suppose you have a file input.txt. The contents of this file is: abcdefghizzzzjklmnop azzbcdefghijklmnop</p> <p>My hope would be that the information would be put into the argument array of strings such that the following code would...
[ { "answer_id": 196831, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 3, "selected": false, "text": "<p>You should be able to read the input data from <code>System.in</code>.</p>\n\n<p>Here's some quick-and-dirty exampl...
2008/10/13
[ "https://Stackoverflow.com/questions/196824", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do you process information in Java that was input from a file. For Example: suppose you have a file input.txt. The contents of this file is: abcdefghizzzzjklmnop azzbcdefghijklmnop My hope would be that the information would be put into the argument array of strings such that the following code would output "abc...
You should be able to read the input data from `System.in`. Here's some quick-and-dirty example code. `javac Test.java; java Test < Test.java`: ``` class Test { public static void main (String[] args) { byte[] bytes = new byte[1024]; try { while (System.in.available() > 0) ...
196,830
<p>Some ways to iterate through the characters of a string in Java are:</p> <ol> <li>Using <code>StringTokenizer</code>?</li> <li>Converting the <code>String</code> to a <code>char[]</code> and iterating over that.</li> </ol> <p>What is the easiest/best/most correct way to iterate?</p>
[ { "answer_id": 196834, "author": "jjnguy", "author_id": 2598, "author_profile": "https://Stackoverflow.com/users/2598", "pm_score": 10, "selected": true, "text": "<p>I use a for loop to iterate the string and use <code>charAt()</code> to get each character to examine it. Since the Strin...
2008/10/13
[ "https://Stackoverflow.com/questions/196830", "https://Stackoverflow.com", "https://Stackoverflow.com/users/85/" ]
Some ways to iterate through the characters of a string in Java are: 1. Using `StringTokenizer`? 2. Converting the `String` to a `char[]` and iterating over that. What is the easiest/best/most correct way to iterate?
I use a for loop to iterate the string and use `charAt()` to get each character to examine it. Since the String is implemented with an array, the `charAt()` method is a constant time operation. ``` String s = "...stuff..."; for (int i = 0; i < s.length(); i++){ char c = s.charAt(i); //Process char } ...
196,840
<p>I am looking for a way to add a drop down list in WPF to a menu. This used to be really easy in winforms and so I am expecting you experts to know just now to do it in WPF. Thanks.</p> <p>Sorry if this is a bad question, it is late and I don't want to think.</p>
[ { "answer_id": 196873, "author": "Jobi Joy", "author_id": 8091, "author_profile": "https://Stackoverflow.com/users/8091", "pm_score": 6, "selected": true, "text": "<p>It is very easy to add any UIElement to any control, You can just add Combobox to a Menu control and create menu as bello...
2008/10/13
[ "https://Stackoverflow.com/questions/196840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22914/" ]
I am looking for a way to add a drop down list in WPF to a menu. This used to be really easy in winforms and so I am expecting you experts to know just now to do it in WPF. Thanks. Sorry if this is a bad question, it is late and I don't want to think.
It is very easy to add any UIElement to any control, You can just add Combobox to a Menu control and create menu as bellow. ``` <Menu> <MenuItem Header="File"> <MenuItem Header="Open"/> <MenuItem Header="Close"/> <Separator/> <ComboBox Width="85" Height="21.96" /> </MenuItem> </...
196,841
<p>In Python, you can do this:</p> <pre><code>print &quot;Hi! I'm %(name)s, and I'm %(age)d years old.&quot; % ({&quot;name&quot;:&quot;Brian&quot;,&quot;age&quot;:30}) </code></pre> <p>What's the closest, simplest Ruby idiom to replicate this behavior? (No monkeypatching the String class, please.)</p> <p>One of the ...
[ { "answer_id": 196847, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 2, "selected": false, "text": "<p>In a double-quoted string in Ruby, you can insert the result of a Ruby expression like this:</p>\n\n<pre><code>puts \"H...
2008/10/13
[ "https://Stackoverflow.com/questions/196841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16034/" ]
In Python, you can do this: ``` print "Hi! I'm %(name)s, and I'm %(age)d years old." % ({"name":"Brian","age":30}) ``` What's the closest, simplest Ruby idiom to replicate this behavior? (No monkeypatching the String class, please.) One of the really excellent benefits of this is that you can store the pre-process...
You can also use ``` printf "1: %<key1>s 2: %<key2>s\n", {:key1 => "value1", :key2 => "value2"} ``` or ``` data = {:key1 => "value1", :key2 => "value2"} printf "1: %<key1>s 2: %<key2>s\n", data ``` or (this needs ruby 1.9, for the other examples I'm not sure) ``` data = {key1: "value1", key2: "value2"} printf ...
196,859
<p>I need to change color of TextBox whenever its required field validator is fired on Clicking the Submit button</p>
[ { "answer_id": 196916, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 0, "selected": false, "text": "<p>Here's some self-contained HTML/JS that does the trick:</p>\n\n<pre><code>&lt;html&gt;\n &lt;head&gt;\n &lt;scrip...
2008/10/13
[ "https://Stackoverflow.com/questions/196859", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to change color of TextBox whenever its required field validator is fired on Clicking the Submit button
What you can do is register a Javascript function that will iterate through the global Page\_Validators array after submission and you can set the background appropriately. The nice thing about this is that you can use it on all of your controls on the page. The function looks like this: ``` function fnOnUpdateValidat...
196,876
<p>Just looking at ways of getting named constants in python.</p> <pre><code>class constant_list: (A_CONSTANT, B_CONSTANT, C_CONSTANT) = range(3) </code></pre> <p>Then of course you can refer to it like so: </p> <pre><code>constant_list.A_CONSTANT </code></pre> <p>I suppose you could use a dictionary, using st...
[ { "answer_id": 196880, "author": "Simon Peverett", "author_id": 6063, "author_profile": "https://Stackoverflow.com/users/6063", "pm_score": 2, "selected": false, "text": "<p>I find the enumeration class recipe (Active State, <a href=\"http://code.activestate.com/recipes/67107/\" rel=\"no...
2008/10/13
[ "https://Stackoverflow.com/questions/196876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61/" ]
Just looking at ways of getting named constants in python. ``` class constant_list: (A_CONSTANT, B_CONSTANT, C_CONSTANT) = range(3) ``` Then of course you can refer to it like so: ``` constant_list.A_CONSTANT ``` I suppose you could use a dictionary, using strings: ``` constant_dic = { "A_CONSTANT" : 1...
For 2.3 or after: ``` class Enumerate(object): def __init__(self, names): for number, name in enumerate(names.split()): setattr(self, name, number) ``` To use: ``` codes = Enumerate('FOO BAR BAZ') ``` `codes.BAZ` will be 2 and so on. If you only have 2.2, precede this with: ``` from __future__ im...
196,883
<p>I am having an ASP.net page in my page i am having this as my code behind files. on first access the page the page preinit, init, load methods are called. on postbacks the preinit, init, load methods are called.</p> <p>My question is LoadViewstate and control state events (Overridden methods) are not firing after p...
[ { "answer_id": 196880, "author": "Simon Peverett", "author_id": 6063, "author_profile": "https://Stackoverflow.com/users/6063", "pm_score": 2, "selected": false, "text": "<p>I find the enumeration class recipe (Active State, <a href=\"http://code.activestate.com/recipes/67107/\" rel=\"no...
2008/10/13
[ "https://Stackoverflow.com/questions/196883", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22162/" ]
I am having an ASP.net page in my page i am having this as my code behind files. on first access the page the page preinit, init, load methods are called. on postbacks the preinit, init, load methods are called. My question is LoadViewstate and control state events (Overridden methods) are not firing after postbacks a...
For 2.3 or after: ``` class Enumerate(object): def __init__(self, names): for number, name in enumerate(names.split()): setattr(self, name, number) ``` To use: ``` codes = Enumerate('FOO BAR BAZ') ``` `codes.BAZ` will be 2 and so on. If you only have 2.2, precede this with: ``` from __future__ im...
196,885
<p>How can I determine if I'm running on a 32bit or a 64bit version of matlab?</p> <p>I have some pre-compiled mex-files which need different path's depending on 32/64bit matlab.</p>
[ { "answer_id": 206927, "author": "Adrian", "author_id": 28406, "author_profile": "https://Stackoverflow.com/users/28406", "pm_score": 2, "selected": false, "text": "<p>Does this really work? Which version of matlab are you using?</p>\n\n<p>As far as I'm aware the 64 bit platforms end wit...
2008/10/13
[ "https://Stackoverflow.com/questions/196885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27331/" ]
How can I determine if I'm running on a 32bit or a 64bit version of matlab? I have some pre-compiled mex-files which need different path's depending on 32/64bit matlab.
Taking up on ScottieT812 and dwj suggestions, I post my own solution to earn some points. The function `computer` returns the architecture I'm running on. so: ``` switch computer case 'GLNX86' display('32-bit stuff') case 'GLNXA64' display('64-bit stuff') otherwise display('Not sup...
196,890
<p>I'm having performance oddities with Java2D. I know of the sun.java2d.opengl VM parameter to enable 3D acceleration for 2D, but even using that has some weird issues. </p> <p>Here are results of tests I ran:</p> <p>Drawing a 25x18 map with 32x32 pixel tiles on a JComponent<br> Image 1 = .bmp format, Image 2 = A .p...
[ { "answer_id": 196893, "author": "Nick Stinemates", "author_id": 4960, "author_profile": "https://Stackoverflow.com/users/4960", "pm_score": 2, "selected": false, "text": "<p>From what I remember when I was thinking about doing graphics programming in Java, the built in libraries are slo...
2008/10/13
[ "https://Stackoverflow.com/questions/196890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1191472/" ]
I'm having performance oddities with Java2D. I know of the sun.java2d.opengl VM parameter to enable 3D acceleration for 2D, but even using that has some weird issues. Here are results of tests I ran: Drawing a 25x18 map with 32x32 pixel tiles on a JComponent Image 1 = .bmp format, Image 2 = A .png format Without...
I think I found a solution by researching and putting bits and pieces together from too many Google searches. Here it is, comments and all: ``` private BufferedImage toCompatibleImage(BufferedImage image) { // obtain the current system graphical settings GraphicsConfiguration gfxConfig = GraphicsEnvironment....
196,930
<p>How, in the simplest possible way, distinguish between Windows XP and Windows Vista, using Python and <a href="http://python.net/crew/mhammond/win32/Downloads.html" rel="noreferrer">pywin32</a> or <a href="http://www.wxpython.org/" rel="noreferrer">wxPython</a>?</p> <p>Essentially, I need a function that called wil...
[ { "answer_id": 196931, "author": "DzinX", "author_id": 18745, "author_profile": "https://Stackoverflow.com/users/18745", "pm_score": 3, "selected": false, "text": "<p>The simplest solution I found is this one:</p>\n\n<pre><code>import sys\n\ndef isWindowsVista():\n '''Return True iff ...
2008/10/13
[ "https://Stackoverflow.com/questions/196930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18745/" ]
How, in the simplest possible way, distinguish between Windows XP and Windows Vista, using Python and [pywin32](http://python.net/crew/mhammond/win32/Downloads.html) or [wxPython](http://www.wxpython.org/)? Essentially, I need a function that called will return True iff current OS is Vista: ``` >>> isWindowsVista() T...
Python has the lovely 'platform' module to help you out. ``` >>> import platform >>> platform.win32_ver() ('XP', '5.1.2600', 'SP2', 'Multiprocessor Free') >>> platform.system() 'Windows' >>> platform.version() '5.1.2600' >>> platform.release() 'XP' ``` NOTE: As mentioned in the comments proper values may not be retu...
196,936
<p>I'm writing some code for a class constructor which loops through all the properties of the class and calls a generic static method which populates my class with data from an external API. So I've got this as an example class:</p> <pre><code>public class MyClass{ public string Property1 { get; set; } public int...
[ { "answer_id": 196945, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 5, "selected": true, "text": "<p>Do you want to call DoStuff&lt;T&gt; with T = the type of each property? In which case, \"as is\" you would need to...
2008/10/13
[ "https://Stackoverflow.com/questions/196936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11388/" ]
I'm writing some code for a class constructor which loops through all the properties of the class and calls a generic static method which populates my class with data from an external API. So I've got this as an example class: ``` public class MyClass{ public string Property1 { get; set; } public int Property2 { g...
Do you want to call DoStuff<T> with T = the type of each property? In which case, "as is" you would need to use reflection and MakeGenericMethod - i.e. ``` var properties = this.GetType().GetProperties(); foreach (PropertyInfo p in properties) { object value = typeof(MyClass) .GetMethod("DoStuff") .MakeGen...
196,946
<p>I was trying the following example, but with external URLs: <a href="http://android-developers.blogspot.com/2008/09/using-webviews.html" rel="nofollow noreferrer">Using WebViews</a></p> <p>The example shows how to load an HTML file from assets folder (<code>file:// url</code>) and display it in a WebView. </p> <p>...
[ { "answer_id": 198662, "author": "Tahir Akhtar", "author_id": 18027, "author_profile": "https://Stackoverflow.com/users/18027", "pm_score": 6, "selected": true, "text": "<p>I found out the answer myself.</p>\n\n<p>The permission name is android.permission.INTERNET.</p>\n\n<p>Adding follo...
2008/10/13
[ "https://Stackoverflow.com/questions/196946", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18027/" ]
I was trying the following example, but with external URLs: [Using WebViews](http://android-developers.blogspot.com/2008/09/using-webviews.html) The example shows how to load an HTML file from assets folder (`file:// url`) and display it in a WebView. But when I try it with external URLs (like <http://google.com>), ...
I found out the answer myself. The permission name is android.permission.INTERNET. Adding following line to the AndroidManifest.xml (nested directly in tag) did the trick: ``` <uses-permission android:name="android.permission.INTERNET"></uses-permission> ``` The file can also be edited graphically in Eclipse plugi...
196,949
<p>I have an application that I have to run as Administrator.</p> <p>One small part of that application is to start other applications with Process.Start</p> <p>The started applications will also be run as administrators, but I'd rather see them run as the 'normal' user.</p> <p>How do I accomplish that?</p> <p>/joh...
[ { "answer_id": 196959, "author": "Greg Dean", "author_id": 1200558, "author_profile": "https://Stackoverflow.com/users/1200558", "pm_score": 3, "selected": false, "text": "<p>From: <a href=\"http://go.microsoft.com/fwlink/?LinkId=81232\" rel=\"nofollow noreferrer\">http://go.microsoft.co...
2008/10/13
[ "https://Stackoverflow.com/questions/196949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21761/" ]
I have an application that I have to run as Administrator. One small part of that application is to start other applications with Process.Start The started applications will also be run as administrators, but I'd rather see them run as the 'normal' user. How do I accomplish that? /johan/
The WinSafer API's allow a process to be launched as a limited, normal, or elevated user. **Sample Usage:** ``` CreateSaferProcess(@"calc.exe", "", SaferLevel.NormalUser); ``` **Source code:** ``` //http://odetocode.com/Blogs/scott/archive/2004/10/28/602.aspx public static void CreateSaferProcess(String fileName, ...
196,960
<p>I have a dict, which I need to pass key/values as keyword arguments.. For example..</p> <pre><code>d_args = {'kw1': 'value1', 'kw2': 'value2'} example(**d_args) </code></pre> <p>This works fine, <em>but</em> if there are values in the d_args dict that are not accepted by the <code>example</code> function, it obvio...
[ { "answer_id": 196978, "author": "DzinX", "author_id": 18745, "author_profile": "https://Stackoverflow.com/users/18745", "pm_score": 5, "selected": false, "text": "<p>This will print names of all passable arguments, keyword and non-keyword ones:</p>\n<pre><code>def func(one, two=&quot;va...
2008/10/13
[ "https://Stackoverflow.com/questions/196960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/745/" ]
I have a dict, which I need to pass key/values as keyword arguments.. For example.. ``` d_args = {'kw1': 'value1', 'kw2': 'value2'} example(**d_args) ``` This works fine, *but* if there are values in the d\_args dict that are not accepted by the `example` function, it obviously dies.. Say, if the example function is...
A little nicer than inspecting the code object directly and working out the variables is to use the inspect module. ``` >>> import inspect >>> def func(a,b,c=42, *args, **kwargs): pass >>> inspect.getargspec(func) (['a', 'b', 'c'], 'args', 'kwargs', (42,)) ``` If you want to know if its callable with a particular se...
196,966
<p>I need to develop a generic jQuery-based search plugin for the ASP.NET MVC application I'm building, but I can't figure out how it's supposed to fit, or what the best practice is. I want to do the following:</p> <pre><code>$().ready(function() { $('#searchHolder').customSearch('MyApp.Models.User'); }); </code>...
[ { "answer_id": 196999, "author": "liggett78", "author_id": 19762, "author_profile": "https://Stackoverflow.com/users/19762", "pm_score": 0, "selected": false, "text": "<p>I'm not sure I understand what you're trying to accomplish, but I would construct the relevant UI on the server as pa...
2008/10/13
[ "https://Stackoverflow.com/questions/196966", "https://Stackoverflow.com", "https://Stackoverflow.com/users/192/" ]
I need to develop a generic jQuery-based search plugin for the ASP.NET MVC application I'm building, but I can't figure out how it's supposed to fit, or what the best practice is. I want to do the following: ``` $().ready(function() { $('#searchHolder').customSearch('MyApp.Models.User'); }); ``` As long as I hav...
Just to follow up (I'm very surprised nobody else has had any opinions on this), in an effort to keep best practice I've opted to adopt [jTemplates](http://jtemplates.tpython.com/). It enables me to request some Model-style JSON from my server-side Controller and process it using syntax similar to that I would already...
196,972
<p>Is there a simple way to convert a string to Title Case? E.g. <code>john smith</code> becomes <code>John Smith</code>. I'm not looking for something complicated like <a href="http://ejohn.org/blog/title-capitalization-in-javascript/" rel="noreferrer">John Resig's solution</a>, just (hopefully) some kind of one- or t...
[ { "answer_id": 196989, "author": "PhiLho", "author_id": 15459, "author_profile": "https://Stackoverflow.com/users/15459", "pm_score": 3, "selected": false, "text": "<pre><code>var toMatch = \"john w. smith\";\nvar result = toMatch.replace(/(\\w)(\\w*)/g, function (_, i, r) {\n retur...
2008/10/13
[ "https://Stackoverflow.com/questions/196972", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1896/" ]
Is there a simple way to convert a string to Title Case? E.g. `john smith` becomes `John Smith`. I'm not looking for something complicated like [John Resig's solution](http://ejohn.org/blog/title-capitalization-in-javascript/), just (hopefully) some kind of one- or two-liner.
Try this: ```js function toTitleCase(str) { return str.replace( /\w\S*/g, function(txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); } ); } ``` ```html <form> Input: <br /><textarea name="input" onchange="form.output.value=toTitleCase(this.value)" onkeyup="form.output....
196,976
<p>I have an old project that was built using visual studio 2003 and I recompiled it with vs2005 recently. However, during runtime, I get the following error:</p> <p>list iterator not incrementable</p> <p>I traced the program to this function:</p> <pre><code>void InputQueue::update() { list&lt;PCB&gt;::iterator...
[ { "answer_id": 196988, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 3, "selected": false, "text": "<p>Notice that if <code>iter-&gt;arrivalTime == 0</code>, then the list iterator gets incremented twice: once before element...
2008/10/13
[ "https://Stackoverflow.com/questions/196976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have an old project that was built using visual studio 2003 and I recompiled it with vs2005 recently. However, during runtime, I get the following error: list iterator not incrementable I traced the program to this function: ``` void InputQueue::update() { list<PCB>::iterator iter; list<PCB>::iterator iter...
I would re-write your loop to be like the following: ``` while (iter != end()) { if (iter->arrivalTime == 0) { ReadyQueue::getInstance()->add(*iter); iter = erase(iter); } else { ++iter; } } ``` Now you are correctly looping through the list checking every index.
196,993
<p>i have a wordpress blog and want to give people the same user experience for adding comments that is in stackoverflow. There are a number of comments ajax plugins out there but i can't find a working one that allows you to inline on the main page, go in and add comments without first drilling down into a seperate s...
[ { "answer_id": 199132, "author": "Jay", "author_id": 20840, "author_profile": "https://Stackoverflow.com/users/20840", "pm_score": 2, "selected": false, "text": "<p>I think <a href=\"http://wordpress.org/extend/plugins/ajaxd-wordpress/\" rel=\"nofollow noreferrer\">AJAXed Wordpress</a> d...
2008/10/13
[ "https://Stackoverflow.com/questions/196993", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4653/" ]
i have a wordpress blog and want to give people the same user experience for adding comments that is in stackoverflow. There are a number of comments ajax plugins out there but i can't find a working one that allows you to inline on the main page, go in and add comments without first drilling down into a seperate singl...
I was never able to get AJAXed Wordpress to do what me (and apparently the questioner) want to do. I use a custom solution that makes use of a plug-in called [Inline Ajax Comments](http://kashou.net/blog/inline-ajax-comments). I had a heck of a time finding a download link, but here's one that still works: <http://kas...
197,005
<p>I'm using System.Reflection.Emit for a while now, and find it (who don't?) as painful as bug prone.</p> <p>Do you know if there is a good wrapper around the IL Generator, something that I can rely on to emit IL in a more safe and easier manner than with playing directly with SRE?</p> <p><strong>Edit:</strong></p> ...
[ { "answer_id": 197017, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": false, "text": "<p>If you're using .NET 3.5, you may find using Expression Trees to be more reasonable. It entirely depends on what you'...
2008/10/13
[ "https://Stackoverflow.com/questions/197005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4687/" ]
I'm using System.Reflection.Emit for a while now, and find it (who don't?) as painful as bug prone. Do you know if there is a good wrapper around the IL Generator, something that I can rely on to emit IL in a more safe and easier manner than with playing directly with SRE? **Edit:** I know that manipulating expressi...
If you're using .NET 3.5, you may find using Expression Trees to be more reasonable. It entirely depends on what you're doing - and it can still be quite painful - but it's certainly another option to be aware of.
197,009
<p>A python script is running two parallel python processes ( created via os.fork() ) each of which eventually tries to check out a subversion repository leaf into the same working copy dir.</p> <p>Before running 'svn co ...' command in a sub-process ( via python subprocess module ) the parent python code checks if th...
[ { "answer_id": 197025, "author": "Liam", "author_id": 18333, "author_profile": "https://Stackoverflow.com/users/18333", "pm_score": 2, "selected": false, "text": "<p>Within the directory, there should be a directory called '.svn'. Within this, a file named 'locked' indicates that the dir...
2008/10/13
[ "https://Stackoverflow.com/questions/197009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/140995/" ]
A python script is running two parallel python processes ( created via os.fork() ) each of which eventually tries to check out a subversion repository leaf into the same working copy dir. Before running 'svn co ...' command in a sub-process ( via python subprocess module ) the parent python code checks if the working ...
This sounds like a potential race condition, in that something like the following can happen: 1. Process A checks to see if the directory exists (it doesn't yet). 2. Process B checks to see if the directory exists (it doesn't yet). 3. Process A invokes `svn`, which creates the directory. 4. Process B invokes `svn`, wh...
197,027
<p>I would like to declare a dropdown box in a view in an ASP.NET MVC application, for letting the user select a lookup value. I know how to declare plain text boxes but is there an official helper for declaring dropdown boxes (date time pickers and the rest)?.</p> <p>I also don't know what structure I should pass to ...
[ { "answer_id": 197549, "author": "Elijah Manor", "author_id": 4481, "author_profile": "https://Stackoverflow.com/users/4481", "pm_score": 1, "selected": false, "text": "<p>You might check out this blog entry by Scott Guthrie about <a href=\"http://weblogs.asp.net/scottgu/archive/2007/12/...
2008/10/13
[ "https://Stackoverflow.com/questions/197027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2812/" ]
I would like to declare a dropdown box in a view in an ASP.NET MVC application, for letting the user select a lookup value. I know how to declare plain text boxes but is there an official helper for declaring dropdown boxes (date time pickers and the rest)?. I also don't know what structure I should pass to my view fo...
If you have a table of Product Types with description and a value ( id ) that you want to map to your dropdown then do the following inside your action in the controller. ``` //Lets assume you retrieve your product types somehow here ViewData["ProductTypes"] = new List<ProductType>(); ``` Then inside your view type...
197,028
<p>neither</p> <pre><code>&lt;?php system('php file.php'); ?&gt; </code></pre> <p>nor</p> <pre><code>&lt;?php system('/usr/bin/php file.php'); ?&gt; </code></pre> <p>worked. Why?</p> <p>I tried with <code>-q</code>, with <code>!#/usr/bin/php</code> etc.</p>
[ { "answer_id": 197032, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 0, "selected": false, "text": "<p>Without any more info... it's probably the path to the PHP executable, the path to file.php or a file permissions problem....
2008/10/13
[ "https://Stackoverflow.com/questions/197028", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7398/" ]
neither ``` <?php system('php file.php'); ?> ``` nor ``` <?php system('/usr/bin/php file.php'); ?> ``` worked. Why? I tried with `-q`, with `!#/usr/bin/php` etc.
You are supposed to call it with -f, but it should work without it as well: ``` <?php system('/usr/bin/php -f file.php'); ?> ``` What do you mean by "it doesn't work"? Did you want the contents to be outputted as if they were from your script? Use [include](http://php.net/include) or [require](http://php.net/requi...
197,033
<p>Where is the location of my oracle event log (on a default Linux installation)?</p>
[ { "answer_id": 197108, "author": "cagcowboy", "author_id": 19629, "author_profile": "https://Stackoverflow.com/users/19629", "pm_score": 5, "selected": true, "text": "<pre><code>select value from v$parameter where name = 'background_dump_dest'\n</code></pre>\n" }, { "answer_id": ...
2008/10/13
[ "https://Stackoverflow.com/questions/197033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27346/" ]
Where is the location of my oracle event log (on a default Linux installation)?
``` select value from v$parameter where name = 'background_dump_dest' ```
197,045
<p>Is it possible to set a default value for columns in JPA, and if, how is it done using annotations?</p>
[ { "answer_id": 197072, "author": "PEELY", "author_id": 17641, "author_profile": "https://Stackoverflow.com/users/17641", "pm_score": 2, "selected": false, "text": "<p>This isn't possible in JPA.</p>\n\n<p>Here's what you <em>can</em> do with the Column annotation: <a href=\"http://java.s...
2008/10/13
[ "https://Stackoverflow.com/questions/197045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16152/" ]
Is it possible to set a default value for columns in JPA, and if, how is it done using annotations?
Actually it is possible in JPA, although a little bit of a hack using the `columnDefinition` property of the `@Column` annotation, for example: ```java @Column(name="Price", columnDefinition="Decimal(10,2) default '100.00'") ```
197,059
<p>What is the most efficient way of turning the list of values of a dictionary into an array?</p> <p>For example, if I have a <code>Dictionary</code> where <code>Key</code> is <code>String</code> and <code>Value</code> is <code>Foo</code>, I want to get <code>Foo[]</code></p> <p>I am using VS 2005, C# 2.0</p>
[ { "answer_id": 197062, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 8, "selected": true, "text": "<pre><code>// dict is Dictionary&lt;string, Foo&gt;\n\nFoo[] foos = new Foo[dict.Count];\ndict.Values.CopyTo(foos, 0);\n\...
2008/10/13
[ "https://Stackoverflow.com/questions/197059", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4653/" ]
What is the most efficient way of turning the list of values of a dictionary into an array? For example, if I have a `Dictionary` where `Key` is `String` and `Value` is `Foo`, I want to get `Foo[]` I am using VS 2005, C# 2.0
``` // dict is Dictionary<string, Foo> Foo[] foos = new Foo[dict.Count]; dict.Values.CopyTo(foos, 0); // or in C# 3.0: var foos = dict.Values.ToArray(); ```
197,070
<p>Could you provide an example of accessing the Eclipse Abstract Syntax Tree programmatically for a given piece of code?</p> <p>eg getting the AST for:</p> <hr> <h2>Class1.java</h2> <pre><code>package parseable; public class Class1 { /** * @param args */ public static void main(String[] args) { System.out....
[ { "answer_id": 197079, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 3, "selected": true, "text": "<p>It is not an <em>exact</em> answer, that may give you a place where to start:</p>\n\n<p>As said in this <a href=\"https://sta...
2008/10/13
[ "https://Stackoverflow.com/questions/197070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15441/" ]
Could you provide an example of accessing the Eclipse Abstract Syntax Tree programmatically for a given piece of code? eg getting the AST for: --- Class1.java ----------- ``` package parseable; public class Class1 { /** * @param args */ public static void main(String[] args) { System.out.println("Hello worl...
It is not an *exact* answer, that may give you a place where to start: As said in this [question](https://stackoverflow.com/questions/160382/extract-all-string-from-a-java-project#161145), A full example is available in this [eclipse corner article](http://www.eclipse.org/articles/article.php?file=Article-JavaCodeMa...
197,081
<p>How can I do the Ruby method <a href="http://www.ruby-doc.org/core/classes/Array.html#M002241" rel="noreferrer">"Flatten" Ruby Method</a> in C#. This method flattens a jagged array into a single-dimensional array.</p> <p>For example:</p> <pre><code>s = [ 1, 2, 3 ] #=&gt; [1, 2, 3] t = [ 4, 5, 6, [7, 8] ]...
[ { "answer_id": 197087, "author": "Alexander Kojevnikov", "author_id": 712, "author_profile": "https://Stackoverflow.com/users/712", "pm_score": 5, "selected": true, "text": "<p>Recursive solution:</p>\n\n<pre><code>IEnumerable Flatten(IEnumerable array)\n{\n foreach(var item in array)...
2008/10/13
[ "https://Stackoverflow.com/questions/197081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4455/" ]
How can I do the Ruby method ["Flatten" Ruby Method](http://www.ruby-doc.org/core/classes/Array.html#M002241) in C#. This method flattens a jagged array into a single-dimensional array. For example: ``` s = [ 1, 2, 3 ] #=> [1, 2, 3] t = [ 4, 5, 6, [7, 8] ] #=> [4, 5, 6, [7, 8]] a = [ s, t, 9, 10 ] #...
Recursive solution: ``` IEnumerable Flatten(IEnumerable array) { foreach(var item in array) { if(item is IEnumerable) { foreach(var subitem in Flatten((IEnumerable)item)) { yield return subitem; } } else { y...
197,088
<p>In WPF, there are two ways to set the focus to an element.<br> You can either call the .Focus() method of the input element, or call Keyboard.Focus() with the input element as parameter.</p> <pre><code>// first way: item.Focus(); // alternate way: Keyboard.Focus(item); </code></pre> <p>What is the difference betwe...
[ { "answer_id": 197100, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 3, "selected": false, "text": "<p>As per <a href=\"http://msdn.microsoft.com/en-us/library/aa969768.aspx\" rel=\"noreferrer\">WPF documentation on MSDN</...
2008/10/13
[ "https://Stackoverflow.com/questions/197088", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7021/" ]
In WPF, there are two ways to set the focus to an element. You can either call the .Focus() method of the input element, or call Keyboard.Focus() with the input element as parameter. ``` // first way: item.Focus(); // alternate way: Keyboard.Focus(item); ``` What is the difference between these two? Are there spe...
One of the first things that `item.Focus()` does is call `Keyboard.Focus( this )`. If that fails, then it makes calls to `FocusManager`, as decasteljau has answered. The following are copied from disassambler view in [Reflector](http://reflector.red-gate.com/). This is from `UIElement` (`UIElement3D` is the same): `...
197,095
<p>The following code has a simple binding which binds the Text of the TextBlock named MyTextBlock to TextBox's Text and ToolTip property using the exact same Binding notation:</p> <pre><code>&lt;StackPanel&gt; &lt;TextBlock x:Name="MyTextBlock"&gt;Foo Bar&lt;/TextBlock&gt; &lt;TextBox Text="{Binding Elemen...
[ { "answer_id": 197130, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 7, "selected": false, "text": "<p>ToolTips in WPF can contain anything, not just text, so they provide a ContentStringFormat property for the times you...
2008/10/13
[ "https://Stackoverflow.com/questions/197095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39/" ]
The following code has a simple binding which binds the Text of the TextBlock named MyTextBlock to TextBox's Text and ToolTip property using the exact same Binding notation: ``` <StackPanel> <TextBlock x:Name="MyTextBlock">Foo Bar</TextBlock> <TextBox Text="{Binding ElementName=MyTextBlock, Path=Text, Strin...
The following is a wordy solution but it works. ``` <StackPanel> <TextBox Text="{Binding Path=., StringFormat='The answer is: {0}'}"> <TextBox.DataContext> <sys:Int32>42</sys:Int32> </TextBox.DataContext> <TextBox.ToolTip> <ToolTip Content="{Binding}" ContentStringFormat="{}The answer is: {0...
197,096
<p>In a SQL-database I make some selects, that get an duration (as result of a subtraction between two dates) in seconds as an int. But I want to format this result in a human-readable form like 'hh:mm' or 'dd:hh'. Is that possible in SQL and how can I realize this?</p>
[ { "answer_id": 197138, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": true, "text": "<p>In SQL 2005, You can use the following:</p>\n\n<pre><code> select convert(varchar(8), dateadd(second, [SecondsColumn], 0)...
2008/10/13
[ "https://Stackoverflow.com/questions/197096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21005/" ]
In a SQL-database I make some selects, that get an duration (as result of a subtraction between two dates) in seconds as an int. But I want to format this result in a human-readable form like 'hh:mm' or 'dd:hh'. Is that possible in SQL and how can I realize this?
In SQL 2005, You can use the following: ``` select convert(varchar(8), dateadd(second, [SecondsColumn], 0), 108) ``` Which first converts the seconds into a date after 1900-01-01, and then gets the hh:mm:ss part. If the column is more than 24 hours, this will roll over, if you want days and then hours in that...
197,097
<p>I'm having a bit of trouble with the UTL_MAIL package in Oracle 10g, and was wondering if anyone had any solutions?</p> <p>I connect to my DB as SYSMAN and load the following two scripts;</p> <p><strong>@C:\oracle\product\10.2.0\db_1\rdbms\admin\utlmail.sql</strong></p> <p><strong>@C:\oracle\product\10.2.0\db_1\r...
[ { "answer_id": 197103, "author": "cagcowboy", "author_id": 19629, "author_profile": "https://Stackoverflow.com/users/19629", "pm_score": 2, "selected": false, "text": "<p>Sounds like you need to create a PUBLIC SYNONYM for the package..</p>\n\n<pre><code>CREATE PUBLIC SYNONYM UTL_MAIL FO...
2008/10/13
[ "https://Stackoverflow.com/questions/197097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5827/" ]
I'm having a bit of trouble with the UTL\_MAIL package in Oracle 10g, and was wondering if anyone had any solutions? I connect to my DB as SYSMAN and load the following two scripts; **@C:\oracle\product\10.2.0\db\_1\rdbms\admin\utlmail.sql** **@C:\oracle\product\10.2.0\db\_1\rdbms\admin\prvtmail.plb** I set up the ...
I'm pretty sure that public synonyms will be the only difference. ``` SELECT * FROM ALL_SYNONYMS WHERE OWNER = 'PUBLIC' and table_name LIKE 'UTL%' ``` will confirm or deny
197,099
<p>I'm trying to select data from a table defined similar to the following :</p> <pre><code>Column | Data Type ------------------------- Id | Int DataType | Int LoggedData | XML </code></pre> <p>but I only want to select those rows with a specific DataType value, and that contain a string (o...
[ { "answer_id": 197106, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 0, "selected": false, "text": "<p>Is this not doing the trick for you?</p>\n\n<pre><code>SELECT\n Id, \n LoggedData \nFROM\n myTable \nWHERE\n DataTy...
2008/10/13
[ "https://Stackoverflow.com/questions/197099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/377/" ]
I'm trying to select data from a table defined similar to the following : ``` Column | Data Type ------------------------- Id | Int DataType | Int LoggedData | XML ``` but I only want to select those rows with a specific DataType value, and that contain a string (or evaluates a piece of XPa...
If you want to filter by a *searchterm* (like a SQL variable) you will probably need to use something like this: ``` Select Id, LoggedData From myTable Where DataType = 29 And LoggedData.exist('RootNode/ns1:ChildNode[@value=sql:variable("@searchterm")]')=1 ``` where @searchterm is your SQL variable.
197,111
<p>What is an example of a fast SQL to get duplicates in datasets with hundreds of thousands of records. I typically use something like:</p> <pre><code>SELECT afield1, afield2 FROM afile a WHERE 1 &lt; (SELECT count(afield1) FROM afile b WHERE a.afield1 = b.afield1); </code></pre> <p>But this is quite slow.</p>
[ { "answer_id": 197114, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 7, "selected": true, "text": "<p>This is the more direct way:</p>\n\n<pre><code>select afield1,count(afield1) from atable \ngroup by afield1 having...
2008/10/13
[ "https://Stackoverflow.com/questions/197111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3535708/" ]
What is an example of a fast SQL to get duplicates in datasets with hundreds of thousands of records. I typically use something like: ``` SELECT afield1, afield2 FROM afile a WHERE 1 < (SELECT count(afield1) FROM afile b WHERE a.afield1 = b.afield1); ``` But this is quite slow.
This is the more direct way: ``` select afield1,count(afield1) from atable group by afield1 having count(afield1) > 1 ```
197,112
<p>This <a href="http://my.php.net/static" rel="nofollow noreferrer">example</a> is from php.net:</p> <pre><code>&lt;?php function Test() { static $a = 0; echo $a; $a++; } ?&gt; </code></pre> <p>And this is my code:</p> <pre><code>function getNextQuestionID() { static $idx = 0; return $idx++; } <...
[ { "answer_id": 197126, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": true, "text": "<p>I believe you misunderstand what static vars do. Try this code and you may understand better:</p>\n\n<pre><code>echo getNext...
2008/10/13
[ "https://Stackoverflow.com/questions/197112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15345/" ]
This [example](http://my.php.net/static) is from php.net: ``` <?php function Test() { static $a = 0; echo $a; $a++; } ?> ``` And this is my code: ``` function getNextQuestionID() { static $idx = 0; return $idx++; } ``` And I use it in JavaScript: ``` 'quizID=' + "<?php echo getNextQuestionID(...
I believe you misunderstand what static vars do. Try this code and you may understand better: ``` echo getNextQuestionID() . ", " getNextQuestionID() . ", " getNextQuestionID(); ``` And you will see what I mean. The static var only lives as long as the script does. The reason it is returning 0 on the first run ins...
197,121
<p>I'm trying to do the following without too much special case code to deal with invalidated POSITIONs etc:</p> <p>What's the best way to fill in the blanks?</p> <pre><code>void DeleteUnreferencedRecords(CAtlMap&lt;Record&gt;&amp; records) { for(____;____;____) { if( NotReferencedElsewhere(record) ) ...
[ { "answer_id": 197209, "author": "Rob", "author_id": 9236, "author_profile": "https://Stackoverflow.com/users/9236", "pm_score": 0, "selected": false, "text": "<p>My first thoughts would be the save the current POSITION before calling <code>GetNext</code>, then, if you delete the element...
2008/10/13
[ "https://Stackoverflow.com/questions/197121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11898/" ]
I'm trying to do the following without too much special case code to deal with invalidated POSITIONs etc: What's the best way to fill in the blanks? ``` void DeleteUnreferencedRecords(CAtlMap<Record>& records) { for(____;____;____) { if( NotReferencedElsewhere(record) ) { // Delete record ...
According to this: <http://msdn.microsoft.com/en-us/library/0h4c3zkw(VS.80).aspx> RemoveAtPos has these semantics > > Removes the key/value pair stored at the specified position. The memory used to store the element is freed. The POSITION referenced by pos becomes invalid, and while the POSITION of any other elemen...
197,150
<p>I can write a trivial script to do this but in my ongoing quest to get more familliar with unix I'd like to learn efficient methods using built in commands instead.</p> <p>I need to deal with very large files that have a variable number of header lines. the last header line consists of the text 'LastHeaderLine'. I ...
[ { "answer_id": 197169, "author": "Avi", "author_id": 1605, "author_profile": "https://Stackoverflow.com/users/1605", "pm_score": 4, "selected": false, "text": "<p>Using sed:</p>\n\n<pre><code>sed -ne '/LastHeaderLine/,$p' &lt;inputfile\n</code></pre>\n\n<p>will match everything from the ...
2008/10/13
[ "https://Stackoverflow.com/questions/197150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I can write a trivial script to do this but in my ongoing quest to get more familliar with unix I'd like to learn efficient methods using built in commands instead. I need to deal with very large files that have a variable number of header lines. the last header line consists of the text 'LastHeaderLine'. I wish to ou...
Similar to the answer of [Avi](https://stackoverflow.com/questions/197150/skip-file-lines-until-a-match-is-found-then-output-the-rest#197169), but without including the line with "LastHeaderLine". ``` sed -e '1,/LastHeaderLine/d' ```
197,164
<p>In my views I use a helper that takes arbitrary HTML as a block:</p> <pre><code>&lt;% some_block_helper do %&gt; Some arbitrary HTML and ERB variables here. More HTML here. &lt;% end %&gt; </code></pre> <p>My helper does a bunch of things to the passed block of HTML before rendering it back to the view (Markdo...
[ { "answer_id": 248778, "author": "James Baker", "author_id": 9365, "author_profile": "https://Stackoverflow.com/users/9365", "pm_score": 1, "selected": false, "text": "<ol>\n<li>For a functional test, write a normal <a href=\"http://rspec.info/documentation/rails/writing/views.html\" rel...
2008/10/13
[ "https://Stackoverflow.com/questions/197164", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21702/" ]
In my views I use a helper that takes arbitrary HTML as a block: ``` <% some_block_helper do %> Some arbitrary HTML and ERB variables here. More HTML here. <% end %> ``` My helper does a bunch of things to the passed block of HTML before rendering it back to the view (Markdown and other formatting). I would like...
To add just a bit to what James said, I think something like this should work just fine: ``` describe SomeHelper do it 'should do something' do helper.some_block_helper { the_block_code }.should XXXX end end ```
197,171
<p>Not too long ago, I had a problem which required me to <a href="https://stackoverflow.com/questions/186237/program-only-crashes-as-release-build-how-to-debug">set WinDbg.exe as the default post-mortem debugger</a>. Now that I've fixed that and am back doing normal work, it would be really nice if I could set VS to ...
[ { "answer_id": 197208, "author": "MvdD", "author_id": 18044, "author_profile": "https://Stackoverflow.com/users/18044", "pm_score": 4, "selected": true, "text": "<p>from the <a href=\"http://support.microsoft.com/kb/121434\" rel=\"noreferrer\">Microsoft support page</a>:</p>\n\n<pre><cod...
2008/10/13
[ "https://Stackoverflow.com/questions/197171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14302/" ]
Not too long ago, I had a problem which required me to [set WinDbg.exe as the default post-mortem debugger](https://stackoverflow.com/questions/186237/program-only-crashes-as-release-build-how-to-debug). Now that I've fixed that and am back doing normal work, it would be really nice if I could set VS to be my default p...
from the [Microsoft support page](http://support.microsoft.com/kb/121434): ``` 1. Start Registry Editor and locate the following Registry subkey in the HKEY_LOCAL_MACHINE subtree: \SOFTWARE\MICROSOFT\WINDOWS NT\CURRENTVERSION\AEDEBUG 2. Select the Debugger value. 3. On the Edit menu, click String. • To use the ...
197,190
<p>So, I understand <i>that</i> the following doesn't work, but <i>why</i> doesn't it work?</p> <pre><code>interface Adapter&lt;E&gt; {} class Adaptulator&lt;I&gt; { &lt;E, A extends I &amp; Adapter&lt;E&gt;&gt; void add(Class&lt;E&gt; extl, Class&lt;A&gt; intl) { addAdapterFactory(new AdapterFactory&lt;E...
[ { "answer_id": 197301, "author": "Miserable Variable", "author_id": 18573, "author_profile": "https://Stackoverflow.com/users/18573", "pm_score": 2, "selected": false, "text": "<p>This probably does not answer the root question, but just want to point out that the spec unambiguously forb...
2008/10/13
[ "https://Stackoverflow.com/questions/197190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27358/" ]
So, I understand *that* the following doesn't work, but *why* doesn't it work? ``` interface Adapter<E> {} class Adaptulator<I> { <E, A extends I & Adapter<E>> void add(Class<E> extl, Class<A> intl) { addAdapterFactory(new AdapterFactory<E, A>(extl, intl)); } } ``` The `add()` method gives me a comp...
I'm also not sure why the restriction is there. You could try sending a friendly e-mail to the designers of Java 5 Generics (chiefly Gilad Bracha and Neal Gafter). My guess is that they wanted to support only an absolute minimum of [intersection types](https://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4...
197,218
<p>I am trying to get system date in a C program on a MSVC++ 6.0 compiler. I am using a system call:</p> <p><strong>system("date /T")</strong> (output is e.g. 13-Oct-08 which is date on my system in the format i have set) </p> <p>but this prints the date to the i/o console. </p> <p>How do i make take this date as ...
[ { "answer_id": 197227, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 0, "selected": false, "text": "<p>There are a couple of ways to do this using API functions, two that jump to mind are <a href=\"http://msdn.microsoft.c...
2008/10/13
[ "https://Stackoverflow.com/questions/197218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2759376/" ]
I am trying to get system date in a C program on a MSVC++ 6.0 compiler. I am using a system call: **system("date /T")** (output is e.g. 13-Oct-08 which is date on my system in the format i have set) but this prints the date to the i/o console. How do i make take this date as returned by above system call and store...
``` #include <windows.h> #include <iostream> int main() { SYSTEMTIME systmDateTime = {}; ::GetLocalTime(&systmDateTime); wchar_t wszDate[64] = {}; int const result = ::GetDateFormatW( LOCALE_USER_DEFAULT, DATE_SHORTDATE, &systmDateTime, 0, wszDate, _countof(wszDate)); if (result) { std::wcout ...
197,220
<p>I've got an ASP.NET 2.0 website that connects to a SQL database. I've upgraded the SQL server from 2000 to 2008 and since then, one page refuses to work. </p> <p>I've worked out the problem is that the call to SqlDataReader.HasRows is returning false even though the dataset is not empty and removing the check allow...
[ { "answer_id": 197287, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 1, "selected": false, "text": "<p>Does the stored procedure work if you invoke it in directly, say in SSMS? I'd start by making sure that it does.</p...
2008/10/13
[ "https://Stackoverflow.com/questions/197220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27377/" ]
I've got an ASP.NET 2.0 website that connects to a SQL database. I've upgraded the SQL server from 2000 to 2008 and since then, one page refuses to work. I've worked out the problem is that the call to SqlDataReader.HasRows is returning false even though the dataset is not empty and removing the check allows the loop...
Does the stored procedure work if you invoke it in directly, say in SSMS? I'd start by making sure that it does.
197,228
<p>I'm using the jquery library to load the content of an html file. Something like this:</p> <p>$("#Main").load("login.html")</p> <p>If the file (in this case 'login.html') does not exist, I would like to detect it so that I can redirect the user to an error page for example. Any ideas how I can detect if the file t...
[ { "answer_id": 197237, "author": "redsquare", "author_id": 6440, "author_profile": "https://Stackoverflow.com/users/6440", "pm_score": 5, "selected": true, "text": "<p>You can use the ajaxComplete event, whis gives you access to the xhr object which you can query the status of the reques...
2008/10/13
[ "https://Stackoverflow.com/questions/197228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15928/" ]
I'm using the jquery library to load the content of an html file. Something like this: $("#Main").load("login.html") If the file (in this case 'login.html') does not exist, I would like to detect it so that I can redirect the user to an error page for example. Any ideas how I can detect if the file to load exists or ...
You can use the ajaxComplete event, whis gives you access to the xhr object which you can query the status of the request e.g a status of 404 will mean the file does not exist. More Info in the docs <http://docs.jquery.com/Ajax/ajaxComplete#callback> Test here <http://pastebin.me/48f32a74927bb> e.g ``` $("#someDivI...
197,266
<p>Below is the code of a simple html with a table layout. In FF it's looking as I think it should look like, in IE7 it doesn't. what am I doing wrong?<br><br> And how can I fix it?</p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt; &lt;html&gt; &lt;head&gt; &lt;TITLE&gt;t...
[ { "answer_id": 197283, "author": "roundcrisis", "author_id": 162325, "author_profile": "https://Stackoverflow.com/users/162325", "pm_score": 0, "selected": false, "text": "<p>completely agree, you can have a look at blueprint CSS or other CSS frameworks for some help</p>\n" }, { ...
2008/10/13
[ "https://Stackoverflow.com/questions/197266", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15981/" ]
Below is the code of a simple html with a table layout. In FF it's looking as I think it should look like, in IE7 it doesn't. what am I doing wrong? And how can I fix it? ``` <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <TITLE>test</TITLE> </head> <body> ...
I assume you are complaining about the minimal height of the middle row (the one containing only rowspanned cells), and the enlarged height of the adjacent rows to compensate, leaving gaps between the divs. IE cannot calculate optimal row heights when the row contains only rowspanned cells. The usual solution when you...
197,291
<p>Given a table (mytable) containing a numeric field (mynum), how would one go about writing an SQL query which summarizes the table's data based on ranges of values in that field rather than each distinct value?</p> <p>For the sake of a more concrete example, let's make it intervals of 3 and just "summarize" with a ...
[ { "answer_id": 197300, "author": "Jouni K. Seppänen", "author_id": 26575, "author_profile": "https://Stackoverflow.com/users/26575", "pm_score": 5, "selected": true, "text": "<p>The idea is to compute some function of the field that has constant value within each group you want:</p>\n\n<...
2008/10/13
[ "https://Stackoverflow.com/questions/197291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18914/" ]
Given a table (mytable) containing a numeric field (mynum), how would one go about writing an SQL query which summarizes the table's data based on ranges of values in that field rather than each distinct value? For the sake of a more concrete example, let's make it intervals of 3 and just "summarize" with a count(\*),...
The idea is to compute some function of the field that has constant value within each group you want: ``` select count(*), round(mynum/3.0) foo from mytable group by foo; ```
197,294
<p>I have a simple lambda expression which runs fine as a UNIT test and also runs fine when I copy the code into the Main method of my application. However, when I run the same piece of code within a callback method (via JMS courier) I get the above error. Has anyone encountered this?</p> <p>Example code failing:</p> ...
[ { "answer_id": 197352, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 2, "selected": false, "text": "<p>You will normally get this sort of error when a ModuleBuilder has already been 'compiled', or a TypeBuilder has already ...
2008/10/13
[ "https://Stackoverflow.com/questions/197294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a simple lambda expression which runs fine as a UNIT test and also runs fine when I copy the code into the Main method of my application. However, when I run the same piece of code within a callback method (via JMS courier) I get the above error. Has anyone encountered this? Example code failing: ``` Expressio...
You will normally get this sort of error when a ModuleBuilder has already been 'compiled', or a TypeBuilder has already been 'compiled'. I would check where such things happen. Also, a stack trace may be handy in this case.
197,297
<p>I'm writing code that looks similar to this:</p> <pre><code>public IEnumerable&lt;T&gt; Unfold&lt;T&gt;(this T seed) { while (true) { yield return [next (T)object in custom sequence]; } } </code></pre> <p>Obviously, this method is never going to return. (The C# compiler silently allows this, wh...
[ { "answer_id": 197299, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "<p>So long as you document very clearly that the method will never finish iterating (the method itself returns very quick...
2008/10/13
[ "https://Stackoverflow.com/questions/197297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11808/" ]
I'm writing code that looks similar to this: ``` public IEnumerable<T> Unfold<T>(this T seed) { while (true) { yield return [next (T)object in custom sequence]; } } ``` Obviously, this method is never going to return. (The C# compiler silently allows this, while R# gives me the warning *"Function...
So long as you document very clearly that the method will never finish iterating (the method itself returns very quickly, of course) then I think it's fine. Indeed, it can make some algorithms much neater. I don't believe there are any significant memory/perf implications - although if you refer to an "expensive" objec...
197,302
<p>How can I unset variable? For example, PHP has an <code>unset($var)</code> function.</p>
[ { "answer_id": 197306, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": false, "text": "<p>You can't. There's no notion of \"unsetting\" a variable. You can set it to a different value - 0, null, whatever's a...
2008/10/13
[ "https://Stackoverflow.com/questions/197302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25413/" ]
How can I unset variable? For example, PHP has an `unset($var)` function.
There is not really an equivalent to "unset". The closest match I know is the use of the [default](http://msdn.microsoft.com/en-us/library/xwth0h0d(VS.80).aspx) keyword. For example: ``` MyType myvar = default(MyType); string a = default(string); ``` The variable will still be "set", but it will have its default v...