qid int64 4 19.1M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
394,321 | <p>I'm looking for examples of specifying files in a tree structure, for example, for specifying the set of files to search in a grep tool. I'd like to be able to include and exclude files and directories by name matches. I'm sure there are examples out there, but I'm having a hard time finding them. </p>
<p>Here's an example of a possible syntax:</p>
<pre><code>*.py *.html
*.txt *.js
-*.pyc
-.svn/
-*combo_*.js
</code></pre>
<p>(this would mean include file with extensions .py .html .txt .js, exclude .pyc files, anything under a .svn directory, and any file matching <em>combo_</em>.js)</p>
<p>I know I've seen these sorts of specifications in other tools before. Is this ringing any bells for anyone?</p>
| [
{
"answer_id": 394347,
"author": "dmckee --- ex-moderator kitten",
"author_id": 2509,
"author_profile": "https://Stackoverflow.com/users/2509",
"pm_score": 1,
"selected": false,
"text": "find primaries''\n and find ./ \\( -name *.{py,html,txt,js,pyc} -or \\\n -name *combo... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14343/"
] |
394,330 | <p><em>[I'm just starting with Ruby, but "no question is ever too newbie," so I trudge onwards...]</em></p>
<p>Every tutorial and book I see goes from Ruby with the interactive shell to Ruby on Rails. I'm not doing Rails (yet), but I don't want to use the interactive shell. I have a class file (first_class.rb) and a Main (main.rb). If I run the main.rb, I of course get the <code>uninitialized constant FirstClass</code>. <strong>How do I tell ruby about the <code>first_class.rb</code>?</strong></p>
| [
{
"answer_id": 394338,
"author": "frankodwyer",
"author_id": 42404,
"author_profile": "https://Stackoverflow.com/users/42404",
"pm_score": 4,
"selected": true,
"text": "require 'first_class'\n"
},
{
"answer_id": 395997,
"author": "Sophie Alpert",
"author_id": 49485,
"... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8047/"
] |
394,349 | <pre><code>Array 1 | Array 2
=================
1 | 2
2 | 3
3 | 4
5 | 5
| 6
</code></pre>
<p>What is a good algorithm to 'sync' or combine Array 2 into Array 1? The following needs to happen:</p>
<ol>
<li>Integers in Array 2 but not in Array 1 should be added to Array 1.</li>
<li>Integers in both Arrays can be left alone.</li>
<li>Integers in Array 1 but not in Array 2 should be removed from Array 1.</li>
</ol>
<p>I'll eventually be coding this in Obj-C, but I'm really just looking for a pseudo-code representation of an efficient algorithm to solve this problem so feel free to suggest an answer in whatever form you'd like.</p>
<p>EDIT:</p>
<p>The end result I need is bit hard to explain without giving the backstory. I have a Cocoa application that has a Core Data entity whose data needs to be updated with data from a web service. I cannot simply overwrite the contents of Array 1 (the core data entity) with the content of Array 2 (the data parsed from the web into an array) because the Array 1 has relationships with other core data entities in my application. So basically it is important that integers contained in both Arrays are not overwritten in array one. </p>
| [
{
"answer_id": 394366,
"author": "Yuliy",
"author_id": 47527,
"author_profile": "https://Stackoverflow.com/users/47527",
"pm_score": 3,
"selected": false,
"text": "Array1 = Array2.Clone()"
},
{
"answer_id": 394387,
"author": "Gant",
"author_id": 12460,
"author_profile... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46540/"
] |
394,372 | <p>Is there a way to find when the activeApplication changes in OSX through Python and AppKit? I know how to find out launchedApplication and activeApplication ( please refer to my other question here: <a href="https://stackoverflow.com/questions/373020/finding-the-current-active-window-in-mac-os-x-using-python">Finding the Current Active Window in Mac OS X using Python</a> )</p>
| [
{
"answer_id": 394416,
"author": "Dirk Stoop",
"author_id": 24051,
"author_profile": "https://Stackoverflow.com/users/24051",
"pm_score": 0,
"selected": false,
"text": "def awakeFromNib(self):\n NSDistributedNotificationCenter.defaultCenter().addObserver_selector_name_object_(\n ... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40195/"
] |
394,375 | <p>How do I get the row count of an internal table? I guess that I can loop on it. But there must be a saner way.</p>
<p>I don't know if it makes a difference but the code should run on 4.6c version.</p>
| [
{
"answer_id": 394386,
"author": "Thorsten",
"author_id": 25320,
"author_profile": "https://Stackoverflow.com/users/25320",
"pm_score": 7,
"selected": true,
"text": " DESCRIBE TABLE <itab-Name> LINES <variable>\n"
},
{
"answer_id": 411952,
"author": "user51478",
"author_i... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25737/"
] |
394,382 | <p>I am trying to program an Excel module where it dynamically inserts code in new objects in a form that is created at design time.</p>
<p>I am using this code where "Code" contains a string with the actual code that should go into the DstrFiles object.</p>
<pre><code>Dim DstrFiles As Object
Set DstrFiles = ThisWorkbook.VBProject.VBComponents("DistributeFiles")
With DstrFiles.CodeModule
.InsertLines .CountOfLines + 1, Code
End With
</code></pre>
<p>My problem is that when I use the .InsertLines, McAfee removes the entire Code from my module, is there a way to work around this?</p>
<p>First I create the label with:</p>
<pre><code>Form1.Controls.Add("Forms.Label.1", "Label1", True)
</code></pre>
<p>Then I use the .InsertLines to create some code to go with the Label. </p>
<p>For instance, I want the background color of the label to turn red when someone clicks on it. This has been very easy to accomplish with the ".InsertLines".</p>
<p>An ugly way to work around this is to just create a bunch of code beforehand that is ready in the background and then limit the amount of labels that may be created on the fly. - I hope it won't come to that.</p>
<p>I have been googeling around, and this seems to be a known problem with McAfee.</p>
<p>Do anyone know a way to create a dynamic user form that can add code to new labels or button that are added with the Contrls.Add method? </p>
| [
{
"answer_id": 423099,
"author": "Joel Spolsky",
"author_id": 4,
"author_profile": "https://Stackoverflow.com/users/4",
"pm_score": 4,
"selected": true,
"text": "UserForm1.Controls.Add(\"Forms.Label.1\", \"foo\", True)\n WithEvents Public WithEvents a As MSForms.Label\n\nPrivate Sub a_Cl... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49280/"
] |
394,402 | <p>If I'm looking to use Core Animation to fade a view in and out of display -- is it good practice to have the UIView in the same NIB as the view that it is being drawn into? Should I build the view in another NIB file and load it in from there? I'm looking to animate three small views into display simultaneously upon a user action. I wanted to construct the views in IB. Looking for a best practice type response here.</p>
| [
{
"answer_id": 394856,
"author": "Cocoatype",
"author_id": 49345,
"author_profile": "https://Stackoverflow.com/users/49345",
"pm_score": 3,
"selected": true,
"text": "[UIView beginAnimations:@\"fade\" context:nil];\n[UIView setAnimationDuration:1.0];\nmyViewOne.alpha = 1.0;\nmyViewTwo.al... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394402",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40882/"
] |
394,439 | <p>I'd like to be able to lock directory access under windows.
The following code work greatly with file or directory under POSIX system:</p>
<pre><code>def flock(fd, blocking=False, exclusive=False):
if exclusive:
flags = fcntl.LOCK_EX
else:
flags = fcntl.LOCK_SH
if not blocking:
flags |= fcntl.LOCK_NB
fcntl.flock(fd, flags)
</code></pre>
<p>But I only find a way to perform lock access for file, not directory with the following code:</p>
<pre><code>def flock(fd, blocking=False, exclusive=False):
if blocking:
flags = msvcrt.LK_NBLCK
else:
flags = msvcrt.LK_LOCK
msvcrt.locking(fd.fileno(), flags, os.path.getsize(fd.name))
</code></pre>
<p>Have you got any idea how to improve this code and be able to lock directory access ?</p>
<p>Bertrand</p>
| [
{
"answer_id": 394464,
"author": "kylebrooks",
"author_id": 49284,
"author_profile": "https://Stackoverflow.com/users/49284",
"pm_score": 0,
"selected": false,
"text": "for file in os.listdir(dir):\n f = open(file)\n flock(f)\n"
},
{
"answer_id": 394813,
"author": "Bertrand",... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11563/"
] |
394,440 | <p>So I have this code that takes care of command acknowledgment from remote computers, sometimes (like once in 14 days or something) the following line throws a null reference exception:</p>
<pre><code>computer.ProcessCommandAcknowledgment( commandType );
</code></pre>
<p>What really bugs me is that I check for a null reference before it, so I have <strong>no</strong> idea whats going on.
Here's the full method for what its worth: </p>
<pre><code> public static void __CommandAck( PacketReader reader, SocketContext context )
{
string commandAck = reader.ReadString();
Type commandType = Type.GetType( commandAck );
Computer computer = context.Client as Computer;
if (computer == null)
{
Console.WriteLine("Client already disposed. Couldn't complete operation");
}
else
{
computer.ProcessCommandAcknowledgment( commandType );
}
}
</code></pre>
<p>Any clues?</p>
<p>Edit: ProcessCommandAcknowledgment:</p>
<pre><code> public void ProcessCommandAcknowledgment( Type ackType )
{
if( m_CurrentCommand.GetType() == ackType )
{
m_CurrentCommand.Finish();
}
}
</code></pre>
| [
{
"answer_id": 394449,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 2,
"selected": false,
"text": "ReadString() m_CurrentCommand ProcessCommandAcknowledgment"
},
{
"answer_id": 394499,
"author": "Charlie Ma... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15409/"
] |
394,450 | <p>Is it possible to animate a change in css using jquery? </p>
<p>If someone would be so kind as to provide me with an example i would be much obliged.</p>
<p>Essentially, i am trying to animate the sprites technique by manipulating the background-image in the css using jQuery. The goal is to animate the hover so that I get a nice fade instead of just the abrupt switch produced by the code below.</p>
<p>Here is where I'm at: </p>
<p>HTML: </p>
<pre><code><h1 id="solomon">Solomon</h1>
</code></pre>
<p>CSS: </p>
<pre><code>body#default h1 {
text-indent: -9999px;
display: inline-block;
height: 213px;
}
body#default h1#solomon {
background: transparent url(/images/S.gif) center top no-repeat;
width: 183px;
margin: 100px 0 0 216px;
}
</code></pre>
<p>JQUERY: </p>
<pre><code>$(function() {
$('h1').hover(function() {
$(this).stop().css('background-position', 'center bottom');
}, function() {
$(this).stop().css('background-position', 'center top');
});
});
</code></pre>
<p>Right now the it works fine, but there is no pretty animation on hover. I want to know how to animate the effect of switching the background-image placement.</p>
<p>Thanks to whomever takes a shot at this. :) </p>
<hr>
<p>i'm hoping someone can answer my question without pointing me to a tutorial? my issue with the tutorials is that they all force me to change my html which i am pretty locked into at this point. </p>
<p>also, why doesn't the animate function work in my above example (@CMS)? </p>
<p>thanks for your help everyone! :)</p>
| [
{
"answer_id": 394462,
"author": "Andreas Grech",
"author_id": 44084,
"author_profile": "https://Stackoverflow.com/users/44084",
"pm_score": 2,
"selected": false,
"text": "Two Image Technique"
}
] | 2008/12/26 | [
"https://Stackoverflow.com/questions/394450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44443/"
] |
394,465 | <p>This must be a very simple question, but I don't seem to be able to figure out.</p>
<p>I'm using apache + mod_wsgi to host my python application, and I'd like to get the post content submitted in one of the forms -however, neither the environment values, nor sys.stdin contains any of this data. Mind giving me a quick hand?</p>
<p>Edit:
Tried already: </p>
<ul>
<li>environ["CONTENT_TYPE"] = 'application/x-www-form-urlencoded' (no data)</li>
<li>environ["wsgi.input"] seems a plausible way, however, both environ["wsgi.input"].read(), and environ["wsgi.input"].read(-1) returns an empty string (yes, content has been posted, and environ["request_method"] = "post"</li>
</ul>
| [
{
"answer_id": 394543,
"author": "nosklo",
"author_id": 17160,
"author_profile": "https://Stackoverflow.com/users/17160",
"pm_score": 6,
"selected": true,
"text": "from pprint import pformat\n\ndef application(environ, start_response):\n # show the environment:\n output = ['<pre>']... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9440/"
] |
394,470 | <p>I'm trying to change the alt of the image, I'm clicking by
selecting the image's class (<strong><em><code>add_answer</code></em></strong>)</p>
<p><strong>Note:</strong> <strong><em><code>.add_answer</code></strong> shows up multiple times inside different containing <code>div</code>'s</em></p>
<pre><code>jQuery(function(){ // Add Answer
jQuery(".add_answer").click(function(){
var count = $(this).attr("alt");
count++;
$('.a_type_'+count+'').show();
$(this).parents("div:first").$('.add_answer').attr("alt", count);
});
});
</code></pre>
<p>This line doesn't seem to be working, how do I select this <strong><code>add_answer</code></strong> class by way of it's parent <code>div</code></p>
<pre><code>$(this).parents("div:first").$('.add_answer').attr("alt", count);
</code></pre>
<p>Anyone else have an idea?</p>
<p>I'm trying having trouble decreasing the <code>alt</code> value on the <code>.add_answer</code> image when <code>.destroy_answer</code> is clicked</p>
<pre><code>jQuery(function(){ // Hide Answer
jQuery(".destroy_answer").click(function(){
$(this).parents("div:first").hide();
var count = $('.add_answer').attr("alt");
count--;
$('.add_answer',$(this).parent('div:first')).attr('alt',count);
});
});
</code></pre>
<p>Problem line:</p>
<pre><code>$('.add_answer',$(this).parent('div:first')).attr('alt',count);
</code></pre>
| [
{
"answer_id": 394474,
"author": "Andreas Grech",
"author_id": 44084,
"author_profile": "https://Stackoverflow.com/users/44084",
"pm_score": 4,
"selected": false,
"text": "$(this).parent(\"div\").find(\".add_answer\").attr(\"alt\", count);\n"
},
{
"answer_id": 394476,
"author... | 2008/12/26 | [
"https://Stackoverflow.com/questions/394470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48973/"
] |
394,488 | <p>I need to convert an 8-bit IplImage to a 32-bits IplImage. Using documentation from all over the web I've tried the following things:</p>
<pre><code>// general code
img2 = cvCreateImage(cvSize(img->width, img->height), 32, 3);
int height = img->height;
int width = img->width;
int channels = img->nChannels;
int step1 = img->widthStep;
int step2 = img2->widthStep;
int depth1 = img->depth;
int depth2 = img2->depth;
uchar *data1 = (uchar *)img->imageData;
uchar *data2 = (uchar *)img2->imageData;
for(h=0;h<height;h++) for(w=0;w<width;w++) for(c=0;c<channels;c++) {
// attempt code...
}
// attempt one
// result: white image, two red spots which appear in the original image too.
// this is the closest result, what's going wrong?!
// see: http://files.dazjorz.com/cache/conversion.png
((float*)data2+h*step2+w*channels+c)[0] = data1[h*step1+w*channels+c];
// attempt two
// when I change float to unsigned long in both previous examples, I get a black screen.
// attempt three
// result: seemingly random data to the top of the screen.
data2[h*step2+w*channels*3+c] = data1[h*step1+w*channels+c];
data2[h*step2+w*channels*3+c+1] = 0x00;
data2[h*step2+w*channels*3+c+2] = 0x00;
// and then some other things. Nothing did what I wanted. I couldn't get an output
// image which looked the same as the input image.
</code></pre>
<p>As you see I don't really know what I'm doing. I'd love to find out, but I'd love it more if I could get this done correctly.
Thanks for any help I get!</p>
| [
{
"answer_id": 395049,
"author": "Stefan Schmidt",
"author_id": 1958045,
"author_profile": "https://Stackoverflow.com/users/1958045",
"pm_score": 4,
"selected": true,
"text": "float value = 0.5 float value = 0x0000001;"
},
{
"answer_id": 395412,
"author": "sgielen",
"auth... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13104/"
] |
394,491 | <p>I'm developing an <code>ASP.Net MVC</code> site and on it I list some bookings from a database query in a table with an <code>ActionLink</code> to cancel the booking on a specific row with a certain <code>BookingId</code> like this: </p>
<p><strong>My bookings</strong></p>
<pre><code><table cellspacing="3">
<thead>
<tr style="font-weight: bold;">
<td>Date</td>
<td>Time</td>
<td>Seats</td>
<td></td>
<td></td>
</tr>
</thead>
<tr>
<td style="width: 120px;">2008-12-27</td>
<td style="width: 120px;">13:00 - 14:00</td>
<td style="width: 100px;">2</td>
<td style="width: 60px;"><a href="/Booking.aspx/Cancel/15">cancel</a></td>
<td style="width: 80px;"><a href="/Booking.aspx/Change/15">change</a></td>
</tr>
<tr>
<td style="width: 120px;">2008-12-27</td>
<td style="width: 120px;">15:00 - 16:00</td>
<td style="width: 100px;">3</td>
<td style="width: 60px;"><a href="/Booking.aspx/Cancel/10">cancel</a></td>
<td style="width: 80px;"><a href="/Booking.aspx/Change/10">change</a></td>
</tr>
</table>
</code></pre>
<p>What would be nice is if I could use the <code>jQuery Dialog</code> to popup a message asking if the user is sure he wants to cancel the booking. I have been trying get this to work but I keep getting stuck on how to create a jQuery function that accepts parameters so that I can replace the </p>
<p><code><a href="/Booking.aspx/Cancel/10">cancel</a></code> </p>
<p>with </p>
<p><code><a href="#" onclick="ShowDialog(10)">cancel</a></code>. </p>
<p>The <code>ShowDialog</code> function would then open the dialog and also pass the paramter 10 to the dialog so that if the user clicks yes then It will post the href: <code>/Booking.aspx/Change/10</code></p>
<p>I have created the jQuery Dialog in a script like this:</p>
<pre><code>$(function() {
$("#dialog").dialog({
autoOpen: false,
buttons: {
"Yes": function() {
alert("a Post to :/Booking.aspx/Cancel/10 would be so nice here instead of the alert");},
"No": function() {$(this).dialog("close");}
},
modal: true,
overlay: {
opacity: 0.5,
background: "black"
}
});
});
</code></pre>
<p>and the dialog itself:</p>
<pre><code> <div id="dialog" title="Cancel booking">Are you sure you want to cancel your booking?</div>
</code></pre>
<p>So finally to my question: How can I accomplish this? or is there a better way of doing it?</p>
| [
{
"answer_id": 394580,
"author": "Mauricio Scheffer",
"author_id": 21239,
"author_profile": "https://Stackoverflow.com/users/21239",
"pm_score": 7,
"selected": true,
"text": "<a> $('a.cancel').click(function() { \n var a = this; \n $('#myDialog').dialog({\n buttons: {\n \"Yes\"... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/459417/"
] |
394,500 | <p>In the python program I'm writing, I've got a thread which iterates over a large structure in memory and writes it incrementally into a file-like object. I've got another thread which takes a file-like object and writes it to disk. Is there an easy way to connect the two, such that any data input from the first thread will be buffered for the second?</p>
<p>Specifically, I'm trying to pass data to subprocess.Popen(). The process will read from stdin, but you cannot pass a "file-like" object to Popen because it calls stdin.fileno() and blows up unless you have a real file.</p>
<p>Instead, you need to pass the PIPE argument to Popen, which allows you to use proc.stdin as a file-like object. But if you've already got a file-like object, there doesn't seem to be a great way to yolk the two of them together.</p>
| [
{
"answer_id": 394549,
"author": "nosklo",
"author_id": 17160,
"author_profile": "https://Stackoverflow.com/users/17160",
"pm_score": 3,
"selected": true,
"text": "shutil copyfileobj() import shutil\nimport subprocess\n\nproc = subprocess.Popen([...], stdin=subprocess.PIPE)\n\nmy_input =... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9161/"
] |
394,504 | <p>So I'm trying to load some returned html from an .aspx page but a click event needs to fire before it doing some stuff that the AJAX request depends upon. More specifically, I'm doing this. When a user types in a text field this function is run...</p>
<pre><code>function KeyPress() {
$("#" + HiddenButtonId).click();
$("#test").load("TempJumpToAJAX.aspx");
}
</code></pre>
<p>then $("#" + HiddenButtonId).click(); does sets some session data in a code behind file. Specifically...</p>
<pre><code>Session["SearchText"] = Search.Text;
</code></pre>
<p>then, $("#test").load("TempJumpToAJAX.aspx"); calls that .aspx page that returns a newly built select box...</p>
<pre><code> Response.Expires = -1;
StringBuilder builder = new StringBuilder();
builder.Append("<select id=\"testListId\" name=\"testList\" size=\"4\" style=\"width:200px;\">");
builder.Append("<option>");
builder.Append(Session["SearchText"]);
builder.Append("</option>");
builder.Append("</select>");
Response.ContentType = "text/HTML";
Response.Write(builder.ToString());
Response.End();
</code></pre>
<p>The problem is, the order seems to be screwed up it tries to append the Session["SearchText"] first, then runs the code that the click event runs. So it functions more like this...</p>
<pre><code>function KeyPress() {
$("#test").load("TempJumpToAJAX.aspx");
$("#" + HiddenButtonId).click();
}
</code></pre>
<p>Where the commands are reversed. So what in effect happens is the session variable has an empty string as opposed to what the user typed in the text box. What's odd to me is that it doesn't seem like it should have an empty string, it seems like it should have nothing since the session variable has not been initialized to anything at this point. I really have no idea what's happening. Chalk it up to inexperience I guess. Any ideas?</p>
| [
{
"answer_id": 394563,
"author": "cfbarbero",
"author_id": 2218,
"author_profile": "https://Stackoverflow.com/users/2218",
"pm_score": 3,
"selected": true,
"text": "\nfunction KeyPress() {\n $(\"#test\").load(\"TempJumpToAJAX.aspx\", {searchText: $(\"#\").val()});\n}\n"
},
{
"an... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49294/"
] |
394,514 | <p>I've downloaded the examples for both the Request and Request.HTML and cannot make either work. I unzipped them to a folder and browsed to their index.html to execute them as is, but the response is always "The request failed." with no clues as to why.</p>
<p>I've played around with them with different permutations and can get the request to complete but it always fails. Is there any way to get a reason for failure? I've tried three different browsers turned off my firewall, used relative and absolute file references but nothing works. Am I missing something glarringly obvious? I'd post the code, but it is the examples exactly as is...</p>
<p>Any help would be awesome.</p>
<p>Cheers,</p>
<p>Justin.</p>
| [
{
"answer_id": 2809960,
"author": "Daniel Linkov",
"author_id": 338174,
"author_profile": "https://Stackoverflow.com/users/338174",
"pm_score": 0,
"selected": false,
"text": "XMLHttpRequest() isSuccess Request // Determines if an XMLHttpRequest was successful or not\nhttpSuccess: fun... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
394,521 | <p>While it's my understanding that there's no fundamental reason a program written for 32-bit hardware / OSs not to run on 64-bit hardware / OSs, in practice, I've found many programs intended for 32-bit versions of Windows that will not work on 64-bit versions of Windows. Examples include a number of popular security utilities (most products from Norton and Check Point's Zone Alarm) and several games (I've been trying to get Grand Theft Auto 4 to run for a few weeks now, but to no avail - of course, that might be related to any number of other problems related to GTA4, but that's neither here nor there).</p>
<p>I've heard that a program's incompatibility might result from something as simple as not wanting to run from the "Program Files (x86)" folder, but what are some of the other reasons? Why would a virus scanner or firewall written for a 32-bit system not run on a 64-bit system? Why would a game not run when everything is theoretically backwards-compatible?</p>
| [
{
"answer_id": 394538,
"author": "Jorge Córdoba",
"author_id": 2695,
"author_profile": "https://Stackoverflow.com/users/2695",
"pm_score": 2,
"selected": false,
"text": "struct GPoint\n{\n int x;\n int y;\n}\n\n// Array of twenty GPoints\nGPoint[] myArr = malloc(20 * sizeof(GPoint);\n\... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28076/"
] |
394,552 | <p>I'm trying to write some code to work with an htdigest password file. The documentation I can find seems to claim that the format of that file is:</p>
<pre><code>user:realm:MD5(user:realm:pass)
</code></pre>
<p>If that is the case, then why doesn't this work for me? I created a file with the command line htdigest thus:</p>
<pre><code>htdigest -c test b a
</code></pre>
<p>When prompted for a password I entered 'c'. This creates a file with the contents:</p>
<pre><code>a:b:02cc8f08398a4f3113b554e8105ebe4c
</code></pre>
<p>However if I try to derive this hash I can't,</p>
<pre><code>echo a:b:c | md5
</code></pre>
<p>gives me "49d6ea7ca1facf323ca1928995420354". Is there something obvious that I'm missing here?</p>
<p>Thanks</p>
| [
{
"answer_id": 394556,
"author": "wxs",
"author_id": 12981,
"author_profile": "https://Stackoverflow.com/users/12981",
"pm_score": 2,
"selected": false,
"text": "echo a:b:c | wc\n"
},
{
"answer_id": 394558,
"author": "James Brady",
"author_id": 29903,
"author_profile"... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12981/"
] |
394,567 | <p>I have a generic list say and I want to serialize it.
I want to use a interface for the generic list which can't be serialized
so you have to use the instance. Like this
MyClass implements IMyClass.</p>
<pre><code>List<IMyClass> list = DeserializeMyClass(path); //Can't do this right
</code></pre>
<p>So have to do this</p>
<pre><code>List<MyClass> list = DeserializeMyClass(path);
</code></pre>
<p>So question is can i now cast to </p>
<pre><code>List<IMyClass> ilist = (IMyClass)list;
</code></pre>
<p>Malcolm</p>
| [
{
"answer_id": 394578,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "Listl<IMyclass> list = DeserializeMyClass(path); //Can't do this right\n List<MyClass> list = DeserializeMyClass(path);\n List... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
394,574 | <p>Write a program that take a single command line argument N and prints out the corresponding <a href="http://en.wikipedia.org/wiki/Roman_numerals" rel="nofollow noreferrer">Roman Numeral</a>.</p>
<p>Eg N = 2009 should print MMIX.</p>
<p>Let's say this should work for 0 < N < 3000.</p>
<p>(Had fun playing my first ever round of code golf with the <a href="https://stackoverflow.com/questions/392788/code-golf-christmas-edition-how-to-print-out-a-christmas-tree-of-height-n">Christmas edition</a>, and thought this could fit for New Year. Googled to see if this has come up before elsewhere and it looks like it hasn't, but let me know if this is too hard or too easy or if the rules need changing. )</p>
<p>Happy MMIX!</p>
| [
{
"answer_id": 394592,
"author": "jason",
"author_id": 45914,
"author_profile": "https://Stackoverflow.com/users/45914",
"pm_score": 4,
"selected": false,
"text": "Int32 public static class Int32Extension {\n public static string ToRomanNumeral(this int number) {\n Dictionary<i... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4812/"
] |
394,588 | <p>in terms of both parsing (serializing, deserializing) and sending packets over the network is there any good estimation of performance differences between binary and xml serialization?</p>
| [
{
"answer_id": 394597,
"author": "Dave Markle",
"author_id": 24995,
"author_profile": "https://Stackoverflow.com/users/24995",
"pm_score": 5,
"selected": true,
"text": "<person>\n <name>Dave</dave>\n <ssn>000-00-0000</ssn>\n <email1>xxxxxx/email1>\n</person>\n...\n <book name=\"bible\... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394588",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] |
394,591 | <p>I'm working on improving our group's development process, and I'm considering how best to implement Design By Contract with Test-Driven Development. It seems the two techniques have a lot of overlap, and I was wondering if anyone had some insight on the following (related) questions:</p>
<ul>
<li>Isn't it against the DRY principle to have TDD and DbC unless you're using some kind of code generator to generate the unit tests based on contracts? Otherwise, you have to maintain the contract in two places (the test and the contract itself), or am I missing something?</li>
<li>To what extent does TDD make DbC redundant? If I write tests well enough, aren't they equivalent to writing a contract? Do I only get added benefit if I enforce the contract at run time as well as through the tests?</li>
<li>Is it significantly easier/more flexible to only use TDD rather than TDD with DbC? </li>
</ul>
<p>The main point of these questions is this more general question: <strong>If we're already doing TDD properly, will we get a significant benefit for the overhead if we also use DbC?</strong></p>
<p>A couple of details, though I think the question is largely language-agnostic:</p>
<ul>
<li>Our team is very small, <10 programmers.</li>
<li>We mostly use Perl.</li>
</ul>
| [
{
"answer_id": 394999,
"author": "Jörg W Mittag",
"author_id": 2988,
"author_profile": "https://Stackoverflow.com/users/2988",
"pm_score": 5,
"selected": false,
"text": "queue.full? queue.num_entries == queue.size"
}
] | 2008/12/27 | [
"https://Stackoverflow.com/questions/394591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21632/"
] |
394,596 | <p>Does anyone know if you can obtain the following user interface components as seen in various adobe products for use in ones own product?</p>
<ul>
<li>Treeview (Adobe Acrobat)</li>
<li>Collapsable Toolbars (Adobe Photoshop, Illustrator)</li>
</ul>
| [
{
"answer_id": 394999,
"author": "Jörg W Mittag",
"author_id": 2988,
"author_profile": "https://Stackoverflow.com/users/2988",
"pm_score": 5,
"selected": false,
"text": "queue.full? queue.num_entries == queue.size"
}
] | 2008/12/27 | [
"https://Stackoverflow.com/questions/394596",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48499/"
] |
394,616 | <p>I have a JAR file named <em>helloworld.jar</em>.
In order to run it, I'm executing the following command in a command-line window:</p>
<pre class="lang-none prettyprint-override"><code>java -jar helloworld.jar
</code></pre>
<p>This works fine, but how do I execute it with double-click instead?
Do I need to install any software?</p>
| [
{
"answer_id": 394628,
"author": "Brian Kelly",
"author_id": 8252,
"author_profile": "https://Stackoverflow.com/users/8252",
"pm_score": 8,
"selected": true,
"text": "C:\\Program Files\\Java\\j2re1.4.2_04\\bin\\javaw.exe\" -jar \"%1\" %"
},
{
"answer_id": 1459206,
"author": "... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40945/"
] |
394,618 | <p>So basically, how is non-western input handled in SDL or OpenGL games or applications? Googling for it reveals <a href="http://sdl-im.csie.net/" rel="nofollow noreferrer">http://sdl-im.csie.net/</a> but that doesn't seem to be maintained or available anymore. Just to view the page I had to use the <a href="http://74.125.95.132/search?q=cache:PYYdG1HpzZ0J:sdl-im.csie.net/+sdl+input&hl=en&ct=clnk&cd=6&gl=us&client=firefox-a" rel="nofollow noreferrer">Google cache</a>. </p>
<p>To clarify, I'm not having any kind of issue in terms of the application displaying text in non-western languages to users. This is a solved problem. There are many unicode fonts available, and many different ways to process text into glyphs and then into display surfaces. </p>
<p>I run a-foul in the opposite direction. Even if my program could safely handle text data in any arbitrary encoding, there's no way for users to actually type their name if it happens to include a character that requires more than one keystroke to produce. </p>
| [
{
"answer_id": 685280,
"author": "Ivan Vučica",
"author_id": 39974,
"author_profile": "https://Stackoverflow.com/users/39974",
"pm_score": 2,
"selected": false,
"text": "SDL_EnableUNICODE() unicode SDL_keysym unicode"
}
] | 2008/12/27 | [
"https://Stackoverflow.com/questions/394618",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49287/"
] |
394,645 | <p>With regards to making a game server, it seems Erlang always comes up as a language that is "built for this kind of thing" with its scalability and concurrency features. I don't have experience in either Haskell nor Erlang, but on the surface they seem the same. Looking into Haskell's docs it seems like it has support for multiprocessor scalability and concurrency, and Haskell is said to be a more solid language and has a visibly better community. My question is, then, is Haskell considered to be as good of a solution to server building as Erlang supposedly is?</p>
| [
{
"answer_id": 395017,
"author": "Alexey Romanov",
"author_id": 9204,
"author_profile": "https://Stackoverflow.com/users/9204",
"pm_score": 3,
"selected": false,
"text": "gen_server gen_event"
}
] | 2008/12/27 | [
"https://Stackoverflow.com/questions/394645",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49018/"
] |
394,647 | <p>Say I have two repositories that were created from the same initial content. For example, if I were using git to manage my apache config files in /etc/apache2 and I ran <code>git init</code> on machine-a and machine-b separately.</p>
<p>I've since made some configuration changes to machine-b that I would like to apply to the configuration on machine-a without overwriting un-common things like hostnames, etc.</p>
<p>If I do this:</p>
<pre><code>machine-a% remote add machine-b ssh://...
machine-a% git fetch machine-b
</code></pre>
<p>I get all the commits on machine-b and GitX shows a wholy disconnected set of commits, as I would expect.</p>
<p>However, if I try to merge any of machine-b's changes I get conflicts on all modified lines.</p>
<p>For my purposes, this is good enough, but I wonder, is there a cleaner solution?</p>
| [
{
"answer_id": 395257,
"author": "Paul",
"author_id": 23356,
"author_profile": "https://Stackoverflow.com/users/23356",
"pm_score": 2,
"selected": false,
"text": "$ git checkout [localmachine bracnch]\n$ git cherry-pick [SHA1 of common commit1]\n$ git cherry-pick [SHA1 of common commit2]... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9594/"
] |
394,650 | <p>Is there a tool that I can use to see the multiple inheritance memory layout of compiled C++ code?</p>
| [
{
"answer_id": 394670,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 3,
"selected": false,
"text": "class classA { };\n\nclass classB { };\n\nclass classC : public classA, public classB {\n\n};\n\n$ g++ -fdu... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
394,652 | <p>After experiencing numerous problems with a certain media player, it got me thinking is it really acceptable to prompt the user to launch a debugger or terminate an application without any relevant information in this day and age? </p>
| [
{
"answer_id": 394664,
"author": "yuriks",
"author_id": 42029,
"author_profile": "https://Stackoverflow.com/users/42029",
"pm_score": 0,
"selected": false,
"text": "System.Exception"
}
] | 2008/12/27 | [
"https://Stackoverflow.com/questions/394652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
394,665 | <p>Does anyone know how I can best stream a webcam through an iGoogle widget? </p>
<p>My ideal is to actually be able to stream locally--that is, get a widget that allows me to display my computer's webcam. Is this possible?</p>
<p>(No, I'm not that vain. I'm using a webcam as a Security Camera, and I'd like to be able to view it, streaming, on my iGoogle console as part of an array of useful, automatic widgets that are being displayed on a wallmounted flat screen monitor.)</p>
| [
{
"answer_id": 394664,
"author": "yuriks",
"author_id": 42029,
"author_profile": "https://Stackoverflow.com/users/42029",
"pm_score": 0,
"selected": false,
"text": "System.Exception"
}
] | 2008/12/27 | [
"https://Stackoverflow.com/questions/394665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
394,692 | <p>I have a DATETIME field. I would like to select all the records that have been updated in the last week. Right now I'm using this query:</p>
<pre><code>SELECT SUM(mins_spent) as time_sum FROM todos WHERE
lastUpdate >= '2008-12-22' AND lastUpdate <='2008-12-28'
</code></pre>
<p>But the results i get seem to be different depending on time of the day, e.g on 7 PM I might get 17 hours and on 11 PM I'l get 14 hours even though it should be increasing, not decreasing. I was thinking of changing the query to:</p>
<pre><code>SELECT SUM(mins_spent) as time_sum FROM todos WHERE
lastUpdate >= '2008-12-22 00:00:00' AND lastUpdate <='2008-12-28 00:00:00'
</code></pre>
<p>Would it help at all? Suggestions please..</p>
| [
{
"answer_id": 394705,
"author": "Jonathan Lonowski",
"author_id": 15031,
"author_profile": "https://Stackoverflow.com/users/15031",
"pm_score": 4,
"selected": true,
"text": "'2008-12-22' '2008-12-22 00:00:00' 23:59:59 lastUpdate < \"2008-12-29\" INSERT DELETE UPDATE DELETE UPDATE mins_s... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49153/"
] |
394,698 | <p>Can you have cellpadding or spacing just on the top/ bottom as opposed to all (T, B, L, R) ?</p>
| [
{
"answer_id": 394703,
"author": "TRF",
"author_id": 48230,
"author_profile": "https://Stackoverflow.com/users/48230",
"pm_score": 6,
"selected": true,
"text": "td {\n padding-top: 2px;\n padding-bottom: 2px;\n}\n"
},
{
"answer_id": 394712,
"author": "Robert C. Barth",
... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394698",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] |
394,709 | <p>I am learning functional programming style. In <a href="http://channel9.msdn.com/shows/Going+Deep/Brian-Beckman-Dont-fear-the-Monads/" rel="noreferrer">Don't Fear the Monads</a>, Brian Beckman gave a brilliant introduction about Monad. He mentioned that Monad is about composition of functions so as to address complexity. </p>
<blockquote>
<p>A Monad includes a <code>unit</code> function that transfers type T to an amplified type M(T); and a Bind function that, given function from T to M(U), transforms type M(T) to another type M(U). (U can be T, but is not necessarily). </p>
</blockquote>
<p>In my understanding, the language implementing monad should be type-checked statically. Otherwise, type errors cannot be found during compilation and "Complexity" is not controlled. Is my understanding correct?</p>
| [
{
"answer_id": 394952,
"author": "Jörg W Mittag",
"author_id": 2988,
"author_profile": "https://Stackoverflow.com/users/2988",
"pm_score": 6,
"selected": true,
"text": "<?php\nclass Identity {\n protected $val;\n public function __construct($val) { $this->val = $val; }\n public static... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26349/"
] |
394,715 | <p>I am implementing Javascript Validation on an ASP.Net page that is inside a Master Page. The control IDs are changing, so I can't use the original control IDs for validation. I looked on the Net and got the suggestion to build the script dynamically, and add it to the page using RegisterStartupScript. I don't like that solution because it is not maintainable. </p>
<p>What are the ways I can perform javascript validation on this page and arrange for the client IDs?</p>
<p>Another solution just asked me to go ahead and use the final clientIDs that appear in the browser. That is workable and I'd prefer it to creating the script on runtime. What's your opinion?</p>
| [
{
"answer_id": 394728,
"author": "Brant Bobby",
"author_id": 4160,
"author_profile": "https://Stackoverflow.com/users/4160",
"pm_score": 2,
"selected": false,
"text": "<script>\n var SomeControl = <%= Control1.ClientID %>;\n var AnotherControl = <%= Control2.ClientID %>;\n // et... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33052/"
] |
394,767 | <p>Does anyone have any good articles or explanations (blogs, examples) for pointer arithmetic? Figure the audience is a bunch of Java programmers learning C and C++.</p>
| [
{
"answer_id": 394774,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 7,
"selected": true,
"text": "int * pa = NULL;\nint * pb = NULL;\npa += 1; // pa++. behind the scenes, add sizeof(int) bytes\nassert((pa -... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] |
394,770 | <p>Is there a way in Python to override a class method at instance level?
For example:</p>
<pre><code>class Dog:
def bark(self):
print "WOOF"
boby = Dog()
boby.bark() # WOOF
# METHOD OVERRIDE
boby.bark() # WoOoOoF!!
</code></pre>
| [
{
"answer_id": 394779,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 8,
"selected": false,
"text": "class Dog:\n def bark(self):\n print \"Woof\"\n\ndef new_bark(self):\n print \"Woof Woof\"\n\nfoo = Dog()\n... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42636/"
] |
394,771 | <p>I have a table where each row has a few fields that have ID's that relate to some other data from some other tables.</p>
<p>Let's say it's called <code>people</code>, and each person has the ID of a <code>city</code>, <code>state</code> and <code>country</code>.</p>
<p>So there will be three more tables, <code>cities</code>, <code>states</code> and <code>countries</code> where each has an ID and a name.</p>
<p>When I'm selecting a person, what's the easiest way to get the <strong>names</strong> of the <code>city</code>, <code>state</code> and <code>country</code> in a single query?</p>
<p><strong>Note:</strong> I know this is possible with joins, however as there are more related tables, the nested joins makes the query hard to read, and I'm wondering if there is a cleaner way. It should also be possible for the person to have those fields empty.</p>
| [
{
"answer_id": 394781,
"author": "hamishmcn",
"author_id": 3590,
"author_profile": "https://Stackoverflow.com/users/3590",
"pm_score": -1,
"selected": false,
"text": "SELECT first_name, last_name, formated_address(city_id, state_id, country_id) \nFROM people\nWHERE some_where_clause;\n f... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394771",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25910/"
] |
394,809 | <p>Is there a <a href="https://en.wikipedia.org/wiki/%3F:#Python" rel="noreferrer">ternary conditional operator</a> in Python?</p>
| [
{
"answer_id": 394814,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 14,
"selected": true,
"text": "a if condition else b\n condition a b condition condition True a b b a condition a b condition b a >>> 'true' if Tru... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51518/"
] |
394,816 | <p>I was looking a lot for method to get parent process in .NET, but found only P/Invoke way.</p>
| [
{
"answer_id": 2336322,
"author": "Michael Hale",
"author_id": 166325,
"author_profile": "https://Stackoverflow.com/users/166325",
"pm_score": 7,
"selected": true,
"text": "Console.WriteLine(\"ParentPid: \" + Process.GetProcessById(6972).Parent().Id);\n public static class ProcessExtensi... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41956/"
] |
394,829 | <p>I have written a very simple WCF Service that sends and receives messages. I have tested the app through the VS 2008 default web server host and everything works fine. But when I deploy the WCF service to another computer's IIS I receive the following error:</p>
<p><strong>"The request for security token could not be satisfied because authentication failed."</strong></p>
<p>How can I set the authentication type to use my custom username and password in config file?
If it is not possible, please tell me how I can set its windows credentials because the 2 computers that I'm using, don't share the same users.</p>
| [
{
"answer_id": 799654,
"author": "Mark",
"author_id": 2760,
"author_profile": "https://Stackoverflow.com/users/2760",
"pm_score": 5,
"selected": false,
"text": "<endpoint address=\"\" \n binding=\"wsHttpBinding\" \n contract=\"HelloWorldService.IService1\"\n bi... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34623/"
] |
394,844 | <p>This problem is from a solved problem in my old question, which is from:
<a href="https://stackoverflow.com/questions/394763/c-inserting-2d-array-object-into-another-2d-array-object">C++ Inserting 2D array Object into another 2D array Object</a></p>
<p>But also created a new problem for me. Please read the question and the solution in the link to understand my problem. The solution in the previous question was to make my Data Member Function into a pointer to pointer, to allow the pass into the other Data Member Function. But while fixing that, the first Data Member Function which is <code>smallerArray.extractPiece()</code> now only return address of the pointer to the pointer and not the content of those pointers. I need the content in order for my 2nd Data Member Function <code>largerArray.extractArray(result)</code> to work properly, as I attempt run the code and gave an Window Error, and not a Compile Error.</p>
<p>Does anyone know how to extract the content of the <code>smallerArray.extractPiece()</code> and instead of getting of the address, and is there isn't, does anyone have any other methods of creating a 2D-Array Object?</p>
| [
{
"answer_id": 394896,
"author": "marioddd",
"author_id": 49353,
"author_profile": "https://Stackoverflow.com/users/49353",
"pm_score": 1,
"selected": false,
"text": "void Grid::extractArray( int** arr )\n{\n for(int i = 0; i < xGrid ; ++i) {\n for (int j = 0; j < yGrid ; ++j) {\n ... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
394,850 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/171970/how-can-i-find-the-method-that-called-the-current-method">How can I find the method that called the current method?</a></p>
</blockquote>
<p>I need a way to know the name of calling methods in C#.</p>
<p>For instance: </p>
<pre><code>private void doSomething()
{
// I need to know who is calling me? (method1 or method2).
// do something pursuant to who is calling you?
}
private void method1()
{
doSomething();
}
private void method2()
{
doSomething();
}
</code></pre>
| [
{
"answer_id": 394852,
"author": "Andrew Robertson",
"author_id": 40167,
"author_profile": "https://Stackoverflow.com/users/40167",
"pm_score": 7,
"selected": true,
"text": "using System.Diagnostics;\n\n// get call stack\nStackTrace stackTrace = new StackTrace();\n\n// get calling method... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36446/"
] |
394,853 | <p>the two bits of SQL below get the same result</p>
<pre><code>SELECT c.name, o.product
FROM customer c, order o
WHERE c.id = o.cust_id
AND o.value = 150
SELECT c.name, o.product
FROM customer c
INNER JOIN order o on c.id = o.cust_id
WHERE o.value = 150
</code></pre>
<p>I've seen both styles used as standard at different companies. From what I've seen, the 2nd one is what most people recommend online. Is there any real reason for this other than style? Does using an Inner Join sometimes have better performance?</p>
<p>I've noticed Ingres and Oracle developers tend to use the first style, whereas Microsoft SQL Server users have tended to use the second, but that might just be a coincidence.</p>
<p>Thanks for any insight, I've wondered about this for a while.</p>
<p>Edit: I've changed the title from 'SQL Inner Join versus Cartesian Product' as I was using the incorrect terminlogy. Thanks for all the responses so far.</p>
| [
{
"answer_id": 394858,
"author": "Ed Guiness",
"author_id": 4200,
"author_profile": "https://Stackoverflow.com/users/4200",
"pm_score": 2,
"selected": false,
"text": "select *\nfrom t1,t2\n"
},
{
"answer_id": 394876,
"author": "Cruachan",
"author_id": 7315,
"author_pr... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49171/"
] |
394,871 | <p>This is about a school assignment so I'm trying to do things by the book. I feel like I'm getting the grips of Java, but good programming practice, design patterns, etc. are all rather new to me.</p>
<p>I've made my model and it works fine. It contains a student class which contains a number of fields with student information (obviously). Now I want this information to be displayed in a couple of JLabels. It is easiest to pass a whole student object to the GUI and use JLabel.settext.getname() etc. a number of times and no doubt this will work perfectly. But I feel that the student object is part of the model and by passing it to the GUI I'm not using a MVC pattern anymore. Am I right here?</p>
<p>I did make a controller object for passing data to and from the model and the GUI but for passing only strings to the labels or setting the JLabel text through the controller, I need either a lot of setters in the GUI, or I would have to make all JLabels global fields which doesn't feel good either.</p>
<p>Any advice on this? </p>
| [
{
"answer_id": 394888,
"author": "Michael Borgwardt",
"author_id": 16883,
"author_profile": "https://Stackoverflow.com/users/16883",
"pm_score": 2,
"selected": false,
"text": "TableModel setModel() getModel() setModel() setText()"
}
] | 2008/12/27 | [
"https://Stackoverflow.com/questions/394871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49349/"
] |
394,882 | <p>There are some nice free "image to ASCII art" conversion sites like this one: <a href="http://www.ascii-art.org/" rel="noreferrer">ASCII-art.org</a></p>
<p>How does such an image conversion algorithm work?</p>
<pre>
,
. W ,
W W @
W ,W W
, W, :W* .W .
# WW @WW WW #
W WW.WWW WW: W
W. WW*WWW# WW@ W
* :WW.WWWWWWW@WWW@W #
+* #WW#WWWWWWWWWWWWW# W
W# @WWWWWWWWWWWWWWWWW W
WW WWWWWWWWWWWWWWWWWW W
WW WWWWWWWWWWWWWWWWWW@W#
,WW.WWWWWWWWWWWWWWWWWWWWW
WW@WWWWWWWWWWWWWWWWWWWWW
: WWWWWWWWWWWWWWWWWWWWWWWW :
@ WWWWWWWW@WWWWWWW@@WWWWWW.
W*WWWWWW::::@WWW:::::#WWWWW
WWWWWW@:: :+*:. ::@WWWW
WWWWW@:*:.:: .,.:.:WWWW
@WWWW#:.:::. .:: #:@WWW
:WWW@:#. :: :WWWW:@WWWW
WWW#*:W@*@W . W:#WWW
#WWWW:@ :: :: *WWWW
W@WW*W .::,.::::,:+ @@WW#,
WWWW## ,,.: .:::.: . .WWW:,
@WWW@: W..::::: #. :WWWW
WWWW:: *..:. ::.,. :WWWW
WWWW:: :.:.: : :: ,@WW@
WWWW: .:, : ,, :WW,
.: # : , : *
W + ., ::: ., : @
W :: .: W
@,,,W:. ,, ::*@*:, . :@W.,,@
+.....*: : : .#WWWWW: : .#:....+,
@...:::*:,, : :WWWWWWW, , *::::..,#
:...::::::W:, @W::::*W. :W:::::...#
@@@@@@@@@@@W@@@@@W@@@@@@W@@@@@W@@@@@@@@@@:
</pre>
| [
{
"answer_id": 394938,
"author": "daniels",
"author_id": 9789,
"author_profile": "https://Stackoverflow.com/users/9789",
"pm_score": 4,
"selected": false,
"text": "libcaca aalib"
},
{
"answer_id": 395116,
"author": "joel.neely",
"author_id": 3525,
"author_profile": "h... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6461/"
] |
394,889 | <p>I have the following scenario
I have a main form as MDI parent and MDI child form, the child form shows a new form (I called it mydialog).
I want to access specific function in the MDI child form from mydialog so I tried to set the Owner property in the mydialog object but exception occured (circular reference exception) also the Parent and ParentForm properities of mydialog form are null, I made a quick and dirty soluion using the Tag property of mydialog.
I am looking for a better solution and why there is an exception when I set the Owner property of mydialog</p>
| [
{
"answer_id": 394892,
"author": "Leon Tayson",
"author_id": 18413,
"author_profile": "https://Stackoverflow.com/users/18413",
"pm_score": 0,
"selected": false,
"text": "public MyDialog(object param1)\n MyDialog frm = new MyDialog(\"data\");\nfrm.ShowDialog();\n public object Data {get; ... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42749/"
] |
394,898 | <p>I came across <a href="http://www.cs.umd.edu/%7Epugh/java/memoryModel/DoubleCheckedLocking.html" rel="noreferrer">this</a> article discussing why the double-check locking paradigm is broken in Java. Is the paradigm valid for .NET (in particular, C#), if variables are declared <code>volatile</code>?</p>
| [
{
"answer_id": 394918,
"author": "Michael Borgwardt",
"author_id": 16883,
"author_profile": "https://Stackoverflow.com/users/16883",
"pm_score": 3,
"selected": false,
"text": "private static Singleton instance = new Singleton();\n"
},
{
"answer_id": 2909299,
"author": "David ... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47161/"
] |
394,900 | <p>I have a class which is not thread safe:</p>
<pre><code>class Foo {
/* Abstract base class, code which is not thread safe */
};
</code></pre>
<p>Moreover, if you have foo1 and foo2 objects, you cannot call foo1->someFunc() until foo2->anotherFunc() has returned (this can happen with two threads). This is the situation and it can't be changed (a Foo subclass is actually a wrapper for a python script).</p>
<p>In order to prevent unwanted calls I've created the following -</p>
<pre><code>class FooWrapper {
public:
FooWrapper(Foo* foo, FooWrappersMutex* mutex);
/* Wrapped functions from Foo */
};
</code></pre>
<p>Internally, FooWrapper wraps calls to the Foo functions with the shared mutex.</p>
<p>I want to test FooWrapper for thread safety. My biggest problem is the fact that threads are managed by the operating system, which means I've got less control on their execution. What I would like to test is the following scenario:</p>
<ul>
<li>Thread 1 calls fooWrapper1->someFunc() and blocks while inside the function</li>
<li>Thread 2 calls fooWrapper2->anotherFunc() and returns immediately (since someFunc() is still executing)</li>
<li>Thread 1 finishes the execution</li>
</ul>
<p>What is the simplest to test a scenario like this automatically?</p>
<p>I'm using QT on Win32, although I would prefer a solution which is at least cross-platform as QT is.</p>
| [
{
"answer_id": 394903,
"author": "kshahar",
"author_id": 33982,
"author_profile": "https://Stackoverflow.com/users/33982",
"pm_score": 0,
"selected": false,
"text": "//! Give some time to the other threads\nstatic void YieldThread()\n{\n#ifdef _WIN32\n Sleep(10);\n#endif //_WIN32\n}\n... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33982/"
] |
394,908 | <p>I'm designing a game server and I have never done anything like this before. I was just wondering what a good structure for a packet would be data-wise? I am using TCP if it matters. Here's an example, and what I was considering using as of now:</p>
<p>(each value in brackets is a byte)</p>
<pre><code>[Packet length][Action ID][Number of Parameters]
[Parameter 1 data length as int][Parameter 1 data type][Parameter 1 data (multi byte)]
[Parameter 2 data length as int][Parameter 2 data type][Parameter 2 data (multi byte)]
[Parameter n data length as int][Parameter n data type][Parameter n data (multi byte)]
</code></pre>
<p>Like I said, I really have never done anything like this before so what I have above could be complete bull, which is why I'm asking ;). Also, is passing the total packet length even necessary?</p>
| [
{
"answer_id": 394930,
"author": "Chad Okere",
"author_id": 48839,
"author_profile": "https://Stackoverflow.com/users/48839",
"pm_score": 2,
"selected": false,
"text": "[action ID][item 1 (sizeof(item 1 bytes)][item 1 (sizeof(item 2 bytes)]...[item n (sizeof(item n bytes)]\n [action ID]\... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49018/"
] |
394,921 | <p>I am writing a (very small) framework for checking pre- and postconditions of methods. Entry points are (they could be easily be methods; that doesn't matter):</p>
<pre><code>public static class Ensures {
public static Validation That {
get { ... }
}
}
public static class Requires {
public static Validation That {
get { ... }
}
}
</code></pre>
<p>Obviously, checking the postconditions may be expensive, and isn't actually necessary, when the method isn't buggy. So I want a method which works like this:</p>
<pre><code>public static class Ensures {
[ConditionalCallingCode("DEBUG")]
public static Validation ThatDuringDebug {
get { ... }
}
}
</code></pre>
<p>where <code>ConditionalCallingCodeAttribute</code> means that this method should only run when the calling code is compiled with the DEBUG symbol defined. Is this possible?</p>
<p>I want client code to look like this:</p>
<pre><code>public class Foo {
public void Bar() {
... // do some work
Ensures.That // do these checks always
.IsNotNull(result)
.IsInRange(result, 0, 100);
Ensures.WhileDebuggingThat // only do these checks in debug mode
.IsPositive(ExpensiveCalculation(result));
return result;
}
}
</code></pre>
<p>Of course, I can simply not provide WhileDebuggingThat. Then the client code would look like this:</p>
<pre><code>public class Foo {
public void Bar() {
... // do some work
Ensures.That // do these checks always
.IsNotNull(result)
.IsInRange(result, 0, 100);
#ifdef DEBUG
Ensures.That // only do these checks in debug mode
.IsPositive(ExpensiveCalculation(result));
#endif
return result;
}
}
</code></pre>
<p>This is the fallback plan if nothing else works out, but it breaks DRY really badly.</p>
<p>As I understand it, marking <code>WhileDebuggingThat</code> with <code>[Conditional("DEBUG")]</code> will emit (or not) this method depending on whether DEBUG is defined during the compilation of the library, <em>not</em> of the assemblies which reference this library. So I <em>could</em> do this and then write documentation telling the library users to link debug builds of their code with the debug build of the library, and release builds with release builds. This doesn't strike me as the best solution.</p>
<p>Finally, I could tell the library users to define this class inside their projects:</p>
<pre><code>using ValidationLibrary;
public static class EnsuresWhileDebugging {
[Conditional("DEBUG")]
public static Validation That() {
return Ensures.That;
}
}
</code></pre>
<p>This should work as well, as far as I see, but still requires breaking the DRY principle, if only slightly.</p>
| [
{
"answer_id": 395083,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 0,
"selected": false,
"text": "Debug.Assert() try\n{\n Debug.Assert(false);\n}\ncatch (Exception e)\n{\n // will only and always run in debug... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9204/"
] |
394,942 | <p>I am using SimpleModal in jQuery, and I have one confirm dialog. If the result is <code>Yes</code>, I have to call <code>my.php</code> into this dialog. However, I have done the code, and I am still searching for ideas. How can I do it?</p>
<pre><code>$(document).ready(function () {
$('#confirmDialog input.confirm, #confirmDialog a.confirm').click(function (e) {
e.preventDefault();
// Example of calling the confirm function.
// You must use a callback function to perform the "yes" action.
confirm("Continue", function () {
alert("OK");
});
});
});
function confirm(message, callback) {
$('#confirm').modal({
close:false,
position: ["20%",],
overlayId:'confirmModalOverlay',
containerId:'confirmModalContainer',
onShow: function (dialog) {
dialog.data.find('.message').append(message);
// If the user clicks "yes"
dialog.data.find('.yes').click(function () {
$.get('my.php', function(data){
// Create a modal dialog with the data.
// Here: How do I write the same window?
});
// Call the callback
// Close the dialog
$.modal.close();
});
}
});
}
</code></pre>
<p>Here I have the problem of how to write it the same window Confirmdialog from an Ajax result. How can I do it?</p>
| [
{
"answer_id": 394966,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 1,
"selected": false,
"text": " dialog.data.find('.message').html( 'new contents from your ajax data' );\n dialog,data.find('.buttons').remove();\n"
... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44984/"
] |
394,947 | <p><em>Let me try rephrasing this:</em></p>
<p>I am looking for a robust RDF store or library with the following features:</p>
<ul>
<li><strong>Named graphs</strong>, or some other form of reification.</li>
<li><strong>Version tracking</strong> (probably at the named graph level).</li>
<li><strong>Privacy</strong> between groups of users, either at named graph or triple level.</li>
<li>Human-readable data input and output, e.g. <strong>TriG</strong> parser and serialiser.</li>
</ul>
<p>I've played with <a href="http://jena.sourceforge.net/" rel="noreferrer">Jena</a>, <a href="http://www.openrdf.org/" rel="noreferrer">Sesame</a>, <a href="http://ibm-slrp.sourceforge.net/2006/11/20/boca-the-rdf-repository-component-of-the-ibm-semantic-layered-research-platform/" rel="noreferrer">Boca</a>, <a href="http://rdflib.net/" rel="noreferrer">RDFLib</a>, <a href="http://librdf.org/" rel="noreferrer">Redland</a> and one or two others some time ago but each had its problems. Have any improved in the above areas recently? Can anything else do what I want, or is RDF not yet ready for prime-time?</p>
<hr>
<p>Reading around the subject a bit more, I've found that:</p>
<ul>
<li><a href="http://jena.sourceforge.net/" rel="noreferrer">Jena</a>, nothing further</li>
<li><a href="http://www.openrdf.org/" rel="noreferrer">Sesame</a>, nothing further</li>
<li><a href="http://ibm-slrp.sourceforge.net/2006/11/20/boca-the-rdf-repository-component-of-the-ibm-semantic-layered-research-platform/" rel="noreferrer">Boca</a> does not appear to be maintained any more and seems only really designed for DB2. <strong><a href="http://www.openanzo.org/" rel="noreferrer">OpenAnzo</a>, an open-source fork, appears more promising.</strong></li>
<li><a href="http://rdflib.net/" rel="noreferrer">RDFLib</a>, nothing further</li>
<li><a href="http://librdf.org/" rel="noreferrer">Redland</a>, nothing further</li>
<li><a href="http://www.talis.com/platform/" rel="noreferrer">Talis Platform</a> appears to support changesets (<a href="http://n2.talis.com/wiki/ChangeSets" rel="noreferrer">wiki page</a> and reference in <em><a href="http://n2.talis.com/wiki/Kniblet_Tutorial_Part_5" rel="noreferrer">Kniblet Tutorial Part 5</a></em>) but it's a hosted-only service. Still may look into it though.</li>
<li><a href="http://semweb4j.org/site/semversion/index.html" rel="noreferrer">SemVersion</a> sounded promising, but appears to be stale.</li>
</ul>
| [
{
"answer_id": 2651262,
"author": "castagna",
"author_id": 318257,
"author_profile": "https://Stackoverflow.com/users/318257",
"pm_score": 2,
"selected": false,
"text": "[ id | g | s | p | o | user | timestamp | prev | next ]\n id - long (unique identifier, same (g,s,p,o) will have di... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42974/"
] |
394,959 | <p>Web browsers are good as thin clients for web applications.</p>
<p>But if the user has to enter some code (where tabs and formatting are important) in an edit box, inside a web browser, he navigates through the webpage controls every time he hits the "tab" key, instead of printing the "tab" character.</p>
<p>Are there any free web controls or is there any code to get the opposite behavior?<br/>
<a href="http://docs.google.com/" rel="nofollow noreferrer">Google Docs</a> does this perfectly.</p>
<p>Thanks.</p>
| [
{
"answer_id": 394996,
"author": "PEZ",
"author_id": 44639,
"author_profile": "https://Stackoverflow.com/users/44639",
"pm_score": 2,
"selected": false,
"text": "<html>\n<body>\n<script type=\"text/javascript\">\nfunction keyFilter(e, field) {\n var key = window.event ? e.keyCode : e.wh... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23034/"
] |
394,978 | <p>So I wrote this short script (correct word?) to download the comic images from explosm.net comics because I somewhat-recently found out about it and I want to...put it on my iPhone...3G.</p>
<p>It works fine and all. urllib2 for getting webpage html and urllib for image.retrieve()</p>
<p><strong><em>Why I posted this on SO: how do I optimize this code? Would REGEX (regular expressions) make it faster? Is it an internet limitation? Poor algorithm...?</em></strong></p>
<p>Any improvements in speed or <strong><em>general code aesthetics</em></strong> would be greatly appreciated "answers".</p>
<p><i>Thank you.</i></p>
<p><i>--------------------------------CODE----------------------------------</i></p>
<pre><code>import urllib, urllib2
def LinkConvert(string_link):
for eachLetter in string_link:
if eachLetter == " ":
string_link = string_link[:string_link.find(eachLetter)] + "%20" + string_link[string_link.find(eachLetter)+1:]
return string_link
start = 82
end = 1506
matchingStart = """<img alt="Cyanide and Happiness, a daily webcomic" src="http://www.explosm.net/db/files/Comics/"""
matchingEnd = """></"""
link = "http://www.explosm.net/comics/"
for pageNum in range(start,start+7):
req = urllib2.Request(link+`pageNum`)
response = urllib2.urlopen(req)
page = response.read()
istart1 = page.find(matchingStart)
iend1 = page.find(matchingEnd, istart1)
newString1 = page[istart1 : iend1]
istart2 = newString1.find("src=")+4
iend2 = len(newString1)
final = newString1[istart2 +1 : iend2 -1]
final = LinkConvert(final)
try:
image = urllib.URLopener()
image.retrieve(final, `pageNum` + ".jpg")
except:
print "Uh-oh! " + `pageNum` + " was not downloaded!"
print `pageNum` + " completed..."
</code></pre>
<p><i>By the way, this is Python 2.5 code, not 3.0 but you bet I have all the features of PYthon 3.0 greatly studied and played around with before or right after New Year (after College Apps - YAY! ^-^)</i></p>
| [
{
"answer_id": 47475296,
"author": "Balmipour",
"author_id": 2472389,
"author_profile": "https://Stackoverflow.com/users/2472389",
"pm_score": 0,
"selected": false,
"text": "mkdir -p html/archived\nmkdir png\n START=15\nEND=4783\nfor ((i=START;i<=END;i++)); do\n echo $i\n wget http://e... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51518/"
] |
394,984 | <p>Services default to starting as <code>root</code> at boot time on my RHEL box. If I recall correctly, the same is true for other Linux distros which use the init scripts in <code>/etc/init.d</code>.</p>
<p>What do you think is the best way to instead have the processes run as a (static) user of my choosing?</p>
<p>The only method I'd arrived at was to use something like:</p>
<pre><code> su my_user -c 'daemon my_cmd &>/dev/null &'
</code></pre>
<p>But this seems a bit untidy...</p>
<p>Is there some bit of magic tucked away that provides an easy mechanism to automatically start services as other, non-root users?</p>
<p><strong>EDIT:</strong> I should have said that the processes I'm starting in this instance are either Python scripts or Java programs. I'd rather not write a native wrapper around them, so unfortunately I'm unable to call <a href="http://linux.die.net/man/2/setuid" rel="noreferrer">setuid()</a> as <a href="https://stackoverflow.com/users/25234/black">Black</a> suggests.</p>
| [
{
"answer_id": 395013,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 7,
"selected": true,
"text": "start-stop-daemon daemon /etc/init.d/functions start-stop-daemon daemonize"
},
{
"answer_id": 395342,
"author": "Ja... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29903/"
] |
394,989 | <p>How to handle click event of the linkbutton in gridview in vb.net (windows application )</p>
<p>Thanks</p>
| [
{
"answer_id": 395184,
"author": "t3rse",
"author_id": 64,
"author_profile": "https://Stackoverflow.com/users/64",
"pm_score": 4,
"selected": true,
"text": "Dim data As New DataTable()\ndata.Columns.Add(New DataColumn(\"Link\", Type.GetType(\"System.String\")))\nDim newRow As DataRow = d... | 2008/12/27 | [
"https://Stackoverflow.com/questions/394989",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49238/"
] |
395,009 | <p>I need to automatically check the style of javascript sources written by different people. Do you know of a good tool to do it? Integration with emacs would be a plus. Thank you in advance.</p>
| [
{
"answer_id": 11445376,
"author": "xuhdev",
"author_id": 1150462,
"author_profile": "https://Stackoverflow.com/users/1150462",
"pm_score": 2,
"selected": false,
"text": ".editorconfig"
}
] | 2008/12/27 | [
"https://Stackoverflow.com/questions/395009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49364/"
] |
395,019 | <p>I want to have a textarea that's <code>500px</code>, this is the CSS I use for the textarea:</p>
<pre><code>width: 498px;
padding: 0px;
margin: 0px;
</code></pre>
<p>I noticed IE and Chrome have a <code>1px</code> border by default, on the other hand FF have a <code>2px</code> border which results the textarea to be <code>502px</code> instead of <code>500px</code>, any workarounds?</p>
<p>Just a note, I could explicitly specify the texarea border width, ie. border-width: <code>1px</code>, but the problem here is that it doesn't work nicely with IE (the default textarea border in IE doesn't visually look ok when the border is set to <code>1px</code>), I could change the border color but I don't want to do this, I prefer to keep the default browsers styles, I just want the width to be the same in all browsers without changing the default styles or setting a color to the border, is this possible?</p>
| [
{
"answer_id": 395022,
"author": "Dave Markle",
"author_id": 24995,
"author_profile": "https://Stackoverflow.com/users/24995",
"pm_score": 3,
"selected": false,
"text": "<link rel=\"stylesheet\" type=\"text/css\" href=\"http://yui.yahooapis.com/2.6.0/build/reset/reset-min.css\"> \n"
},... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/676066/"
] |
395,030 | <p>Just for review, can someone quickly explain what prevents this from working (on compile):</p>
<pre><code>private HashSet data;
...
public DataObject[] getDataObjects( )
{
return (DataObject[]) data.toArray();
}
</code></pre>
<p>...and what makes this the way that DOES work:</p>
<pre><code>public DataObject[] getDataObjects( )
{
return (DataObject[]) data.toArray( new DataObject[ Data.size() ] );
}
</code></pre>
<p>I'm not clear on the mechanism at work with casting (or whatever it is) that makes this so.</p>
| [
{
"answer_id": 395038,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 6,
"selected": true,
"text": "toArray() Object[] DataObject[] toArray(DataObject[]) DataObject Collection<E>.toArray() toArray(DataObject[]) toArray(n... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19825/"
] |
395,034 | <p>I own a website which contain a lot of freeware stuff to download on it. The problem I'm facing is that people from around the world are taking the direct links
of the files (for example .zip files) and posting them on their websites and general forums. I am getting a huge amount of bandwidth and that's ok, but the number of pages visited is low. Is there a way or a script that I can add to the links, so that when someone presses on the link from a foreign website, a page from my website opens instead, which then lets him download the file so I can get more visits.</p>
<p>For example, this is a address from my website:</p>
<blockquote>
<p><a href="http://sy-stu.org/stu/PublicFiles/StdLibrary/Exam.zip" rel="noreferrer">http://sy-stu.org/stu/PublicFiles/StdLibrary/Exam.zip</a></p>
</blockquote>
<p>When anyone presses on it, it will start the downloading process directly.</p>
| [
{
"answer_id": 395040,
"author": "Ólafur Waage",
"author_id": 22459,
"author_profile": "https://Stackoverflow.com/users/22459",
"pm_score": 5,
"selected": true,
"text": "$_SERVER['HTTP_REFERER']"
},
{
"answer_id": 395092,
"author": "Brian Kelly",
"author_id": 8252,
"a... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
395,045 | <p>I want to provide a piece of Javascript code that will work on any website where it is included, but it always needs to get more data (or even modify data) on the server where the Javascript is hosted. I know that there are security restrictions in place for obvious reasons.</p>
<p>Consider index.html hosted on xyz.com containing the following:</p>
<pre><code><script type="text/javascript" src="http://abc.com/some.js"></script>
</code></pre>
<p>Will some.js be able to use XMLHttpRequest to post data to abc.com? In other words, is abc.com implicitly trusted because we loaded Javascript from there?</p>
| [
{
"answer_id": 395177,
"author": "James",
"author_id": 21677,
"author_profile": "https://Stackoverflow.com/users/21677",
"pm_score": 5,
"selected": true,
"text": "function getJSON(URL,success){\n var ud = 'json'+(Math.random()*100).toString().replace(/\\./g,'');\n window[ud]= funct... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1606/"
] |
395,051 | <p>I know innerHTML is supposedly evil, but I think it's the simplest way to change link text. For example:</p>
<pre><code><a id="mylink" href="">click me</a>
</code></pre>
<p>In JS you can change the text with:</p>
<pre><code>document.getElementById("mylink").innerHTML = new_text;
</code></pre>
<p>And in Prototype/jQuery: </p>
<pre><code>$("mylink").innerHTML = new_text;
</code></pre>
<p>works fine. Otherwise you have to replace all of the child nodes first and then add a text node. Why bother?</p>
| [
{
"answer_id": 395074,
"author": "Christoph",
"author_id": 48015,
"author_profile": "https://Stackoverflow.com/users/48015",
"pm_score": 3,
"selected": false,
"text": "document.getElementById('mylink').firstChild.nodeValue = new_text;\n var oldLink = document.getElementById('mylink'),\n ... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
395,053 | <p>I have two templatetags in my app which contain forms which show entries in db. When I alter data or add new entry to db, the forms show the old data. While in admin panel everything is correct (updated). When I restart the server (I mean <code>manage.py runserver</code>) forms show updated db entries. How to make the forms show updated data?<br /><br />
regards<br />
chriss<br /><br />
<b>EDIT:</b><br />
file: <code>templatetags/oceny_tags.py</code>:<br /></p>
<pre><code>from django import template
from oceny.formularze import StudentFormularz, PrzeniesStudentaFormularz
def dodajStudenta(req):
formularz = StudentFormularz(req)
return {'formularz': formularz}
def przeniesStudenta(req):
formularz = PrzeniesStudentaFormularz(req)
return {'formularz': formularz}
register = template.Library()
register.inclusion_tag('oceny/formularz_studenta.html', takes_context = False)(dodajStudenta)
register.inclusion_tag('oceny/formularz_przenies_studenta.html', takes_context = False)(przeniesStudenta)
</code></pre>
<p>file: <code>views.py</code> view responsible for handling forms:</p>
<pre><code>def zarzadzajStudentami(request):
formularze = ['dodaj_studenta', 'przenies_studenta']
req = {}
for e in formularze:
req[e] = None
if request.POST:
req[request.POST['formularz']] = request.POST
if request.POST['formularz'] == 'dodaj_studenta':
formularz = StudentFormularz(request.POST)
if formularz.is_valid():
formularz.save()
return HttpResponseRedirect(reverse('zarzadzaj_studentami'))
elif request.POST['formularz'] == 'przenies_studenta':
formularz = PrzeniesStudentaFormularz(request.POST)
if formularz.is_valid():
student = Student.objects.get(id = request.POST['student'])
grupa = Grupa.objects.get(id = request.POST['grupa'])
student.grupa = grupa
student.save()
return HttpResponseRedirect(reverse('zarzadzaj_studentami'))
return render_to_response('oceny/zarzadzaj_studentami.html', {'req': req}, context_instance = RequestContext(request))
</code></pre>
<p>I realize that the code may be lame in some cases. I would appreciate any other hints how to write things better.</p>
| [
{
"answer_id": 30299070,
"author": "user2213295",
"author_id": 2213295,
"author_profile": "https://Stackoverflow.com/users/2213295",
"pm_score": 1,
"selected": false,
"text": "takes_context"
}
] | 2008/12/27 | [
"https://Stackoverflow.com/questions/395053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36832/"
] |
395,056 | <p>I want to create a game that will work both locally and online.</p>
<p>My first thought was to create an interface that would have all the methods that will be needed by the GUI for the business logic and then have a network implementation and a local implementation.</p>
<p>This works fine for request-response messages. But what about messages that the server sends, where I have to update some GUI components (i.e. JLabels)?</p>
<p>My first solution to this was to implement listeners, where each change in the implementation will fire an event. The GUI would register and change it's components appropriately. However, calls to fire events in the business logic looks a little wrong.</p>
<p>Am I in the right track? Because I think I'm not. Any suggestions?</p>
<p>Thank you.</p>
<p>NOTE: The client is a simple Java Swing GUI.</p>
| [
{
"answer_id": 395179,
"author": "duffymo",
"author_id": 37213,
"author_profile": "https://Stackoverflow.com/users/37213",
"pm_score": 1,
"selected": false,
"text": "public class ExamplePanel extends JPanel implements ActionListener\n{\n private JButton button;\n private ActionList... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395056",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2644/"
] |
395,057 | <p>Where would</p>
<pre><code>set_include_path("../../");
</code></pre>
<p>point to?</p>
<p>I am trying to run some PHP code on a standard XAMPP server. And put my stuff into the htdocs folder. The includes point to relative paths, But it does not work. Is there any best-practise for includes? The code has to run on machines of multiple developers.</p>
| [
{
"answer_id": 395100,
"author": "Eineki",
"author_id": 29125,
"author_profile": "https://Stackoverflow.com/users/29125",
"pm_score": 2,
"selected": true,
"text": "ini_set('include_path', 'yourdir');\n"
}
] | 2008/12/27 | [
"https://Stackoverflow.com/questions/395057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
395,060 | <p>I drew a little graph in paint that explains my problem:</p>
<p>But it doesn't seem to show up when I use the <code><img></code> tag after posting?</p>
<p>Graph:</p>
<p><a href="https://i.stack.imgur.com/DkI1T.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DkI1T.jpg" alt="http://i44.tinypic.com/103gcbk.jpg"></a>
</p>
| [
{
"answer_id": 395068,
"author": "erikkallen",
"author_id": 47161,
"author_profile": "https://Stackoverflow.com/users/47161",
"pm_score": 3,
"selected": true,
"text": "#include GameSocket.h\nDatabase db(1, 2, 3);\nint main() {\n //whatever\n}\n"
},
{
"answer_id": 395069,
"a... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395060",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
395,075 | <p>I've following problem, which I've not been able to do successfully. Your help will be appreciated. I'm using SQL 2005, and trying to do this using CTE.</p>
<p>Table has following 2 columns</p>
<pre><code>DocNum DocEntry
1 234
2 324
2 746
3 876
3 764
4 100
4 387
</code></pre>
<p>Expected result is as follows</p>
<pre><code>1 234
2 324, 746
3 876, 764
4 100, 387
</code></pre>
<p>Thanks
Rahul Jain</p>
<hr>
<p>Further explanation transcribed from the comments:</p>
<p>I'm using a query like following:</p>
<pre><code>WITH ABC (DocNum, DocEntry) AS
(SELECT DocNum, Cast(DocEntry As VARCHAR(8000))
FROM Temp5
WHERE DocNum = 1
UNION ALL
SELECT a.DocNum, A.DocEntry + ', ' + B.DocEntry
FROM ABC B INNER JOIN Temp5 A ON B.DocNum +1= A.DocNum
WHERE A.DOCNUM > 1)
SELECT * FROM ABC;
</code></pre>
<p>Result from above query is as follows</p>
<pre><code>1 234
2 234, 324
2 234, 746
3 234, 746, 876
3 234, 746, 764
</code></pre>
<p>I dont want those numbers to repeat as shown in question.</p>
| [
{
"answer_id": 395133,
"author": "Kev",
"author_id": 419,
"author_profile": "https://Stackoverflow.com/users/419",
"pm_score": 2,
"selected": false,
"text": "DECLARE @sql AS varchar(max)\nDECLARE @pivot_list AS varchar(max) -- Leave NULL for COALESCE technique\nDECLARE @select_list AS va... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49372/"
] |
395,082 | <p>I don't really <em>FEEL</em> CSS and it doesn't always work as I think it would. </p>
<p>This is one of these situations:</p>
<p>I have a simple (2 rows, 2 columns) asp:table generated dynamically. in the right column it contains a combo box <code>(cell (0, 1))</code> and a label <code>(cell (1,1))</code>. When I change the combobox's selection, the text in the label changes too. If it's too long for a cell, it re-sizes the table. I would prefer the text to be in lines, so that it fits cell's width.</p>
<p>I don't know if it's some label's property that could do it or should I specify this in CSS style of a label or of a cell? i tried setting table's width explicitly, cell's width in CSS class but nothing works and I feel like a blind in a labyrinth.</p>
| [
{
"answer_id": 395091,
"author": "ceejayoz",
"author_id": 1902010,
"author_profile": "https://Stackoverflow.com/users/1902010",
"pm_score": 3,
"selected": true,
"text": "<label> display: block;"
}
] | 2008/12/27 | [
"https://Stackoverflow.com/questions/395082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40872/"
] |
395,114 | <p>I would like vim to color "long" lines for me. Using 80 columns as an example, I would like to highlight lines that exceed that length. Here is roughly what I think the .vimrc file should contain, although it (1) doesn't work, and (2) uses Perl's regex syntax to illustrate my point, because I don't know Vim's well enough:</p>
<pre><code>...
highlight Excess ctermbg=0
au Syntax * syn match Excess /.{80,}$/
...
</code></pre>
<p>This (in my mind at least) should mark lines that exceed 80 columns. What I would ideally like is the ability to color only the part of the line that exceeds 80 columns, so if a line is 85 columns, then the 81st through the 85th columns would be highlighted.</p>
<p>I'm sure Vim can do this, just not with me at the helm.</p>
| [
{
"answer_id": 395117,
"author": "terminus",
"author_id": 9232,
"author_profile": "https://Stackoverflow.com/users/9232",
"pm_score": 1,
"selected": false,
"text": "hi gitError ctermbg=Red\nmatch gitError /^.*\\s$/\n2match gitError /^.\\{120\\}.*$/\n"
},
{
"answer_id": 395326,
... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14356/"
] |
395,123 | <p>In practice with C++, what is <a href="http://en.wikipedia.org/wiki/Resource_acquisition_is_initialization" rel="noreferrer">RAII</a>, what are <a href="http://en.wikipedia.org/wiki/Smart_pointers" rel="noreferrer">smart pointers</a>, how are these implemented in a program and what are the benefits of using RAII with smart pointers?</p>
| [
{
"answer_id": 395158,
"author": "Michael Williamson",
"author_id": 49381,
"author_profile": "https://Stackoverflow.com/users/49381",
"pm_score": 9,
"selected": true,
"text": "File file(\"/path/to/file\");\n// Do stuff with file\nfile.close();\n try {\n File file = new File(\"/path/to... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25093/"
] |
395,145 | <p>Is it possible to switch off optimization of a specific function?
A friend of mine has the problem that the gcc optimization makes some (unknown to me) µ-controller-code not work.
We know which functions it is, but we have no clue of the code itself so the easiest and safest way would probably be to just switch it off for the whole function.</p>
<p>Sadly <a href="http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html" rel="noreferrer">http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html</a> shows that there is a an optimize function attribute / pragma, but it requires gcc 4.4, which we do not have.</p>
<p>thanks in advance</p>
| [
{
"answer_id": 395148,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 2,
"selected": false,
"text": "volatile"
}
] | 2008/12/27 | [
"https://Stackoverflow.com/questions/395145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14114/"
] |
395,157 | <p>I want to scrape the user pages of SO to give the owners of my toolbar the updated information on their questions/answers/etc...</p>
<p>This means I need to do this in the background, parse the pages, extract the content, compare it with the last run and then present the results either on the toolbar or the status bar, or alternatively, on a pop-up window of some kind. And all of this has to be done while the user is going about his business not being interrupted or even being on SO.</p>
<p>I've searched quite thoroughly both on Google and on the Mozilla Wiki for some kind of hint. I've even gone to the extent of downloading a few other extensions that I think do the same. Unfortunately I've not had the time to go through all of them and the ones I've looked at, all use data APIs(Services, WebServices, XML), not html scrapping.</p>
<p><strong>Old question text</strong></p>
<p>I'm looking for a nice place to learn how I can load a page inside a function called buy the infamous set_timeout() to process a screen-scraping in the background.</p>
<p>My idea is to present the results of such scraping in a status bar extension, just in case any thing changed from the last run.</p>
<p>Is there a hidden overlay or some other subterfuge?</p>
| [
{
"answer_id": 395180,
"author": "James Brady",
"author_id": 29903,
"author_profile": "https://Stackoverflow.com/users/29903",
"pm_score": 1,
"selected": false,
"text": "iframe set_timeout Document.onload"
},
{
"answer_id": 431778,
"author": "David Hanak",
"author_id": 42... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8167/"
] |
395,163 | <p>In jQuery you can get the top position relative to the parent as a number, but you can not get the css top value as a number if it was set in <code>px</code>.<br>
Say I have the following:</p>
<pre><code>#elem{
position:relative;
top:10px;
}
</code></pre>
<pre><code><div>
Bla text bla this takes op vertical space....
<div id='elem'>bla</div>
</div>
</code></pre>
<pre><code>$('#elem').position().top; //Returns the number (10+(the vertical space took by the text))
$('#elem').css('top'); //Returns the string '10px'
</code></pre>
<p>But I want to have the css top property as the number <code>10</code>.<br>
How would one achieve this?</p>
| [
{
"answer_id": 395171,
"author": "M4N",
"author_id": 19635,
"author_profile": "https://Stackoverflow.com/users/19635",
"pm_score": 9,
"selected": true,
"text": "parseInt($('#elem').css('top'));\n parseInt($('#elem').css('top'), 10);\n"
},
{
"answer_id": 9895063,
"author": "Iv... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35197/"
] |
395,169 | <p>I am working on an open source C++ project, for code that compiles on Linux and Windows. I use CMake to build the code on Linux. For ease of development setup and political reasons, I must stick to Visual Studio project files/editor on Windows (I can't switch to <a href="http://en.wikipedia.org/wiki/Code::Blocks" rel="noreferrer">Code::Blocks</a>, for example). I see instructions to generate Visual Studio files using CMake, as <a href="http://www.opentissue.org/mediawiki/index.php/Using_CMake" rel="noreferrer">here</a>.</p>
<p>Have you used CMake to generate Visual Studio files before? How has been your experience? Suppose I want to add a new file to my project. What is the workflow for this?</p>
| [
{
"answer_id": 5397994,
"author": "Red XIII",
"author_id": 339249,
"author_profile": "https://Stackoverflow.com/users/339249",
"pm_score": 3,
"selected": false,
"text": ".projs .slns .cmake .proj .sln /src .filter /src .cmake .cmake"
},
{
"answer_id": 9259836,
"author": "Ghit... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19501/"
] |
395,195 | <p>i'm trying to figure out how to layout a simple dialog in WPF using the proper <strong>dialog units</strong> (DLUs). </p>
<hr>
<blockquote>
<h2>What's a dialog unit?</h2>
<p>A dialog is a unit of measure based on the user's preferred font size.
A dialog unit is defined such that the <em>average character</em> is 4 dialog
units wide by 8 dialog units high:</p>
<p><img src="https://i.stack.imgur.com/yRvvQ.png" alt="enter image description here"></p>
<p>This means that dialog units:</p>
<ul>
<li>change with selected font</li>
<li>changed with selected DPI setting</li>
<li>are not square</li>
</ul>
</blockquote>
<hr>
<p>i spent about two hours dimensioning this sample dialog box from Windows Vista with the various <strong>dlu</strong> measurements. Can someone please give the corresponding XAML markup that generates this dialog box?</p>
<p><a href="https://i.stack.imgur.com/PgNaP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PgNaP.png" alt="alt text"></a>
(<a href="http://i44.tinypic.com/30a7390.jpg" rel="nofollow noreferrer">Image Link</a>)</p>
<p>Now admittedly i know almost nothing about WPF XAML. Every time i start, i get stymied because i cannot figure out how to place any control. It seems that everything in WPF must be contained on a panel of some kind. There's StackPanels, FlowPanels, DockPanel, <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.grid.aspx" rel="nofollow noreferrer">Grid</a>, etc. If you don't have one of these then it won't compile.</p>
<p>The only XAML i've been able to come up with (uing XAMLPad) so far:</p>
<pre><code><DockPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Image Width="23" />
<Label>Are you sure you want to move this file to the Recycle Bin?</Label>
<Image Width="60" />
<Label>117__6.jpg</Label>
<Label>Type: ACDSee JPG Image</Label>
<Label>Rating: Unrated</Label>
<Label>Dimensions: 1072 × 712</Label>
<Button Content="Yes" Width="50" Height="14"/>
<Button Content="Cancel" Width="50" Height="14"/>
</DockPanel>
</code></pre>
<p>Which renders as a gaudy monstrosity. None of the controls are placed or sized right. i cannot figure out how to position controls in a window, nor size them properly.</p>
<p>Can someone turn that screenshot into XAML? </p>
<p><strong>Note:</strong> You're not allowed to measure the screenshot. All the Dialog Unit (dlu) widths and heights are specified.</p>
<p><strong>Note:</strong> 1 horizontal DLU != 1 vertical DLU. Horizontal and vertical DLUs are different sizes.</p>
<hr>
<h1>See also</h1>
<ul>
<li><a href="https://stackoverflow.com/questions/1425509/wpf-applications-that-adjust-to-screen-and-font-settings-or-how-would-i-relate">WPF applications that adjust to screen and font settings (Or, How would I relate DLUs to units in WPF?)</a></li>
<li><a href="https://stackoverflow.com/questions/893428/wpf-global-font-size">WPF global font size</a></li>
<li><a href="https://stackoverflow.com/questions/2658511/wpf-buttons-same-recommended-width">WPF buttons same/recommended width</a></li>
<li><a href="https://stackoverflow.com/questions/6403918/wpf-version-of-scalecontrol">WPF version of .ScaleControl?</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/aa511279.aspx#sizingspacing" rel="nofollow noreferrer">Microsoft User Experience Guidelines: Recommended sizing and spacing</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/bb847924.aspx" rel="nofollow noreferrer">Microsoft User Experience Guidelines: Layout Metrics</a></li>
</ul>
<p><strong>Bump:</strong> 6/20/2011</p>
| [
{
"answer_id": 395780,
"author": "Brad Leach",
"author_id": 708,
"author_profile": "https://Stackoverflow.com/users/708",
"pm_score": 3,
"selected": false,
"text": " <Window x:Class=\"VistaLayout.Dialog\"\n xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\n ... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12597/"
] |
395,198 | <p>I've been diving into Erlang recently, and I decided to use Mnesia to do my database work given it can store any kind of Erlang data structure without a problem, scale with ease, be used with list comprehensions, etc.</p>
<p>Coming from standard SQL databases, most rows can and should be identified by a primary key, usually an auto-incrementing integer. By default Mnesia considers the first field of a row to be its key. It also gives no way to have an auto-incrementing integer key as far as I know.</p>
<p>Given I have these fictional records representing my tables:</p>
<pre><code>-record(user, {name, salt, pass_hash, email}).
-record(entry, {title, body, slug}).
-record(user_entry, {user_name, entry_title}).
</code></pre>
<p>I figure using the username may be good enough for some purposes, as with the entry title, in order to identify the resource, but how do I go about maintaining integrity?</p>
<p>Say the user changes its name, or that the entry's title changes after an edit. How do I make sure my data is still correctly related? Updating every table using the username when it changes sounds like a terrible idea no matter how it's put. </p>
<p>What would be the best way to implement some kind of primary key system in Mnesia? </p>
<p>Also, how would an intermediary table like 'user_entry' do if the first field is usually the key? Otherwise, what would a better way be to represent a many-to-many relationship in Mnesia?</p>
| [
{
"answer_id": 395343,
"author": "Alexey Romanov",
"author_id": 9204,
"author_profile": "https://Stackoverflow.com/users/9204",
"pm_score": 4,
"selected": true,
"text": "{now(), node()} now/0 -record(user, {id, name, salt, pass_hash, email, entries}).\n-record(entry, {id, title, body, sl... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35344/"
] |
395,220 | <p>I have been learning to use Emacs for a little while now. So far liking it a lot.</p>
<p>My problem is that for little C codes I prefer using Rake instead of Make. However flymake does not seem to want anything else than Make. As it complains that it can not find Makefile. From the command line Rake is used in the same way as Make so I was wondering if there was some emacs configuration I could enter to allow Rake to be used by flymake?</p>
<p>To correct a bit what I am doing. I'm not actually editing a Rakefile. And flymake-ruby does not help at all. I'm working with C code. I just use RAKE to compile the c code using gcc instead of MAKE.</p>
| [
{
"answer_id": 402057,
"author": "genehack",
"author_id": 39933,
"author_profile": "https://Stackoverflow.com/users/39933",
"pm_score": 3,
"selected": true,
"text": "(defun flymake-get-make-cmdline (source base-dir)\n (list \"make\"\n (list \"-s\"\n \"-C\"\n base-di... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395220",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5601/"
] |
395,232 | <p>I was reading the following article:
<a href="http://msdn.microsoft.com/en-us/magazine/cc817398.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/magazine/cc817398.aspx</a>
"Solving 11 Likely Problems In Your Multithreaded Code" by Joe Duffy</p>
<p>And it raised me a question:
"We need to lock a .NET Int32 when reading it in a multithreaded code?"</p>
<p>I understand that if it was an Int64 in a 32-bit SO it could tear, as it is explained in the article. But for Int32 I imagined the following situation:</p>
<pre><code>class Test
{
private int example = 0;
private Object thisLock = new Object();
public void Add(int another)
{
lock(thisLock)
{
example += another;
}
}
public int Read()
{
return example;
}
}
</code></pre>
<p>I don't see a reason to include a lock in the Read method. Do you?</p>
<p><strong>Update</strong> Based on the answers (by Jon Skeet and ctacke) I understand that the code above still vulnerable to multiprocessor caching (each processor has its own cache, unsynchronized with others). All the three modifications bellow fix the problem:</p>
<ol>
<li>Adding to "int example" the "volatile" property</li>
<li>Inserting a Thread.MemoryBarrier(); before the actual reading of "int example"</li>
<li>Read "int example" inside a "lock(thisLock)"</li>
</ol>
<p>And I also think that "volatile" is the most elegant solution.</p>
| [
{
"answer_id": 395269,
"author": "Ian Boyd",
"author_id": 12597,
"author_profile": "https://Stackoverflow.com/users/12597",
"pm_score": 2,
"selected": false,
"text": "i++;\n i i i = 8;\n"
},
{
"answer_id": 395270,
"author": "Mark Brackett",
"author_id": 2199,
"author_... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48465/"
] |
395,234 | <p>"make" is not only useful for building your programming project, but it seems to be under-used in other areas.</p>
<p>For example, many shell scripts can be rewritten as Makefiles to allow independent parts to run in parallel (with "make -jXX") to keep all your CPU cores busy, with the explicitly declared dependencies as an added benefit in case you'd ever consider reordering some tasks with side effects in your shell script.</p>
<p>Do you have any interesting stories with unusual uses of make / Makefiles to share? Do you use some other utility as a cheap job scheduler?</p>
| [
{
"answer_id": 395544,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 1,
"selected": false,
"text": "make make -f script.mk MACRO=\"list of files on which to operate\"\n make -f script.mk MACRO=\"$(echo *[io]*)\"\n... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2128202/"
] |
395,237 | <p>I have a View that can vary significantly, depending on the 'mode' a particular user has chosen.</p>
<p>I thought I would extract the different behavior into two different Helpers, and then have code like this in the Controller:</p>
<pre><code>class MyController < ApplicationController
case mode
when 'mode1'
helper "mode1"
when 'mode2'
helper "mode2"
else
raise "Invalid mode"
end
etc...
</code></pre>
<p>Once the correct helper is loaded, then a statement like <%= edit_item %> , which is defined in both helpers, will load the correct form for the particular 'mode'.</p>
<p>This works beautifully in development, but in production, the case statement is only run once. Then you are stuck with whatever helper was first loaded (Duh! I should have known that.)</p>
<p>I have thought of other ways to achieve what I need to do, but I still think this use of Helpers is a nice clean way to change behavior of a View. </p>
<p>Does anyone know how I can load (or reload) a helper at runtime?</p>
<p>TIA: John </p>
| [
{
"answer_id": 395544,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 1,
"selected": false,
"text": "make make -f script.mk MACRO=\"list of files on which to operate\"\n make -f script.mk MACRO=\"$(echo *[io]*)\"\n... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44317/"
] |
395,247 | <p>Anybody have good examples of usability disasters?</p>
<p>Here's an example. Hector is a manager with a large team. Department admin wants to send Hector a spreadsheet with his team's salaries. She types "Hector" in the Outlook "To:" field. It autocompletes to "Hector's Team" but she doesn't notice that until after she sends it.</p>
| [
{
"answer_id": 395282,
"author": "James Brady",
"author_id": 29903,
"author_profile": "https://Stackoverflow.com/users/29903",
"pm_score": 6,
"selected": true,
"text": "<blink>"
}
] | 2008/12/27 | [
"https://Stackoverflow.com/questions/395247",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
395,256 | <p>I am working on a Windows Forms application in VS 2008, and I want to display one image over the top of another, with the top image being a gif or something with transparent parts.</p>
<p>Basically I have a big image and I want to put a little image on top if it, so that they kinda appear as one image to the user.</p>
<p>I've been trying to use a picturebox, but this doesn't seem to have worked, any suggestions?</p>
| [
{
"answer_id": 395300,
"author": "Jon Grant",
"author_id": 18774,
"author_profile": "https://Stackoverflow.com/users/18774",
"pm_score": 2,
"selected": false,
"text": "PictureBox OnPaint e.Graphics.DrawImage() Image.FromFile()"
},
{
"answer_id": 434706,
"author": "Leon Tayson... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30025/"
] |
395,261 | <p>I know that Hpricot is still a standard but I remember hearing about a faster more expressive HTML parser for Ruby.</p>
<p>Does anybody know what it's called and if it is worth switching to from Hpricot??</p>
<p>Thanks in advance</p>
| [
{
"answer_id": 395324,
"author": "Wes Oldenbeuving",
"author_id": 4187,
"author_profile": "https://Stackoverflow.com/users/4187",
"pm_score": 5,
"selected": true,
"text": "hpricot:html:doc 48.930000 3.640000 52.570000 ( 52.900035)\nhpricot2:html:doc 4.500000 0.020000 4.520000 ( 4.518... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395261",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38354/"
] |
395,262 | <p>What would be the jquery equivalent for list.detect in prototype?</p>
| [
{
"answer_id": 395299,
"author": "Tautologistics",
"author_id": 44481,
"author_profile": "https://Stackoverflow.com/users/44481",
"pm_score": 2,
"selected": false,
"text": "jQuery.inArray(value, array);\n"
}
] | 2008/12/27 | [
"https://Stackoverflow.com/questions/395262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49396/"
] |
395,271 | <p>Still new to Objective C, and I'm having some trouble that I just can't seem to figure out on my own. The error occurs twice for each of the first three @properties below, and is:
error: "syntax error before ')' token".</p>
<pre><code>#import <Foundation/Foundation.h>
@interface PolygonShape : NSObject {
int *numberOfSides;
int *minimumNumberOfSides;
int *maximumNumberOfSides;
}
@property (setter = setNumberOfSides) int *numberOfSides;
@property (setter = setMin) int *minimumNumberOfSides;
@property (setter = setMax) int *maximumNumberOfSides;
@property (readonly, getter = angleInDegrees) float *angleInDegrees;
@property (readonly, getter = angleInRadians) float *angleInRadians;
@property (readonly, getter = name) NSString *name;
- (id) init;
- (id) initWithSides: (int*) sides min: (int*) min max: (int*) max;
- (void) dealloc;
- (BOOL) setNumberOfSides: (int*) num;
- (void) setMin: (int*) num;
- (void) setMax: (int*) num;
- (void) description;
- (float*) angleInDegrees;
- (float*) angleInRadians;
- (NSString*) name;
@end
</code></pre>
<p>Not sure if this would make a difference, but here is a summarized version of the implementation:</p>
<pre><code>#import "PolygonShape.h";
@implementation PolygonShape
@synthesize numberOfSides;
@synthesize minimumNumberOfSides;
@synthesize maximumNumberOfSides;
...
- (BOOL) setNumberOfSides: (int*) num {
if(num > minimumNumberOfSides && num < maximumNumberOfSides) {
[numberOfSides release];
numberOfSides = [num retain];
return YES;
} else {
NSLog(@"Number %i is out of range %i to %i", num, minimumNumberOfSides, maximumNumberOfSides);
return NO;
}
}
- (BOOL) setMin: (int*) num {
if(num > 2 && num <= maximumNumberOfSides) {
[minimumNumberOfSides release];
minimumNumberOfSides = [num retain];
return YES;
} elseif (num > 2 && maximumNumberOfSides == nil) {
[minimumNumberOfSides release];
[self setMax: 12];
minimumNumberOfSides = [num retain];
return YES;
} elseif (num > 2) {
NSLog(@"Polygons must have more than 2 sides.");
return NO;
} else {
NSLog(@"Please enter a number less than or equal to %i, the current maximum", maximumNumberOfSides);
return NO;
}
}
- (void) setMax: (int*) num {
if(num <= 12 && num < maximumNumberOfSides) {
[maximumNumberOfSides release];
maximumNumberOfSides = [num retain];
} elseif (num <= 12) {
NSLog(@"Please enter a number less than or equal to 12");
} else {
NSLog(@"Please enter a number greater than or equal to %i, the current minimum", minimumNumberOfSides);
}
}
...
@end
</code></pre>
<p>Thanks in advance for your help!</p>
| [
{
"answer_id": 395683,
"author": "Ashley Clark",
"author_id": 4556,
"author_profile": "https://Stackoverflow.com/users/4556",
"pm_score": 2,
"selected": true,
"text": "setNumberOfSides: @interface Foo\n@property (readwrite, setter = setNumberOfSides:) int numberOfSides;\n@end\n"
},
{... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29297/"
] |
395,275 | <p>I am trying to design an object model (for C#), and can't work out the best way to store the data. I'll try to use a simple example to illustrate this!</p>
<p>I have an object "pet", which could be one of, "cat", "dog" etc. So I have created an "pet" class with a "petType" enum to store this.</p>
<p>Now this is where it gets tricky. If an "pet" is a "cat", then its "food" could be one of "fish", "milk" etc. If it is a "dog" then its "food" could be "meat", "biscuits" or something.</p>
<p>Now should I create a big enum for "fish", "milk", "meat" and "biscuits" and somehow code it so that a "cat" cannot be assigned "food.meat"?
It wouldnt really make sense for my "pet" class to have a "catfood" and "dogfood" enum, because thats not extensible and it will end up storing loads of enums that are null.</p>
<p>Is there an elegant solution to this that I'm not seeing?</p>
| [
{
"answer_id": 395302,
"author": "abatishchev",
"author_id": 41956,
"author_profile": "https://Stackoverflow.com/users/41956",
"pm_score": 3,
"selected": true,
"text": "interface IPet { }\n\nclass Cat : IPet\n{\n public void eat(CommonFood food) { }\n public void eat(CatFood food) ... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395275",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30025/"
] |
395,286 | <p>I like the Stack Overflow comment UI a great deal and I'm looking into implementing the same thing on my own website. I looked at the code and it looks like the main tool here is <a href="http://wmd-editor.com/" rel="nofollow noreferrer">WMD</a>, with the JQuery <a href="http://plugins.jquery.com/project/TextAreaResizer" rel="nofollow noreferrer">TextArea Resizer</a> playing a supporting role.</p>
<p>WMD converts Markdown into HTML on the client side. That's pretty nice because it helps out with previewing but I run into a challenge when sending that to the server. If there's a validation error (say the user entered an invalid e-mail address on some other part of the comment form, or he didn't enter his name maybe), then the server responds by redisplaying the form with an error message and the form fields prepopulated. Only now the comment text is HTML, not Markdown, because the server never even saw the Markdown. But I would like it to be Markdown since that's what the user was entering.</p>
<p>Any ideas here?</p>
<p>I've considered various ideas:</p>
<ul>
<li>Do a server-side <a href="https://stackoverflow.com/questions/59557/html-to-markdown-with-java">HTML-to-Markdown transformation</a>. Not that excited about this idea. Seems hokey to transform from Markdown to HTML back to Markdown again, and as a user I always find it irritating when the software reformats my text/code.</li>
<li>Client-side validation (to augment the server-side validation, which I would of course retain). Seems like a reasonable direction though currently I'm using reCAPTCHA on my comment forms, which means that I need to post at least the reCAPTCHA part to a server.</li>
<li>Lose WMD and use <a href="http://code.google.com/p/markdownj/" rel="nofollow noreferrer">MarkdownJ</a> to transform the Markdown to HTML on the server. I'd need to look for some other mechanism for accomplishing the preview function, which I want to keep.</li>
</ul>
<p>Ideally there'd be some way to get at the Markdown version of the text and submit that to the server in addition to the HTML, but I'm not enough of a JavaScript guy to know whether that's a real possibility.</p>
<p>Any suggestions appreciated.</p>
| [
{
"answer_id": 395964,
"author": "Jeduan Cornejo",
"author_id": 33560,
"author_profile": "https://Stackoverflow.com/users/33560",
"pm_score": 3,
"selected": false,
"text": "wmd_options = {\n //Markdown or HTML\n output: \"Markdown\"\n };\n"
}
] | 2008/12/27 | [
"https://Stackoverflow.com/questions/395286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
395,317 | <p>I am trying to test that a particular method throws an expected exception from a method. As per JUnit4 documentation and <a href="https://stackoverflow.com/questions/156503/how-to-assert-that-a-certain-exception-is-thrown-in-junit45-tests">this answer</a> I wrote the test as:</p>
<pre><code>@Test(expected=CannotUndoException.class)
public void testUndoThrowsCannotUndoException() {
// code to initialise 'command'
command.undo();
}
</code></pre>
<p>However, this code fails the JUnit test, reporting the thrown (and expected) exception as an error.</p>
<p>The method I'm testing has only this in the body:</p>
<pre><code>public void undo() {
throw new CannotUndoException();
}
</code></pre>
<p>Furthermore, the following test passes:</p>
<pre><code>public void testUndoThrowsCannotUndoException() {
// code to initialise 'command'
try {
command.undo();
fail();
} catch (CannotUndoException cue){
}
}
</code></pre>
<p>Meaning that the expected exception is actually thrown.</p>
<p>I am actually planning to change the method to actually do something, rather than just throw the exception, but it's got me curious as to what caused the problem, lest it should happen again in the future.</p>
<p>The following checks have been made: </p>
<ul>
<li>the CannotUndoException imported into the test case is the correct one</li>
<li>version 4 of JUnit is the only one on my classpath </li>
<li>a clean and build of Eclipse workspace did not change the outcome</li>
</ul>
<p>I am using JUnit 4.1, and in the same test I am using Mockito.</p>
<p>What could be causing the erroneous failure?</p>
| [
{
"answer_id": 395334,
"author": "duffymo",
"author_id": 37213,
"author_profile": "https://Stackoverflow.com/users/37213",
"pm_score": 0,
"selected": false,
"text": "public class UndoCommand\n{\n public void undo()\n {\n throw new CannotUndoException();\n }\n}\n // Note: ... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395317",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4120/"
] |
395,321 | <p>I've got the following Generic usercontrol declared:</p>
<pre><code>public partial class MessageBase<T> : UserControl
{
protected T myEntry;
public MessageBase()
{
InitializeComponent();
}
public MessageBase(T newEntry)
{
InitializeComponent();
myEntry = newEntry;
}
}
}
</code></pre>
<p>But the compiler won't allow me to do this:</p>
<pre><code>public partial class MessageControl : MessageBase<Post>
{
public MessageControl()
{
InitializeComponent();
}
}
</code></pre>
<p>How do I create a generic user control in C#?</p>
| [
{
"answer_id": 395344,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 1,
"selected": false,
"text": "Type object GetType() Activator.CreateInstance TypeDescriptor"
},
{
"answer_id": 395446,
"author": "rnwoo... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5648/"
] |
395,340 | <p>I have the following classes: Ingredients, Recipe and RecipeContent...</p>
<pre><code>class Ingredient(models.Model):
name = models.CharField(max_length=30, primary_key=True)
qty_on_stock = models.IntegerField()
def __unicode__(self):
return self.name
class Recipe(models.Model):
name = models.CharField(max_length=30, primary_key=True)
comments = models.TextField(blank=True)
ingredient = models.ManyToManyField(Ingredient)
def __unicode__(self):
return self.name
class RecipeContent(models.Model):
recipe = models.ForeignKey(Recipe)
ingredients = models.ForeignKey(Ingredient)
qty_used = models.IntegerField()
</code></pre>
<p>but for __unicode__() in RecipeContent I would like to use the Recipe name to which this RecipeContent belongs to... is there a way to do it?</p>
| [
{
"answer_id": 395347,
"author": "jb.",
"author_id": 37522,
"author_profile": "https://Stackoverflow.com/users/37522",
"pm_score": 6,
"selected": true,
"text": "class RecipeContent(models.Model):\n ...\n def __unicode__(self):\n # You can access ForeignKey properties through the fie... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48540/"
] |
395,377 | <p>I'm using an AMP server (Apache 1.3, MySQL 5.0, PHP 5.1.5) which I have found to only allow 1 connection/request per browser at one time. The easiest way to reporduce this is to request a large download which is passed through PHP and try to access another page at the same time. You will end up waiting for the first request (the file download) to complete before the other page loads.</p>
<p>I'm not sure if the problem is Apache, MySQL or PHP. Any ideas where I should start looking?</p>
<p>I can make other requests through other browsers on the same computer.</p>
| [
{
"answer_id": 395404,
"author": "Tom Haigh",
"author_id": 22224,
"author_profile": "https://Stackoverflow.com/users/22224",
"pm_score": 2,
"selected": false,
"text": "session_write_close()"
}
] | 2008/12/27 | [
"https://Stackoverflow.com/questions/395377",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] |
395,379 | <p>I'm having a strange problem when retrieving JSON formatted text. I use jQuery <code>post</code> to send some data (also JSON formatted) to the server (running PHP) which works fine. Then, when I request the same data from the server using jQuery <code>get</code>, the callback method never executes. This only occurs when the data is JSON formatted and the data contains a line break. When I don't use JSON formatting it works fine. What baffles me is that there are no problems with uploading the data.</p>
<p>Uploading code: (works)</p>
<pre><code>$.post("ajax/contents_ajax.php", {
'title': caption,
'text': frameText().getContent(),
'image_id': img
},
//Callback
</code></pre>
<p>Download code: (doesn't work with line breaks)</p>
<pre><code>$.get("ajax/contents_ajax.php", { 'get_item': id },
function (data){
//Never gets executed if data contains line breaks
}
,'json');
</code></pre>
<p>The whole problem stems from the fact that the TinyMCE rich text editor seems to insist on inserting line breaks everywhere, even though I enabled the option</p>
<pre><code>remove_linebreaks : true
</code></pre>
<p>I do prefer to have line breaks, but not if they break my code. Can anyone tell me what the problem is here, and perhaps how I can encode the linebreaks on the server with PHP?</p>
<hr>
<h2>Update</h2>
<p>While the suggestions to replace <code>'\n'</code> with <code>''</code> did not work, it was close to the right solution. This code removed the offending characters:</p>
<pre><code>function parse($text){
$parsedText = str_replace(chr(10), "", $text);
return str_replace(chr(13), "", $parsedText);
}
</code></pre>
| [
{
"answer_id": 395390,
"author": "ThoKra",
"author_id": 38254,
"author_profile": "https://Stackoverflow.com/users/38254",
"pm_score": 1,
"selected": false,
"text": "<?php\n$string = 'asdfasf<br />asdfasf';\necho str_replace('<br />', '', $strin); // Replace <br /> with '' (nothing)\n?>\n... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4055/"
] |
395,388 | <p>I'm a configuration manager and I'm working on Windows and UNIX environments.
Currently, I have to create the views by myself for the developers and QA engineers.
Is there any better approach?</p>
<p>Thanks.</p>
| [
{
"answer_id": 395479,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 0,
"selected": false,
"text": "newview -p /work5/atria bug129201\n ct cleartool cleartool #!/bin/ksh\n#\n# @(#)$Id: newview.sh,v 1.8 2008/03/1... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395388",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
395,401 | <p>I wish to print a <code>Stack<Integer></code> object as nicely as the Eclipse debugger does (i.e. <code>[1,2,3...]</code>) but printing it with <code>out = "output:" + stack</code> doesn't return this nice result.</p>
<p>Just to clarify, I'm talking about Java's built-in collection so I can't override its <code>toString()</code>.</p>
<p>How can I get a nice printable version of the stack?</p>
| [
{
"answer_id": 395403,
"author": "Zach Langley",
"author_id": 45230,
"author_profile": "https://Stackoverflow.com/users/45230",
"pm_score": 9,
"selected": true,
"text": "Arrays.toString(Object[]) System.out.println(Arrays.toString(stack.toArray()));\n"
},
{
"answer_id": 395407,
... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55094/"
] |
395,402 | <p>I have some old perl code which recently stopped working on a FreeBSD box. The code which fails looks (in simplest form) like this:</p>
<pre><code>#!/usr/local/bin/perl -w
use strict;
use DBI;
my $datasource = "DBI:mysql:dbname:hostname.domain.com";
my $user = "username";
my $pass = "password";
DBI->connect($datasource, $user, $pass);
</code></pre>
<p>This fails with the following error:</p>
<pre><code>/libexec/ld-elf.so.1: /usr/local/lib/mysql/libmysqlclient.so.15: Undefined symbol "gethostbyname_r"
</code></pre>
<p>If I change the datasource to reference "localhost" the code succeeds.</p>
<p>I've reinstalled mysql-client, DBI, and DBD-mysql from ports; no effect.</p>
<p>Other applications on this server (PHP, command line tools) are able to access mysql databases by hostname without trouble.</p>
<p>Suggestions for how to resolve this?</p>
<p>EDITED TO ADD: I notice that my box has both <code>libmysqlclient.so.15</code> and <code>libmysqlclient_r.so.15</code>. Could the problem be that DBD::mysql is trying to use libmysqlclient when it should be using libmysqlclient_r? And if so, how to resolve?</p>
| [
{
"answer_id": 395413,
"author": "max",
"author_id": 49407,
"author_profile": "https://Stackoverflow.com/users/49407",
"pm_score": 2,
"selected": false,
"text": "make config"
},
{
"answer_id": 395414,
"author": "Community",
"author_id": -1,
"author_profile": "https://... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395402",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36754/"
] |
395,424 | <p>Greetings.</p>
<p>1 - Let's say I have about 500 folders of variable size with a total size of 100 GB.</p>
<p>2 - I want to distribute these folders automatically in other folders until the size of 700 MB is reached with the best optimization of space.</p>
<p>Example: In folder "CD--01" I want to have the maximum number of folders possible without passing the limit of 700 MB, and so on in "CD--02", "CD--03"...</p>
<p>Is there a tool that allows me to do this "on the fly" or will I have to code one myself?</p>
<p>Thanks</p>
| [
{
"answer_id": 395491,
"author": "frankodwyer",
"author_id": 42404,
"author_profile": "https://Stackoverflow.com/users/42404",
"pm_score": 0,
"selected": false,
"text": "tar cvzf allfolders.tgz ./allfolders\nsplit allfolders.tgz -b 700m\n"
},
{
"answer_id": 395696,
"author": ... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395424",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49416/"
] |
395,430 | <p>Okay, I have this program and I don't want more than one instance of it running. So what I have right now is it grabs all instances that match it's name, and if there are more than one it quits and lets the user know it's already running in another instance.</p>
<p>However, there is a special case in which the new instance will want change what the other instance is doing, then it will exit. How can I do this?</p>
<p>Here's an example:
I have this program that times an event. I don't want more than one running at the same time because you can't be doing two things at once (for this application). Now say a third party program wants to notify this thread that the user is now working on something else, so it launches the application again. If the application is already running, it will update it's actions, else it will act as normal.</p>
<p>How can this be done?</p>
<p>This is what I use to tell if there is another instance running:</p>
<pre><code> string proc = Process.GetCurrentProcess().ProcessName;
Process[] processess = Process.GetProcessesByName(proc);
if (processess.Length > 1) {
MessageBox.Show("There is an instance of the Timer already running");
return;
}
</code></pre>
| [
{
"answer_id": 395516,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 3,
"selected": true,
"text": " program start\n try to acquire mutex (or semaphore)\n if failed\n send message via message queue to running prog... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12243/"
] |
395,431 | <p>I am working on a legacy system and have introduced fluent nHibernate but have one last mapping that I can not seem to get working.</p>
<p>Code:</p>
<pre><code>public class Permit
{
public int PermitId { get; set; }
public char Discipline { get; set; }
public PermitDetails PermitDetails { get; set; }
}
public PermitDetails
{
public int PermitId { get; set; }
}
public class GasPermitDetails : PermitDetails
{
... permit details
}
public class ElectricalPermitDetails : PermitDetails
{
... permit details
}
</code></pre>
<p>Schema:</p>
<pre><code>*tblPermit*
PermitId, int
Discipline, char
.... some other columns
*tblGas*
PermitId, int
....gasDetails
*tblElectrical*
PermitId, int
....electrical details
</code></pre>
<p>If <code>tblPermit.Discipline</code> is <code>"G"</code>, we need to get the data out of <code>tblGas</code>. If <code>tblPermit.Discipline</code> is <code>"E"</code>, we need to get the data out of <code>tblElectrical</code>. I have messing around trying to get this figured out but have not had any luck so far.</p>
| [
{
"answer_id": 395516,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 3,
"selected": true,
"text": " program start\n try to acquire mutex (or semaphore)\n if failed\n send message via message queue to running prog... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37723/"
] |
395,432 | <p>I have this on line 56 in my environment.rb:</p>
<pre><code>I18n.load_path += Dir[ File.join(RAILS_ROOT, 'lib', 'locale', '*.{rb,yml}') ]
</code></pre>
<p>I can run the app just fine, but when I try to run:
script/generate migration</p>
<p>I get this error:</p>
<pre><code>environment.rb:56: uninitialized constant I18n (NameError)
</code></pre>
<p>What gives?</p>
| [
{
"answer_id": 396360,
"author": "swenson",
"author_id": 10524,
"author_profile": "https://Stackoverflow.com/users/10524",
"pm_score": 2,
"selected": true,
"text": "active_support I18n environment.rb environment.rb config.i18n.load_path << Dir[File.join(RAILS_ROOT, 'my', 'locales', '*.{r... | 2008/12/27 | [
"https://Stackoverflow.com/questions/395432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4025/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.