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
526,761
<p>I am having a qt question. I want the QLineEdit widget to have the focus at application startup. Take the following code for example:</p> <pre><code>#include &lt;QtGui/QApplication&gt; #include &lt;QtGui/QHBoxLayout&gt; #include &lt;QtGui/QPushButton&gt; #include &lt;QtGui/QLineEdit&gt; #include &lt;QtGui/QFont&gt;...
[ { "answer_id": 526790, "author": "milot", "author_id": 22637, "author_profile": "https://Stackoverflow.com/users/22637", "pm_score": 1, "selected": false, "text": "<p>In Qt setFocus() is a slot, you can try other overloaded method which takes a Qt::FocusReason parameter like the line sho...
2009/02/09
[ "https://Stackoverflow.com/questions/526761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49032/" ]
I am having a qt question. I want the QLineEdit widget to have the focus at application startup. Take the following code for example: ``` #include <QtGui/QApplication> #include <QtGui/QHBoxLayout> #include <QtGui/QPushButton> #include <QtGui/QLineEdit> #include <QtGui/QFont> int main(int argc, char *argv[]) { ...
[Keyboard focus](https://doc.qt.io/qt-5/focus.html) is related to widget [tab order](https://doc.qt.io/qt-5/qwidget.html#setTabOrder), and the default tab order *is based on the order in which widgets are constructed*. Therefore, creating more widgets changes the keyboard focus. That is why you must make the [`QWidget:...
526,762
<p>I'm wondering about the table structure for a threaded messaging system.</p> <p>I'm thinking there will be 3 tables:</p> <pre><code>- message_thread - id - subject - message_user - thread_id - user_id - thread_status (unread, read, trash, deleted) - message - date (date sent) - sent_use...
[ { "answer_id": 526765, "author": "womble", "author_id": 60003, "author_profile": "https://Stackoverflow.com/users/60003", "pm_score": 2, "selected": false, "text": "<p>Try one table:</p>\n\n<pre><code>messages\n id (INT)\n user_id (INT, ref to users table)\n subject (CHAR)\n parent_i...
2009/02/09
[ "https://Stackoverflow.com/questions/526762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5441/" ]
I'm wondering about the table structure for a threaded messaging system. I'm thinking there will be 3 tables: ``` - message_thread - id - subject - message_user - thread_id - user_id - thread_status (unread, read, trash, deleted) - message - date (date sent) - sent_user_id - message `...
Try one table: ``` messages id (INT) user_id (INT, ref to users table) subject (CHAR) parent_id (INT, ref to messages table, NULL if head of thread) content (TEXT), (other per-message attributes) ``` Allows threading, as well as for each message to have it's own subject. To add read status, add a many-t...
526,782
<p>I have a long running BASH script that I am running under CYGWIN on Windows.</p> <p>I would like to limit the script to run for 30 seconds, and automatically terminate if it exceeds this limit. Ideally, I'd like to be able to do this to any command.</p> <p>For example:</p> <pre><code>sh-3.2$ limittime -t 30 'mysc...
[ { "answer_id": 526785, "author": "Jason Cohen", "author_id": 4926, "author_profile": "https://Stackoverflow.com/users/4926", "pm_score": 2, "selected": false, "text": "<p>You could run the command as a background job (i.e. with \"&amp;\"), use the bash variable for \"pid of last command ...
2009/02/09
[ "https://Stackoverflow.com/questions/526782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/814/" ]
I have a long running BASH script that I am running under CYGWIN on Windows. I would like to limit the script to run for 30 seconds, and automatically terminate if it exceeds this limit. Ideally, I'd like to be able to do this to any command. For example: ``` sh-3.2$ limittime -t 30 'myscript.sh' ``` or ``` sh-3...
See the <http://www.pixelbeat.org/scripts/timeout> script the functionality of which has been integrated into newer coreutils: ``` #!/bin/sh # Execute a command with a timeout # License: LGPLv2 # Author: # http://www.pixelbeat.org/ # Notes: # Note there is a timeout command packaged with coreutils since v7.0 #...
526,795
<p>I'm trying to add custom fields to an InlineFormset using the following code, but the fields won't show up in the Django Admin. Is the InlineFormset too locked down to allow this? My print "ding" test fires as expected, I can print out the form.fields and see them all there, but the actual fields are never rendere...
[ { "answer_id": 527903, "author": "David Arcos", "author_id": 30300, "author_profile": "https://Stackoverflow.com/users/30300", "pm_score": 1, "selected": true, "text": "<pre><code>model = models.Progress\n</code></pre>\n\n<p>In the admin there will be only the fields defined in this <em>...
2009/02/09
[ "https://Stackoverflow.com/questions/526795", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46914/" ]
I'm trying to add custom fields to an InlineFormset using the following code, but the fields won't show up in the Django Admin. Is the InlineFormset too locked down to allow this? My print "ding" test fires as expected, I can print out the form.fields and see them all there, but the actual fields are never rendered in ...
``` model = models.Progress ``` In the admin there will be only the fields defined in this *Progress* model. You have no fields/fieldsets option overwriting it. If you want to add the new ones, there are two options: * In the model definition, add those new additional fields (make them optional!) * In the admin mod...
526,817
<p>I was having some problems with my first C++ program (this one) awhile ago. Basically I am trying to do an assignment for intro to C++ class where the professor has taught us no syntax. Here is my code right now:</p> <pre><code>#include &lt;cstdlib&gt; #include &lt;ctime&gt; #include &lt;iostream&gt; #include &lt;s...
[ { "answer_id": 526821, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 2, "selected": false, "text": "<p>I think you should be using <code>gcc -o ...</code>, not <code>gcc o- ...</code>.</p>\n\n<p>And, secondly, you can't ...
2009/02/09
[ "https://Stackoverflow.com/questions/526817", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I was having some problems with my first C++ program (this one) awhile ago. Basically I am trying to do an assignment for intro to C++ class where the professor has taught us no syntax. Here is my code right now: ``` #include <cstdlib> #include <ctime> #include <iostream> #include <string> using namespace std; class ...
You cannot have [functions inside your functions](http://i35.tinypic.com/2l8fbwl.jpg)\*. You probably want this: ``` #include <cstdlib> #include <ctime> #include <iostream> #include <string> using namespace std; class Race { public: int randomMove() { srand(time(NULL)); int randomIn...
526,832
<p>This is probably an easy question, but I want to understand better how Apache works with virtual hosts. I am setting up virtual hosts because I work on multiple websites at once and I don't want to use subdirectories. I was pretty much using the default Apache httpd.conf file with the DocumentRoot pointing to some...
[ { "answer_id": 526840, "author": "Joe", "author_id": 57135, "author_profile": "https://Stackoverflow.com/users/57135", "pm_score": 5, "selected": true, "text": "<p><a href=\"http://httpd.apache.org/docs/1.3/vhosts/name-based.html\" rel=\"noreferrer\">http://httpd.apache.org/docs/1.3/vhos...
2009/02/09
[ "https://Stackoverflow.com/questions/526832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2484/" ]
This is probably an easy question, but I want to understand better how Apache works with virtual hosts. I am setting up virtual hosts because I work on multiple websites at once and I don't want to use subdirectories. I was pretty much using the default Apache httpd.conf file with the DocumentRoot pointing to something...
<http://httpd.apache.org/docs/1.3/vhosts/name-based.html> (Should be true for 2.x also) "If no matching virtual host is found, then the first listed virtual host that matches the IP address will be used. As a consequence, the first listed virtual host is the default virtual host. The DocumentRoot from the main serve...
526,836
<p>I have 12 columns separated by a tab. How can I join them side-by-side?</p> <p><strong>[Added]</strong> You can also tell me other methods as AWK: the faster the better. </p>
[ { "answer_id": 526839, "author": "Martin Beckett", "author_id": 10897, "author_profile": "https://Stackoverflow.com/users/10897", "pm_score": 2, "selected": false, "text": "<p>If you are just using awk to concatenate the columns I would use 'tr' and delete tab</p>\n\n<pre><code>cat file1...
2009/02/09
[ "https://Stackoverflow.com/questions/526836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54964/" ]
I have 12 columns separated by a tab. How can I join them side-by-side? **[Added]** You can also tell me other methods as AWK: the faster the better.
Since you asked specifically about awk (there are tools better suited to the job), the following is a first-cut solution: ``` awk '{print $1$2$3$4$5$6$7$8$9$10$11$12}' ``` A more complicated and configurable solution, where you could change the number of columns used for output, would be: ``` awk -v lim=12 '{for(x=...
526,858
<p>When I'm opening a new file in Vim and I use tab completion, it completes the whole file name instead of doing the partial match like Bash does. Is there an option to make this file name tab completion work more like Bash?</p>
[ { "answer_id": 526881, "author": "Mike", "author_id": 62248, "author_profile": "https://Stackoverflow.com/users/62248", "pm_score": 3, "selected": false, "text": "<p>I'm assuming that you are using autocomplete in Vim via <kbd>Ctrl</kbd> + <kbd>N</kbd> to search through the current buffe...
2009/02/09
[ "https://Stackoverflow.com/questions/526858", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58089/" ]
When I'm opening a new file in Vim and I use tab completion, it completes the whole file name instead of doing the partial match like Bash does. Is there an option to make this file name tab completion work more like Bash?
I personally use ``` set wildmode=longest,list,full set wildmenu ``` When you type the first tab hit, it will complete as much as possible. The second tab hit will provide a list. The third and subsequent tabs will cycle through completion options so you can complete the file without further keys. Bash-like would b...
526,863
<p>If I put this tag in my HTML:</p> <pre><code>&lt;img src="http://server/imageHandler.php?image=someImage.jpg" /&gt; </code></pre> <p>instead of </p> <pre><code>&lt;img src="http://server/images/someImage.jpg" /&gt; </code></pre> <p>and use the imageHandler.php script to read the image file, output expire headers...
[ { "answer_id": 526874, "author": "David Z", "author_id": 56541, "author_profile": "https://Stackoverflow.com/users/56541", "pm_score": 2, "selected": false, "text": "<p>Try something like</p>\n\n<pre><code>header(\"Expires: &lt;the date&gt;\");\nhttp_send_file(\"someImage.jpg\");\n</code...
2009/02/09
[ "https://Stackoverflow.com/questions/526863", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36047/" ]
If I put this tag in my HTML: ``` <img src="http://server/imageHandler.php?image=someImage.jpg" /> ``` instead of ``` <img src="http://server/images/someImage.jpg" /> ``` and use the imageHandler.php script to read the image file, output expire headers and print the image data, i expect it to be slower. Is this ...
Yes, running any PHP script is slower than serving a static file. Instead, you can set expire headers using Apache configuration directives. See the documentation for [`mod_expires`](http://httpd.apache.org/docs/2.2/mod/mod_expires.html). For example, you can put the following directives in an Apache httpd.conf or .ht...
526,866
<p>Since I don't own a G1 for development purposes, I am doing my best with the emulator. This said, I am trying to scan a JPEG image or a PNG image in my sdCard, with the ZXing (Zebra Zrossing) library.</p> <p>I tried to change the code in the Android project, so it would scan from an image in the sdCard, instead fro...
[ { "answer_id": 528141, "author": "Sean Owen", "author_id": 64174, "author_profile": "https://Stackoverflow.com/users/64174", "pm_score": 0, "selected": false, "text": "<p>This is Sean from the project in question.</p>\n\n<p>You are trying to use the code intended for Java SE in Android. ...
2009/02/09
[ "https://Stackoverflow.com/questions/526866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Since I don't own a G1 for development purposes, I am doing my best with the emulator. This said, I am trying to scan a JPEG image or a PNG image in my sdCard, with the ZXing (Zebra Zrossing) library. I tried to change the code in the Android project, so it would scan from an image in the sdCard, instead from the came...
Hai, I tried to extract the data from the Barcodes and these are the steps i followed. 1.Download ZXing 1.3 and extract it. 2.Add the core/src and androidtest/src from the extracted zxing floder to the android application by setting the property. use this link to set the property,<http://groups.google.com/group/zxi...
526,887
<p>I am using TouchXml because of the given limitations of NSXML on the actual iPhone. Anyway, I'm just starting out with Objective-C, I come from a C# background, and felt like learning something new..anyhow.. here is my xml file...</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;FundInfo xmlns:xsi="h...
[ { "answer_id": 526914, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": -1, "selected": false, "text": "<p>Try</p>\n\n<pre><code>NSArray *nodes = [myParser nodesForXPath:@\"/FundInfo/*\" error:&amp;err];\n</code></pre>\...
2009/02/09
[ "https://Stackoverflow.com/questions/526887", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7280/" ]
I am using TouchXml because of the given limitations of NSXML on the actual iPhone. Anyway, I'm just starting out with Objective-C, I come from a C# background, and felt like learning something new..anyhow.. here is my xml file... ``` <?xml version="1.0" encoding="utf-8"?> <FundInfo xmlns:xsi="http://www.w3.org/2001/X...
The problem is that your XML has a namespace, which means your XPath does not actually match. Unfortunately there is no default mapping, and XPath does not actually define a good way to handle this internally, so you can't fix it simply by changing the XPath. Instead you need to inform the interpreter how you want to m...
526,895
<p>What is the best way to catch a &lt; select > change event? I have a form that has different input elements but I want to trigger an event only in the case of a &lt; select > change. I don't want to use the ID since there are a lot of selects on the form.</p> <p>Many thanks in advance!</p>
[ { "answer_id": 526901, "author": "Sebastian", "author_id": 29909, "author_profile": "https://Stackoverflow.com/users/29909", "pm_score": 2, "selected": false, "text": "<p>For a select like this:</p>\n\n<pre><code>&lt;select id=\"item_select\" name=\"item\"&gt; \n &lt;option&gt;Select ...
2009/02/09
[ "https://Stackoverflow.com/questions/526895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63938/" ]
What is the best way to catch a < select > change event? I have a form that has different input elements but I want to trigger an event only in the case of a < select > change. I don't want to use the ID since there are a lot of selects on the form. Many thanks in advance!
If you want only *some* selects in the page to have the change event, you can add a class to them, like so: ``` <select class='choose_me'>...</select> <!-- later on in the page... --> <select class='choose_me'>...</select> ``` And then you can catch the change event from any of these by doing something like: ``` ...
526,898
<p>HI all.</p> <p>I am working on some code to send/receive SMS messages through Zeep Mobile (<a href="http://zeepmobile.com/developers/" rel="nofollow noreferrer">http://zeepmobile.com/developers/</a>). </p> <p>I have looked at their google groups and even contacted their support but they've not been very good at co...
[ { "answer_id": 527342, "author": "peSHIr", "author_id": 50846, "author_profile": "https://Stackoverflow.com/users/50846", "pm_score": 2, "selected": false, "text": "<p>Are you sure that you need to manually implement the HTTP protocol in code using a <code>TcpClient</code> and an <code>S...
2009/02/09
[ "https://Stackoverflow.com/questions/526898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64015/" ]
HI all. I am working on some code to send/receive SMS messages through Zeep Mobile (<http://zeepmobile.com/developers/>). I have looked at their google groups and even contacted their support but they've not been very good at communicating back and I am really flying blind now. I have to get integrated with them (w...
SOLUTION: --------- OK. I worked on it all last night and I made some progress. I used Fiddler to construct the POST message to see any discrepancies between what I had above and what the server expected. I have got it sending the message and returning a HTTP 200 OK response. Again, this code is not production ready,...
526,918
<p>When displaying my DateTime values, I want them to be formatted like so: "February 9, 2009 7:00 AM"</p> <p>I am using the following code, but am concerned that the date may display incorrectly in other cultures. Can anyone tell me if this is the case or not, and if it is how can I fix it?</p> <pre><code>Date.ToStr...
[ { "answer_id": 526956, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "<p>Why not simply use the user's long date/time format(s)?</p>\n" }, { "answer_id": 526957, "author": "Av...
2009/02/09
[ "https://Stackoverflow.com/questions/526918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56864/" ]
When displaying my DateTime values, I want them to be formatted like so: "February 9, 2009 7:00 AM" I am using the following code, but am concerned that the date may display incorrectly in other cultures. Can anyone tell me if this is the case or not, and if it is how can I fix it? ``` Date.ToString("MMMM dd, yyyy hh...
> > I am using the following code, but am concerned that the date may display incorrectly in other cultures. > > > What exactly is ‘correct’? Are you a normal client-side app? If so, you'll get localised month names. Is that ‘incorrect’? Depends what you're looking for. If you *do* want locale-friendly times in a...
526,930
<p>Is there an "official" naming / casing convention for F#?</p> <p>I'm always in doubt of using C# style or not: </p> <pre><code>Class.MyFunctionName or Module.my_function_name </code></pre> <p>In F# you're meant to mix BCL classes and F# library ones: they have different casing and the code looks very ugly.</p>
[ { "answer_id": 526947, "author": "masfenix", "author_id": 50312, "author_profile": "https://Stackoverflow.com/users/50312", "pm_score": 1, "selected": false, "text": "<p>From what I've seen from hubfs.com and other sources, its a mix from .net and OCaml. </p>\n\n<p>I hope they switch to ...
2009/02/09
[ "https://Stackoverflow.com/questions/526930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2250286/" ]
Is there an "official" naming / casing convention for F#? I'm always in doubt of using C# style or not: ``` Class.MyFunctionName or Module.my_function_name ``` In F# you're meant to mix BCL classes and F# library ones: they have different casing and the code looks very ugly.
Yes, there is confusion, because F# has morphed from OCaml to .Net over the years. Basically, the naming conventions are a "breaking change" - old code is inconsistent with new code. However, the May 2009 CTP has settled the issue. The [Release Notes](http://blogs.msdn.com/dsyme/archive/2009/05/20/detailed-release-no...
526,946
<p>I have a page layout, PeopleSearchResults.aspx programmed by someone else. It contains the following tag for a <a href="http://msdn.microsoft.com/en-us/library/microsoft.office.server.search.webcontrols.refinesearchresults.aspx" rel="nofollow noreferrer">SharePoint refine people search results control</a>.</p> <pre...
[ { "answer_id": 527348, "author": "AboutDev", "author_id": 64015, "author_profile": "https://Stackoverflow.com/users/64015", "pm_score": 2, "selected": false, "text": "<blockquote>\n <p>Where are SharePoint resources strings\n located.</p>\n</blockquote>\n\n<p>The provisioning resources...
2009/02/09
[ "https://Stackoverflow.com/questions/526946", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13813/" ]
I have a page layout, PeopleSearchResults.aspx programmed by someone else. It contains the following tag for a [SharePoint refine people search results control](http://msdn.microsoft.com/en-us/library/microsoft.office.server.search.webcontrols.refinesearchresults.aspx). ``` Title="<%$Resources:sps,RefineByTitle%>" ``...
The particular file you specified, sps.resx is actually in 12\CONFIG\Resources (but there's a bunch of others in 12\Resources).
526,961
<p>Lets say I have a string "COLIN". </p> <p>The numeric value of this string would is worth:</p> <blockquote> <p>3 + 15 + 12 + 9 + 14 = 53. </p> </blockquote> <p>So</p> <blockquote> <p>A = 1, B = 2, C = 3, and so on. </p> </blockquote> <p>I have no idea how to even start in F# for this.</p> <pre><code>let mu...
[ { "answer_id": 526974, "author": "masfenix", "author_id": 50312, "author_profile": "https://Stackoverflow.com/users/50312", "pm_score": 1, "selected": false, "text": "<p>I've found a hackish way to do this using the ascii value of the character, and getting the number from there but i th...
2009/02/09
[ "https://Stackoverflow.com/questions/526961", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50312/" ]
Lets say I have a string "COLIN". The numeric value of this string would is worth: > > 3 + 15 + 12 + 9 + 14 = 53. > > > So > > A = 1, B = 2, C = 3, and so on. > > > I have no idea how to even start in F# for this. ``` let mutable nametotal = 0 let rec tcalculate name = name.ToString().ToCharArray()...
If the 'mapping' is more arbitrary, you could use a strategy like the code below, where you can specify a data structure of what value each letter maps to. ``` #light let table = [ 'C', 3 'O', 15 'L', 12 'I', 9 'N', 14 ] let dictionary = dict table let Value c = match dictionary.TryGetV...
526,973
<p>I have a web service running in IIS 6.0 on Windows 2003. It's authentication mode is Integrated Windows security (anonymous disabled), and authorization is done with Authorization Manager and an XML authorization store. My test user is a domain user (admin, actually) with membership in an authorized role.</p> <p>I ...
[ { "answer_id": 526974, "author": "masfenix", "author_id": 50312, "author_profile": "https://Stackoverflow.com/users/50312", "pm_score": 1, "selected": false, "text": "<p>I've found a hackish way to do this using the ascii value of the character, and getting the number from there but i th...
2009/02/09
[ "https://Stackoverflow.com/questions/526973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32050/" ]
I have a web service running in IIS 6.0 on Windows 2003. It's authentication mode is Integrated Windows security (anonymous disabled), and authorization is done with Authorization Manager and an XML authorization store. My test user is a domain user (admin, actually) with membership in an authorized role. I am testing...
If the 'mapping' is more arbitrary, you could use a strategy like the code below, where you can specify a data structure of what value each letter maps to. ``` #light let table = [ 'C', 3 'O', 15 'L', 12 'I', 9 'N', 14 ] let dictionary = dict table let Value c = match dictionary.TryGetV...
526,991
<p>The method <b>Concat()</b> does not modify the original value. It returns a new value.<br> like this:</p> <pre><code>String str = "good"; str.concat("ness"); System.out.println(str); //"good" </code></pre> <p>But some method modify the original value. Why?</p> <p>In Groovy:<br></p> <pre><code>def languages = [...
[ { "answer_id": 526993, "author": "coobird", "author_id": 17172, "author_profile": "https://Stackoverflow.com/users/17172", "pm_score": 5, "selected": true, "text": "<p><strong><a href=\"http://java.sun.com/javase/6/docs/api/java/lang/String.html\" rel=\"noreferrer\"><code>String</code></...
2009/02/09
[ "https://Stackoverflow.com/questions/526991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10927/" ]
The method **Concat()** does not modify the original value. It returns a new value. like this: ``` String str = "good"; str.concat("ness"); System.out.println(str); //"good" ``` But some method modify the original value. Why? In Groovy: ``` def languages = ["Java", "Groovy", "JRuby"] languages.reverse() ===...
**[`String`](http://java.sun.com/javase/6/docs/api/java/lang/String.html) is immutable in Java.** Any method that "modifies" a `String` must return a new instance of `String`. From the [Java API Specifications for the `String` class](http://java.sun.com/javase/6/docs/api/java/lang/String.html): > > Strings are const...
527,008
<p>I'm trying to extract the domain name from a string in C#. You don't necessarily have to use a RegEx but we should be able to extract <code>yourdomain.com</code> from all of the following:</p> <pre><code>yourdomain.com www.yourdomain.com http://www.yourdomain.com http://www.yourdomain.com/ store.yourdomain.com http...
[ { "answer_id": 527015, "author": "rid00z", "author_id": 64027, "author_profile": "https://Stackoverflow.com/users/64027", "pm_score": 0, "selected": false, "text": "<p>I would recommend trying this yourself. Using regulator and a regex cheat sheet. </p>\n\n<p><a href=\"http://sourceforge...
2009/02/09
[ "https://Stackoverflow.com/questions/527008", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34133/" ]
I'm trying to extract the domain name from a string in C#. You don't necessarily have to use a RegEx but we should be able to extract `yourdomain.com` from all of the following: ``` yourdomain.com www.yourdomain.com http://www.yourdomain.com http://www.yourdomain.com/ store.yourdomain.com http://store.yourdomain.com w...
1. If no scheme present (no colon in string), prepend "http://" to make it a valid URL. 2. Pass string to [Uri constructor](http://msdn.microsoft.com/en-us/library/z6c2z492.aspx). 3. Access the Uri's [Host property](http://msdn.microsoft.com/en-us/library/system.uri.host.aspx). Now you have the hostname. What exactly ...
527,028
<p>I want to update a cell in a spreadsheet that is used by a chart, using the Open XML SDK 2.0 (CTP). All the code samples I have found insert new cells. I am struggling with retrieving the right worksheet.</p> <pre><code>public static void InsertText(string docName, string text, uint rowIndex, string columnName) ...
[ { "answer_id": 528743, "author": "cdonner", "author_id": 58880, "author_profile": "https://Stackoverflow.com/users/58880", "pm_score": 7, "selected": true, "text": "<p>Here is the working code. This is a prototype. For a larger number of changes, one might open the document only once. Al...
2009/02/09
[ "https://Stackoverflow.com/questions/527028", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58880/" ]
I want to update a cell in a spreadsheet that is used by a chart, using the Open XML SDK 2.0 (CTP). All the code samples I have found insert new cells. I am struggling with retrieving the right worksheet. ``` public static void InsertText(string docName, string text, uint rowIndex, string columnName) { // Open th...
Here is the working code. This is a prototype. For a larger number of changes, one might open the document only once. Also, there are some hard-coded things like sheet name and cell type that would have to be parameterized before this can be called production-ready. <http://openxmldeveloper.org/forums/4005/ShowThread.a...
527,037
<p>While attempting to get an old svn dump of a project under git control, I ran into an interesting problem. Whenever I run <code>git svn</code>, I get an error saying it isn't a git command, yet there is documentation for it that I can pull up using <code>git help</code>. Is there something wrong with my install, o...
[ { "answer_id": 527047, "author": "jfsantos", "author_id": 62695, "author_profile": "https://Stackoverflow.com/users/62695", "pm_score": 3, "selected": false, "text": "<p>Under my system I've had this trouble:</p>\n\n<pre><code>$ git svn\nCan't locate SVN/Core.pm in @INC (@INC contains: /...
2009/02/09
[ "https://Stackoverflow.com/questions/527037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1256/" ]
While attempting to get an old svn dump of a project under git control, I ran into an interesting problem. Whenever I run `git svn`, I get an error saying it isn't a git command, yet there is documentation for it that I can pull up using `git help`. Is there something wrong with my install, or am I just missing somethi...
I am not sure that [git svn has ever worked](http://osdir.com/ml/version-control.msysgit/2008-01/msg00225.html) with recent Git Windows distribution (post 1.5.6). Many problems [have been reported](http://article.gmane.org/gmane.comp.version-control.msysgit/2433) before, so `git svn` may very much be not included in c...
527,065
<p>This is a specific variation on the "can't connect" problem. In my case, I've just set up two virtual hosts in my httpd.conf listening on port 80. The declaration looks like:</p> <pre> NameVirtualHost *:80 &lt;VirtualHost *:80&gt; ServerName site1.dev DocumentRoot /www/site1 &lt;/VirtualHost> &lt;Virtua...
[ { "answer_id": 527066, "author": "rz.", "author_id": 7407, "author_profile": "https://Stackoverflow.com/users/7407", "pm_score": 0, "selected": false, "text": "<p>Did you edit your /etc/hosts file as part of setting up your virtual hosts? You might've removed the \"localhost\" entry on a...
2009/02/09
[ "https://Stackoverflow.com/questions/527065", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2484/" ]
This is a specific variation on the "can't connect" problem. In my case, I've just set up two virtual hosts in my httpd.conf listening on port 80. The declaration looks like: ``` NameVirtualHost *:80 <VirtualHost *:80> ServerName site1.dev DocumentRoot /www/site1 </VirtualHost> <VirtualHost *:80> Server...
A likely suspect is your MySQL access control configuration. yourhost.foo and localhost are completely different, as far as it's concerned, and that's always biting people. If MySQL user table entries exist for WP with the host keyed to `yourhost.foo` but not `localhost`, then that's the problem.
527,088
<p>I'm looking at this .js file and the jquery looks like:</p> <pre><code>$.fn.redirect $.redirect $.request </code></pre> <p>or</p> <pre><code>(function($){$.log=function(message){if(window.console){if(window.console.debug) window.console.debug(message);else if(window.console.log) window.console.log(message);} else...
[ { "answer_id": 527124, "author": "Darko", "author_id": 32943, "author_profile": "https://Stackoverflow.com/users/32943", "pm_score": 0, "selected": false, "text": "<p><code>(function(){ /* your code here */ })();</code> is a self executing function and a closure. It is used to encapsulat...
2009/02/09
[ "https://Stackoverflow.com/questions/527088", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm looking at this .js file and the jquery looks like: ``` $.fn.redirect $.redirect $.request ``` or ``` (function($){$.log=function(message){if(window.console){if(window.console.debug) window.console.debug(message);else if(window.console.log) window.console.log(message);} else alert(message);}; ``` Are these bu...
``` (function($){ // code })(jQuery); ``` is an idiom commonly used so that the $ alias can be used in a localized manner without affecting the rest of the page where other libraries such as Prototype (with its own $) could have been possibly used. [jQuery in Action](http://www.manning.com/bibeault/) explains t...
527,089
<p>YUI has a nice way of creating a namespace for your methods etc. in javascript.</p> <p>Does jQuery have anything similiar?</p>
[ { "answer_id": 527095, "author": "lpfavreau", "author_id": 35935, "author_profile": "https://Stackoverflow.com/users/35935", "pm_score": 3, "selected": false, "text": "<p>jQuery has a bunch of plugins that extend the base functionality. There is <a href=\"http://plugins.jquery.com/projec...
2009/02/09
[ "https://Stackoverflow.com/questions/527089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
YUI has a nice way of creating a namespace for your methods etc. in javascript. Does jQuery have anything similiar?
[lpfavreau](https://stackoverflow.com/users/35935/lpfavreau) offers the solution to *extend* the jQuery object with your own methods (so that their functionality applies on the actual jQuery object context). If you're looking to just namespace your code you can use the dollar symbol like this: ``` $.myNamespace = { ...
527,100
<p>I've been working with the SpiderMonkey C API and would like to implement a closure in C using their API. The one I would like to implement is fairly complex, but I can't even figure out how to do a simple one such as:</p> <pre><code>function x() { var i = 0; return function() { i++; print(i); }; } var y = ...
[ { "answer_id": 527095, "author": "lpfavreau", "author_id": 35935, "author_profile": "https://Stackoverflow.com/users/35935", "pm_score": 3, "selected": false, "text": "<p>jQuery has a bunch of plugins that extend the base functionality. There is <a href=\"http://plugins.jquery.com/projec...
2009/02/09
[ "https://Stackoverflow.com/questions/527100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10093/" ]
I've been working with the SpiderMonkey C API and would like to implement a closure in C using their API. The one I would like to implement is fairly complex, but I can't even figure out how to do a simple one such as: ``` function x() { var i = 0; return function() { i++; print(i); }; } var y = x(); y(); //1 ...
[lpfavreau](https://stackoverflow.com/users/35935/lpfavreau) offers the solution to *extend* the jQuery object with your own methods (so that their functionality applies on the actual jQuery object context). If you're looking to just namespace your code you can use the dollar symbol like this: ``` $.myNamespace = { ...
527,122
<p>My DOM looks like this:</p> <pre><code>&lt;li id="li1"&gt; &lt;div class="c1"&gt;&lt;/div&gt; &lt;/li&gt; &lt;li id="li2"&gt; &lt;div class="c1"&gt;&lt;/div&gt; &lt;/li&gt; </code></pre> <p>Using jQuery, if the first <code>&lt;li&gt;</code> is clicked, I want the inner <code>&lt;div&gt;&lt;/div&g...
[ { "answer_id": 527126, "author": "patricksweeney", "author_id": 24875, "author_profile": "https://Stackoverflow.com/users/24875", "pm_score": 2, "selected": false, "text": "<p>You will run into problems when ID'ing 2 list items as the same ID. If you want the same CSS to apply to both, u...
2009/02/09
[ "https://Stackoverflow.com/questions/527122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
My DOM looks like this: ``` <li id="li1"> <div class="c1"></div> </li> <li id="li2"> <div class="c1"></div> </li> ``` Using jQuery, if the first `<li>` is clicked, I want the inner `<div></div>` to be hidden.
``` $("li:first").click(function() { $(this).children("div").hide(); }); ```
527,140
<p>I've been using Java POI for some time now, but have encountered a new problem, and I'm wondering if anyone has found a solution.</p> <p>When you read a spreadsheet, you need to know the type of cell in order to use the proper read method.</p> <p>So you get the cell type, then call the appropriate read method to g...
[ { "answer_id": 527159, "author": "Learning", "author_id": 18275, "author_profile": "https://Stackoverflow.com/users/18275", "pm_score": 2, "selected": false, "text": "<pre><code> FileInputStream fis = new FileInputStream(\"c:/temp/test.xls\");\n Workbook wb = new HSSFWorkbook(fis); //...
2009/02/09
[ "https://Stackoverflow.com/questions/527140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33977/" ]
I've been using Java POI for some time now, but have encountered a new problem, and I'm wondering if anyone has found a solution. When you read a spreadsheet, you need to know the type of cell in order to use the proper read method. So you get the cell type, then call the appropriate read method to get the cell's con...
``` FileInputStream fis = new FileInputStream("c:/temp/test.xls"); Workbook wb = new HSSFWorkbook(fis); //or new XSSFWorkbook("c:/temp/test.xls") Sheet sheet = wb.getSheetAt(0); FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator(); // suppose your formula is in B3 CellRefer...
527,166
<p>I have a vector of integers and I want to convert it to a vector of pairs (pair consists of a bool and a int). My current code is simple like this:</p> <pre><code> std::vector&lt;int&gt; a; std::vector&lt;std::pair&lt;bool,int&gt; &gt; b; a.push_back(1); a.push_back(2); a.push_back(3); for(...
[ { "answer_id": 527179, "author": "Evan Teran", "author_id": 13430, "author_profile": "https://Stackoverflow.com/users/13430", "pm_score": 6, "selected": true, "text": "<p><strong>1.</strong> You could make a functor and <code>std::for_each</code>:</p>\n<pre><code>struct F {\n F(std::v...
2009/02/09
[ "https://Stackoverflow.com/questions/527166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39742/" ]
I have a vector of integers and I want to convert it to a vector of pairs (pair consists of a bool and a int). My current code is simple like this: ``` std::vector<int> a; std::vector<std::pair<bool,int> > b; a.push_back(1); a.push_back(2); a.push_back(3); for(int i = 0; i < a.size(); ++i) ...
**1.** You could make a functor and `std::for_each`: ``` struct F { F(std::vector<std::pair<bool,int> > &b) : m_b(b){ } void operator()(int x) { m_b.push_back(std::make_pair(false, x)); } std::vector<std::pair<bool,int> > &m_b; }; std::for_each(a.begin(), a.end(), F(b)); ``` Though thi...
527,187
<p>Allow me to start with: I am a n00b on ASP.NET MVC. I love it, but I am a n00b.</p> <p>I am trying to pass "complex" data back from a LINQ query. I understand how to use the data context and then just cast that data when I send it back, but when I do a more complicated LINQ query which returns an anonymous type, ...
[ { "answer_id": 527190, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "<p>The best answer here simply <em>is</em> to create a new type. You can do get anonymous types back from <code>objec...
2009/02/09
[ "https://Stackoverflow.com/questions/527187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64052/" ]
Allow me to start with: I am a n00b on ASP.NET MVC. I love it, but I am a n00b. I am trying to pass "complex" data back from a LINQ query. I understand how to use the data context and then just cast that data when I send it back, but when I do a more complicated LINQ query which returns an anonymous type, things break...
`var` is a compiler shortcut for declaring a type in the current scope. It doesn't add any dynamic functionality to the .NET runtime, so code outside the scope sees the object as "System.Object", since that is the most-specific type in the inheritance chain the view code is aware of. You should create a real class if ...
527,197
<p>If this is my subprocess:</p> <pre><code>import time, sys for i in range(200): sys.stdout.write( 'reading %i\n'%i ) time.sleep(.02) </code></pre> <p>And this is the script controlling and modifying the output of the subprocess:</p> <pre><code>import subprocess, time, sys print 'starting' proc = subproc...
[ { "answer_id": 527202, "author": "Charles Duffy", "author_id": 14122, "author_profile": "https://Stackoverflow.com/users/14122", "pm_score": 3, "selected": false, "text": "<p>Process output is buffered. On more UNIXy operating systems (or Cygwin), the <A HREF=\"http://www.noah.org/wiki/P...
2009/02/09
[ "https://Stackoverflow.com/questions/527197", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31676/" ]
If this is my subprocess: ``` import time, sys for i in range(200): sys.stdout.write( 'reading %i\n'%i ) time.sleep(.02) ``` And this is the script controlling and modifying the output of the subprocess: ``` import subprocess, time, sys print 'starting' proc = subprocess.Popen( 'c:/test_apps/testcr.py...
As Charles already mentioned, the problem is buffering. I ran in to a similar problem when writing some modules for SNMPd, and solved it by replacing stdout with an auto-flushing version. I used the following code, inspired by some posts on ActiveState: ``` class FlushFile(object): """Write-only flushing wrapper ...
527,198
<p>Can anybody please explain how this could possibly happen?</p> <p>I am completely aware of programming with thread safety in mind and as you can see I am catering for UI updates via a form InvokeRequired check here, everything has been working fine and no changes to break this that I am aware, and now suddenly just...
[ { "answer_id": 527208, "author": "bleevo", "author_id": 45909, "author_profile": "https://Stackoverflow.com/users/45909", "pm_score": -1, "selected": false, "text": "<p>Use </p>\n\n<pre><code>if (InvokeRequired)\n{\n //invoke\n}\nelse\n{\n //do\n}\n</code></pre>\n" }, { "answer...
2009/02/09
[ "https://Stackoverflow.com/questions/527198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41211/" ]
Can anybody please explain how this could possibly happen? I am completely aware of programming with thread safety in mind and as you can see I am catering for UI updates via a form InvokeRequired check here, everything has been working fine and no changes to break this that I am aware, and now suddenly just as I'm pr...
I suspect InvokedRevoked might be lying to you. A WinForm Control defers creation of the Control's underlying Win32 HWND until a method call actually needs it. InvokeRequired will return false if the HWND has not been created yet. For a detailed explanation, see: [**"Mysterious Hang or The Great Deception of InvokeReq...
527,214
<p>I have an excel document represented as a byte[] and I'm wanting to send it as an attachment in an email.</p> <p>I'm having a bit of trouble constructing the attachment.</p> <p>I can create an Attachment which has the following constructors:</p> <pre><code>(Stream contentStream, ContentType contentType) (Stream c...
[ { "answer_id": 527222, "author": "John Boker", "author_id": 2847, "author_profile": "https://Stackoverflow.com/users/2847", "pm_score": 0, "selected": false, "text": "<p>--------------- I guess im wrong, this is if you have a file you want to attach ---------------</p>\n\n<p>it looks lik...
2009/02/09
[ "https://Stackoverflow.com/questions/527214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39532/" ]
I have an excel document represented as a byte[] and I'm wanting to send it as an attachment in an email. I'm having a bit of trouble constructing the attachment. I can create an Attachment which has the following constructors: ``` (Stream contentStream, ContentType contentType) (Stream contentStream, string name) (...
The attachment constructor does indeed have a constructor that does what you need. I'm assuming you're using the System.Net.MailMessage class from .NET Framework 2. If so [read this link](http://www.systemnetmail.com/faq/3.4.2.aspx) for some sample code of what you need
527,215
<p>This is tricky for me.</p> <pre><code>const int * const buffer[] </code></pre> <p>Currently, I have it translated as follows:</p> <pre><code>byte[] buffer </code></pre> <p>Problem is that I'm getting AccessViolation exceptions, when DLL is calling function with that is using above parameter.</p> <p>Thanks for h...
[ { "answer_id": 527223, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 2, "selected": false, "text": "<p>With <strong>two</strong> <code>const</code>'s surely that should be indication enough that you're not allowed to cha...
2009/02/09
[ "https://Stackoverflow.com/questions/527215", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
This is tricky for me. ``` const int * const buffer[] ``` Currently, I have it translated as follows: ``` byte[] buffer ``` Problem is that I'm getting AccessViolation exceptions, when DLL is calling function with that is using above parameter. Thanks for help.
With **two** `const`'s surely that should be indication enough that you're not allowed to change it :-). But, seriously, one of those states that the pointer shouldn't change, the other states that the data pointed to by the pointer shouldn't change. That's why you're getting the access violation. What you'll need to...
527,216
<p>I try the following code to remove contact with a specified number:</p> <pre><code>private void removeContact(Context context, String phone) { //context.getContentResolver().delete(Contacts.Phones.CONTENT_URI, phone, null); context.getContentResolver().delete(Contacts.Phones.CONTENT_URI, Contacts....
[ { "answer_id": 527454, "author": "Reto Meier", "author_id": 822, "author_profile": "https://Stackoverflow.com/users/822", "pm_score": 3, "selected": false, "text": "<p>Do you have the appropriate permissions declared in your manifest? </p>\n\n<p>You'll need the <code>android.permission.R...
2009/02/09
[ "https://Stackoverflow.com/questions/527216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/60311/" ]
I try the following code to remove contact with a specified number: ``` private void removeContact(Context context, String phone) { //context.getContentResolver().delete(Contacts.Phones.CONTENT_URI, phone, null); context.getContentResolver().delete(Contacts.Phones.CONTENT_URI, Contacts.PhonesColumns....
To delete all contacts use the following code: ``` ContentResolver cr = getContentResolver(); Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); while (cur.moveToNext()) { try{ String lookupKey = cur.getString(cur.getColumnIndex(ContactsContrac...
527,218
<p>Under Windows Vista (2008 and Seven), an application cannot write in Program Files Folder. I understand that UAC is the responsible, but it prevents my application to self-update. Is there a folder somewhere (available in Windows XP, Vista (and all other version)) which would allow me to deploy my application and le...
[ { "answer_id": 527454, "author": "Reto Meier", "author_id": 822, "author_profile": "https://Stackoverflow.com/users/822", "pm_score": 3, "selected": false, "text": "<p>Do you have the appropriate permissions declared in your manifest? </p>\n\n<p>You'll need the <code>android.permission.R...
2009/02/09
[ "https://Stackoverflow.com/questions/527218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42024/" ]
Under Windows Vista (2008 and Seven), an application cannot write in Program Files Folder. I understand that UAC is the responsible, but it prevents my application to self-update. Is there a folder somewhere (available in Windows XP, Vista (and all other version)) which would allow me to deploy my application and let i...
To delete all contacts use the following code: ``` ContentResolver cr = getContentResolver(); Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); while (cur.moveToNext()) { try{ String lookupKey = cur.getString(cur.getColumnIndex(ContactsContrac...
527,230
<pre><code>&lt;root&gt; &lt;thing&gt; &lt;specs&gt; &lt;spec1 /&gt; &lt;spec3 /&gt; &lt;spec2 /&gt; &lt;/specs&gt; &lt;details /&gt; &lt;more_info&gt; &lt;info1 /&gt; &lt;info2 /&gt; &lt;/more_info&gt; &lt;/thing&gt; &lt;/root&gt; </code></pre> <p><br> okeee so i g...
[ { "answer_id": 527534, "author": "troelskn", "author_id": 18180, "author_profile": "https://Stackoverflow.com/users/18180", "pm_score": 0, "selected": false, "text": "<p>That's working <a href=\"http://www.php.net/manual/en/xmlreader.readinnerxml.php\" rel=\"nofollow noreferrer\">as adve...
2009/02/09
[ "https://Stackoverflow.com/questions/527230", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24744/" ]
``` <root> <thing> <specs> <spec1 /> <spec3 /> <spec2 /> </specs> <details /> <more_info> <info1 /> <info2 /> </more_info> </thing> </root> ``` okeee so i got this sample xml and the problem is i cant seem to get the values of the innerxml, when i use `$reader-...
It depends what you mean by "value". If you have something like ``` <spec3 />Value</spec3> ``` Then readInnerXML should be giving you your value. If your value is in an attribute, ``` <spec1 foo="my attribute" /> ``` You'll need to use the getAttribute method of the XMLReader object, or explicitly tell the re...
527,246
<p>How can I use jquery to remove a SPECIFIC div that has no children (at least no children that isn't whitespace). E.g.</p> <pre><code>&lt;div id="outer"&gt; some content &lt;div id="removeme"&gt; &lt;/div&gt; some more content &lt;/div&gt; </code></pre> <p>Want to completely remove the div with i...
[ { "answer_id": 527249, "author": "Samantha Branham", "author_id": 62590, "author_profile": "https://Stackoverflow.com/users/62590", "pm_score": 0, "selected": false, "text": "<p>I couldn't find a selector that ignores text nodes, so this is the quickest/dirtiest code snippet I could come...
2009/02/09
[ "https://Stackoverflow.com/questions/527246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How can I use jquery to remove a SPECIFIC div that has no children (at least no children that isn't whitespace). E.g. ``` <div id="outer"> some content <div id="removeme"> </div> some more content </div> ``` Want to completely remove the div with id="removeme".
To remove the element with `id` equal to `removeme`: ``` $("#removeme").remove(); ``` To remove the element with `id` equal to `removeme` only if it is empty: ``` $("#removeme:empty").remove(); ``` To remove all empty `<div>`s: ``` $("div:empty").remove(); ``` **EDIT:** If it's not empty, but has whitespace: ...
527,250
<p>I would like to know if it's possible to call a inline function with an output parameter from a scalar function?</p> <p>For example: My inline function is called test_1(input parameter format bigint), the following example works great:<br><br> <b>SELECT * FROM MM.test_1(4679)</b></p> <p>But now I would...
[ { "answer_id": 527422, "author": "Tiberiu Ana", "author_id": 38567, "author_profile": "https://Stackoverflow.com/users/38567", "pm_score": 0, "selected": false, "text": "<pre><code>SELECT * FROM MM.test_1(dbo.test_2(4679))\n</code></pre>\n\n<p>This part should work fine if you have a tab...
2009/02/09
[ "https://Stackoverflow.com/questions/527250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I would like to know if it's possible to call a inline function with an output parameter from a scalar function? For example: My inline function is called test\_1(input parameter format bigint), the following example works great: **SELECT \* FROM MM.test\_1(4679)** But now I would like to use it with an output par...
I can interpret what you're trying to do in two different ways. ### Scenario 1: You want to get a **single value** out of your **kp** table first, then run it through the static function, then feed the result to the inline function and get a table. In this case, you can do something like: ``` declare @foo int; set ...
527,301
<p>In css should I 'name' my page at the top level - like this :</p> <pre><code>&lt;div class="page_products"&gt; </code></pre> <p>in order to write css specific to that page like this :</p> <pre><code>.page_products h3 { font-color: red; } </code></pre> <p>Note: This is a completely random and probably not usef...
[ { "answer_id": 527305, "author": "Rex M", "author_id": 67, "author_profile": "https://Stackoverflow.com/users/67", "pm_score": 4, "selected": false, "text": "<p>Rather than have a pile of one-off CSS files with 1 or 2 rules each in them, I have found it useful to give the <code>body</cod...
2009/02/09
[ "https://Stackoverflow.com/questions/527301", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940/" ]
In css should I 'name' my page at the top level - like this : ``` <div class="page_products"> ``` in order to write css specific to that page like this : ``` .page_products h3 { font-color: red; } ``` Note: This is a completely random and probably not useful style override. H3 is the first thing that came into...
Rather than have a pile of one-off CSS files with 1 or 2 rules each in them, I have found it useful to give the `body` an ID or class attribute similar to your example. Ultimately, pragmatism should win. Simplicity means different things at different scales - if you have massive CSS changes per page, it suddenly become...
527,322
<p>I'm trying to use an NSTextField for integer user input. The text field is bound to an NSNumber property and in the setter method I cleanup the input value (make sure it's an int) and set the property if necessary. I send the willChangeValueForKey: and didChangeValueForKey:, but the UI doesn't update to the new valu...
[ { "answer_id": 527337, "author": "Sophie Alpert", "author_id": 49485, "author_profile": "https://Stackoverflow.com/users/49485", "pm_score": 0, "selected": false, "text": "<p>I think you need to set up a number formatter to your <code>NSTextField</code>.</p>\n\n<p>Go read up about format...
2009/02/09
[ "https://Stackoverflow.com/questions/527322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3740/" ]
I'm trying to use an NSTextField for integer user input. The text field is bound to an NSNumber property and in the setter method I cleanup the input value (make sure it's an int) and set the property if necessary. I send the willChangeValueForKey: and didChangeValueForKey:, but the UI doesn't update to the new values ...
> > I send the willChangeValueForKey: and didChangeValueForKey:, but the UI doesn't update to the new values while that text field is still active. > > > There are very few reasons to send those messages. Usually, you can do the same job better and more cleanly by implementing and using accessors (or, better yet, ...
527,360
<p>I can obtain the Weblogic InitialContext from a JNDI Client using the following properties as the Environment parameters for InitialContext</p> <pre><code>Hashtable jndiProps = new Hashtable(); jndiProps.put("java.naming.factory.initial", "t3://localhost:7001"); jndiProps.put("java.naming.provider.url", "weblogic....
[ { "answer_id": 589401, "author": "Rene", "author_id": 16352, "author_profile": "https://Stackoverflow.com/users/16352", "pm_score": 0, "selected": false, "text": "<p>Simply hashing the password has no real added security value. Since your password resides on the client anyway.</p>\n\n<p>...
2009/02/09
[ "https://Stackoverflow.com/questions/527360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I can obtain the Weblogic InitialContext from a JNDI Client using the following properties as the Environment parameters for InitialContext ``` Hashtable jndiProps = new Hashtable(); jndiProps.put("java.naming.factory.initial", "t3://localhost:7001"); jndiProps.put("java.naming.provider.url", "weblogic.jndi.WLInitial...
You could use symmetric encryption, encrypt the password value and store this in the properties file. Then before creating the initial context read the property value, decrypt it and update the property before passing the jndiProps object to the InitialContext constructor. The encryption key would still be on the clie...
527,368
<p>I might have wandered into wrong direction so please help. </p> <p>I have a page in my ASP.NET MVC application which displays comments. These comments come from 'Index' action of 'Comments' controller. At the bottom of the page I have a form for adding new comments. This form should call </p> <pre><code>[AcceptVer...
[ { "answer_id": 527384, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": true, "text": "<p>If the form submit does a POST (submit) to the comments page (i.e. has the action of the comments page, and the met...
2009/02/09
[ "https://Stackoverflow.com/questions/527368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/430254/" ]
I might have wandered into wrong direction so please help. I have a page in my ASP.NET MVC application which displays comments. These comments come from 'Index' action of 'Comments' controller. At the bottom of the page I have a form for adding new comments. This form should call ``` [AcceptVerbs(HttpVerbs.Get)] p...
If the form submit does a POST (submit) to the comments page (i.e. has the action of the comments page, and the method of POST), then it is indeed the POST version that chouls be used. The GET version would be used if you (for example) use a standard anchor/link to show the standalone comments page (or when issuing an ...
527,415
<p>I have large batches of XHTML files that are manually updated. During the review phase of the updates I would like to programmatically check the well-formedness of the files. I am currently using a <strong>XmlReader</strong>, but the time required on an average CPU is much longer than I expected.</p> <p>The XHTML f...
[ { "answer_id": 527421, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": true, "text": "<p>I would expect that <code>XmlReader</code> with <code>while(reader.Read)() {}</code> would be the fastest <em>manag...
2009/02/09
[ "https://Stackoverflow.com/questions/527415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35709/" ]
I have large batches of XHTML files that are manually updated. During the review phase of the updates I would like to programmatically check the well-formedness of the files. I am currently using a **XmlReader**, but the time required on an average CPU is much longer than I expected. The XHTML files range in size from...
I would expect that `XmlReader` with `while(reader.Read)() {}` would be the fastest *managed* approach. It certainly shouldn't take **seconds** to read 40KB... what is the input approach you are using? Do you perhaps have some external (schema etc) entities to resolve? If so, you might be able to write a custom `XmlRe...
527,420
<p>I am doing something like this in python</p> <pre><code>class MyThread ( threading.Thread ): def run (s): try: s.wantQuit = 0 while(not s.wantQuit): button = raw_input() if button == "q": s.wantQuit=1 except KeyboardInte...
[ { "answer_id": 527433, "author": "Michael Walts", "author_id": 64037, "author_profile": "https://Stackoverflow.com/users/64037", "pm_score": 0, "selected": false, "text": "<p>just tried the code to make sure, but this does do what it's supposed to... you can type q and enter in to the co...
2009/02/09
[ "https://Stackoverflow.com/questions/527420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am doing something like this in python ``` class MyThread ( threading.Thread ): def run (s): try: s.wantQuit = 0 while(not s.wantQuit): button = raw_input() if button == "q": s.wantQuit=1 except KeyboardInterrupt: ...
You mean the while loop runs before the thread? Well, you can't predict this unless you synchronize it. No one guarantees you that the thread will run before or after that while loop. But if it's being blocked for 5 seconds that's akward - the thread should have been pre-empted by then. Also, since you're first use of...
527,439
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/260484/how-do-i-query-the-iphones-current-ip-address">How do I query the iPhone&#39;s current IP address?</a> </p> </blockquote> <p>I'm trying to find the local ip address using gethostname/gethostbyname but I ...
[ { "answer_id": 527776, "author": "Andy Jacobs", "author_id": 62009, "author_profile": "https://Stackoverflow.com/users/62009", "pm_score": 2, "selected": false, "text": "<pre><code> -(NSString*)getAddress {\n char iphone_ip[255];\n strcpy(iphone_ip,\"127.0.0.1\"); //...
2009/02/09
[ "https://Stackoverflow.com/questions/527439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
> > **Possible Duplicate:** > > [How do I query the iPhone's current IP address?](https://stackoverflow.com/questions/260484/how-do-i-query-the-iphones-current-ip-address) > > > I'm trying to find the local ip address using gethostname/gethostbyname but I always get "Unable to Resolve" when doing it. Why coul...
``` -(NSString*)getAddress { char iphone_ip[255]; strcpy(iphone_ip,"127.0.0.1"); // if everything fails NSHost* myhost =[NSHost currentHost]; if (myhost) { NSString *ad = [myhost address]; if (ad) strcpy(iphone_ip,[ad cS...
527,453
<p>If have this in the setter of a property:</p> <pre><code>decimal? temp = value as decimal?; </code></pre> <p>value = "90"</p> <p>But after the cast, temp is <strong>null</strong>...</p> <p>What is the proper way to do this cast?</p>
[ { "answer_id": 527464, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 7, "selected": true, "text": "<p>Unboxing only works if the type is identical! You can't unbox an <code>object</code> that does not contain the targ...
2009/02/09
[ "https://Stackoverflow.com/questions/527453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59119/" ]
If have this in the setter of a property: ``` decimal? temp = value as decimal?; ``` value = "90" But after the cast, temp is **null**... What is the proper way to do this cast?
Unboxing only works if the type is identical! You can't unbox an `object` that does not contain the target value. What you need is something along the lines of ``` decimal tmpvalue; decimal? result = decimal.TryParse((string)value, out tmpvalue) ? tmpvalue : (decimal?)null; ``` This looks whether t...
527,468
<p>I'm trying to create a resizable div without using jQuery's interface library.</p> <pre><code>var myY = 0; var mouseDown = false; var originalHeight = 0; function resize(e){ if(mouseDown == true){ $("#cooldiv").height(originalHeight+e.pageY-myY); } } $(document).ready(function(){ $().mouseup...
[ { "answer_id": 527464, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 7, "selected": true, "text": "<p>Unboxing only works if the type is identical! You can't unbox an <code>object</code> that does not contain the targ...
2009/02/09
[ "https://Stackoverflow.com/questions/527468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64087/" ]
I'm trying to create a resizable div without using jQuery's interface library. ``` var myY = 0; var mouseDown = false; var originalHeight = 0; function resize(e){ if(mouseDown == true){ $("#cooldiv").height(originalHeight+e.pageY-myY); } } $(document).ready(function(){ $().mouseup(function(e){ ...
Unboxing only works if the type is identical! You can't unbox an `object` that does not contain the target value. What you need is something along the lines of ``` decimal tmpvalue; decimal? result = decimal.TryParse((string)value, out tmpvalue) ? tmpvalue : (decimal?)null; ``` This looks whether t...
527,474
<p>I am trying to learn or generate any codes to learn string <code>day("26.02.2009")</code> ---> give me "wednesday"</p> <p>I need a static datefunction in C#.</p> <p>For example:</p> <pre><code>datetime Str_day= Returnstringdate("09.02.2009"); ----&gt;Str_day="Monday"; Returnstringdate("09.02.2009") { it m...
[ { "answer_id": 527479, "author": "Richard Szalay", "author_id": 3603, "author_profile": "https://Stackoverflow.com/users/3603", "pm_score": 3, "selected": false, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/w2sa9yss.aspx\" rel=\"nofollow noreferrer\"><code>DateTime.Parse...
2009/02/09
[ "https://Stackoverflow.com/questions/527474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52420/" ]
I am trying to learn or generate any codes to learn string `day("26.02.2009")` ---> give me "wednesday" I need a static datefunction in C#. For example: ``` datetime Str_day= Returnstringdate("09.02.2009"); ---->Str_day="Monday"; Returnstringdate("09.02.2009") { it must return Monday!!! } ``` OR ``` Retur...
[`DateTime.ParseExact`](http://msdn.microsoft.com/en-us/library/w2sa9yss.aspx) allows you to specify the exact format of the date you are parsing. You can then use `ToString("dddd")` to return the day of the week as a string. ``` DateTime date = DateTime.ParseExact("09.02.2009", "dd.MM.yyyy", CultureInfo.Invaria...
527,484
<p>I am trying to display the menu using DHTML, but I am getting a JavaScript error and menus are not getting displayed.</p> <pre><code>&lt;script language="JavaScript" vqp_datafile0="Welcome to Epicenter Fitness_files/epicenter_nav.js" vqp_uid0="61625" vqptag="doc_level_settings"&gt; cdd__codebase =...
[ { "answer_id": 527498, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 1, "selected": false, "text": "<p>I guess <a href=\"http://www.jboss.com/products/jbossas/architecture\" rel=\"nofollow noreferrer\">JBoss</a> is a good examp...
2009/02/09
[ "https://Stackoverflow.com/questions/527484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2572740/" ]
I am trying to display the menu using DHTML, but I am getting a JavaScript error and menus are not getting displayed. ``` <script language="JavaScript" vqp_datafile0="Welcome to Epicenter Fitness_files/epicenter_nav.js" vqp_uid0="61625" vqptag="doc_level_settings"> cdd__codebase = "Welcome to Epicent...
I guess [JBoss](http://www.jboss.com/products/jbossas/architecture) is a good example of multiple layers Architecture... [![alt text](https://i.stack.imgur.com/ovJ5n.gif)](https://i.stack.imgur.com/ovJ5n.gif) (source: [jboss.com](http://www.jboss.com/images/appInstrumentation.gif))
527,486
<p>I have this enum:</p> <pre><code>[Flags] public enum ExportFormat { None = 0, Csv = 1, Tsv = 2, Excel = 4, All = Excel | Csv | Tsv } </code></pre> <p>I am trying to make a wrapper on this (or any, really) enum which notifies on change. Currently it looks like this:</p> <pre><code>public class ...
[ { "answer_id": 527501, "author": "Anton Gogolev", "author_id": 60188, "author_profile": "https://Stackoverflow.com/users/60188", "pm_score": 0, "selected": false, "text": "<p>See <a href=\"http://www.codeproject.com/KB/cs/ExtendEnum.aspx\" rel=\"nofollow noreferrer\">here</a>. Quite a lo...
2009/02/09
[ "https://Stackoverflow.com/questions/527486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39321/" ]
I have this enum: ``` [Flags] public enum ExportFormat { None = 0, Csv = 1, Tsv = 2, Excel = 4, All = Excel | Csv | Tsv } ``` I am trying to make a wrapper on this (or any, really) enum which notifies on change. Currently it looks like this: ``` public class NotifyingEnum<T> : INotifyPropertyCha...
With flag-based enums, it's about having a bit set or not. So for 'ExportFormat', if bit 1 is set, it's CSV format, even though there might be more bits set. Is having bit 1 and 2 set an invalid value? This is subjective: from the point of view of the values as a group, it is invalid (there's no bitpattern defined for ...
527,510
<p><strong>Background</strong>: I have a small Python application that makes life for developers releasing software in our company a bit easier. I build an executable for Windows using py2exe. The application as well as the binary are checked into Subversion. Distribution happens by people just checking out the directo...
[ { "answer_id": 527531, "author": "nosklo", "author_id": 17160, "author_profile": "https://Stackoverflow.com/users/17160", "pm_score": 3, "selected": false, "text": "<p>Just use <a href=\"http://pypi.python.org/pypi/virtualenv\" rel=\"noreferrer\">virtualenv</a> - it is a tool to create i...
2009/02/09
[ "https://Stackoverflow.com/questions/527510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1996/" ]
**Background**: I have a small Python application that makes life for developers releasing software in our company a bit easier. I build an executable for Windows using py2exe. The application as well as the binary are checked into Subversion. Distribution happens by people just checking out the directory from SVN. The...
I sometimes use the approach I describe below, for the exact same reason that @Boris states: I would prefer that the use of some code is as easy as a) svn checkout/update - b) go. But for the record: * I use virtualenv/easy\_install most of the time. * I agree to a certain extent to the critisisms by @Ali A and @S.Lo...
527,513
<p>I need to execute a PowerShell script from within C#. The script needs commandline arguments.</p> <p>This is what I have done so far:</p> <pre><code>RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create(); Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConfiguration); runspace.Ope...
[ { "answer_id": 527644, "author": "Kosi2801", "author_id": 57601, "author_profile": "https://Stackoverflow.com/users/57601", "pm_score": 8, "selected": true, "text": "<p>Try creating scriptfile as a separate command:</p>\n<pre><code>Command myCommand = new Command(scriptfile);\n</code></p...
2009/02/09
[ "https://Stackoverflow.com/questions/527513", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23369/" ]
I need to execute a PowerShell script from within C#. The script needs commandline arguments. This is what I have done so far: ``` RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create(); Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConfiguration); runspace.Open(); RunspaceInvoke ...
Try creating scriptfile as a separate command: ``` Command myCommand = new Command(scriptfile); ``` then you can add parameters with ``` CommandParameter testParam = new CommandParameter("key","value"); myCommand.Parameters.Add(testParam); ``` and finally ``` pipeline.Commands.Add(myCommand); ``` --- ***Here ...
527,525
<p>I find myself defining classes like:</p> <pre><code>struct AngleSize { explicit AngleSize(double radians) : size(radians) {} double size; }; </code></pre> <p>This has a bunch of advantages over storing anglesizes as plain doubles. </p> <p><strong>Advantage 1</strong>, it makes it possible to define these ...
[ { "answer_id": 527548, "author": "zoul", "author_id": 17279, "author_profile": "https://Stackoverflow.com/users/17279", "pm_score": 1, "selected": false, "text": "<p>I don’t do this, I’d find it overly verbose and complicated for the tiny advantages it brings. I sometimes do a simple <co...
2009/02/09
[ "https://Stackoverflow.com/questions/527525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I find myself defining classes like: ``` struct AngleSize { explicit AngleSize(double radians) : size(radians) {} double size; }; ``` This has a bunch of advantages over storing anglesizes as plain doubles. **Advantage 1**, it makes it possible to define these 2 distinct constructors: ``` Vec2::Vec2(doubl...
I do this whenever it makes sense. Compare with [How do you make wrong code look wrong? What patterns do you use to avoid semantic errors?](https://stackoverflow.com/questions/26086/how-do-you-make-wrong-code-look-wrong-what-patterns-do-you-use-to-avoid-semantic/26174#26174). In the example of Joel's article he discus...
527,532
<p>I want to enable users on my site to upload images to their accounts. The images get resized into 4 different sizes required across the site. </p> <p>I have been using Pear Image_Transform but I kept getting "bytes exhausted" fatal errors on certain types of jpgs (all files tried under 2mb). So I moved to a dedicat...
[ { "answer_id": 527606, "author": "ed209", "author_id": 31399, "author_profile": "https://Stackoverflow.com/users/31399", "pm_score": 1, "selected": false, "text": "<p>It seems that ini_set(\"memory_limit\",\"256M\"); has covered it. Also, using memory_get_peak_usage() I discovered that m...
2009/02/09
[ "https://Stackoverflow.com/questions/527532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31399/" ]
I want to enable users on my site to upload images to their accounts. The images get resized into 4 different sizes required across the site. I have been using Pear Image\_Transform but I kept getting "bytes exhausted" fatal errors on certain types of jpgs (all files tried under 2mb). So I moved to a dedicated server...
A rough guide to how much memory you're going to need can be calculated like this ``` $imageInfo = getimagesize( $sourceImagePath ); // a check to make sure we have enough memory to hold this image $requiredMemoryMB = ( $imageInfo[0] * $imageInfo[1] * ($imageInfo['bits'] / 8) * $imageInfo['channels'] * 2.5 ) / 1024; ...
527,533
<p>I have a database table that contains a list of contacts, some of those contacts might have multiple records, e.g.</p> <pre><code>CustomerID, CustomerName, Vehicle 1, Dan, Mazda 1, Dan, Suzuki 2, John, Ford 3, Dasha, Volvo 3, Dasha, Ford </code></pre> <p>Can I write a select query to return the distinct customerID...
[ { "answer_id": 527541, "author": "Learning", "author_id": 18275, "author_profile": "https://Stackoverflow.com/users/18275", "pm_score": 1, "selected": false, "text": "<p>I'm not sure if it can be done via a single sql. However , last time when I attempted this in sybase's tsql , I had us...
2009/02/09
[ "https://Stackoverflow.com/questions/527533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55041/" ]
I have a database table that contains a list of contacts, some of those contacts might have multiple records, e.g. ``` CustomerID, CustomerName, Vehicle 1, Dan, Mazda 1, Dan, Suzuki 2, John, Ford 3, Dasha, Volvo 3, Dasha, Ford ``` Can I write a select query to return the distinct customerID and CustomerName, and a l...
There are some [nice answers to this problem on another question](https://stackoverflow.com/questions/451415/simulating-groupconcat-mysql-function-in-ms-sql-server-2005). According to [the linked article](http://blog.shlomoid.com/2008/11/emulating-mysqls-groupconcat-function.html), this will only work in SQL Server 2...
527,553
<p>I'm working on a class that is storing a 2D array of class <code>MyType</code> and would like it to use dynamic data types. i.e. not <code>MyType[,]</code></p> <p>The problem with <code>MyType[,]</code> is that the class doesn't know the size of the array ahead of time, and I don't want to go to the trouble of mana...
[ { "answer_id": 527559, "author": "Anton Gogolev", "author_id": 60188, "author_profile": "https://Stackoverflow.com/users/60188", "pm_score": 1, "selected": false, "text": "<p>It depends on how sparse your structure will be. For instance, if your entries will resemble something like <code...
2009/02/09
[ "https://Stackoverflow.com/questions/527553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30698/" ]
I'm working on a class that is storing a 2D array of class `MyType` and would like it to use dynamic data types. i.e. not `MyType[,]` The problem with `MyType[,]` is that the class doesn't know the size of the array ahead of time, and I don't want to go to the trouble of managing array re-sizing if it's been done else...
Create your own `List<List<T>>` encapsulation like : ``` public class Matrix<T> { List<List<T>> matrix; public void Add(IEnumerable<T> row) { List<T> newRow = new List<T>(row); matrix.Add(newRow); } public T this[int x, int y] { get { return matrix[y][x]; } } .... } ``` d...
527,561
<p>How to move one Arraylist data to another arraylist. I have tried for many option but the output is in the form of array not arraylist</p>
[ { "answer_id": 527567, "author": "Øyvind Skaar", "author_id": 49194, "author_profile": "https://Stackoverflow.com/users/49194", "pm_score": 3, "selected": false, "text": "<pre><code>ArrayList l1=new ArrayList();\nl1.Add(\"1\");\nl1.Add(\"2\");\nArrayList l2=new ArrayList(l1);\n</code></p...
2009/02/09
[ "https://Stackoverflow.com/questions/527561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22162/" ]
How to move one Arraylist data to another arraylist. I have tried for many option but the output is in the form of array not arraylist
First - unless you are on .NET 1.1, you should a avoid `ArrayList` - prefer typed collections such as `List<T>`. When you say "copy" - do you want to *replace*, *append*, or *create new*? For append (using `List<T>`): ``` List<int> foo = new List<int> { 1, 2, 3, 4, 5 }; List<int> bar = new List<int> { 6, 7, ...
527,576
<p>I don't konow how to set <code>Path</code> inside a <code>UserControl</code> based on a <code>Parameter</code>:</p> <p>User control:</p> <pre><code>&lt;UserControl x:Class="WpfApplication3.TestControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/w...
[ { "answer_id": 527579, "author": "Anton Gogolev", "author_id": 60188, "author_profile": "https://Stackoverflow.com/users/60188", "pm_score": 0, "selected": false, "text": "<p>The table in question is not even First Normal Form, which is bad.</p>\n\n<p>The only way you can possibly do tha...
2009/02/09
[ "https://Stackoverflow.com/questions/527576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59964/" ]
I don't konow how to set `Path` inside a `UserControl` based on a `Parameter`: User control: ``` <UserControl x:Class="WpfApplication3.TestControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:diagnostics="clr-namespace:Syst...
You should implement an `IUserCollection`, which would map your CSV column to an actual list of emails, then serialize it back on save.
527,595
<p>I'm a begginer in java I have </p> <pre><code>packet=090209153038020734.0090209153039020734.0 </code></pre> <p>like this I want to split this string and store into an array like two strings:</p> <pre><code>1) 090209153038020734.0 2) 090209153039020734.0 </code></pre> <p>I have done like this:</p> <pre><code>St...
[ { "answer_id": 527613, "author": "Nick Fortescue", "author_id": 5346, "author_profile": "https://Stackoverflow.com/users/5346", "pm_score": 0, "selected": false, "text": "<p>You don't say how you want to do the split. It could be based on a fixed length (number of characters) or you wan...
2009/02/09
[ "https://Stackoverflow.com/questions/527595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm a begginer in java I have ``` packet=090209153038020734.0090209153039020734.0 ``` like this I want to split this string and store into an array like two strings: ``` 1) 090209153038020734.0 2) 090209153039020734.0 ``` I have done like this: ``` String packetArray[] = packets.split(packets,Constants.SF); ...
The JavaDoc of String is helpful here: <http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html> You have your String packet; `String.indexOf(String)` gives you a position of a special substring. your interested in the "." sign. So you write ``` int position = packet.indexOf(".")+1 ``` +1 becuase you want t...
527,602
<p>Is there any way to automatically get notified of property changes in a class without having to write OnPropertyChanged in every setter? (I have hundreds of properties that I want to know if they have changed).</p> <hr> <p>Anton suggests <a href="http://www.nablasoft.com/alkampfer/index.php/2008/08/04/implement-i...
[ { "answer_id": 527639, "author": "TcKs", "author_id": 20382, "author_profile": "https://Stackoverflow.com/users/20382", "pm_score": 2, "selected": false, "text": "<p>I don't know no standard way, but I know two workarounds:</p>\n\n<p>1) <a href=\"http://www.postsharp.org/\" rel=\"nofollo...
2009/02/09
[ "https://Stackoverflow.com/questions/527602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16676/" ]
Is there any way to automatically get notified of property changes in a class without having to write OnPropertyChanged in every setter? (I have hundreds of properties that I want to know if they have changed). --- Anton suggests [dynamic proxies](http://www.nablasoft.com/alkampfer/index.php/2008/08/04/implement-inot...
**EDIT:** The author of NotifyPropertyWeaver has deprecated the tool in favor of the more general [Fody](https://github.com/Fody/Fody#readme). (A [migration guide](https://github.com/Fody/PropertyChanged/wiki/ConvertingFromNotifyPropertyWeaver) for people moving from weaver to fody is available.) --- A very convenien...
527,610
<p>I have a Java keystore (.jks file) holding a single certificate. How can I create a .pfx file from this keystore?</p>
[ { "answer_id": 527891, "author": "Nick Fortescue", "author_id": 5346, "author_profile": "https://Stackoverflow.com/users/5346", "pm_score": 2, "selected": false, "text": "<p>This guy() seems to have written a little Java class and batch file with good instructions to do this here: <a hre...
2009/02/09
[ "https://Stackoverflow.com/questions/527610", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5035/" ]
I have a Java keystore (.jks file) holding a single certificate. How can I create a .pfx file from this keystore?
From Java 6 onwards, `keytool` has an `-importkeystore` option, which should be able to convert a JKS store into a PKCS#12 store (.p12/.pfx): ``` keytool -importkeystore -srckeystore thekeystore.jks \ -srcstoretype JKS \ -destkeystore thekeystore.pfx \ -deststoretype PKCS12 ``` It...
527,611
<p>I've created a simple solution with 2 projects. The 1st project (class library) contains a custom control called Container which draws itself with rounded corners. The 2nd project (windows forms) is a test application.</p> <p>If I add a Container instance to main Form in the 2nd project it shows the rounded corners...
[ { "answer_id": 527626, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 1, "selected": false, "text": "<p>It shouldn't be necessary to force a redraw here (under normal circumstances) since that redraw is automatically f...
2009/02/09
[ "https://Stackoverflow.com/questions/527611", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45311/" ]
I've created a simple solution with 2 projects. The 1st project (class library) contains a custom control called Container which draws itself with rounded corners. The 2nd project (windows forms) is a test application. If I add a Container instance to main Form in the 2nd project it shows the rounded corners nicely. A...
This is your problem: ``` Dim r As Rectangle = e.ClipRectangle ``` Change it to: ``` Dim r As Rectangle = Me.ClientRectangle ```
527,617
<p>Just a question of curiosity. When i preserve object refernces while serializing an object graph with DataContractSerializer the xml emitted where there are refrences looks like this:</p> <pre><code>&lt;test z:Ref="1" and i:nil="true" /&gt; </code></pre> <p>Can anybody tell me why it says i:nil="true" here? Why no...
[ { "answer_id": 1075368, "author": "Martin Delille", "author_id": 118125, "author_profile": "https://Stackoverflow.com/users/118125", "pm_score": 0, "selected": false, "text": "<p>This is a reference to your element.\nYou must have a definition of your element previously in the document...
2009/02/09
[ "https://Stackoverflow.com/questions/527617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64105/" ]
Just a question of curiosity. When i preserve object refernces while serializing an object graph with DataContractSerializer the xml emitted where there are refrences looks like this: ``` <test z:Ref="1" and i:nil="true" /> ``` Can anybody tell me why it says i:nil="true" here? Why not just the reference?
This is because the content of the `test` element is empty. `i:nil="true"` is necessary so that the content will validate.
527,624
<p>I created a WebService using the .NET 2.0 framework, a class based on an interface that has the WebServiceAttribute and hosting it using IIS and a ASMX file. The WebService currently loads its configuration from one XML file.</p> <p>I'd like to create multiple instance of this service where each loads it own configu...
[ { "answer_id": 1075368, "author": "Martin Delille", "author_id": 118125, "author_profile": "https://Stackoverflow.com/users/118125", "pm_score": 0, "selected": false, "text": "<p>This is a reference to your element.\nYou must have a definition of your element previously in the document...
2009/02/09
[ "https://Stackoverflow.com/questions/527624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25782/" ]
I created a WebService using the .NET 2.0 framework, a class based on an interface that has the WebServiceAttribute and hosting it using IIS and a ASMX file. The WebService currently loads its configuration from one XML file. I'd like to create multiple instance of this service where each loads it own configuration. ...
This is because the content of the `test` element is empty. `i:nil="true"` is necessary so that the content will validate.
527,633
<p>I want to give a minimal js code to random websites so that they can add a widget.</p> <p>The code needs to run after the main page loads and include a parameter with the domain name. ( I don't want to hardcode it)</p> <p>One option is to add this code just before the <code>&lt;/body&gt;</code> (so It will run aft...
[ { "answer_id": 527651, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": 1, "selected": true, "text": "<p>You probably want to be implementing the <strong>non-blocking script technique</strong>. Essentially instead of modifyi...
2009/02/09
[ "https://Stackoverflow.com/questions/527633", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64106/" ]
I want to give a minimal js code to random websites so that they can add a widget. The code needs to run after the main page loads and include a parameter with the domain name. ( I don't want to hardcode it) One option is to add this code just before the `</body>` (so It will run after the page loads): ``` <script t...
You probably want to be implementing the **non-blocking script technique**. Essentially instead of modifying the src of a script, you're going to create and append a whole new script element. Good write up [here](http://www.artzstudio.com/2008/07/beating-blocking-javascript-asynchronous-js/) and there are standard way...
527,663
<p>This is a (hopefully) really simple question - I have been told recently that using C++ style initialisation is better than traditional (and more common) assignment.</p> <p>So this code:</p> <pre><code>std::SomeSTLContainer::const_iterator it = container.begin(); std::SomeSTLContainer::const_iterator itEnd = conta...
[ { "answer_id": 527670, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 4, "selected": true, "text": "<blockquote>\n <p>I have been told recently that using C++ style initialisation is better than traditional (and more ...
2009/02/09
[ "https://Stackoverflow.com/questions/527663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18664/" ]
This is a (hopefully) really simple question - I have been told recently that using C++ style initialisation is better than traditional (and more common) assignment. So this code: ``` std::SomeSTLContainer::const_iterator it = container.begin(); std::SomeSTLContainer::const_iterator itEnd = container.end(); ``` wou...
> > I have been told recently that using C++ style initialisation is better than traditional (and more common) assignment. > > > This is simply wrong. > > I understand the reason for this - the first example causes default construction and initialisation then subsequent assignment rather than specific constructi...
527,684
<p>I need to create a gridview based on 2 different datasources: main and sub-cathegory. And I need to list them like below:</p> <pre> Productinfo sub-product 1 sub-product 2 Productinfo sub-product 1 sub-product 2 sub-product 3 sub-product 4 </pre> <p>Etc... the thing is that both the "productinfo...
[ { "answer_id": 527834, "author": "Frost", "author_id": 63467, "author_profile": "https://Stackoverflow.com/users/63467", "pm_score": 0, "selected": false, "text": "<p>I'm not sure i understand your question? ..but do you just want to databind your grid?</p>\n\n<p>I would properly create ...
2009/02/09
[ "https://Stackoverflow.com/questions/527684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to create a gridview based on 2 different datasources: main and sub-cathegory. And I need to list them like below: ``` Productinfo sub-product 1 sub-product 2 Productinfo sub-product 1 sub-product 2 sub-product 3 sub-product 4 ``` Etc... the thing is that both the "productinfo" and the "su...
vb code: ``` Dim mydatatable As New DataTable ' Create columns mydatatable.Columns.Add("field_a", Type.GetType("System.String")) mydatatable.Columns.Add("field_b", Type.GetType("System.String")) ' Declare row Dim myrow As DataRow ' create new row myrow = mydatatable.NewRow myrow("field_a") = "filed a row 1" myrow("fie...
527,685
<p>I am not sure when I should use <em>anonymous types</em> instead of <em>local variables</em> in C#.</p> <p>I have:</p> <pre><code>string fullMessage // This is the full message including sender and recipient names string sender = GetMessagePart(fullMessage, "from"); string recipient = GetMessagePart(fullMessage,...
[ { "answer_id": 527689, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": true, "text": "<p><s>Do you mean statically typed variables? Note that anonymous types <em>are</em> statically typed...</s> (removed ...
2009/02/09
[ "https://Stackoverflow.com/questions/527685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61976/" ]
I am not sure when I should use *anonymous types* instead of *local variables* in C#. I have: ``` string fullMessage // This is the full message including sender and recipient names string sender = GetMessagePart(fullMessage, "from"); string recipient = GetMessagePart(fullMessage, "to"); //do some stuff and delive...
~~Do you mean statically typed variables? Note that anonymous types *are* statically typed...~~ (removed due to question edit) There are 2 problems with C# anonymous types: * you can't expose them through a method API * you can't mutate them (the members are read-only) If you only need to know about the data within ...
527,695
<p>I am trying to deal with an IE7 bug in my application. Here is the HTML/CSS code</p> <pre><code>&lt;div style="margin-left: 320px"&gt; &lt;form method="post" action=""&gt;&lt;fieldset&gt; &lt;textarea name="prj_comment" id="prj_comment" rows="5" cols="50" style="margin: 0; padding: 0"...
[ { "answer_id": 527746, "author": "yoavf", "author_id": 1011, "author_profile": "https://Stackoverflow.com/users/1011", "pm_score": 3, "selected": true, "text": "<p>Totally weird. I actually get a 320px (=parent div margin) in ie7.</p>\n\n<p>You can overwrite with an ie7 only negative mar...
2009/02/09
[ "https://Stackoverflow.com/questions/527695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8404/" ]
I am trying to deal with an IE7 bug in my application. Here is the HTML/CSS code ``` <div style="margin-left: 320px"> <form method="post" action=""><fieldset> <textarea name="prj_comment" id="prj_comment" rows="5" cols="50" style="margin: 0; padding: 0"></textarea> </fieldset></form>...
Totally weird. I actually get a 320px (=parent div margin) in ie7. You can overwrite with an ie7 only negative margin, but that's awful... **EDIT:** OK, I have no idea why this works, but it works. this is defintely a bug: ``` <div style="margin-left: 320px; display:inline-block;"> <form method="post" action="">...
527,714
<p>I have an HTML element (let's say a <code>div</code>ision) that contains a set titles (<code>h2</code>) and paragraphs (<code>p</code>) with other element inside (some links for example, <code>a</code>).</p> <p>My <strong>goal</strong> is to cut my HTML element in 2 same size element.</p> <p><strong>Constrains :</...
[ { "answer_id": 527800, "author": "Gary Green", "author_id": 63523, "author_profile": "https://Stackoverflow.com/users/63523", "pm_score": 2, "selected": false, "text": "<p>If your trying to make an automatic two column layout; take a look at <a href=\"http://www.alistapart.com/articles/m...
2009/02/09
[ "https://Stackoverflow.com/questions/527714", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have an HTML element (let's say a `div`ision) that contains a set titles (`h2`) and paragraphs (`p`) with other element inside (some links for example, `a`). My **goal** is to cut my HTML element in 2 same size element. **Constrains :** paragraphs, titles, and block should not be cut My idea asbout this was to bro...
If your trying to make an automatic two column layout; take a look at [multicolumnlists](http://www.alistapart.com/articles/multicolumnlists)
527,719
<p>What is the best way to add a hyperlink in a JLabel? I can get the view using html tags, but how to open the browser when the user clicks on it?</p>
[ { "answer_id": 527733, "author": "Srikanth", "author_id": 7205, "author_profile": "https://Stackoverflow.com/users/7205", "pm_score": 3, "selected": false, "text": "<p>If &lt;a href=\"link\"&gt; doesn't work, then:</p>\n\n<ol>\n<li>Create a JLabel and add a MouseListener (decorate the la...
2009/02/09
[ "https://Stackoverflow.com/questions/527719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62237/" ]
What is the best way to add a hyperlink in a JLabel? I can get the view using html tags, but how to open the browser when the user clicks on it?
You can do this using a `JLabel`, but an alternative would be to style a [`JButton`](http://docs.oracle.com/javase/7/docs/api/javax/swing/JButton.html). That way, you don't have to worry about [accessibility](http://en.wikipedia.org/wiki/Computer_accessibility) and can just fire events using an [`ActionListener`](http:...
527,724
<p>I've a procedure where I need to save an entity object. The problem is that I don't know if this entity is attached to my datacontext or not. To solve this I use the following code:</p> <pre><code>try { db.ClientUsers.Attach(clientUser); db.Refresh(RefreshMode.KeepCurrentValues, clientUser); } catch { } db...
[ { "answer_id": 527734, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 6, "selected": true, "text": "<p>I wonder... what does <a href=\"http://msdn.microsoft.com/en-us/library/bb548700.aspx\" rel=\"noreferrer\"><code>Ge...
2009/02/09
[ "https://Stackoverflow.com/questions/527724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40939/" ]
I've a procedure where I need to save an entity object. The problem is that I don't know if this entity is attached to my datacontext or not. To solve this I use the following code: ``` try { db.ClientUsers.Attach(clientUser); db.Refresh(RefreshMode.KeepCurrentValues, clientUser); } catch { } db.SubmitChanges...
I wonder... what does [`GetOriginalEntityState`](http://msdn.microsoft.com/en-us/library/bb548700.aspx) return for a non-attached object? Even if it throws an exception, it'll probably be faster than a refresh... (update) - a test shows it returns null: ``` Customer cust = new Customer(); Customer ori...
527,742
<p>Hey. Is it possible to overload operator&lt;&lt; for primitive types? Fx lets say that I want to write a std::endl each time want to write a int. Can I overload operator&lt;&lt; for int, so that it automatic puts a std::endl to the output? I have tried with this,</p> <pre><code>std::ostream&amp; operator&lt;&lt;(st...
[ { "answer_id": 527769, "author": "Muxecoid", "author_id": 50194, "author_profile": "https://Stackoverflow.com/users/50194", "pm_score": 2, "selected": false, "text": "<p>Remember that here you use &lt;&lt; operator not only on int but also on ostream. You could derive from ostream and im...
2009/02/09
[ "https://Stackoverflow.com/questions/527742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21199/" ]
Hey. Is it possible to overload operator<< for primitive types? Fx lets say that I want to write a std::endl each time want to write a int. Can I overload operator<< for int, so that it automatic puts a std::endl to the output? I have tried with this, ``` std::ostream& operator<<(std::ostream& strm, int & i) { strm...
As zabzonk said, the standard library provides an (ostream&, int) overload so you can't define another. To simulate what you were doing (though it is completely pointless in its present form :) : ``` class EndlinedInteger { public: EndlinedInteger(int i) : i(i) { } friend ostream& operator<<(ostream&, Endline...
527,753
<p>In a Rails app sometimes you use a redirect in an action...</p> <pre><code>redirect_to :controller =&gt; 'sessions', :action =&gt; 'new' </code></pre> <p>I wonder if that's bad though because it sends back a 302 status to the browser and then the browser makes a whole new request. It's an additional back-and-forth...
[ { "answer_id": 527791, "author": "Ola Bini", "author_id": 64081, "author_profile": "https://Stackoverflow.com/users/64081", "pm_score": 4, "selected": true, "text": "<p>The main reason for using redirects instead of renderings is to ensure the idempotent invariant. This basically mean th...
2009/02/09
[ "https://Stackoverflow.com/questions/527753", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42595/" ]
In a Rails app sometimes you use a redirect in an action... ``` redirect_to :controller => 'sessions', :action => 'new' ``` I wonder if that's bad though because it sends back a 302 status to the browser and then the browser makes a whole new request. It's an additional back-and-forth. Would it be better to just re...
The main reason for using redirects instead of renderings is to ensure the idempotent invariant. This basically mean that if you modify something from a POST or DELETE, then you should redirect to the next page. Otherwise, if someone tries to update, they might redo the mutating operation. It also makes it easier for t...
527,757
<p>I have the following example code:</p> <pre><code>class A(object): def __init__(self, id): self.myid = id def foo(self, x): print 'foo', self.myid*x class B(A): def __init__(self, id): self.myid = id self.mybid = id*2 def bar(self, x): print 'bar', self.myid,...
[ { "answer_id": 527789, "author": "Abgan", "author_id": 46308, "author_profile": "https://Stackoverflow.com/users/46308", "pm_score": 4, "selected": true, "text": "<p>You should rather implement <a href=\"http://en.wikipedia.org/wiki/Abstract_factory_pattern\" rel=\"noreferrer\">Abstract...
2009/02/09
[ "https://Stackoverflow.com/questions/527757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42580/" ]
I have the following example code: ``` class A(object): def __init__(self, id): self.myid = id def foo(self, x): print 'foo', self.myid*x class B(A): def __init__(self, id): self.myid = id self.mybid = id*2 def bar(self, x): print 'bar', self.myid, self.mybid, x...
You should rather implement [Abstract Factory pattern](http://en.wikipedia.org/wiki/Abstract_factory_pattern), and your factory would then build any object you like, depending on provided parameters. That way your code will remain clean and extensible. Any hack you could use to make it directly can be removed when you...
527,758
<p>Given this magical interface:</p> <pre><code>public interface IHat&lt;out TRabbit&gt; { TRabbit Take(); } </code></pre> <p>And this class hierarchy:</p> <pre><code>public class Rabbit { } public class WhiteRabbit : Rabbit { } </code></pre> <p>I can now compile this:</p> <pre><code>IHat&lt;WhiteRabbit&gt; h...
[ { "answer_id": 527774, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": true, "text": "<p>Interesting. However, at the CLI level there is no such thing as \"out\" - only \"ref\"; there is an attribute that...
2009/02/09
[ "https://Stackoverflow.com/questions/527758", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27423/" ]
Given this magical interface: ``` public interface IHat<out TRabbit> { TRabbit Take(); } ``` And this class hierarchy: ``` public class Rabbit { } public class WhiteRabbit : Rabbit { } ``` I can now compile this: ``` IHat<WhiteRabbit> hat1 = null; IHat<Rabbit> hat2 = hat1; ``` Which is great. But what if ...
Interesting. However, at the CLI level there is no such thing as "out" - only "ref"; there is an attribute that helps compilers (for definite assignment) that says "you don't need to pass it in". Maybe this restriction is because the CLI doesn't have "out", only "ref".
527,766
<p>I'm developing an application where I the need to invoke a method of a generic class and I don't care about the instances actual type. Something like the following Java code:</p> <pre><code>public class Item&lt;T&gt;{ private T item; public doSomething(){...} } ... public void processItems(Item&lt;?&gt;[] ite...
[ { "answer_id": 527775, "author": "Anton Gogolev", "author_id": 60188, "author_profile": "https://Stackoverflow.com/users/60188", "pm_score": 1, "selected": false, "text": "<p>There's no way you can omit Type Parameters in .NET generic implementation; this is by design. In fact, this can ...
2009/02/09
[ "https://Stackoverflow.com/questions/527766", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1009/" ]
I'm developing an application where I the need to invoke a method of a generic class and I don't care about the instances actual type. Something like the following Java code: ``` public class Item<T>{ private T item; public doSomething(){...} } ... public void processItems(Item<?>[] items){ for(Item<?> item : i...
The normal way to do this would be to make the method generic: ``` public void ProcessItems<T>(Item<T>[] items) { foreach(Item<T> item in items) item.DoSomething(); } ``` Assuming the *caller* knows the type, type inference should mean that they don't have to explicitly specify it. For example: ``` Item<int> ...
527,772
<p>In my PowerShell script, I'm running Select-String over a number of files, looking for a string passed into it via a variable ($id):</p> <pre><code>foreach ($file in (ls "path\to\files")) { $found = $false $found = Select-String -Path $file $id -Quiet if ($found) { break } } </code></pre> <...
[ { "answer_id": 527901, "author": "Shay Levy", "author_id": 9833, "author_profile": "https://Stackoverflow.com/users/9833", "pm_score": 6, "selected": true, "text": "<p>Use the static <code>escape()</code> method, it instructs the regular expression engine to interpret these characters li...
2009/02/09
[ "https://Stackoverflow.com/questions/527772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5296/" ]
In my PowerShell script, I'm running Select-String over a number of files, looking for a string passed into it via a variable ($id): ``` foreach ($file in (ls "path\to\files")) { $found = $false $found = Select-String -Path $file $id -Quiet if ($found) { break } } ``` Unfortunately, the $id v...
Use the static `escape()` method, it instructs the regular expression engine to interpret these characters literally rather than as metacharacters: ``` $id = [regex]::escape($id) ``` You can also turn the command to a one liner (`-path` can take a collection of files): ``` Select-String -Path path\to\files\\* -Patt...
527,803
<p>I have a Perl program that stores regular expressions in configuration files. They are in the form:</p> <pre><code>regex = ^/d+$ </code></pre> <p>Elsewhere, the regex gets parsed from the file and stored in a variable - <code>$regex</code>. I then use the variable when checking the regex, e.g. </p> <pre><code>$lV...
[ { "answer_id": 527841, "author": "Emmanuel Rodriguez", "author_id": 59223, "author_profile": "https://Stackoverflow.com/users/59223", "pm_score": 3, "selected": true, "text": "<p>Using <a href=\"http://perldoc.perl.org/functions/eval.html\" rel=\"nofollow noreferrer\">eval</a> can help y...
2009/02/09
[ "https://Stackoverflow.com/questions/527803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61318/" ]
I have a Perl program that stores regular expressions in configuration files. They are in the form: ``` regex = ^/d+$ ``` Elsewhere, the regex gets parsed from the file and stored in a variable - `$regex`. I then use the variable when checking the regex, e.g. ``` $lValid = ($valuetocheck =~ /$regex/); ``` I want...
Using [eval](http://perldoc.perl.org/functions/eval.html) can help you here. Take a look at the following code it can precompile a regexp that's ready to be used latter: ``` my $compiled_regexp; my $regexp = '^\d+$stored_regexp$'; my $stored_regexp = 'a'; eval "\$compiled_regexp = qr/$regexp/;"; print "$compiled_rege...
527,805
<p>Need a little advice here. We do some windows mobile development using the .NET Compact framework and SQL CE on the mobile along with a central SQL 2005 database at the customers offices. Currently we synchronize the data using merge replication technology.</p> <p>Lately we've had some annoying problems with sync...
[ { "answer_id": 527841, "author": "Emmanuel Rodriguez", "author_id": 59223, "author_profile": "https://Stackoverflow.com/users/59223", "pm_score": 3, "selected": true, "text": "<p>Using <a href=\"http://perldoc.perl.org/functions/eval.html\" rel=\"nofollow noreferrer\">eval</a> can help y...
2009/02/09
[ "https://Stackoverflow.com/questions/527805", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32714/" ]
Need a little advice here. We do some windows mobile development using the .NET Compact framework and SQL CE on the mobile along with a central SQL 2005 database at the customers offices. Currently we synchronize the data using merge replication technology. Lately we've had some annoying problems with synchronization ...
Using [eval](http://perldoc.perl.org/functions/eval.html) can help you here. Take a look at the following code it can precompile a regexp that's ready to be used latter: ``` my $compiled_regexp; my $regexp = '^\d+$stored_regexp$'; my $stored_regexp = 'a'; eval "\$compiled_regexp = qr/$regexp/;"; print "$compiled_rege...
527,811
<p>how could i vertically center a <code>&lt;div&gt;</code> within a <code>&lt;div&gt;</code> ?</p> <p>my code so far:</p> <pre><code>&lt;div style="height:322px;overflow:auto;"&gt; &lt;div style="border: Solid 1px #999999;padding:5px;"&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>i have tried "top:50%;" a...
[ { "answer_id": 527823, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": 3, "selected": false, "text": "<p>It's non-trivial, there can be caveats, and it's not something CSS handles well at this point.</p>\n\n<p>It <em>is</em...
2009/02/09
[ "https://Stackoverflow.com/questions/527811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
how could i vertically center a `<div>` within a `<div>` ? my code so far: ``` <div style="height:322px;overflow:auto;"> <div style="border: Solid 1px #999999;padding:5px;"> </div> </div> ``` i have tried "top:50%;" and "vertical-align:middle;" without success **EDIT:** okay so it's been discussed a lot. a...
In short, you're stuffed. More on this in a recent question I asked [Can you do this HTML layout without using tables?](https://stackoverflow.com/questions/522928/can-you-do-this-html-layout-without-using-tables) Basically the CSS fanatics need to get a grip and realize there's simply some things you can't do (or can't...
527,819
<p>How do I write a sub-select in LINQ.</p> <p>If I have a list of customers and a list of orders I want all the customers that have no orders.</p> <p>This is my pseudo code attempt:</p> <pre><code> var res = from c in customers where c.CustomerID ! in (from o in orders select o.CustomerID) select c </code></p...
[ { "answer_id": 527835, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": false, "text": "<p>If this is database-backed, try using navigation properties (if you have them defined):</p>\n\n<pre><code>var res ...
2009/02/09
[ "https://Stackoverflow.com/questions/527819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/230/" ]
How do I write a sub-select in LINQ. If I have a list of customers and a list of orders I want all the customers that have no orders. This is my pseudo code attempt: ``` var res = from c in customers where c.CustomerID ! in (from o in orders select o.CustomerID) select c ```
How about: ``` var res = from c in customers where !orders.Select(o => o.CustomerID).Contains(c.CustomerID) select c; ``` Another option is to use: ``` var res = from c in customers join o in orders on c.CustomerID equals o.customerID into customerOrder...
527,821
<p>I've set up Textpattern's hak_tinymce plugin on a website I run, and it works great in Firefox, Chrome, Safari and Opera. However, in IE the content area is gray (e.g. it just isn't there), and the Javascript fails with this error:</p> <pre><code>Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0;...
[ { "answer_id": 528091, "author": "Ramuns Usovs", "author_id": 2952, "author_profile": "https://Stackoverflow.com/users/2952", "pm_score": 1, "selected": false, "text": "<p>Well, you could try to <a href=\"http://blogs.msdn.com/ie/archive/2004/10/26/247912.aspx\" rel=\"nofollow noreferrer...
2009/02/09
[ "https://Stackoverflow.com/questions/527821", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1606/" ]
I've set up Textpattern's hak\_tinymce plugin on a website I run, and it works great in Firefox, Chrome, Safari and Opera. However, in IE the content area is gray (e.g. it just isn't there), and the Javascript fails with this error: ``` Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6...
The answer turned out to be a bug in hak\_tinymce, not in tinyMCE itself. hak\_tinymce specifies the height of the text area in a Javascript array using quotes around the value, like this: ``` somesetting: "somevalue", height:"420", ``` When tinyMCE tries to do arithmetic on the height value, it somehow turns into a...
527,833
<p>After git clone, the config in the new repo looks like:</p> <pre><code>remote.origin.url=&lt;some url&gt; remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* branch.master.remote=origin branch.master.merge=refs/heads/master </code></pre> <p>Then, I can execute "git pull" and "git push". But I'm interested in o...
[ { "answer_id": 529635, "author": "Emil Sit", "author_id": 55284, "author_profile": "https://Stackoverflow.com/users/55284", "pm_score": 3, "selected": false, "text": "<p>I'm not sure you can actually do this in git today. The implementation of git-fetch (in builtin-fetch.c) and git-push...
2009/02/09
[ "https://Stackoverflow.com/questions/527833", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16135/" ]
After git clone, the config in the new repo looks like: ``` remote.origin.url=<some url> remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* branch.master.remote=origin branch.master.merge=refs/heads/master ``` Then, I can execute "git pull" and "git push". But I'm interested in only do "git pull", because I wan...
Looks like ``` git config remote.origin.receivepack /bin/false ``` Makes push to remote origin fail.
527,839
<p>I have an issue executing a package via the API at Microsoft.SqlServer.Dts.Runtime. I have 4 SQL servers that can potentially execute my package in 2 clusters. On the passive nodes in each cluster, execution fails - reported error is that SSIS evaluation period has expired. On the active nodes, it works fine. I ...
[ { "answer_id": 528479, "author": "ThorHalvor", "author_id": 63243, "author_profile": "https://Stackoverflow.com/users/63243", "pm_score": 1, "selected": false, "text": "<p>Check what version of DTEXEC you are using as default (start-run: cmd, dtexec). I had an error a while ago when i ha...
2009/02/09
[ "https://Stackoverflow.com/questions/527839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36852/" ]
I have an issue executing a package via the API at Microsoft.SqlServer.Dts.Runtime. I have 4 SQL servers that can potentially execute my package in 2 clusters. On the passive nodes in each cluster, execution fails - reported error is that SSIS evaluation period has expired. On the active nodes, it works fine. I don't t...
Bingo; SSIS tells which edition it is by looking at the registry key at ``` HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\90 ``` Our server hardening process removed the inherited permission for the users group to have read access to this key. Instead of giving an error that it couldn't read this key, ...
527,851
<p>messagebox (handle, 'do you really want to exit?', 'are you sure?', 1);</p> <p>in this button there are two things, what the user can do. ok and cancel. what code do i have to write, that the button closes the program at "ok" and ends the dialog, when pressing cancel?</p>
[ { "answer_id": 527886, "author": "mghie", "author_id": 30568, "author_profile": "https://Stackoverflow.com/users/30568", "pm_score": 2, "selected": false, "text": "<p>First, make sure that the buttons in the message box match the text. So if the text is \"Do you really want to exit?\" th...
2009/02/09
[ "https://Stackoverflow.com/questions/527851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61910/" ]
messagebox (handle, 'do you really want to exit?', 'are you sure?', 1); in this button there are two things, what the user can do. ok and cancel. what code do i have to write, that the button closes the program at "ok" and ends the dialog, when pressing cancel?
Delphi provides better solutions for showing a messagebox. I should use the MessageDlg function. The return value of the MessageDlg (and MessageBox) function indicates the users choice. So you when you place a yes button on the MessageDlg, the return value will be mrYes when the user presses the Yes button. So your co...
527,860
<p>I thought this would be simple, but searching Google didn't seem to help.</p> <p>I'm basically trying to write a function which will return a ratio as a string (eg 4:3) when supplies with two integers (eg 800 and 600).</p> <pre><code>string GetRatio(Int A, Int B) { // Code I'm looking for return Ratio; } <...
[ { "answer_id": 527871, "author": "Tomas Pajonk", "author_id": 4694, "author_profile": "https://Stackoverflow.com/users/4694", "pm_score": 3, "selected": false, "text": "<p>Are you basically trying to get the greatest common denominator - GCD for the two numbers and then dividing them by ...
2009/02/09
[ "https://Stackoverflow.com/questions/527860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383/" ]
I thought this would be simple, but searching Google didn't seem to help. I'm basically trying to write a function which will return a ratio as a string (eg 4:3) when supplies with two integers (eg 800 and 600). ``` string GetRatio(Int A, Int B) { // Code I'm looking for return Ratio; } ```
You can simplify fractions by dividing numerator and denominator by their [GCD](http://en.wikipedia.org/wiki/Greatest_common_divisor): ``` var gcd = GCD(A, B); return string.Format("{0}:{1}", A / gcd, B / gcd) ``` And a very basic function for calculating the GCD, using the [Euclidean algorithm](http://en.wikipedia....
527,861
<p>As a web developer you often run into problems that might be solved very easily if there was something like value calculation.</p> <p>I've often wondered why it is not possible to do something like this in CSS:</p> <pre><code>line-height: (height / 2)px; </code></pre> <p>This would solve some problems you run int...
[ { "answer_id": 528048, "author": "okoman", "author_id": 35903, "author_profile": "https://Stackoverflow.com/users/35903", "pm_score": 4, "selected": true, "text": "<p>I'd say it is because CSS just defines how something is displayed by the browser. There is no flow of information back to...
2009/02/09
[ "https://Stackoverflow.com/questions/527861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9535/" ]
As a web developer you often run into problems that might be solved very easily if there was something like value calculation. I've often wondered why it is not possible to do something like this in CSS: ``` line-height: (height / 2)px; ``` This would solve some problems you run into when you want to vertical align...
I'd say it is because CSS just defines how something is displayed by the browser. There is no flow of information back to the style sheets, or to say it in other words: CSS is not dynamic. If you know the height of an element and want to change it everytime the page is displayed you can generate a style sheet with PHP...
527,862
<p>Does anyone know how to retrieve an iframe top position within a page for IE6 using JavaScript?</p> <p>The following code works for IE7: window.frames(0).screenTop</p> <p>but the same code in IE6 retrieves the wrong value (far too high).</p> <p>Any ideas?</p>
[ { "answer_id": 528266, "author": "geowa4", "author_id": 50214, "author_profile": "https://Stackoverflow.com/users/50214", "pm_score": 0, "selected": false, "text": "<p>You might wish to use <code>offsetTop</code>. Of course, you'll have to loop, adding the <code>offsetParent</code>'s <co...
2009/02/09
[ "https://Stackoverflow.com/questions/527862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Does anyone know how to retrieve an iframe top position within a page for IE6 using JavaScript? The following code works for IE7: window.frames(0).screenTop but the same code in IE6 retrieves the wrong value (far too high). Any ideas?
> > Does anyone know how to retrieve an iframe top position within a page for IE6 using JavaScript? > > > The same way as for any other element, using offsetTop (and adding up offsetTop from any offsetParent ancestors). It doesn't matter that it's an <iframe> element. ``` var el= document.getElementsByTagName('if...
527,866
<p>I am having problems with getting a HTML editor working. We are using “contentEditable” to implement it, however when any paragraph formatting option is done without contents selected, IE removes the ID from one of the divs in the page.</p> <p>The problem repeats for me with the HTML, </p> <ol> <li>just save it t...
[ { "answer_id": 527925, "author": "Gary Green", "author_id": 63523, "author_profile": "https://Stackoverflow.com/users/63523", "pm_score": 0, "selected": false, "text": "<p>IDs are case sensitive. Try MAINCONTENTS instead of MainContents.</p>\n" }, { "answer_id": 527959, "auth...
2009/02/09
[ "https://Stackoverflow.com/questions/527866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57159/" ]
I am having problems with getting a HTML editor working. We are using “contentEditable” to implement it, however when any paragraph formatting option is done without contents selected, IE removes the ID from one of the divs in the page. The problem repeats for me with the HTML, 1. just save it to a file, 2. then ope...
Thanks for everyone’s help, anyone thinking of using “contentEditable” should read the other answers to my question and then think **very hard** before using “contentEditable”. I have found that if I use an iframe e.g. ``` <iframe id=EditorIFrame > </iframe> ``` And create the div that is editable in the iframe eg ...
527,887
<p>Working with a program that uses 16bytes 4v4 one byte matrices :</p> <pre><code>unsigned char matrix[4][4]; </code></pre> <p>and a few 256bytes 16v16 one byte matrices:</p> <pre><code>unsigned char bigMatrix[16][16]; </code></pre> <p>Very often due to data manipulation I am forced to loop column wise in the prog...
[ { "answer_id": 527897, "author": "jalf", "author_id": 33213, "author_profile": "https://Stackoverflow.com/users/33213", "pm_score": 5, "selected": true, "text": "<p>It makes no difference. The data is laid out in the exact same way in either case, and is accessed in the same way too. I'd...
2009/02/09
[ "https://Stackoverflow.com/questions/527887", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62570/" ]
Working with a program that uses 16bytes 4v4 one byte matrices : ``` unsigned char matrix[4][4]; ``` and a few 256bytes 16v16 one byte matrices: ``` unsigned char bigMatrix[16][16]; ``` Very often due to data manipulation I am forced to loop column wise in the program making cache misses. Will the performance im...
It makes no difference. The data is laid out in the exact same way in either case, and is accessed in the same way too. I'd be surprised if it didn't generate exactly the same assembly, even. However, with a 256byte table, you're unlikely to get cache misses in any case. The CPU's L1 cache is typically between 32 and ...
527,902
<p>I've got a base class which is compatible with XML serialization and a derived class which implements IXmlSerializable.</p> <p>In this example, the base class does implement IXmlSerializable:</p> <pre><code> using System.Diagnostics; using System.Text; using System.Xml; using System.Xml.Schema; using System.Xml.Se...
[ { "answer_id": 527916, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": true, "text": "<p>\" This prevents using base.Read/WriteXml.\"</p>\n\n<p>Typically, if the base-class implemented <code>IXmlSerializa...
2009/02/09
[ "https://Stackoverflow.com/questions/527902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39590/" ]
I've got a base class which is compatible with XML serialization and a derived class which implements IXmlSerializable. In this example, the base class does implement IXmlSerializable: ``` using System.Diagnostics; using System.Text; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; namespa...
" This prevents using base.Read/WriteXml." Typically, if the base-class implemented `IXmlSerializable`, you might make it a `virtual` method so that the concrete version is used. Typically, you'd also use explicit implementation (rather than public properties) - perhaps with some `protected virtual` methods for the im...
527,919
<p>Good morning,</p> <p>I am currently writing a python library. At the moment, modules and classes are deployed in an unorganized way, with no reasoned design. As I approach a more official release, I would like to reorganize classes and modules so that they have a better overall design. I drew a diagram of the impor...
[ { "answer_id": 527943, "author": "Ali Afshar", "author_id": 28380, "author_profile": "https://Stackoverflow.com/users/28380", "pm_score": 0, "selected": false, "text": "<p>The question is very vague.</p>\n\n<p>You can achieve this by having base/core things that import nothing from the r...
2009/02/09
[ "https://Stackoverflow.com/questions/527919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/78374/" ]
Good morning, I am currently writing a python library. At the moment, modules and classes are deployed in an unorganized way, with no reasoned design. As I approach a more official release, I would like to reorganize classes and modules so that they have a better overall design. I drew a diagram of the import dependen...
**"I drew a diagram of the import dependencies, and I was planning to aggregate classes by layer level."** Python must read like English (or any other natural language.) An import is a first-class statement that should have real meaning. Organizing things by "layer level" (whatever that is) should be clear, meaningfu...
527,947
<p>What is the difference between <code>InvokeRequired</code> and <code>somecontrol.InvokeRequired</code>?</p> <p>like this,</p> <pre><code>delegate void valueDelegate(string value); private void SetValue(string value) { if (InvokeRequired) { BeginInvoke(new valueDelegate(SetValue),value); } else ...
[ { "answer_id": 527965, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "<p>The first version checks the thread responsible for <em>this</em> control. The second version checks the thread respon...
2009/02/09
[ "https://Stackoverflow.com/questions/527947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What is the difference between `InvokeRequired` and `somecontrol.InvokeRequired`? like this, ``` delegate void valueDelegate(string value); private void SetValue(string value) { if (InvokeRequired) { BeginInvoke(new valueDelegate(SetValue),value); } else { someControl.Text = value; } ...
The first version checks the thread responsible for *this* control. The second version checks the thread responsible for `someControl`. (And ditto for which control's thread they then delegate the invocation to.) They could potentially be different - although they really *shouldn't* be if the two controls are in the s...
527,948
<p>I just learned how to integrate StyleCop into Visual Studio. Now it runs every build and its errors appears as warnings. Excelent!</p> <p>Now I just want to do the same thing with FxCop, but even installing MSBuild Community Tasks and adding to the proj file:</p> <pre><code> &lt;Import Project="$(MSBuildExtensions...
[ { "answer_id": 527965, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "<p>The first version checks the thread responsible for <em>this</em> control. The second version checks the thread respon...
2009/02/09
[ "https://Stackoverflow.com/questions/527948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48465/" ]
I just learned how to integrate StyleCop into Visual Studio. Now it runs every build and its errors appears as warnings. Excelent! Now I just want to do the same thing with FxCop, but even installing MSBuild Community Tasks and adding to the proj file: ``` <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTa...
The first version checks the thread responsible for *this* control. The second version checks the thread responsible for `someControl`. (And ditto for which control's thread they then delegate the invocation to.) They could potentially be different - although they really *shouldn't* be if the two controls are in the s...
527,953
<p>Do <strong>out</strong> parameters in <strong>C#</strong> have any performance implications I should know about? (Like exceptions)</p> <p>I mean, is it a good idea to have a method with an <code>out</code> parameter in a loop that will run a couple of million times a second?</p> <p>I know it's ugly but I am using ...
[ { "answer_id": 527967, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 3, "selected": false, "text": "<p>There are no performance implications. <code>out</code> is basically the same as any old argument passing, from a ...
2009/02/09
[ "https://Stackoverflow.com/questions/527953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8954/" ]
Do **out** parameters in **C#** have any performance implications I should know about? (Like exceptions) I mean, is it a good idea to have a method with an `out` parameter in a loop that will run a couple of million times a second? I know it's ugly but I am using it the same way as `Int32.TryParse` is using them - re...
I doubt that you'll find any significant performance penalty to using an `out` parameter. You've got to get information back to the caller somehow or other - `out` is just a different way of doing it. You may find there's *some* penalty if you use the out parameter extensively within the method, as it may well mean an ...
527,955
<p>I am working on a file upload in ASP.NET. I used <code>&lt;input type=file id=upload&gt;</code> and <code>&lt;input type=button id="btnupload" value="File Upload"&gt;</code></p> <p>I want to upload the file in JavaScript. The update panel does not work, I do not want it to postback and refresh the page.</p> <p>tha...
[ { "answer_id": 527984, "author": "Christoph", "author_id": 48015, "author_profile": "https://Stackoverflow.com/users/48015", "pm_score": -1, "selected": false, "text": "<p>If you want to prevent the page from being refreshed, send a <code>204 No Content</code> HTTP header.</p>\n" }, ...
2009/02/09
[ "https://Stackoverflow.com/questions/527955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64135/" ]
I am working on a file upload in ASP.NET. I used `<input type=file id=upload>` and `<input type=button id="btnupload" value="File Upload">` I want to upload the file in JavaScript. The update panel does not work, I do not want it to postback and refresh the page. thanks but If you have code related to fileUpload in j...
You can use jQuery and [jQuery form plugin](http://malsup.com/jquery/form/). I used this combination for few project and i had no problems, even for big files (10mb) ``` <form action="form.asp" method="post"> ....... </form> $('form').submit(function(){ $(this).ajaxSubmit(function(data){ $('#updateDiv').html(data);...
527,972
<p>I know <a href="http://msdn.microsoft.com/en-us/library/system.environment.tickcount.aspx" rel="nofollow noreferrer">Environment.TickCount</a> exist but I have a big problem with that, it's limited to 25 days.</p> <p>what would be a good alternative that require no external module/dll and would work in a vanilla in...
[ { "answer_id": 527986, "author": "Anton Gogolev", "author_id": 60188, "author_profile": "https://Stackoverflow.com/users/60188", "pm_score": 2, "selected": true, "text": "<p>Plenty of choices.</p>\n\n<pre><code>public TimeSpan SystemUpTime()\n{\n PerformanceCounter upTime = \n ...
2009/02/09
[ "https://Stackoverflow.com/questions/527972", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40868/" ]
I know [Environment.TickCount](http://msdn.microsoft.com/en-us/library/system.environment.tickcount.aspx) exist but I have a big problem with that, it's limited to 25 days. what would be a good alternative that require no external module/dll and would work in a vanilla install of windows server 2003? thanks
Plenty of choices. ``` public TimeSpan SystemUpTime() { PerformanceCounter upTime = new PerformanceCounter("System", "System Up Time"); // You've got to call this twice. First time it returns 0 // and the second time it returns the real info. upTime.NextValue(); return TimeSpan.FromSe...
527,973
<p>As part of a course assignment i need to write an exploit code to cause a buffer overflow and execute code that is present on stack.</p> <p>I have turned off the stack randomiztion by the following command: sysctl -w kernel.randomize_va_space=0 However, i am unable to find a way to turn off the stack execution prot...
[ { "answer_id": 2196893, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "<p>You probably want to compile with the <code>-z execstack</code> flag in your GCC compilation, along with <code>-fno-stack-...
2009/02/09
[ "https://Stackoverflow.com/questions/527973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/60103/" ]
As part of a course assignment i need to write an exploit code to cause a buffer overflow and execute code that is present on stack. I have turned off the stack randomiztion by the following command: sysctl -w kernel.randomize\_va\_space=0 However, i am unable to find a way to turn off the stack execution protection. ...
You probably want to compile with the `-z execstack` flag in your GCC compilation, along with `-fno-stack-protector` (to disable GCC's SSP/Propolice stack protection), i.e: ``` gcc -fno-stack-protector -z execstack -o vuln vuln.c ``` Everything should probably turn out jake after this. Note that `sysctl -w kernel.ra...