qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
370,878 | <p>Does anyone know how to get a service ticket from the Key Distribution Center (KDC) using the Java GSS-API?</p>
<p>I have a thick-client-application that first authenticates via JAAS using the Krb5LoginModule to fetch the TGT from the ticket cache (background: Windows e.g. uses a kerberos implementation and stores the ticket granting ticket in a secure memory area). From the LoginManager I get the Subject object which contains the TGT. Now I hoped when I create a specific GSSCredential object for my service, the service ticket will be put into the Subject's private credentials as well (I've read so somewhere in the web). So I have tried the following:</p>
<pre><code>// Exception handling ommitted
LoginContext lc = new LoginContext("HelloEjbClient", new DialogCallbackHandler());
lc.login()
Subject.doAs(lc.getSubject(), new PrivilegedAction() {
public Object run() {
GSSManager manager = GSSManager.getInstance();
GSSName clientName = manager.createName("clientUser", GSSName.NT_USER_NAME);
GSSCredential clientCreds = manager.createCredential(clientName, 8 * 3600, createKerberosOid(), GSSCredential.INITIATE_ONLY);
GSSName serverName = manager.createName("myService@localhost", GSSName.NT_HOSTBASED_SERVICE);
manager.createCredential(serverName, GSSCredential.INDEFINITE_LIFETIME, createKerberosOid(), GSSCredential.INITIATE_ONLY);
return null;
}
private Oid createKerberosOid() {
return new Oid("1.2.840.113554.1.2.2");
}
});
</code></pre>
<p>Unfortunately I get a GSSException: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt).</p>
| [
{
"answer_id": 377108,
"author": "Roland Schneider",
"author_id": 16515,
"author_profile": "https://Stackoverflow.com/users/16515",
"pm_score": 5,
"selected": true,
"text": " GSSManager manager = GSSManager.getInstance();\n GSSName clientName = manager.createName(\"clientUser\", GS... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16515/"
] |
370,884 | <p>I understand that you can use forms authentication to grant/deny access to certain pages based on the criteria of your choosing.</p>
<p>However I wish to go in a little more specific than that and say, have different buttons appear for users based on thier permissions.</p>
<p>I know I could do something like</p>
<pre><code>if(((User)ViewData["CurrentUser"]).IsEmployee).....
</code></pre>
<p>But that doesn't seem very elegant and could get messy very quickly.</p>
<p>Are there any guidelines/tools/framework features that could help me out here?</p>
| [
{
"answer_id": 371376,
"author": "Craig Stuntz",
"author_id": 7714,
"author_profile": "https://Stackoverflow.com/users/7714",
"pm_score": 3,
"selected": false,
"text": "if (ViewContext.HttpContext.User.IsInRole(\"vEmployee\") {\n"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3193/"
] |
370,890 | <p>I have to display marks of my students through my site. The database is created using <a href="http://en.wikipedia.org/wiki/Microsoft_Access" rel="noreferrer">Microsoft Access</a>. How can I display the marks of each student in a table, as they enter the registration number?</p>
| [
{
"answer_id": 371583,
"author": "Diodeus - James MacFarlane",
"author_id": 12579,
"author_profile": "https://Stackoverflow.com/users/12579",
"pm_score": 0,
"selected": false,
"text": "<%\nSet Conn = Server.CreateObject(\"ADODB.Connection\")\nConn.Open \"Provider=Microsoft.Jet.OLEDB.4.0;... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370890",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
370,892 | <p>Please follow the link <a href="http://msdn.microsoft.com/hi-in/default.aspx" rel="noreferrer">http://msdn.microsoft.com/hi-in/default.aspx</a> and see the top right corner of the page. </p>
<p>There you will find a "Microsoft.com" expander. When you move the mouse over it, it displays as a popup and grows. When you move your mouse off of it the window shrinks back. I want to mimic this effect in my WPF application using C#.</p>
| [
{
"answer_id": 370964,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 2,
"selected": false,
"text": "Popup"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370892",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46607/"
] |
370,913 | <p>I have been playing with the Linq to Sql and I was wondering if it was possible to get a single result out? For example, I have the following:</p>
<pre><code>using(DataClassContext context = new DataClassContext())
{
var customer = from c in context.table
where c.ID = textboxvalue
select c;
}
</code></pre>
<p>And with this I need to do a foreach around the var customer but i know that this will be a single value! Anyone know how I could do a <code>textbox.text = c.name;</code> or something along that line?</p>
| [
{
"answer_id": 370924,
"author": "Paul Nearney",
"author_id": 24071,
"author_profile": "https://Stackoverflow.com/users/24071",
"pm_score": 2,
"selected": false,
"text": "var customer = context.table.SingleOrDefault(c => c.ID == textboxvalue);\n"
},
{
"answer_id": 370930,
"au... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36243/"
] |
370,925 | <p>I have a method I want to unittest that has filesystem calls in it and am wondering how to go about it. I have looked at <a href="https://stackoverflow.com/questions/129036/unit-testing-code-with-a-file-system-dependency">Unit testing code with a file system dependency</a> but it does not answer my question.</p>
<p>The method I am testing looks something like this (c#)</p>
<pre><code>public void Process(string input)
{
string outputFile = "output.txt";
this.Transform(input, Resources.XsltFile, outputFile);
if ((new FileInfo(outputFile)).Length == 0)
{
File.Delete(outputFile);
}
}
</code></pre>
<p>I am mocking the Transform(..) method to not output anything to a file as I am unittesting the Process method and not the Transform(..) method and therefore no output.txt file exists. Therefore the if check fails. </p>
<p>How should I do this properly? Should I create some sort of wrapper around the file io methods that i would mock out as well?</p>
| [
{
"answer_id": 370955,
"author": "Dan Vinton",
"author_id": 21849,
"author_profile": "https://Stackoverflow.com/users/21849",
"pm_score": 3,
"selected": false,
"text": "interface FileProvider {\n public Reader getContentReader(String file);\n // notice use of the Reader interfa... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32313/"
] |
370,943 | <p>How can I use multiple keys in WSH Script like (ALT,CTRL,DELETE)?
How can i take a screenshot of an application and paste it in MSWord using WSH SCript?</p>
| [
{
"answer_id": 370963,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 2,
"selected": false,
"text": "SendKeys()"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/370943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46565/"
] |
370,944 | <p>I am using a DropDownList as </p>
<pre><code><asp:DropDownList
ID="ddlLocationName"
runat="server"
DataValueField="Guid"
DataTextField="LocationName"
AppendDataBoundItems="false"
AutoPostBack="false"
onchange="LocationChange()"
></asp:DropDownList>
</code></pre>
<p>and when I select item from dropdown the DataTextField should be displayed in the textfield. For that i am using following javascript: </p>
<pre><code>function LocationChange()
{
document.getElementById ("ctl00_mainContent_ctl02_txtEventLocation").value = document.getElementById ('ctl00_mainContent_ctl02_ddlLocationName')[document.getElementById ('ctl00_mainContent_ctl02_ddlLocationName').selectedIndex].value
}
</code></pre>
<p>It works fine when dropdown's DataValueField is not used. But how to do desired task when DataValueField property of dropdown is also used?</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 370980,
"author": "Aaron Powell",
"author_id": 11388,
"author_profile": "https://Stackoverflow.com/users/11388",
"pm_score": 2,
"selected": false,
"text": "<option />"
},
{
"answer_id": 371041,
"author": "Devashri B.",
"author_id": 43886,
"author_profil... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43886/"
] |
370,954 | <p>I have a KTextEdit, filled with some text. </p>
<p>When I put lots of text, the KTextEdit will be scrolled automatically to the end (obviously). </p>
<p>My question is: how can I scroll to the start (viz to the first line of the KTextEdit) ?!?</p>
| [
{
"answer_id": 370988,
"author": "user11323",
"author_id": 11323,
"author_profile": "https://Stackoverflow.com/users/11323",
"pm_score": 0,
"selected": false,
"text": "KTextEdit *kte;\n...\nkte->append(\"some huge text\");\nkte->verticalScrollBar()->setValue(0);\n"
},
{
"answer_i... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39339/"
] |
370,962 | <p>The question is in Java why can't I define an abstract static method? for example</p>
<pre><code>abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
</code></pre>
| [
{
"answer_id": 371011,
"author": "Mnementh",
"author_id": 21005,
"author_profile": "https://Stackoverflow.com/users/21005",
"pm_score": 1,
"selected": false,
"text": "foo var = new ImplementsFoo();\nvar.bar();\n"
},
{
"answer_id": 372544,
"author": "Jared",
"author_id": 4... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42303/"
] |
370,978 | <p>I have an application that uses a cron like job to update a set of data. The update process happens once a minute and doesn't last long. A servlet exposes this data set to the users. My problem is that during the update process, the servlet requests should block and wait for the process to complete. </p>
<p>In bottom line I have these two functions:</p>
<pre><code>private void updateData() {
}
public List getData() {
}
</code></pre>
<p>The first function runs once a minute. The second one can be called any number of times simultaneously. When updateData runs, all calls of getData must wait for it to complete. One getData call shouldn't block subsequent calls of the same function. The updateData function has higher priority than the getData, i.e. when updateData is to run, it has to wait for all calls of getData to complete, but new calls shouldn't be allowed to start.</p>
<p>What synchronization mechanism should I use for a case like this? I am using a Java server, but I would be interested to know what solutions exist for other platforms as well.</p>
| [
{
"answer_id": 370995,
"author": "Bombe",
"author_id": 43582,
"author_profile": "https://Stackoverflow.com/users/43582",
"pm_score": 0,
"selected": false,
"text": "public void updateData() {\n synchronized (updateLock) {\n /* do stuff. */\n }\n}\n\n\npublic List getData() {\... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24054/"
] |
371,005 | <p>I have a class</p>
<pre><code>public class Broker
{
public Broker(string[] hosts, string endPoint, string port, Type remoteType)
{
}
}
</code></pre>
<p>Which I want to configure using Unity XML Configuration, I can configure it using code in C# as follows already, where "container" is my Unity container</p>
<pre><code> container.Configure<InjectedMembers>()
.ConfigureInjectionFor<Broker>("myBroker",
new InjectionConstructor(hosts, endPoint, port, new InjectionParameter(typeof(IMyBrokeredObject))));
</code></pre>
<p>and it will happly resolve using the normal unity calls</p>
<p>container.Resolve("myBroker");</p>
<p>But currently my xml cannot resolve the final parameter IMyBrokeredObject, I get a resolution exception, as Unity is trying to resolve the type insted of simply injecting the type, as it does in the code above.</p>
<p>Any Ideas?</p>
| [
{
"answer_id": 398214,
"author": "Bruno Shine",
"author_id": 28294,
"author_profile": "https://Stackoverflow.com/users/28294",
"pm_score": 1,
"selected": false,
"text": "<unity>\n<typeAliases>\n <typeAlias alias=\"IMyBrokeredObject\" type=\"MyAssembly.IMyBrokeredObject, MyAssembly\" />\... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371005",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
371,018 | <p>I using the Win32 API and C/C++. I have a HFONT and want to use it to create a new HFONT. The new font should use the exact same font metrics except that it should be bold. Something like:</p>
<pre><code>HFONT CreateBoldFont(HFONT hFont) {
LOGFONT lf;
GetLogicalFont(hFont, &lf);
lf.lfWeight = FW_BOLD;
return CreateFontIndirect(&lf);
}
</code></pre>
<p>The "GetLogicalFont" is the missing API (as far as I can tell anyway). Is there some other way to do it? Preferrably something that works on Windows Mobile 5+.</p>
| [
{
"answer_id": 371052,
"author": "arul",
"author_id": 15409,
"author_profile": "https://Stackoverflow.com/users/15409",
"pm_score": 6,
"selected": true,
"text": "GetObject ( hFont, sizeof(LOGFONT), &lf );\n"
},
{
"answer_id": 372678,
"author": "Johann Gerell",
"author_id"... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20398/"
] |
371,019 | <p>In the javadoc it says that EventListener is </p>
<blockquote>
<p>"A tagging interface that all event listener interfaces must extend."</p>
</blockquote>
<p>Why is that? What's the significance of making a custom listener implement EventListner? Is there any special handling for EventListner somewhere?</p>
| [
{
"answer_id": 371256,
"author": "asalamon74",
"author_id": 21348,
"author_profile": "https://Stackoverflow.com/users/21348",
"pm_score": 4,
"selected": true,
"text": "extends EventListener"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/371019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/931/"
] |
371,026 | <p>What's the shortest way to get an Iterator over a range of Integers in Java? In other words, implement the following:</p>
<pre><code>/**
* Returns an Iterator over the integers from first to first+count.
*/
Iterator<Integer> iterator(Integer first, Integer count);
</code></pre>
<p>Something like</p>
<pre><code>(first..first+count).iterator()
</code></pre>
| [
{
"answer_id": 371034,
"author": "Bombe",
"author_id": 43582,
"author_profile": "https://Stackoverflow.com/users/43582",
"pm_score": 3,
"selected": true,
"text": "List<Integer> ints = new ArrayList<Integer>();\nfor (int i = 0; i < count; i++) {\n ints.add(first + i);\n}\n"
},
{
... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18722/"
] |
371,032 | <p>I am developing a program that continually sends a stream of data in the background and I want to allow the user to set a cap for both upload and download limit.</p>
<p>I have read up on the <a href="http://en.wikipedia.org/wiki/Token_bucket" rel="noreferrer">token bucket</a> and <a href="http://en.wikipedia.org/wiki/Leaky_bucket" rel="noreferrer">leaky bucket</a> alghorhithms, and seemingly the latter seems to fit the description since this is not a matter of maximizing the network bandwidth but rather being as unobtrusive as possible.</p>
<p>I am however a bit unsure on how I would implement this. A natural approach is to extend the abstract Stream class to make it simple to extend existing traffic, but would this not require the involvement of extra threads to send the data while simultaneously receiving (leaky bucket)? Any hints on other implementations that do the same would be appreciated.</p>
<p>Also, although I can modify how much data the program receives, how well does bandwidth throttling work at the C# level? Will the computer still receive the data and simply save it, effectively canceling the throttling effect or will it wait until I ask to receive more?</p>
<p>EDIT: I am interested in throttling both incoming and outgoing data, where I have no control over the opposite end of the stream.</p>
| [
{
"answer_id": 29456717,
"author": "0xDEADBEEF",
"author_id": 909365,
"author_profile": "https://Stackoverflow.com/users/909365",
"pm_score": 2,
"selected": false,
"text": "public ThrottledStream(Stream parentStream, int maxBytesPerSecond=int.MaxValue) \n{\n MaxBytesPerSecond = maxByt... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9479/"
] |
371,054 | <p>I was working with the Action Delegates in C# in the hope of learning more about them and thinking where they might be useful.</p>
<p>Has anybody used the Action Delegate, and if so why? or could you give some examples where it might be useful?</p>
| [
{
"answer_id": 371074,
"author": "Sorskoot",
"author_id": 31722,
"author_profile": "https://Stackoverflow.com/users/31722",
"pm_score": 2,
"selected": false,
"text": "SpecialRequest(this,\n new BalieEventArgs \n { \n Message = \"A Message\", \n Action = Update... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371054",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41968/"
] |
371,055 | <p>I am trying to modify the below program to ensure each msg is converted to utf-8 using Encode::decode(), but I am unsure of how and where to place this to make it work.</p>
<pre><code>#!/usr/bin/perl
use warnings;
use strict;
use Mail::Box::Manager;
open (MYFILE, '>>data.txt');
binmode(MYFILE, ':encoding(UTF-8)');
my $file = shift || $ENV{MAIL};
my $mgr = Mail::Box::Manager->new(
access => 'r',
);
my $folder = $mgr->open( folder => $file )
or die "$file: Unable to open: $!\n";
for my $msg ( sort { $a->timestamp <=> $b->timestamp } $folder->messages)
{
my $to = join( ', ', map { $_->format } $msg->to );
my $from = join( ', ', map { $_->format } $msg->from );
my $date = localtime( $msg->timestamp );
my $subject = $msg->subject;
my $body = $msg->decoded->string;
# Strip all quoted text
$body =~ s/^>.*$//msg;
print MYFILE <<"";
From: $from
To: $to
Date: $date
Subject: $subject
\n
$body
}
</code></pre>
| [
{
"answer_id": 371074,
"author": "Sorskoot",
"author_id": 31722,
"author_profile": "https://Stackoverflow.com/users/31722",
"pm_score": 2,
"selected": false,
"text": "SpecialRequest(this,\n new BalieEventArgs \n { \n Message = \"A Message\", \n Action = Update... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] |
371,059 | <p>Here is my query:</p>
<pre><code> Select Top 10 CS.CaseStudyID,
CS.Title,
CSI.ImageFileName
From CaseStudy CS
Left Join CaseStudyImage CSI On CS.CaseStudyID = CSI.CaseStudyID
And CSI.CSImageID in(
Select Min(CSImageID) -- >not really satisfactory
From CaseStudyImage
Group By CaseStudyID
)
Order By CS.CaseStudyID ASC
</code></pre>
<p>Instead of min(CSImageID) I'd like a random record from my CaseStudyImage table that corresponds to the particular case study</p>
<p>Can anyone point me in the right direction pleas?</p>
| [
{
"answer_id": 371061,
"author": "Bombe",
"author_id": 43582,
"author_profile": "https://Stackoverflow.com/users/43582",
"pm_score": 0,
"selected": false,
"text": "ORDER BY RAND() LIMIT 1"
},
{
"answer_id": 375418,
"author": "Chaowlert Chaisrichalermpol",
"author_id": 239... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11394/"
] |
371,064 | <p>I have unsorted map of key value pairs.</p>
<pre><code>input = {
"xa" => "xavalue",
"ab" => "abvalue",
"aa" => "aavalue",
"ba" => "bavalue",
}
</code></pre>
<p>Now I want to sort them by the key and cluster them into sections by the first character of the key. Similar to this:</p>
<pre><code>output1 = {
"a" => {
"aa" => "aavalue",
"ab" => "abvalue",
},
"b" => {
"ba" => "bavalue",
},
"x" => {
"xa" => "xavalue",
},
}
</code></pre>
<ol>
<li><p>While this is relatively trivial I am looking for a concise way to express this transformation from input to output1 in ruby. (My approach is probably too verbose as to ruby standards)</p></li>
<li><p>You might also have noticed that maps are (usually) not ordered. So the above data structure will not work appropriately unless I manually sort the keys and wrap the access to the map. So how would I create a key ordered map in ruby? Or is there one already?</p></li>
<li><p>If the ordered map approach is not that easy I would have to change the final structure into something like the following. Again I am looking for some concise ruby code to come from input to output2.</p></li>
</ol>
<p>.</p>
<pre><code>output2 = [
{
"name" => "a",
"keys" => [ "aa", "ab" ],
"values" => [ "aavalue", "abvalue" ],
},
{
"name" => "b",
"keys" => [ "ba" ],
"values" => [ "bavalue" ],
},
{
"name" => "x",
"keys" => [ "xa" ],
"values" => [ "xavalue" ],
}
]
</code></pre>
| [
{
"answer_id": 371234,
"author": "ttepasse",
"author_id": 46657,
"author_profile": "https://Stackoverflow.com/users/46657",
"pm_score": 1,
"selected": false,
"text": "class Hash\n def clustered\n clustered = Hash.new\n sort.each do | key, value |\n first = key[0,1]\n unl... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371064",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33165/"
] |
371,072 | <p>I have the code pasted below, which servers as the core of a small ajax application. This was working fine previously, with makewindows actually displaying a popup containing the rsult of artcile_desc. I seem to have an error before that function however, as now only the actual php code is outputted. This is not a problem with my server setup, as I am the administrator and this has not changed.</p>
<p>I get the following errors with Firebug, but I am not sure what they mean.</p>
<pre><code>unterminated string literal
onclick(click clientX=52, clientY=50)1GmRZ%2F...D9g%3D%3D (line 2)
[Break on this error] child1.document.write("<br />\n
1GmRZ%2F...D9g%3D%3D (line 2)
updateByQuery is not defined
onclick(click clientX=29, clientY=17)CLQWYjW1...WlQ%3D%3D (line 2)
[Break on this error] updateByQuery("Layer3", "Ed Hardy");
var xmlHttp
var layername
var url
function update(layer, url) {
var xmlHttp=GetXmlHttpObject(); //you have this defined elsewhere
if(xmlHttp==null) {
alert("Your browser is not supported?");
}
xmlHttp.onreadystatechange = function() {
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
document.getElementById(layer).innerHTML=xmlHttp.responseText;
} else if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading") {
document.getElementById(layer).innerHTML="loading";
}
//etc
}
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function updateByPk(layer, pk) {
url = "get_auction.php?cmd=GetAuctionData&pk="+pk+"&sid="+Math.random();
update(layer, url);
}
function updateByQuery(layer, query) {
url = "get_records.php?cmd=GetRecordSet&query="+query+"&sid="+Math.random();
update(layer, url);
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
xmlHttp=new XMLHttpRequest();
}catch (e)
{
try
{
xmlHttp =new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
}
return xmlHttp;
}
function makewindows(){
child1 = window.open ("about:blank");
child1.document.write("<?php echo htmlspecialchars(json_encode($row2['ARTICLE_DESC']), ENT_QUOTES); ?>");
child1.document.close();
}
</code></pre>
<p>Which whatever I try the makewindows function simply outputs the php code as the html source, and not the result of the php code. This was previously working fine, and I am not sure what I have changed to result in this behavior.</p>
<p>I have pasted all the code now. An error is generated by a link that calls updateByQuery, preventing makewindows from being parsed correctly..I think. </p>
<p>edit: the php is getting parsed when I use this code:</p>
<pre><code>function makewindows(){
child1 = window.open ("about:blank");
child1.document.write("<?php echo htmlspecialchars(json_encode($row2['ARTICLE_DESC']), ENT_QUOTES); ?>");
child1.document.close();
}
</code></pre>
<p>But not the code above</p>
<p>the result of the php is this:</p>
<pre><code>child1.document.write("<br />
58<b>Notice</b>: Undefined variable: row2 in <b>C:\Programme\EasyPHP 2.0b1\www\records4\fetchlayers.js</b> on line <b>57</b><br />
59null");
</code></pre>
<p>which cuases an error</p>
| [
{
"answer_id": 371284,
"author": "Jay",
"author_id": 41690,
"author_profile": "https://Stackoverflow.com/users/41690",
"pm_score": 2,
"selected": true,
"text": "child1.document.write(\"<?php echo htmlspecialchars(json_encode($row2['ARTICLE_DESC']), ENT_QUOTES); ?>\");\n"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/371072",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] |
371,079 | <p>I have a problem with the jQuery-UI dialog in my ASP.NET form:</p>
<pre><code>$("#pnlReceiverDialog").dialog({
autoOpen:false,
modal: true,
height:220,
width:500,
resizable :false,
overlay: { opacity: 0.5,background: "black" },
buttons: {
"Cancel": function() {
$(this).dialog("close");
},
"Ok": function() {
__doPostBack('ctl00$phContent$ctl00$LetterLocation$pupNewReceiver','')
}
}
});
</code></pre>
<p><code>pnlReceiverDialog</code> contains an ASP.NET <code>TextBox</code>.</p>
<p>When I click on the OK button, the form posts back but the textbox doesn't have a value.</p>
| [
{
"answer_id": 4193284,
"author": "Lars Thorén",
"author_id": 372208,
"author_profile": "https://Stackoverflow.com/users/372208",
"pm_score": 0,
"selected": false,
"text": "$(\"#ModalId\").parent().appendTo(jQuery(\"form:first\"));\n"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/371079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
371,107 | <p>Different iPhones have different published memory 4GB, 8GB and 16GB. The touch can have 32GB. My understanding is this is the off-line memory (disk alike). </p>
<p>How much actual fast ram is there in the device available for my Cocoa Application? </p>
<p>Is there a preconfigured virtual amount?</p>
| [
{
"answer_id": 3085744,
"author": "AnthonyLambert",
"author_id": 31762,
"author_profile": "https://Stackoverflow.com/users/31762",
"pm_score": 5,
"selected": true,
"text": "iPhone = 128 MB\niPhone 3G = 128 MB\niPhone 3GS = 256 MB\niPhone 4 = 512 MB\niPhone 4S =... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31762/"
] |
371,109 | <p><strong>UPDATE</strong> </p>
<p>I have combined various answers from here into a 'definitive' answer on a <a href="https://stackoverflow.com/questions/1747235/weak-event-handler-model-for-use-with-lambdas/1747236#1747236">new question</a>.</p>
<p><strong>Original question</strong></p>
<p>In my code I have an event publisher, which exists for the whole lifetime of the application (here reduced to bare essentials):</p>
<pre><code>public class Publisher
{
//ValueEventArgs<T> inherits from EventArgs
public event EventHandler<ValueEventArgs<bool>> EnabledChanged;
}
</code></pre>
<p>Because this publisher can be used all over the place, I was quite pleased with myself for creating this little helper class to avoid re-writing the handling code in all subscribers:</p>
<pre><code>public static class Linker
{
public static void Link(Publisher publisher, Control subscriber)
{
publisher.EnabledChanged += (s, e) => subscriber.Enabled = e.Value;
}
//(Non-lambda version, if you're not comfortable with lambdas)
public static void Link(Publisher publisher, Control subscriber)
{
publisher.EnabledChanged +=
delegate(object sender, ValueEventArgs<bool> e)
{
subscriber.Enabled = e.Value;
};
}
}
</code></pre>
<p>It worked fine, until we started using it on smaller machines, when I started getting the occasional:</p>
<pre><code>System.ComponentModel.Win32Exception
Not enough storage is available to process this command
</code></pre>
<p>As it turns out, there is one place in the code where subscribers controls are being dynamically created, added and removed from a form. Given my advanced understanding of garbage collection etc (i.e. none, until yesterday), I never thought to clear up behind me, as in the vast majority of cases, the subscribers also live for the lifetime of the application.</p>
<p>I've fiddled around a while with <a href="http://diditwith.net/CommentView,guid,aacdb8ae-7baa-4423-a953-c18c1c7940ab.aspx#commentstart" rel="nofollow noreferrer">Dustin Campbell's WeakEventHandler</a>, but it <em>doesn't work with anonymous delegates</em> (not for me anyway).</p>
<p>Is there anyway out of this problem? I really would like to avoid having to copy-paste boiler-plate code all over the shop.</p>
<p>(Oh, and don't bother with asking me WHY we are creating and destroying controls all the time, it wasn't my design decision...)</p>
<p>(PS: It's a winforms application, but we've upgraded to VS2008 and .Net 3.5, should I consider using the <a href="http://msdn.microsoft.com/en-us/library/aa970850.aspx" rel="nofollow noreferrer">Weak Event pattern</a>?)</p>
<p>(PPS: Good <a href="http://#371150" rel="nofollow noreferrer">answer from Rory</a>, but if anyone can come up with an equivalent to the WeakEventHandler which avoids me having to remember to explicitly UnLink/Dispose, that would be cool...)</p>
<p><strong>EDIT</strong> I must admit that I worked around this problem by "recycling" the controls in question. However the workaround has come back to haunt me as the 'key' I was using is apparently non-unique (sob). I've just discovered other links <a href="http://danylaporte.blogspot.com/2008/09/weakeventhandler.html" rel="nofollow noreferrer">here</a> (tried this - seems to be a bit <em>too</em> weak - GC clears delegates even if target is still alive, same problem with <a href="https://stackoverflow.com/questions/371109/garbage-collection-when-using-anonymous-delegates-for-event-handling/955928#955928">s,oɔɯǝɹ answer</a> below), <a href="http://code.logos.com/blog/2008/08/event_subscription_using_weak_references.html" rel="nofollow noreferrer">here</a> (forces you to modify publisher, and doesn't really work with anonymous delegates) and <a href="http://joshsmithonwpf.wordpress.com/2009/04/06/a-mediator-prototype-for-wpf-apps/" rel="nofollow noreferrer">here</a> (cited-as-incomplete by Dustin Campbell). </p>
<p>It occurs to me that what I'm looking for may be semantically impossible - closures are designed to 'hang around even after I'm gone'. </p>
<p>I've found another workaround, so I'll stick with that, pending a <a href="http://blogs.msdn.com/ericlippert/" rel="nofollow noreferrer">voice from the gods</a>.</p>
| [
{
"answer_id": 371150,
"author": "Rory",
"author_id": 8479,
"author_profile": "https://Stackoverflow.com/users/8479",
"pm_score": 3,
"selected": false,
"text": "public static class Linker\n{\n\n //(Non-lambda version, I'm not comfortable with lambdas:)\n public static EventHandler<... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410/"
] |
371,112 | <p>Using the CRM views, is there a way to retrieve a list of all of the activities linked to a specific account?</p>
<p>I want it to retrieve not only those associated with the account directly, but also those associated with the account's contacts, cases, etc. I am trying to replicate the list generated when you click the Activities option from within an account.</p>
<p>So far I have retrieved the contacts for the account and their activities. I also noticed that CRM doesn't seem to always return what I expect. Sometimes activities related to contacts of the account are not displayed. Other times, emails / appointments that are logically related to the account but have nothing in their regardingobjectid field are shown.</p>
<p>I am hoping this doesn't mean creating the mother of all joins or querying each activity type separately. Particularly because I need all of the related case activities, opportunity activities, etc.</p>
| [
{
"answer_id": 398242,
"author": "brendan",
"author_id": 225,
"author_profile": "https://Stackoverflow.com/users/225",
"pm_score": 1,
"selected": true,
"text": "Declare @account_guid varchar(200)\nSelect @account_guid = 'insert some guid here'\n\nDeclare @GUIDS as Table(id varchar(200), ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44938/"
] |
371,115 | <p>I have a bunch of log files. I need to find out how many times a string occurs in all files.</p>
<pre><code>grep -c string *
</code></pre>
<p>returns</p>
<pre><code>...
file1:1
file2:0
file3:0
...
</code></pre>
<p>Using a pipe I was able to get only files that have one or more occurrences:</p>
<pre><code>grep -c string * | grep -v :0
...
file4:5
file5:1
file6:2
...
</code></pre>
<p>How can I get only the combined count? (If it returns <code>file4:5, file5:1, file6:2</code>, I want to get back 8.)</p>
| [
{
"answer_id": 371124,
"author": "Michael Haren",
"author_id": 29,
"author_profile": "https://Stackoverflow.com/users/29",
"pm_score": 5,
"selected": false,
"text": "grep string * | wc -l\n"
},
{
"answer_id": 371130,
"author": "Bombe",
"author_id": 43582,
"author_prof... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17469/"
] |
371,133 | <p>I have a class that contains a list of objects. What's the best way to run some code in the class when the list is modified?</p>
<pre><code>class MyManagerClass
{
ArrayList list = new ArrayList(); // will likely be a different collection class
private OnItemAddedToList(object o)
{
// how to call this?
}
private OnItemRemovedFromList(object o)
{
// how to call this?
}
}
</code></pre>
| [
{
"answer_id": 371163,
"author": "mookid8000",
"author_id": 6560,
"author_profile": "https://Stackoverflow.com/users/6560",
"pm_score": 1,
"selected": false,
"text": "CollectionChanged"
},
{
"answer_id": 371167,
"author": "Alex J",
"author_id": 27667,
"author_profile"... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27667/"
] |
371,140 | <p>I'm using WinRAR SFX module to create an installation, and use its presetup option to run some preliminary tests.</p>
<p>Since wscript can only accept vbs file, and not the script itself, I first run "cmd /c echo {...script code...} > setup.vbs", and then I run "wscript setup.vbs". The run of the first cmd command opens a brief command window, and I would really like to avoid this. I thought of using RunDll32 to write this data, but couldn't find any suitable API to use.</p>
<p>Can anyone think of a way to bypass it and create a small file with a small VBScript text without opening a Command Prompt window?</p>
<p>Thanks a lot,</p>
<p>splintor</p>
| [
{
"answer_id": 371198,
"author": "Patrick Cuff",
"author_id": 7903,
"author_profile": "https://Stackoverflow.com/users/7903",
"pm_score": 2,
"selected": false,
"text": "TYPE [script_file] > setup.vbs\n"
},
{
"answer_id": 393433,
"author": "Patrick Cuff",
"author_id": 7903... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46635/"
] |
371,147 | <p>So I've got a form in my Rails app which uses a custom FormBuilder to give me some custom field tags</p>
<pre><code><% form_for :staff_member, @staff_member, :builder => MyFormBuilder do |f| %>
[...]
<%= render :partial => "staff_members/forms/personal_details", :locals => {:f => f, :skill_groups => @skill_groups, :staff_member => @staff_member} %>
[...]
<% end %>
</code></pre>
<p>Now, this partial is in an area of the form which gets replaces by an AJAX callback. What I end up doing from the controller in response to the AJAX request is:</p>
<pre><code>render :partial => "staff_members/forms/personal_details", :locals => {:skill_groups => @skill_groups, :staff_member => @staff_member}
</code></pre>
<p>However, if I do that then the form breaks, as the FormBuilder object I used in the form_for is no longer available. Is there any way for me to use my custom FormBuilder object inside a partial used for an AJAX callback?</p>
| [
{
"answer_id": 405444,
"author": "nakajima",
"author_id": 39589,
"author_profile": "https://Stackoverflow.com/users/39589",
"pm_score": 1,
"selected": false,
"text": "# in the controller\nrender :partial => {\n :f => MyFormBuilder.new(:staff_member, @staff_member, template),\n :skill_g... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31582/"
] |
371,153 | <p>I am using the program below to sort and eventually print out email messages. Some messages may contain attachments or HTML code, which would not be good for printing. Is there an easy way to strip attachments and strip HTML but not the text formatted by HTML from the messages?</p>
<pre><code>#!/usr/bin/perl
use warnings;
use strict;
use Mail::Box::Manager;
open (MYFILE, '>>data.txt');
binmode(MYFILE, ':encoding(UTF-8)');
my $file = shift || $ENV{MAIL};
my $mgr = Mail::Box::Manager->new(
access => 'r',
);
my $folder = $mgr->open( folder => $file )
or die "$file: Unable to open: $!\n";
for my $msg ( sort { $a->timestamp <=> $b->timestamp } $folder->messages)
{
my $to = join( ', ', map { $_->format } $msg->to );
my $from = join( ', ', map { $_->format } $msg->from );
my $date = localtime( $msg->timestamp );
my $subject = $msg->subject;
my $body = $msg->decoded->string;
# Strip all quoted text
$body =~ s/^>.*$//msg;
print MYFILE <<"";
From: $from
To: $to
Date: $date
Subject: $subject
\n
$body
}
</code></pre>
| [
{
"answer_id": 371179,
"author": "Nietzche-jou",
"author_id": 39892,
"author_profile": "https://Stackoverflow.com/users/39892",
"pm_score": 1,
"selected": false,
"text": "perldoc -q html"
},
{
"answer_id": 371192,
"author": "innaM",
"author_id": 7498,
"author_profile"... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] |
371,155 | <p>I'm using Python 2.5. The DLL I imported is created using the CLR. The DLL function is returning a string. I'm trying to apply "partition" attribute to it. I'm not able to do it. Even the partition is not working. I think "all strings returned from CLR are returned as Unicode".</p>
| [
{
"answer_id": 371200,
"author": "sastanin",
"author_id": 25450,
"author_profile": "https://Stackoverflow.com/users/25450",
"pm_score": 3,
"selected": true,
"text": "type(yourvar)"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/371155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46646/"
] |
371,174 | <p>I often find linq being problematic when working with custom collection object.
They are often defened as</p>
<p>The base collection</p>
<pre><code>abstract class BaseCollection<T> : List<T> { ... }
</code></pre>
<p>the collections is defined as</p>
<pre><code>class PruductCollection : BaseCollection<Product> { ... }
</code></pre>
<p>Is there a better way to add results from a linq expession to this collection than
addrange or concat?</p>
<pre><code>var products = from p in HugeProductCollection
where p.Vendor = currentVendor
select p;
PruductCollection objVendorProducts = new PruductCollection();
objVendorProducts.AddRange(products);
</code></pre>
<p>It would be nice if the object returned form the linq query was of my custom collection type. As you seem to need to enumerate the collection two times to do this.</p>
<p><strong>EDIT</strong> :
After reading the answers i think the best solution is to implementa a ToProduct() extention.
Wonder if the covariance/contravariance in c#4.0 will help solve these kinds of problems.</p>
| [
{
"answer_id": 371221,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 4,
"selected": true,
"text": "IEnumerable<T>"
},
{
"answer_id": 371223,
"author": "bruno conde",
"author_id": 31136,
"author_profi... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24821/"
] |
371,181 | <p>WSPBuilder</p>
<p>Version: 0.9.8.0830
Created by Carsten Keutmann
GPL License 2007</p>
<p>Install and deploying [MYDLL]
Unable to deploy solution
Inner exception(1): This solution contains one or more assemblies targeted for the global assembly cache. You should use a strong name for any assembly that will be in the global assembly cache.</p>
| [
{
"answer_id": 371215,
"author": "alexandrul",
"author_id": 19756,
"author_profile": "https://Stackoverflow.com/users/19756",
"pm_score": 1,
"selected": false,
"text": "Delay sign only"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/371181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41291/"
] |
371,183 | <p>I'm developing an HTML newsletter system using PHP & PEAR. It sends out the emails fine.</p>
<p>However I cannot force Apple Mail to reload images from the server. I have tried:</p>
<ul>
<li>Restarting Mail</li>
<li>Clear ~/Library/MailDownloads </li>
<li>Clear ~/Library/Cache/Mail</li>
<li>Empty Safari cache</li>
</ul>
<p>Does any one know where Apple Mail caches the images ?</p>
| [
{
"answer_id": 485467,
"author": "Ates Goral",
"author_id": 23501,
"author_profile": "https://Stackoverflow.com/users/23501",
"pm_score": 2,
"selected": false,
"text": "<img src=\"http://example.com/images/hello.png?343882881923\"/>\n"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/371183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2725/"
] |
371,203 | <p>Can you recommend any tool to migrate sources (with history) from TFS to SVN?</p>
| [
{
"answer_id": 7591528,
"author": "Benjamin",
"author_id": 186606,
"author_profile": "https://Stackoverflow.com/users/186606",
"pm_score": 1,
"selected": false,
"text": "public Tfs2SvnConverter(string tfsPath, string svnPath, bool createSvnFileRepository, int fromChangeset, string workin... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
371,204 | <p>I am writing a managed custom action. I am using the DTF Framework from Windows Installer Xml to wrap the managed dll into a usable CA dll. The CA does what it is supposed to, but I am still having trouble with error handling:</p>
<pre><code>Dim record As New Record(1)
' Field 0 intentionally left blank
' Field 1 contains error number
record(1) = 27533
session.Message(InstallMessage.Error, record)
</code></pre>
<p>The above code produces the following text shown in the MSI log:</p>
<blockquote>
<p>MSI (c) (C4 ! C6) [13:15:08:749]: Product: TestMSI -- Error 27533. The case-sensitive passwords do not match.</p>
</blockquote>
<p>The error number refers to the code contained in the Error table within the MSI. The Message shown above is correct.</p>
<p>My problem is: Why does Windows Installer NOT create a dialog notifying the user about the error?</p>
| [
{
"answer_id": 654840,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": -1,
"selected": false,
"text": " private void _handleSqlException(SqlException ex)\n {\n StringBuilder errorMessage = new StringBuilder();\n ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23369/"
] |
371,209 | <p>How can I blur a whole page using CSS?
Other elements such as images are allowed.</p>
| [
{
"answer_id": 371257,
"author": "Aron Rotteveel",
"author_id": 11568,
"author_profile": "https://Stackoverflow.com/users/11568",
"pm_score": 4,
"selected": false,
"text": "/* DIV-element with black background and 50% opacity set */\ndiv.overlay {\n position: absolute;\n width: 100... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
371,227 | <p>Is there anyway to change the ASPNETDB and also using SQLExpress (2005) user instance ?</p>
<p>I have changed my web.config's connectin string to </p>
<pre><code><remove name="LocalSqlServer"/>
<add name="LocalSqlServer"
connectionString="Data Source=.\SQLEXPRESS;
AttachDbFilename=|DataDirectory|\Kooft.mdf;
User Instance=true;
Integrated Security=True;
Initial Catalog=Kooft;"
providerName="System.Data.SqlClient" />
</code></pre>
<p>but every time I using ASP.Net Configuration Tool, it will create another ASPNETDB.mdf file in my App_Data folder.</p>
| [
{
"answer_id": 371294,
"author": "Zhaph - Ben Duguid",
"author_id": 33051,
"author_profile": "https://Stackoverflow.com/users/33051",
"pm_score": 2,
"selected": false,
"text": "C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\aspnet_regsql.exe\n"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/371227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
371,237 | <p>In F#, you can generate a set of numbers, just by saying [1..100].</p>
<p>I want to do something similar in C#. This is what I have come up with so far:</p>
<pre><code>public static int[] To(this int start, int end)
{
var result = new List<int>();
for(int i = start; i <= end; i++)
result.Add(i);
return result.ToArray();
}
</code></pre>
<p>By doing this, I can now create a set by saying 1.To(100)</p>
<p>Unfortunately, this is not nearly as readable as [1..100]. Has anyone come up with a better way to do this in C#? Is it more readable if it is lowercase? 1.to(100), for instance? Or, is "To" a bad word? Is something like 1.Through(100) more readable?</p>
<p>Just looking for some thoughts. Has anyone else come up with a more elegant solution?</p>
<p><strong>EDIT:</strong>
After reading the responses, I have re-written my To method using the range:</p>
<pre><code>public static int[] To(this int start, int end)
{
return Enumerable.Range(start, end - start + 1).ToArray();
}
</code></pre>
<p>I am still looking for thoughts on the readability of 1.To(100)</p>
| [
{
"answer_id": 371251,
"author": "lc.",
"author_id": 44853,
"author_profile": "https://Stackoverflow.com/users/44853",
"pm_score": 0,
"selected": false,
"text": "Set(1,100)"
},
{
"answer_id": 371273,
"author": "Christoffer Lette",
"author_id": 11808,
"author_profile":... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36687/"
] |
371,246 | <p>I have a very simple Update statement that will update mail server settings and network credentials info... Query works fine when I run it in Access but C# keeps giving me the error stating that my SQL Syntax is wrong ... I have a dataaccess layer (dal class) and Update instance method pasted belows ... But the problem must be sth else cuz I have updated lots of stuff this way but this time it just won't do .. any clues will be greatly appreciated. Thx in advance.</p>
<p>Update instance method in DAL class .. (this is supposed to be a Data Access Layer :) I'm just a management graduate :P</p>
<pre><code>public int UpdateRow(string Query, bool isSP, params OleDbParameter[] args)
{
int affectedRows = -1;
using (con = new OleDbConnection(connStr))
{
using (cmd = con.CreateCommand())
{
cmd.CommandText = Query;
if (isSP)
{
cmd.CommandType = CommandType.StoredProcedure;
}
if (args != null)
{
foreach (OleDbParameter prm in args)
{
cmd.Parameters.Add(prm);
}
}
try
{
con.Open();
affectedRows = cmd.ExecuteNonQuery();
}
catch(OleDbException ex)
{
throw ex;
}
catch (Exception ex)
{
throw ex;
}
}
}
return affectedRows;
}
</code></pre>
<p>And the ASP.NEt codebehind that will do the updating =</p>
<pre><code>protected void Update_Click(object sender, EventArgs e) {
DAL dal = new DAL();
string upt = string.Format("UPDATE [MailConfig] SET Server='{0}', Username='{1}', Password='{2}', AddressFrom='{3}', DisplayName='{4}'",server.Text,username.Text,password.Text,replyto.Text,displayname.Text);
dal.UpdateRow(upt,false,null);
LoadData();
}
</code></pre>
<p>peace!</p>
| [
{
"answer_id": 371258,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 0,
"selected": false,
"text": "string.Format"
},
{
"answer_id": 371281,
"author": "Tony Peterson",
"author_id": 26140,
"author_p... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371246",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
371,266 | <p>I've found this piece of code on <a href="http://www.koders.com/csharp/fidACD7502AA845419FF59B7DA804D3C8FCA0E40138.aspx?s=basecodegeneratorwithsite#L76" rel="nofollow noreferrer">Koders</a>:</p>
<pre><code>private ServiceProvider SiteServiceProvider
{
get
{
if (serviceProvider == null)
{
serviceProvider = new ServiceProvider(site as VSOLE.IServiceProvider);
Debug.Assert(serviceProvider != null, "Unable to get ServiceProvider from site object.");
}
return serviceProvider;
}
}
</code></pre>
<p>I'm wondering, is there <em>any</em> possible way the <code>Debug.Assert(serviceProvider != null</code> could trigger? I'm under the impression that <code>new</code> could only be aborted by an exception, in which case the assert would never be reached.</p>
| [
{
"answer_id": 371310,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": false,
"text": "SomeType provider = SomeFactory.CreateProvider();\nif(provider == null) // damn!! no factory implementation loaded...... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4918/"
] |
371,268 | <p>using the Code Snippet for sending email in VB.Net I have successfully sent an email from my local machine, but when I Upload it to my server I get a message that the email failed. We have a national relay server that is running SMTP and I am pointed at that server in both instances. The only differance that jump out at me between the two machines is that the server is not running SMTP. Do I need SMTP to be running on the server if I am using a relay server to send the email that is running SMTP?</p>
<pre><code> Dim message As New MailMessage("DoNotReply@faa.gov", My.Settings.NotifyList, "Starting FalconCMSOffloader @ " & My.Settings.FacID & " - " & Now, "NM")
Dim emailClient As New SmtpClient(My.Settings.EmailServerAddress)
emailClient.Send(message)
</code></pre>
| [
{
"answer_id": 371309,
"author": "J c",
"author_id": 25837,
"author_profile": "https://Stackoverflow.com/users/25837",
"pm_score": 3,
"selected": true,
"text": "telnet RelayServerAddress 25\n"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/371268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38349/"
] |
371,272 | <p>Rails introduced some core extensions to Ruby like <code>3.days.from_now</code> which returns, as you'd expect a date three days in the future. With extension methods in C# we can now do something similar:</p>
<pre><code>static class Extensions
{
public static TimeSpan Days(this int i)
{
return new TimeSpan(i, 0, 0, 0, 0);
}
public static DateTime FromNow(this TimeSpan ts)
{
return DateTime.Now.Add(ts);
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine(
3.Days().FromNow()
);
}
}
</code></pre>
<p>Or how about:</p>
<pre><code>static class Extensions
{
public static IEnumerable<int> To(this int from, int to)
{
return Enumerable.Range(from, to - from + 1);
}
}
class Program
{
static void Main(string[] args)
{
foreach (var i in 10.To(20))
{
Console.WriteLine(i);
}
}
}
</code></pre>
<p>Is this fundamentally wrong, or are there times when it is a good idea, like in a framework like Rails?</p>
| [
{
"answer_id": 371291,
"author": "mackenir",
"author_id": 25457,
"author_profile": "https://Stackoverflow.com/users/25457",
"pm_score": 3,
"selected": false,
"text": "TimeSpan.FromSeconds(4).FromNow()\n"
},
{
"answer_id": 371360,
"author": "Andrew Hare",
"author_id": 3421... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27782/"
] |
371,279 | <p>I've got the following Linq2Sql and it's doing more than one round trip for my 'SELECT' statement. I'm not sure why. First the code, then the explanation:-</p>
<pre><code>from p in db.Questions
select new Models.Question
{
Title = p.Title,
TagList = (from t in p.QuestionTags
select t.Tag.Name).ToList()
}
</code></pre>
<p>Now the database is</p>
<blockquote>
<p><em>Questions <-one to many-> QuestionTags <-many to one->Tag</em></p>
</blockquote>
<p>so one question has one to many Tags, with a link table in the middle. This way, i can reuse tags multiple times. (I'm open to a better schema if there's one).</p>
<p>Doing this does the following Sql code generated by Linq2Sql</p>
<pre><code>SELECT [t0].[QuestionId] AS [ID], etc.... <-- that's the good one
</code></pre>
<p>.</p>
<pre><code>exec sp_executesql N'SELECT [t1].[Name]
FROM [dbo].[QuestionTags] AS [t0]
INNER JOIN [dbo].[Tags] AS [t1] ON [t1].[TagId] = [t0].[TagId]
WHERE [t0].[QuestionId] = @x1',N'@x1 int',@x1=1
</code></pre>
<p>The second sql block is listed 2x .. i think that's because the first sql block returns TWO results, so the second one is fired for each result from the first.</p>
<p>Is there any way i can make this one sql statement instead of 1 + n, where n = the number of results from the first query?</p>
<h2>Update:</h2>
<p>I've tried both Eager and Lazy loading and there's no difference. </p>
<pre><code>DataLoadOptions dataLoadOptions = new DataLoadOptions();
dataLoadOptions.LoadWith<Question>(x => x.QuestionTags);
dataLoadOptions.LoadWith<QuestionTag>(x => x.Tag);
db.LoadOptions = dataLoadOptions;
</code></pre>
| [
{
"answer_id": 371297,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "DECLARE @foo varchar(max)\nSET @foo = ''\nSELECT @foo = @foo + [SomeColumn] + ',' -- CSV\nFROM [SomeTable]\nWHERE -- ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] |
371,300 | <p>In my domain model I have an abstract class CommunicationChannelSpecification, which has child classes like FTPChannelSpecification, EMailChannelSpecification and WebserviceChannelSpecification. Now I want to create an HQL query which contains a where clause that narrows down the result to certain types of channel specifications. E.g. (in plain English) select all CommunicationChannelSpecifications that whose types occur in the set {FTPChannelSpecification, WebserviceChannelSpecification}.</p>
<p>How can this be achieved in HQL? I'm using NHibernate 2.0.1 and a table per subclass inheritance mapping strategy...</p>
<p>Thanks!</p>
<p>Pascal</p>
| [
{
"answer_id": 371343,
"author": "bangroot",
"author_id": 45693,
"author_profile": "https://Stackoverflow.com/users/45693",
"pm_score": 4,
"selected": true,
"text": "from CommunicationChannelSpecifications spec where spec.class in (?)\n"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/371300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/414376/"
] |
371,302 | <p>I would like to implement a post build event that performs the following actions</p>
<ol>
<li>A relative path copy of the DLL output (1 file, not all the debug jazz)</li>
<li>A register the output DLL to GAC</li>
</ol>
<p>How is this done?</p>
| [
{
"answer_id": 371332,
"author": "Dirk Vollmar",
"author_id": 40347,
"author_profile": "https://Stackoverflow.com/users/40347",
"pm_score": 5,
"selected": true,
"text": "copy $(TargetPath) $(TargetDir)..\\..\\someFolder\\myoutput.dll\nregasm $(TargetPath) \n"
},
{
"answer_id": 37... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41291/"
] |
371,320 | <p>I have a YouTube's player in the webpage. I need to change the video played by this player dynamicaly.</p>
<p>This is (relatively) easy using YouTube's chromeless player. It has method <a href="http://code.google.com/apis/youtube/chromeless_player_reference.html#loadVideoById" rel="noreferrer"><code>loadVideoById()</code></a> which works perfectly. The problem is, that the chromeless player doesn't have any controls (play/pause, etc.). The <a href="http://code.google.com/apis/youtube/js_api_reference.html#Functions" rel="noreferrer">regular YouTube player</a> has all this, but it doesn't have the <code>loadVideoById()</code> method.</p>
<p>Is there any way to include the controls of regular player into chromeless player, or to implement <code>loadVideoById()</code> method in the regular player?</p>
<p>Thanks.</p>
| [
{
"answer_id": 5130725,
"author": "asper",
"author_id": 636047,
"author_profile": "https://Stackoverflow.com/users/636047",
"pm_score": 1,
"selected": false,
"text": " * The mediaContentUrl must be a fully qualified YouTube player URL in the format http://www.youtube.com/e/VIDEO_ID. I... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22920/"
] |
371,322 | <p>I have to read invoice ascii files that are structured in a really convoluted way, for example:</p>
<pre><code>55651108 3090617.10.0806:46:32101639Example Company Construction Company Example Road. 9 9524 Example City
</code></pre>
<p>There's actually additional stuff in there, but I don't want to confuse you any further.</p>
<p>I know I'm doomed if the client can't offer a better structure. For instance 30906 is an iterative number that grows. 101639 is the CustomerId. The whitespaces between "Example Company" and "Construction Company" are of variable length The field "Example Company" could have whitespaces of variable length too however, for instance "Microsoft Corporation Redmond". Same with the other fields. So there's no clear way to extract data from the latter part.</p>
<p>But that's not the question. I got taken away. My question is as follows:</p>
<p>If the input was somewhat structured and well defined, how would you guard against future changes in its structure. How would you design and implement a reader. </p>
<p>I was thinking of using a simple EAV Model in my DB, and use text or xml templates that describe the input, the entity names, and their valuetypes. I would parse the invoice files according to the templates.</p>
| [
{
"answer_id": 371344,
"author": "mat",
"author_id": 42083,
"author_profile": "https://Stackoverflow.com/users/42083",
"pm_score": 0,
"selected": false,
"text": "unpack"
},
{
"answer_id": 371383,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stack... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13466/"
] |
371,328 | <p>Given the following class</p>
<pre><code>public class Foo
{
public int FooId { get; set; }
public string FooName { get; set; }
public override bool Equals(object obj)
{
Foo fooItem = obj as Foo;
if (fooItem == null)
{
return false;
}
return fooItem.FooId == this.FooId;
}
public override int GetHashCode()
{
// Which is preferred?
return base.GetHashCode();
//return this.FooId.GetHashCode();
}
}
</code></pre>
<p>I have overridden the <code>Equals</code> method because <code>Foo</code> represent a row for the <code>Foo</code>s table. Which is the preferred method for overriding the <code>GetHashCode</code>?</p>
<p>Why is it important to override <code>GetHashCode</code>?</p>
| [
{
"answer_id": 371348,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 12,
"selected": true,
"text": "HashSet<T>"
},
{
"answer_id": 371350,
"author": "Trap",
"author_id": 7839,
"author_profile": "htt... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2469/"
] |
371,329 | <p>I've several textboxes. I would like to make the Enter button act as Tab. So that when I will be in one textbox, pressing Enter will move me to the next one. Could you please tell me how to implement this approach without adding any code inside textbox class (no override and so on if possible)?</p>
| [
{
"answer_id": 371351,
"author": "arul",
"author_id": 15409,
"author_profile": "https://Stackoverflow.com/users/15409",
"pm_score": -1,
"selected": false,
"text": "// on enter event handler\nparentForm.GetNextControl().Focus();\n"
},
{
"answer_id": 371362,
"author": "JFV",
... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38940/"
] |
371,333 | <p>What is the Ruby idiomatic way for retrieving a single character from a string as a one-character string? There is the <code>str[n]</code> method of course, but (as of Ruby 1.8) it returns a character code as a fixnum, not a string. How do you get to a single-character string?</p>
| [
{
"answer_id": 371341,
"author": "Thiago Arrais",
"author_id": 17801,
"author_profile": "https://Stackoverflow.com/users/17801",
"pm_score": 0,
"selected": false,
"text": "'abc'[1].chr # => \"b\"\n"
},
{
"answer_id": 371342,
"author": "Thiago Arrais",
"author_id": 17801,
... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17801/"
] |
371,337 | <p>An image set as the background of a DIV is displayed in IE, but not in Firefox.</p>
<p>CSS example:</p>
<pre><code>div.something {
background:transparent url(../images/table_column.jpg) repeat scroll 0 0;
}
</code></pre>
<p>(The issue is described in many places but haven't seen any conclusive explanation or fix.)</p>
| [
{
"answer_id": 371367,
"author": "Kablam",
"author_id": 42389,
"author_profile": "https://Stackoverflow.com/users/42389",
"pm_score": 0,
"selected": false,
"text": "div.something {\nbackground: transparent url(../images/table_column.jpg);\n}\n"
},
{
"answer_id": 371368,
"auth... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46665/"
] |
371,371 | <p>I'd like a C library that can serialize my data structures to disk, and then load them again later. It should accept arbitrarily nested structures, possibly with circular references.</p>
<p>I presume that this tool would need a configuration file describing my data structures. The library is allowed to use code generation, although I'm fairly sure it's possible to do this without it. </p>
<p>Note I'm not interested in data portability. I'd like to use it as a cache, so I can rely on the environment not changing.</p>
<p>Thanks.</p>
<hr>
<p><em>Results</em></p>
<p>Someone suggested <a href="http://tpl.sourceforge.net/" rel="noreferrer">Tpl</a> which is an awesome library, but I believe that it does not do arbitrary object graphs, such as a tree of Nodes that each contain two other Nodes.</p>
<p>Another candidate is <a href="http://www.enlightenment.org/p.php?p=about/efl/eet&l=en" rel="noreferrer">Eet</a>, which is a project of the Enlightenment window manager. Looks interesting but, again, seems not to have the ability to serialize nested structures.</p>
| [
{
"answer_id": 372113,
"author": "dmckee --- ex-moderator kitten",
"author_id": 2509,
"author_profile": "https://Stackoverflow.com/users/2509",
"pm_score": 3,
"selected": false,
"text": "typedef"
},
{
"answer_id": 15064199,
"author": "Amith Chinthaka",
"author_id": 210680... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11951/"
] |
371,372 | <p>I am using ruby on rails with a MySQL backend. I have a table called notes and here is the migration I use to create it:</p>
<pre><code>def self.up
create_table(:notes, :options => 'ENGINE=MyISAM') do |t|
t.string :title
t.text :body
t.timestamps
end
execute "alter table notes ADD FULLTEXT(title, body)"
end
</code></pre>
<p>I want to do full text searches on the title and body fields. The problem is that the full text searches always come back empty. For example if I add this row into the database: <code>Title: test, Body: test</code>. Then I run this query <code>SELECT * FROM notes WHERE MATCH(title, body) AGAINST('test')</code>. It returns a nil set. Can anybody tell me what I am doing wrong and how to get full text search working?</p>
| [
{
"answer_id": 371408,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 4,
"selected": true,
"text": "SELECT * FROM notes WHERE MATCH(title, body) AGAINST('test' IN BOOLEAN MODE)\n"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/371372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5004/"
] |
371,378 | <p>Working with VS.NET 2008, output type Class Library, Target Framework .NET 2.0</p>
<p>I've come up with a simplified scenario to ask this question.</p>
<p>I have a <code>Button</code> user control, its a simple panel with a single big button on it.</p>
<p>I want to create a <code>RedButton</code> control that extends <code>Button</code>, and similarly, a <code>GreenButton</code>.<br/>e.g. <code>Class RedButton : Button</code></p>
<p>Ideally, when I open up <code>RedButton</code>'s designer I will see the button that I created in <code>Button</code> and be able to modify it, for example make it Red, or change font, etc.</p>
<p>I've tried to do this once, but when I open up the <code>RedButton</code>'s designer I just get a bunch of errors. </p>
<p>In this case, doing all this work programatically isn't an option for us, as in the real case this would be a pain.</p>
<p>Could someone shed some light on this?
Thanks Very Much.</p>
| [
{
"answer_id": 371459,
"author": "Jacob Adams",
"author_id": 32518,
"author_profile": "https://Stackoverflow.com/users/32518",
"pm_score": 0,
"selected": false,
"text": "btnTheButton.BackGround=Color.Red; \n"
},
{
"answer_id": 6429536,
"author": "AndyClaw",
"author_id": 5... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
371,384 | <p>What is the best way to print stuff from c#/.net?</p>
<p>The question is in regard to single pages as well as to reports containing lots of pages. </p>
<p>It would be great to get a list of the most common printing libs containing the main features and gotchas of each of them.</p>
<p>[Update] for standard windows clients (or servers), not for web apps, please.</p>
| [
{
"answer_id": 371399,
"author": "Stephen Wrighton",
"author_id": 7516,
"author_profile": "https://Stackoverflow.com/users/7516",
"pm_score": 4,
"selected": true,
"text": "Sub MyMethod()\n Dim x as New PrintDocument\n AddHandler x.PrintPage, AddressOf printDoc_PrintPage\n x.P... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7021/"
] |
371,386 | <p>Having an odd problems with ASP MVC deployed on IIS6 (Windows 2003). I've simplified the controller code to the below;</p>
<pre><code><AcceptVerbs(HttpVerbs.Get)> _
Public Function CloseBatches() As ActionResult
ViewData("Title") = "Close Batches"
ViewData("Message") = Session("Message")
Return View()
End Function
<AcceptVerbs(HttpVerbs.Post)> _
Public Function CloseBatches(ByVal RequestId As String) As ActionResult
Session("Message") = "Yadda yadda blah"
Return RedirectToAction("CloseBatches")
End Function
</code></pre>
<p>The controller did originally do more, of course, but stripped it to this to try to troubleshoot. The page has the basic ViewPage html (master page reference, etc) and then;</p>
<pre><code><p><%=ViewData("Message")%></p>
<%Using Html.BeginForm("CloseBatches", "Home", New With {.RequestId = "Close"})%>
<input type="submit" id="Close" value="Close"/>
<%End Using%>
</code></pre>
<p>As you can see I'm trying to go with the Post-Redirect-Display pattern which seems to be the way to go at the moment. The trouble is the when you click the button the message doesn't appear, no matter how many times you click the button. However, if you do a refresh/F5 the text does appear - then refresh again and it disappears - refresh again and it appears - repeat!</p>
<p>I've had breakpoints on both controller functions and it hits them at the correct points, I've stepped through the code and no errors are happening so the ViewData should be populated, but the page just doesn't always show it!</p>
<p>Tested with IE7 and FF3 - the latter seems a bit more intermittent in that it does occasionally work!</p>
<p>Any ideas? Something obvious I'm missing? Could some weird caching be going on?</p>
<p>Thanks.</p>
| [
{
"answer_id": 371433,
"author": "Craig Stuntz",
"author_id": 7714,
"author_profile": "https://Stackoverflow.com/users/7714",
"pm_score": 2,
"selected": false,
"text": "<AcceptVerbs(HttpVerbs.Get)> _\nPublic Function CloseBatches() As ActionResult\n ViewData(\"Title\") = \"Close Batch... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
371,404 | <p>I have an Access 2003 file that contains 200 queries, and I want to print out their representation in SQL. I can use Design View to look at each query and cut and paste it to a file, but that's tedious. Also, I may have to do this again on other Access files, so I definitely want to write a program to do it.</p>
<p>Where are queries stored an Access db? I can't find anything saying how to get at them. I'm unfamiliar with Access, so I'd appreciate any pointers. Thanks!</p>
| [
{
"answer_id": 371811,
"author": "Mark Bell",
"author_id": 43140,
"author_profile": "https://Stackoverflow.com/users/43140",
"pm_score": 4,
"selected": true,
"text": "OleDbConnection conn = new OleDbConnection(connectionString);\nconn.Open();\n\nDataTable queries = conn.GetOleDbSchemaTab... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1121861/"
] |
371,417 | <p>I'm working on mapping two objects in .NET. </p>
<p>I would like to be able to print the items in the properties list from the Object Browser window in Visual Studio 2008. Is there a way to print that information out to the console?</p>
<p>If that is not possible, what is a good method to print a general definition of a class (property names, method names)?</p>
| [
{
"answer_id": 371494,
"author": "R. Martinho Fernandes",
"author_id": 46642,
"author_profile": "https://Stackoverflow.com/users/46642",
"pm_score": 2,
"selected": true,
"text": "System.Reflection"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/371417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/283/"
] |
371,418 | <p>I've recently found out about protocol buffers and was wondering if they could be applied to my specific problem.</p>
<p>Basically I have some CSV data that I need to convert to a more compact format for storage as some of the files are several gig. </p>
<p>Each field in the CSV has a header, and there are only two types, strings and decimals (because sometimes there are alot of significant digits and I need to handle all numbers the same way). But each file will have different column names for each field.</p>
<p>As well as capturing the original CSV data I need to be able to add extra information to the file before saving. And I was hoping to make this future proof by handling different file versions.</p>
<p>So, is it possible to use protocol buffers to capture a random number of randomly named columns of data, like a CSV file?</p>
| [
{
"answer_id": 371508,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "message CsvFile {\n repeated CsvHeader header = 1;\n repeated CsvRow row = 2;\n}\n\nmessage CsvHeader {\n requir... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371418",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3820/"
] |
371,419 | <p>I have a function that expects real numbers (either integers or floats) as its input, and I'm trying to validate this input before doing mathematical operations on it.</p>
<p>My first instinct is to cast inputs as floats from within a try-except block.</p>
<pre><code>try:
myinput = float(input)
except:
raise ValueError("input is not a well-formed number")
</code></pre>
<p>I could also call <code>isinstance(mydata, (float, int, long) )</code> but the list of "all these could be numbers" seems a bit inelegant to me.</p>
<p>What's the most pythonic way of going about it? Is there another option I overlooked?</p>
| [
{
"answer_id": 371436,
"author": "Mapad",
"author_id": 28165,
"author_profile": "https://Stackoverflow.com/users/28165",
"pm_score": 2,
"selected": false,
"text": "assert"
},
{
"answer_id": 371573,
"author": "Brian",
"author_id": 9493,
"author_profile": "https://Stack... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8027/"
] |
371,422 | <p>I'm looking to build a query that will use the non-clustered indexing plan on a street address field that is built with a non-clustered index. The problem I'm having is that if I'm searching for a street address I will most likely be using the 'like' eval function. I'm thinking that using this function will cause a table scan instead of using the index. How would I go about writing one in this case? Is it just pointless to put a non-clustered index on an address3 field? Thanks in advance.</p>
| [
{
"answer_id": 371447,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 1,
"selected": false,
"text": "Address LIKE 'Blah%'"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/371422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1491425/"
] |
371,426 | <p>When running a web application project, at seemingly random times a page may fail with a CS0433 error: type exists in multiple DLL's. The DLL's are all generated DLL's residing in the "Temporary ASP.NET Files" directory.</p>
| [
{
"answer_id": 714320,
"author": "Mike Powell",
"author_id": 205,
"author_profile": "https://Stackoverflow.com/users/205",
"pm_score": 2,
"selected": false,
"text": "compilation batch=\"false\""
},
{
"answer_id": 10241054,
"author": "Amrinder Singh",
"author_id": 1345731,... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6902/"
] |
371,439 | <p>Normally when you update an object in linq2sql you get the object from a datacontext and use the same datacontext to save the object, right?</p>
<p>What's the best way to update a object that hasn't been retreived by that datacontext that you use to perform the save operation, i.e. I'm using flourinefx to pass data between flex and asp.net and when object return from the client to be saved I don't know how to save the object?</p>
<pre><code> public static void Save(Client client)
{
CompanyDataContext db = new CompanyDataContext();
Validate(client);
if(client.Id.Equals(Guid.Empty))
{
//Create (right?):
client.Id = Guid.NewGuid();
db.Clients.InsertOnSubmit(client);
db.SubmitChanges();
}
else
{
//Update:
OffertaDataContext db = new OffertaDataContext();
db.Clients.????
}
}
</code></pre>
<p>Update: different approaches to use Attach doens't work in this case. So I guess a reflection based approach is required.</p>
| [
{
"answer_id": 371493,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": true,
"text": "ctx.Customers.Attach(customer); // optional bool to treat as modified\n"
},
{
"answer_id": 725967,
"author... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40939/"
] |
371,445 | <p>We have followed the approach below to get the data from multiple results using LINQ To SQL</p>
<pre><code>CREATE PROCEDURE dbo.GetPostByID
(
@PostID int
)
AS
SELECT *
FROM Posts AS p
WHERE p.PostID = @PostID
SELECT c.*
FROM Categories AS c
JOIN PostCategories AS pc
ON (pc.CategoryID = c.CategoryID)
WHERE pc.PostID = @PostID
</code></pre>
<p>The calling method in the class the inherits from DataContext should look like:</p>
<pre><code>[Database(Name = "Blog")]
public class BlogContext : DataContext
{
...
[Function(Name = "dbo.GetPostByID")]
[ResultType(typeof(Post))]
[ResultType(typeof(Category))]
public IMultipleResults GetPostByID(int postID)
{
IExecuteResult result =
this.ExecuteMethodCall(this,
((MethodInfo)(MethodInfo.GetCurrentMethod())),
postID);
return (IMultipleResults)(result.ReturnValue);
}
}
</code></pre>
<p>Notice that the method is decorated not only with the Function attribute that maps to the stored procedure name, but also with the ReturnType attributes with the types of the result sets that the stored procedure returns. Additionally, the method returns an untyped interface of IMultipleResults:</p>
<pre><code>public interface IMultipleResults : IFunctionResult, IDisposable
{
IEnumerable<TElement> GetResult<TElement>();
}
</code></pre>
<p>so the program can use this interface in order to retrieve the results:</p>
<pre><code>BlogContext ctx = new BlogContext(...);
IMultipleResults results = ctx.GetPostByID(...);
IEnumerable<Post> posts = results.GetResult<Post>();
IEnumerable<Category> categories = results.GetResult<Category>();
</code></pre>
<p>In the above stored procedures we had two select queries
1. Select query without join
2. Select query with Join</p>
<p>But in the above second select query the data which is displayed is from one of the table i.e. from Categories table. But we have used join and want to display the data table with the results from both the tables i.e. from Categories as well as PostCategories.</p>
<ol>
<li>Please if anybody can let me know how to achieve this using LINQ to SQL</li>
<li>What is the performance trade-off if we use the above approach vis-à-vis implement the above approach with simple SQL </li>
</ol>
| [
{
"answer_id": 460222,
"author": "Pure.Krome",
"author_id": 30674,
"author_profile": "https://Stackoverflow.com/users/30674",
"pm_score": 3,
"selected": false,
"text": "IEnumerable<Post> posts;\nIEnumerable<Category> categories;\n\nusing (BlogContext ctx = new BlogContext(...))\n{\n c... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
371,455 | <p>I have a c# class which uses the WindowsIdentity namespace to return details of the current Active Directory user. This is accessible through a web part on SPS and sure enough returns the desired record values specific to that user. </p>
<p>I have a classic ASP application which I would like to have inherit this functionality. After wrapping it up as a COM and registering it to the server, I created a Classic ASP page from which to call and display the details to the browser window.</p>
<p>My problem is that when this page is accessed from an authenticated user on a client machine the only user details it displays is that of the local machine.</p>
<p>How do I therefore alter my code so I can display the details of the user accessing the page from a client machine?</p>
| [
{
"answer_id": 460222,
"author": "Pure.Krome",
"author_id": 30674,
"author_profile": "https://Stackoverflow.com/users/30674",
"pm_score": 3,
"selected": false,
"text": "IEnumerable<Post> posts;\nIEnumerable<Category> categories;\n\nusing (BlogContext ctx = new BlogContext(...))\n{\n c... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
371,464 | <p>I have a non-visual component which manages other visual controls. </p>
<p>I need to have a reference to the form that the component is operating on, but i don't know how to get it.</p>
<p>I am unsure of adding a constructor with the parent specified as control, as i want the component to work by just being dropped into the designer.</p>
<p>The other thought i had was to have a Property of parent as a control, with the default value as 'Me'</p>
<p>any suggestions would be great</p>
<p><strong>Edit:</strong></p>
<p>To clarify, this is a <strong>component</strong>, not a <strong>control</strong>, see here :<a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.component.aspx" rel="noreferrer">ComponentModel.Component</a></p>
| [
{
"answer_id": 371559,
"author": "Rob Prouse",
"author_id": 30827,
"author_profile": "https://Stackoverflow.com/users/30827",
"pm_score": 3,
"selected": false,
"text": "public Form ParentForm\n{\n get { return GetParentForm( this.Parent ); }\n}\n\nprivate Form GetParentForm( Control p... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1500/"
] |
371,468 | <p>I'm using jQuery UI's draggable and droppable libraries in a simple ASP.NET proof of concept application. This page uses the ASP.NET AJAX UpdatePanel to do partial page updates. The page allows a user to drop an item into a trashcan div, which will invoke a postback that deletes a record from the database, then rebinds the list (and other controls) that the item was drug from. All of these elements (the draggable items and the trashcan div) are inside an ASP.NET UpdatePanel.</p>
<p>Here is the dragging and dropping initialization script:</p>
<pre><code> function initDragging()
{
$(".person").draggable({helper:'clone'});
$("#trashcan").droppable({
accept: '.person',
tolerance: 'pointer',
hoverClass: 'trashcan-hover',
activeClass: 'trashcan-active',
drop: onTrashCanned
});
}
$(document).ready(function(){
initDragging();
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function()
{
initDragging();
});
});
function onTrashCanned(e,ui)
{
var id = $('input[id$=hidID]', ui.draggable).val();
if (id != undefined)
{
$('#hidTrashcanID').val(id);
__doPostBack('btnTrashcan','');
}
}
</code></pre>
<p>When the page posts back, partially updating the UpdatePanel's content, I rebind the draggables and droppables. When I then grab a draggable with my cursor, I get an "htmlfile: Unspecified error." exception. I can resolve this problem in the jQuery library by replacing <code>elem.offsetParent</code> with calls to this function that I wrote:</p>
<pre><code>function IESafeOffsetParent(elem)
{
try
{
return elem.offsetParent;
}
catch(e)
{
return document.body;
}
}
</code></pre>
<p>I also have to avoid calls to elem.getBoundingClientRect() as it throws the same error. For those interested, I only had to make these changes in the <code>jQuery.fn.offset</code> function in the <a href="http://plugins.jquery.com/project/dimensions" rel="nofollow noreferrer">Dimensions Plugin</a>.</p>
<p>My questions are: </p>
<ul>
<li>Although this works, are there better ways (cleaner; better performance; without having to modify the jQuery library) to solve this problem?</li>
<li>If not, what's the best way to manage keeping my changes in sync when I update the jQuery libraries in the future? For, example can I extend the library somewhere other than just inline in the files that I download from the jQuery website.</li>
</ul>
<p><b>Update:</b></p>
<p>@some It's not publicly accessible, but I will see if SO will let me post the relevant code into this answer. Just create an ASP.NET Web Application (name it <b>DragAndDrop</b>) and create these files. Don't forget to set Complex.aspx as your start page. You'll also need to download the <a href="http://ui.jquery.com/download_builder/" rel="nofollow noreferrer">jQuery UI drag and drop plug in</a> as well as <a href="http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.2.6.js" rel="nofollow noreferrer">jQuery core</a></p>
<p><b>Complex.aspx</b></p>
<pre><code><%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Complex.aspx.cs" Inherits="DragAndDrop.Complex" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script src="jquery-1.2.6.min.js" type="text/javascript"></script>
<script src="jquery-ui-personalized-1.5.3.min.js" type="text/javascript"></script>
<script type="text/javascript">
function initDragging()
{
$(".person").draggable({helper:'clone'});
$("#trashcan").droppable({
accept: '.person',
tolerance: 'pointer',
hoverClass: 'trashcan-hover',
activeClass: 'trashcan-active',
drop: onTrashCanned
});
}
$(document).ready(function(){
initDragging();
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function()
{
initDragging();
});
});
function onTrashCanned(e,ui)
{
var id = $('input[id$=hidID]', ui.draggable).val();
if (id != undefined)
{
$('#hidTrashcanID').val(id);
__doPostBack('btnTrashcan','');
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:UpdatePanel ID="updContent" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:LinkButton ID="btnTrashcan" Text="trashcan" runat="server" CommandName="trashcan"
onclick="btnTrashcan_Click" style="display:none;"></asp:LinkButton>
<input type="hidden" id="hidTrashcanID" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Save" onclick="Button1_Click" />
<table>
<tr>
<td style="width: 300px;">
<asp:DataList ID="lstAllPeople" runat="server" DataSourceID="odsAllPeople"
DataKeyField="ID">
<ItemTemplate>
<div class="person">
<asp:HiddenField ID="hidID" runat="server" Value='<%# Eval("ID") %>' />
Name:
<asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>' />
<br />
<br />
</div>
</ItemTemplate>
</asp:DataList>
<asp:ObjectDataSource ID="odsAllPeople" runat="server" SelectMethod="SelectAllPeople"
TypeName="DragAndDrop.Complex+DataAccess"
onselecting="odsAllPeople_Selecting">
<SelectParameters>
<asp:Parameter Name="filter" Type="Object" />
</SelectParameters>
</asp:ObjectDataSource>
</td>
<td style="width: 300px;vertical-align:top;">
<div id="trashcan">
drop here to delete
</div>
<asp:DataList ID="lstPeopleToDelete" runat="server"
DataSourceID="odsPeopleToDelete">
<ItemTemplate>
ID:
<asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
<br />
Name:
<asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
<br />
<br />
</ItemTemplate>
</asp:DataList>
<asp:ObjectDataSource ID="odsPeopleToDelete" runat="server"
onselecting="odsPeopleToDelete_Selecting" SelectMethod="GetDeleteList"
TypeName="DragAndDrop.Complex+DataAccess">
<SelectParameters>
<asp:Parameter Name="list" Type="Object" />
</SelectParameters>
</asp:ObjectDataSource>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
</code></pre>
<p><b>Complex.aspx.cs</b></p>
<pre><code>namespace DragAndDrop
{
public partial class Complex : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected List<int> DeleteList
{
get
{
if (ViewState["dl"] == null)
{
List<int> dl = new List<int>();
ViewState["dl"] = dl;
return dl;
}
else
{
return (List<int>)ViewState["dl"];
}
}
}
public class DataAccess
{
public IEnumerable<Person> SelectAllPeople(IEnumerable<int> filter)
{
return Database.SelectAll().Where(p => !filter.Contains(p.ID));
}
public IEnumerable<Person> GetDeleteList(IEnumerable<int> list)
{
return Database.SelectAll().Where(p => list.Contains(p.ID));
}
}
protected void odsAllPeople_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
{
e.InputParameters["filter"] = this.DeleteList;
}
protected void odsPeopleToDelete_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
{
e.InputParameters["list"] = this.DeleteList;
}
protected void Button1_Click(object sender, EventArgs e)
{
foreach (int id in DeleteList)
{
Database.DeletePerson(id);
}
DeleteList.Clear();
lstAllPeople.DataBind();
lstPeopleToDelete.DataBind();
}
protected void btnTrashcan_Click(object sender, EventArgs e)
{
int id = int.Parse(hidTrashcanID.Value);
DeleteList.Add(id);
lstAllPeople.DataBind();
lstPeopleToDelete.DataBind();
}
}
}
</code></pre>
<p><b>Database.cs</b></p>
<pre><code>namespace DragAndDrop
{
public static class Database
{
private static Dictionary<int, Person> _people = new Dictionary<int,Person>();
static Database()
{
Person[] people = new Person[]
{
new Person("Chad")
, new Person("Carrie")
, new Person("Richard")
, new Person("Ron")
};
foreach (Person p in people)
{
_people.Add(p.ID, p);
}
}
public static IEnumerable<Person> SelectAll()
{
return _people.Values;
}
public static void DeletePerson(int id)
{
if (_people.ContainsKey(id))
{
_people.Remove(id);
}
}
public static Person CreatePerson(string name)
{
Person p = new Person(name);
_people.Add(p.ID, p);
return p;
}
}
public class Person
{
private static int _curID = 1;
public int ID { get; set; }
public string Name { get; set; }
public Person()
{
ID = _curID++;
}
public Person(string name)
: this()
{
Name = name;
}
}
}
</code></pre>
| [
{
"answer_id": 516534,
"author": "CodeChef",
"author_id": 21786,
"author_profile": "https://Stackoverflow.com/users/21786",
"pm_score": 4,
"selected": true,
"text": "function IESafeOffsetParent(elem)\n{\n try\n {\n return elem.offsetParent;\n }\n catch(e)\n { ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21786/"
] |
371,471 | <p>I am trying to get some <code>JavaScript</code> to programmatically adjust a HTML <code>img</code> tag's width to display various sized images correctly.</p>
<p>I have a fixed width <code>img</code> tag at <code>800px</code> to display an image, this is the max width.</p>
<p>If the image is wider then <code>800px</code> I want to display it at <code>800px</code> wide;</p>
<p>If the image is less than <code>800px</code> wide I want to preserve its width to avoid stretching it.</p>
<p>I use this html/javacript code to get a partial solution:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function resize_image(id) {
var img = document.getElementById(id);
var normal_width = img.width;
img.removeAttribute("width");
var real_width = img.width;
if (real_width < normal_width) {
img.width = real_width;
} else {
img.width = normal_width;
}
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><img id="myimage" onload="resize_image(self.id);" src="https://via.placeholder.com/350x150" width="800" /></code></pre>
</div>
</div>
</p>
<p>The above code seems to work on all browsers I have tested except <code>Safari</code> (images don't display unless you refresh the page).</p>
<p>I know I can use CSS <code>max-width</code> but that wont work on <code>IE</code> < 7 which is a show stopper.</p>
<p>How can I get this working for all browsers? Many thanks in advance.</p>
| [
{
"answer_id": 371504,
"author": "bezmax",
"author_id": 43677,
"author_profile": "https://Stackoverflow.com/users/43677",
"pm_score": 2,
"selected": false,
"text": ".dynamic_img {\n width: expression(document.body.clientWidth <= 800? \"auto\" : \"800px\");\n max-width: 800px; //For... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14260/"
] |
371,490 | <p>Does anyone know how to turn this string: "Smith, John R"<br>
Into this string: "jsmith" ?</p>
<p>I need to lowercase everything with lower()<br>
Find where the comma is and track it's integer location value<br>
Get the first character after that comma and put it in front of the string<br>
Then get the entire last name and stick it after the first initial.<br><br>
Sidenote - instr() function is not compatible with my version<br><br>
Thanks for any help!</p>
| [
{
"answer_id": 386658,
"author": "Gabe",
"author_id": 48143,
"author_profile": "https://Stackoverflow.com/users/48143",
"pm_score": 1,
"selected": false,
"text": "with name_list as\n (select ' Parisi, Kenneth R' name from dual)\nselect name\n -- There may be a space after the com... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42229/"
] |
371,497 | <p>Is there any way (in Javascript) to download a remote website (i.e. like with Curl), read it into a string variable and further process it?</p>
| [
{
"answer_id": 371524,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 3,
"selected": false,
"text": " var xhReq = createXMLHttpRequest();\n xhReq.open(\"GET\", \"page.html\", true);\n xhReq.onreadystatechange = onResp... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371497",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
371,503 | <p>Why is ++i is l-value and i++ not?</p>
| [
{
"answer_id": 371533,
"author": "Renaud Bompuis",
"author_id": 3811,
"author_profile": "https://Stackoverflow.com/users/3811",
"pm_score": 2,
"selected": false,
"text": "C"
},
{
"answer_id": 371540,
"author": "LeppyR64",
"author_id": 16592,
"author_profile": "https:/... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22076/"
] |
371,513 | <p>We have a database that persist our metadata and data.</p>
<p>Our metadata is produced buy a dedicated team, using a Web application on the development server, and is a critical part of our application.</p>
<p>Then the customer generates data according to this metadata.</p>
<p>We already version the database schema, and all schema change. The next step is to put our metadata under version control.</p>
Naive solution
<p>A naive solution would be to dump all the metadata, and commit it under version control before generating the corresponding packages. Since it's a dump, it can easily be restored. But there is probably a better way, like an incremental solution (only version diffs).</p>
Text dumps
<p>Another solution is to export all metadata tables in text format (like XML), and then version those text files. But then you have to find a way to reimport them.</p>
<p>So, is your metadata under version control? Why? How?</p>
| [
{
"answer_id": 371533,
"author": "Renaud Bompuis",
"author_id": 3811,
"author_profile": "https://Stackoverflow.com/users/3811",
"pm_score": 2,
"selected": false,
"text": "C"
},
{
"answer_id": 371540,
"author": "LeppyR64",
"author_id": 16592,
"author_profile": "https:/... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2797/"
] |
371,534 | <p>I'm running into an issue with an ASP.NET 2.0 application. Our network folks just upped our security, and now I get the floowing error whenever I try to access the app:</p>
<blockquote>
<p>"This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms."</p>
</blockquote>
<p>I've done a little research, and it sounds like ASP.NET uses the RijndaelManaged AES encryption algorithm to encrypt the ViewState of pages... and RijndaelManaged is on the list of algorithms that aren't FIPS compliant. We're certainly not explicitly calling <em>any</em> encryption algorithm... much less anything on the non-compliant list. </p>
<p>This ViewState business makes sense to me, I guess. The thing I can't muddle out, though, is what to do about it. I've found a <a href="http://support.microsoft.com/kb/911722" rel="noreferrer">KB article</a> that suggests using a web.config setting to specify a different algorithm... but either that didn't stick, or that algorithm isn't up to snuff, either.</p>
<p>So: </p>
<p>1) Is the RijndaelManaged / ViewState thing actually the problem? Or am I barking up the wrong tree?</p>
<p>2) How to I specify what algorithm to use instead of RijndaelManaged? I've got a list of algorithms that are and aren't compliant; I'm just not sure where to plug that information in.</p>
<p>Thanks!</p>
<p>Richard</p>
| [
{
"answer_id": 380866,
"author": "kay.herzam",
"author_id": 47093,
"author_profile": "https://Stackoverflow.com/users/47093",
"pm_score": 2,
"selected": false,
"text": "<machineKey \n validationKey=\"AutoGenerate,IsolateApps\"\n decryptionKey=\"AutoGenerate,IsolateApps\"\n validation=... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371534",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46692/"
] |
371,546 | <pre><code>select Table1.colID, Table1.colName,
(select * from Table2 where Table2.colID = Table1.colID) as NestedRows
from Table1
</code></pre>
<p>The above query gives you this error:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used..... </p>
<p>Can anybody explain why this limitation exist? </p>
<p>I had this idea that this kind of multidimentional queries would be nice for building OO objects directly from the database with 1 query</p>
<p>EDIT:</p>
<p>This question is pretty theoretical. To solve this practical I would use a join or simply done 2 queries, but I wondered if there was anything stopping you from returning a column as a table type (In sql server 2008 you can create table types).</p>
<p>Say you have corrensponding classes in code, think Linq2Sql</p>
<pre><code>public class Table1
{
public int colID,
public string colName,
public List<Table2> table2s;
}
</code></pre>
<p>I would like to be able to fill instances of this class directly with 1 query</p>
| [
{
"answer_id": 371575,
"author": "DCNYAM",
"author_id": 30419,
"author_profile": "https://Stackoverflow.com/users/30419",
"pm_score": 0,
"selected": false,
"text": "SELECT tab1.colID, tab1.colName, tab2.Column1, tab2.column2\nFROM dbo.Table1 AS tab1\n INNER JOIN dbo.Table2 AS tab2\n ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29519/"
] |
371,551 | <p>When I try to build my projects in Visual Studio 2008, web sites won't build anymore, they hang on this stage: </p>
<pre><code>------ Build started: Project: C:\...\Web\, Configuration: Debug Any CPU ------
Validating Web Site
Building directory '/Web/Admin/Secure/'.
Building directory '/Web/Admin/'.
Building directory '/Web/Students/'.
Building directory '/Web/'.
Validation Complete
</code></pre>
<p>And I have to cancel it as it doesn't complete even after leaving it for an hour. Does anyone have any ideas on what's going on? Class libraries build fine.</p>
| [
{
"answer_id": 371655,
"author": "NikolaiDante",
"author_id": 39643,
"author_profile": "https://Stackoverflow.com/users/39643",
"pm_score": 3,
"selected": false,
"text": "C:\\WINDOWS\\Microsoft.NET\\Framework\\<Framework Version>\\Temporary ASP.NET Files\n"
},
{
"answer_id": 1195... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33137/"
] |
371,554 | <p>I have the following code:</p>
<pre><code>if ($_POST['submit'] == "Next") {
foreach($_POST['info'] as $key => $value) {
echo $value;
}
}
</code></pre>
<p>How do I get the foreach function to start from the 2nd key in the array?</p>
| [
{
"answer_id": 371560,
"author": "Irmantas",
"author_id": 43182,
"author_profile": "https://Stackoverflow.com/users/43182",
"pm_score": 2,
"selected": false,
"text": "if ($key == 0) //or whatever\n continue;\n"
},
{
"answer_id": 371563,
"author": "Tom Haigh",
"author_id... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37667/"
] |
371,555 | <p>My team is developing a large java application which extensively queries a MySQL database (in different classes and modules).
I'd like to known if there is a pattern that allows me to be notified at compile time if there are queries that refer to a wrong table structure (for instance if I remove or add a field on a table and the query string refers to it), in order to prevent runtime errors.
This should work also for JOIN queries.</p>
| [
{
"answer_id": 532425,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "select count(*) from test where name = null\n"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/371555",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17934/"
] |
371,571 | <p>I'm running a simple batch file which is generated by a vbscript to delete individual files, however when I execute it, it is deleting entire subdirectories. Anyone have any ideas on this? Below is the batch file. </p>
<pre><code>rem 2008-12-15D:\DP-Production\Administrative\BUSINESS\FileLink
del D:\DP-Production\Administrative\BUSINESS\FileLink\.-1003067260 /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\.-997208891 /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\.-998224323 /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._proofing.pdf /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Sample1.pdf /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Shortcut (2) to PDFProofs.lnk /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Shortcut to Art.lnk /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Shortcut to Filelink on 'Admin-srv' (I).lnk /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Shortcut to LeadGen program.lnk /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Shortcut to Mail.lnk /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Shortcut to Maintained on 'Data Pro (Pmi41)' (H).lnk /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Shortcut to Openjobs on 'SRV-srv02' (J).lnk /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._SHRP.pdf /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._skyphone2.bmp /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Smokey Bones Solo_Mailer.pdf /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._steakhouseback.pdf /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._steakhousefront.pdf /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Summercamp.pdf /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._taxsampleback.pdf /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._taxsamplefront.pdf /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Temporary Items /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Beta.pdf /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Trurdy.pdf /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Trash /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._trishwenrick.pdf /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Tulane.pdf /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._valpak_price.mdb /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._WasteM.jpg /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\weekly_deletions.vbs /q/f
rem 2008-12-15D:\DP-Production\Administrative\BUSINESS\FileLink\Art
del D:\DP-Production\Administrative\BUSINESS\FileLink\Art\._+.pdf /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Art\._0805_NJGolf 12-44-24.pdf /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Art\._806857.eps /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Art\._ADPLogo.JPG /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Art\._FranchiseLtr_MM.doc /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Art\._REPAIR-SMA.doc /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Art\._Safety.pdf /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Art\._Summer 2008 Donor V1.pdf /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Art\desktop.ini /q/f
rem 2008-12-15D:\DP-Production\Administrative\BUSINESS\FileLink\Mail
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\ BOBBSS LIST COUNT - DRIBOX 2008-06 ejs.msg /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\#7608 GHA MD Mailing.ZIP /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\2008 Adel List.xls /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\2008 mailing-BREAK OUT.xls /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\2008 Password Letter to GM (R).doc /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\2008 RL Mailing.xls /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\2008DLRCRICKPage1.pdf /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\805026.pdf /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\805442_Breakfast.pdf /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\806330_Letter.pdf /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\806778.pdf /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\806785 JONES WORLD VIEW DHL.xls /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\807364-807117.csv /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\8522435_INTDELIVERY.zip /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\8674252_INTDELIVERY.zip /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\8674856_INTDELIVERY.zip /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\8675351_INTDELIVERY.zip /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\8694521_INTDELIVERY.zip /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\8720608_INTDELIVERY.zip /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\8cletoy0903_1.csv /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\8roncar0657.csv /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\8vanhyu0531.zip /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\addressfile0605.xls /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\All Active Employee Address 070808.xls /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\APPA_Mailing_List-FINAL-XLS4.xls /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\Aug 08 Coupon Data.txt /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\BMA.pdf /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\BODYCOPY.doc /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\BOISE JUNE SALON MASTER LIST rev 6-9-08 (6).xls /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\Broward Committe REVISED.xls /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\CAW Tournament Letter (2).doc /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\detroit lasalle delete list.xls /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\CHIROPRACTOR 300.xls /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\CMTFV08204macroed.bak /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\Comm Ltr#2.doc /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\Contact Directory.rtf-MA /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\Copy of Jones Newsletter 0708.xls /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\Copy of MD L-Listing 07_11_08.xls /q/f
</code></pre>
| [
{
"answer_id": 371594,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 3,
"selected": false,
"text": "del D:\\DP-Production\\Administrative\\BUSINESS\\FileLink\\Mail\\ BOBBSS LIST COUNT - DRIBOX 2008-06 ejs.msg /q/\... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18853/"
] |
371,591 | <p>I am trying to get simple jQuery to execute on my Content page with no luck below is what I am trying to do:</p>
<pre><code><asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<script src="../../Scripts/jquery-1.2.6.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
alert("hi");
});
</script>
</asp:Content>
</code></pre>
<p>I have also tried getting the following to work:</p>
<pre><code><asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<script src="../../Scripts/jquery-1.2.6.js" type="text/javascript"></script>
<script type="text/javascript">
function onload()
{
$("#myDiv").css("border", "1px solid green");
}
</script>
<div id="myDive">
Hello
</div>
</asp:Content>
</code></pre>
| [
{
"answer_id": 371603,
"author": "Kieron",
"author_id": 5791,
"author_profile": "https://Stackoverflow.com/users/5791",
"pm_score": 6,
"selected": true,
"text": "<script src=\"<%= Url.Content (\"~/Scripts/jquery-1.2.6.js\") %>\" type=\"text/javascript\"></script>\n"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/371591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3111/"
] |
371,599 | <p>In my app have a window splitted by a QSplitter, and I need to remove an widget. </p>
<p>How can I do that? I can't find useful methods </p>
| [
{
"answer_id": 371649,
"author": "Caleb Huitt - cjhuitt",
"author_id": 9876,
"author_profile": "https://Stackoverflow.com/users/9876",
"pm_score": 2,
"selected": false,
"text": "setParent( NULL )"
},
{
"answer_id": 17196052,
"author": "thrichard",
"author_id": 1506390,
... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39339/"
] |
371,604 | <p>Following on from <a href="https://stackoverflow.com/questions/371418/can-you-represent-csv-data-in-googles-protocol-buffer-format">this</a> question, what would be the best way to represent a System.Decimal object in a Protocol Buffer?</p>
| [
{
"answer_id": 371690,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "message Decimal {\n\n // 96-bit mantissa broken into two chunks\n optional uint64 mantissa_msb = 1;\n optional ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3820/"
] |
371,606 | <p>i am trying to fix a site I am helping a friend with, and in IE it is displaying the navigation bar like it is stacking on top of each other.</p>
<p>Is that a part of the double float bug, I tried adding display:inline, but I still have that problem.</p>
<p>URL: <a href="http://www.flanels.com/RadiantecHOME.html" rel="nofollow noreferrer">http://www.flanels.com/RadiantecHOME.html</a><br>
CSS: <a href="http://www.flanels.com/style.css" rel="nofollow noreferrer">http://www.flanels.com/style.css</a>`</p>
| [
{
"answer_id": 371690,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "message Decimal {\n\n // 96-bit mantissa broken into two chunks\n optional uint64 mantissa_msb = 1;\n optional ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
371,608 | <p>GCC 3.4.5 (MinGW version) produces a warning: parameter has incomplete type for line 2 of the following C code:</p>
<pre><code>struct s;
typedef void (* func_t)(struct s _this);
struct s { func_t method; int dummy_member; };
</code></pre>
<p>Is there a way to fix this (or at least hide the warning) without changing the method argument's signature to (struct s *)?</p>
<p><strong>Note:</strong> <br>
As to why something like this would be useful: I'm currently tinkering with an object-oriented framework; 'method' is an entry in a dispatch table and because of the particular design of the framework, it makes sense to pass '_this' by value and not by reference (as it is usually done)...</p>
| [
{
"answer_id": 371870,
"author": "HUAGHAGUAH",
"author_id": 38809,
"author_profile": "https://Stackoverflow.com/users/38809",
"pm_score": -1,
"selected": false,
"text": "typedef void (*func_t)(void*);\n"
},
{
"answer_id": 371962,
"author": "Adam Rosenfield",
"author_id": ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48015/"
] |
371,637 | <p>I am trying to use the following code, which I have not been able to test yet, because I get the following errors:</p>
<pre><code>#!/usr/bin/perl
use warnings;
use strict;
use Text::Wrap;
use Mail::Box::Manager;
use HTML::Obliterate qw(extirpate_html);
open (MYFILE, '>>data.txt');
binmode(MYFILE, ':encoding(UTF-8)');
my $file = shift || $ENV{MAIL};
my $mgr = Mail::Box::Manager->new(
access => 'r',
);
my $folder = $mgr->open( folder => $file )
or die "$file: Unable to open: $!\n";
for my $msg ( sort { $a->timestamp <=> $b->timestamp } $folder->messages)
{
my $to = join( ', ', map { $_->format } $msg->to );
my $from = join( ', ', map { $_->format } $msg->from );
my $date = localtime( $msg->timestamp );
my $subject = $msg->subject;
my $body = $msg->decoded->string;
if ( $msg->isMultipart ) {
foreach my $part ( $msg->parts ) {
if ( $part->contentType eq 'text/html' ) {
my $nohtml = extirpate_html( $msg );
$body =~ s/^>.*$//msg;
$Text::Wrap::columns=80;
print MYFILE wrap("", "", <<"");
\n
From: $from
To: $to
Date: $date
Subject: $subject
\n
$body
}
else {
$body =~ s/^>.*$//msg;
$Text::Wrap::columns=80;
print MYFILE wrap("", "", <<"");
\n
From: $from
To: $to
Date: $date
Subject: $subject
\n
$body
}
}}
</code></pre>
<p>All the braces seem to match up, so I am unsure what the problem is</p>
<pre><code>syntax error at x.pl line 46, near "else"
(Might be a runaway multi-line << string starting on line 36)
Missing right curly or square bracket at x.pl line 63, at end of line
syntax error at x.pl line 63, at EOF
Execution of x.pl aborted due to compilation errors.
</code></pre>
<p>edit:</p>
<p>it now works, but the html is not striped: instead a few emails with stuff like <BR>> <BR>> interlaced throughout, causing it to be many more pages than it should. Is there a better way to do this</p>
| [
{
"answer_id": 371658,
"author": "Tuminoid",
"author_id": 40657,
"author_profile": "https://Stackoverflow.com/users/40657",
"pm_score": 3,
"selected": true,
"text": "print MYFILE wrap(\"\", \"\", <<\"\");\n"
},
{
"answer_id": 371772,
"author": "Tuminoid",
"author_id": 406... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] |
371,638 | <p>I'm in the design stage for an app which will utilize a REST web service and sort of have a dilemma in as far as using asynchronous vs synchronous vs threading. Here's the scenario.</p>
<p>Say you have three options to drill down into, each one having its own REST-based resource. I can either lazily load each one with a synchronous request, but that'll block the UI and prevent the user from hitting a back navigation button while data is retrieved. This case applies almost anywhere <em>except</em> for when your application requires a login screen. I can't see any reason to use synchronous HTTP requests vs asynchronous because of that reason alone. The only time it makes sense is to have a worker thread make your synchronous request, and notify the main thread when the request is done. This will prevent the block. The question then is bench marking your code and seeing which has more overhead, a threaded synchronous request or an asynchronous request.</p>
<p>The problem with asynchronous requests is you need to either setup a smart notification or delegate system as you can have multiple requests for multiple resources happening at any given time. The other problem with them is if I have a class, say a singleton which is handling all of my data, I can't use asynchronous requests in a getter method. Meaning the following won't go:</p>
<pre><code> - (NSArray *)users {
if(users == nil)
users = do_async_request // NO GOOD
return users;
}
</code></pre>
<p>whereas the following:</p>
<pre><code> - (NSArray *)users {
if(users == nil)
users == do_sync_request // OK.
return users;
}
</code></pre>
<p>You also might have priority. What I mean by priority is if you look at Apple's Mail application on the iPhone, you'll notice they first suck down your entire POP/IMAP tree before making a second request to retrieve the first 2 lines (the default) of your message.</p>
<p>I suppose my question to you experts is this. When are you using asynchronous, synchronous, threads -- and when are you using either async/sync in a thread? What kind of delegation system do you have setup to know what to do when a async request completes? Are you prioritizing your async requests?</p>
<p>There's a gamut of solutions to this all too common problem. It's simple to hack something out. The problem is, I don't want to hack and I want to have something that's simple and easy to maintain.</p>
| [
{
"answer_id": 373906,
"author": "Kendall Helmstetter Gelner",
"author_id": 6330,
"author_profile": "https://Stackoverflow.com/users/6330",
"pm_score": -1,
"selected": false,
"text": "- (NSArray *)users {\n if(users == nil && !didLaunchRequestAlready )\n users = do_async_reque... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40882/"
] |
371,644 | <p>In a mysqli prepared statement, a NULL gets turned into '' (in the case of a string) or 0 (in the case of an integer). I would like to store it as a true NULL. Is there any way of doing this?</p>
| [
{
"answer_id": 371782,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 2,
"selected": false,
"text": "mysqli_stmt::bind_param"
},
{
"answer_id": 1235102,
"author": "Community",
"author_id": -1,
"author_pr... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1902010/"
] |
371,656 | <p>Are there any O/R mappers out there that will automatically create or modify the database schema when you update the business objects? After looking around it seems that most libraries work the other way by creating business object from the database schema.</p>
<p>The reason I'd like to have that capability is that I am planning a product that stores its data in a database on the customer's machine. So I may have to update the database schema when a new version comes out.</p>
<p>Another requirement is that the mapper supports a file based database like SQLite or JET, not only SQL server.</p>
<p>I know XPO from Developer Express has that capability but I was wondering if there are any alternatives out there.</p>
<p>Thanks</p>
| [
{
"answer_id": 374028,
"author": "faulty",
"author_id": 20007,
"author_profile": "https://Stackoverflow.com/users/20007",
"pm_score": 2,
"selected": true,
"text": "namespace MyApps.Migrations\n{\n public class _001_Initial : Migration\n {\n public override void Up()\n ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46703/"
] |
371,702 | <p>I have made some code which exports some details of a journal article to a reference manager called <a href="http://www.endnote.com/enhome.asp" rel="nofollow noreferrer">Endnote</a></p>
<p>The format of which is a list of items like below (an author):</p>
<pre><code>%A Schortgen Frédérique
</code></pre>
<p>Unfortunately, I am having some encoding problems somewhere, as when endnote opens the file, this is what it makes of the above author:</p>
<blockquote>
<p>Schortge Frédérique</p>
</blockquote>
<p>I have frantically tried playing around with the encoding and stuff that I am outputting and I am at a loss, here is the code:</p>
<pre><code> Response.ContentType = _citation.ContentType;
string fileExtension = "";
if (_citation.GetFileExtension() != null)
fileExtension = "." + _citation.GetFileExtension();
Response.AddHeader("content-disposition", "attachment; filename=citation" + fileExtension);
Response.ContentType = _citation.GetFileReferrer();
Response.Charset = "UTF-8";
Response.write(-snip-);
Response.End();
</code></pre>
| [
{
"answer_id": 374287,
"author": "Chris James",
"author_id": 3193,
"author_profile": "https://Stackoverflow.com/users/3193",
"pm_score": 0,
"selected": false,
"text": "Response.Charset = \"ISO-8859-1\"; \nResponse.ContentEncoding = System.Text.Encoding.GetEncoding(28591);\nRes... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3193/"
] |
371,708 | <p>I have two classes that each need an instance of each other to function. Ordinarily if an object needs another object to run, I like to pass it in the constructor. But I can't do that in this case, because one object has to be instantiated before the other, and so therefore the second object does not exist to be passed to the first object's constructor.</p>
<p>I can resolve this by passing the first object to the second object's constructor, then calling a setter on the first object to pass the second object to it, but that seems a little clunky, and I'm wondering if there's a better way:</p>
<pre><code>backend = new Backend();
panel = new Panel(backend);
backend.setPanel();
</code></pre>
<p>I've never put any study into MVC; I suppose I'm dealing with a model here (the Backend), and a view or a controller (the Panel). Any insights here I can gain from MVC?</p>
| [
{
"answer_id": 371768,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 2,
"selected": false,
"text": "backend = new Backend();\npanel = new Panel(backend);\nbackend.setPanel(panel);\n"
},
{
"answer_id": 371779,
... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18103/"
] |
371,716 | <p>When we serialize an enum from C# to SQL Server we use a NCHAR(3) datatype with mnemonic values for each value of the enum.
That way we can easily read a SELECT qry.</p>
<p>How do you save enum to your database?</p>
<p>What datatype do you use?</p>
| [
{
"answer_id": 371748,
"author": "Kev",
"author_id": 419,
"author_profile": "https://Stackoverflow.com/users/419",
"pm_score": 3,
"selected": false,
"text": "public enum ActionType\n{\n Insert = 1,\n Update = 2,\n Delete = 3\n}\n"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/371716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28207/"
] |
371,721 | <p>I have a simple question and wish to hear others' experiences regarding which is the best way to replicate images across multiple hosts.</p>
<p>I have determined that storing images in the database and then using database replication over multiple hosts would result in maximum availability.</p>
<p>The worry I have with the filesystem is the difficulty synchronising the images (e.g I don't want 5 servers all hitting the same server for images!).</p>
<p>Now, the only concerns I have with storing images in the database is the extra queries hitting the database and the extra handling i'd have to put in place in apache if I wanted 'virtual' image links to point to database entries. (e.g AddHandler)</p>
<p>As far as my understanding goes:</p>
<ul>
<li>If you have a script serving up the
images: Each image would require a
database call.</li>
<li>If you display the images inline as
binary data: Which could be done in
a single database call.</li>
<li>To provide external / linkable
images you would have to add a
addHandler for the extension you
wish to 'fake' and point it to your
scripting language (e.g php, asp).</li>
</ul>
<p>I might have missed something, but I'm curious if anyone has any better ideas?</p>
<hr>
<p>Edit:
Tom has suggested using mod_rewrite to save using an AddHandler, I have accepted as a proposed solution to the AddHandler issue; however I don't yet feel like I have a complete solution yet so please, please, keep answering ;)</p>
<p>A few have suggested using lighttpd over Apache. How different are the ISAPI modules for lighttpd?</p>
| [
{
"answer_id": 371806,
"author": "Tom Haigh",
"author_id": 22224,
"author_profile": "https://Stackoverflow.com/users/22224",
"pm_score": 1,
"selected": false,
"text": "$_SERVER['PATH_INFO']"
}
] | 2008/12/16 | [
"https://Stackoverflow.com/questions/371721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41690/"
] |
371,725 | <p>In Pseudo code</p>
<pre><code>If Domain inList(GB,US,ES,FR Then
Print This Html
Else
Print This HTML
EndIf
</code></pre>
| [
{
"answer_id": 371880,
"author": "mtruesdell",
"author_id": 6479,
"author_profile": "https://Stackoverflow.com/users/6479",
"pm_score": 1,
"selected": false,
"text": "<xsl:choose>\n <xsl:when test=\"domain = 'GB' or domain = 'US' or domain = 'ES' or domain = 'FR'\">\n print this html... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/87783/"
] |
371,728 | <p>Every time I create a new excel sheet, I have to go in and change it's cell reference mode to the familiar A1, B1, etc. I can't seem to find a way to permanently set it to A1 style.</p>
<p>Is there a macro I can write or a way to use templates or something, so that I don't have to keep changing the R1C1 setting?</p>
| [
{
"answer_id": 371757,
"author": "Ian G",
"author_id": 31765,
"author_profile": "https://Stackoverflow.com/users/31765",
"pm_score": 4,
"selected": true,
"text": "personal.xls"
},
{
"answer_id": 371765,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile":... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26140/"
] |
371,739 | <p>I want to develop a plug-in that does this:</p>
<p><em>A button, when clicked, opens the new mail window but has a certain phrase in the subject line, for e.g. when I click a button called 'PROJ123', the new mail window opens with the subject line "[PROJ123]"</em></p>
<p>Other functionality it would need:</p>
<ul>
<li>Ability to Create/Update/Delete Buttons as needed</li>
</ul>
<p>What is the best way to do this? </p>
<p>Any and all tips, references, online resources, examples are greatly appreciated!</p>
| [
{
"answer_id": 371971,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 2,
"selected": false,
"text": "Private Sub cmdCommand_Click()\n Dim eml As MailItem\n\n Set eml = Application.CreateItem(olMailItem)\n eml.Subje... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
371,753 | <p>I want to override access to one variable in a class, but return all others normally. How do I accomplish this with <code>__getattribute__</code>?</p>
<p>I tried the following (which should also illustrate what I'm trying to do) but I get a recursion error:</p>
<pre><code>class D(object):
def __init__(self):
self.test=20
self.test2=21
def __getattribute__(self,name):
if name=='test':
return 0.
else:
return self.__dict__[name]
>>> print D().test
0.0
>>> print D().test2
...
RuntimeError: maximum recursion depth exceeded in cmp
</code></pre>
| [
{
"answer_id": 371833,
"author": "Egil",
"author_id": 44606,
"author_profile": "https://Stackoverflow.com/users/44606",
"pm_score": 8,
"selected": true,
"text": "self.__dict__"
},
{
"answer_id": 371844,
"author": "Singletoned",
"author_id": 46715,
"author_profile": "h... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13009/"
] |
371,762 | <p>What exactly is GUID? Why and where I should use it? <br/>
I've seen references to GUID in a lot of places, and in wikipedia,
but it is not very clear telling you where to use it.
If someone could answer this, it would be nice.
Thanks</p>
| [
{
"answer_id": 371868,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 4,
"selected": false,
"text": "com.example.jpackage\n"
},
{
"answer_id": 67889504,
"author": "N Djel Okoye",
"author_id": 4170558,
... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37650/"
] |
371,781 | <p>There are 3 parts to the page. </p>
<ol>
<li><p>Header, which has unknown content at design time as it is populated with text at runtime. All the text must be displayed, no scroll bars.( I think <code>height: 100%</code> does this) </p></li>
<li><p>Content, the content should fill the page below the bottom of the header to the top of the footer. if there is more text in the content that can be shown, then scroll bars should be available. </p></li>
<li><p>Footer. Footer should be <code>25px</code> high and always sit at the bottom of the viewport. </p></li>
</ol>
<p>The window is a popup and it should never have window scroll bars, it can be resized but no scrollbars. The contents scroll bars should be the only one available. </p>
<p>The content area should resize when resizing the window, but the footer stay the same, ie fixed to the bottom. </p>
<p>The widths would all be <code>100%</code></p>
| [
{
"answer_id": 371868,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 4,
"selected": false,
"text": "com.example.jpackage\n"
},
{
"answer_id": 67889504,
"author": "N Djel Okoye",
"author_id": 4170558,
... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46716/"
] |
371,796 | <p>If I'm adding a column via MySQL, I can specify where in the table that column will be using the AFTER modifier. But if I do the add_column via a Rails migration, the column will be created at the end of the table.</p>
<p>Is there any functionality for rails migrations to specify the position of an added column?</p>
| [
{
"answer_id": 371949,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 3,
"selected": false,
"text": "add_column"
},
{
"answer_id": 9946311,
"author": "Tamik Soziev",
"author_id": 429649,
"author_prof... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2177/"
] |
371,807 | <p>I've been looking for a component that would allow me to pass an arbitrary C# object to an XSL transform.</p>
<p>The naive way of doing this is to serialise the object graph using an XmlSerializer; however, if you have a large object graph, this could cause problems as far as performance is concerned. Issues such as circular references, lazy loading, proxies etc may further muddy the waters here.</p>
<p>A better approach is to have some kind of Adapter class that implements IXPathNavigable and XPathNavigator. One such example that I've encountered is the <a href="http://blogs.byte-force.com/media/g/objectxpathnavigator/default.aspx" rel="noreferrer">ObjectXPathNavigator from Byte-Force</a> -- however, most of its key documentation is in Russian, and my initial tests seem to indicate that it has a few quirks and idiosyncrasies.</p>
<p>Does anyone know of either (a) any resources (overviews, tutorials, blog posts etc) about this particular in <strong>English</strong> or (b) any other alternatives that offer the same or similar functionality?</p>
| [
{
"answer_id": 431924,
"author": "Bevan",
"author_id": 30280,
"author_profile": "https://Stackoverflow.com/users/30280",
"pm_score": 2,
"selected": false,
"text": "XPathNavigator"
},
{
"answer_id": 466511,
"author": "Adam Hawkes",
"author_id": 6703,
"author_profile": ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/886/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.