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
232,933
<p>How do I multiply the values of a multi-dimensional array with weights and sum up the results into a new array in PHP or in general?</p> <p>The boring way looks like this:</p> <pre><code>$weights = array(0.25, 0.4, 0.2, 0.15); $values = array ( array(5,10,15), array(20,25,30...
[ { "answer_id": 232963, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 0, "selected": false, "text": "<p>Hm...</p>\n\n<pre><code>foreach($values as $index =&gt; $ary )\n $result[$index] = array_sum($ary) * $weights[$index];...
2008/10/24
[ "https://Stackoverflow.com/questions/232933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6260/" ]
How do I multiply the values of a multi-dimensional array with weights and sum up the results into a new array in PHP or in general? The boring way looks like this: ``` $weights = array(0.25, 0.4, 0.2, 0.15); $values = array ( array(5,10,15), array(20,25,30), arra...
Depends on what you mean by elegant, of course. ``` function weigh(&$vals, $key, $weights) { $sum = 0; foreach($vals as $v) $sum += $v*$weights[$key]; $vals = $sum; } $result = $values; array_walk($result, "weigh", $weights); ``` EDIT: Sorry for not reading your example better. I make result a c...
232,934
<p>I want to subclass the built-in DropDownList in ASP.NET so that I can add functionality to it and use it in my pages. I tried doing this with a UserControl but found that it doesn't expose the internal DropDownList (logically, I guess). I've googled for the answer but can't find anything. </p> <p>I've come as far a...
[ { "answer_id": 232972, "author": "Eoin Campbell", "author_id": 30155, "author_profile": "https://Stackoverflow.com/users/30155", "pm_score": 5, "selected": true, "text": "<p>You want to extend DropDownList in a Custom Control... not in a usercontrol.</p>\n\n<p>Create a new Class Library ...
2008/10/24
[ "https://Stackoverflow.com/questions/232934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/614/" ]
I want to subclass the built-in DropDownList in ASP.NET so that I can add functionality to it and use it in my pages. I tried doing this with a UserControl but found that it doesn't expose the internal DropDownList (logically, I guess). I've googled for the answer but can't find anything. I've come as far as writing ...
You want to extend DropDownList in a Custom Control... not in a usercontrol. Create a new Class Library Project called MyLibrary. Add a class called MyDropDownList.cs ``` namespace My.Namespace.Controls { [ToolboxData("<{0}:MyDropDownList runat=\"server\"></{0}:MyDropDownList>")] public class MyDropDownList: DropDow...
232,935
<p>I want to find an SQL query to find rows where field1 does not contain $x. How can I do this?</p>
[ { "answer_id": 232942, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 5, "selected": false, "text": "<p><code>SELECT * FROM table WHERE field1 NOT LIKE '%$x%';</code> (Make sure you escape $x properly beforehand to avoid SQL...
2008/10/24
[ "https://Stackoverflow.com/questions/232935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26823/" ]
I want to find an SQL query to find rows where field1 does not contain $x. How can I do this?
What kind of field is this? The IN operator cannot be used with a single field, but is meant to be used in subqueries or with predefined lists: ``` -- subquery SELECT a FROM x WHERE x.b NOT IN (SELECT b FROM y); -- predefined list SELECT a FROM x WHERE x.b NOT IN (1, 2, 3, 6); ``` If you are searching a string, go f...
232,938
<p>I have a .rc file which is used to include some text data in my executable, like this:</p> <pre><code>1234 RCDATA myfile.txt </code></pre> <p>This works fine: the content of the 'myfile.txt' is included in my executable. The problem is that no 0-terminator is added to the string, and I cannot add it to the file. I...
[ { "answer_id": 232992, "author": "eugensk", "author_id": 17495, "author_profile": "https://Stackoverflow.com/users/17495", "pm_score": 3, "selected": true, "text": "<p>I don't think so, unless you write your own resource compiler.<br>\nI have not meet one which allowed to build one resou...
2008/10/24
[ "https://Stackoverflow.com/questions/232938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12893/" ]
I have a .rc file which is used to include some text data in my executable, like this: ``` 1234 RCDATA myfile.txt ``` This works fine: the content of the 'myfile.txt' is included in my executable. The problem is that no 0-terminator is added to the string, and I cannot add it to the file. Is there any way of adding ...
I don't think so, unless you write your own resource compiler. I have not meet one which allowed to build one resource from several sources. You may write a small utility to add a trailing '\0' to a file, say makeZ.exe, and set an additional build step: ``` makeZ myfile.txt myfileZ.txt ``` In you .rc there...
232,945
<p>I have an XML document which looks like this:</p> <pre><code>&lt;xconnect&gt; &lt;type&gt;OK&lt;/type&gt; &lt;response/&gt; &lt;report&gt; &lt;id&gt;suppressionlist_get&lt;/id&gt; &lt;name&gt;Suppression List Get&lt;/name&gt; &lt;timestamp&gt;24 Oct 08 @ 10:16AM&lt;/timestamp&gt; &lt;records type=\"...
[ { "answer_id": 232954, "author": "benPearce", "author_id": 4490, "author_profile": "https://Stackoverflow.com/users/4490", "pm_score": 0, "selected": false, "text": "<p>Create a test DataSet and write it out to Xml to get a feel for the Xml format used by a dataset, then either convert t...
2008/10/24
[ "https://Stackoverflow.com/questions/232945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30004/" ]
I have an XML document which looks like this: ``` <xconnect> <type>OK</type> <response/> <report> <id>suppressionlist_get</id> <name>Suppression List Get</name> <timestamp>24 Oct 08 @ 10:16AM</timestamp> <records type=\"user\"/> <records type=\"client\"/> <records type=\"group\"> <recor...
Try: ``` DataSet dataSet = new DataSet(); dataSet.ReadXML("Path to XML"); this.GridView1.DataMember = "record"; this.GridView1.DataSource = dataSet; this.GridView1.DataBind(); ```
232,979
<p>I'm looking to get data such as Size/Capacity, Serial No, Model No, Heads Sectors, Manufacturer and possibly SMART data.</p>
[ { "answer_id": 232991, "author": "jmcd", "author_id": 2285, "author_profile": "https://Stackoverflow.com/users/2285", "pm_score": 0, "selected": false, "text": "<p>You can use <a href=\"http://www.csharphelp.com/archives2/archive334.html\" rel=\"nofollow noreferrer\">WMI</a> to get most ...
2008/10/24
[ "https://Stackoverflow.com/questions/232979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11538/" ]
I'm looking to get data such as Size/Capacity, Serial No, Model No, Heads Sectors, Manufacturer and possibly SMART data.
You can use WMI Calls to access info about the hard disks. //Requires using System.Management; & System.Management.dll Reference ``` ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"c:\""); disk.Get(); Console.WriteLine("Logical Disk Size = " + disk["Size"] + " bytes"); Console.WriteLine(...
232,986
<p>I am attempting to bind a WPF textbox's Maxlength property to a known constant deep within a class. I am using c#.</p> <p>The class has a structure not too dissimilar to the following:</p> <pre><code>namespace Blah { public partial class One { public partial class Two { public ...
[ { "answer_id": 232996, "author": "Joachim Kerschbaumer", "author_id": 20227, "author_profile": "https://Stackoverflow.com/users/20227", "pm_score": 0, "selected": false, "text": "<p>try to bind with x:Static. add a xmlns:local namespace with the namespace of Sizes to your xaml header and...
2008/10/24
[ "https://Stackoverflow.com/questions/232986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31128/" ]
I am attempting to bind a WPF textbox's Maxlength property to a known constant deep within a class. I am using c#. The class has a structure not too dissimilar to the following: ``` namespace Blah { public partial class One { public partial class Two { public string MyBindingValue...
Fixed! Initially I tried doing this: ``` {Binding Path=MetaData+Sizes.Length1} ``` which compiled ok, however the binding failed at runtime, despite the Class 'Two' being the datacontext the path couldn't resolve into the inner static classes (could I have done something like : {Binding Path={x:Static MetaData+Size...
232,997
<p>I have what is essentially a jagged array of name value pairs - i need to generate a set of unique name values from this. the jagged array is approx 86,000 x 11 values. It does not matter to me what way I have to store a name value pair (a single string "name=value" or a specialised class for example KeyValuePair).<...
[ { "answer_id": 233005, "author": "Eoin Campbell", "author_id": 30155, "author_profile": "https://Stackoverflow.com/users/30155", "pm_score": 0, "selected": false, "text": "<p>if you don't need any specific correlation between each key/value pair and the unique values you're generating, y...
2008/10/24
[ "https://Stackoverflow.com/questions/232997", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22100/" ]
I have what is essentially a jagged array of name value pairs - i need to generate a set of unique name values from this. the jagged array is approx 86,000 x 11 values. It does not matter to me what way I have to store a name value pair (a single string "name=value" or a specialised class for example KeyValuePair). ...
**I have it running in 0.34 seconds** down from 9+ minutes The problem is when comparing the KeyValuePair structs. I worked around it by writing a comparer object, and passing an instance of it to the Dictionary. From what I can determine, the KeyValuePair.GetHashCode() returns the hashcode of it's `Key` object (in t...
233,009
<p>Ok: This is some of my table structure that matters here</p> <pre><code>CaseStudyID int Title nvarchar(50) OverrideTitle nvarchar(50) </code></pre> <p>Part of my procedure</p> <pre><code>Declare @Temp table(CaseStudyID int, Title nvarchar(50)) Insert Into @Temp SELECT CaseStudyID,Title FROM CaseStu...
[ { "answer_id": 233039, "author": "splattne", "author_id": 6461, "author_profile": "https://Stackoverflow.com/users/6461", "pm_score": 1, "selected": false, "text": "<p>You could achieve it without using tempory table this way:</p>\n\n<pre><code>SELECT \n MIN(CaseStudyID) AS CaseStudyI...
2008/10/24
[ "https://Stackoverflow.com/questions/233009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11394/" ]
Ok: This is some of my table structure that matters here ``` CaseStudyID int Title nvarchar(50) OverrideTitle nvarchar(50) ``` Part of my procedure ``` Declare @Temp table(CaseStudyID int, Title nvarchar(50)) Insert Into @Temp SELECT CaseStudyID,Title FROM CaseStudy WHERE Visible = 1 AND DisplayOnHo...
That would replace every title that appears multiple times with the corresponding overrideTitle value. It will keep the first occurrence of it, e.g if you have 3 titles like a,a,a only the second and third one will be replaced ``` select distinct cs1.CaseStudyID, case when cs2.CaseStudyID is null then cs1.Ti...
233,013
<p>I recently started learning Python and I was rather surprised to find a 1000 deep recursion limit (by default). If you set it high enough, about 30000, it crashes with a segmentation fault just like C. Although, C seems to go quite a lot higher.</p> <p>(The Python folks are quick to point out that you can always ...
[ { "answer_id": 233028, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 2, "selected": false, "text": "<p>PHP has a default limit of 100 before it dies:</p>\n\n<p><code>Fatal error: Maximum function nesting level of '100' reache...
2008/10/24
[ "https://Stackoverflow.com/questions/233013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/388466/" ]
I recently started learning Python and I was rather surprised to find a 1000 deep recursion limit (by default). If you set it high enough, about 30000, it crashes with a segmentation fault just like C. Although, C seems to go quite a lot higher. (The Python folks are quick to point out that you can always convert recu...
"The Python folks are quick to point out that you can always convert recursive functions to iterative ones and that they're always faster" This is true, but if it's really as easy as all that, why doesn't Python do it for me, so that my code can look as simple as possible? (I say this not to slam Python implementers, ...
233,026
<p>I have a database with a table which is full of conditions and error messages for checking another database.</p> <p>I want to run a loop such that each of these conditions is checked against all the tables in the second database and generae a report which gives the errors.</p> <p>Is this possible in ms access.</p>...
[ { "answer_id": 233086, "author": "Patrick Cuff", "author_id": 7903, "author_profile": "https://Stackoverflow.com/users/7903", "pm_score": 0, "selected": false, "text": "<p>When you say \"report\", do you mean an Access Report, or would writing to a file or Access Form work?</p>\n\n<p>You...
2008/10/24
[ "https://Stackoverflow.com/questions/233026", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31132/" ]
I have a database with a table which is full of conditions and error messages for checking another database. I want to run a loop such that each of these conditions is checked against all the tables in the second database and generae a report which gives the errors. Is this possible in ms access. For example, query...
Here is some more sample code. It illustrates the use of two different types of recordsets. You may wish to read [VBA Traps: Working with Recordsets](http://allenbrowne.com/ser-29.html) by Allen Browne and [List of reserved words in Access 2002 and in later versions of Access](http://support.microsoft.com/kb/286335). ...
233,027
<p>How to set the turbo c path in windows globally so that i can compile and run my C programs (which are in other drives) using command prompt in windows XP? Can any one tell me how to get commands at every drive in the command prompt just by typing in </p> <pre><code>c:\tcc </code></pre> <p>in command prompt i...
[ { "answer_id": 233036, "author": "Zebra North", "author_id": 17440, "author_profile": "https://Stackoverflow.com/users/17440", "pm_score": 4, "selected": true, "text": "<ul>\n<li>Go to the Start Menu, then Control Panel. </li>\n<li>Choose the \"System\" applet.</li>\n<li>Click on the \"...
2008/10/24
[ "https://Stackoverflow.com/questions/233027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31116/" ]
How to set the turbo c path in windows globally so that i can compile and run my C programs (which are in other drives) using command prompt in windows XP? Can any one tell me how to get commands at every drive in the command prompt just by typing in ``` c:\tcc ``` in command prompt in windows and turbo c environ...
* Go to the Start Menu, then Control Panel. * Choose the "System" applet. * Click on the "Advanced" tab. * Click on "Environment Variables" * Find the "Path" variable, and press "Edit" * Append a semicolon, then the path to Turbo C For setting the include and library paths, go to the same place, but instead of editing...
233,072
<p><p>How to include any assembly code lines into my C program ? <p>In turbo c is there a possibility to add an assembly code file (.asm) to a project of few .c files?</p>
[ { "answer_id": 233090, "author": "xsl", "author_id": 11387, "author_profile": "https://Stackoverflow.com/users/11387", "pm_score": 3, "selected": true, "text": "<p>One way to include assembly code is to add a wrapper function and write the assembly code in the asm block, as shown in the ...
2008/10/24
[ "https://Stackoverflow.com/questions/233072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31116/" ]
How to include any assembly code lines into my C program ? In turbo c is there a possibility to add an assembly code file (.asm) to a project of few .c files?
One way to include assembly code is to add a wrapper function and write the assembly code in the asm block, as shown in the example below: ``` void wrapper_function() { asm { /* your assembly code */ } } ```
233,073
<p>How can I group by two different fields in a Crystal Report?</p> <p>Foe example :</p> <pre><code>val1|val2|val3|val6 val1|val12|val3|val7 val11|val2|val3|val8 val11|val12|val3|val9 </code></pre> <p>I want the report to look like </p> <pre><code>val1 : ======= val2 ---- val3|val6 val12 ------- val3|val7 val11 ...
[ { "answer_id": 233463, "author": "thismat", "author_id": 14045, "author_profile": "https://Stackoverflow.com/users/14045", "pm_score": 0, "selected": false, "text": "<p>Not sure on best practices, but what I've used to do similar in the past was a sub report with it's own grouping, withi...
2008/10/24
[ "https://Stackoverflow.com/questions/233073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How can I group by two different fields in a Crystal Report? Foe example : ``` val1|val2|val3|val6 val1|val12|val3|val7 val11|val2|val3|val8 val11|val12|val3|val9 ``` I want the report to look like ``` val1 : ======= val2 ---- val3|val6 val12 ------- val3|val7 val11 : ========= val2 ----- val3|val8 val12 : -...
The generic data provided is rather vague, so I will provide my own to demonstrate (with field names on the first line) ``` "EmployeeName","WeekNumber","DayOfWeek","HoursWorked" "John Doe",20,"Monday",8 "John Doe",20,"Tuesday",8 "John Doe",20,"Wednesday",8 "John Doe",21,"Thursday",8 "John Doe",21,"Friday",8 "Jane Doe"...
233,074
<p>Please could someone help me with writing a regex expression to replace 0044 token which will be at the start of the string with a 0. Please note that I do not want to replace all 0044 tokens with 0, only those that appear at the start of the string.</p> <p>Thanks a lot</p>
[ { "answer_id": 233076, "author": "Graeme Perrow", "author_id": 1821, "author_profile": "https://Stackoverflow.com/users/1821", "pm_score": 1, "selected": false, "text": "<p>In perl: </p>\n\n<pre><code>s/^0044/0/;\n</code></pre>\n\n<p>The <code>^</code> means that the match will only happ...
2008/10/24
[ "https://Stackoverflow.com/questions/233074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Please could someone help me with writing a regex expression to replace 0044 token which will be at the start of the string with a 0. Please note that I do not want to replace all 0044 tokens with 0, only those that appear at the start of the string. Thanks a lot
In perl: ``` s/^0044/0/; ``` The `^` means that the match will only happen at the beginning of the string.
233,088
<p>The fundamental equation of weight loss/gain is:</p> <pre><code>weight_change = convert_to_weight_diff(calories_consumed - calories_burnt); </code></pre> <p>I'm going on a health kick, and like a good nerd I thought I'd start keeping track of these things and write some software to process my data. I'm not attenti...
[ { "answer_id": 233096, "author": "Ken", "author_id": 20074, "author_profile": "https://Stackoverflow.com/users/20074", "pm_score": 4, "selected": true, "text": "<p>Look at <a href=\"http://www.fourmilab.ch/hackdiet/www/hackdiet.html\" rel=\"nofollow noreferrer\">The Hacker's Diet</a> and...
2008/10/24
[ "https://Stackoverflow.com/questions/233088", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6408/" ]
The fundamental equation of weight loss/gain is: ``` weight_change = convert_to_weight_diff(calories_consumed - calories_burnt); ``` I'm going on a health kick, and like a good nerd I thought I'd start keeping track of these things and write some software to process my data. I'm not attentive and disciplined enough ...
Look at [The Hacker's Diet](http://www.fourmilab.ch/hackdiet/www/hackdiet.html) and [physicsdiet.com](http://www.physicsdiet.com/) - this wheel has already been invented.
233,113
<p>How do I get the type of a generic typed class within the class?</p> <p>An example:</p> <p>I build a generic typed collection implementing <em>ICollection&lt; T></em>. Within I have methods like </p> <pre><code> public void Add(T item){ ... } public void Add(IEnumerable&lt;T&gt; enumItems){ ...
[ { "answer_id": 233120, "author": "Keith", "author_id": 905, "author_profile": "https://Stackoverflow.com/users/905", "pm_score": 5, "selected": false, "text": "<p>You can use: <code>typeof(T)</code></p>\n\n<pre><code>if (typeof(T) == typeof(object) ) {\n // Check for IEnumerable\n}\n<...
2008/10/24
[ "https://Stackoverflow.com/questions/233113", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9470/" ]
How do I get the type of a generic typed class within the class? An example: I build a generic typed collection implementing *ICollection< T>*. Within I have methods like ``` public void Add(T item){ ... } public void Add(IEnumerable<T> enumItems){ ... } ``` How can I ask within t...
Personally, I would side step the issue by renaming the `IEnumerable<T>` method to `AddRange`. This avoids such issues, and is consistent with existing APIs such as [`List<T>.AddRange`](http://msdn.microsoft.com/en-us/library/z883w3dc.aspx). It also keeps things clean when the `T` you want to add implements `IEnumerab...
233,127
<p>We have a function which a single thread calls into (we name this the main thread). Within the body of the function we spawn multiple worker threads to do CPU intensive work, wait for all threads to finish, then return the result on the main thread.</p> <p>The result is that the caller can use the function naively,...
[ { "answer_id": 233180, "author": "PierreBdR", "author_id": 7136, "author_profile": "https://Stackoverflow.com/users/7136", "pm_score": 2, "selected": false, "text": "<p>There is, indeed, no good and generic way to transmit exceptions from one thread to the next.</p>\n\n<p>If, as it shoul...
2008/10/24
[ "https://Stackoverflow.com/questions/233127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/755/" ]
We have a function which a single thread calls into (we name this the main thread). Within the body of the function we spawn multiple worker threads to do CPU intensive work, wait for all threads to finish, then return the result on the main thread. The result is that the caller can use the function naively, and inter...
C++11 introduced the `exception_ptr` type that allows to transport exceptions between threads: ``` #include<iostream> #include<thread> #include<exception> #include<stdexcept> static std::exception_ptr teptr = nullptr; void f() { try { std::this_thread::sleep_for(std::chrono::seconds(1)); thro...
233,141
<p>I have a comma separated list of strings like the one below.</p> <pre><code>a,b ,c ,d, , , , ,e, f,g,h . </code></pre> <p>I want to write a regular expression that will replace the empty values i.e., strings that contain only white spaces to 'NA'. So the result should be</p> <pre><code>a,b ,c ,d,NA,NA,N...
[ { "answer_id": 233160, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 4, "selected": true, "text": "<p><code>(?&lt;=,)\\s+(?=,)</code></p>\n\n<p>This is a lookbehind for a comma, then whitespace, then a lookahead for a comma</...
2008/10/24
[ "https://Stackoverflow.com/questions/233141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24424/" ]
I have a comma separated list of strings like the one below. ``` a,b ,c ,d, , , , ,e, f,g,h . ``` I want to write a regular expression that will replace the empty values i.e., strings that contain only white spaces to 'NA'. So the result should be ``` a,b ,c ,d,NA,NA,NA,NA,e, f,g,h . ``` I tried using ...
`(?<=,)\s+(?=,)` This is a lookbehind for a comma, then whitespace, then a lookahead for a comma
233,148
<p>I keep reading that, in C, using pointer arithmetic is generally faster than subscripting for array access. Is this true even with modern (supposedly-optimizing) compilers?</p> <p>If so, is this still the case as I begin to move away from learning C into Objective-C and <a href="http://en.wikipedia.org/wiki/Cocoa_%...
[ { "answer_id": 233166, "author": "Mecki", "author_id": 15809, "author_profile": "https://Stackoverflow.com/users/15809", "pm_score": 7, "selected": true, "text": "<p>You need to understand the reason behind this claim. Have you ever questioned yourself why it is faster? Let's compare som...
2008/10/24
[ "https://Stackoverflow.com/questions/233148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14048/" ]
I keep reading that, in C, using pointer arithmetic is generally faster than subscripting for array access. Is this true even with modern (supposedly-optimizing) compilers? If so, is this still the case as I begin to move away from learning C into Objective-C and [Cocoa](http://en.wikipedia.org/wiki/Cocoa_%28API%29) o...
You need to understand the reason behind this claim. Have you ever questioned yourself why it is faster? Let's compare some code: ``` int i; int a[20]; // Init all values to zero memset(a, 0, sizeof(a)); for (i = 0; i < 20; i++) { printf("Value of %d is %d\n", i, a[i]); } ``` They are all zero, what a surprise ...
233,171
<p>What is the best way to do GUIs in <a href="http://en.wikipedia.org/wiki/Clojure" rel="noreferrer">Clojure</a>?</p> <p>Is there an example of some functional <a href="http://en.wikipedia.org/wiki/Swing_%28Java%29" rel="noreferrer">Swing</a> or <a href="http://en.wikipedia.org/wiki/Standard_Widget_Toolkit" rel="nore...
[ { "answer_id": 233271, "author": "dsm", "author_id": 7780, "author_profile": "https://Stackoverflow.com/users/7780", "pm_score": 4, "selected": false, "text": "<p>From this <a href=\"http://blog.thinkrelevance.com/2008/8/12/java-next-2-java-interop\" rel=\"noreferrer\">page</a>:</p>\n\n<...
2008/10/24
[ "https://Stackoverflow.com/questions/233171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31141/" ]
What is the best way to do GUIs in [Clojure](http://en.wikipedia.org/wiki/Clojure)? Is there an example of some functional [Swing](http://en.wikipedia.org/wiki/Swing_%28Java%29) or [SWT](http://en.wikipedia.org/wiki/Standard_Widget_Toolkit) wrapper? Or some integration with [JavaFX](http://en.wikipedia.org/wiki/JavaFX...
I will humbly suggest [Seesaw](https://github.com/daveray/seesaw). [Here's a REPL-based tutorial](https://gist.github.com/1441520) that assumes no Java or Swing knowledge. --- Seesaw's a lot like what @tomjen suggests. Here's "Hello, World": ```clj (use 'seesaw.core) (-> (frame :title "Hello" :content "Hel...
233,188
<p>I have a web page that uses a scrolling div to display table information. When the window is resized (and also on page load), the display is centered and the div's scrollbar positioned to the right of the page by setting its width. For some reason, the behaviour is different under firefox than IE. IE positions/sizes...
[ { "answer_id": 233195, "author": "Michael Madsen", "author_id": 27528, "author_profile": "https://Stackoverflow.com/users/27528", "pm_score": 0, "selected": false, "text": "<p>As long as you don't include a valid doctype, you can't expect consistent results, due to Quirks Mode. Go add on...
2008/10/24
[ "https://Stackoverflow.com/questions/233188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11820/" ]
I have a web page that uses a scrolling div to display table information. When the window is resized (and also on page load), the display is centered and the div's scrollbar positioned to the right of the page by setting its width. For some reason, the behaviour is different under firefox than IE. IE positions/sizes th...
You are dealing with "[one of the best-known software bugs in a popular implementation of Cascading Style Sheets (CSS)](http://en.wikipedia.org/wiki/Internet_Explorer_box_model_bug)" according to Wikipedia. I recommend the [Element dimensions](http://www.quirksmode.org/viewport/elementdimensions.html) and [CSS Object M...
233,192
<p><em>What options are there to detect web-crawlers that do not want to be detected?</em></p> <p>(I know that listing detection techniques will allow the smart stealth-crawler programmer to make a better spider, but I do not think that we will ever be able to block smart stealth-crawlers anyway, only the ones that mak...
[ { "answer_id": 233465, "author": "Chris", "author_id": 15578, "author_profile": "https://Stackoverflow.com/users/15578", "pm_score": 3, "selected": false, "text": "<p>One thing you didn't list, that are used commonly to detect bad crawlers.</p>\n\n<p>Hit speed, good web crawlers will bre...
2008/10/24
[ "https://Stackoverflow.com/questions/233192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22674/" ]
*What options are there to detect web-crawlers that do not want to be detected?* (I know that listing detection techniques will allow the smart stealth-crawler programmer to make a better spider, but I do not think that we will ever be able to block smart stealth-crawlers anyway, only the ones that make mistakes.) I'...
See [Project Honeypot](http://www.projecthoneypot.org/) - they're setting up bot traps on large scale (and have DNSRBL with their IPs). Use tricky URLs and HTML: ``` <a href="//example.com/"> = http://example.com/ on http pages. <a href="page&amp;&#x23;hash"> = page& + #hash ``` In HTML you can use plenty of tricks...
233,199
<p>I am trying to get data from my server, used RemoteObject to accomplish it. When I run the application on my localhost it works great but when iam using it on my server i get a Channel.Security.Error(Security Error accessing URL).</p> <p>On the server side logs there is a mention about cross domain . 77.127.194.4 -...
[ { "answer_id": 233465, "author": "Chris", "author_id": 15578, "author_profile": "https://Stackoverflow.com/users/15578", "pm_score": 3, "selected": false, "text": "<p>One thing you didn't list, that are used commonly to detect bad crawlers.</p>\n\n<p>Hit speed, good web crawlers will bre...
2008/10/24
[ "https://Stackoverflow.com/questions/233199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20955/" ]
I am trying to get data from my server, used RemoteObject to accomplish it. When I run the application on my localhost it works great but when iam using it on my server i get a Channel.Security.Error(Security Error accessing URL). On the server side logs there is a mention about cross domain . 77.127.194.4 - - [23/Oct...
See [Project Honeypot](http://www.projecthoneypot.org/) - they're setting up bot traps on large scale (and have DNSRBL with their IPs). Use tricky URLs and HTML: ``` <a href="//example.com/"> = http://example.com/ on http pages. <a href="page&amp;&#x23;hash"> = page& + #hash ``` In HTML you can use plenty of tricks...
233,216
<p>I have an abstract generic class <code>BLL&lt;T&gt; where T : BusinessObject</code>. I need to open an assembly that contains a set of concrete BLL classes, and return the tuples (businessObjectType, concreteBLLType) inside a Dictionary. There is the part of the method I could do until now, but I'm having problems t...
[ { "answer_id": 233236, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "<p>So the concrete classes will be closed rather than generic? Here's a short program which demonstrates what I <em>think...
2008/10/24
[ "https://Stackoverflow.com/questions/233216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21668/" ]
I have an abstract generic class `BLL<T> where T : BusinessObject`. I need to open an assembly that contains a set of concrete BLL classes, and return the tuples (businessObjectType, concreteBLLType) inside a Dictionary. There is the part of the method I could do until now, but I'm having problems to discover T. ``` p...
So the concrete classes will be closed rather than generic? Here's a short program which demonstrates what I *think* you're after... ``` using System; using System.Reflection; public abstract class Base<T> { } public class Concrete : Base<string> { } class Test { static void Main() { Type type = typ...
233,217
<p>I'm writing a C Shell program that will be doing <code>su</code> or <code>sudo</code> or <code>ssh</code>. They all want their passwords in console input (the TTY) rather than stdin or the command line.</p> <p>Does anybody know a solution?</p> <p>Setting up password-less <code>sudo</code> is not an option.</p> <p...
[ { "answer_id": 233224, "author": "Marko", "author_id": 31141, "author_profile": "https://Stackoverflow.com/users/31141", "pm_score": 3, "selected": false, "text": "<p>Take a look at <code>expect</code> linux utility.</p>\n\n<p>It allows you to send output to stdio based on simple pattern...
2008/10/24
[ "https://Stackoverflow.com/questions/233217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23420/" ]
I'm writing a C Shell program that will be doing `su` or `sudo` or `ssh`. They all want their passwords in console input (the TTY) rather than stdin or the command line. Does anybody know a solution? Setting up password-less `sudo` is not an option. [expect](/questions/tagged/expect "show questions tagged 'expect'")...
For sudo there is a -S option for accepting the password from standard input. Here is the man entry: ``` -S The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device. ``` This will allow you to run a command like: ``` echo myPassword |...
233,222
<p>I have 3 divs where only one is visible by default, they each contain information about a product. Below this divs is a list of 3 images which are images of the products. By default of course the 1st list item is selected and has <code>class="selected"</code>. When a different product image is clicks then <code>clas...
[ { "answer_id": 233252, "author": "Jeff Fritz", "author_id": 29156, "author_profile": "https://Stackoverflow.com/users/29156", "pm_score": 2, "selected": false, "text": "<p>Consider the following code:</p>\n\n<pre><code>&lt;img id=\"img1\" src=\"1.jpg\" desc=\"d1\" class=\"selected prodIm...
2008/10/24
[ "https://Stackoverflow.com/questions/233222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26823/" ]
I have 3 divs where only one is visible by default, they each contain information about a product. Below this divs is a list of 3 images which are images of the products. By default of course the 1st list item is selected and has `class="selected"`. When a different product image is clicks then `class="selected"` moves...
Consider the following code: ``` <img id="img1" src="1.jpg" desc="d1" class="selected prodImg" /> <img id="img2" src="2.jpg" desc="d2" class="prodImg" /> <img id="img3" src="3.jpg" desc="d3" class="prodImg"/> <div id="d1">description 1</div> <div id="d2" class="hidden">description 2</div> <div id="d3" class="hidden">...
233,251
<p>Since many years a GUI-standard are the menu-bars of applications with menus popping up, if you click or hover an entry in the menu-bar. Some websites implement this feature too, but they are using Javascript, as far as I can see. For different reasons Javascript can be a problem, so the question: Is this possible ...
[ { "answer_id": 233266, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 1, "selected": false, "text": "<p>You can use the pseudoclass :hover to get an hover effect.</p>\n\n<pre><code>a:link {\n color: blue;\n}\n\na:hover...
2008/10/24
[ "https://Stackoverflow.com/questions/233251", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21005/" ]
Since many years a GUI-standard are the menu-bars of applications with menus popping up, if you click or hover an entry in the menu-bar. Some websites implement this feature too, but they are using Javascript, as far as I can see. For different reasons Javascript can be a problem, so the question: Is this possible to i...
I've done something like this before, and it's a trick pulled off by placing the menu items in anchor tags, with submenus in hidden divs INSIDE those anchor tags. The CSS trick is to make the inner div appear during the a:hover event. It looks something like: ``` <style> A DIV { display: none; } A:hover DIV {...
233,255
<p>I am working on a project to enhance our production debugging capabilities. Our goal is to reliably produce a minidump on any unhandled exception, whether the exception is managed or unmanaged, and whether it occurs on a managed or unmanaged thread.</p> <p>We use the excellent <a href="http://www.debuginfo.com/too...
[ { "answer_id": 233742, "author": "Chris Becke", "author_id": 27491, "author_profile": "https://Stackoverflow.com/users/27491", "pm_score": 2, "selected": false, "text": "<p>SetUnhandledExceptionFilter installs a handler that is invoked when a Win32-excpetion reaches the top of a threads ...
2008/10/24
[ "https://Stackoverflow.com/questions/233255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6996/" ]
I am working on a project to enhance our production debugging capabilities. Our goal is to reliably produce a minidump on any unhandled exception, whether the exception is managed or unmanaged, and whether it occurs on a managed or unmanaged thread. We use the excellent [ClrDump](http://www.debuginfo.com/tools/clrdump...
Windows Forms has a built-in exception handler that does the following by default: * Catches an unhandled managed exception when: + no debugger attached, and + exception occurs during window message processing, and + jitDebugging = false in App.Config. * Shows dialog to user and prevents app termination. You can d...
233,261
<p>The strongly typed <code>SearchViewData</code> has a field called Colors that in it's turn is a <code>ColorViewData</code>. In my <code>/Colors.mvc/search</code> I populate this <code>viewData.Model.Colors</code> based on the given search criteria. Then, based on several factors, I render one of a set of user contro...
[ { "answer_id": 233335, "author": "Karl Seguin", "author_id": 34, "author_profile": "https://Stackoverflow.com/users/34", "pm_score": 0, "selected": false, "text": "<p>Noticed the same thing, I fixed it with the following, though I'm not sure if it's the \"right\" solution:</p>\n\n<pre><c...
2008/10/24
[ "https://Stackoverflow.com/questions/233261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
The strongly typed `SearchViewData` has a field called Colors that in it's turn is a `ColorViewData`. In my `/Colors.mvc/search` I populate this `viewData.Model.Colors` based on the given search criteria. Then, based on several factors, I render one of a set of user controls that are able to render itself with a `Color...
Probably an overload issues. You could call the RenderPartial(string, object, ViewDataDictionary) which makes all three parameters explicit. One thing we're planning to change is if you call the overload RenderPartial(string, object), we'll pass the current ViewDataDictionary to the partial. We don't do that in the Be...
233,264
<p>I have an ASP.NET application. Basically the delivery process is this one :</p> <ul> <li>Nant builds the application and creates a zip file on the developer's computer with the application files without SVN folders and useless files. This file is delivered with a Nant script.</li> <li>The zip and nant files are cop...
[ { "answer_id": 233299, "author": "Jeff Fritz", "author_id": 29156, "author_profile": "https://Stackoverflow.com/users/29156", "pm_score": 3, "selected": true, "text": "<p>You need to run the CACLS program in windows to grant permissions to files and folders. From Nant, you can do this w...
2008/10/24
[ "https://Stackoverflow.com/questions/233264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28544/" ]
I have an ASP.NET application. Basically the delivery process is this one : * Nant builds the application and creates a zip file on the developer's computer with the application files without SVN folders and useless files. This file is delivered with a Nant script. * The zip and nant files are copied to the client's c...
You need to run the CACLS program in windows to grant permissions to files and folders. From Nant, you can do this with the EXEC task. Try a tag block like: ``` <exec program="cacls"> <arg value="*" /> <arg value="/G IIS_WPG:F" /> </exec> ```
233,284
<p>I have created a .NET DLL which makes some methods COM visible.</p> <p>One method is problematic. It looks like this:</p> <pre><code>bool Foo(byte[] a, ref byte[] b, string c, ref string d) </code></pre> <p>VB6 gives a compile error when I attempt to call the method:</p> <blockquote> <p>Function or interface m...
[ { "answer_id": 233451, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 1, "selected": false, "text": "<p>Try</p>\n\n<pre><code>[ComVisible(true)]\nbool Foo([In] ref byte[] a, [In] ref byte[] b, string c, ref string d)\n</cod...
2008/10/24
[ "https://Stackoverflow.com/questions/233284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/329888/" ]
I have created a .NET DLL which makes some methods COM visible. One method is problematic. It looks like this: ``` bool Foo(byte[] a, ref byte[] b, string c, ref string d) ``` VB6 gives a compile error when I attempt to call the method: > > Function or interface marked as > restricted, or the function uses an > ...
Declaring the array argument with "ref" is required. Your 2nd attempt should have worked just fine, perhaps you forgot to regenerate the .tlb? Tested code: ``` [ComVisible(true)] public interface IMyInterface { bool Foo(ref byte[] a, ref byte[] b,string c, ref string d); } [ComVisible(true)] public class MyClass : ...
233,288
<p><strong>I have class A:</strong></p> <pre><code>public class ClassA&lt;T&gt; </code></pre> <p><strong>Class B derives from A:</strong></p> <pre><code>public class ClassB : ClassA&lt;ClassB&gt; </code></pre> <p><strong>Class C derives from class B:</strong></p> <pre><code>public class ClassC : ClassB </code></pr...
[ { "answer_id": 233303, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "<p>Well, you could change Method to:</p>\n\n<pre><code>public static T Method&lt;T,U&gt;() where T : ClassA&lt;U&gt; wher...
2008/10/24
[ "https://Stackoverflow.com/questions/233288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24681/" ]
**I have class A:** ``` public class ClassA<T> ``` **Class B derives from A:** ``` public class ClassB : ClassA<ClassB> ``` **Class C derives from class B:** ``` public class ClassC : ClassB ``` **Now I have a generic method with constraints** ``` public static T Method<T>() where T : ClassA<T> ``` OK, now ...
Well, you could change Method to: ``` public static T Method<T,U>() where T : ClassA<U> where U : T ``` Does that help at all? It's not much use if you can't change Method of course...
233,320
<p>I'm running Python 2.6 on Unix and when I run the interactive prompt (<a href="http://en.wikipedia.org/wiki/SQLite" rel="noreferrer">SQLite</a> is supposed to be preinstalled) I get:</p> <pre><code>[root@idev htdocs]# python Python 2.6 (r26:66714, Oct 23 2008, 16:25:34) [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] ...
[ { "answer_id": 233336, "author": "gimel", "author_id": 6491, "author_profile": "https://Stackoverflow.com/users/6491", "pm_score": 3, "selected": false, "text": "<pre><code>import sqlite3\n</code></pre>\n\n<p><a href=\"http://docs.python.org/library/sqlite3.html#module-sqlite3\" rel=\"no...
2008/10/24
[ "https://Stackoverflow.com/questions/233320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3404/" ]
I'm running Python 2.6 on Unix and when I run the interactive prompt ([SQLite](http://en.wikipedia.org/wiki/SQLite) is supposed to be preinstalled) I get: ``` [root@idev htdocs]# python Python 2.6 (r26:66714, Oct 23 2008, 16:25:34) [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2 Type "help", "copyright", "credi...
The error: ``` ImportError: No module named _sqlite3 ``` means that [SQLite](http://en.wikipedia.org/wiki/SQLite) 3 does not find the associated shared library. On Mac OS X it's \_sqlite3.so and it should be the same on other Unix systems. To resolve the error you have to locate the \_sqlite3.so library on your c...
233,328
<p>I want to print the full length of a C-string in GDB. By default it's being abbreviated, how do I force GDB to print the whole string?</p>
[ { "answer_id": 233339, "author": "John Carter", "author_id": 8331, "author_profile": "https://Stackoverflow.com/users/8331", "pm_score": 10, "selected": true, "text": "<pre><code>set print elements 0\n</code></pre>\n\n<p><a href=\"http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_node/gd...
2008/10/24
[ "https://Stackoverflow.com/questions/233328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8331/" ]
I want to print the full length of a C-string in GDB. By default it's being abbreviated, how do I force GDB to print the whole string?
``` set print elements 0 ``` [From the GDB manual](http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_node/gdb_57.html#IDX353): > `set print elements` *`number-of-elements`* > > Set a limit on how many elements of an array GDB will print. If GDB is printing a large array, it stops printing after it has printed the...
233,421
<p>Is there currently a way to host a shared Git repository in Windows? I understand that you can configure the Git service in Linux with:</p> <pre><code>git daemon </code></pre> <p>Is there a native Windows option, short of sharing folders, to host a Git service?</p> <p>EDIT: I am currently using the cygwin instal...
[ { "answer_id": 233444, "author": "Clokey", "author_id": 2438, "author_profile": "https://Stackoverflow.com/users/2438", "pm_score": 2, "selected": false, "text": "<p>Have you considered using the cygwin layer? See <a href=\"http://fab.cba.mit.edu/classes/MIT/863.07/people/steve/git.html\...
2008/10/24
[ "https://Stackoverflow.com/questions/233421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29156/" ]
Is there currently a way to host a shared Git repository in Windows? I understand that you can configure the Git service in Linux with: ``` git daemon ``` Is there a native Windows option, short of sharing folders, to host a Git service? EDIT: I am currently using the cygwin install of git to store and work with gi...
Here are some steps you can follow to get the git daemon running under Windows: *(Prerequisites: A default Cygwin installation and a git client that supports git daemon)* **Step 1**: Open a bash shell **Step 2**: In the directory /cygdrive/c/cygwin64/usr/local/bin/, create a file named "gitd" with the following cont...
233,434
<p>I am trying to make our SQL Server Integration Services packages as portable as possible and the one thing that is preventing that is that the path to the config is always an absolute path, which makes testing and deployment a headache. Are there any suggestions for making this more manageble?</p> <p>Another issue ...
[ { "answer_id": 233528, "author": "Malik Daud Ahmad Khokhar", "author_id": 1688440, "author_profile": "https://Stackoverflow.com/users/1688440", "pm_score": 5, "selected": true, "text": "<p>If you are trying to execute your packages using Visual Studio then the configuration file path wil...
2008/10/24
[ "https://Stackoverflow.com/questions/233434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12915/" ]
I am trying to make our SQL Server Integration Services packages as portable as possible and the one thing that is preventing that is that the path to the config is always an absolute path, which makes testing and deployment a headache. Are there any suggestions for making this more manageble? Another issue is when an...
If you are trying to execute your packages using Visual Studio then the configuration file path will be hardcoded in there. So if you move your project around you'll need to change the path in the package settings. To avoid this you could use the Environment variable option to store the configuration file path. Then yo...
233,455
<p>I am making a program in C# to connect to a webcam and do some image manipulation with it.</p> <p>I have a working application that uses win32 api (avicap32.dll) to connect to the webcam and send messages to it that sends it to the clipboard. The problem is that, while accessible from paint, reading it from the prog...
[ { "answer_id": 233854, "author": "Rob Prouse", "author_id": 30827, "author_profile": "https://Stackoverflow.com/users/30827", "pm_score": 0, "selected": false, "text": "<p>Have you tried Clipboard.GetImage()? You could also try the various Clipboard.Contains*() methods to see what format...
2008/10/24
[ "https://Stackoverflow.com/questions/233455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31151/" ]
I am making a program in C# to connect to a webcam and do some image manipulation with it. I have a working application that uses win32 api (avicap32.dll) to connect to the webcam and send messages to it that sends it to the clipboard. The problem is that, while accessible from paint, reading it from the program resul...
I've recently started doing some hobby work in this area. We settled on using the [OpenCV](http://sourceforge.net/projects/opencv/) library with the [opencvdotnet](http://code.google.com/p/opencvdotnet/) wrapper. It supports capturing frames from a webcam: ``` using (var cv = new OpenCVDotNet.CVCapture(0)) { var ...
233,467
<p>I know that most links should be left up to the end-user to decide how to open, but we can't deny that there are times you almost 'have to' force into a new window (for example to maintain data in a form on the current page).</p> <p>What I'd like to know is what the consensus is on the 'best' way to open a link in ...
[ { "answer_id": 233477, "author": "Luk", "author_id": 5789, "author_profile": "https://Stackoverflow.com/users/5789", "pm_score": 4, "selected": false, "text": "<p>Why is <code>target=\"_blank\"</code> a bad idea?</p>\n\n<p>It's supposed to do exactly what you want.</p>\n\n<p>edit: (see c...
2008/10/24
[ "https://Stackoverflow.com/questions/233467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22303/" ]
I know that most links should be left up to the end-user to decide how to open, but we can't deny that there are times you almost 'have to' force into a new window (for example to maintain data in a form on the current page). What I'd like to know is what the consensus is on the 'best' way to open a link in a new brow...
I am using the last method you proposed. I add rel="external" or something similar and then use jQuery to iterate through all links and assign them a click handler: ``` $(document).ready(function() { $('a[rel*=external]').click(function(){ window.open($(this).attr('href')); return false; }); }); ``` I f...
233,468
<p>I have a number of custom controls that I am trying to enable designer support for. The signature looks something like the following:</p> <pre><code>[ToolboxData("&lt;{0}:MyDropDownList runat=\"server\" CustomProp="123"&gt;&lt;/{0}:MyDropDownList&gt;")] public class MyDropDownList: DropDownList { ... code here }...
[ { "answer_id": 233484, "author": "DOK", "author_id": 27637, "author_profile": "https://Stackoverflow.com/users/27637", "pm_score": 4, "selected": true, "text": "<p>It looks something like this:</p>\n\n<pre><code>[assembly:TagPrefix(\"MyControls\",\"RequiredTextBox\")]\n</code></pre>\n\n<...
2008/10/24
[ "https://Stackoverflow.com/questions/233468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29662/" ]
I have a number of custom controls that I am trying to enable designer support for. The signature looks something like the following: ``` [ToolboxData("<{0}:MyDropDownList runat=\"server\" CustomProp="123"></{0}:MyDropDownList>")] public class MyDropDownList: DropDownList { ... code here } ``` This works fine, bu...
It looks something like this: ``` [assembly:TagPrefix("MyControls","RequiredTextBox")] ``` and [here's](http://msdn.microsoft.com/en-us/library/system.web.ui.tagprefixattribute.tagprefixattribute.aspx) some more info about it.
233,491
<p>Specifically, I currently have a JPanel with a TitledBorder. I want to customize the look of the border. In my app's current state, the title is drawn, but not the line border itself.</p> <p>If I bind an imagePainter to the panelBorder method for Panel objects, I can put a custom image around panels -- however it o...
[ { "answer_id": 279305, "author": "SpooneyDinosaur", "author_id": 22386, "author_profile": "https://Stackoverflow.com/users/22386", "pm_score": 1, "selected": false, "text": "<p>Specify the name of the component you want to apply the special style to, not the region:</p>\n\n<pre><code>&lt...
2008/10/24
[ "https://Stackoverflow.com/questions/233491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7161/" ]
Specifically, I currently have a JPanel with a TitledBorder. I want to customize the look of the border. In my app's current state, the title is drawn, but not the line border itself. If I bind an imagePainter to the panelBorder method for Panel objects, I can put a custom image around panels -- however it only shows ...
Specify the name of the component you want to apply the special style to, not the region: ``` <bind style="PanelStyle" type="name" key="mySpecialPanel" /> ``` In your Java code, you'll need to set the component's name to match the name you supplied in the XML: ``` panel.setName("mySpecialPanel"); ``` You might co...
233,504
<p>I am trying to programatically set the dpi metadata of an jpeg image in Java. The source of the image is a scanner, so I get the horizontal/vertical resolution from TWAIN, along with the image raw data. I'd like to save this info for better print results.</p> <p>Here's the code I have so far. It saves the raw image...
[ { "answer_id": 234142, "author": "branchgabriel", "author_id": 30807, "author_profile": "https://Stackoverflow.com/users/30807", "pm_score": 2, "selected": false, "text": "<p>I would seem this could be a bug. </p>\n\n<p>I found this post <a href=\"http://www.velocityreviews.com/forums/t3...
2008/10/24
[ "https://Stackoverflow.com/questions/233504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31155/" ]
I am trying to programatically set the dpi metadata of an jpeg image in Java. The source of the image is a scanner, so I get the horizontal/vertical resolution from TWAIN, along with the image raw data. I'd like to save this info for better print results. Here's the code I have so far. It saves the raw image (byteArra...
Some issues that were not considered here: 1. The tree is not directly mapped to the IOMetaData. To apply data from tree, add following call after setting the densities and raster parameters: ``` data.setFromTree("javax_imageio_jpeg_image_1.0", tree); ``` 2. don't use the meta data as first parameter in the write ca...
233,553
<p>I have a very simple jQuery Datepicker calendar:</p> <pre><code>$(document).ready(function(){ $("#date_pretty").datepicker({ }); }); </code></pre> <p>and of course in the HTML...</p> <pre><code>&lt;input type="text" size="10" value="" id="date_pretty"/&gt; </code></pre> <p>Today's date is nicely highlig...
[ { "answer_id": 233654, "author": "lucas", "author_id": 31172, "author_profile": "https://Stackoverflow.com/users/31172", "pm_score": 6, "selected": false, "text": "<pre><code>var myDate = new Date();\nvar prettyDate =(myDate.getMonth()+1) + '/' + myDate.getDate() + '/' +\n myDate....
2008/10/24
[ "https://Stackoverflow.com/questions/233553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26848/" ]
I have a very simple jQuery Datepicker calendar: ``` $(document).ready(function(){ $("#date_pretty").datepicker({ }); }); ``` and of course in the HTML... ``` <input type="text" size="10" value="" id="date_pretty"/> ``` Today's date is nicely highlighted for the user when they bring up the calendar, but ...
**Update: There are reports this no longer works in Chrome.** This is concise and does the job (obsolete): ``` $(".date-pick").datepicker('setDate', new Date()); ``` This is less concise, utilizing [chaining](https://www.w3schools.com/jquery/jquery_chaining.asp) allows it to work in chrome (2019-06-04): ``` $(".da...
233,560
<p>I have developed about 300 Applications which I would like to provide with multi-language capabilities independent from the Operating System. I have written a just-in-time translator, but that is too slow in applications with many components. What would you suggest I do?</p>
[ { "answer_id": 233592, "author": "gabr", "author_id": 4997, "author_profile": "https://Stackoverflow.com/users/4997", "pm_score": 3, "selected": false, "text": "<p>We are using <a href=\"http://www.sicomponents.com/tsilang1.html\" rel=\"nofollow noreferrer\">TsiLang</a> and are very happ...
2008/10/24
[ "https://Stackoverflow.com/questions/233560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3535708/" ]
I have developed about 300 Applications which I would like to provide with multi-language capabilities independent from the Operating System. I have written a just-in-time translator, but that is too slow in applications with many components. What would you suggest I do?
I've heard that the [TsiLang components](http://www.tsilang.com/?siteid2=1) are nice, but your looking at an inplace solution... I've used [GNU gettext for Delphi](http://dxgettext.po.dk/) which does exactly the thing you want, it loads the translations from a text file and replaces the text in your components. It eve...
233,564
<p>I have created a multi column datastore on a table that allows me to do full text indexing on the table. What I need to be able to do is weight each column different and add the scores together.</p> <p>The following query works, but is slow:</p> <pre><code>SELECT document.*, Score(1) + 2*Score(2) as Score FROM doc...
[ { "answer_id": 233694, "author": "user31183", "author_id": 31183, "author_profile": "https://Stackoverflow.com/users/31183", "pm_score": 3, "selected": true, "text": "<p>Instead of the OR operator, use ACCUM:</p>\n\n<p>SELECT document.*, Score(1) as Score\nFROM document\nWHERE CONTAINS(d...
2008/10/24
[ "https://Stackoverflow.com/questions/233564", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31169/" ]
I have created a multi column datastore on a table that allows me to do full text indexing on the table. What I need to be able to do is weight each column different and add the scores together. The following query works, but is slow: ``` SELECT document.*, Score(1) + 2*Score(2) as Score FROM document WHERE (CONTAINS...
Instead of the OR operator, use ACCUM: SELECT document.\*, Score(1) as Score FROM document WHERE CONTAINS(dummy, '(((the\_keyword) within documentTitle))\*2 **ACCUM** ((the\_keyword) within documentText)',1) > 0) ORDER BY Score Desc
233,579
<p>I have heard that closures could be introduced in the next Java standard that is scheduled to be released somewhere around next summer. </p> <p>What would this syntax look like?</p> <p>I read somewhere that introducing closures in java is a bigger change than generic was in java 5. Is this true? pros and cons?</p>...
[ { "answer_id": 233595, "author": "Steven Huwig", "author_id": 28604, "author_profile": "https://Stackoverflow.com/users/28604", "pm_score": 5, "selected": true, "text": "<p>Have a look at <a href=\"http://www.javac.info/\" rel=\"noreferrer\">http://www.javac.info/</a> .</p>\n\n<p>It seem...
2008/10/24
[ "https://Stackoverflow.com/questions/233579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/148909/" ]
I have heard that closures could be introduced in the next Java standard that is scheduled to be released somewhere around next summer. What would this syntax look like? I read somewhere that introducing closures in java is a bigger change than generic was in java 5. Is this true? pros and cons? (By now we definite...
Have a look at <http://www.javac.info/> . It seems like this is how it would look: ``` boolean even = { int x => x % 2 == 0 }.invoke(15); ``` where the `{ int x => x % 2 == 0 }` bit is the closure.
233,622
<p>It sounds a lot more complicated than it really is.</p> <p>So in Perl, you can do something like this:</p> <pre><code>foreach my $var (@vars) { $hash_table{$var-&gt;{'id'}} = $var-&gt;{'data'}; } </code></pre> <p>I have a JSON object and I want to do the same thing, but with a javascript associative array in j...
[ { "answer_id": 233685, "author": "roenving", "author_id": 23142, "author_profile": "https://Stackoverflow.com/users/23142", "pm_score": 0, "selected": false, "text": "<p>Why would you want to change an array into another array ?-)</p>\n\n<p>-- why not simply access the data, if you want ...
2008/10/24
[ "https://Stackoverflow.com/questions/233622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22390/" ]
It sounds a lot more complicated than it really is. So in Perl, you can do something like this: ``` foreach my $var (@vars) { $hash_table{$var->{'id'}} = $var->{'data'}; } ``` I have a JSON object and I want to do the same thing, but with a javascript associative array in jQuery. I've tried the following: ``` ...
I think you can use the JSON response as an associative array. So you should be able to go directly in and use the JSON. Assuming you received the above example: ``` $('result').innerHTML = data['results']['dataset_a']['dataset_two']['data']; // Or the shorter form: $('result').innerHTML = data.results.dataset_a.data...
233,643
<p>I'd like to link to some PDFs in one of my controller views. What's the best practice for accomplishing this? The CakePHP webroot folder contains a ./files/ subfolder, I am confounded by trying to link to it without using "magic" pathnames in my href (e.g. "/path/to/my/webroot/files/myfile.pdf").</p> <p>What are my...
[ { "answer_id": 238045, "author": "Jonas Due Vesterheden", "author_id": 7445, "author_profile": "https://Stackoverflow.com/users/7445", "pm_score": 1, "selected": false, "text": "<p>I'm not sure I understand the question correctly, but here goes. Basically any file you put in the webroot ...
2008/10/24
[ "https://Stackoverflow.com/questions/233643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5030/" ]
I'd like to link to some PDFs in one of my controller views. What's the best practice for accomplishing this? The CakePHP webroot folder contains a ./files/ subfolder, I am confounded by trying to link to it without using "magic" pathnames in my href (e.g. "/path/to/my/webroot/files/myfile.pdf"). What are my options? ...
``` $html->link('Pdf', '/files/myfile.pdf'); ```
233,673
<p>While I was investigating a problem I had with lexical closures in Javascript code, I came along this problem in Python:</p> <pre><code>flist = [] for i in xrange(3): def func(x): return x * i flist.append(func) for f in flist: print f(2) </code></pre> <p>Note that this example mindfully avoids <code...
[ { "answer_id": 233713, "author": "Alex Coventry", "author_id": 1941213, "author_profile": "https://Stackoverflow.com/users/1941213", "pm_score": 2, "selected": false, "text": "<p>The variable <code>i</code> is a global, whose value is 2 at each time the function <code>f</code> is called....
2008/10/24
[ "https://Stackoverflow.com/questions/233673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
While I was investigating a problem I had with lexical closures in Javascript code, I came along this problem in Python: ``` flist = [] for i in xrange(3): def func(x): return x * i flist.append(func) for f in flist: print f(2) ``` Note that this example mindfully avoids `lambda`. It prints "4 4 4", wh...
Python is actually behaving as defined. **Three separate functions** are created, but they each have the **closure of the environment they're defined in** - in this case, the global environment (or the outer function's environment if the loop is placed inside another function). This is exactly the problem, though - in ...
233,691
<p><strong>Scenario:</strong></p> <p>The task I have at hand is to enable a single-signon solution between different organizations/websites. I start as an authenticated user on one organization's website, convert specific information into an Xml document, encrypt the document with triple des, and send that over as a p...
[ { "answer_id": 233817, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 0, "selected": false, "text": "<p>You are thinking about this too process oriented, it would take you a month of sundays to try and work out all the bugs ...
2008/10/24
[ "https://Stackoverflow.com/questions/233691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5289/" ]
**Scenario:** The task I have at hand is to enable a single-signon solution between different organizations/websites. I start as an authenticated user on one organization's website, convert specific information into an Xml document, encrypt the document with triple des, and send that over as a post variable to the sec...
Send back a document that contains the from with hidden input and include an onload handler that posts the form immediately to the other site. Using jquery's document.ready() solves the issue of whether the DOM is loaded before the post occurs, though there are other ways to do this without jquery. You might want to in...
233,711
<p>I use an anonymous object to pass my Html Attributes to some helper methods. If the consumer didn't add an ID attribute, I want to add it in my helper method.</p> <p>How can I add an attribute to this anonymous object?</p>
[ { "answer_id": 233730, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 6, "selected": false, "text": "<p>I assume you mean anonymous types here, e.g. <code>new { Name1=value1, Name2=value2}</code> etc. If so, you're out of...
2008/10/24
[ "https://Stackoverflow.com/questions/233711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
I use an anonymous object to pass my Html Attributes to some helper methods. If the consumer didn't add an ID attribute, I want to add it in my helper method. How can I add an attribute to this anonymous object?
If you're trying to extend this method: ``` public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, object routeValues); ``` Although I'm sure Khaja's Object extensions would work, you might get better performance by creating a RouteValueDictionary and passing in the ro...
233,718
<p>This question is about App domains and Sessions. Is it possible to have IIS run each User Session in a seperate App Domain. If Yes, Could you please let me settings in the config file that affect this.</p> <p>Regards, Anil.</p>
[ { "answer_id": 233730, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 6, "selected": false, "text": "<p>I assume you mean anonymous types here, e.g. <code>new { Name1=value1, Name2=value2}</code> etc. If so, you're out of...
2008/10/24
[ "https://Stackoverflow.com/questions/233718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
This question is about App domains and Sessions. Is it possible to have IIS run each User Session in a seperate App Domain. If Yes, Could you please let me settings in the config file that affect this. Regards, Anil.
If you're trying to extend this method: ``` public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, object routeValues); ``` Although I'm sure Khaja's Object extensions would work, you might get better performance by creating a RouteValueDictionary and passing in the ro...
233,719
<p>I'm trying to read the contents of the clipboard using JavaScript. With Internet Explorer it's possible using the function</p> <pre><code>window.clipboardData.getData(&quot;Text&quot;) </code></pre> <p>Is there a similar way of reading the clipboard in Firefox, Safari and Chrome?</p>
[ { "answer_id": 233781, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 1, "selected": false, "text": "<p>I believe people use a hidden Flash element to read the clipboard data from the browsers you mentioned.</p>\n" }, { ...
2008/10/24
[ "https://Stackoverflow.com/questions/233719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25960/" ]
I'm trying to read the contents of the clipboard using JavaScript. With Internet Explorer it's possible using the function ``` window.clipboardData.getData("Text") ``` Is there a similar way of reading the clipboard in Firefox, Safari and Chrome?
Safari supports reading the clipboard during `onpaste` events: [Information](http://developer.apple.com/documentation/AppleApplications/Conceptual/SafariJSProgTopics/Tasks/CopyAndPaste.html#//apple_ref/doc/uid/30001234-176911) You want to do something like: ``` someDomNode.onpaste = function(e) { var paste = e.c...
233,721
<p>As per RFC1035, dns names may contain \ddd \x and quote symbol. Please explain with examples about those.</p>
[ { "answer_id": 233941, "author": "jj33", "author_id": 430, "author_profile": "https://Stackoverflow.com/users/430", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://www.ietf.org/rfc/rfc1035.txt\" rel=\"nofollow noreferrer\">RFC1035</a> doesn't say that DNS <strong>names</st...
2008/10/24
[ "https://Stackoverflow.com/questions/233721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
As per RFC1035, dns names may contain \ddd \x and quote symbol. Please explain with examples about those.
[RFC1035](http://www.ietf.org/rfc/rfc1035.txt) doesn't say that DNS **names** can contain those characters. In section 5 (MASTER FILES) it says that the **file** that contains the RR information can contain those characters. Specifically: "Because these files are text files several special encodings are necessary to al...
233,749
<p>I have this loop, which I am using to get the values of all cells within all rows of a gridview and then write it to a csv file. My loop looks like this:</p> <pre><code>string filename = @"C:\Users\gurdip.sira\Documents\Visual Studio 2008\WebSites\Supressions\APP_DATA\surpressionstest.csv"; StreamWriter sWriter = n...
[ { "answer_id": 233891, "author": "EFrank", "author_id": 28572, "author_profile": "https://Stackoverflow.com/users/28572", "pm_score": 1, "selected": false, "text": "<p>I think the inner loop should access the <em>Cells</em>, not the columns:</p>\n\n<pre><code> for (int i = 0; i &lt;= ...
2008/10/24
[ "https://Stackoverflow.com/questions/233749", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30004/" ]
I have this loop, which I am using to get the values of all cells within all rows of a gridview and then write it to a csv file. My loop looks like this: ``` string filename = @"C:\Users\gurdip.sira\Documents\Visual Studio 2008\WebSites\Supressions\APP_DATA\surpressionstest.csv"; StreamWriter sWriter = new StreamWrite...
I think the inner loop should access the *Cells*, not the columns: ``` for (int i = 0; i <= (this.GridView3.Rows.Count - 1); i++) { for (int j = 0; j <= (this.GridView3.Rows[i].Cells.Count - 1); j++) { Str = this.GridView3.Rows[i].Cells[j].Text.ToString(); sWriter.Wri...
233,756
<p>i've written a UserControl descendant that <strong>is</strong> in an assembly dll.</p> <p>How do i drop the control on a form?</p> <pre><code>namespace StackOverflowExample { public partial class MonthViewCalendar : UserControl { ... } } </code></pre> <p>i've added a reference to the assembly under...
[ { "answer_id": 233770, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": -1, "selected": false, "text": "<p>Add the ToolboxAttribute to your class.</p>\n" }, { "answer_id": 233774, "author": "Jeff Yates", "autho...
2008/10/24
[ "https://Stackoverflow.com/questions/233756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
i've written a UserControl descendant that **is** in an assembly dll. How do i drop the control on a form? ``` namespace StackOverflowExample { public partial class MonthViewCalendar : UserControl { ... } } ``` i've added a reference to the assembly under the **References** node in the **Solution Exp...
Normally, when you build your project, your user control will appear in your toolbox at the top. Normally, you will see a new pane with each of your Assemblies and the controls in there. If that doesn't happen, you can also add your control by right clicking on the toolbox, selecting *Choose Items*, then under *.NET F...
233,793
<p>I'm trying to dynamically add some textboxes (input type=text) to a page in javascript and prefill them. The textboxes are coming up, but they are coming up empty. What is the proper way to pre-fill a textbox. Ideally I'd love to use the trick of creating a child div, setting the innerhtml property, and then addi...
[ { "answer_id": 233815, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 2, "selected": false, "text": "<pre><code>txtEmail.value = 'my text'\n</code></pre>\n\n<p>Does not work?</p>\n" }, { "answer_id": 233853, ...
2008/10/24
[ "https://Stackoverflow.com/questions/233793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16891/" ]
I'm trying to dynamically add some textboxes (input type=text) to a page in javascript and prefill them. The textboxes are coming up, but they are coming up empty. What is the proper way to pre-fill a textbox. Ideally I'd love to use the trick of creating a child div, setting the innerhtml property, and then adding tha...
``` txtEmail.value = 'my text' ``` Does not work?
233,802
<p>I am trying to detect Blackberry user agents in my app, which works fine in my development version. But nothing happens when I redeploy the app in production.</p> <p>application_helper.rb</p> <pre><code> def blackberry_user_agent? request.env["HTTP_USER_AGENT"] &amp;&amp; request.env["HTTP_USER_AGENT"][/(Blac...
[ { "answer_id": 233986, "author": "Mike Breen", "author_id": 22346, "author_profile": "https://Stackoverflow.com/users/22346", "pm_score": 3, "selected": true, "text": "<p>Are you using Apache or nginx in front of your mongrel(s)?</p>\n\n<p>Are you logging the user_agent? This is from my ...
2008/10/24
[ "https://Stackoverflow.com/questions/233802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10258/" ]
I am trying to detect Blackberry user agents in my app, which works fine in my development version. But nothing happens when I redeploy the app in production. application\_helper.rb ``` def blackberry_user_agent? request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(Blackberry)/] end ``` applic...
Are you using Apache or nginx in front of your mongrel(s)? Are you logging the user\_agent? This is from my nginx.conf: ``` log_format main '$remote_addr - $remote_user [$time_local] $request ' '"$status" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "http_x_forwarded_for"...
233,842
<p>I am using VB.Net WinForms. I would like to call the Adobe Reader 9 ActiveX control to print some PDFs. I have added the ActiveX control to the VS toolbox (the dll is AcroPDF.dll, the COM name "Adobe PDF Reader". After some experiment the following code works.</p> <pre><code>Dim files As String() = Directory.Get...
[ { "answer_id": 234124, "author": "Rick Minerich", "author_id": 9251, "author_profile": "https://Stackoverflow.com/users/9251", "pm_score": 0, "selected": false, "text": "<p>We ended up using Adobe's PDF Verifier for our own testing purposes. In order to do this we had to actually launch ...
2008/10/24
[ "https://Stackoverflow.com/questions/233842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29411/" ]
I am using VB.Net WinForms. I would like to call the Adobe Reader 9 ActiveX control to print some PDFs. I have added the ActiveX control to the VS toolbox (the dll is AcroPDF.dll, the COM name "Adobe PDF Reader". After some experiment the following code works. ``` Dim files As String() = Directory.GetFiles(TextBoxPath...
Using this method to print multiple documents is not going to work good as you found. Having it work is quite tricky but here is a general description of the solution. I use System.Diagnostics.Process to print using myProcess.StartInfo.Verb = "Print" Then I check the Status and State of printer queue in two steps to ...
233,850
<p>What are the best algorithms (and explanations) for representing and rotating the pieces of a tetris game? I always find the piece rotation and representation schemes confusing.</p> <p>Most tetris games seem to use a naive "remake the array of blocks" at each rotation:</p> <p><a href="http://www.codeplex.com/Proj...
[ { "answer_id": 233882, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 5, "selected": false, "text": "<p>There is a limited amount of shapes, so I would use a fixed table and no calculation. That saves time.</p>\n\n<p>B...
2008/10/24
[ "https://Stackoverflow.com/questions/233850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21826/" ]
What are the best algorithms (and explanations) for representing and rotating the pieces of a tetris game? I always find the piece rotation and representation schemes confusing. Most tetris games seem to use a naive "remake the array of blocks" at each rotation: <http://www.codeplex.com/Project/ProjectDirectory.aspx?...
There is a limited amount of shapes, so I would use a fixed table and no calculation. That saves time. But there are rotation algorithms. Chose a centerpoint and rotate pi/2. If a block of a piece starts at (1,2) it moves clockwise to (2,-1) and (-1,-2) and (-1, 2). Apply this for each block and the piece is rotat...
233,870
<p>I know the statement:</p> <pre><code>create table xyz_new as select * from xyz; </code></pre> <p>Which copies the structure and the data, but what if I just want the structure?</p>
[ { "answer_id": 233879, "author": "branchgabriel", "author_id": 30807, "author_profile": "https://Stackoverflow.com/users/30807", "pm_score": 4, "selected": false, "text": "<p>Using sql developer select the table and click on the DDL tab</p>\n\n<p>You can use that code to create a new tab...
2008/10/24
[ "https://Stackoverflow.com/questions/233870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5662/" ]
I know the statement: ``` create table xyz_new as select * from xyz; ``` Which copies the structure and the data, but what if I just want the structure?
Just use a where clause that won't select any rows: ``` create table xyz_new as select * from xyz where 1=0; ``` ### Limitations The following things will not be copied to the new table: * sequences * triggers * indexes * some constraints may not be copied * materialized view logs This also does not handle partit...
233,896
<p>Whenever I drop a new database object from server explorer into the dbml, Visual Studio replaces the connection string in the designer file with a new one that it automatically adds to the connection strings in my config file. They both have exactly the same parameters, just different names.</p> <p>How do I force V...
[ { "answer_id": 249527, "author": "alextansc", "author_id": 19582, "author_profile": "https://Stackoverflow.com/users/19582", "pm_score": 1, "selected": false, "text": "<p>You'll need to make sure the connectionstring used in the Server Explorer of your Visual Studio is the same as the on...
2008/10/24
[ "https://Stackoverflow.com/questions/233896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30604/" ]
Whenever I drop a new database object from server explorer into the dbml, Visual Studio replaces the connection string in the designer file with a new one that it automatically adds to the connection strings in my config file. They both have exactly the same parameters, just different names. How do I force Visual Stud...
There's a good post that pretty much explains your options here: <http://blog.jongallant.com/2007/11/linq-web-app-connection-strings.html#.UGA8Q42PUg0>
233,905
<p>Is is better to do a joined query like this:</p> <pre><code>var employer = (from person in db.People join employer in db.Employers on person.EmployerID equals employer.EmployerID where person.PersonID == idPerson select employer).FirstOrDefaul...
[ { "answer_id": 233920, "author": "David Basarab", "author_id": 2469, "author_profile": "https://Stackoverflow.com/users/2469", "pm_score": 1, "selected": false, "text": "<p>The second one could evaluate to null which would result in an error.</p>\n\n<p>I like the first one better because...
2008/10/24
[ "https://Stackoverflow.com/questions/233905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4797/" ]
Is is better to do a joined query like this: ``` var employer = (from person in db.People join employer in db.Employers on person.EmployerID equals employer.EmployerID where person.PersonID == idPerson select employer).FirstOrDefault(); ``` Or ...
I'd use this: ``` var employer = (from person in db.People where person.PersonID == idPerson select person.Employer).FirstOrDefault(); ``` It's got the simplicity of the first version but still only fetches the data for the employer (rather than the person *and* the employer).
233,908
<p>I need to replace some 2- and 3-digit numbers with the same number plus 10000. So</p> <pre><code>Photo.123.aspx </code></pre> <p>needs to become</p> <pre><code>Photo.10123.aspx </code></pre> <p>and also</p> <pre><code>Photo.12.aspx </code></pre> <p>needs to become</p> <pre><code>Photo.10012.aspx </code></pre>...
[ { "answer_id": 233914, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 3, "selected": false, "text": "<p>I think that using a RegEx for the match, and a function for the replace is most appropriate in this case, you ...
2008/10/24
[ "https://Stackoverflow.com/questions/233908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239663/" ]
I need to replace some 2- and 3-digit numbers with the same number plus 10000. So ``` Photo.123.aspx ``` needs to become ``` Photo.10123.aspx ``` and also ``` Photo.12.aspx ``` needs to become ``` Photo.10012.aspx ``` I know that in .NET I can delegate the replacement to a function and just add 10000 to the...
James is right that you want to use the Regex.Replace method that takes a MatchEvaluator argument. The match evaluator delegate is where you can take the numeric string you get in the match and convert it into a number that you can add 10,000 to. I used a lambda expression in place of the explicit delegate because its ...
233,919
<p>I have been working with T-SQL in MS SQL for some time now and somehow whenever I have to insert data into a table I tend to use syntax:</p> <pre><code>INSERT INTO myTable &lt;something here&gt; </code></pre> <p>I understand that keyword <code>INTO</code> is optional here and I do not have to use it but somehow it...
[ { "answer_id": 233937, "author": "DOK", "author_id": 27637, "author_profile": "https://Stackoverflow.com/users/27637", "pm_score": 1, "selected": false, "text": "<p>They both do the same thing. INTO is optional (in SQL Server's T-SQL) but aids readability.</p>\n" }, { "answer_id"...
2008/10/24
[ "https://Stackoverflow.com/questions/233919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3241/" ]
I have been working with T-SQL in MS SQL for some time now and somehow whenever I have to insert data into a table I tend to use syntax: ``` INSERT INTO myTable <something here> ``` I understand that keyword `INTO` is optional here and I do not have to use it but somehow it grew into habit in my case. My question i...
`INSERT INTO` is the standard. Even though `INTO` is optional in most implementations, it's required in a few, so it's a good idea to include it to ensure that your code is portable. You can find links to several versions of the SQL standard [here](http://en.wikipedia.org/wiki/SQL#Standardization). I found an HTML ver...
233,922
<p>I have this code to give me a rollover on submit buttons, and I'm trying to make it more generic:</p> <pre><code>$('.rollover').hover( function(){ // Change the input image's source when we "roll on" srcPath = $(this).attr("src"); srcPathOver = ??????? ...
[ { "answer_id": 234025, "author": "Matt Ephraim", "author_id": 22291, "author_profile": "https://Stackoverflow.com/users/22291", "pm_score": 2, "selected": false, "text": "<p>You should be able to use a regex replace to modify your source path. Like this: </p>\n\n<pre><code>srcPathOver =...
2008/10/24
[ "https://Stackoverflow.com/questions/233922", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26107/" ]
I have this code to give me a rollover on submit buttons, and I'm trying to make it more generic: ``` $('.rollover').hover( function(){ // Change the input image's source when we "roll on" srcPath = $(this).attr("src"); srcPathOver = ??????? /*nee...
``` $('.rollover').hover( function(){ // Change the input image's source when we "roll on" var t = $(this); t.attr('src',t.attr('src').replace(/([^.]*)\.(.*)/, "$1-over.$2")); }, function(){ var t= $(this); t.attr('src'...
233,936
<p>Ok let me make an example:</p> <pre><code>&lt;head&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ $("#options_2").hide(); $("#options_3").hide(); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="options_1"&gt;option 1&lt;/div&gt; &lt;div id="options_2"&gt;option 2&lt;/di...
[ { "answer_id": 234009, "author": "Wayne Austin", "author_id": 31109, "author_profile": "https://Stackoverflow.com/users/31109", "pm_score": 2, "selected": false, "text": "<p>Given the format your given I'd do something like the following, assign each link with an id that can understandab...
2008/10/24
[ "https://Stackoverflow.com/questions/233936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26823/" ]
Ok let me make an example: ``` <head> <script type="text/javascript"> $(document).ready(function(){ $("#options_2").hide(); $("#options_3").hide(); }); </script> </head> <body> <div id="options_1">option 1</div> <div id="options_2">option 2</div> <div id="options_3">option 3</div> <a href="" class="selected"...
First of all give your links a class or Id (I've used a class), which will make it easier to do the swap in ``` <div id="options_1" class="tab" >option 1</div> <div id="options_2" class="tab">option 2</div> <div id="options_3" class="tab">option 3</div> $(document).ready(function () { var clickHandler = function...
233,979
<p>I am trying to link to a file that has the '#' character in via a window.open() call. The file does exist and can be linked to just fine using a normal anchor tag.</p> <p>I have tried escaping the '#' character with '%23' but when the window.open(myurl) gets processed, the '%23' becomes '%2523'. This tells me tha...
[ { "answer_id": 234002, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 0, "selected": false, "text": "<p>Did you try using the standard text escape char \"\\\"?</p>\n\n<pre><code>\\#\n</code></pre>\n" }, { "answer...
2008/10/24
[ "https://Stackoverflow.com/questions/233979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18284/" ]
I am trying to link to a file that has the '#' character in via a window.open() call. The file does exist and can be linked to just fine using a normal anchor tag. I have tried escaping the '#' character with '%23' but when the window.open(myurl) gets processed, the '%23' becomes '%2523'. This tells me that my url str...
You seek the dark magicks of [encodeURI](http://www.w3schools.com/jsref/jsref_encodeURI.asp): ``` window.open("http://your-url.com/" + encodeURIComponent("foo#123.jpg")); ```
234,008
<p>I need to create at runtime instances of a class that uses generics, like <code>class&lt;T&gt;</code>, without knowing previously the type T they will have, I would like to do something like that:</p> <pre><code>public Dictionary&lt;Type, object&gt; GenerateLists(List&lt;Type&gt; types) { Dictionary&lt;Type, ob...
[ { "answer_id": 234016, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "<p>You can't do it like that - the point of generics is mostly <em>compile-time</em> type-safety - but you can do it with...
2008/10/24
[ "https://Stackoverflow.com/questions/234008", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21668/" ]
I need to create at runtime instances of a class that uses generics, like `class<T>`, without knowing previously the type T they will have, I would like to do something like that: ``` public Dictionary<Type, object> GenerateLists(List<Type> types) { Dictionary<Type, object> lists = new Dictionary<Type, object>(); ...
You can't do it like that - the point of generics is mostly *compile-time* type-safety - but you can do it with reflection: ``` public Dictionary<Type, object> GenerateLists(List<Type> types) { Dictionary<Type, object> lists = new Dictionary<Type, object>(); foreach (Type type in types) { Type gen...
234,027
<p>How can I find the index in a string that matches a boost regex?</p>
[ { "answer_id": 234248, "author": "Anthony Williams", "author_id": 5597, "author_profile": "https://Stackoverflow.com/users/5597", "pm_score": 3, "selected": false, "text": "<p>Use the <code>position</code> member function of the <code>match_results</code>:</p>\n\n<pre><code>int find_matc...
2008/10/24
[ "https://Stackoverflow.com/questions/234027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
How can I find the index in a string that matches a boost regex?
If you use boost::regex\_match it's the whole string that's matching. Maybe you mean to use regex\_search: ``` void index(boost::regex& re,const std::string& input){ boost::match_results<std::string::const_iterator> what; boost::match_flag_type flags = boost::match_default; std::string::const_iterator s...
234,044
<p>I am trying to achieve anonymous personalization in a ASP.net environment. I know that ASP.NET 2.0 provide <a href="http://www.odetocode.com/articles/440.aspx" rel="nofollow noreferrer">Profile</a>. However, I want to avoid traffic to the database as much as possible since the site I am working on is a relatively h...
[ { "answer_id": 239386, "author": "Ady", "author_id": 31395, "author_profile": "https://Stackoverflow.com/users/31395", "pm_score": 0, "selected": false, "text": "<p>I'd create a database record for the visitor and only store the ID in the cookie, this way you can look up all the personal...
2008/10/24
[ "https://Stackoverflow.com/questions/234044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31206/" ]
I am trying to achieve anonymous personalization in a ASP.net environment. I know that ASP.NET 2.0 provide [Profile](http://www.odetocode.com/articles/440.aspx). However, I want to avoid traffic to the database as much as possible since the site I am working on is a relatively high traffic site. The other obvious solu...
If database load is an issue, you can retrieve the personalization when the user starts his session on the website, and then store it on the session state. This way, only the first page load will make a call to the database. You can store the user ID in the cookie. Just remember to persist the session in the db when ...
234,056
<p>Anyone got a ready made function that will take an XML string and return a correctly indented string?</p> <p>eg</p> <pre><code>&lt;XML&gt;&lt;TAG1&gt;A&lt;/TAG1&gt;&lt;TAG2&gt;&lt;Tag3&gt;&lt;/Tag3&gt;&lt;/TAG2&gt;&lt;/XML&gt; </code></pre> <p>and will return nicely formatted String in return after inserting line...
[ { "answer_id": 234101, "author": "gabr", "author_id": 4997, "author_profile": "https://Stackoverflow.com/users/4997", "pm_score": 3, "selected": false, "text": "<p>Using <a href=\"http://www.omnixml.com/\" rel=\"noreferrer\">OmniXML</a>:</p>\n\n<pre><code>program TestIndentXML;\n\n{$APPT...
2008/10/24
[ "https://Stackoverflow.com/questions/234056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6244/" ]
Anyone got a ready made function that will take an XML string and return a correctly indented string? eg ``` <XML><TAG1>A</TAG1><TAG2><Tag3></Tag3></TAG2></XML> ``` and will return nicely formatted String in return after inserting linebreaks and tabs or spaces?
The RTL has [FormatXMLData](http://docwiki.embarcadero.com/Libraries/XE5/en/Xml.XMLDoc.FormatXMLData) in XMLDoc.pas that accepts and returns strings.
234,059
<p>I have the following code:</p> <pre><code>MemoryStream foo(){ MemoryStream ms = new MemoryStream(); // write stuff to ms return ms; } void bar(){ MemoryStream ms2 = foo(); // do stuff with ms2 return; } </code></pre> <p>Is there any chance that the MemoryStream that I've allocated will som...
[ { "answer_id": 234068, "author": "Nick", "author_id": 26161, "author_profile": "https://Stackoverflow.com/users/26161", "pm_score": 3, "selected": false, "text": "<p>All streams implement IDisposable. Wrap your Memory stream in a using statement and you'll be fine and dandy. The using ...
2008/10/24
[ "https://Stackoverflow.com/questions/234059", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26286/" ]
I have the following code: ``` MemoryStream foo(){ MemoryStream ms = new MemoryStream(); // write stuff to ms return ms; } void bar(){ MemoryStream ms2 = foo(); // do stuff with ms2 return; } ``` Is there any chance that the MemoryStream that I've allocated will somehow fail to be disposed o...
If something is Disposable, you should always Dispose it. You should be using a `using` statement in your `bar()` method to make sure `ms2` gets Disposed. It will eventually get cleaned up by the garbage collector, but it is always good practice to call Dispose. If you run FxCop on your code, it would flag it as a war...
234,064
<p>Using data binding, how do you bind a new object that uses value types? </p> <p>Simple example:</p> <pre><code>public class Person() { private string _firstName; private DateTime _birthdate; private int _favoriteNumber; //Properties } </code></pre> <p>If I create a new Person() and bind it to a f...
[ { "answer_id": 234155, "author": "Arcturus", "author_id": 900, "author_profile": "https://Stackoverflow.com/users/900", "pm_score": 2, "selected": false, "text": "<p>Perhaps you can try Nullable types?</p>\n\n<pre><code>public class Person() {\n private string? _firstName;\n privat...
2008/10/24
[ "https://Stackoverflow.com/questions/234064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4231/" ]
Using data binding, how do you bind a new object that uses value types? Simple example: ``` public class Person() { private string _firstName; private DateTime _birthdate; private int _favoriteNumber; //Properties } ``` If I create a new Person() and bind it to a form with text boxes. Birth Date di...
Perhaps you can try Nullable types? ``` public class Person() { private string? _firstName; private DateTime? _birthdate; private int? _favoriteNumber; //Properties } ``` or ``` public class Person() { private Nullable<string> _firstName; private Nullable<DateTime> _birthdate; private N...
234,076
<p>I have a "Login" button that I want to be disabled until 3 text boxes on the same WPF form are populated with text (user, password, server). </p> <p>I have a backing object with a boolean property called IsLoginEnabled which returns True if and only if all 3 controls have data. However, when should I be checking ...
[ { "answer_id": 234118, "author": "Totty", "author_id": 30838, "author_profile": "https://Stackoverflow.com/users/30838", "pm_score": 0, "selected": false, "text": "<p>Yes, I would say the easiest option would be to check it on the LostFocus or TextChanged event of each of those controls....
2008/10/24
[ "https://Stackoverflow.com/questions/234076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/132931/" ]
I have a "Login" button that I want to be disabled until 3 text boxes on the same WPF form are populated with text (user, password, server). I have a backing object with a boolean property called IsLoginEnabled which returns True if and only if all 3 controls have data. However, when should I be checking this propert...
I'd get the "backing object" to raise the `IsLoginEnabled` changed event when any of the 3 fields are updated. You can then bind the button to the IsLoginEnabled property and not have to keep checking it. The pseudocode would look something like this: ``` Public Event IsLoginEnabledChanged As EventHandler Public Pro...
234,090
<p>How do I pass a parameter from a page's useBean in JSP to a servlet in Java? I have some data in a form that gets passed no problem with a submit button, but no way to send anything else. Please help? Here is my code:</p> <pre><code>&lt;input name = "deleteGameButton" type = "submit" value = "Delete" onclick = "su...
[ { "answer_id": 234125, "author": "Vladimir Dyuzhev", "author_id": 1163802, "author_profile": "https://Stackoverflow.com/users/1163802", "pm_score": 3, "selected": true, "text": "<p>You kind of mess things here.</p>\n\n<p>onclick() is Javascript and executed on client side. It has no (dir...
2008/10/24
[ "https://Stackoverflow.com/questions/234090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25280/" ]
How do I pass a parameter from a page's useBean in JSP to a servlet in Java? I have some data in a form that gets passed no problem with a submit button, but no way to send anything else. Please help? Here is my code: ``` <input name = "deleteGameButton" type = "submit" value = "Delete" onclick = "submitToServlet('De...
You kind of mess things here. onclick() is Javascript and executed on client side. It has no (direct) way to update session-scoped bean. That bean is left on server-side, and was used when the HTML page was **generated**. To pass parameters back to servlet you need to use good old form fields, and submit the form. A...
234,091
<p>We have a highly specialized DAL which sits over our DB. Our apps need to use this DAL to correctly operate against this DB.</p> <p>The generated DAL (which sits on some custom base classes) has various 'Rec' classes (Table1Rec, Table2Rec) each of which represents the record structure of a given table.</p> <p>Here...
[ { "answer_id": 234216, "author": "Sixto Saez", "author_id": 9711, "author_profile": "https://Stackoverflow.com/users/9711", "pm_score": 0, "selected": false, "text": "<p>Web services are designed to expose operation(methods) &amp; data contracts but not internal implementation logic. Thi...
2008/10/24
[ "https://Stackoverflow.com/questions/234091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11356/" ]
We have a highly specialized DAL which sits over our DB. Our apps need to use this DAL to correctly operate against this DB. The generated DAL (which sits on some custom base classes) has various 'Rec' classes (Table1Rec, Table2Rec) each of which represents the record structure of a given table. Here is a sample Pseu...
Not sure if I fully understand the question, but you can have nullable data types in XML. So this... ``` Imports System.Web Imports System.Web.Services Imports System.Web.Services.Protocols <WebService(Namespace:="http://tempuri.org/")> _ <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _ <Global.Micros...
234,110
<p>I'm trying to do a very simple INSERT using VB.NET. For some reason I'm getting a SqlException on every insert though. The data is inserted, but still get the following: </p> <p>Violation of PRIMARY KEY constraint 'PK_User'. Cannot insert duplicate key in object 'dbo.Employee'. The statement has been terminated</...
[ { "answer_id": 234132, "author": "Joseph Anderson", "author_id": 18102, "author_profile": "https://Stackoverflow.com/users/18102", "pm_score": 3, "selected": true, "text": "<p>Two theories. Either your code is being executed twice, or there's a trigger on the Employee table that's attemp...
2008/10/24
[ "https://Stackoverflow.com/questions/234110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to do a very simple INSERT using VB.NET. For some reason I'm getting a SqlException on every insert though. The data is inserted, but still get the following: Violation of PRIMARY KEY constraint 'PK\_User'. Cannot insert duplicate key in object 'dbo.Employee'. The statement has been terminated When I chec...
Two theories. Either your code is being executed twice, or there's a trigger on the Employee table that's attempting an insert following the successful insert. (Edit: @Mitchel Sellers is exactly right, if the same code works in c# it's absolutely not a trigger issue.) My hunch is that your code is being executed twice...
234,131
<p>I did this tests and the results seems the count function scale linearly. I have another function relying strongly in the efficiency to know if there are any data, so I would like to know how to replace this select count(*) with another more efficient (maybe constant?) query or data structure.</p> <blockquote> <p...
[ { "answer_id": 234153, "author": "warren", "author_id": 4418, "author_profile": "https://Stackoverflow.com/users/4418", "pm_score": 0, "selected": false, "text": "<p>How a count on the primary key field where it is NOT NULL, limiting the query at 1 response?</p>\n\n<p>Since a primary key...
2008/10/24
[ "https://Stackoverflow.com/questions/234131", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18300/" ]
I did this tests and the results seems the count function scale linearly. I have another function relying strongly in the efficiency to know if there are any data, so I would like to know how to replace this select count(\*) with another more efficient (maybe constant?) query or data structure. > > psql -d testdb -U ...
You may find [this](http://wiki.postgresql.org/wiki/Slow_Counting) useful.
234,174
<p>I couldn't figure out why NHibernate is doing this. </p> <p>Here's part of my table in MS SQL</p> <pre><code>CREATE TABLE Person ( nameFamily text, nameGiven text ) </code></pre> <p>Here's Person.hbm.xml</p> <pre><code>&lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"&gt; &lt;class name="Infosci.Dpd....
[ { "answer_id": 234245, "author": "DJ.", "author_id": 10492, "author_profile": "https://Stackoverflow.com/users/10492", "pm_score": 2, "selected": false, "text": "<p>That's a \"feature\" of SetNamingStrategy(ImprovedNamingStrategy.Instance)</p>\n\n<p>It will add underscores before each up...
2008/10/24
[ "https://Stackoverflow.com/questions/234174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22839/" ]
I couldn't figure out why NHibernate is doing this. Here's part of my table in MS SQL ``` CREATE TABLE Person ( nameFamily text, nameGiven text ) ``` Here's Person.hbm.xml ``` <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <class name="Infosci.Dpd.Model.Person,Infosci.Dpd.Model" table="Person" lazy="t...
That's a "feature" of SetNamingStrategy(ImprovedNamingStrategy.Instance) It will add underscores before each uppercase letter in mixed-cased names. Not sure how you disable it (me not being a nhibernate user)
234,177
<p>As usual, some background information first:</p> <p>Database A (Access database) - Holds a table that has information I need from only two columns. The information from these two columns is needed for an application that will be used by people that cannot access database A.</p> <p>Database B (Access database) - Ho...
[ { "answer_id": 234188, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 0, "selected": false, "text": "<p>Why not simply use a data reader, and loop through the records, doing manual inserts if needed into database B?...
2008/10/24
[ "https://Stackoverflow.com/questions/234177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9732/" ]
As usual, some background information first: Database A (Access database) - Holds a table that has information I need from only two columns. The information from these two columns is needed for an application that will be used by people that cannot access database A. Database B (Access database) - Holds a table that ...
Setting aside for a moment that I would use SQLServer and only have a single table with multiple views controlling who could see what information in it to avoid the whole synchronization problem... I think that @Mitchel is correct here. Just write a program that connects to both databases, load A table and B table, re...
234,210
<p>I'm trying to write a web application using SpringMVC. Normally I'd just map some made-up file extension to Spring's front controller and live happily, but this time I'm going for REST-like URLs, with no file-name extensions.</p> <p>Mapping everything under my context path to the front controller (let's call it "...
[ { "answer_id": 244754, "author": "Adam Crume", "author_id": 25498, "author_profile": "https://Stackoverflow.com/users/25498", "pm_score": 2, "selected": false, "text": "<p>I've never tried to map a servlet like this, but I <em>would</em> argue that /* does technically both start with / a...
2008/10/24
[ "https://Stackoverflow.com/questions/234210", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6069/" ]
I'm trying to write a web application using SpringMVC. Normally I'd just map some made-up file extension to Spring's front controller and live happily, but this time I'm going for REST-like URLs, with no file-name extensions. Mapping everything under my context path to the front controller (let's call it "**app**") me...
I think I may know what is going on. In your working web.xml you have set your servlet to be the default servlet (/ by itself is the default servlet called if there are no other matches), it will answer any request that doesn't match another mapping. In Failed 1 your /\* mapping does appear to be a valid path mapping...
234,215
<p>I am creating a WordML document from an xml file whose elements sometimes contain html-formatted text. </p> <pre><code>&lt;w:p&gt; &lt;w:r&gt; &lt;w:t&gt; html formatted content is in here taken from xml file! &lt;/w:t&gt; &lt;/w:r&gt; &lt;/w:p&gt; </code></pre> <p>This is how my templates are sort of set...
[ { "answer_id": 239235, "author": "GerG", "author_id": 17249, "author_profile": "https://Stackoverflow.com/users/17249", "pm_score": 0, "selected": false, "text": "<p>I can most probably help you if only I understood your problem... Is the html in a CDATA section or is it parsed as part o...
2008/10/24
[ "https://Stackoverflow.com/questions/234215", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31229/" ]
I am creating a WordML document from an xml file whose elements sometimes contain html-formatted text. ``` <w:p> <w:r> <w:t> html formatted content is in here taken from xml file! </w:t> </w:r> </w:p> ``` This is how my templates are sort of set up. I have a recursive call-template function that does text r...
Working with WordML is tricky. One tip when converting arbitrary XML to WordML using XSLT is to not worry about the text runs when processing blocks, but to instead create a template that matches text() nodes directly, and create the text runs there. It turns out that Word doesn't care if you nest text runs, which make...
234,217
<p><strong>Note: Mathematical expression evaluation is not the focus of this question. I want to compile and execute new code at runtime in .NET.</strong> That being said...</p> <p>I would like to allow the user to enter any equation, like the following, into a text box:</p> <pre><code>x = x / 2 * 0.07914 x = x^2 /...
[ { "answer_id": 234228, "author": "Scott Dorman", "author_id": 1559, "author_profile": "https://Stackoverflow.com/users/1559", "pm_score": 2, "selected": false, "text": "<p>You can try looking at either CodeDom or Lambda Expression Trees. I think either one of those should allow you to ac...
2008/10/24
[ "https://Stackoverflow.com/questions/234217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4228/" ]
**Note: Mathematical expression evaluation is not the focus of this question. I want to compile and execute new code at runtime in .NET.** That being said... I would like to allow the user to enter any equation, like the following, into a text box: ``` x = x / 2 * 0.07914 x = x^2 / 5 ``` And have that equation appl...
Yes! Using methods found in the [Microsoft.CSharp](http://msdn.microsoft.com/en-us/library/microsoft.csharp.aspx), [System.CodeDom.Compiler](http://msdn.microsoft.com/en-us/library/system.codedom.compiler.aspx), and [System.Reflection](http://msdn.microsoft.com/en-us/library/system.reflection.aspx) name spaces. Here is...
234,231
<p>How do you create an application shortcut (.lnk file) in C# or using the .NET framework?</p> <p>The result would be a .lnk file to the specified application or URL.</p>
[ { "answer_id": 234543, "author": "Charley Rathkopf", "author_id": 10119, "author_profile": "https://Stackoverflow.com/users/10119", "pm_score": 7, "selected": true, "text": "<p>It's not as simple as I'd have liked, but there is a great class call <a href=\"http://www.vbaccelerator.com/ho...
2008/10/24
[ "https://Stackoverflow.com/questions/234231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10119/" ]
How do you create an application shortcut (.lnk file) in C# or using the .NET framework? The result would be a .lnk file to the specified application or URL.
It's not as simple as I'd have liked, but there is a great class call [ShellLink.cs](http://www.vbaccelerator.com/home/NET/Code/Libraries/Shell_Projects/Creating_and_Modifying_Shortcuts/ShellLink_Code.html) at [vbAccelerator](http://www.vbaccelerator.com/home/index.html) This code uses interop, but does not rely on W...
234,239
<p>C# .NET 3.5. I'm trying to understand the intrinsic limitation of the C# Action object. Within the lamda (are those, in fact, lamdas?), we can perform assignments, call functions, even execute a ternary operation, but we can't execute a multi-statement operation.</p> <p>Is this because the single-statement execut...
[ { "answer_id": 234266, "author": "cfeduke", "author_id": 5645, "author_profile": "https://Stackoverflow.com/users/5645", "pm_score": 5, "selected": true, "text": "<p>You are missing a semi-colon, it compiles:</p>\n\n<pre><code> Action action = () =&gt; { if (m_Count &lt; 10) m_Count++; v...
2008/10/24
[ "https://Stackoverflow.com/questions/234239", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17803/" ]
C# .NET 3.5. I'm trying to understand the intrinsic limitation of the C# Action object. Within the lamda (are those, in fact, lamdas?), we can perform assignments, call functions, even execute a ternary operation, but we can't execute a multi-statement operation. Is this because the single-statement execution is just ...
You are missing a semi-colon, it compiles: ``` Action action = () => { if (m_Count < 10) m_Count++; value = m_Count; }; ``` When you say `type name = statement;` you need a semicolon even if you use braces for a code block.
234,241
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/7094118/reference-comparing-phps-print-and-echo">Reference: Comparing PHP&#39;s print and echo</a> </p> </blockquote> <p>Is there any major and fundamental difference between these two functions in PHP?</p>
[ { "answer_id": 234255, "author": "dl__", "author_id": 28565, "author_profile": "https://Stackoverflow.com/users/28565", "pm_score": 9, "selected": true, "text": "<p>From:\n<a href=\"http://web.archive.org/web/20090221144611/http://faqts.com/knowledge_base/view.phtml/aid/1/fid/40\" rel=\"...
2008/10/24
[ "https://Stackoverflow.com/questions/234241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26823/" ]
> > **Possible Duplicate:** > > [Reference: Comparing PHP's print and echo](https://stackoverflow.com/questions/7094118/reference-comparing-phps-print-and-echo) > > > Is there any major and fundamental difference between these two functions in PHP?
From: <http://web.archive.org/web/20090221144611/http://faqts.com/knowledge_base/view.phtml/aid/1/fid/40> 1. Speed. There is a difference between the two, but speed-wise it should be irrelevant which one you use. echo is marginally faster since it doesn't set a return value if you really want to get down to the nitty...
234,249
<p>I'm trying to come up with a Java regex that will match a filename only if it has a valid extension. For example it should match "foo.bar" and "foo.b", but neither "foo." nor "foo".</p> <p>I've written the following test program</p> <pre><code>public static void main(String[] args) { Pattern fileExtensionPattern...
[ { "answer_id": 234283, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 4, "selected": true, "text": "<p>The <a href=\"http://java.sun.com/javase/6/docs/api/java/util/regex/Matcher.html#matches()\" rel=\"noreferrer\">Ma...
2008/10/24
[ "https://Stackoverflow.com/questions/234249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
I'm trying to come up with a Java regex that will match a filename only if it has a valid extension. For example it should match "foo.bar" and "foo.b", but neither "foo." nor "foo". I've written the following test program ``` public static void main(String[] args) { Pattern fileExtensionPattern = Pattern.compile("\...
The [Matcher.matches()](http://java.sun.com/javase/6/docs/api/java/util/regex/Matcher.html#matches()) function tries to match the pattern against the entire input. Thus, you have to add `.*` to the beginning of your regex (and the `\\Z` at the end is superfluous, too), or use the [find()](http://java.sun.com/javase/6/d...
234,268
<p>When overriding the MembershipProvider and calling it directly, is there a way to fill the NameValueCollection config parameter of the Initialize method without manually looking through the config file for the settings? </p> <p>Obviously this Initialize is being called by asp.net and the config is being filled som...
[ { "answer_id": 234327, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": false, "text": "<p>Not sure why you want to create a new one, but if you create it yourself, you'll need to read the web config and get...
2008/10/24
[ "https://Stackoverflow.com/questions/234268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30848/" ]
When overriding the MembershipProvider and calling it directly, is there a way to fill the NameValueCollection config parameter of the Initialize method without manually looking through the config file for the settings? Obviously this Initialize is being called by asp.net and the config is being filled somewhere. I h...
tvanfosson- Thanks for the help. (if I had the 15 points necessary I would vote you up) From your link I was able to figure it out. It turns out the second parameter to the Initialize proceedure was the list of parameters from the provider and could be reached in the following way: ``` string configPath = "~/web.con...
234,289
<p>From everything I've read, it seemed that adding paging to a ListView control should be dead simple, but it's not working for me. After adding the ListView and DataPager controls to the form and wiring them together, I'm getting very odd behavior. The DataPager correctly limits the ListView's page size, but clicking...
[ { "answer_id": 237036, "author": "MartinHN", "author_id": 2972, "author_profile": "https://Stackoverflow.com/users/2972", "pm_score": 2, "selected": true, "text": "<p>Take a look at the ListViewPagedDataSource.</p>\n\n<pre><code>private ListViewPagedDataSource GetProductsAsPagedDataSourc...
2008/10/24
[ "https://Stackoverflow.com/questions/234289", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23935/" ]
From everything I've read, it seemed that adding paging to a ListView control should be dead simple, but it's not working for me. After adding the ListView and DataPager controls to the form and wiring them together, I'm getting very odd behavior. The DataPager correctly limits the ListView's page size, but clicking th...
Take a look at the ListViewPagedDataSource. ``` private ListViewPagedDataSource GetProductsAsPagedDataSource(DataView dv) { // Limit the results through a PagedDataSource ListViewPagedDataSource pagedData = new ListViewPagedDataSource(); pagedData.DataSource = dv; pagedData.MaximumRows = dv.Table.Rows.Count; pagedData...
234,291
<p>I don´t know why, but my form isn´t calling Form_Load event when it loads.</p> <p>Any ideas why this might be happening?</p>
[ { "answer_id": 234342, "author": "itsmatt", "author_id": 7862, "author_profile": "https://Stackoverflow.com/users/7862", "pm_score": 3, "selected": false, "text": "<p>Do you have the event handler set up?</p>\n\n<p>Ultimately, there is going to be a line of code that looks something like...
2008/10/24
[ "https://Stackoverflow.com/questions/234291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22869/" ]
I don´t know why, but my form isn´t calling Form\_Load event when it loads. Any ideas why this might be happening?
Do you have the event handler set up? Ultimately, there is going to be a line of code that looks something like this: ``` this.Load += new System.EventHandler(this.Form1_Load); ``` That might be something you code yourself, or is generated by double-clicking the Load event for the form from within Visual Studio.
234,333
<p>I am displaying a texture that I want to manipulate without out affecting the image data. I want to be able to clamp the texel values so that anything below the lower value becomes 0, anything above the upper value becomes 0, and anything between is linearly mapped from 0 to 1. </p> <p>Originally, to display my ima...
[ { "answer_id": 235529, "author": "Menkboy", "author_id": 29539, "author_profile": "https://Stackoverflow.com/users/29539", "pm_score": 3, "selected": true, "text": "<p>Unless you have a pretty old graphics-card, it's surprising that you don't have fragment-shader support. I'd suggest you...
2008/10/24
[ "https://Stackoverflow.com/questions/234333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55638/" ]
I am displaying a texture that I want to manipulate without out affecting the image data. I want to be able to clamp the texel values so that anything below the lower value becomes 0, anything above the upper value becomes 0, and anything between is linearly mapped from 0 to 1. Originally, to display my image I was u...
Unless you have a pretty old graphics-card, it's surprising that you don't have fragment-shader support. I'd suggest you try double-checking using [this](http://www.realtech-vr.com/glview/). Also, are you sure you want anything above the max value to be 0? Perhaps you meant 1? If you did mean 1 and not 0 then are quit...
234,367
<p>As a software developer, I have done many web page applications and been doing blog for my programming experiences. I would like to use pictures in many cases. <strong>Pictures worth thousand words and they are universal language</strong>!</p> <p>You could create your own clip art images or download graphics(actual...
[ { "answer_id": 234569, "author": "Chris", "author_id": 15578, "author_profile": "https://Stackoverflow.com/users/15578", "pm_score": 1, "selected": false, "text": "<p>Typically sites discourage this. What this really does is shift the bandwidth cost to the hosting site. There have been...
2008/10/24
[ "https://Stackoverflow.com/questions/234367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62776/" ]
As a software developer, I have done many web page applications and been doing blog for my programming experiences. I would like to use pictures in many cases. **Pictures worth thousand words and they are universal language**! You could create your own clip art images or download graphics(actually many are open clip a...
Typically sites discourage this. What this really does is shift the bandwidth cost to the hosting site. There have been cases where sites with pictures have analyzed the referrer to determine if images are linked to from other sites, then servering an image with text claiming the image is being 'stolen'. The point of ...
234,388
<p>I'm trying to make a simple blackjack program. Sadly, I'm having problems right off the bat with generating a deck of cards.</p> <pre><code>#include &lt;iostream&gt; #include &lt;vector&gt; using namespace std; int main() { vector&lt;char&gt; deck; char suit[] = {'h','d','c','s'}; char card[] = {'2','...
[ { "answer_id": 234393, "author": "Dave", "author_id": 21294, "author_profile": "https://Stackoverflow.com/users/21294", "pm_score": 3, "selected": false, "text": "<p>Use 'T' instead of 10.</p>\n" }, { "answer_id": 234394, "author": "Ross", "author_id": 2025, "author_p...
2008/10/24
[ "https://Stackoverflow.com/questions/234388", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38/" ]
I'm trying to make a simple blackjack program. Sadly, I'm having problems right off the bat with generating a deck of cards. ``` #include <iostream> #include <vector> using namespace std; int main() { vector<char> deck; char suit[] = {'h','d','c','s'}; char card[] = {'2','3','4','5','6','7','8','9','10',...
Try to create class of Card with suit and card as a member and set it as a type of vector. Like ``` public class Card { public: Card(char suit, char card); char suit, card; }; int main() { vector<Card> deck; char suit[] = {'h','d','c','s'}; char card[] = {'2','3','4','5','6','7','8','9','T','J','Q','...
234,439
<p>Disclaimer: I've solved the problem using Expressions from System.Linq.Expressions, but I'm still looking for a better/easier way.</p> <p>Consider the following situation :</p> <pre><code>var query = from c in db.Customers where (c.ContactFirstName.Contains("BlackListed") || c.ContactLastName....
[ { "answer_id": 234523, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 3, "selected": false, "text": "<pre><code>var query = from C in db.Customers select c;\n\nif (seachFirstName)\n query = query.Where(c=&gt;c....
2008/10/24
[ "https://Stackoverflow.com/questions/234439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9178/" ]
Disclaimer: I've solved the problem using Expressions from System.Linq.Expressions, but I'm still looking for a better/easier way. Consider the following situation : ``` var query = from c in db.Customers where (c.ContactFirstName.Contains("BlackListed") || c.ContactLastName.Contains("BlackListed...
@Geoff has the best option, justing Dynamic LINQ. If you want to go the way of building queries at runtime using Lambda though I'd recomment that you use the PredicateBuilder (<http://www.albahari.com/nutshell/predicatebuilder.aspx>) and have something such as this: ``` Expression<Fun<T,bool>> pred = null; //delcare ...
234,458
<p>I recently stumbled across <a href="http://googletesting.blogspot.com/2008/08/by-miko-hevery-so-you-decided-to.html" rel="noreferrer">this entry in the google testing blog</a> about guidelines for writing more testable code. I was in agreement with the author until this point:</p> <blockquote> <p>Favor polymorph...
[ { "answer_id": 234491, "author": "Martin York", "author_id": 14065, "author_profile": "https://Stackoverflow.com/users/14065", "pm_score": 7, "selected": true, "text": "<p>Actually this makes testing and code easier to write.</p>\n\n<p>If you have one switch statement based on an interna...
2008/10/24
[ "https://Stackoverflow.com/questions/234458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14302/" ]
I recently stumbled across [this entry in the google testing blog](http://googletesting.blogspot.com/2008/08/by-miko-hevery-so-you-decided-to.html) about guidelines for writing more testable code. I was in agreement with the author until this point: > > Favor polymorphism over conditionals: If you see a switch statem...
Actually this makes testing and code easier to write. If you have one switch statement based on an internal field you probably have the same switch in multiple places doing slightly different things. This causes problems when you add a new case as you have to update all the switch statements (if you can find them). B...
234,479
<p>I'm writing a config file and I need to define if the process expects a windows format file or a unix format file. I've got a copy of the expected file - is there a way I can check if it uses \n or \r\n without exiting emacs?</p>
[ { "answer_id": 234495, "author": "Chris", "author_id": 15578, "author_profile": "https://Stackoverflow.com/users/15578", "pm_score": 0, "selected": false, "text": "<p>Open the file in emacs using find-file-literally. If lines have ^M symbols at the end, it expects a windows format text ...
2008/10/24
[ "https://Stackoverflow.com/questions/234479", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26880/" ]
I'm writing a config file and I need to define if the process expects a windows format file or a unix format file. I've got a copy of the expected file - is there a way I can check if it uses \n or \r\n without exiting emacs?
If it says (DOS) on the modeline when you open the file on Unix, the line endings are Windows-style. If it says (Unix) when you open the file on Windows, the line endings are Unix-style. From the Emacs 22.2 manual (Node: Mode Line): > > If the buffer's file uses > carriage-return linefeed, the colon > changes to e...
234,482
<p>I have a collection of elements that I need to operate over, calling member functions on the collection:</p> <pre><code>std::vector&lt;MyType&gt; v; ... // vector is populated </code></pre> <p>For calling functions with no arguments it's pretty straight-forward:</p> <pre><code>std::for_each(v.begin(), v.end(), st...
[ { "answer_id": 234525, "author": "Marcin", "author_id": 22724, "author_profile": "https://Stackoverflow.com/users/22724", "pm_score": 3, "selected": false, "text": "<p>Is it ok to change the vector? You may want to look at the partition algorithm.\n<br>\n<a href=\"http://www.cplusplus.co...
2008/10/24
[ "https://Stackoverflow.com/questions/234482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24263/" ]
I have a collection of elements that I need to operate over, calling member functions on the collection: ``` std::vector<MyType> v; ... // vector is populated ``` For calling functions with no arguments it's pretty straight-forward: ``` std::for_each(v.begin(), v.end(), std::mem_fun(&MyType::myfunc)); ``` A simil...
Boost Lambda makes this easy. ``` #include <boost/lambda/lambda.hpp> #include <boost/lambda/bind.hpp> #include <boost/lambda/if.hpp> std::for_each( v.begin(), v.end(), if_( MyPred() )[ std::mem_fun(&MyType::myfunc) ] ); ``` You could even do away with defining MyPred(), if it is simple...
234,507
<p>This was something originally discussed during a presentation given by Charles Brian Quinn of the <a href="http://www.bignerdranch.com/" rel="noreferrer">Big Nerd Ranch</a> at <a href="http://www.actsasconference.com" rel="noreferrer">acts_as_conference</a>. He was discussing what he had learned from instructing a ...
[ { "answer_id": 234529, "author": "Niniki", "author_id": 4155, "author_profile": "https://Stackoverflow.com/users/4155", "pm_score": 4, "selected": false, "text": "<p>I can see the point when talking to non programmers, but when you're at a whiteboard discussing a problem with some team m...
2008/10/24
[ "https://Stackoverflow.com/questions/234507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23909/" ]
This was something originally discussed during a presentation given by Charles Brian Quinn of the [Big Nerd Ranch](http://www.bignerdranch.com/) at [acts\_as\_conference](http://www.actsasconference.com). He was discussing what he had learned from instructing a Ruby on Rails Bootcamp to many people both new to programm...
It strictly depends on what are you trying to teach. Sometimes, when showing a programming example, you have to declare a few things just for the snippet to be "complete", and those few things are not the core of what you are showing. For example, if you want to show how to throw an exception, I believe it is ok to p...
234,512
<p>I have a string which is like this:</p> <p>this is [bracket test] "and quotes test "</p> <p>I'm trying to write something in Python to split it up by space while ignoring spaces within square braces and quotes. The result I'm looking for is:</p> <p>['this','is','bracket test','and quotes test '] </p>
[ { "answer_id": 234645, "author": "Bryan Oakley", "author_id": 7432, "author_profile": "https://Stackoverflow.com/users/7432", "pm_score": 3, "selected": false, "text": "<p>Here's a simplistic solution that works with your test input:</p>\n\n<pre><code>import re\nre.findall('\\[[^\\]]*\\]...
2008/10/24
[ "https://Stackoverflow.com/questions/234512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31256/" ]
I have a string which is like this: this is [bracket test] "and quotes test " I'm trying to write something in Python to split it up by space while ignoring spaces within square braces and quotes. The result I'm looking for is: ['this','is','bracket test','and quotes test ']
Here's a simplistic solution that works with your test input: ``` import re re.findall('\[[^\]]*\]|\"[^\"]*\"|\S+',s) ``` This will return any code that matches either * a open bracket followed by zero or more non-close-bracket characters followed by a close bracket, * a double-quote followed by zero or more non-q...