qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
351,360 | <p>I've got this small question - given a bitmask of weekdays (e.g., <code>Sunday = 0x01, Monday = 0x02, Tuesday = 0x04</code>, etc...) and today's day (in a form of <code>Sunday = 1, Monday = 2, Tuesday = 3</code>, etc...) - what's the most elegant way to find out the next day from today, that's set in the bitmask? By elegant I mean, is there a way to do this without if/switch/etc..., because I know the non-elegant way?</p>
<p><strong>Edit</strong> I probably should've mentioned (to make this more clear) that the variable holding the bitmask can have several of the days set, so for example (roughly):</p>
<pre><code>uDay = Sunday | Monday;
today = Tuesday;
</code></pre>
<p>I need to get "Sunday"</p>
| [
{
"answer_id": 351387,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 1,
"selected": false,
"text": "// returns t (today) if no weekday is set in the mask.\nint getNextDay(int m, int t) {\n int i, idx;\n ... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351360",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20208/"
] |
351,368 | <p>I have an asp page that uses jQuery ajax to load member counts into a bunch of <code>div</code>s after a page is loaded.</p>
<p>It works perfectly well in FireFox, and with clients that have a small number of groups.</p>
<p>For the small number of clients that have many groups (500+), I am getting an error in IE. The ajax calls seem to be running synchronously, because the click events won't register until every ajax call has returned.</p>
<p>The series of ajax requests is just 1 request for most clients. It is only broken up into multiple requests for clients with a VERY large number of groups.</p>
<p>Now, I've seen the bug where <code>$("a").click</code> functions are not bound if links are added after the DOM is loaded. The links that aren't working are not being loaded by AJAX, they do not fall into this category.</p>
<p>Here is the pseudocode:</p>
<pre><code>ready()
{
// count the number of groups that this user has, adding the ids to a list
if( count < 50 )
{
runAjax();
}
else
{
// this calls the ajax request on groups of 50 ids
// it pauses briefly after each request by using setTimeout to call the next
runAjaxRecursively();
}
}
</code></pre>
<p>And here is the ajax request:</p>
<pre><code>// run the HTTPRequest
$.ajax({
async: true,
type: "POST",
url: "emailcatcount.asp?idList="+idList,
data: "idList="+idList,
dataType: "html",
success: function(html) { // blah blah blah }
});
</code></pre>
<p>Anyway, the code works fine, so please consider any errors as typos. The only problem is that, in IE, click events won't fire until every single ajax call has returned.</p>
<p>Does anyone know why this would occur? Notice that I am setting <code>async</code> to true.</p>
<p>Does it have anything to do with how jQuery's ready event is processed in IE?</p>
<p>I am bewildered, and have spent a few days on this, so any ideas are appreciated.</p>
| [
{
"answer_id": 351387,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 1,
"selected": false,
"text": "// returns t (today) if no weekday is set in the mask.\nint getNextDay(int m, int t) {\n int i, idx;\n ... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1311247/"
] |
351,371 | <p>You may have seen JavaScript sliders before:</p>
<p><a href="http://dev.jquery.com/view/tags/ui/1.5b2/demos/ui.slider.html" rel="nofollow noreferrer">http://dev.jquery.com/view/tags/ui/1.5b2/demos/ui.slider.html</a></p>
<p>What I'm envisioning is a circular slider. It would consist of a draggable button at one point on the circle -- and that button can be dragged anywhere along the ring. The value depends on what position the button is at (think of a clock).</p>
| [
{
"answer_id": 351384,
"author": "Jimmy",
"author_id": 4435,
"author_profile": "https://Stackoverflow.com/users/4435",
"pm_score": 3,
"selected": true,
"text": "var dx = m.x-c.x;\nvar dy = m.y-c.y;\n\nvar scale = radius/Math.sqrt(dx*dx+dy*dy);\n\nslider.x = dx*scale + c.x;\nslider.y = dy... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32881/"
] |
351,373 | <p>In the context of creating a custom Eclipse distribution for a development team.</p>
<p>How would I go about building a custom Eclipse distribution containing a specific set of plugins? Would it be difficult to also add a kind of update site to put specific versions of the plug-ins from which the customized eclipse would update?</p>
| [
{
"answer_id": 15806377,
"author": "Paul Verest",
"author_id": 482717,
"author_profile": "https://Stackoverflow.com/users/482717",
"pm_score": 2,
"selected": false,
"text": "<?xml version='1.0' encoding='UTF-8'?>\n<?p2f version='1.0.0'?>\n<p2f version='1.0.0'>\n <ius size='5'>\n <iu ... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39057/"
] |
351,375 | <p>So we've been told that one source of <code>TM Enq</code> contention can be unindexed FK's. My question is which one.</p>
<p>I have an <code>INSERT INTO Table_B</code> that is recording <code>TM Enq Wait</code>.</p>
<p>It contains a <code>PK</code> that is the parent to other tables and it has columns that are <code>FK</code> constrained to other <code>PK</code>s.</p>
<p>So which <code>FK</code>s need indexed: that table's columns or its children?</p>
<p>NB: I know that this isn't the only cause of TM Contention. Can you explain why it couldn't possibly be this if that's the case.</p>
| [
{
"answer_id": 351637,
"author": "derobert",
"author_id": 27727,
"author_profile": "https://Stackoverflow.com/users/27727",
"pm_score": 2,
"selected": false,
"text": "SELECT o.something\n FROM oltp_tab o JOIN lookup l ON (o.lookup_no = l.lookup_no)\n WHERE l.lookup_name = ?\n"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/351375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
351,380 | <p>Starting recently, some of my new web pages (XHTML 1.1) are setup to do a regex of the request header <code>Accept</code> and send the right HTTP response headers if the user agent accepts XML (Firefox and Safari do).</p>
<p>IE (or any other browser that doesn't accept it) will just get the plain <code>text/html</code> content type. </p>
<p>Will Google bot (or any other search bot) have any problems with this? Is there any negatives to my approach I have looked over? Would you think this header sniffer would have much effect on performance?</p>
| [
{
"answer_id": 351411,
"author": "Alohci",
"author_id": 42585,
"author_profile": "https://Stackoverflow.com/users/42585",
"pm_score": 4,
"selected": true,
"text": "application/xhtml+xml"
},
{
"answer_id": 413536,
"author": "Kornel",
"author_id": 27009,
"author_profile... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351380",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31671/"
] |
351,409 | <p>How do I append an object (such as a string or number) to an array in JavaScript? </p>
| [
{
"answer_id": 351421,
"author": "jdecuyper",
"author_id": 296,
"author_profile": "https://Stackoverflow.com/users/296",
"pm_score": 13,
"selected": true,
"text": "Array.prototype.push"
},
{
"answer_id": 351444,
"author": "MK_Dev",
"author_id": 39843,
"author_profile"... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8482/"
] |
351,415 | <p>I need to programatically find the users name using C#. Specifically, I want to get the system/network user attached to the current process. I'm writing a web application that uses windows integrated security.</p>
| [
{
"answer_id": 351876,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 5,
"selected": false,
"text": "IPrincipal"
},
{
"answer_id": 28427047,
"author": "Mehdi Bugnard",
"author_id": 1429232,
"author_... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4491/"
] |
351,443 | <p>The "Application Icon" of my application is wrong.</p>
<p>My application shows in taskbar a different icon than the classic Delphi icon. Instead is shows the icon of one of my VCL's. That specific VCL from which the icon was "stolen" is not used in my application but other VCL's in the same package are used.</p>
<p>Related info:
- The icon looks ok if I drag and drop my app on Desktop.
- The icon looks ok in Windows Commander when I put the cursor on it.
- The icon does not look ok in Windows Commander when I drag and drop it in "Button Bar". Conclusion: the icon is not accidentally changed at the runtime (the problem is there even if the application is not running).</p>
<p>I use Delphi 7. I disabled EurekaLog and FastMM just to be sure, and rebuild the application. The problem still persists. I have not even the slightest clue why the compiler inserts the wrong icon.
I really need some hints.
Thanks.</p>
| [
{
"answer_id": 351914,
"author": "Rob Kennedy",
"author_id": 33732,
"author_profile": "https://Stackoverflow.com/users/33732",
"pm_score": 3,
"selected": false,
"text": "{$R *.RES}"
}
] | 2008/12/09 | [
"https://Stackoverflow.com/questions/351443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
351,456 | <p>The only reliable method that I a have found for using a script to download text from wikipedia is with cURL. So far the only way I have for doing that is to call <code>os.system()</code>. Even though the output appears properly in the python shell I can't seem to the function it to return anything other than the exit code(<code>0</code>). Alternately somebody could show be how to properly use <code>urllib</code>.</p>
| [
{
"answer_id": 351475,
"author": "Sean",
"author_id": 44133,
"author_profile": "https://Stackoverflow.com/users/44133",
"pm_score": 4,
"selected": true,
"text": "import urllib\nsock = urllib.urlopen(\"http://en.wikipedia.org/wiki/Python_(programming_language)\")\nhtmlsource = sock.read()... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26659/"
] |
351,473 | <pre><code>class Child
{
private override void Check_CheckedChanged(object sender, EventArgs e)
{
if (Check.Checked)
{
this.addName(this.FirstName);
this.disableControls();
}
else
{
this.addAddress(this.address);
//this.activatecontrols();// gives error since it's private method in parent.
}
}
}
class Parent
{
private void Check_CheckedChanged(object sender, EventArgs e)
{
if (Check.Checked)
{
this.disablecontrols();
}
else
{
this.addAddress(this.address);
this.activatecontrols();
}
}
}
</code></pre>
<p>I want to fire the the child event if it satisfies if condition. But if can not I need to call the base's else condition as I activatecontrols() is private in Parent. So, how do I call the event? </p>
| [
{
"answer_id": 351494,
"author": "Bryan Watts",
"author_id": 37815,
"author_profile": "https://Stackoverflow.com/users/37815",
"pm_score": 2,
"selected": false,
"text": "ActivateControls"
}
] | 2008/12/09 | [
"https://Stackoverflow.com/questions/351473",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42564/"
] |
351,479 | <p>Not sure if this is intended behavior or a bug or a wrong function that I'm using, but the problem is that PathCombine() returns a wrong path on a Vista box.</p>
<p>The relative path is (as exported by the WMP to a playlist):</p>
<p><code>..\..\..\Public\Music\Sample Music\Amanda.wma</code></p>
<p>The path it's relative to is:</p>
<p><code>C:\Users\userX\Music\Playlists\playlist.wpl</code></p>
<p>and PathCombine() returns:</p>
<p><code>C:\Users\userX\Public\Music\Sample Music\Amanda.wma</code></p>
<p>however, the file is actually located here (judging by the Explorer and the fact that I can't open it from the code):</p>
<p><code>C:\Users\Public\Music\Sample Music\Amanda.wma</code></p>
<p>Is this a known issue? Is there some other function I should be using?</p>
| [
{
"answer_id": 351614,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 2,
"selected": false,
"text": "C:\\Users\\userX\\Music\\Playlists\\playlist.wpl\\..\\..\\..\\Public\\Music\\Sample Music\\Amanda.wma\n"
}
] | 2008/12/09 | [
"https://Stackoverflow.com/questions/351479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20208/"
] |
351,483 | <p>How do I create a ListBox in ASP.NET MVC with single selection mode?</p>
| [
{
"answer_id": 351579,
"author": "Jeffrey Meyer",
"author_id": 2323,
"author_profile": "https://Stackoverflow.com/users/2323",
"pm_score": 6,
"selected": true,
"text": "<%= Html.DropDownList(\"list1\", \n new Dictionary<string, object> {{\"size\", \"5\"}} ) %>\n"
},
{
"answer_... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31624/"
] |
351,484 | <p>I have an application the will load usercontrols dynamically depending on the user. You will see in the example below that I am casting each user control via switch/case statements. Is there a better way to do this? Reflection? (I must be able to add an event handler Bind in each control.)</p>
<pre><code>override protected void OnInit(EventArgs e)
{
cc2007.IndividualPageSequenceCollection pages = new IndividualPageSequenceCollection().Load();
pages.Sort("displayIndex", true);
foreach (IndividualPageSequence page in pages)
{
Control uc = Page.LoadControl(page.PageName);
View view = new View();
int viewNumber = Convert.ToInt32(page.DisplayIndex) -1;
switch(page.PageName)
{
case "indStart.ascx":
IndStart = (indStart) uc;
IndStart.Bind += new EventHandler(test_handler);
view.Controls.Add(IndStart);
MultiView1.Views.AddAt(viewNumber, view);
break;
case "indDemographics.ascx":
IndDemographics = (indDemographics)uc;
IndDemographics.Bind += new EventHandler(test_handler);
view.Controls.Add(IndDemographics);
MultiView1.Views.AddAt(viewNumber, view);
break;
case "indAssetSurvey.ascx":
IndAssetSurvey = (indAssetSurvey)uc;
IndAssetSurvey.Bind += new EventHandler(test_handler);
view.Controls.Add(IndAssetSurvey);
MultiView1.Views.AddAt(viewNumber, view);
break;
}
}
base.OnInit(e);
}
</code></pre>
<p>Thanks in advance!</p>
| [
{
"answer_id": 351505,
"author": "Jeroen Landheer",
"author_id": 44056,
"author_profile": "https://Stackoverflow.com/users/44056",
"pm_score": 1,
"selected": false,
"text": ""
},
{
"answer_id": 351542,
"author": "Andrew Kennan",
"author_id": 22506,
"author_profile": "... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4888/"
] |
351,487 | <p>I am a Delphi novice, but I'm trying to understand the relationship between TApplication and TfrmMain windows using Spy++. It seems that the TfrmMain window is the real window that has proper screen coordinates, but the TApplication window is the one that appears in the Windows taskbar. Also, they don't seem to be related to each other at all. One isn't the parent window of the other, so how are the windows linked together? And why is the non-UI window the one that gets the Windows taskbar button? Can any Delphi experts help me understand this?</p>
| [
{
"answer_id": 351504,
"author": "JamesSugrue",
"author_id": 1075,
"author_profile": "https://Stackoverflow.com/users/1075",
"pm_score": 4,
"selected": true,
"text": "program Project1;\nuses\n Forms,\n Unit1 in 'Unit1.pas' {Form1};\n{$R *.RES}\nbegin\n Application.Initialize;\n Appli... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/343/"
] |
351,489 | <p>How can I get a PL/SQL block to output the results of a <code>SELECT</code> statement the same way as if I had done a plain <code>SELECT</code>?</p>
<p>For example how to do a <code>SELECT</code> like:</p>
<pre><code>SELECT foo, bar FROM foobar;
</code></pre>
<p>Hint :</p>
<pre><code>BEGIN
SELECT foo, bar FROM foobar;
END;
</code></pre>
<p>doesn't work.</p>
| [
{
"answer_id": 351752,
"author": "Sergey Stadnik",
"author_id": 10557,
"author_profile": "https://Stackoverflow.com/users/10557",
"pm_score": 6,
"selected": false,
"text": "DECLARE\n v_foo foobar.foo%TYPE;\n v_bar foobar.bar%TYPE;\nBEGIN\n SELECT foo,bar FROM foobar INTO v_foo, v_b... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351489",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26659/"
] |
351,495 | <p>All the documentation I've found so far is to update keys that are already created:</p>
<pre><code> arr['key'] = val;
</code></pre>
<p>I have a string like this: <code>" name = oscar " </code></p>
<p>And I want to end up with something like this:</p>
<pre><code>{ name: 'whatever' }
</code></pre>
<p>That is, split the string and get the first element, and then put that in a dictionary.</p>
<h3>Code</h3>
<pre><code>var text = ' name = oscar '
var dict = new Array();
var keyValuePair = text.split(' = ');
dict[ keyValuePair[0] ] = 'whatever';
alert( dict ); // Prints nothing.
</code></pre>
| [
{
"answer_id": 351507,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 8,
"selected": true,
"text": "var a = new Array();\na['name'] = 'oscar';\nalert(a['name']);\n"
},
{
"answer_id": 351538,
"author": "Danny"... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20654/"
] |
351,499 | <p>I need to make a pop-up window for users to log-in to my website from other websites.</p>
<p>I need to use a pop-up window to show the user the address bar so that they know it is a secure login, and not a spoof. For example, if I used a floating iframe, websites could spoof my login window and record the user's login information.</p>
<p>Thanks</p>
<p>Additional details: My pop-up will come from javascript code from within an iframe in any domain. I know this sounds like I'm creating adverts.. but really I'm not. If it makes any difference, the iframe domain and the pop-up domain are the same.</p>
<p>1 more detail, I'm looking to do the same thing "Facebook Connect" does... if you aren't logged into facebook, they allow you to login to facebook from any domain by showing a pop-up on that domain's site. For an example, go to any article at techcrunch.com and use Facebook Connect to comment. Make sure you're logged out of facebook and you'll see what I'm talking about.</p>
| [
{
"answer_id": 351513,
"author": "Sean",
"author_id": 44133,
"author_profile": "https://Stackoverflow.com/users/44133",
"pm_score": 3,
"selected": true,
"text": "<script language=\"javascript\" type=\"text/javascript\">\n<!--\nfunction popitup(url) {\n newwindow=window.open(url,'name'... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43005/"
] |
351,519 | <pre><code>typedef union
{
uint ui[4];
} md5hash;
void main(void)
{
int opt;
while ((opt = getopt(argc, argv, "c:t:s:h:")) != -1) {
switch (opt) {
case 'h':
hash = optarg;
break;
default: /* '?' */
exit(EXIT_FAILURE);
}
}
md5hash hash;
sscanf(hash, "%x%x%x%x", &hash.ui);
}
</code></pre>
<p>./program -h ffffffffffffffffffffffffffffffff</p>
<p>I want to do the above, but sscanf does not accept the md5sum properly...</p>
| [
{
"answer_id": 351566,
"author": "dreamlax",
"author_id": 10320,
"author_profile": "https://Stackoverflow.com/users/10320",
"pm_score": 3,
"selected": false,
"text": "sscanf"
},
{
"answer_id": 351968,
"author": "Community",
"author_id": -1,
"author_profile": "https://... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
351,520 | <p>Greetings!</p>
<p>I have an XML value that I'd like to use as a boolean value to toggle the visibility of a Panel. I have something like this:</p>
<pre><code><asp:FormView id="MyFormView" runat="server" DataSourceID="MyXmlDataSource">
<ItemTemplate>
<!-- some stuff -->
<asp:Panel id="MyPanel" runat="server" Visible='<%# (bool)XPath("Menu/Show") %>'>
</asp:Panel>
<!-- some more stuff -->
</ItemTemplate>
</asp:FormView>
<asp:XmlDataSource id="MyXmlDataSource" runat="sever" DataFile="MyFile.xml" />
</code></pre>
<p>However, this throws an exception. I've tried setting the value of Show in my XML to "true", "True", "0", but to no avail. Is this even possible? My XPath definitely works because I've tried moving <%# (bool)XPath("Menu/Show") %> outside so that I can see its value and it is correct. I have tried this:</p>
<pre><code><%#((bool)XPath("Menu/Show")).ToString() %>
</code></pre>
<p>But this also throws an exception.</p>
<p>Thanks.</p>
| [
{
"answer_id": 351529,
"author": "Andrew Rollings",
"author_id": 40410,
"author_profile": "https://Stackoverflow.com/users/40410",
"pm_score": 1,
"selected": false,
"text": "<%#(Convert.ToBoolean(XPath(\"Menu/Show\"))) %>"
},
{
"answer_id": 351568,
"author": "Dan Esparza",
... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27870/"
] |
351,522 | <p>basically, I've got my Huffman table as </p>
<pre><code>std::map<std::string, char> ciMap;
</code></pre>
<p>Where string is the bit pattern and char is the value represented by said pattern.
The problem is how do I store that as a header of my compressed file so I can build again the same map when I want to decode it?</p>
<p>Trying to store it as binary:</p>
<pre><code>size_t mapLen = ciMap.size();
outFile.write(reinterpret_cast<char*>(&mapLen), sizeof(size_t));
outFile.write(reinterpret_cast<char*>(&ciMap), sizeof(ciMap));
</code></pre>
<p>And later building with:</p>
<pre><code>inFile.read(reinterpret_cast<char*>(&mapLen), sizeof(size_t));
inFile.read(reinterpret_cast<char*>(&ciMap), sizeof(mapLen));
</code></pre>
<p>Doesn't work, I get string initilization error... something to do with NULL. Any suggestions? If you have better way of storing the bits and values I'd like to hear.</p>
| [
{
"answer_id": 351535,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 2,
"selected": false,
"text": "std::map"
},
{
"answer_id": 351548,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15345/"
] |
351,546 | <p>I'm trying to show in the screen a table...</p>
<p>Basically I create a custom UITableViewController with the methods needed for the UITableView delegate and data source which is self since UITableViewController does it for you.</p>
<p>When I put it in the <code>-initWithRootView:</code> controller, and add the nav's bar view to the window it doesn't show! With debugging, the table is being created and all, but the delegate methods are never called!</p>
<p>Any ideas?</p>
| [
{
"answer_id": 351535,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 2,
"selected": false,
"text": "std::map"
},
{
"answer_id": 351548,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
351,547 | <p>I've used the Views Theming Wizard to output a template and it gave me the following chunk of code to go in template.php.</p>
<p>I'd prefer to just maintain the one template, so all my functions will be calling the same one, and rather than writing numerous versions of the same function, I'm wondering if there's a way to string function names together? Something like:</p>
<pre><code>function phptemplate_views_view_list_recent_articles($view, $nodes, $type),
phptemplate_views_view_list_popular_articles($view, $nodes, $type) {
$fields = _views_get_fields();
$taken = array();
// Set up the fields in nicely named chunks.
foreach ($view->field as $id => $field) {
$field_name = $field['field'];
if (isset($taken[$field_name])) {
$field_name = $field['queryname'];
}
$taken[$field_name] = true;
$field_names[$id] = $field_name;
}
// Set up some variables that won't change.
$base_vars = array(
'view' => $view,
'view_type' => $type,
);
foreach ($nodes as $i => $node) {
$vars = $base_vars;
$vars['node'] = $node;
$vars['count'] = $i;
$vars['stripe'] = $i % 2 ? 'even' : 'odd';
foreach ($view->field as $id => $field) {
$name = $field_names[$id];
$vars[$name] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
if (isset($field['label'])) {
$vars[$name . '_label'] = $field['label'];
}
}
$items[] = _phptemplate_callback('views-list-first-with-abstract', $vars);
}
if ($items) {
return theme('item_list', $items);
}
}
</code></pre>
<p>Thanks,<br />
Steve</p>
| [
{
"answer_id": 353285,
"author": "pdemarest",
"author_id": 40332,
"author_profile": "https://Stackoverflow.com/users/40332",
"pm_score": 3,
"selected": true,
"text": "function phptemplate_views_view_list_recent_articles($view, $nodes, $type){\n actual_template_function($view, $n... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16124/"
] |
351,557 | <p>I'm trying to insert a column into an existing DataSet using C#.</p>
<p>As an example I have a DataSet defined as follows:</p>
<pre><code>DataSet ds = new DataSet();
ds.Tables.Add(new DataTable());
ds.Tables[0].Columns.Add("column_1", typeof(string));
ds.Tables[0].Columns.Add("column_2", typeof(int));
ds.Tables[0].Columns.Add("column_4", typeof(string));
</code></pre>
<p>later on in my code I am wanting to insert a column between column 2 and column 4.</p>
<p>DataSets have methods for adding a column but I can't seem to find the best way in insert one.</p>
<p>I'd like to write something like the following...</p>
<pre><code>...Columns.InsertAfter("column_2", "column_3", typeof(string))
</code></pre>
<p>The end result should be a data set that has a table with the following columns:
column_1 column_2 column_3 column_4</p>
<p>rather than:
column_1 column_2 column_4 column_3 which is what the add method gives me</p>
<p>surely there must be a way of doing something like this.</p>
<p><strong>Edit</strong>...Just wanting to clarify what I'm doing with the DataSet based on some of the comments below:</p>
<blockquote>
<p>I am getting a data set from a stored
procedure. I am then having to add
additional columns to the data set
which is then converted into an Excel
document. I do not have control over
the data returned by the stored proc
so I have to add columns after the
fact.</p>
</blockquote>
| [
{
"answer_id": 351631,
"author": "lomaxx",
"author_id": 493,
"author_profile": "https://Stackoverflow.com/users/493",
"pm_score": 7,
"selected": true,
"text": "DataSet ds = new DataSet();\nds.Tables.Add(new DataTable());\nds.Tables[0].Columns.Add(\"column_1\", typeof(string));\nds.Tables... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39532/"
] |
351,565 | <h2><strong>Accuracy Vs. Precision</strong></h2>
<p>What I would like to know is whether I should use <strong>System.currentTimeMillis()</strong> or <strong>System.nanoTime()</strong> when updating my object's positions in my game? Their change in movement is directly proportional to the elapsed time since the last call and I want to be as precise as possible.</p>
<p>I've read that there are some serious time-resolution issues between different operating systems (namely that Mac / Linux have an almost 1 ms resolution while Windows has a 50ms resolution??). I'm primarly running my apps on windows and 50ms resolution seems pretty inaccurate.</p>
<p>Are there better options than the two I listed?</p>
<p>Any suggestions / comments?</p>
| [
{
"answer_id": 351571,
"author": "dancavallaro",
"author_id": 42891,
"author_profile": "https://Stackoverflow.com/users/42891",
"pm_score": 9,
"selected": true,
"text": "System.nanoTime()"
},
{
"answer_id": 351572,
"author": "Paul Morel",
"author_id": 1311247,
"author... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2635/"
] |
351,578 | <p>I need to make OK and Cancel buttons in my HTML, and I'd like them to be a fixed width so the two buttons are the same size. For example, like this:</p>
<pre><code><style>
button.ok_cancel {
width: 50px;
background-color: #4274af;
font-size: 9px;
line-height: 12px;
color: #fff;
cursor: pointer;
text-transform: uppercase;
padding: 1px;
border: 0px;
margin: 0 0 0 5px;
text-align: center;
letter-spacing: 1px;
}
</style>
<button class="ok_cancel" onclick="do_cancel()">Cancel</button>
</code></pre>
<p>But now I'm localizing the text, and the translation for "Cancel" can be too wide for the button. I want the button to be its fixed width of 50 pixels if the string fits, but to expand in width if the string is wider. A fixed amount of side padding would be used to keep the button looking good.</p>
<p>I know I probably can't do this with pure CSS, but what's the simplest HTML I can use that will give me the effect I want? </p>
| [
{
"answer_id": 354820,
"author": "Ned Batchelder",
"author_id": 14343,
"author_profile": "https://Stackoverflow.com/users/14343",
"pm_score": 3,
"selected": true,
"text": "/* Browser hack! This is for everyone: */\nbutton {\n display: inline;\n cursor: pointer;\n padding: 6px 6p... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14343/"
] |
351,602 | <p>Just curious, did I overlook somewhere in the API to display a chat bubble type image as found in the iPhone's SMS application? There's a few applications out there that use bubbles that look verbatim to the iPhone's and I'm wondering if they're using a native widget or their own image.</p>
<p>This is also seen in the Tweetie application where the content of the tweets are.</p>
| [
{
"answer_id": 698871,
"author": "Jab",
"author_id": 29676,
"author_profile": "https://Stackoverflow.com/users/29676",
"pm_score": 5,
"selected": true,
"text": "[UIImage stretchableImageWithLeftCapWidth:15 topCapHeight:13]\n"
}
] | 2008/12/09 | [
"https://Stackoverflow.com/questions/351602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40882/"
] |
351,627 | <p>I'm building an iPhone application that talks to a Ruby on Rails backend. The Ruby on Rails application will also service web users. The restful_authentication plugin is an excellent way to provide quick and customizable user authentication. However, I would like users of the iPhone application to have an account created automatically by the phone's unique identifier ([[UIDevice device] uniqueIdentifier]) stored in a new column. Later, when users are ready to create a username/password, the account will be updated to contain the username and password, leaving the iPhone unique identifier intact. Users should not be able to access the website until they've setup their username/password. They can however, use the iPhone application, since the application can authenticate itself using it's identifier.</p>
<p>What is the best way to modify restful_authentication to do this? Create a plugin? Or modify the generated code?</p>
<p>What about alternative frameworks, such as AuthLogic. What is the best way to allow iPhones to get a generated auth token locked to their UUID's, but then let the user create a username/password later?</p>
| [
{
"answer_id": 2570066,
"author": "Leandro Ardissone",
"author_id": 42565,
"author_profile": "https://Stackoverflow.com/users/42565",
"pm_score": 0,
"selected": false,
"text": "salt = 'afG553Dvbf3'\n\nudid = '1234567890'\npass = Digest::MD5.hexdigest(udid + salt)\n"
}
] | 2008/12/09 | [
"https://Stackoverflow.com/questions/351627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44482/"
] |
351,633 | <p>I currently have issues in Webkit(Safari and Chrome) were I try to load dynamically (innerHTML) some html into a div, the html contains css rules (...), after the html gets rendered the style definitions are not loaded (so visually I can tell the styles are not there and also if I search with javascript for them no styles are found).
I have tried using a jquery plugin tocssRule(), it works but it is just too slow. Is there another way of getting webkit to load the styles dynamically?
Thanks.
Patrick</p>
| [
{
"answer_id": 352060,
"author": "I.devries",
"author_id": 6388,
"author_profile": "https://Stackoverflow.com/users/6388",
"pm_score": 4,
"selected": true,
"text": "var link = document.createElement('link');\n\nlink.setAttribute('rel', 'stylesheet');\n\nlink.type = 'text/css';\n\nlink.hr... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
351,635 | <p>Is there anyone already implement memcached for production use in Windows environment?
Because many blogs that I've read, it's not recommended to run memcached in Windows especially for production use, for example <a href="http://latebound.blogspot.com/2008/10/running-memcached-on-windows.html" rel="noreferrer">running memcached on windows</a>.</p>
<p>And one more thing, which memcached client that is good to use with c# and .net 3.5 ?
I've found many alternate such as <a href="http://www.codeplex.com/memcachedproviders" rel="noreferrer">Memcached Providers @ Codeplex</a>, <a href="http://code.google.com/p/beitmemcached/" rel="noreferrer">Beitmemcached</a>, and <a href="http://sourceforge.net/projects/memcacheddotnet" rel="noreferrer">memcached provider @ Sourceforge</a></p>
| [
{
"answer_id": 1112675,
"author": "Nicholas Piasecki",
"author_id": 32187,
"author_profile": "https://Stackoverflow.com/users/32187",
"pm_score": 4,
"selected": false,
"text": "Cache*"
}
] | 2008/12/09 | [
"https://Stackoverflow.com/questions/351635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37509/"
] |
351,640 | <p>What is the proper way to install Hibernate Tools in Eclipse as a plugin?
The <a href="http://www.hibernate.org/255.html" rel="noreferrer" title="Hibernate site">Hibernate site</a> doesn't really give any instructions.</p>
<p>Looking at the Hibernate Tools binary <code>HibernateTools-3.2.4.Beta1-R200810311334.zip</code>, it appears that I can just unzip this in my eclipse directory. Do I just unzip it in my eclipse directory? This seems like a hacky was to install it.</p>
| [
{
"answer_id": 352429,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 2,
"selected": false,
"text": "[eclipse\\dropins\\HibernateTools-3.2.4.Beta1-R20081031133]"
},
{
"answer_id": 35099192,
"author": "Divyesh Kanzari... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351640",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24396/"
] |
351,644 | <p>I'm using ADO.NET dataservices in a Silverlight application and since the silverlight libraries don't support the ToList() call on the IQueryable I thought it might be possible to create an extension method around this called SilverlightToList(). So in this method I'm calling the BeginExecute method on my context as shown below: </p>
<pre><code> var result = context.BeginExecute<T>(currentRequestUri,null,context);
result.AsyncWaitHandle.WaitOne();
return context.EndExecute<T>(result).ToList();
</code></pre>
<p>The problem is that when I call the WaitOne() method this results in a deadlock. Is this a limitation of ADO.NET dataservices in Silverlight? Is there perhaps a workaround for this?</p>
| [
{
"answer_id": 351817,
"author": "Boyan",
"author_id": 38106,
"author_profile": "https://Stackoverflow.com/users/38106",
"pm_score": 1,
"selected": false,
"text": "context.BeginExecute<T>(currentRequestUri, resultCallback, context);\n\nprivate void resultCallback(IAsyncResult asyncResult... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36086/"
] |
351,656 | <p>I'm curious to know if there is an easy way to mock an IMAP server (a la the <code>imaplib</code> module) in Python, <em>without</em> doing a lot of work.</p>
<p>Is there a pre-existing solution? Ideally I could connect to the existing IMAP server, do a dump, and have the mock server run off the real mailbox/email structure.</p>
<p>Some background into the laziness: I have a nasty feeling that this small script I'm writing will grow over time and would <em>like</em> to create a proper testing environment, but given that it might <em>not</em> grow over time, I don't want to do much work to get the mock server running.</p>
| [
{
"answer_id": 35488764,
"author": "Bruno Thomas",
"author_id": 396155,
"author_profile": "https://Stackoverflow.com/users/396155",
"pm_score": 3,
"selected": false,
"text": "factory = loop.create_server(lambda: ImapProtocol(mailbox_map), 'localhost', 1143)\nserver = loop.run_until_compl... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3594/"
] |
351,657 | <p>By default sqlplus truncates column names to the length of the underlying data type. Many of the column names in our database are prefixed by the table name, and therefore look identical when truncated.</p>
<p>I need to specify select * queries to remote DBAs in a locked down production environment, and drag back spooled results for diagnosis. There are too many columns to specify individual column formatting. Does sqlplus offer any option to uniformly defeat column name truncation?</p>
<p>(I am using SET MARKUP HTML ON, though I could use some other modality, csv, etc. as long as it yields unabbreviated output.)</p>
| [
{
"answer_id": 353335,
"author": "m0j0",
"author_id": 31319,
"author_profile": "https://Stackoverflow.com/users/31319",
"pm_score": 1,
"selected": false,
"text": "ALL_TAB_COLS"
},
{
"answer_id": 354550,
"author": "IK.",
"author_id": 21283,
"author_profile": "https://S... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14749/"
] |
351,661 | <p>Can you store an Array ( that contains another two subarrays one being a string and another another array) into a single MutableArray object?</p>
| [
{
"answer_id": 351673,
"author": "e.James",
"author_id": 33686,
"author_profile": "https://Stackoverflow.com/users/33686",
"pm_score": 0,
"selected": false,
"text": "NSMutableArray * completeArray =\n [NSMutableArray arrayWithArray:\n [[myArray objectAtIndex:0] arrayByAddingObj... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
351,690 | <p>In order to write better code, is it worth to know deeply what the compiler does? </p>
<p>Just how much would be enough? I'm not a bit scrubber, but I was thinking that knowing how the compiler operates would make me a better programmer. Am I wrong? </p>
<p>If so, what resources would you recommend?</p>
| [
{
"answer_id": 352126,
"author": "Norman Ramsey",
"author_id": 41661,
"author_profile": "https://Stackoverflow.com/users/41661",
"pm_score": 2,
"selected": false,
"text": " answer = answer .. strings[i] -- .. is string concatenation\n"
}
] | 2008/12/09 | [
"https://Stackoverflow.com/questions/351690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12423/"
] |
351,720 | <p>Is it a good idea to share views between different controllers (using the <em>Views/Shared</em> folder)?<br><br> I am creating my first MVC application and it requires some pieces of data that are similar to each other. They "explain" different things (and will therefore be stored in different tables) but they each have an <code>Id</code>, <code>Name</code> and <code>Status</code>. I can therefore use different controllers which then use the same View to display the data in a drop down list, allow the user to select one to edit or add a new one via a text box.<br><br> Obviously I lose the ability to have strongly typed ViewPage data but besides that, would this be considered a good way to do this or am I better off creating a View for each controller to use?</p>
| [
{
"answer_id": 351803,
"author": "Todd Smith",
"author_id": 31624,
"author_profile": "https://Stackoverflow.com/users/31624",
"pm_score": 1,
"selected": false,
"text": "public class MyCustomViewData\n{\n public int Id {get; set;}\n public string Name {get; set;}\n public int Sta... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17248/"
] |
351,732 | <p>How do you usually convert line breaks in a form textbox or input=text element to html line breaks?</p>
<p>Thanks</p>
<p>Edit: Is it always \r\n with all browsers?</p>
| [
{
"answer_id": 351735,
"author": "Shawn",
"author_id": 26,
"author_profile": "https://Stackoverflow.com/users/26",
"pm_score": 2,
"selected": false,
"text": "Replace(vbcrlf, \"<br />\")\n"
},
{
"answer_id": 351747,
"author": "ine",
"author_id": 4965,
"author_profile":... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/676066/"
] |
351,733 | <p>What are some ways to write object-oriented code in C? Especially with regard to polymorphism.</p>
<hr/>
<p>See also this Stack Overflow question <em><a href="https://stackoverflow.com/questions/415452/object-orientation-in-c">Object-orientation in C</a></em>.</p>
| [
{
"answer_id": 351745,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 9,
"selected": false,
"text": "struct"
},
{
"answer_id": 351766,
"author": "Alan Storm",
"author_id": 4668,
"author_profile": "http... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/356/"
] |
351,760 | <p>I would like to create a simple file format/DSL which would allow my users to input data. My system is in python and using python's parser is appealing.
Syntax like this for defining a data element seems quite convenient.</p>
<pre><code>Allocation(Param1 = Val1, Param2 = Val2 )
</code></pre>
<p>However, it does not support param names with spaces.</p>
<pre><code>Allocation(Param 1 = Val1, Param 2 = Val2 )
</code></pre>
<p>Python parser friendly versions can look as follows, but not very user friendly.</p>
<pre><code>Allocation(("Param 1",Val1), ("Param 2",Val1) )
Allocation(**{"Param 1":Val1, "Param 2":Val1} )
</code></pre>
<p>Is there a way to make this more readable in python?</p>
| [
{
"answer_id": 351776,
"author": "Harley Holcombe",
"author_id": 1057,
"author_profile": "https://Stackoverflow.com/users/1057",
"pm_score": 1,
"selected": false,
"text": "def Allocation(**kwargs):\n print kwargs\n\nmyargs = {\"Param 1\":Val1, \"Param 2\":Val1}\nAllocation(**myargs)\n... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52490/"
] |
351,784 | <p>My requirement is to replace a set of words in a given text file with a second set of words, which might be given from the command line or another file. Wanting to use Perl to do this, as the rest of my code is also in Perl.</p>
<p>So, if I have the following:</p>
<pre><code>server name="${server1}" host="abc.com"
server name="${server2}" host="webcs.com"
server name="${server5}" host="httpvcs1.com"
server name="${server6}" host="xyz.com"
server name="${server7}" host="msg.com"
</code></pre>
<p>I wish to replace the strings 'server1', 'server2', 'server5', etc, with a different set of words. These might be placed in another file or given from the command line (whichever is more feasible).</p>
<p>Also, if, instead of just 'server1', 'server2', etc, I want to replace the 'server' word with say 'file', how would i go about making a regex for this replacement?</p>
<pre><code>perl -pie 's/server\d{1-3}/myword/g' loginOut.txt > loginOut1.txt
</code></pre>
<p>The above will do a replacement for all words with 'myword'. But I want only the substring to be replaced. </p>
| [
{
"answer_id": 351831,
"author": "George Stocker",
"author_id": 16587,
"author_profile": "https://Stackoverflow.com/users/16587",
"pm_score": 0,
"selected": false,
"text": "perl -pie 's/\\{server/myword/g' loginOut.txt > loginOut1.txt\n"
},
{
"answer_id": 351853,
"author": "u... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35416/"
] |
351,797 | <p>I know this maybe a very basic question but I'm having a bit of a mind blank at the moment. Should I be unit testing this class.</p>
<pre><code>public class MapinfoWindowHandle : IWin32Window
{
IntPtr handle;
public MapinfoWindowHandle(IntPtr mapinfoHandle)
{
this.handle = mapinfoHandle;
}
#region IWin32Window Members
IntPtr IWin32Window.Handle
{
get { return this.handle; }
}
#endregion
}
</code></pre>
<p>If I should be what should I be testing for? <bR> I use it like this:</p>
<pre><code>IntPtr handle = new IntPtr(100);
myform.show(new MapinfoWindowHandle(handle));
</code></pre>
| [
{
"answer_id": 351805,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 3,
"selected": true,
"text": " [TestMethod]\n public void ConstructorTest()\n {\n IntPtr handle = new IntPtr(100);\n MapinfoWindowHandle win... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6335/"
] |
351,800 | <p>Is it possible to create an inline delegate in vb.net like you can in c#?</p>
<p>For example, I would like to be able to do something inline like this:</p>
<pre><code>myObjects.RemoveAll(delegate (MyObject m) { return m.X >= 10; });
</code></pre>
<p>only in VB and without having to do something like this</p>
<pre><code>myObjects.RemoveAll(AddressOf GreaterOrEqaulToTen)
Private Function GreaterOrEqaulToTen(ByVal m as MyObject)
If m.x >= 10 Then
Return true
Else
Return False
End If
End Function
</code></pre>
<p>-- edit --
I should have mentioned that I am still working in .net 2.0 so I won't be able to use lambdas.</p>
| [
{
"answer_id": 351820,
"author": "Shawn",
"author_id": 26,
"author_profile": "https://Stackoverflow.com/users/26",
"pm_score": 3,
"selected": false,
"text": "myObjects.RemoveAll(Function(m) m.X >= 10)\n"
},
{
"answer_id": 351825,
"author": "BlackMael",
"author_id": 19377,... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1632/"
] |
351,801 | <p>I'm trying to get Unicode working properly in rails using MySQL. Now, Rails displays the text correctly, but it shows up as ??? in MySQL. Additionally, I am not able to filter the text.</p>
<p>My MySQL database has been configured with the utf8 character set. My client character is also UTF8. Likewise, rails is set to use UTF8. </p>
<p>If I enter the Unicode string directly from the MySQL client, it is stored properly in the table, but Rails does not correctly display it.</p>
<p>How do I get the data in, properly formatted in the database?</p>
| [
{
"answer_id": 416539,
"author": "sikachu",
"author_id": 52035,
"author_profile": "https://Stackoverflow.com/users/52035",
"pm_score": 2,
"selected": false,
"text": "encoding: utf8"
}
] | 2008/12/09 | [
"https://Stackoverflow.com/questions/351801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
351,806 | <p>I am curious to know where the "Don't Fragment" [DF] Bit of the IP Flags is used. As fragmentation is invisible to higher layers and they don't care too.</p>
<p>I am also looking for an example. </p>
<p>Thanks a lot in advance.</p>
| [
{
"answer_id": 352027,
"author": "unwind",
"author_id": 28169,
"author_profile": "https://Stackoverflow.com/users/28169",
"pm_score": 4,
"selected": false,
"text": "write()"
},
{
"answer_id": 355530,
"author": "bortzmeyer",
"author_id": 15625,
"author_profile": "https... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38038/"
] |
351,823 | <p>The following is a simplified version of what I'm trying to do, because I'm sure you don't want to wade through an entire set of structs and function prototypes for a particle system.</p>
<pre><code>float const materials[24][4][4] = {{{...}}};
typedef struct EmitterStruct { float *material[4][4]; } Emitter;
typedef struct ParticleStruct { float material[4][4]; } Particle;
Emitter *myEmitter;
Emitter * createEmitter(float *material[4][4])
{
Emitter * newEmitter;
newEmitter = (Emitter *)malloc(sizeof(Emitter));
newEmitter->material = materal; /* Returns "incompatable types in assignment" */
return newEmitter; /* I also tried newEmitter->material = &material */
}
int main(char *argv, int argc)
{
myEmitter = createEmitter(materials[0]);
}
</code></pre>
<p>In essence, as the comment shows, I get a compile error. I've tried this several different ways, even using "float material[4][4]" in the Emitter struct and the signature of createEmitter. However, then later on when I try to copy values into a particle for modificaitons using:</p>
<pre><code>for (i=0; i++; i<4)
{
for (j=0; j++; j<4)
{
particle->material[i][j] = emitter->material[i][j];
}
}
</code></pre>
<p>I get another type mismatch when copying, even though <em>everything</em> is declared as type float[4][4]. In essence, I want to get a 4x4 array out of an array of 4x4 arrays, keep note of it in the emitter struct, then copy it into the particle struct. But I only want to actually copy the values one time.</p>
| [
{
"answer_id": 351843,
"author": "AlfaZulu",
"author_id": 44060,
"author_profile": "https://Stackoverflow.com/users/44060",
"pm_score": 1,
"selected": false,
"text": "memcpy"
},
{
"answer_id": 351849,
"author": "Community",
"author_id": -1,
"author_profile": "https://... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
351,840 | <p>I have the following Transact-Sql that I am trying to convert to LINQ ... and struggling. </p>
<pre><code>SELECT * FROM Project
WHERE Project.ProjectId IN (SELECT ProjectId FROM ProjectMember Where MemberId = 'a45bd16d-9be0-421b-b5bf-143d334c8155')
</code></pre>
<p>Any help would be greatly appreciated ... I would like to do it with Lambda expressions, if possible. </p>
<p>Thanks in advance!</p>
| [
{
"answer_id": 351859,
"author": "Dave Markle",
"author_id": 24995,
"author_profile": "https://Stackoverflow.com/users/24995",
"pm_score": 3,
"selected": false,
"text": "var projects = \nfrom p in db.Projects\nwhere db.ProjectMembers.Where(m => m.MemberId == \"a45bd16d-9be0-421b-b5bf-143... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1768/"
] |
351,845 | <p>I have a class A and another class that inherits from it, B. I am overriding a function that accepts an object of type A as a parameter, so I have to accept an A. However, I later call functions that only B has, so I want to return false and not proceed if the object passed is not of type B.</p>
<p>What is the best way to find out which type the object passed to my function is?</p>
| [
{
"answer_id": 351852,
"author": "Joshua",
"author_id": 14768,
"author_profile": "https://Stackoverflow.com/users/14768",
"pm_score": 3,
"selected": false,
"text": "dynamic_cast<B*>(pointer)"
},
{
"answer_id": 351865,
"author": "yesraaj",
"author_id": 22076,
"author_p... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43463/"
] |
351,848 | <p>Ok another WPF question, well I guess this is just general .NET. I have an xml document retreived from a URL.</p>
<p>I want to get multiple values out of the document (weather data, location, some other strings).</p>
<p>When I use the XmlTextReader I can call my method to pull the values out. The first time I pass the method to search for the xml node and get the value (the XMLTextReader object) I get the right data back, but then the XMLTextReader is dead. Not sure why it gets nulled out. So I'm having to do this UGLY code below in the FindTags... method. I want to just keep passing the xtr (XMLTextreader) back to my find method. Is this the nature of the reader? I don't want to have to hit the URL each time either... that seems wrong too.</p>
<p>Help.. this just all feels wrong.</p>
<p>Thanks.</p>
<pre><code> GetWeatherFeed("97229", "//weather//loc//dnam", "//weather//cc//tmp", "/weather/cc/icon");
</code></pre>
<p>Get WeatherFeed method (snipped)</p>
<pre><code> System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(Url that retuns xm);
System.Collections.Hashtable ht = new System.Collections.Hashtable();
ht = FindTagsUsingXPthNaviatorAndXPathDocumentNew(xtr, location, temperature, iconid);
lblLocation.Content = ht["Location"].ToString();
lblWeatherCondition.Content = ht["Weather"].ToString();
public System.Collections.Hashtable FindTagsUsingXPthNaviatorAndXPathDocumentNew(System.Xml.XmlTextReader xtr, string nodeToLocate1, string nodeToLocate2, string nodeToLocate3)
{
System.Xml.XPath.XPathDocument xpDoc = new System.Xml.XPath.XPathDocument(xtr);
System.Xml.XPath.XPathNavigator xpNav = xpDoc.CreateNavigator();
System.Xml.XPath.XPathExpression xpExpression = xpNav.Compile(nodeToLocate1);
System.Xml.XPath.XPathNodeIterator xpIter = xpNav.Select(xpExpression);
System.Collections.Hashtable ht = new System.Collections.Hashtable();
while (xpIter.MoveNext())
{
ht.Add("Location", xpIter.Current.Value);
}
xpExpression = xpNav.Compile(nodeToLocate2);
xpIter = xpNav.Select(xpExpression);
while (xpIter.MoveNext())
{
ht.Add("Weather", xpIter.Current.Value);
}
xpExpression = xpNav.Compile(nodeToLocate3);
xpIter = xpNav.Select(xpExpression);
while (xpIter.MoveNext())
{
ht.Add("Icon", xpIter.Current.Value);
}
return ht;
}
</code></pre>
| [
{
"answer_id": 351949,
"author": "John Batdorf",
"author_id": 22451,
"author_profile": "https://Stackoverflow.com/users/22451",
"pm_score": 1,
"selected": false,
"text": " System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(my xml url);\n System.Xml.XPath.XP... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351848",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22451/"
] |
351,903 | <p>I have a GridView that has columns such as:</p>
<pre><code>| A | B C | D E / F |
</code></pre>
<p>I want these to be wrapped in a particular way - that is, I do not want to leave it up to the browser to work out whether to wrap or not depending on the column width. So in the above example I may want the following:</p>
<pre><code>| A | B | D |
| | C | E / F |
</code></pre>
<p>I have tried using <code>\n</code> and also using <code><br/></code> however both of these did not work.</p>
<p>Any ideas?</p>
| [
{
"answer_id": 352986,
"author": "HectorMac",
"author_id": 1400,
"author_profile": "https://Stackoverflow.com/users/1400",
"pm_score": 3,
"selected": false,
"text": "<asp:templatefield>\n <headertemplate>\n D<br />\n E / F\n </headertemplate>\n <itemtemplate>\n ... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
351,911 | <p>Example:</p>
<pre><code>public class Name {
public string FirstName { get; private set; }
public string LastName { get; private set; }
private Name() { }
public Name(string firstName, string lastName) {
FirstName = firstName;
LastName = lastName;
}
}
</code></pre>
<p>When trying to instantiate this c# class, intellisense shows both the private and the public constructor for new keyword even though one of the constructor is private! </p>
<p>What is even more weird is that when I remove the second argument from the public constructor ( remove lastName as argument to public constructor), intellisense now shows just the public constructor with new keyword, correctly.</p>
<p>Is this a bug or am I missing something here? I am using VS2008 SP1.</p>
<p>edit: code clarity</p>
| [
{
"answer_id": 351924,
"author": "Strelok",
"author_id": 2788,
"author_profile": "https://Stackoverflow.com/users/2788",
"pm_score": 0,
"selected": false,
"text": "public abstract class BaseDomainObject{\n public BaseDomainObject() { }\n\n private int _id;\n\n public virtual int Id { ... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23217/"
] |
351,915 | <p>I have written a function that gets a given number of random records from a list. Currently I can do something like:</p>
<pre><code>IEnumerable<City> cities = db.Cites.GetRandom(5);
</code></pre>
<p>(where db is my DataContext connecting to a SQL Server DB)</p>
<p>Currently, I have a function like this in every entity I need random records from:</p>
<pre><code>public partial class City
{
public static IEnumerable<City> GetRandom(int count)
{
Random random = new Random();
IEnumerable<City> cities = DB.Context.Cities.OrderBy( c => random.Next() ).Take(count);
return cities;
}
}
</code></pre>
<p>It works fine, but I'd like it to be generic, so it can work for any table, or even any list of items. I have tried an extension method like:</p>
<pre><code> public static IEnumerable<T> GetRandom<T>( this Table<T> table, int count)
{
Random random = new Random();
IEnumerable<T> records = table.OrderBy(r => random.Next()).Take(count);
return records;
}
</code></pre>
<p>but I get:</p>
<pre>
Error 1 The type 'T' must be a reference type in order to use it as parameter 'TEntity' in the generic type or method 'System.Data.Linq.Table'
</pre>
<p>which highlights <code>GetRandom<T></code>.</p>
<p>I don't understand what the problem is here. Can someone clear up the proper syntax?</p>
| [
{
"answer_id": 351922,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 0,
"selected": false,
"text": "public static IEnumerable<T> GetRandom<T>( this Table<T> table, int count) where T : class {\n ...\n}\n"
},
{
"a... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30529/"
] |
351,919 | <p>I've had a lot of users complain that the little "i" info button is difficult to touch on the iPhone. Ok, simple enough -- I just stuck a big-fat invisible button behind it that you can't miss even with the sloppiest of finger touches and, when you touch it, it does the infoButtonAction.</p>
<p>Thing is, I'd like to flash the info button, itself, for about .25 sec, just to give a visual "this is what's going on" type of feedback. I mean, I'm already assuming that you meant to hit the "i" button, so I'm just treating it as if you <em>DID</em> hit it.</p>
<p>I tried this, but it doesn't work:</p>
<pre><code> UIImage* normalImage = [_infoButton imageForState:UIControlStateNormal];
UIImage* highlighted = [_infoButton imageForState:UIControlStateHighlighted];
_infoButton.highlighted = YES; // flash the button
[_infoButton setImage:highlighted forState:UIControlStateNormal];
[_infoButton setNeedsDisplay]; //* FIXME: No flash?!
[(AppDelegate*)[[UIApplication sharedApplication] delegate] infoTap]; // do the info action
_infoButton.highlighted = NO;
[_infoButton setImage:normalImage forState:UIControlStateNormal];
[_infoButton setNeedsDisplay];
</code></pre>
<p>Any ideas about how to get the behaviour I want?</p>
<p>(I'm also open to alternate ideas about user feedback, but still curious how I'd do this. Imagine that, instead, I have a "game"/prank where you push the "ok" button and "cancel" flashes, and vice versa, or something equally silly.)</p>
| [
{
"answer_id": 351951,
"author": "Matt Ball",
"author_id": 43120,
"author_profile": "https://Stackoverflow.com/users/43120",
"pm_score": 0,
"selected": false,
"text": "infotap"
},
{
"answer_id": 353245,
"author": "Mike Abdullah",
"author_id": 28768,
"author_profile": ... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34820/"
] |
351,927 | <p>I just ran into an issue with Python's imaplib and Gmail's authentication mechanism:</p>
<pre><code>>>> import imaplib
>>> imap = imaplib.IMAP4_SSL('imap.gmail.com', 993)
>>> imap.authenticate('bobdole@gmail.com', 'Bob Dole likes your style!')
Traceback (most recent call last):
...
imaplib.error: AUTHENTICATE command error: BAD ['TODO (not supported yet) 31if3458825wff.5']
</code></pre>
<p>If authentication is unsupported, how does one log in?</p>
| [
{
"answer_id": 351930,
"author": "cdleary",
"author_id": 3594,
"author_profile": "https://Stackoverflow.com/users/3594",
"pm_score": 0,
"selected": false,
"text": ">>> imap.login('bobdole@gmail.com', 'Bob Dole likes your style!')\n('OK', ['bobdole@gmail.com authenticated (Success)'])\n"
... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3594/"
] |
351,932 | <p>How do you associate a <code>-mouseUp:</code> event with the <code>-add:</code> method of a NSArrayController? The <code>-mouseUp:</code> event lives in a different object but is <code>#import</code>'ed and instantiated in the object that holds the array being controlled.</p>
<p>Usually, with an NSButton you command-drag from the button to the NSArrayController's <code>-add:</code> method but obviously this is not possible with a mouse event.
<br /><br /> -- ADDED CONTENT --<br />
MATT: Thanks for the answer and on first read it made sense. Being a beginner to Obj-C/Cocoa with a procedural and NON-GUI language (PLM51 and C51 for embedded controllers) background, I'm having a hard time to grasp the practical implementation of IBOutlets and connecting. I have no problems with buttons and the like (i.e. visible things in IB) but here is what I understand: I need to declare <code>-IBOutlet NSArrayControler * arryCtrl;</code> in my myDocuments.h file. Now keep in mind, the object where I override the <code>-mouseUp</code> method is called Canvas and in myDocuments.h I have a <code>Canvas * canvas</code> declaration hence, I have a canvas object instantiated by myDocument at runtime. In IB, I drag from File's Owner (myDocument right) to ArrayController and a link is established BUT not to <code>-add:</code> as that option is not available. In the nib (myDocument) there is no object for Canvas
But, in mouseUp (the canvas method), if I send a message to the IBOutput, i.e. <code>[arrayCtrl add:self]</code> arrayCtrl is not known.
<br /><br />
Anyhow, I'm sure you guys are having a giggle as the answer is probably so obvious. However, I'm really trying to understand it all and realize that the problem is my novice coding. Thanks for pointing this newbie in the right direction</p>
| [
{
"answer_id": 351930,
"author": "cdleary",
"author_id": 3594,
"author_profile": "https://Stackoverflow.com/users/3594",
"pm_score": 0,
"selected": false,
"text": ">>> imap.login('bobdole@gmail.com', 'Bob Dole likes your style!')\n('OK', ['bobdole@gmail.com authenticated (Success)'])\n"
... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41880/"
] |
351,937 | <p>I'm trying to write a html helper extension that outputs an image tag.
I need to access (within C# code) something like Razor's @Url.Content() helper to get the proper URL for the current context.
How does one do this?</p>
| [
{
"answer_id": 351955,
"author": "Dave K",
"author_id": 19864,
"author_profile": "https://Stackoverflow.com/users/19864",
"pm_score": -1,
"selected": false,
"text": "string fullUrl = HttpContext.Current.Request.Url.AbsoluteUri;\n"
},
{
"answer_id": 353057,
"author": "Tim Scot... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351937",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4541/"
] |
351,954 | <p>Is there a way using the iPhone SDK to get WiFi information? Things like Signal Strength, WiFi Channel and SSID are the main things I'm looking for.</p>
<p>Only interested in Wifi info, not cellular.</p>
| [
{
"answer_id": 412548,
"author": "Gordon Wilson",
"author_id": 23071,
"author_profile": "https://Stackoverflow.com/users/23071",
"pm_score": 5,
"selected": true,
"text": "Apple80211GetInfoCopy"
}
] | 2008/12/09 | [
"https://Stackoverflow.com/questions/351954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1075/"
] |
351,971 | <p>Hi I'm trying to use mono-service2 to run a stock Windows Service Project from visual studio. I'm running this on debian with mono 2.0 and compiling with.</p>
<pre><code>gmcs *.cs -pkg:dotnet
</code></pre>
<p>I try and start with this (I've tried with -d set to the dir with the app and -n,-m set)</p>
<pre><code>mono-service2 -l:service.lock --debug Program.exe
</code></pre>
<p>The only code change is to add writelines for testing</p>
<p><strong>Service1.cs</strong></p>
<pre><code>using System;
using System.ServiceProcess;
namespace spikes
{
public partial class Service1 : ServiceBase
{
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
Console.WriteLine("starting...");
}
protected override void OnStop()
{
Console.WriteLine("stopping....");
}
}
}
</code></pre>
<p>The resulting is this error</p>
<pre><code>Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for Mono.Unix.Native.Syscall ---> System.DllNotFoundException: libMonoPosixHelper.so
at (wrapper managed-to-native) Mono.Unix.Native.Syscall:_L_ctermid ()
at Mono.Unix.Native.Syscall..cctor () [0x00000]
--- End of inner exception stack trace ---
at MonoServiceRunner.Main (System.String[] args) [0x00000]
</code></pre>
<p>Thanks for your help</p>
<p><strong>Answer</strong></p>
<p>I was missing the LD____LIBRARY____PATH env variable, so I added it in a csh for a test</p>
<pre><code>#!/bin/csh
setenv LD_LIBRARY_PATH .:/usr/local/lib
mono-service2 -l:service.lock --debug Program.exe
</code></pre>
| [
{
"answer_id": 352051,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 4,
"selected": true,
"text": "libMonoPosixHelper.so"
}
] | 2008/12/09 | [
"https://Stackoverflow.com/questions/351971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/253/"
] |
351,987 | <p>I'm trying to grab an image from a web site using simpleXML and am getting a PHP error saying that I'm trying to call to a member function <code>xpath()</code> on a non-object.</p>
<p>Below are the lines I'm trying to use to get the image's source tag: </p>
<pre><code>$xpath = '/html/body/div/div/div[5]/div/div/div[2]/div/div[2]/img';
$html = new DOMDocument();
@$html->loadHTMLFile($target_URL);
$xml = simplexml_import_dom($html);
$source_image = $xml->xpath($xpath);
$source_image = $source_image[0]['src'];
</code></pre>
<p>What am I doing wrong? It's pretty clear the second to last line has a problem, but I'm not sure what it is.</p>
| [
{
"answer_id": 352023,
"author": "dancavallaro",
"author_id": 42891,
"author_profile": "https://Stackoverflow.com/users/42891",
"pm_score": 3,
"selected": false,
"text": "$xpath = '/html/body/div/div/div[5]/div/div/div[2]/div/div[2]/img'; \n$html = new DOMDocument();\n@$html->lo... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
352,010 | <p>I have 3 web projects in a Visual studio solution.I want to create a single web setup project which should install all 3 web projects in their virtual directories.So how to create a single web setup project which supports multiple web application installation?</p>
| [
{
"answer_id": 9357940,
"author": "awe",
"author_id": 109392,
"author_profile": "https://Stackoverflow.com/users/109392",
"pm_score": 0,
"selected": false,
"text": "Property"
}
] | 2008/12/09 | [
"https://Stackoverflow.com/questions/352010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11039/"
] |
352,032 | <p>I'm just trying to do simple scripting with F#, and Math.PI seems to have 'disappeared'. I've referenced FSharp.PowerPack.dll, but still can't find it.</p>
| [
{
"answer_id": 352040,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": -1,
"selected": false,
"text": "let PI = 3.141592653589\n"
},
{
"answer_id": 352041,
"author": "Community",
"author_id": -1,
"author_prof... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410/"
] |
352,039 | <p>Please list <strong>one</strong> site which allows Flash/Silverlight access via crossdomain.xml file. Vote for your favorite sites.</p>
<p>The goal is to build an up to date list of sites which can be directly accessed via Flash/Silverlight without a server-side proxy. </p>
| [
{
"answer_id": 7354974,
"author": "puppybits",
"author_id": 304499,
"author_profile": "https://Stackoverflow.com/users/304499",
"pm_score": 1,
"selected": false,
"text": "JSONP.get(\"http://api.twitter.com/statuses/user_timeline.json\", \n \"{screen_name:'puppybits', count:'1'}\",... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5/"
] |
352,055 | <p>What is the best approach in stripping leading and trailing spaces in C?</p>
| [
{
"answer_id": 352071,
"author": "mcjabberz",
"author_id": 30323,
"author_profile": "https://Stackoverflow.com/users/30323",
"pm_score": 1,
"selected": false,
"text": "int i = strlen(s) - 1;\nwhile (isspace(s[i]))\n s[i--] = '\\0';\nwhile (isspace(*s))\n s++;\n"
},
{
"answe... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16139/"
] |
352,059 | <p>do you know any good algorithms that match two strings and then return a percentage in how many percent those two strings match?</p>
<p>And are there some, that work with databases too?</p>
| [
{
"answer_id": 352881,
"author": "Tom",
"author_id": 40620,
"author_profile": "https://Stackoverflow.com/users/40620",
"pm_score": 2,
"selected": false,
"text": "Levenstein(\"copy\", \"cpoy\") == 2\n"
}
] | 2008/12/09 | [
"https://Stackoverflow.com/questions/352059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9535/"
] |
352,076 | <p>This is something that has bugged me for some time. I learnt Haskell before I learnt Python, so I've always been fond of thinking of many computations as a mapping onto a list. This is beautifully expressed by a list comprehension (I'm giving the pythonic version here):</p>
<pre><code>result = [ f(x) for x in list ]
</code></pre>
<p>In many cases though, we want to execute more than a single statement on x, say:</p>
<pre><code>result = [ f(g(h(x))) for x in list ]
</code></pre>
<p>This very quickly gets clunky, and difficult to read.</p>
<p>My normal solution to this is to expand this back into a for loop:</p>
<pre><code>result = []
for x in list:
x0 = h(x)
x1 = g(x0)
x2 = f(x1)
result.append(x2)
</code></pre>
<p>One thing about this that bothers me no end is having to initialize the empty list 'result'. It's a triviality, but it makes me unhappy. I was wondering if there were any alternative equivalent forms. One way may be to use a local function(is that what they're called in Python?)</p>
<pre><code>def operation(x):
x0 = h(x)
x1 = g(x0)
x2 = f(x1)
return x2
result = [ operation(x) for x in list ]
</code></pre>
<p>Are there any particular advantages/disadvantages to either of the two forms above? Or is there perhaps a more elegant way?</p>
| [
{
"answer_id": 352105,
"author": "Darius Bacon",
"author_id": 27024,
"author_profile": "https://Stackoverflow.com/users/27024",
"pm_score": 0,
"selected": false,
"text": "result = [blah(blah(blah(x)))\n for x in list]\n"
},
{
"answer_id": 352121,
"author": "monkut",
... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37984/"
] |
352,079 | <p>I'm using the appengine webapp framework (<a href="http://code.google.com/appengine/docs/webapp/" rel="nofollow noreferrer">link</a>). Is it possible to add Django middleware? I can't find any examples. I'm currently trying to get the FirePython middleware to work (<a href="http://github.com/woid/firepython/tree/master" rel="nofollow noreferrer">link</a>).</p>
| [
{
"answer_id": 548865,
"author": "zgoda",
"author_id": 12138,
"author_profile": "https://Stackoverflow.com/users/12138",
"pm_score": 0,
"selected": false,
"text": "session"
}
] | 2008/12/09 | [
"https://Stackoverflow.com/questions/352079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37575/"
] |
352,089 | <p>Why isn't there a bit structure in C#?</p>
| [
{
"answer_id": 25684299,
"author": "Konamiman",
"author_id": 4574,
"author_profile": "https://Stackoverflow.com/users/4574",
"pm_score": 5,
"selected": false,
"text": "int"
}
] | 2008/12/09 | [
"https://Stackoverflow.com/questions/352089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44527/"
] |
352,098 | <p>Is there a (Unix) shell script to format JSON in human-readable form?</p>
<p>Basically, I want it to transform the following:</p>
<pre class="lang-json prettyprint-override"><code>{ "foo": "lorem", "bar": "ipsum" }
</code></pre>
<p>... into something like this:</p>
<pre class="lang-json prettyprint-override"><code>{
"foo": "lorem",
"bar": "ipsum"
}
</code></pre>
| [
{
"answer_id": 352160,
"author": "jfs",
"author_id": 4279,
"author_profile": "https://Stackoverflow.com/users/4279",
"pm_score": 6,
"selected": false,
"text": "$ echo '{ \"foo\": \"lorem\", \"bar\": \"ipsum\" }' \\\n> | python -c'import fileinput, json;\n> print(json.dumps(json.loads(\"\... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
352,103 | <p>On this page (<a href="http://www.bonniesphere.com/blog/elsewhere/" rel="nofollow noreferrer">http://www.bonniesphere.com/blog/elsewhere/</a>) the "li" items have an image instead of a bullet. But the image is centered vertically, and in multi-line entries it doesn't look good. Can anyone tell me if there is something in the CSS that should be changed?</p>
<p>Here's the relative code:</p>
<p>.entry ul {list-style-type:none;}
.entry ul li{padding: 0 0 0 15px;background: url(img/ol.gif) no-repeat left center;margin-left:10px;}</p>
<p>Many thanks for your help...</p>
| [
{
"answer_id": 352106,
"author": "Kablam",
"author_id": 42389,
"author_profile": "https://Stackoverflow.com/users/42389",
"pm_score": 0,
"selected": false,
"text": ".entry ul {list-style-type:none;} \n.entry ul li{padding: 0 0 0 15px;\nbackground: url(img/ol.gif) no-repeat left top cente... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
352,117 | <p>I've been lately trying to learn more and generally test Java's serialization for both work and personal projects and I must say that the more I know about it, the less I like it. This may be caused by misinformation though so that's why I'm asking these two things from you all:</p>
<p><strong>1:</strong> On byte level, how does serialization know how to match serialized values with some class?</p>
<p>One of my problems right here is that I made a small test with ArrayList containing values "one", "two", "three". After serialization the byte array took 78 bytes which seems awfully lot for such low amount of information(19+3+3+4 bytes). Granted there's bound to be some overhead but this leads to my second question:</p>
<p><strong>2:</strong> Can serialization be considered a good method for persisting objects at all? Now obviously if I'd use some homemade XML format the persistence data would be something like this</p>
<pre class="lang-xml prettyprint-override"><code><object>
<class="java.util.ArrayList">
<!-- Object array inside Arraylist is called elementData -->
<field name="elementData">
<value>One</value>
<value>Two</value>
<value>Three</value>
</field>
</object>
</code></pre>
<p>which, like XML in general, is a bit bloated and takes 138 bytes(without whitespaces, that is). The same in JSON could be </p>
<pre class="lang-json prettyprint-override"><code>{
"java.util.ArrayList": {
"elementData": [
"one",
"two",
"three"
]
}
}
</code></pre>
<p>which is 75 bytes so already slightly smaller than Java's serialization. With these text-based formats it's of course obvious that there has to be a way to represent your basic data as text, numbers or any combination of both.</p>
<p>So to recap, how does serialization work on byte/bit level, when it should be used and when it shouldn't be used and what are real benefits of serialization besides that it comes standard in Java?</p>
| [
{
"answer_id": 366739,
"author": "Tom Hawtin - tackline",
"author_id": 4725,
"author_profile": "https://Stackoverflow.com/users/4725",
"pm_score": 0,
"selected": false,
"text": "implements Serializable"
},
{
"answer_id": 34623934,
"author": "Premraj",
"author_id": 1697099... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44523/"
] |
352,118 | <p>I place using namespace in a view code behind but i can't call any class of this name space in aspx.</p>
<p>In codebehind:</p>
<pre><code>using MVCTest.Controller;
</code></pre>
| [
{
"answer_id": 352138,
"author": "mookid8000",
"author_id": 6560,
"author_profile": "https://Stackoverflow.com/users/6560",
"pm_score": 2,
"selected": false,
"text": "// system.web / compilation / assemblies\n<add assembly=\"Microsoft.Web.Mvc\"/>\n"
},
{
"answer_id": 352142,
... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44533/"
] |
352,152 | <p>I was wondering if there is an iterator in the STL that dereferences the object pointed before returning it. This could be very useful when manipulating containers aggregating pointers. Here's an example of what I would like to be able to do:</p>
<pre><code>#include <vector>
#include <iterator>
#include <algorithm>
using namespace std;
int main()
{
vector<int*> vec;
int i = 1;
int j = 2;
int k = 3;
vec.push_back(&i);
vec.push_back(&j);
vec.push_back(&k);
copy(deref_iterator(vec.begin()),
deref_iterator(vec.end()),
ostream_iterator<int>(cout, " ")); // prints "1 2 3"
return 0;
}
</code></pre>
| [
{
"answer_id": 352162,
"author": "Luc Touraille",
"author_id": 20984,
"author_profile": "https://Stackoverflow.com/users/20984",
"pm_score": 2,
"selected": false,
"text": "#include <iterator>\n\ntemplate <typename T>\nstruct PointedType;\n\ntemplate <typename T>\nstruct PointedType<T*>\n... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352152",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20984/"
] |
352,174 | <pre><code> [SoapRpcMethod(Action = "http://cyberindigo/TempWebService/InsertXML",
RequestNamespace = "http://cyberindigo/TempWebService/Request",
RequestElementName = "InsertXMLRequest",
ResponseNamespace = "http://cyberindigo/TempWebService/Response",
ResponseElementName = "InsertXMLResponse",
Use = System.Web.Services.Description.SoapBindingUse.Literal)]
[WebMethod]
public string InsertXML(string Jobs)
{
return "Hi";
}
</code></pre>
<p>The Problem when I am accessing it using XMLHttpRequest it gives following error
Server did not recognize the value of HTTP Header SOAPAction: <a href="http://Cyberindigo/TempWebService/InsertXML" rel="noreferrer">http://Cyberindigo/TempWebService/InsertXML</a></p>
| [
{
"answer_id": 2109100,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 6,
"selected": false,
"text": "SOAPAction"
},
{
"answer_id": 5745476,
"author": "Ben",
"author_id": 719114,
"author_profile": "https://S... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42070/"
] |
352,176 | <p>The following SQL separates tables according to their relationship. The problem is with the tables that sort under the 3000 series. Tables that are part of foreign keys and that use foreign keys. Anyone got some clever recursive CTE preferably or a stored procedure to do the necessary sorting?? Programs connectiong to the database are not considered a solution. </p>
<p>Edit: I posted the answer in the "answers" based on the first solution
Free "right answer" to be had for anyone reposting my own "right" answer!</p>
<pre><code>WITH
AllTables(TableName) AS
(
SELECT OBJECT_SCHEMA_NAME(so.id) +'.'+ OBJECT_NAME(so.id)
FROM dbo.sysobjects so
INNER JOIN sys.all_columns ac ON
so.ID = ac.object_id
WHERE
so.type = 'U'
AND
ac.is_rowguidcol = 1
),
Relationships(ReferenceTableName, ReferenceColumnName, TableName, ColumnName) AS
(
SELECT
OBJECT_SCHEMA_NAME (fkey.referenced_object_id) + '.' +
OBJECT_NAME (fkey.referenced_object_id) AS ReferenceTableName
,COL_NAME(fcol.referenced_object_id,
fcol.referenced_column_id) AS ReferenceColumnName
,OBJECT_SCHEMA_NAME (fkey.parent_object_id) + '.' +
OBJECT_NAME(fkey.parent_object_id) AS TableName
,COL_NAME(fcol.parent_object_id, fcol.parent_column_id) AS ColumnName
FROM sys.foreign_keys AS fkey
INNER JOIN sys.foreign_key_columns AS fcol ON
fkey.OBJECT_ID = fcol.constraint_object_id
),
NotReferencedOrReferencing(TableName) AS
(
SELECT TableName FROM AllTables
EXCEPT
SELECT TableName FROM Relationships
EXCEPT
SELECT ReferenceTableName FROM Relationships
),
OnlyReferenced(Tablename) AS
(
SELECT ReferenceTableName FROM Relationships
EXCEPT
SELECT TableName FROM Relationships
),
-- These need to be sorted based on theire internal relationships
ReferencedAndReferencing(TableName, ReferenceTableName) AS
(
SELECT r1.Tablename, r2.ReferenceTableName FROM Relationships r1
INNER JOIN Relationships r2
ON r1.TableName = r2.ReferenceTableName
),
OnlyReferencing(TableName) AS
(
SELECT Tablename FROM Relationships
EXCEPT
SELECT ReferenceTablename FROM Relationships
)
SELECT TableName, 1000 AS Sorting FROM NotReferencedOrReferencing
UNION
SELECT TableName, 2000 AS Sorting FROM OnlyReferenced
UNION
SELECT TableName, 3000 AS Sorting FROM ReferencedAndReferencing
UNION
SELECT TableName, 4000 AS Sorting FROM OnlyReferencing
ORDER BY Sorting
</code></pre>
| [
{
"answer_id": 352294,
"author": "ConcernedOfTunbridgeWells",
"author_id": 15401,
"author_profile": "https://Stackoverflow.com/users/15401",
"pm_score": 2,
"selected": false,
"text": "declare @level int -- Current depth\n ,@count int \n\n-- Step 1: Start with tables that ... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13219/"
] |
352,177 | <p>Fun with enums in C#. Take one generic list that is created to store some Enum that you had defined previously and add few items in it. Iterate with foreach or <code>GetEnumerator<T>()</code> but specify some other enum then the original and see what happens. I was expecting InvalidCastException or something like that but it perfectly works :). </p>
<p>
For the illustration let's take a simple console application and create two enums there: Cars and Animals:
</p>
<pre><code> public enum Cars
{
Honda = 0,
Toyota = 1,
Chevrolet = 2
}
public enum Animals
{
Dog = 0,
Cat = 1,
Tiger = 2
}
</code></pre>
<p>And do this in main method:</p>
<pre><code> public static void Main()
{
List<Cars> cars = new List<Cars>();
List<Animals> animals = new List<Animals>();
cars.Add(Cars.Chevrolet);
cars.Add(Cars.Honda);
cars.Add(Cars.Toyota);
foreach (Animals isItACar in cars)
{
Console.WriteLine(isItACar.ToString());
}
Console.ReadLine();
}
</code></pre>
<p>It will print this in console:</p>
<blockquote>
<pre><code>Tiger
Dog
Cat
</code></pre>
</blockquote>
<p>Why is this happening? My first guess was that enum is not actually a Type by himself it's just and int but that's not true: If we write:</p>
<p><code>Console.WriteLine(Animals.Tiger.GetType().FullName);</code>
We will get his fully qualified name printed! So why this?</p>
| [
{
"answer_id": 352196,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 2,
"selected": false,
"text": "ToString()"
},
{
"answer_id": 352210,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352177",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29511/"
] |
352,178 | <p>I have a <code>MultipleChoiceField</code> on a form holding car makes. I want to filter my database of cars to the makes that were checked but this causes a problem. How do I get all the <code>Q(make=...)</code> statements in dynamically?</p>
<p>How I start: <code>['value1', 'value2', ...]</code></p>
<p>How I want to end: <code>Q(col='value1') | Q(col='value2') | ...</code></p>
<p>I've couple of other methods. I've tried appending querysets for each make and doing it the other way around (doing multiple excludes) but they were both really slow.</p>
| [
{
"answer_id": 352208,
"author": "Ber",
"author_id": 11527,
"author_profile": "https://Stackoverflow.com/users/11527",
"pm_score": 4,
"selected": true,
"text": "Model.objects.filter(make__in=list_of_makes)"
},
{
"answer_id": 352262,
"author": "Oli",
"author_id": 12870,
... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12870/"
] |
352,203 | <p>I'm looking for an algorithm to generate permutations of a set in such a way that I could make a lazy list of them in Clojure. i.e. I'd like to iterate over a list of permutations where each permutation is not calculated until I request it, and all of the permutations don't have to be stored in memory at once.</p>
<p>Alternatively I'm looking for an algorithm where given a certain set, it will return the "next" permutation of that set, in such a way that repeatedly calling the function on its own output will cycle through all permutations of the original set, in some order (what the order is doesn't matter).</p>
<p>Is there such an algorithm? Most of the permutation-generating algorithms I've seen tend to generate them all at once (usually recursively), which doesn't scale to very large sets. An implementation in Clojure (or another functional language) would be helpful but I can figure it out from pseudocode.</p>
| [
{
"answer_id": 352226,
"author": "Bogdan Maxim",
"author_id": 23795,
"author_profile": "https://Stackoverflow.com/users/23795",
"pm_score": 2,
"selected": false,
"text": "C#"
},
{
"answer_id": 353248,
"author": "ShreevatsaR",
"author_id": 4958,
"author_profile": "http... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23070/"
] |
352,236 | <p>Is there a way for a Windows application to access another applications data, more specifically a text input field in the GUI, and grab the text there for processing in our own application?</p>
<p>If it is possible, is there a way to "shield" your application to prevent it?</p>
<hr />
<p><strong>EDIT:</strong> The three first answers seem to be about getting the another applications window title, not a specific text input field in that window.</p>
<p>I'm no Windows API expert, so could you be more exact how do I find a certain text field in that window, what are the prerequisites for it (seems like knowing a window handle something is required, does it require knowing the text field handle as well? How do I get that? etc...)</p>
<p>Code snippets in C++ really would be really appreciated. MSDN help is hard to browse since Win32-API has such horrible naming conventions.</p>
<hr />
<p><strong>Completed!</strong> See my answer below for a how-to in C++.</p>
| [
{
"answer_id": 352246,
"author": "Stefan",
"author_id": 19307,
"author_profile": "https://Stackoverflow.com/users/19307",
"pm_score": 0,
"selected": false,
"text": "Private Declare Function GetWindowText Lib \"user32\" Alias \"GetWindowTextA\" (ByVal hwnd As Long, ByVal lpString As Strin... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40657/"
] |
352,259 | <p>I want to use the standard ADO connection string dialog box in MS Access.
How can I do that?</p>
| [
{
"answer_id": 352751,
"author": "John Mo",
"author_id": 38988,
"author_profile": "https://Stackoverflow.com/users/38988",
"pm_score": 1,
"selected": false,
"text": "Dim dl As MSDASC.DataLinks\nDim cn As ADODB.Connection\n\nSet dl = New MSDASC.DataLinks\nSet cn = New ADODB.Connection\n\n... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
352,311 | <p>I'm using this database where the date colomn is a numeric value instead of a Date value. </p>
<p>Yes, I know I can change that with a mouseclick, but all the applications using that database were made by one of my predecessors (and everyone after him just ignored it and built on). So if I'd change it to Date a lot af applications would fail. :(</p>
<p>Well, I am making an overview of that database, ranging from one specfic date to another. I tried using a dropdown list but as you can tell, a thousand options in one list is terribly inconvenient, even ugly. </p>
<p>I rather have small inputfields for day - month - year, but there comes waltzing in the numeric date in the database. I would have to calculate the date back to the numeric value somehow... </p>
<p>There must be an easy solution to this. Right?<br /><br /><br /><br />
I'm using ASP(vbscript) for the application, it's for an intraweb, and I have an Access Database.</p>
| [
{
"answer_id": 352436,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 2,
"selected": true,
"text": "Dim rs As DAO.Recordset\n\nSet rs = CurrentDb.OpenRecordset(\"TestTable\")\nrs.AddNew\nrs!NumberDate = Now() 'Value stored... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42389/"
] |
352,321 | <p>I am testing the application in the debug mode under several conditions. Now I'm doing it by writing some of the states and executed functions on the piece of paper and then comparing the scenarios.</p>
<p>Does anyone know if there is any built-in functionality in VS2008 or any additional tool that could record the selected states and executed functions?</p>
<p>Thanks!</p>
| [
{
"answer_id": 352436,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 2,
"selected": true,
"text": "Dim rs As DAO.Recordset\n\nSet rs = CurrentDb.OpenRecordset(\"TestTable\")\nrs.AddNew\nrs!NumberDate = Now() 'Value stored... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22996/"
] |
352,334 | <p>I'm using GDOME.pm and in my script I have this line:</p>
<pre><code>my $doc = XML::GDOME->createDocument("","","");
</code></pre>
<p>I can't for the life of me figure out why it's coming out with this error:</p>
<pre><code>NAMESPACE_ERR at /usr/lib/perl5/site_perl/5.6.1/i586-linux/XML/GDOME.pm line 103.
</code></pre>
<p>which basically points to:</p>
<pre><code>sub createDocument {
my $class = shift;
return $di->createDocument(@_); ## it points to this LINE!!
}
</code></pre>
<p>Is there a tool or something that would provide me more look into which namespaces is actually causing this error?</p>
<p>In the meantime, my solution goes along the lines of my forehead meeting the keyboard,
but that doesn't seem to be working except for causing some headache, and random shapes appearing on my forehead.</p>
<p>thanks
~steve</p>
| [
{
"answer_id": 352567,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 2,
"selected": true,
"text": "$doc = XML::GDOME->createDocument( $nsURI, $name, $dtd );\n"
},
{
"answer_id": 352571,
"author": "ysth",
... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352334",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38124/"
] |
352,335 | <p>I am using an open source client to programmatically process incoming emails (on Windows 2003). The only way to prevent receiving previously read emails is to delete them from the server. This is less than ideal. As far as I know, there is no command in Pop3 to set emails as being read. So how do you go about this? </p>
| [
{
"answer_id": 352347,
"author": "xahtep",
"author_id": 42184,
"author_profile": "https://Stackoverflow.com/users/42184",
"pm_score": 5,
"selected": true,
"text": "UIDL"
}
] | 2008/12/09 | [
"https://Stackoverflow.com/questions/352335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27805/"
] |
352,340 | <p>Edit: How to return/serve a file from a python controller (back end) over a web server, with the file_name? as suggested by @JV</p>
| [
{
"answer_id": 352497,
"author": "gimel",
"author_id": 6491,
"author_profile": "https://Stackoverflow.com/users/6491",
"pm_score": 2,
"selected": true,
"text": "from cherrypy.lib.static import serve_file\n"
}
] | 2008/12/09 | [
"https://Stackoverflow.com/questions/352340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2220518/"
] |
352,341 | <p>I often find myself using Integers to represent values in different "spaces". For example...</p>
<pre><code>int arrayIndex;
int usersAge;
int daysToChristmas;
</code></pre>
<p>Ideally, I'd like to have separate classes for each of these types "Index","Years" and "Days", which should prevent me accidentally mixing them up. Typedefs are a help from a documnentation perspective, but aren't type-safe enough.</p>
<p>I've tried wrapper classes, but end up with too much boilerplate for my liking. Is there a straightforward template-based solution, or maybe something ready-to-go in Boost?</p>
<p>EDIT: Several people have talked about bounds-checking in their answers. That maybe a handy side-effect, but is NOT a key requirement. In particular, I don't just want to prevent out-of-bound assignments, but assignments between "inappropriate" types.</p>
| [
{
"answer_id": 352363,
"author": "Joris Timmermans",
"author_id": 33987,
"author_profile": "https://Stackoverflow.com/users/33987",
"pm_score": 3,
"selected": false,
"text": "template<unsigned i>\nclass t_integer_wrapper\n {\n private:\n int m_value;\n public:\n // Constructors... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1737/"
] |
352,343 | <p>I'm developing a web app. In it I have a section called categories that every time a user clicks one of the categories an update panel loads the appropriate content. </p>
<p>After the user clicked the category I want to change the browser's address bar url from</p>
<pre><code>www.mysite.com/products
</code></pre>
<p>to something like </p>
<pre><code>www.mysite.com/products/{selectedCat}
</code></pre>
<p>without refreshing the page.<br>
Is there some kind of JavaScript API I can use to achieve this?</p>
| [
{
"answer_id": 352387,
"author": "roborourke",
"author_id": 42147,
"author_profile": "https://Stackoverflow.com/users/42147",
"pm_score": 5,
"selected": false,
"text": "window.location.hash = 'category-name'; // address bar would become http://example.com/#category-name\n"
},
{
"... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
352,348 | <p>In answering this question (<a href="https://stackoverflow.com/questions/352317/c-coding-question#352327">https://stackoverflow.com/questions/352317/c-coding-question#352327</a>), it got me wondering...</p>
<p>Is there any danger in regarding a static class as being equivalent to a non-static class instatiation that implements the singleton pattern?</p>
| [
{
"answer_id": 352391,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "Comparer<T>.Default"
}
] | 2008/12/09 | [
"https://Stackoverflow.com/questions/352348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14357/"
] |
352,350 | <p>This is a question for a WSS/SharePoint guru. </p>
<p>Consider this scenario: I have an ASP.Net web service which links our corporate CRM system and WSS-based intranet together. What I am trying to do is provision a new WSS site collection whenever a new client is added to the CRM system. In order to make this work, I need to programmatically add the managed path to the new site collection. I know that this is possible via the Object Model, but when I try it in my own web service, it fails. Sample code extract below:</p>
<pre><code>
Dim _ClientSiteUrl As String = "http://myintranet/clients/sampleclient"
Using _RootWeb As SPSite = New SPSite("http://myintranet")
Dim _ManagedPaths As SPPrefixCollection = _RootWeb.WebApplication.Prefixes
If Not (_ManagedPaths.Contains(_ClientSiteUrl)) Then
_ManagedPaths.Add(_ClientSiteUrl, SPPrefixType.ExplicitInclusion)
End If
End Using
</code>
</pre>
<p>This code fails with a NullReferenceException on SPUtility.ValidateFormDigest(). Research suggested that this may be due to insufficient privileges, I tried running the code within an elevated privileges block using SPSecurity.RunWithElevatedPrivileges(AddressOf AddManagedPath), where AddManagedPath is a Sub procedure containing the above code sample.</p>
<p>This then fails with an InvalidOperationException, "Operation is not valid due to the current state of the object."</p>
<p>Where am I going wrong?</p>
<p>One workaround I have managed to do is to call out to STSADM.EXE via Process.Start(), supplying the requisite parameters, and this works.</p>
<p><strong>Update:</strong> whilst developing the web service, I am running it using the built-in Visual Studio 2005 web server - what security context will this be running under? Can I change the security context by putting entries in web.config?</p>
<p><strong>Update:</strong> I think the problem is definitely to do with not running the web service within the correct SharePoint security context. I decided to go with the workaround I suggested and shell out to STSADM, although to do this, the application pool identity that the web service runs under must be a member of the SharePoint administrators.</p>
| [
{
"answer_id": 354261,
"author": "Nat",
"author_id": 13813,
"author_profile": "https://Stackoverflow.com/users/13813",
"pm_score": 2,
"selected": true,
"text": "Dim clientSiteUrl As String = \"http://myintranet/clients/sampleclient\"\nUsing SPSite = new SPSite(clientSiteUrl) \n webApp... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352350",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1052/"
] |
352,354 | <p>I need to match a string holiding html using a regex to pull out all the nested spans, I assume I assume there is a way to do this using a regex but have had no success all morning. </p>
<p>So for a sample input string of </p>
<pre><code><DIV id=c445c9c2-a02e-4cec-b254-c134adfa4192 style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid; BACKGROUND-COLOR: #eeeeee">
<SPAN id=b8db8cd1-f600-448f-be26-2aa56ea09a9c>
<SPAN id=304ccd38-8161-4def-a557-1a048c963df4>
<IMG src="http://avis.co.uk/Assets/build/menu.gif">
</SPAN>
</SPAN>
<SPAN id=bc88c866-5370-4c72-990b-06fbe22038d5>
<SPAN id=55b88bbe-15ca-49c9-ad96-cecc6ca7004e>UK<BR></SPAN>
</SPAN>
<SPAN id=52bb62ca-8f0a-42f1-a13b-9b263225ff1d>
<SPAN id=0e1c3eb6-046d-4f07-96c1-d1ac099d5f1c>
<IMG src="http://avis.co.uk/Assets/build/menu.gif">
</SPAN>
</SPAN>
<SPAN id=4c29eef2-cd77-4d33-9828-e442685a25cb>
<SPAN id=0d5a266a-14ae-4a89-9263-9e0ab57f7ad2>Italy</SPAN>
</SPAN>
<SPAN id=f0a72eea-fddd-471e-89e6-56e9b9efbece>
<SPAN id=b7d9ada7-ade0-49fe-aa5f-270237e87c2b>
<IMG src="http://avis.co.uk/Assets/build/menu.gif">
</SPAN>
</SPAN>
<SPAN id=7604df94-34ba-4c89-bf11-125df01731ff>
<SPAN id=330d6429-4f1b-46a2-a485-9001e2c6b8c1>Netherlands</SPAN>
</SPAN>
<SPAN id=a18fb516-451e-4c32-ab31-3e3be29235f6>
<SPAN id=6c70238d-78f9-468f-bb8d-370fff13c909>
<IMG src="http://avis.co.uk/Assets/build/menu.gif">
</SPAN>
</SPAN>
<SPAN id=5a2465eb-b337-4f94-a4f8-6f5001dfbd75>
<SPAN id=47877a9e-a7d5-4f13-a41e-6948f899e385>Malta &amp; Gozo
</code></pre>
<p>i would want to get each outer span and its containing span so in the above text there should be Eight results</p>
<p>Any help gladly accepted</p>
| [
{
"answer_id": 352907,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": 0,
"selected": false,
"text": "Pattern p = Pattern.compile(\"(<SPAN id.*?<SPAN id.*?</SPAN></SPAN>)\");\nMatcher m = p.matcher(html);\nwhile (m.find())\n{... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/87783/"
] |
352,365 | <p>What is the difference between the concepts of <strong>"Code Re-entrancy"</strong> and <strong>"Thread Safety"</strong>? As per the link mentioned below, a piece of code can be either of them, both of them or neither of them. </p>
<p><a href="http://encyclopedia.thefreedictionary.com/reentrant+code" rel="noreferrer">Reentrant and Thread safe code</a></p>
<p>I was not able to understand the explaination clearly. Help would be appreciated. </p>
| [
{
"answer_id": 352645,
"author": "Steve Jessop",
"author_id": 13005,
"author_profile": "https://Stackoverflow.com/users/13005",
"pm_score": 3,
"selected": false,
"text": "take_global_lock();\nint i = get_global_counter();\ndo_callback(i);\nset_global_counter(i+1);\nrelease_global_lock();... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40981/"
] |
352,389 | <p>We have this set of data that we need to get the average of a column. a <code>select avg(x) from y</code> does the trick. However we need a more accurate figure.</p>
<p>I figured that there must be a way of filtering records that has either too high or too low values(spikes) so that we can exclude them in calculating the average.</p>
| [
{
"answer_id": 352530,
"author": "Jonathan",
"author_id": 6910,
"author_profile": "https://Stackoverflow.com/users/6910",
"pm_score": 3,
"selected": true,
"text": "select name, \n (select top 1 h.run_duration\n from sysjobhistory h\n where h.step_id = 0\n an... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20300/"
] |
352,408 | <p>A colleague of mine and I have been discussing how to declare variables in a function.</p>
<p>Let's say you have a class called TStrings (using Delphi for the sake of explanation) that has at least one abstract method and a descendant class called TStringList which obviously implements the abstract method, but it introduces nothing else you need that is not already implemented in the ancestor, how would you declare a function variable of type TStringList?</p>
<p>Here are two examples. Which is considered better practice and why?</p>
<pre><code>procedure AddElements;
var
aList: TStringList;
begin
aList := TStringList.Create;
try
aList.Add('Apple');
aList.Add('Pear');
finally
aList.free;
end;
end;
procedure AddElementsII;
var
aList: TStrings;
begin
aList := TStringList.Create;
try
aList.Add('Apple');
aList.Add('Pear');
finally
aList.free;
end;
end;
</code></pre>
| [
{
"answer_id": 352454,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 0,
"selected": false,
"text": "procedure TMyClass.MyMethod(const AList: TStrings);\nbegin\nend;\n"
},
{
"answer_id": 352823,
"author": "... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1264322/"
] |
352,415 | <p>I am reorganizing my source files into a single solution with a single project, due to various reasons:</p>
<ul>
<li>a paranoic configured antivirus software;</li>
<li><a href="http://codebetter.com/blogs/patricksmacchia/archive/2008/12/08/advices-on-partitioning-code-through-net-assemblies.aspx" rel="nofollow noreferrer">Advices on partitioning code through .NET assemblies</a></li>
<li><a href="http://www.theserverside.net/tt/articles/showarticle.tss?id=ControllingDependencies" rel="nofollow noreferrer">Control component dependencies to gain clean architecture</a></li>
<li><a href="http://codebetter.com/blogs/patricksmacchia/archive/2007/06/20/benefit-from-the-c-and-vb-net-compilers-perf.aspx" rel="nofollow noreferrer">Benefit from the C# and VB.NET compilers perf</a></li>
</ul>
<p>This leaves me with many namespaces, which are splitted across multiple files. So far, I am using this convention: given the namespace <code>Company.Project.A</code>, the files are named <code>A.f1.cs</code>, <code>A.f2.cs</code> and so on, and the <code>Company.Project.B</code> namespace is splitted across <code>B.f1.cs</code>, <code>B.f2.cs</code>, etc.</p>
<p>Given the single project restriction, are there any better ways to organize multiple files in multiple namespaces?</p>
| [
{
"answer_id": 352421,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": true,
"text": "using System; // Etc\n\nnamespace Company.Project.Foo\n{\n class Bar\n {\n }\n}\n"
}
] | 2008/12/09 | [
"https://Stackoverflow.com/questions/352415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19756/"
] |
352,420 | <p>I just wanted to know what's the difference between clear() and str("");</p>
<p>For example:</p>
<pre><code>stringstream ss("Stack Overflow");
ss.clear();
ss.str("");
</code></pre>
<p>I wanted to know the underlying technical difference.</p>
| [
{
"answer_id": 352426,
"author": "AlfaZulu",
"author_id": 44060,
"author_profile": "https://Stackoverflow.com/users/44060",
"pm_score": 5,
"selected": true,
"text": "clear()"
},
{
"answer_id": 352443,
"author": "yesraaj",
"author_id": 22076,
"author_profile": "https:/... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352420",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38038/"
] |
352,434 | <p>I have a long "binary string" like the output of PHPs pack function.</p>
<p>How can I convert this value to base62 (0-9a-zA-Z)?
The built in maths functions overflow with such long inputs, and BCmath doesn't have a base_convert function, or anything that specific. I would also need a matching "pack base62" function.</p>
| [
{
"answer_id": 364626,
"author": "david",
"author_id": 27600,
"author_profile": "https://Stackoverflow.com/users/27600",
"pm_score": 1,
"selected": false,
"text": "base64_encode()\nbase64_decode()\n"
},
{
"answer_id": 1743486,
"author": "Jay Dansand",
"author_id": 198299,... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352434",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
352,452 | <p>I have this code </p>
<p><a href="http://www.nomorepasting.com/getpaste.php?pasteid=22580" rel="nofollow noreferrer">http://www.nomorepasting.com/getpaste.php?pasteid=22580</a> </p>
<p>which is part of a small ajax application. I would like to know a better, more efficient way to assign $query, instead of copying the sql each time with a different query or a bunch of if clauses. Basically the query will be dependant on the link clicked, but I am not sure how to show that in the logic. I am also unsure why my SQL query in $result fails.</p>
| [
{
"answer_id": 352483,
"author": "markus",
"author_id": 11995,
"author_profile": "https://Stackoverflow.com/users/11995",
"pm_score": 3,
"selected": true,
"text": "<?php\nsession_start(); //ommit, no session var used\n\n//use braces, always!\n//you may write such statements with the shor... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] |
352,463 | <p>I have a JSON as follows</p>
<pre><code>{
columns : [RULE_ID,COUNTRY_CODE],
RULE_ID : [1,2,3,7,9,101,102,103,104,105,106,4,5,100,30],
COUNTRY_CODE : [US,US,CA,US,FR,GB,GB,UM,AF,AF,AL,CA,US,US,US]
}
</code></pre>
<p>I need to retrive the column names from the columns entry and then use it to search the rest of the entries using jquery.
For example I get each column using </p>
<pre><code>jQuery.each(data.columns, function(i,column))
</code></pre>
<p>I need to loop throgh the rest of the entries using the values I get from the previous loop. ie <strong>without hardcoding COUNTRY_CODE or RULE_ID</strong>.
What is the best way to do that using Jquery?</p>
| [
{
"answer_id": 352533,
"author": "Paolo Bergantino",
"author_id": 16417,
"author_profile": "https://Stackoverflow.com/users/16417",
"pm_score": 4,
"selected": true,
"text": "jQuery.each(data.columns, function(i,column) {\n jQuery.each(data[column], function(i, row) {\n ....\n })... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16488/"
] |
352,467 | <p>I am currently doing the front end for a site with looooads of forms, all styled up and looking pretty in IE, but I've just noticed that in Firefox the file input fields aren't responding to any of my styles, all the other types of input fields are fine. I've checked it in Firebug and its associating the correct styles to it, but not changing how it looks.</p>
<p>If this isn't a complete brain fart on my behalf, then is this a known issue in Firefox? And if so, how have I never noticed it before?</p>
<p>Here is a sample of the code.</p>
<p>CSS:</p>
<pre><code>form.CollateralForm input,
form.CollateralForm textarea
{
width:300px;
font-size:1em;
border: solid 1px #979797;
font-family: Verdana, Helvetica, Sans-Serif;
}
</code></pre>
<p>HTML:</p>
<pre><code><form method="bla" action="blah" class="CollateralForm">
<input type="file" name="descriptionFileUpload" id="descriptionFileUpload" />
</form>
</code></pre>
<p>I've also tried applying a class to it but that doesn't work either.</p>
| [
{
"answer_id": 352512,
"author": "Samiksha",
"author_id": 29515,
"author_profile": "https://Stackoverflow.com/users/29515",
"pm_score": -1,
"selected": false,
"text": "form.CollateralForm input,\nform.CollateralForm textarea\n{\n width:300px; //for firefox\n #width:200px; //for IE... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31109/"
] |
352,471 | <p>I am working on creating an immutable class.<br>
I have marked all the properties as read-only. </p>
<p>I have a list of items in the class.<br>
Although if the property is read-only the list can be modified. </p>
<p>Exposing the IEnumerable of the list makes it immutable.<br>
I wanted to know what is the basic rules one has to follow to make a class immutable ? </p>
| [
{
"answer_id": 352490,
"author": "Joe",
"author_id": 13087,
"author_profile": "https://Stackoverflow.com/users/13087",
"pm_score": 4,
"selected": false,
"text": "public class MyClass\n{\n public MyClass(..., IList<MyType> items)\n {\n ...\n _myReadOnlyList = new List<... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41968/"
] |
352,472 | <p>I was curiious to know what type of structures you use for your project references?</p>
<p>Where I work the developers have a shared folder called AssemblyCache (\\MACHINENAME\AssemblyCache) which is mapped to an R:\ via GPO in Windows 2008 AD (tied to the Developers AD group).</p>
<p>Our shared components have post-build events that copy them to something like this:</p>
<p>R:\.Net %VERSION%\Project\%SOMETHING%</p>
<p>Sometimes it's followed by either 'Common' if it's common to the project or something specific.
There's also a common directory for shared stuff under the .Net version folder.</p>
<p>This is so large projects over multiple solutions can reference the assemblies from a common place.</p>
<p>The build machine also has a shared drive of the same share name which the developers have mapped to S:. This allows them to get the latest working build should they need it.</p>
<p>All this is so someone can get on a new PC, and open a project without having to copy references to varying locations, and ensuring that dev a is referencing the assembly from the same place as dev b etc...</p>
<p>This solution works well for us, so I was wondering what, if any, solutions you have in-place for ensuring all developers reference assemblies from the same path?</p>
| [
{
"answer_id": 352524,
"author": "Sandeep Datta",
"author_id": 39648,
"author_profile": "https://Stackoverflow.com/users/39648",
"pm_score": 2,
"selected": true,
"text": "subst R: \"C:\\.Net %VERSION%\\Project\\%SOMETHING%\"\n"
}
] | 2008/12/09 | [
"https://Stackoverflow.com/questions/352472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5791/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.