qid int64 4 19.1M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
421,773 | <p>I have a Repeater which displays a list of items (in a grid-like/table view). When a user clicks an item, I display an UpdatePanel under this item with additional information relevant to the item (similar to Accordion control). I know how to populate the elements of the UpdatePanel in code-behind (I pass the ID of the selected element in the Repeater control as CommandArgument, get additional info for this ID, and set up the text fields of the active UpdatePanel controls). But I'm wondering if I could set up binding directly in the ASPX (instead of code-behind). When I used the <code><%= %></code> syntax to assign text fields of the UpdatePanel control the values of the page properties, e.g. <code><%= Comment %></code>, it sort of worked, but it changed the fields of all UpdatePanels in the repeater. Is there any way to bind the active UpdatePanel to the current values and leave already bound UpdatePanels unchanged?</p>
| [
{
"answer_id": 421905,
"author": "orip",
"author_id": 37020,
"author_profile": "https://Stackoverflow.com/users/37020",
"pm_score": 2,
"selected": false,
"text": "# settings.sh\necho export CLASSPATH=${CLASSPATH}:/foo/bar\n eval $(/path/to/settings.sh)\n X=...; export X setenv X ..."
}... | 2009/01/07 | [
"https://Stackoverflow.com/questions/421773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52545/"
] |
421,778 | <p>My default document is in subfolder not in root how can i make it default in asp.net 2.0 website.</p>
<p>Tried iis7 default document setting to '/pages/default.aspx'
'~/pages/default.aspx' but it didn't work.</p>
| [
{
"answer_id": 421836,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 5,
"selected": true,
"text": "mysite.com/somefolder public override void ProcessRequest(HttpContext context) {\n context.Response.Redirect(\"pages/default... | 2009/01/07 | [
"https://Stackoverflow.com/questions/421778",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48695/"
] |
421,782 | <p>I have to take over and improve/finish some code that transforms Java objects from a third party library into internal objects. Currently this is done through a big if-else statement along the lines of:</p>
<pre><code>if (obj instanceOf X)
{
//code to initialize internal object
}
else if (obj instanceOf Y)
{
//code to initialize different object
}
else if (obj instanceOf Z)
{
//more init code
}
...
</code></pre>
<p>Personally I don't find this solution satisfactory; it's long and messy and to make matters worse many of the if-else blocks contain more if-else blocks dealing with subclasses and edge cases. Is there a better solution to this problem?</p>
| [
{
"answer_id": 421803,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 4,
"selected": true,
"text": "public interface Converter<S,T> {\n public T convert(S source);\n}\n"
},
{
"answer_id": 421824,
"author"... | 2009/01/07 | [
"https://Stackoverflow.com/questions/421782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52558/"
] |
421,789 | <p>I want to create an ASP:ImageMap with a dynamic number of hot spots. I tried the code below, but it complains about having a repeater nested inside an image map. Any ideas on how to do this?</p>
<pre><code> <asp:ImageMap ID="imgMap" runat="server" ImageUrl="~/circles.png"
HotSpotMode="PostBack">
<asp:Repeater runat="server" id="repeat" DataSource=<%#circles %>>
<asp:CircleHotSpot PostBackValue="<%#name %>"
Radius="<%#r %>"
X="<%#x %>"
Y="<%#y %>" />
</asp:Repeater>
</asp:ImageMap>
</code></pre>
<p>(Please ignore problems with databinding. I'll solve those later.)</p>
| [
{
"answer_id": 421803,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 4,
"selected": true,
"text": "public interface Converter<S,T> {\n public T convert(S source);\n}\n"
},
{
"answer_id": 421824,
"author"... | 2009/01/07 | [
"https://Stackoverflow.com/questions/421789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17715/"
] |
421,794 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/193547/what-is-the-best-way-to-do-loops-in-javascript">What is the best way to do loops in JavaScript</a><br>
<a href="https://stackoverflow.com/questions/157260/whats-the-best-way-to-loop-through-a-set-of-elements-in-javascript">What’s the best way to loop through a set of elements in JavaScript?</a></p>
</blockquote>
<p>Any ideas?</p>
| [
{
"answer_id": 421807,
"author": "Rob",
"author_id": 3542,
"author_profile": "https://Stackoverflow.com/users/3542",
"pm_score": 2,
"selected": false,
"text": "for for( var i = 0; i < list.length; i++ ) {\n // do something with list[i]\n}\n for...in for...each...in"
},
{
"answ... | 2009/01/07 | [
"https://Stackoverflow.com/questions/421794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49881/"
] |
421,797 | <p>I saw this tip in another question and was wondering if someone could explain to me how on earth this works? </p>
<pre><code>try { return x; } finally { x = null; }
</code></pre>
<p>I mean, does the <code>finally</code> clause really execute <em>after</em> the <code>return</code> statement? How thread-unsafe is this code? Can you think of any additional hackery that can be done w.r.t. this <code>try-finally</code> hack?</p>
| [
{
"answer_id": 421812,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 9,
"selected": true,
"text": "int tmp;\ntry {\n tmp = ...\n} finally {\n ...\n}\nreturn tmp;\n static int Test() {\n try {\n return Some... | 2009/01/07 | [
"https://Stackoverflow.com/questions/421797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9476/"
] |
421,833 | <p>As most should know <code>close()</code> also closes any streams uses.</p>
<p>This allows the follow code:</p>
<pre><code>BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(...)));
...
br.close();
</code></pre>
<p>This is nice, since we don't need a reference to <code>FileInputStream</code> and remember to close it.</p>
<p>But does it also work for <code>FileLock</code>s?</p>
<pre><code>final FileInputStream fis = new FileInputStream(new File("buffer.txt"));
final FileChannel c = fis.getChannel();
final FileLock lock = c.lock(0L, Long.MAX_VALUE, true);
final BufferedReader br = new BufferedReader(new InputStreamReader(fis));
try {
while(br.ready()) {
System.out.println(br.readLine());
}
} finally {
br.close();
}
</code></pre>
<p>I've tried this code and the lock is correctly released when <code>br.close()</code> is called, but is is safe to do so? The <a href="http://java.sun.com/javase/6/docs/api/java/io/Closeable.html#close()" rel="nofollow noreferrer">Closeable JavaDoc</a> says, <em>"Closes this stream and releases any system resources associated with it."</em> Am I safe to assume that I am using <code>close()</code> as specified to <code>release()</code> the lock?</p>
| [
{
"answer_id": 421884,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 4,
"selected": true,
"text": "FileInputStream.close() public void close() throws IOException {\n if (channel != null)\n channel.close();\n clo... | 2009/01/07 | [
"https://Stackoverflow.com/questions/421833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21838/"
] |
421,847 | <p>Is there any FREE "build-in" way to capitalize the "keywords" in the SQL 2005/2008 management studio when you write a sql query?</p>
<p>i.e</p>
<pre><code>truncate table x
</code></pre>
<p>should be automatically changed to:</p>
<pre><code>TRUNCATE TABLE x
</code></pre>
| [
{
"answer_id": 51216167,
"author": "Gregg Taylor",
"author_id": 10043984,
"author_profile": "https://Stackoverflow.com/users/10043984",
"pm_score": 1,
"selected": false,
"text": "Ctrl + Shift + Q"
}
] | 2009/01/07 | [
"https://Stackoverflow.com/questions/421847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1683839/"
] |
421,851 | <p>I have a subclass with an over-ridden method that I know always returns a particular subtype of the return type declared in the base class. If I write the code this way, it won't compile. Since that probably doesn't make sense, let me give a code example:</p>
<pre><code>class BaseReturnType { }
class DerivedReturnType : BaseReturnType { }
abstract class BaseClass {
public abstract BaseReturnType PolymorphicMethod();
}
class DerivedClass : BaseClass {
// Compile Error: return type must be 'BaseReturnType' to match
// overridden member 'BaseClass.PolymorphicMethod()'
public override DerivedReturnType PolymorphicMethod() {
return new DerivedReturnType();
}
}
</code></pre>
<p>Is there any way to accomplish this in C#? If not, what's the best way to achieve something similar? And why isn't it allowed? It doesn't seem to allow any logical inconsistency, since any object returned from the over-ridden method still <code>is BaseReturnType</code>. Maybe there is something I hadn't considered though. Or maybe the reason is technological or historical.</p>
| [
{
"answer_id": 421879,
"author": "anand",
"author_id": 52554,
"author_profile": "https://Stackoverflow.com/users/52554",
"pm_score": 1,
"selected": false,
"text": "class BaseReturnType { }\nclass DerivedReturnType : BaseReturnType { }\n\nabstract class BaseClass {\n public abstract Ba... | 2009/01/07 | [
"https://Stackoverflow.com/questions/421851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44743/"
] |
421,857 | <p>I have created a .NET user control with an ActiveX interface. It works well.</p>
<p>Now, I want to be able to read and write from the property bag for the ActiveX interface.</p>
<p>How would I do this?</p>
| [
{
"answer_id": 421879,
"author": "anand",
"author_id": 52554,
"author_profile": "https://Stackoverflow.com/users/52554",
"pm_score": 1,
"selected": false,
"text": "class BaseReturnType { }\nclass DerivedReturnType : BaseReturnType { }\n\nabstract class BaseClass {\n public abstract Ba... | 2009/01/07 | [
"https://Stackoverflow.com/questions/421857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16794/"
] |
421,860 | <p>I can never remember how I do this because it comes up so infrequently for me. But in C or C++, what is the best way to read a character from standard input without waiting for a newline (press enter).</p>
<p>Also ideally it wouldn't echo the input character to the screen. I just want to capture keystrokes with out effecting the console screen.</p>
| [
{
"answer_id": 421871,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 8,
"selected": true,
"text": "stdin _getch() <conio.h> conio.h getch() getch() man getch man stty"
},
{
"answer_id": 422200,
"... | 2009/01/07 | [
"https://Stackoverflow.com/questions/421860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1366/"
] |
421,873 | <p>In my matlab m-file I am using some logic (string concat) to build variables like this:</p>
<pre><code>c = 'CalcPrediction(1,10)'
</code></pre>
<p>That means I have a string that is a function and some parameters. How can I do that function call?</p>
<p>Trying run(c) results in:</p>
<pre><code>>> run(c)
??? Error using ==> run at 71
CalcPrediction(1,10) not found.
</code></pre>
<p>Note: run(c) works fine if there is no parameters. E.g.
c='CalcPrediction';
run(c);</p>
| [
{
"answer_id": 422021,
"author": "ONODEVO",
"author_id": 40440,
"author_profile": "https://Stackoverflow.com/users/40440",
"pm_score": -1,
"selected": false,
"text": "fh = str2func('CalcPrediction')\nfh(1, 10)\n"
},
{
"answer_id": 422029,
"author": "M456",
"author_id": 49... | 2009/01/07 | [
"https://Stackoverflow.com/questions/421873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52570/"
] |
421,874 | <p>In one of the Stackoverflow podcasts, I remember Jeff Atwood saying that there was a configuration option in SQL Server 2008 which cuts down on locking, and was kind of an alternative to using "with (nolock)" in all your queries. Does anybody know how to enable the feature he was talking about, possibly even Jeff himself. I'm looking at deploying SQL Server 2008, and want to see if using a feature like this would help out my web application.</p>
| [
{
"answer_id": 421932,
"author": "SQLMenace",
"author_id": 740,
"author_profile": "https://Stackoverflow.com/users/740",
"pm_score": 3,
"selected": true,
"text": "ALTER DATABASE MyDatabase\nSET ALLOW_SNAPSHOT_ISOLATION ON\n\nALTER DATABASE MyDatabase\nSET READ_COMMITTED_SNAPSHOT ON\n"
... | 2009/01/07 | [
"https://Stackoverflow.com/questions/421874",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1862/"
] |
421,878 | <p>I have been running an UPDATE on a table containing 250 million rows with 3 index'; this UPDATE uses another table containing 30 million rows. It has been running for about 36 hours now. I am wondering if their is a way to find out how close it is to being done for if it plans to take a million days to do its thing, I will kill it; yet if it only needs another day or two, I will let it run. Here is the command-query:</p>
<pre><code>UPDATE pagelinks SET pl_to = page_id
FROM page
WHERE
(pl_namespace, pl_title) = (page_namespace, page_title)
AND
page_is_redirect = 0
;
</code></pre>
<p>The EXPLAIN is not the issue here and I only mention the big table's having multiple indexes in order to somewhat justify how long it takes to UPDATE it. But here is the EXPLAIN anyway:</p>
<pre><code>Merge Join (cost=127710692.21..135714045.43 rows=452882848 width=57)
Merge Cond: (("outer".page_namespace = "inner".pl_namespace) AND ("outer"."?column4?" = "inner"."?column5?"))
-> Sort (cost=3193335.39..3219544.38 rows=10483593 width=41)
Sort Key: page.page_namespace, (page.page_title)::text
-> Seq Scan on page (cost=0.00..439678.01 rows=10483593 width=41)
Filter: (page_is_redirect = 0::numeric)
-> Sort (cost=124517356.82..125285665.74 rows=307323566 width=46)
Sort Key: pagelinks.pl_namespace, (pagelinks.pl_title)::text"
-> Seq Scan on pagelinks (cost=0.00..6169460.66 rows=307323566 width=46)
</code></pre>
<p>Now I also sent a parallel query-command in order to DROP one of <em>pagelinks'</em> indexes; of course it is waiting for the UPDATE to finish (but I felt like trying it anyway!). Hence, I cannot SELECT anything from <em>pagelinks</em> for fear of corrupting the data (unless you think it would be safe to kill the DROP INDEX postmaster process?). </p>
<p>So I am wondering if their is a table that would keep track of the amount of dead tuples or something for It would be nice to know how fast or how far the UPDATE is in the completion of its task. </p>
<p>Thx
(PostgreSQL is not as intelligent as I thought; it needs heuristics) </p>
| [
{
"answer_id": 429260,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 4,
"selected": true,
"text": "EXPLAIN UPDATE page pagelinks temp_tablespace EXPLAIN (cost=127710692.21..135714045.43) UPDATE UPDATE UPDATE UPDATE DRO... | 2009/01/07 | [
"https://Stackoverflow.com/questions/421878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49985/"
] |
421,880 | <p>Do you keep tools that are necessary to build your project under version control?</p>
<p>If you do, what are your guidelines for which tools to include? I guess noone puts Visual Studio in version control, but how about your unit-test-runner? The Nant/Ant/Maven executable?</p>
<p>How about external dependencies? Do you have Boost in version control? The JDK? NUnit/JUnit? Where do you draw the limit here?</p>
<p>(See also <a href="https://stackoverflow.com/questions/191533/svn-and-binaries">this question</a>).</p>
<p><strong>EDIT:</strong>
I guess my question was not completely clear: I did not want to know whether you kept them in version control vs. or some shared drive. I really wanted to know whether you checked the tools necessary for building a project into version control <em>together</em> with the project, so that when you checked the project out, you would automatically get the tools.</p>
<p>As a general follow-up to those who answer no: what is your process for keeping track of those tools? Do your script download them?</p>
| [
{
"answer_id": 422056,
"author": "Rasmus Faber",
"author_id": 5542,
"author_profile": "https://Stackoverflow.com/users/5542",
"pm_score": 1,
"selected": false,
"text": "set ANT_HOME=tools/apache-ant-x.x.x\ntools/apache-ant-x.x.x %*\n"
}
] | 2009/01/07 | [
"https://Stackoverflow.com/questions/421880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5542/"
] |
421,891 | <p>What's the proper way to create a hyperlink in Spring+JSP? There must be a better way than just coding in the <code><a href="..."></code> tag. Take for example a page that displays people. The URL is <code>people.htm</code>. The corresponding controller gets people from the database and performs optional column sorting. The JSP might look like:</p>
<pre><code><table>
<tr>
<td><a href="people.htm?sort=name">Name</a></td>
<td><a href="people.htm?sort=age">Age</a></td>
<td><a href="people.htm?sort=address">Address</a></td>
</tr>
...
</code></pre>
<p>This seems bad as the URL <code>people.htm</code> is hardcoded in the JSP. There should be a way to have Spring automatically build the <code><a></code> tag using the URL defined in <code>servlet.xml</code>.</p>
<p><strong>Edit</strong>: Maybe I should be using a Spring form.</p>
| [
{
"answer_id": 421920,
"author": "Ole",
"author_id": 49540,
"author_profile": "https://Stackoverflow.com/users/49540",
"pm_score": 2,
"selected": false,
"text": "<td><a href=\"?sort=name\">Name</a></td>\n<td><a href=\"?sort=age\">Age</a></td>\n<td><a href=\"?sort=address\">Address</a></t... | 2009/01/07 | [
"https://Stackoverflow.com/questions/421891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24396/"
] |
421,893 | <p>The basics:</p>
<ul>
<li>I have a contact form that uses
php to validate the
forms. (in addition to client side) This could be done in any server side language though.</li>
<li>The server side only allows
A-z 0-9 for certain fields (it is
acceptable to validate this field to
English only with that extremely limited range)</li>
<li>If the form contains errors, I repopulate the fields so the user doesn't have to retype before submitting again</li>
<li>I am willing to not let other sites post to my form, even if legitimate use could be found there.</li>
</ul>
<p>I can easily make a form on a different web site that posts a dirty word to a field. Certain dirty words are perfectly legit according to the validation rules, but my employeer obviously wouldn't like that to happen.</p>
<p>I am under the impression that dedicated hackers can affect cookies, php sessions and of course hidden fields are easy to spoof along with referrers and such. How can I block third party sites from posting to my page? </p>
<p>Please feel free to help me Google for this too. My search terms are weak and bringing up methods I know will fail.</p>
<p>What if somebody submits "d03boy eats cats" via a form on their site and gets people to click a link that submits it to my form? (Admit it is possible, and my company cannot accept any risk) Then when a user clicks the link they see inside the "name" field "d03boy eats cats" and gets super offended and contacts PETA about our site's content. We just cannot explain to the user what happened. True, nothing happened, but upsetting a single users isn't acceptable to my employer.</p>
<p>Our current solution is to not report any user input, which in my opinion is a big usability issue.</p>
| [
{
"answer_id": 421935,
"author": "Joe Phillips",
"author_id": 20471,
"author_profile": "https://Stackoverflow.com/users/20471",
"pm_score": 0,
"selected": false,
"text": "htmlentities($str, ENT_QUOTES)\n"
},
{
"answer_id": 422590,
"author": "MrChrister",
"author_id": 2422... | 2009/01/07 | [
"https://Stackoverflow.com/questions/421893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24229/"
] |
421,944 | <p>I'll create a EML file with an attachment using JavaMail. </p>
<p>I created a simple EML file successfully, but adding an attachment don't work properly. I'm going to add a PDF file. My EML file will be created successfully. If I open the generated EML file with Outlook I'll find not my PDF file as attachment but I'll find the EML file itself as attachment. Does anyone has an idea? </p>
<p>I tried two variants (with same result), I used the <code>FileDataSource</code> class and the simple way with <code>MimeBodyPart#attachFile(File)</code>. </p>
<p>I'm going to post an example:</p>
<pre><code>File pdfFile = new File("somePdfFile");
Properties p = System.getProperties();
Session session = Session.getInstance(p);
MimeMessage message = new MimeMessage(session);
// MimeBodyPart txt = new MimeBodyPart();
// txt.setText("");
MimeBodyPart mbp = new MimeBodyPart();
mbp.attachFile(attachment);
// FileDataSource fds = new FileDataSource(attachment);
// fds.setFileTypeMap(new FileTypeMap() {
//
// @Override
// public String getContentType(String arg0) {
// return "application/pdf";
// }
//
// @Override
// public String getContentType(File file) {
// return "application/pdf";
// }
//
// });
// mbp.setDataHandler(new DataHandler(fds));
// mbp.setFileName("\"" + attachment.getName() + "\"");
// mbp.setDisposition(MimePart.ATTACHMENT);
// mbp.setHeader("Content-ID", "Attachment");
Multipart mp = new MimeMultipart();
// mp.addBodyPart(txt);
mp.addBodyPart(mbp);
message.setContent(mp);
File emlFile = new File("message.eml");
emlFile.createNewFile();
message.writeTo(new FileOutputStream(emlFile));
// do something with the EML file
// Desktop.getDesktop().open(emlFile);
</code></pre>
<p><a href="https://stackoverflow.com/questions/157195/create-an-eml-e-mail-file-in-java">Create a .eml (email) file in Java</a></p>
<hr>
<p>Thank you for your response. I uploaded a PDF file (that I use for testing, it's a simple HelloWorld generated with Crystal Reports) and the generated EML file which should include the PDF file.</p>
<p>I just noticed that if I open the linked EML file with Apple Mail or with Outlook Express it works (but without edit possibility). Maybe it's an issue of Microsoft Outlook?</p>
<p><em>The links are removed</em></p>
| [
{
"answer_id": 421935,
"author": "Joe Phillips",
"author_id": 20471,
"author_profile": "https://Stackoverflow.com/users/20471",
"pm_score": 0,
"selected": false,
"text": "htmlentities($str, ENT_QUOTES)\n"
},
{
"answer_id": 422590,
"author": "MrChrister",
"author_id": 2422... | 2009/01/07 | [
"https://Stackoverflow.com/questions/421944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42659/"
] |
421,945 | <p>I'm having Internet Explorer 6 problems on one of my sites, and I really wish I had it installed instead of Internet Explorer 7. Is there a quick way to do this?</p>
| [
{
"answer_id": 421954,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 5,
"selected": true,
"text": "[HKLM\\SOFTWARE\\Microsoft\\Internet Explorer\\Version Vector]"
}
] | 2009/01/07 | [
"https://Stackoverflow.com/questions/421945",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428190/"
] |
421,949 | <p>I'm looking for a better way to do the following query. I have a table that looks like this:</p>
<pre><code>game_id | home_team_id | away_team_id
1 | 100 | 200
2 | 200 | 300
3 | 200 | 400
4 | 300 | 100
5 | 100 | 400
</code></pre>
<p>And I want to write a query that counts the number of home games and away games for each team and outputs the following:</p>
<pre><code>team_id | home_games | away_games
100 | 2 | 1
200 | 2 | 1
300 | 1 | 1
400 | 0 | 2
</code></pre>
<p>Right now, I wrote this monstrosity that works, but it's slow (I know it's pulling the entire 2,800 row from the table twice).</p>
<pre><code>SELECT
home_team_id as team_id,
(SELECT count(*) FROM `game` WHERE home_team_id = temp_game.home_team_id) as home_games,
(SELECT count(*) FROM `game` WHERE home_team_id = temp_game.away_team_id) as away_games
FROM (SELECT * FROM `game`) as temp_game
GROUP BY home_team_id
</code></pre>
<p>Can a SQL guru help me knock out a better way? I think my problem is that I don't understand how to get a distinct list of the team IDs to throw at the count queries. I bet there's a better way with a better placed, nested SELECT. Thanks in advance!</p>
| [
{
"answer_id": 422019,
"author": "casperOne",
"author_id": 50776,
"author_profile": "https://Stackoverflow.com/users/50776",
"pm_score": 2,
"selected": false,
"text": "select home_team_id as team_id from game union\nselect away_team_id as team_id from game\n union union all select\n u... | 2009/01/07 | [
"https://Stackoverflow.com/questions/421949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28002/"
] |
421,953 | <p>I have a gridview that contains one to many rows (like most do) - each with an input textbox. Each row has a requiredfieldvalidator against that textbox. When the form is submitted the gridview is validated it is entirely possible that more than one row has an empty textbox. This results in repeating validation messages e.g.</p>
<ul>
<li>Please provide text for 'Name' field</li>
<li>Please provide text for 'Name' field</li>
<li>Please provide text for 'Name' field</li>
</ul>
<p>Is it possible to consolidate these messages into one message?</p>
<p>I know it possible to create a validator by setting up a validator class and inheriting from BaseValidator class which can be used to validate the gridview as a whole. But I put an image against each row when it is invalid so I should imagine I require separate validators on each row.</p>
| [
{
"answer_id": 422925,
"author": "BlackMael",
"author_id": 19377,
"author_profile": "https://Stackoverflow.com/users/19377",
"pm_score": 0,
"selected": false,
"text": "<asp:Validator ID=\"X\" ... runAt=\"server\" Text=\"*\" />\n <asp:Validator ID=\"X\" ... runAt=\"server\">*</asp:Validat... | 2009/01/07 | [
"https://Stackoverflow.com/questions/421953",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47036/"
] |
421,960 | <p>A potential customer has asked me to look at some promotional flyers for a couple of apps which fall into the contact management / scheduler category. Both use Filemaker as their backend. It looks like these two apps are sold as web apps. At any rate I had not heard of Filemaker in about ten years, so it was surprising to see it pop up twice in the same sitting. I think it started out as a Mac platform db system.</p>
<p>I am more partial to SQL Server, MY SQL, etc, but before make any comments on Filemaker, I'd like to know some of the pros and cons of the system. It must be more than Access for Mac's, but I have never run across it as a player in the client / server or web app arena.</p>
<p>Many thanks
Mike Thomas</p>
| [
{
"answer_id": 13677727,
"author": "CrazyTim",
"author_id": 737393,
"author_profile": "https://Stackoverflow.com/users/737393",
"pm_score": 4,
"selected": false,
"text": "SELECT id FROM table\nWHERE datefield1 = {d '2014-03-26'}\n SELECT id FROM table\nWHERE datefield2 = {d '2014-03-26'}... | 2009/01/07 | [
"https://Stackoverflow.com/questions/421960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
421,965 | <p>So I'm working on this class that's supposed to request help documentation from a vendor through a web service. I try to name it <code>DocumentRetriever</code>, <code>VendorDocRequester</code>, <code>DocGetter</code>, but they just don't sound right. I ended up browsing through <a href="http://dictionary.com/" rel="noreferrer">dictionary.com</a> for half an hour trying to come up with an adequate word. </p>
<p>Start programming with bad names is like having a very bad hair day in the morning, the rest of the day goes downhill from there. Feel me?</p>
| [
{
"answer_id": 421982,
"author": "willcodejavaforfood",
"author_id": 51382,
"author_profile": "https://Stackoverflow.com/users/51382",
"pm_score": 5,
"selected": false,
"text": "VendorHelpDocRequester"
},
{
"answer_id": 422039,
"author": "Jason S",
"author_id": 44330,
... | 2009/01/07 | [
"https://Stackoverflow.com/questions/421965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10088/"
] |
421,968 | <p>I need to create a transparent blurred background. Lets suppose I have a border with a white blurry transparent background. Everything that is behind the border is blurred.</p>
<p>I'm trying to avoid dependencies; I'm currently using .NET 3.0, and want it to run with XP too.</p>
<p>Mockup image:</p>
<p><img src="https://i.stack.imgur.com/rmKkp.png" alt="Mockup Image"></p>
| [
{
"answer_id": 422561,
"author": "Rhys",
"author_id": 22169,
"author_profile": "https://Stackoverflow.com/users/22169",
"pm_score": 5,
"selected": true,
"text": " <Grid>\n <Border x:Name=\"src\" Background=\"Silver\">\n <Label HorizontalAlignment=\"Center\" VerticalAlignment=\"C... | 2009/01/07 | [
"https://Stackoverflow.com/questions/421968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1013/"
] |
421,973 | <p>I'm trying to optimize query performance and have had to resort to using optimizer hints. But I've never learned if the optimizer will use more than one hint at a time.</p>
<p>e.g.</p>
<pre><code>SELECT /*+ INDEX(i dcf_vol_prospect_ids_idx)*/
/*+ LEADING(i vol) */
/*+ ALL_ROWS */
i.id_number,
...
FROM i_table i
JOIN vol_table vol on vol.id_number = i.id_number
JOIN to_a_bunch_of_other_tables...
WHERE i.solicitor_id = '123'
AND vol.solicitable_ind = 1;
</code></pre>
<p>The explain plan shows the same cost, but I know that's just an estimate.</p>
<p>Please assume that all table and index statistics have been calculated. FYI, the index dcf_vol_prospect_ids_idx is on the i.solicitor_id column.</p>
<p>Thanks,</p>
<p>Stew</p>
| [
{
"answer_id": 422033,
"author": "Dave Costa",
"author_id": 6568,
"author_profile": "https://Stackoverflow.com/users/6568",
"pm_score": 6,
"selected": true,
"text": "SELECT /*+ LEADING(e2 e1) USE_NL(e1) INDEX(e1 emp_emp_id_pk)\n USE_MERGE(j) FULL(j) */\n e1.first_name, e1.la... | 2009/01/07 | [
"https://Stackoverflow.com/questions/421973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50943/"
] |
421,989 | <p>I have some standard-texts, but some portion of it is different. But of these different parts only a few exists.</p>
<p>For instance I want:</p>
<pre><code>\mytext{...}{a}
\mytext{...}{b}
</code></pre>
<p>That produces:</p>
<pre><code>\section{Item: ...}\label{item...}
This is a standard item. Items of type a are very precious.
\section{Item: ...}\label{item...}
This is a standard item. Items of type b are cheap.
</code></pre>
<p>A simple solution to this would be to define commands mytexta and mytextb, but as I have more options I want more something like an if or switch in programming languages. Has anyone a solution for this problem?</p>
| [
{
"answer_id": 422107,
"author": "ChrisN",
"author_id": 3853,
"author_profile": "https://Stackoverflow.com/users/3853",
"pm_score": 3,
"selected": true,
"text": "ifthen \\ifthenelse \\usepackage{ifthen}\n\\ifthenelse{test}{then-code}{else-code}\n \\newcommand\\mytext[1]{%\n \\ifthenel... | 2009/01/07 | [
"https://Stackoverflow.com/questions/421989",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21005/"
] |
422,002 | <p>I need to open foxpro free tables in vb.net using the oledb connection.</p>
<p>But... I only need to get the column names. I don't really need to 'select' anything.
I am trying to dynamically browse through all our free tables and set up a listing of every column from every file and xref that to another free table that contains a description of each column. </p>
<p>I have a working model now, but it requires that I do...</p>
<pre><code>SELECT TOP 1 FROM "File" ORDER BY 1
</code></pre>
<p>But on the largest table, it takes over two minutes just to read in the first record and there are over 250 tables. Overall, it takes between 15 and 20 minutes.</p>
<p>Or, is there another way to only get the first record of the table without using 'ORDER BY'?</p>
<p>Here's what I have so far. "File" is passed in as a parameter.<br>
It would contain info like "C:\data\table1.dbf"</p>
<pre><code>Dim filePath As String
filePath = IO.Path.GetDirectoryName(file)
myOledbConnection = New OleDbConnection("Provider=VFPOLEDB.1;Data Source=" & filePath & ";Collating Sequence=MACHINE")
myOledbCommand = New OleDbCommand
myOledbDataAdapter = New OleDbDataAdapter
Dim fields, from, order As String
fields = "select top 1 *"
from = " from " & file
order = " order by 1"
myOledbCommand.CommandText = fields & from & order
myOledbCommand.Connection = myOledbConnection
myOledbDataAdapter.SelectCommand = myOledbCommand
myOledbDataAdapter.Fill(dt)
</code></pre>
<p>I then take the datatable (dt) and loop through to get the column information.</p>
<p>I would like it to be as quick as Visual Studio is when I create a dataset and load all tables from the directory through the wizard. It is able to very quickly find all the column information without reading in the data from the table.</p>
<p>Let me know if you need more information.</p>
<p>Thanks.</p>
| [
{
"answer_id": 422079,
"author": "casperOne",
"author_id": 50776,
"author_profile": "https://Stackoverflow.com/users/50776",
"pm_score": 4,
"selected": true,
"text": "SELECT * FROM \"File\" where 1 = 0\n GetOleDbSchemaTable OleDbConnection"
}
] | 2009/01/07 | [
"https://Stackoverflow.com/questions/422002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32540/"
] |
422,028 | <p>I need to lock the browser scrollbars when I show a div that represent a modal window in Internet Explorer 7 only.
Googling I found that I can use <code>document.body.style.overflow='hidden'</code> but this doesn't work for IE7. I also tried with <code>document.body.scroll="no"</code> which works but only after I mouse over the scrollbar :-S</p>
<p>Does anybody knows a better aproach?</p>
<p>Thansks</p>
| [
{
"answer_id": 422088,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 5,
"selected": true,
"text": "position:fixed position:absolute position:fixed position:absolute fixed"
},
{
"answer_id": 422294,
"author": "Quami... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25578/"
] |
422,032 | <p>So I have a Stateful .NET webservice (C#) that I would like Flex to use. The only problem is that I don't see a cookie being passed, even though I have the WebMethods decorated with:</p>
<pre><code>WebMethod(EnableSession=true)
</code></pre>
<p>I can't seem to figure out if it is an issue with Flex or .NET. </p>
<p>Does Flex 3 (as3) pay attention to the session cookie automatically with the generated web service classes? If not what can I do to minimize the code I have to write to get this supported with generated proxy classes.</p>
<p>Code examples, please :)</p>
<h2>EDIT 1</h2>
<p>I found my own <a href="https://stackoverflow.com/questions/422032/how-to-get-flex-to-see-a-net-webservice-session-when-i-use-the-proxy-auto-genera#435846">solution</a>.</p>
| [
{
"answer_id": 422088,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 5,
"selected": true,
"text": "position:fixed position:absolute position:fixed position:absolute fixed"
},
{
"answer_id": 422294,
"author": "Quami... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19854/"
] |
422,045 | <p>How do I split data into pages on ASP.Net?</p>
<p>I'm looking for something like what Google does when you have too many search results and it splits them into x number of pages.</p>
| [
{
"answer_id": 422055,
"author": "Steven Robbins",
"author_id": 26507,
"author_profile": "https://Stackoverflow.com/users/26507",
"pm_score": 3,
"selected": false,
"text": "SELECT Description, Date\nFROM (SELECT ROW_NUMBER() OVER (ORDER BY MyCol DESC) AS Row, Desc, Date FROM MyTabl... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52590/"
] |
422,066 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/227005/manually-drawing-a-gradient-in-iphone-apps">Manually drawing a gradient in iPhone apps?</a> </p>
</blockquote>
<p>My application needs to display text in either a <code>UIView</code> or <code>UILabel</code> but the back ground must be a gradient as opposed to a true <code>UIColor</code>. Using a graphics program to create desired look is no good as the text may vary depending on data returned from a server.</p>
<p>Does anyone know the quickest way to tackle this?
Your thoughts are greatly appreciated.</p>
| [
{
"answer_id": 422208,
"author": "Brad Larson",
"author_id": 19679,
"author_profile": "https://Stackoverflow.com/users/19679",
"pm_score": 7,
"selected": false,
"text": "UIView UILabel UIView drawRect: - (void)drawRect:(CGRect)rect \n{\n CGContextRef currentContext = UIGraphicsGetCurr... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51630/"
] |
422,078 | <p>I have the following DataTemplate in a Listbox</p>
<pre><code><ListBox Grid.Column="1" Grid.Row="2" ItemsSource="{Binding People}" SelectedItem="{Binding SelectedPerson}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock OverridesDefaultStyle="True"
Background="{x:Null}"
Margin="0"
Padding="0"
IsHitTestVisible="True"
Text="{Binding TargetNullValue=None}"
/>
</DataTemplate>
</ListBox.ItemTemplate>
</code></pre>
<p></p>
<p>This works perfectly, displaying "None" in place of any Null (Nothing) values in the bound list. The problem is that I can't click on the Null values to select them. Selection with the keyboard works perfectly, just not with a mouse. What can I do to make the Null values in the list act just like any other value?</p>
<p><strong>Edit:</strong> I should also add that I can change the TextBlock's background to Red and it displays just like the others so I don't think it's a case of having nothing to click on. I've also looked at it with Snoop and I don't see any attributes in the visual tree that are different between a Null item and a normal item.</p>
<p><strong>Edit 2:</strong> I should add that People is actually a class representing a database table. It uses the ToString method to display the People objects by default. I get the same effect if I bind to the proper field using the Path option and I thought this would be easier to read.</p>
| [
{
"answer_id": 424439,
"author": "Rhys",
"author_id": 22169,
"author_profile": "https://Stackoverflow.com/users/22169",
"pm_score": 0,
"selected": false,
"text": "class People\n{\n string Name {get;set;} \n}\n\n...\n...\n\nvar list = new List<People> {new People {Name = \"Fred\"},\n ... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21186/"
] |
422,081 | <p>I have a view which is derived from CEditView. It is read only. I would like to set the text as a kind of logging, but nothing shows up on the screen. If I inspect <code>temp</code> in the debugger after <code>GetEditCtrl().GetWindowText(temp);</code> I can see that the text is indeed changing internally, but I see nothing on the screen.</p>
<pre><code>// HistoryView.cpp : implementation file
//
#include "stdafx.h"
#include "HistoryView.h"
// CHistoryView
IMPLEMENT_DYNCREATE(CHistoryView, CEditView)
CHistoryView::CHistoryView()
{
}
CHistoryView::~CHistoryView()
{
}
BEGIN_MESSAGE_MAP(CHistoryView, CEditView)
END_MESSAGE_MAP()
// CHistoryView diagnostics
#ifdef _DEBUG
void CHistoryView::AssertValid() const
{
CEditView::AssertValid();
}
#ifndef _WIN32_WCE
void CHistoryView::Dump(CDumpContext& dc) const
{
CEditView::Dump(dc);
}
#endif
#endif //_DEBUG
// CHistoryView message handlers
void CHistoryView::OnInitialUpdate()
{
CEditView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
GetEditCtrl().SetReadOnly(TRUE);
}
//!
/*!
*/
void CHistoryView::AddRow(CString message)
{
CString temp;
GetEditCtrl().GetWindowText(temp);
if(temp.IsEmpty())
{
GetEditCtrl().SetWindowText(message);
}
else
{
GetEditCtrl().SetWindowText(temp + "\r\n" + message);
}
GetEditCtrl().LineScroll(2, 0);
//GetEditCtrl().UpdateWindow(); // no effect
}
</code></pre>
| [
{
"answer_id": 422223,
"author": "Joel",
"author_id": 46852,
"author_profile": "https://Stackoverflow.com/users/46852",
"pm_score": 2,
"selected": false,
"text": "\"\\r\\n\" CString GetEditCtrl().SetWindowText(temp + CString(\"\\r\\n\") + message);\n"
},
{
"answer_id": 422311,
... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1490/"
] |
422,090 | <p>Is there a method in the System.IO namespace that checks the validity of a filename?</p>
<p>For example, <code>C:\foo\bar</code> would validate and <code>:"~-*</code> would not</p>
<p>Or a little trickier, <code>X:\foo\bar</code> would validate is there is an <code>X:</code> drive on the system, but wouldn't otherwise.</p>
<p>I suppose I could write such a method myself, but I'm more interested in a built-in one.</p>
| [
{
"answer_id": 422109,
"author": "Eugene Katz",
"author_id": 1533,
"author_profile": "https://Stackoverflow.com/users/1533",
"pm_score": 5,
"selected": false,
"text": "Path.GetInvalidPathChars GetInvalidFileNameChars Directory.GetLogicalDrives"
},
{
"answer_id": 422111,
"auth... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
422,091 | <p>How can I implement the following in python?</p>
<pre><code>#include <iostream>
int main() {
std::string a;
std::cout << "What is your name? ";
std::cin >> a;
std::cout << std::endl << "You said: " << a << std::endl;
}
</code></pre>
<p>Output:</p>
<blockquote>
<p>What is your name? Nick</p>
<p>You said: Nick</p>
</blockquote>
| [
{
"answer_id": 422105,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 2,
"selected": false,
"text": "print raw_input() sys.stdin.read() sys.stdout.write() sys.stdout"
},
{
"answer_id": 422121,
"author": "Swaroop ... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4960/"
] |
422,102 | <p>Suppose I have a database table that has a timedate column of the last time it was updated or inserted. Which would be preferable:</p>
<ol>
<li>Have a trigger update the field.</li>
<li>Have the program that's doing the insertion/update set the field.</li>
</ol>
<p>The first option seems to be the easiest since I don't even have to recompile to do it, but that's not really a huge deal. Other than that, I'm having trouble thinking of any reasons to do one over the other. Any suggestions?</p>
| [
{
"answer_id": 422602,
"author": "Ron Savage",
"author_id": 12476,
"author_profile": "https://Stackoverflow.com/users/12476",
"pm_score": 1,
"selected": false,
"text": "create table dbo.Repository\n (\n ...\n last_updated datetime default getdate(),\n ...\n )\n create tri... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2147/"
] |
422,108 | <p>I am trying to add the following method to the Math class in Ruby on Rails:</p>
<pre><code>class Math
def self.round_with_precision(number, precision)
scalar = 10.0 ** precision
number = number * scalar
number = number.round
number = number / scalar
return number;
end
end
</code></pre>
<p>I then added the following to my environment.rb:</p>
<pre><code>require 'lib/math'
</code></pre>
<p>When I open up the Rails console I get the following error: './lib/math.rb:2:TypeError Math is not a class'</p>
<p>It seems like I'm overlooking something very simple.</p>
<p>Any thoughts?</p>
<p>Thanks in advance for your help.</p>
| [
{
"answer_id": 427162,
"author": "Zach Langley",
"author_id": 45230,
"author_profile": "https://Stackoverflow.com/users/45230",
"pm_score": 0,
"selected": false,
"text": "instance_eval class module Math.instance_eval do\n def round_with_precision(number, precision)\n scalar = 10.0 **... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10333/"
] |
422,138 | <p>Initial Googling indicates that there's no built-in way to do regular expressions in an Objective-C Cocoa application.</p>
<p>So four questions:</p>
<ol>
<li><p>Is that really true?</p></li>
<li><p>Are you kidding me?</p></li>
<li><p>Ok, then is there a nice open-source library you recommend?</p></li>
<li><p>What are ways to get close enough without importing a library, perhaps with the NSScanner class?</p></li>
</ol>
| [
{
"answer_id": 422159,
"author": "Adam Wright",
"author_id": 1200,
"author_profile": "https://Stackoverflow.com/users/1200",
"pm_score": 4,
"selected": false,
"text": "man 3 regex\n"
},
{
"answer_id": 9343810,
"author": "bbaassssiiee",
"author_id": 571517,
"author_pro... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4234/"
] |
422,140 | <p>I'm storing some additional per-user information using the <a href="http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users" rel="noreferrer"><code>AUTH_PROFILE_MODULE</code></a>.</p>
<p>We can access the user in a Django template using <code>{{ request.user }}</code> but how do we access fields in the profile since the profile is only accessible via a function <code>user.get_profile()</code> ?</p>
<p>Is it really required to explicitly pass the profile into the template every time?</p>
| [
{
"answer_id": 422153,
"author": "AdamKG",
"author_id": 16361,
"author_profile": "https://Stackoverflow.com/users/16361",
"pm_score": 8,
"selected": true,
"text": "{{ request.user.get_profile.whatever }} .get_profile()"
},
{
"answer_id": 422218,
"author": "Sergey Golovchenko"... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4869/"
] |
422,181 | <p>Is there a technique such that I can specify a number n such that when the (n + 1)th entry is inserted, the oldest entry is removed first ensuring that the size of the hashtable is always limited to n?</p>
| [
{
"answer_id": 422385,
"author": "Kristian",
"author_id": 11429,
"author_profile": "https://Stackoverflow.com/users/11429",
"pm_score": 5,
"selected": false,
"text": "Map map = new LinkedHashMap() {\n @Override\n protected boolean removeEldestEntry(Entry eldest) {\n return s... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
422,186 | <p>I have a value type that represents a gaussian distribution:</p>
<pre><code>struct Gauss {
double mean;
double variance;
}
</code></pre>
<p>I would like to perform an integral over a series of these values:</p>
<pre><code>Gauss eulerIntegrate(double dt, Gauss iv, Gauss[] values) {
Gauss r = iv;
foreach (Gauss v in values) {
r += v*dt;
}
return r;
}
</code></pre>
<p>My question is how to implement addition for these normal distributions.</p>
<p>The multiplication by a scalar (<code>dt</code>) seemed simple enough. But it wasn't simple! Thanks <a href="https://stackoverflow.com/questions/422186/how-to-calculate-the-sum-of-two-normal-distributions#422229">FOOSHNICK</a> for the help:</p>
<pre><code>public static Gauss operator * (Gauss g, double d) {
return new Gauss(g.mean * d, g.variance * d * d);
}
</code></pre>
<p>However, addition eludes me. I assume I can just add the means; it's the variance that's causing me trouble. Either of these definitions seems "logical" to me.</p>
<pre><code>public static Gauss operator + (Gauss a, Gauss b) {
double mean = a.mean + b.mean;
// Is it this? (Yes, it is!)
return new Gauss(mean, a.variance + b.variance);
// Or this? (nope)
//return new Gauss(mean, Math.Max(a.variance, b.variance));
// Or how about this? (nope)
//return new Gauss(mean, (a.variance + b.variance)/2);
}
</code></pre>
<p>Can anyone help define a statistically correct - or at least "reasonable" - version of the <code>+</code> operator?</p>
<p>I suppose I could switch the code to use interval arithmetic instead, but I was hoping to stay in the world of prob and stats.</p>
| [
{
"answer_id": 422213,
"author": "David Norman",
"author_id": 34502,
"author_profile": "https://Stackoverflow.com/users/34502",
"pm_score": 4,
"selected": true,
"text": "// X + Y\npublic static Gauss operator + (Gauss a, Gauss b) {\n //NOTE: this is valid if X,Y are independent normal... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/338/"
] |
422,188 | <p>I'm doing research into a web API for my company, and it's starting to look like we might implement a RESTful one. I've read a couple of books about this now (O'Reilly's "RESTful web services" seeming the most useful) and have come up with the following set of URIs and operations for an object that can be commented on, tagged, and rated. </p>
<p>It doesn't really matter what the object is, as this scenario applies to many things on the net, but for the sake of argument lets say it's a movie.</p>
<p>Some of these seem to fit quite naturally, but others seem a bit forced (rating and tagging particularly) so does anybody have any suggestions about how these could be improved? I'll list them with the URI and then the supported verbs, and what I propose they would do.</p>
<pre><code>/movies
</code></pre>
<p>GET = List movies</p>
<pre><code>/movies/5
</code></pre>
<p>GET = Get movie 5</p>
<pre><code>/movies/5/comments
</code></pre>
<p>GET = List comments on movie 5</p>
<p>POST = Create a new comment on movie 5</p>
<pre><code>/movies/5/comments/8
</code></pre>
<p>GET = Get comment 8 on movie 5</p>
<p>POST = Reply to comment 8 on movie 5</p>
<p>PUT = Update comment 8 on movie 5</p>
<pre><code>/movies/5/comments/8/flag
</code></pre>
<p>GET = Check whether the movies is flagged as inappropriate (404 if not)</p>
<p>PUT = Flag movie as inappropriate</p>
<pre><code>/movies/5/rating
</code></pre>
<p>GET = Get the rating of the movie</p>
<p>POST = Add the user rating of the movie to the overall rating</p>
<p><em>Edit: My intention is that the movie object would contain its rating as a property, so I wouldn't really expect the GET method to be used here. The URI really exists so that the rating can be an individual resource that can be updated using the POST verb. I'm not sure if this is the best way of doing it, but I can't think of a better one</em></p>
<pre><code>/movies/5/tags/tagname
</code></pre>
<p>GET = Check whether the movies is tagged with <em>tagname</em> (404 if not; but if it is tagged with the tag name should it return the actual tag resource by redirecting to something like <code>/tags/tagname</code>?)</p>
<p>PUT = Add tag <em>tagname</em> to the movie, creating the tag resource <code>/tags/tagname</code> if required</p>
<p>DELETE = Remove tag <em>tagname</em> from the movie, deleting the tag resource <code>tags/tagname</code> if nothing is tagged with it after this removal</p>
<hr>
<p>Note that these wouldn't be the entire URIs, for example the URI to list the movies would support filtering, paging and sorting. For this I was planning on something like:</p>
<pre><code>/movies/action;90s/rating,desc/20-40
</code></pre>
<p>Where:</p>
<p>action;90s is a semi-colon delimited set of filter criteria</p>
<p>rating,desc is the sort order and direction</p>
<p>20-40 is the range of item indices to get</p>
<p>Any comments about this API scheme too?</p>
<hr>
<p><strong>Edit #1</strong></p>
<p>This post is getting quite long now! After reading some of the answers and comments, this is the changes from above I'm planning on making:</p>
<p>Tags will be handled as a group rather than individually, so they will be at:</p>
<pre><code>/movies/5/tags
</code></pre>
<p>GET = List tags</p>
<p>POST = Union of specified tags and existing tags</p>
<p>PUT = Replace any current tags with specified tags</p>
<p>DELETE = Delete all tags</p>
<p>I'm still really not sure how to handle flagging a comment though. One option is that instead of POSTing to a comment replying to it, a comment object will include its parent so it can be POSTed to the general URI, i.e.</p>
<pre><code>/movie/5/comment
</code></pre>
<p>POST = Create a new comment (which may be a reply to a comment)</p>
<p>I could then use the POST to a comment to flag it. But this still doesn't feel quite right.</p>
<pre><code>/movie/5/comment/8
</code></pre>
<p>POST = Flag comment</p>
| [
{
"answer_id": 422231,
"author": "Martijn Laarman",
"author_id": 47020,
"author_profile": "https://Stackoverflow.com/users/47020",
"pm_score": 1,
"selected": false,
"text": "<movie>\n <title>..</title>\n ..\n <rating url=\"movies/ratings/4\">4</rating>\n <tags>\n <tag url=\"... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13552/"
] |
422,199 | <p>What is the best way to discover what USB drives are connected, where they are mounted, and their unique details like Serial number, PID and which USB Hub port they are connected to? Something similar to what <a href="http://www.usblyzer.com/" rel="noreferrer">USBlyzer</a> does for Windows but programmatically.</p>
| [
{
"answer_id": 3820268,
"author": "Niko",
"author_id": 403416,
"author_profile": "https://Stackoverflow.com/users/403416",
"pm_score": 6,
"selected": true,
"text": "system_profiler SPUSBDataType\n"
}
] | 2009/01/07 | [
"https://Stackoverflow.com/questions/422199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47110/"
] |
422,207 | <p>Let's say I'm generating markup through server-side code. I'm generating a bunch of HTML tags but I want to add custom client-side behavior.</p>
<p>With JavaScript (if I had a reference to the DOM node) I could have written:</p>
<pre><code>var myDOMNode = ...
myDOMNode.myCustomAttribute = "Hi!";
</code></pre>
<p>Now the issue here is that I don't want to qualify every element with an unique id just to initialize data. And it's really strange to me, that there's not an easier and unobtrusive way to attach client-side behavior.</p>
<p>If I'm remembing this correctly, this is valid IE stuff.</p>
<pre><code><div onload="this.myCustomAttribute='Hi!'"></div>
</code></pre>
<p>If I was able to do this, I should be able to access it's "data context" though the identifier 'myCustomAttribute', which is really what I want.</p>
| [
{
"answer_id": 422233,
"author": "Dan Williams",
"author_id": 4230,
"author_profile": "https://Stackoverflow.com/users/4230",
"pm_score": 0,
"selected": false,
"text": "<script>\n function LoadElement(myDiv)\n {\n alert(this.myCustomAttribute);\n }\n</script>\n\n<div onlo... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58961/"
] |
422,224 | <pre><code> private void CheckBox_CheckedChanged(object sender, EventArgs e)
{
CheckBox chk = (CheckBox)sender;
SetValuesInDB( System.Security.Principal.WindowsIdentity.GetCurrent().Name,
DateTime.Today.Date);
}
</code></pre>
<p>Now I want to setvalues of my id and current date in database only if I directly clicked on the checkbox.</p>
<p>I dont want to update those values in Database if some other event triggers this event handler.
For eg: while loading everytime the checkbox gets checked but the database value for this checkbox is unchecked.
so, everytime this event handler is triggered and database value is updated.
How do I take care of it? </p>
| [
{
"answer_id": 13125172,
"author": "Benjamin",
"author_id": 1776539,
"author_profile": "https://Stackoverflow.com/users/1776539",
"pm_score": 0,
"selected": false,
"text": " \n\ninternal class MyDataSource {\n\n public bool MyBooleanValue {\n get { return ReadValueFromDB(\"MyUs... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42564/"
] |
422,230 | <p>I'm using the .NET Fx 3.5 and have written my own configuration classes which inherit from ConfigurationSection/ConfigurationElement. Currently I end up with something that looks like this in my configuration file:</p>
<pre><code><blah.mail>
<templates>
<add name="TemplateNbr1" subject="..." body="Hi!\r\nThis is a test.\r\n.">
<from address="blah@hotmail.com" />
</add>
</templates>
</blah.mail>
</code></pre>
<p>I would like to be able to express the body as a child node of <code>template</code> (which is the <code>add</code> node in the example above) to end up with something that looks like:</p>
<pre><code><blah.mail>
<templates>
<add name="TemplateNbr1" subject="...">
<from address="blah@hotmail.com" />
<body><![CDATA[Hi!
This is a test.
]]></body>
</add>
</templates>
</blah.mail>
</code></pre>
| [
{
"answer_id": 465106,
"author": "frantisek",
"author_id": 53332,
"author_profile": "https://Stackoverflow.com/users/53332",
"pm_score": 3,
"selected": false,
"text": "OnDeserializeUnrecognizedElement public class PluginConfigurationElement : ConfigurationElement\n{\n public NameValue... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5645/"
] |
422,234 | <p>How can you make the ASP.net Session Data available to a JavaScript method? I found <a href="http://blogs.msdn.com/mattgi/archive/2006/11/15/accessing-session-data-from-javascript.aspx" rel="nofollow noreferrer">this</a> link when I googled. Anyone has a better trick that does not use the ScriptManager? </p>
| [
{
"answer_id": 422248,
"author": "Michael Haren",
"author_id": 29,
"author_profile": "https://Stackoverflow.com/users/29",
"pm_score": 1,
"selected": false,
"text": "HtmlInputHidden"
},
{
"answer_id": 422280,
"author": "slolife",
"author_id": 698,
"author_profile": "h... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37494/"
] |
422,236 | <p>The intent here is to deal with obfuscated passwords for resources.</p>
<p>We have an Advisor that intercepts calls to setPassword and decrypts the argument.</p>
<p>We've set up a template that looks somewhat like this:</p>
<pre><code><bean id="pwAdvisor" class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor">
<property name="advice"><bean class="our.advice.bean.class"/></property>
<property name="mappedName" value="setPassword"/>
</bean>
<bean id="passwordHandlerTemplate" class="org.springframework.aop.framework.ProxyFactoryBean" abstract="true">
<property name="interceptorNames"><list><value>pwAdvisor</value></list></property>
</bean>
</code></pre>
<p>I'm unclear on the exact syntax to use it. The most obvious way is:</p>
<pre><code><bean id="myPasswordProtectedThing" parent="passwordHandlerTemplate">
<property name="target">
<bean class="the.target.class.name">
<property name="password" value="encrypted garbage"/>
</bean>
</property>
</bean>
</code></pre>
<p>But that doesn't work right, since the password property is applied to the inner bean, which means that the advisor won't wind up doing its work.</p>
<p>Well, what about this:</p>
<pre><code><bean id="myPasswordProtectedThing" parent="passwordHandlerTemplate">
<property name="target"><bean class="the.target.class.name"/></property>
<property name="password" value="encrypted garbage"/>
</bean>
</code></pre>
<p>Nope. Spring complains that the ProxyFactoryBean doesn't have a password property. And, of course, it doesn't. The thing that has the password property is the thing the factory bean <em>creates</em>.</p>
<p>Bueller?</p>
| [
{
"answer_id": 422852,
"author": "duffymo",
"author_id": 37213,
"author_profile": "https://Stackoverflow.com/users/37213",
"pm_score": 2,
"selected": true,
"text": "\npackage aop;\n\nimport org.springframework.context.ApplicationContext;\nimport org.springframework.context.support.ClassP... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13757/"
] |
422,241 | <p>I have two process and a shared memory zone, my workflow is like this. The process A write some data in the shared memory, after that it should wait and send a signal to other process B to start running. The process B should read some data from the shared memory do some stuff write the result, and send a signal to the process A to keep running, after this process B should wait.</p>
<p>Can anyone plese provide an example or a place where I can find how can I stop a process and how can I start running again the process?. I am working in Linux and C++. </p>
<p>I already have semaphores, but the thing that I do not like, it is that one process is stop a bunch of seconds reading all the time from the shared memory, until it detects that it can run. That's why I was thinkin only in send a signal in the right moment</p>
<p><strong>Update with the solution</strong></p>
<p>I selected the answer of stefan.ciobaca as favourite because is a complete solution that it works and it has a very good explanation. But in all of the other answers there are other interesting options.</p>
| [
{
"answer_id": 422279,
"author": "dmckee --- ex-moderator kitten",
"author_id": 2509,
"author_profile": "https://Stackoverflow.com/users/2509",
"pm_score": 2,
"selected": false,
"text": "popen (3)"
},
{
"answer_id": 422418,
"author": "Jason Day",
"author_id": 737,
"au... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39160/"
] |
422,242 | <p>Here's a piece of code to take a string (either NSString or NSAttributedString) <code>input</code> that represents a command line and parse it into two strings, the command <code>cmd</code> and the arguments <code>args</code>:</p>
<pre><code>NSString* cmd = [[input mutableCopy] autorelease];
NSString* args = [[input mutableCopy] autorelease];
NSScanner* scanner = [NSScanner scannerWithString:[input string]];
[scanner scanUpToCharactersFromSet:[NSCharacterSet
whitespaceAndNewlineCharacterSet]
intoString:&cmd];
if (![scanner scanUpToString:@"magicstring666" intoString:&args]) args = @"";
</code></pre>
<p>That seems to work but the magic string is a pretty absurd hack. Also, I'm not at all sure I'm doing things right with the autoreleases.</p>
<p>ADDED: The solution should also be robust to initial whitespace. Also, I originally had the input string called both <code>input</code> and <code>inStr</code>. Sorry for that confusion.</p>
<p>ADDED: I believe one thing the above code gets right that the answers so far don't is that args should not have any initial whitespace.</p>
| [
{
"answer_id": 422310,
"author": "Zach Langley",
"author_id": 45230,
"author_profile": "https://Stackoverflow.com/users/45230",
"pm_score": 3,
"selected": false,
"text": "int index = [input rangeOfString:@\" \"].location;\nNSString *cmd = [input substringToIndex:index]);\nNSString *args ... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4234/"
] |
422,246 | <p>I have a C# base class that I was to associate information with on a per-type (rather than per-instance) basis. Essentially I want all child classes to present an Icon and a FriendlyName that represents the type. I'd like to <em>not</em> have to create a type instance to get this information and I want to require that all child classes provide this information. Ideally it would be in the interface that the base derives from.</p>
<p>I tried to use a class Attribute, but it requires a constant value, so while I can set the FriendlyName, I can't set the Icon, and I can't see a way to make the Attribute required anyway, so child classes could get away with not having it (until run time).</p>
<p>I added a static Property to the base that children can hide, but that's kind of ugly and the values from the base are really nonsensical. It can't know what the name would be for a child. I could have the base throw in the Property, but again, that wouldn't get caught until run time.</p>
<p>Anyone have any ideas on how I might implement something like this? Is there a pattern I'm missing? Any out-of-the-box thinking is encouraged as well.</p>
<p><strong>Edit:</strong> Really what I need to the ability to require class Attributes along an inheritance tree and be able to use an embedded resource to set those attributes. All of the information that will be returned really is static and known at compile. I just can't figure out a way to nicely expose it.</p>
<p><strong>Edit 2:</strong> Here's a more concrete example of what I need:</p>
<p>Let's assume I have a base class:</p>
<pre><code>abstract class Vehicle { ... }
</code></pre>
<p>I then have two children:</p>
<pre><code>class Car : Vehicle { ... }
class Truck : Vehicle { ... }
</code></pre>
<p>I'd like to be able to get an Icon representing a "Car" or a "Truck" without having to create an instance of one (a la Car.Icon) since all vehicles of a given type will all have the same icon. </p>
<p>I also want to ensure that <em>all</em> Vehicle-derived Types expose the same way to get this Icon in case someone comes along in the future and adds a new class</p>
<pre><code>class Airplane : Vehicle { ... }
</code></pre>
<p><strong>Edit 3:</strong> Why do I need this? Well we have an app that can take plug-ins. The plug in is defined by a type, and when the type is loaded, we show the user an icon and name. When they click the icon, it creates an instance of that type (and gives them a dialog for naming the instance, etc). I don't need or want to have to create an instance of the type to get the icon.</p>
| [
{
"answer_id": 422320,
"author": "Rowland Shaw",
"author_id": 50447,
"author_profile": "https://Stackoverflow.com/users/50447",
"pm_score": 1,
"selected": false,
"text": "Car SportsCar"
}
] | 2009/01/07 | [
"https://Stackoverflow.com/questions/422246",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13154/"
] |
422,247 | <p>Does anyone know of a library to do fixed point arithmetic in Python?
Or, does anyone has sample code?</p>
| [
{
"answer_id": 67633903,
"author": "ZinGer_KyoN",
"author_id": 13838690,
"author_profile": "https://Stackoverflow.com/users/13838690",
"pm_score": 2,
"selected": false,
"text": ">>> from numfi import numfi \n>>> x = numfi(0.68751,1,6,3)\n>>> x + 1/3\nnumfi([1.125]) s7/3-r/s\n>>> np.sin(... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422247",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52568/"
] |
422,270 | <p>In Access, what is the difference between these two statements?</p>
<pre><code>DBEngine.BeginTrans
</code></pre>
<p>and</p>
<pre><code>DBEngine.Workspaces(0).BeginTrans
</code></pre>
<p>The documentation for both leads to the same place.</p>
| [
{
"answer_id": 422376,
"author": "Ryan Lundy",
"author_id": 5486,
"author_profile": "https://Stackoverflow.com/users/5486",
"pm_score": 3,
"selected": false,
"text": "DBEngine.Workspaces(0) BeginTrans EndTrans"
},
{
"answer_id": 425045,
"author": "Shane Miskin",
"author_i... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16415/"
] |
422,293 | <p>Is there a way to programatically determine the current workspace of the open sln/proj in visual studio using the TFS API? I've seen how the VersionControlServer can retreive all of the known workspaces, but is there anything I can use to tie that to what the user currently has (or doesn't have) open?</p>
| [
{
"answer_id": 5186936,
"author": "Dave Teply",
"author_id": 550257,
"author_profile": "https://Stackoverflow.com/users/550257",
"pm_score": 4,
"selected": false,
"text": "GetWorkspace VersionControlServer GetWorkspace Environment.MachineName TeamFoundationServerFactory _tfs = TeamFounda... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10976/"
] |
422,296 | <p>I want to display an image at 'true size' in my application. For that I need to know the pixel size of the display.</p>
<p>I know windows display resolution is nominally 96dpi, but for my purposes I want a better guess. I understand this information may not always be available or accurate (e.g. older CRT displays), but I imagine with the prevelance of LCD displays that this should be possible!</p>
<p>Is there a way to get the pixel size of my display?</p>
<p>Is there a way to determine if the pixel size is accurate?</p>
<p>.NET API's preferred (I couldn't find them), but Win32 is OK too, I'm happy to P/Invoke.</p>
| [
{
"answer_id": 422333,
"author": "Pyrolistical",
"author_id": 21838,
"author_profile": "https://Stackoverflow.com/users/21838",
"pm_score": 1,
"selected": false,
"text": "cos(45)*LCD_SCREEN_DIAGONAL_IN_INCHES/sqrt(HORZ_RES^2 + VERT_RES^2)\n"
},
{
"answer_id": 422360,
"author"... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31531/"
] |
422,315 | <p>So we decided to go with visual studio team foundation server for version control, etc. Getting ready to deploy today and read in installation guide:</p>
<p>"You cannot install Team Foundation Server on a domain controller or a computer that is running other server products such as Exchange Server or Host Integration Server."</p>
<p>That and other comments in the guide lead me to think ms does not want me to install tfs on anything other than a server dedicated soley to hosting tfs (ie don't put it on one of my front-end webservers or backend dc).</p>
<p>I am planning on doing a single-server deployment (mostly for simplicity). Can anyone verify that tfs has to be on a dedicated machine? If so, should I virtualize it and hang it off one of the front end machines?</p>
<p>Thanks all...</p>
| [
{
"answer_id": 422365,
"author": "Ray Booysen",
"author_id": 42124,
"author_profile": "https://Stackoverflow.com/users/42124",
"pm_score": 2,
"selected": false,
"text": " <WQL\n namespace=\"\\\\.\\root\\cimv2\"\n query=\"SELECT * FROM Win32_ComputerSystem WHERE Domain !=''\n"
}
] | 2009/01/07 | [
"https://Stackoverflow.com/questions/422315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5234/"
] |
422,327 | <p>What is the best way to test the speed of a LAMP based site, without factoring in the user's connection?</p>
<p>In other words, I have a CMS and I want to see how long it takes for PHP and MySQL to do all their work.</p>
<p>Additionally I do not have shell access to the server, it is in a shared hosting environment.</p>
| [
{
"answer_id": 422359,
"author": "ypnos",
"author_id": 21974,
"author_profile": "https://Stackoverflow.com/users/21974",
"pm_score": 3,
"selected": true,
"text": "function curtime()\n{\n $tm = explode(' ', microtime());\n return $tm[1] + $tm[0];\n}\n"
}
] | 2009/01/07 | [
"https://Stackoverflow.com/questions/422327",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46540/"
] |
422,328 | <p>Does anyone know any Firefox add-on that can show you the size of the current viewing page?</p>
| [
{
"answer_id": 422471,
"author": "John Rose",
"author_id": 46947,
"author_profile": "https://Stackoverflow.com/users/46947",
"pm_score": 4,
"selected": false,
"text": "Scripts (7 files) 82 KB (243 KB uncompressed)\n\n- http://stackoverflow.com/Content/Js/jquery.package.master.js?d=2008... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28647/"
] |
422,342 | <p>For Example:
Let's say that I want to return a <strong>view</strong> that displays a list of cars and also show a section of dealers in your area. These are two disjointed pieces of data.</p>
<p>My <strong>view</strong> inherits a list of cars like the following:</p>
<pre><code>public partial class CarLot : ViewPage<List<Cars>>
{
}
</code></pre>
<p>Now from the <strong>controller</strong> I can return the <strong>view</strong> like the following:</p>
<pre><code>return View(Model.GetCars());
</code></pre>
<p>To render this, my markup would look something like the following:</p>
<pre><code><% foreach (Car myCar in ViewData.Model)
{some html here}
%>
</code></pre>
<p>This takes care of the list of cars, but my question is, how do I handle the list of dealers? Does the <strong>view</strong> support multiple inheritance or am I going to have to hit the <strong>model</strong> again form the markup? I know it can be done that way, but am not sure if it is the best practice.</p>
| [
{
"answer_id": 422366,
"author": "John Sheehan",
"author_id": 1786,
"author_profile": "https://Stackoverflow.com/users/1786",
"pm_score": 5,
"selected": true,
"text": "public class CarLotViewModel\n{\n public List<Car> Cars { get; set; }\n public List<Dealer> NearbyDealers { get;... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47576/"
] |
422,344 | <p>In my current project, I'm producing weekly releases. I've been using the technique described in <a href="http://jebsoft.blogspot.com/2006/04/consistent-version-numbers-across-all.html" rel="noreferrer">this post</a> to keep the version numbers of all of the assemblies in my project in sync. (I don't presently have any good reason to track the assemblies' version numbers separately, though I'm sure that day will eventually come.)</p>
<p>When I push out a release, I build a new version of the installer. Unlike all of the assemblies, which can get their version numbers from a shared SolutionInfo.cs file, the version number of the installer isn't, as best I can tell, an assembly property. So my release process includes manually advancing the version number in the setup project.</p>
<p>Or, I should say, <em>usually</em> includes doing that. I'd like to turn that into something I can't screw up. I'm finding the documentation of setup and deployment projects to be surprisingly opaque (it was quite a bit harder to find out how to make it possible for the MSI to uninstall properly if the user installed it to a non-default path, which is a pretty freaking common use case to be undocumented) and have no idea if it's even possible to do this.</p>
<p>Any ideas?</p>
<p><strong>Edit:</strong></p>
<p>Just to clarify, this is a Visual Studio setup and deployment project I'm talking about.</p>
| [
{
"answer_id": 24195525,
"author": "Philip Marks",
"author_id": 2316927,
"author_profile": "https://Stackoverflow.com/users/2316927",
"pm_score": -1,
"selected": false,
"text": " \"Product\"\n {\n \"Name\" = \"8:Microsoft Visual Studio\"\n \"ProductName\" = \"...\"\n...\n ... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19403/"
] |
422,355 | <p>In trying to make my Javascript unobtrusive, I'm using <code>onLoad</code>s to add functionality to <code><input></code>s and such. With Dojo, this looks something like:</p>
<pre><code>var coolInput = dojo.byId('cool_input');
if(coolInput) {
dojo.addOnLoad(function() {
coolInput.onkeyup = function() { ... };
});
}
</code></pre>
<p>Or, approximately equivalently:</p>
<pre><code>dojo.addOnLoad(function() {
dojo.forEach(dojo.query('#cool_input'), function(elt) {
elt.onkeyup = function() { ... };
});
});
</code></pre>
<p>Has anyone written an implementation of Ruby's <a href="http://github.com/raganwald/andand/tree/master" rel="noreferrer">andand</a> so that I could do the following?</p>
<pre><code>dojo.addOnLoad(function() {
// the input's onkeyup is set iff the input exists
dojo.byId('cool_input').andand().onkeyup = function() { ... };
});
</code></pre>
<p>or</p>
<pre><code>dojo.byId('cool_input').andand(function(elt) {
// this function gets called with elt = the input iff it exists
dojo.addOnLoad(function() {
elt.onkeyup = function() { ... };
});
});
</code></pre>
| [
{
"answer_id": 422409,
"author": "ihumanable",
"author_id": 52639,
"author_profile": "https://Stackoverflow.com/users/52639",
"pm_score": 0,
"selected": false,
"text": "dojo.byId('cool_input') && dojo.byId('cool_input').whateverYouWantToDo(...);\n"
},
{
"answer_id": 422439,
"... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] |
422,379 | <p>I have a class that I am unit testing into with DUnit.
It has a number of methods some public methods and private methods.</p>
<pre><code>type
TAuth = class(TDataModule)
private
procedure PrivateMethod;
public
procedure PublicMethod;
end;
</code></pre>
<p>In order to write a unit test for this class I have to make all the methods public.</p>
<p>Is there a different way to declare the private methods so that I can still test them but they are not public?</p>
| [
{
"answer_id": 422400,
"author": "Craig Stuntz",
"author_id": 7714,
"author_profile": "https://Stackoverflow.com/users/7714",
"pm_score": 5,
"selected": true,
"text": "type\n TAuth = class(TDataModule)\n protected\n procedure MethodIWantToUnitTest;\n public\n procedure PublicMet... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17560/"
] |
422,389 | <p>I'm having problems allocating and deallocating my memory in a recursive C++ program. So without using an automatic memory management solution, I wonder if anyone can help me resolve the memory leak I am experiencing.</p>
<p>The following code essentially explains the problem (although it's a contrived example, please correct any mistakes or simplifications I've made).</p>
<p>A number class to hold the value of a number:</p>
<pre><code>class Number {
public:
Number() { value = 1; };
Number& operator + (const Number& n1) const {
Number result = value + n1.value;
return result;
};
int value;
};
</code></pre>
<p>Two functions to perform the recursion:</p>
<pre><code>Number& recurse(const Number& v1) {
Number* result = new Number();
Number one = Number();
*result = *result + recurse(one);
return *result;
}
int main(...) {
Number answer = Number();
answer = recurse(result);
}
</code></pre>
<p>As you can see the memory allocated in the recurse function is leaked, but I'm not sure where I can free up this memory from based on the nature of the recursion?</p>
| [
{
"answer_id": 422405,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 5,
"selected": true,
"text": "Number& operator + (const Number& n1) const {\n Number result = value + n1.value;\n return result;\n};\n result... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18909/"
] |
422,401 | <p>My employers website has multiple hostnames that all hit the same server and we just show different skins for branding purposes.</p>
<p>Unfortunately WCF doesn't seem to work well in this situation. </p>
<p>I've tried <a href="http://www.robzelt.com/blog/2007/01/24/WCF+This+Collection+Already+Contains+An+Address+With+Scheme+Http.aspx" rel="noreferrer">overriding the default host with a custom host factory</a>.</p>
<p>That's not an acceptable solution because it needs to work from all hosts, not just 1.</p>
<p>I've also looked at <a href="http://blogs.msdn.com/rampo/archive/2008/02/11/how-can-wcf-support-multiple-iis-binding-specified-per-site.aspx" rel="noreferrer">this blog post</a> but either I couldn't get it to work or it wasn't meant to solve my problem.</p>
<p>The error I'm getting is "This collection already contains an address with scheme http"</p>
<p>There's got to be a way to configure this, please help :)</p>
| [
{
"answer_id": 422502,
"author": "thaBadDawg",
"author_id": 48832,
"author_profile": "https://Stackoverflow.com/users/48832",
"pm_score": 4,
"selected": true,
"text": "<system.serviceModel>\n <services>\n <service name=\"ServiceName\" behaviorConfiguration=\"ServiceName.Service... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45005/"
] |
422,411 | <p>I am struggling a bit to figure this one out. </p>
<p>I'm working on an ASP.NET MVC project, using LINQ to SQL for my data layer. The database consists of 10 or so different "exceptions" tables, e.g. "Exceptions.LADM", "Exceptions.USB", "Exceptions.GPO". Basically these tables are tracking user+machine information for relaxation of various security procedures.</p>
<p>My LINQ to SQL model has been generated. I have different classes for each table available to me. However, I am not sure how to use them in controller without having to generate separate Controller Actions for each exception type. For <code>List</code> action, I want to do something like this: </p>
<pre><code>// Example Request: /Exceptions/List/ladm
// Routing: Controller = "Exceptions", Action = "List", type = "ladm"
// Controller Action:
public ActionResult List(string type)
{
string viewname = "List-" + type; // refer to "List-ladm" view.
if(type == "ladm")
{
var items = _repository.ListAllLADMExceptions();
}
return View(viewname, items);
}
</code></pre>
<p>My repository implements <code>ListAll<XXXXXX>Exceptions</code> methods for each table. Is there a way to avoid 10 different if/else statements? It looks ugly and I'm sure there is a better way that I cannot think of. May be I'm approaching it from incorrect angle.</p>
<p>Any suggestions would be welcomed.</p>
<p>Thanks.</p>
| [
{
"answer_id": 422466,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 2,
"selected": true,
"text": "object items = _repository.GetType().GetMethod(\"ListAll\"+type+\"Exceptions\")\n .Invoke(_repository,... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422411",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16522/"
] |
422,426 | <p>Does anyone know about an ORM or something similar for Delphi Win32.</p>
| [
{
"answer_id": 5932998,
"author": "menjaraz",
"author_id": 744588,
"author_profile": "https://Stackoverflow.com/users/744588",
"pm_score": 2,
"selected": false,
"text": "Dead link"
}
] | 2009/01/07 | [
"https://Stackoverflow.com/questions/422426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48705/"
] |
422,475 | <p>I'm using SQL Server 2008. My database is almost 2GB in size. 90% of it is one table (as per sp_spaceused), that I need don't for most of my work. </p>
<p>I was wondering if it was possible to take this table, and have it backed up in a separate file, allowing me to transfer the important data on a more frequent basis than this one. </p>
<p>My guess is the easiest way to do this is create a new database, create the table there, copy the table contents to the new database, drop the table relationships, drop the table, create a view pointing to the other database and use that view in my applications. </p>
<p>However, I was wondering if you had any pointers to different strategies that I may not be aware of at this point. </p>
| [
{
"answer_id": 422491,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 1,
"selected": false,
"text": "SELECT * INTO MyNewDatabase..MyTable FROM MyOldDatabase..MyTable\n"
}
] | 2009/01/07 | [
"https://Stackoverflow.com/questions/422475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20893/"
] |
422,476 | <p>Could you explain the difference between setting methods in the constructor and through prototype object? The following code shows these two ways of setting the methods - <code>say_hello</code> and <code>say_bye</code> both work fine:</p>
<pre><code>function MessageClass() {
this.say_bye = function() { alert('see ya'); };
}
MessageClass.prototype.say_hello = function() { alert('hello'); };
x = new MessageClass();
x.say_hello();
x.say_bye();
</code></pre>
| [
{
"answer_id": 422535,
"author": "Prestaul",
"author_id": 5628,
"author_profile": "https://Stackoverflow.com/users/5628",
"pm_score": 6,
"selected": true,
"text": "function MessageClass() {\n var self = this;\n this.clickHander = function(e) { self.someoneClickedMe = true; };\n\n ... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34134/"
] |
422,486 | <p>Perhaps I'm missing something with the concept of Extension Methods, but I cannot gain access to the Extension Methods within the KeyCollection Class as defined here: <a href="http://msdn.microsoft.com/en-us/library/dk7e2d8e.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/dk7e2d8e.aspx</a>.</p>
<p>Using the following code excerpt:</p>
<pre><code> Dictionary<int, int> foo = new Dictionary<int,int>();
foo.Add(1,1);
Dictionary<int, int>.KeyCollection kc = foo.Keys;
</code></pre>
<p>I can only gain access to the "standard" KeyCollection methods (CopyTo, Equals, Finalize, etc) but cannot gain access to the extension methods (Aggregate, All, Any, etc). </p>
<p>Any help would be greatly appreciated! Thank you!</p>
| [
{
"answer_id": 422494,
"author": "Tamas Czinege",
"author_id": 8954,
"author_profile": "https://Stackoverflow.com/users/8954",
"pm_score": 4,
"selected": true,
"text": "using System.Linq;\n"
},
{
"answer_id": 422496,
"author": "Ray Booysen",
"author_id": 42124,
"autho... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52653/"
] |
422,530 | <p>I have a pair of shell programs that talk over a named pipe. The reader creates the pipe when it starts, and removes it when it exits.</p>
<p>Sometimes, the writer will attempt to write to the pipe between the time that the reader stops reading and the time that it removes the pipe.</p>
<pre><code>reader: while condition; do read data <$PIPE; do_stuff; done
writer: echo $data >>$PIPE
reader: rm $PIPE
</code></pre>
<p>when this happens, the writer will hang forever trying to open the pipe for writing.</p>
<p>Is there a <strong>clean</strong> way to give it a timeout, so that it won't stay hung until killed manually? I know I can do</p>
<pre><code>#!/bin/sh
# timed_write <timeout> <file> <args>
# like "echo <args> >> <file>" with a timeout
TIMEOUT=$1
shift;
FILENAME=$1
shift;
PID=$$
(X=0; # don't do "sleep $TIMEOUT", the "kill %1" doesn't kill the sleep
while [ "$X" -lt "$TIMEOUT" ];
do sleep 1; X=$(expr $X + 1);
done; kill $PID) &
echo "$@" >>$FILENAME
kill %1
</code></pre>
<p>but this is kind of icky. Is there a shell builtin or command to do this more cleanly (without breaking out the C compiler)?</p>
| [
{
"answer_id": 422792,
"author": "Norman Ramsey",
"author_id": 41661,
"author_profile": "https://Stackoverflow.com/users/41661",
"pm_score": 1,
"selected": false,
"text": "timeout #!/bin/ksh\n\n# our watchdog timeout in seconds\nmaxseconds=\"$1\"\nshift\n\ncase $# in\n 0) echo \"Usage: ... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
422,536 | <p>I'm just learning ruby and trying to understand the scope of code executed in blocks. For example, I want to be able to create a block that affects the method that it is attached to, like so:</p>
<pre><code>def test(&block)
block.call() if block_given?
puts "in test, foo is #{foo}"
puts "in test, bar is #{bar}"
end
test() {
foo="this is foo"
bar="this is bar"
}
</code></pre>
<p>In this case I don't want to have to modify the block at all -- I want to be able to write it using simple variable references and no parameters. <i>Only by making changes to the 'test' method in the above example</i>, is it possible to access the variables defined in the block?</p>
<p>Again, the goal is to leave the block unmodified, but be able to access the created variables from within 'test' after the block executes.</p>
| [
{
"answer_id": 422564,
"author": "krusty.ar",
"author_id": 43981,
"author_profile": "https://Stackoverflow.com/users/43981",
"pm_score": 5,
"selected": true,
"text": "block.call() yield &block def test()\n foo = yield if block_given?\n puts \"in test, foo is #{foo}\"\nend\n\ntest() {\n... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7432/"
] |
422,542 | <p>I'm trying to create a feature that both creates a list template and an instance of that list (using the <code><ListTemplate</code>> and <code><ListInstance</code>> elements. I would like for content approval to be turned on by default. According to the <a href="http://msdn.microsoft.com/en-us/library/ms462947.aspx" rel="nofollow noreferrer">docs on ListTemplate</a>, setting the EnableModeration attribute to TRUE should do it. However, when I try to install the solution, I get the following error:</p>
<blockquote>
<p>The 'EnableModeration' attribute is
invalid - The value 'TRUE' is invalid
according to its datatype
'<a href="http://schemas.microsoft.com/sharepoint/:TrueFalseMixed" rel="nofollow noreferrer">http://schemas.microsoft.com/sharepoint/:TrueFalseMixed</a>'
- The Enumeration constraint failed.</p>
</blockquote>
<p>A bit more searching reveals that the value accepted is actually "True", not "TRUE". That installs fine, but it seems to have no effect when the list is created - it still doesn't require content approval. Any idea what I'm doing wrong?</p>
<p>Edit: If anyone could even confirm for me if they've seen "True" or "TRUE" work before, that would at least narrow down my search.</p>
<p>Update: I've found that I can enable content approval using code in a feature receiver:</p>
<pre><code>list.EnableModeration = true;
list.Update();
</code></pre>
<p>That's a bit of a hack, so it'd still be nice to be able to do this through the XML instead.</p>
| [
{
"answer_id": 9430625,
"author": "Tschareck",
"author_id": 1145368,
"author_profile": "https://Stackoverflow.com/users/1145368",
"pm_score": 0,
"selected": false,
"text": "ListInstance <ListTemplate> VersioningEnabled=\"TRUE\" EnableModeration=\"True\""
}
] | 2009/01/07 | [
"https://Stackoverflow.com/questions/422542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21957/"
] |
422,553 | <p>How do you go about creating an instance of an object when given the class name as a string in an ASP.NET v2 application? For example, I've got a class called SystemLog defined in the app_code section of the application. The class is defined within the Reports namespace. To create an instance of the object, I do something like this:</p>
<p>Dim MyObject As New Global.Reports.SystemLog</p>
<p>However, I want to create this object using a string to define the type. The type name is stored in a SQL database as a string. I thinks it's probably something to do with Activator.CreateInstance(AssemblyName, TypeName) but what I don't know is what to pass in those strings. What is the assembly name of an ASP.NET web app?</p>
<p>Help!</p>
<p>Thanks, Rob.</p>
<p>PS. I don't want a hard coded Select statement :-)</p>
| [
{
"answer_id": 422572,
"author": "Ray Booysen",
"author_id": 42124,
"author_profile": "https://Stackoverflow.com/users/42124",
"pm_score": 4,
"selected": true,
"text": "string typeName = \"Your Type Name Here\";\nType t = Type.GetType(typeName);\nobject o = Activator.CreateInstance(t);\n... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18128/"
] |
422,586 | <p>I have two tables in a DataSet where the ID field on each is the same. I have a Relation between the two tables. How do I, in C# code, pull the info from Table2 that relates to the info on Table1?</p>
<p>I have tried using a new DataRow and assigning it by using GetChildRow, but for some reason I cannot seem to make it work.</p>
<p>Also, I understand this question may not be that informative, let me know and I will try to provide more clarification.</p>
| [
{
"answer_id": 424896,
"author": "Matt",
"author_id": 19802,
"author_profile": "https://Stackoverflow.com/users/19802",
"pm_score": 0,
"selected": false,
"text": "currentDataSet.GroupTableOneRow.Clear();\ncurrentDataSet.GroupAttendingEventTable[groupAttendingEventCounter].GetGroupTableRo... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19802/"
] |
422,594 | <p>I have some expressions such as <code>x^2+y^2</code> that I'd like to use for some math calculations. One of the things I'd like to do is to take partial derivatives of the expressions.</p>
<p>So if <code>f(x,y) = x^2 + y^2</code> then the partial of <code>f</code> with respect to <code>x</code> would be <code>2x</code>, the partial with respect to <code>y</code> would be <code>2y</code>.</p>
<p>I wrote a dinky function using a finite differences method but I'm running into lots of problems with floating point precision. For example, I end up with <code>1.99234</code> instead of <code>2</code>. Are there any libraries that support symbolic differentiation? Any other suggestions?</p>
| [
{
"answer_id": 423305,
"author": "j_random_hacker",
"author_id": 47984,
"author_profile": "https://Stackoverflow.com/users/47984",
"pm_score": 1,
"selected": false,
"text": "x * x + y * y struct proto::eval() proto::eval()"
},
{
"answer_id": 15372915,
"author": "Ian",
"au... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14059/"
] |
422,597 | <p>is there a way to hide columns of a buffer (text file, you know what I mean) while editing it in Vim? e.g. text visible in the buffer before hiding column 2&3:</p>
<pre><code>abbcccccc
accdddddd
</code></pre>
<p>And after hiding them:</p>
<pre><code>acccccc
adddddd
</code></pre>
<p>(Not to mention I'm working with really huge files (sometimes over 200 gb).)</p>
<p>And yeah, I had found foldcol.vim, but it requires a patch, and I don't have gcc to compile it as a user on a server.</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 41376825,
"author": "serup",
"author_id": 3990012,
"author_profile": "https://Stackoverflow.com/users/3990012",
"pm_score": 2,
"selected": false,
"text": "\" set the runtime path to include Vundle and initialize \nset rtp+... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11621/"
] |
422,600 | <p>Is there a canonical or recommended pattern for implementing arithmetic operator overloading in C++ number-like classes?</p>
<p>From the C++ FAQ, we have an exception-safe assignment operator that avoids most problems:</p>
<pre><code>class NumberImpl;
class Number {
NumberImpl *Impl;
...
};
Number& Number::operator=(const Number &rhs)
{
NumberImpl* tmp = new NumberImpl(*rhs.Impl);
delete Impl;
Impl = tmp;
return *this;
}
</code></pre>
<p>But for other operators (+, +=, etc..) very little advice is given other than to make them behave like the operators on built-in types.</p>
<p>Is there a standard way of defining these? This is what I've come up with - are there pitfalls I'm not seeing?</p>
<pre><code>// Member operator
Number& Number::operator+= (const Number &rhs)
{
Impl->Value += rhs.Impl->Value; // Obviously this is more complicated
return *this;
}
// Non-member non-friend addition operator
Number operator+(Number lhs, const Number &rhs)
{
return lhs += rhs;
}
</code></pre>
| [
{
"answer_id": 422690,
"author": "wilhelmtell",
"author_id": 456,
"author_profile": "https://Stackoverflow.com/users/456",
"pm_score": 2,
"selected": false,
"text": "operator+(const T&) operator-(const T&) operator+=(const T&) operator-=(const T&) operator+(Number, const Number&) std::co... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8701/"
] |
422,608 | <p>I have a UITextField in a view (on an iPhone) but the input text appears very small. I don't see an option in Interface Builder to set the size.</p>
<p>Is there a way to set it declaratively or do I have to resort to code?</p>
| [
{
"answer_id": 422670,
"author": "Genericrich",
"author_id": 39932,
"author_profile": "https://Stackoverflow.com/users/39932",
"pm_score": 4,
"selected": false,
"text": " myUITextField.font = [UIFont systemFontOfSize:12.0f];\n"
}
] | 2009/01/07 | [
"https://Stackoverflow.com/questions/422608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35958/"
] |
422,625 | <p>I have a method that I'm writing that is calling another overloaded method inside it. I'd like to only write one outer method, since the parameter to the outer method is being passed to the inner one. Is there a way to do this?</p>
<p>I tried using generics, but I don't know enough about this so it isn't working:</p>
<pre><code>public void OuterMethod<T>(T parameter)
{
InnerMethod(parameter); // InnerMethod accepts an int or a string
}
</code></pre>
<p>I know that I can do this:</p>
<pre><code>public void OuterMethod(string parameter)
{
InnerMethod(parameter);
}
public void OuterMethod(int parameter)
{
InnerMethod(parameter);
}
</code></pre>
<p>But I'd rather do this the right way instead of copying/pasting code. What's the best way to accomplish this?</p>
| [
{
"answer_id": 422668,
"author": "ChrisW",
"author_id": 49942,
"author_profile": "https://Stackoverflow.com/users/49942",
"pm_score": 3,
"selected": true,
"text": "public void OuterMethod(object parameter)\n{\n if (parameter is int)\n InnerMethod((int)parameter);\n else if (... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422625",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16320/"
] |
422,632 | <p>I understand that the WITH RECOMPILE option forces the optimizer to rebuild the query plan for stored procs but when would you want that to happen?</p>
<p>What are some rules of thumb on when to use the WITH RECOMPILE option and when not to?</p>
<p>What's the effective overhead associated with just putting it on every sproc?</p>
| [
{
"answer_id": 422685,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 4,
"selected": false,
"text": "sp_executesql WITH RECOMPILE OPTIMIZE FOR OPTIMIZE FOR UNKNOWN"
},
{
"answer_id": 422698,
"author": "Ian V... | 2009/01/07 | [
"https://Stackoverflow.com/questions/422632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12424/"
] |
422,713 | <p>I'm working on a script that sadly I inherited - with no commenting or anything. Argh!
For testing purposes I duplicated one of the tables in the database which had an auto-incrementing ID. When the data is saved to the database, though, the ID number just reads "0" -- which is the default for that column. I'm not sure why it's not auto increasing anymore... any thoughts? Thank you!</p>
| [
{
"answer_id": 422716,
"author": "Eran Galperin",
"author_id": 10585,
"author_profile": "https://Stackoverflow.com/users/10585",
"pm_score": 2,
"selected": false,
"text": " ALTER TABLE `duplicate_table` CHANGE `ai_key` `ai_key` INT( key_length ) NOT NULL AUTO_INCREMENT \n"
},
{
... | 2009/01/08 | [
"https://Stackoverflow.com/questions/422713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
422,738 | <p>I'm trying to use the CRT memory leak detection but I keep getting the following message in Microsoft Visual Studio: "Detected memory leaks - skipping object dump." I can never get the it to actually do and object dump.</p>
<p>I followed the directions in the Microsoft article on Memory Leak Detection (<a href="http://msdn.microsoft.com/en-us/library/e5ewb1h3(VS.80).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/e5ewb1h3(VS.80).aspx</a>) with no luck.</p>
<p>In my stdafx.h I have (rebuilt the entire project):</p>
<pre><code>#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
</code></pre>
<p>In the entry point of my application I have:</p>
<pre><code>_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
</code></pre>
<p>I'm also hoping that it will display the file name and line number in the Microsoft advertised format:</p>
<pre><code>Detected memory leaks!
Dumping objects ->
C:\PROGRAM FILES\VISUAL STUDIO\MyProjects\leaktest\leaktest.cpp(20) : {18}
normal block at 0x00780E80, 64 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
Object dump complete.
</code></pre>
<p>While I've NEVER been able to even get an object dump, but I've noticed that other people say they see something along these lines (even with _CRTDBG_MAP_ALLOC defined):</p>
<pre><code>Detected memory leaks!
Dumping objects ->
{18} normal block at 0x00780E80, 64 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
Object dump complete.
</code></pre>
<p>I don't really want to spend time overriding the new and delete operators, so I was hoping that the CRT debugging would help me. If this doesn't work out I might end up overriding the new and delete operators, but I really want to get the allocation information with a file name and line number (crosses fingers).</p>
<p>Thanks,
Kiril</p>
| [
{
"answer_id": 424007,
"author": "MSalters",
"author_id": 15416,
"author_profile": "https://Stackoverflow.com/users/15416",
"pm_score": 1,
"selected": false,
"text": "new __FILE__ __LINE__. new __FILE__ __LINE__"
}
] | 2009/01/08 | [
"https://Stackoverflow.com/questions/422738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28760/"
] |
422,743 | <p>What is the best design for a punch in/out table?</p>
<p>Would you store the punch in/out in the same table or separate tables? Why?</p>
<p><strong>Edit</strong> - Hourly employees punch in at the beginning of their shift and punch out at the end of their shift. Hourly - Exempt employees must punch out/in for lunch in addition to the in/out at the beginning/end of the day.</p>
| [
{
"answer_id": 422764,
"author": "Joe Phillips",
"author_id": 20471,
"author_profile": "https://Stackoverflow.com/users/20471",
"pm_score": 1,
"selected": false,
"text": "Table name: Sessions\nColumns : ID, UserID, Timestamp_IN, Timestamp_OUT\n"
},
{
"answer_id": 64940398,
... | 2009/01/08 | [
"https://Stackoverflow.com/questions/422743",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50612/"
] |
422,747 | <p>I'm interested in speed, not good looking code, that is why I'm using array and not list(of integer).</p>
<p>I have an array looking like: 0,1,0,1,1,0,1,0,1,1,1,0,0,1</p>
<p>I'm interesting in the position of each number so I can later pick one randomly.</p>
<p>so what I do is looping through the array to take position number of each 1 then creating a new array looking like this: 2,4,5,7,9,10,11,14</p>
<p>is bitwise could be used here? I have no idea</p>
<p>code look like:</p>
<pre><code>Private Function theThing() As Integer()
Dim x As Integer
'arIn() would be a parameter
Dim arIn() As Integer = {0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1}
Dim ar() As Integer = Nothing
Dim arCount As Integer = -1
For x = 1 To arIn.GetUpperBound(0)
If arIn(x) = 1 Then
arCount += 1
End If
Next
If arCount > -1 Then
'using redim preseve is slower than the loop above
ReDim ar(arCount)
arCount = 0
For x = 1 To arIn.GetUpperBound(0)
If arIn(x) = 1 Then
ar(arCount) = x
arCount += 1
End If
Next
End If
Return ar
End Function
</code></pre>
<p><strong>* EDIT *</strong> </p>
<p>current solution(10% to 15% faster) is now</p>
<pre><code>Private Function theThing() As Integer
Dim ar() As Integer = {0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1}
Dim arLenght As Integer = ar.GetUpperBound(0)
Dim arCount As Integer = 0
Dim x As Integer
For x = 1 To arLenght
If ar(x) = 1 Then
ar(arCount) = x
arCount += 1
End If
Next
dim r As New Random()
Return ar(r.Next(arCount))
End Function
</code></pre>
<p>I don't think it can be optimized more than that, unless someone find a way to do exactly what the solution does but way faster</p>
<p>Before this question, my whole thing was able to do about 25500 run each 10 seconds.</p>
<p>Now, it can do over 32250 all the time, a 21% increase, thanks!</p>
| [
{
"answer_id": 422765,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 3,
"selected": false,
"text": "oldArray = [0, 1, 1, 0, 1]\nnewValue = 22 (binary 10110)\n is position 2 set?\nvalue: 10110\n4 (2^2): 00100\nresult: ... | 2009/01/08 | [
"https://Stackoverflow.com/questions/422747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40868/"
] |
422,768 | <p>When writing plugins for media center your plugin is hosted in <code>ehexthost.exe</code> this exe gets launched from <code>ehshell.exe</code> and you have no way of launching it directly, instead you pass a special param to <code>ehshell.exe</code> which will launch the plugin in a separate process.</p>
<p>When we are debugging <a href="http://code.google.com/p/videobrowser/source/checkout" rel="noreferrer">media browser</a> I find the process of attaching to a second process kind of clunky, I know about Debugger.Attach and also of some <a href="http://msdn.microsoft.com/en-us/library/a329t4ed.aspx" rel="noreferrer">special registry</a> entries I can use.</p>
<p>Both these methods don't exactly fit my bill. What I want is to press F5 and have my current instance of visual studio attach to the child process automatically. Can this be done? </p>
<p>If there is a plugin for VS that allows me to achieve this functionality I would be happy with it. </p>
<p><strong>EDIT</strong></p>
<p>I ended up going with the following macro: </p>
<pre><code>Public Sub CompileRunAndAttachToEhExtHost()
DTE.Solution.SolutionBuild.Build(True)
DTE.Solution.SolutionBuild.Debug()
Dim trd As System.Threading.Thread = New System.Threading.Thread(AddressOf AttachToEhExtHost)
trd.Start()
End Sub
Public Sub AttachToEhExtHost()
Dim i As Integer = 0
Do Until i = 50
i = i + 1
Try
For Each proc As EnvDTE.Process In DTE.Debugger.LocalProcesses
If (proc.Name.IndexOf("ehexthost.exe") <> -1) Then
proc.Attach()
Exit Sub
End If
Next
Catch e As Exception
' dont care - stuff may be busy
End Try
Threading.Thread.Sleep(100)
Loop
End Sub
</code></pre>
<p>Also, I outlined the process on how to <a href="http://www.samsaffron.com/archive/2009/01/28/Simpler+debugging+of+Vista+Media+Center+plugins" rel="noreferrer">get this going</a> on my blog. </p>
| [
{
"answer_id": 483815,
"author": "Jab",
"author_id": 29676,
"author_profile": "https://Stackoverflow.com/users/29676",
"pm_score": 6,
"selected": true,
"text": " For Each process In DTE.Debugger.LocalProcesses\n If (process.Name.IndexOf(\"aspnet_wp.exe\") <> -1) Then\n ... | 2009/01/08 | [
"https://Stackoverflow.com/questions/422768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17174/"
] |
422,774 | <p>I have a function inside a class that returns a reference to a member variable.</p>
<pre><code>std::vector<uint8> & getBuffer() const
{
return m_myBuffer;
}
</code></pre>
<p>Now say in another class I call this method:</p>
<pre><code>int someFunction()
{
std::vector<uint8> myFileBuffer = myFile.getBuffer();
}
</code></pre>
<p>This line calls the copy constructor of vector and makes me a local buffer. I do not want this, how can I instead set myFileBuffer to reference the myFile.getBuffer().</p>
<p>I know I can do this via pointers but wanted to use references if it is possible.</p>
<p>Thanks.</p>
| [
{
"answer_id": 422782,
"author": "ChrisW",
"author_id": 49942,
"author_profile": "https://Stackoverflow.com/users/49942",
"pm_score": 2,
"selected": false,
"text": "std::vector<uint8>& myFileBuffer = myFile.getBuffer();\n std::vector<uint8> myFileBuffer = myFile.getBuffer();\n"
},
{
... | 2009/01/08 | [
"https://Stackoverflow.com/questions/422774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52704/"
] |
422,783 | <p>Ive no problems using Javascript to read the rows of a telerik radgrid component im using however I can seem to find anyway to access the row data server side when a postback occurs. Ive spent ages looking for solution but no luck.
Any pointers would be greatly appreciated.</p>
<p>Tony</p>
| [
{
"answer_id": 620566,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "GridItemCollection gridRows = TestGrid.Items;\nforeach (GridDataItem data in gridRows)\n{\n ItemClass obj = (ItemClass)data... | 2009/01/08 | [
"https://Stackoverflow.com/questions/422783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51630/"
] |
422,784 | <p>In the code below I'm trying to load some images and put them in the stage as soon as they get individually loaded. But it is bugged since only the last image is displayed. I suspect it's a closure problem. How can I fix it? Isn't the behaviour of closures in AS3 the same as in Java Script ?</p>
<pre><code>var imageList:Array = new Array();
imageList.push({'src':'image1.jpg'});
imageList.push({'src':'image2.jpg'});
var imagePanel:MovieClip = new MovieClip();
this.addChildAt(imagePanel, 0);
for (var i in imageList) {
var imageData = imageList[i];
imageData.loader = new Loader();
imageData.loader.contentLoaderInfo.addEventListener(
Event.COMPLETE,
function() {
imagePanel.addChild(imageData.loader.content as Bitmap);
trace('Completed: ' + imageData.src);
});
trace('Starting: ' + imageData.src);
imageData.loader.load(new URLRequest(imageData.src));
}
</code></pre>
| [
{
"answer_id": 423073,
"author": "bobince",
"author_id": 18936,
"author_profile": "https://Stackoverflow.com/users/18936",
"pm_score": 7,
"selected": true,
"text": "function makeCallback(imageData) { return function() {\n imagePanel.addChild(imageData.loader.content as Bitmap);\n t... | 2009/01/08 | [
"https://Stackoverflow.com/questions/422784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47883/"
] |
422,828 | <p>My table has data like so</p>
<pre><code> products_parent_id | products_quantity
2 5
2 7
2 9
2 4
</code></pre>
<p>My SQL statement looks like so (so far):</p>
<pre><code>UPDATE ' . TABLE_PRODUCTS . ' SET products_quantity = products_quantity +' . $order['products_quantity'] . ', products_ordered = products_ordered - ' . $order['products_quantity'] . ' WHERE products_parent_id = ' . (int)$order['products_id']
</code></pre>
<p>Now what I want to do, is update only say the 3rd occurrence of products_parent_id (in this case, 3rd from the top is 9)</p>
<p>To SELECT the 3rd occurrence, I used this at the end of my statements LIMIT($grade, 1)</p>
<p>Is there a way to UPDATE using MySQL but only the 3rd/4th/etc occurrence? Will it be reliable?</p>
<p>Thank you</p>
| [
{
"answer_id": 422908,
"author": "Charles Bretana",
"author_id": 32632,
"author_profile": "https://Stackoverflow.com/users/32632",
"pm_score": 0,
"selected": false,
"text": " Update Table T Set\n Col = value \n Where (Select Count(*) From Table \n Where products_quantity... | 2009/01/08 | [
"https://Stackoverflow.com/questions/422828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31671/"
] |
422,830 | <p>If I have a class as follows</p>
<pre><code> class Example_Class
{
private:
int x;
int y;
public:
Example_Class()
{
x = 8;
y = 9;
}
~Example_Class()
{ }
};
</code></pre>
<p>And a struct as follows</p>
<pre><code>struct
{
int x;
int y;
} example_struct;
</code></pre>
<p>Is the structure in memory of the <code>example_struct</code> simmilar to that in <code>Example_Class</code></p>
<p>for example if I do the following</p>
<pre><code>struct example_struct foo_struct;
Example_Class foo_class = Example_Class();
memcpy(&foo_struct, &foo_class, sizeof(foo_struct));
</code></pre>
<p>will <code>foo_struct.x = 8</code> and <code>foo_struct.y = 9</code> (ie: the same values as the x,y values in the foo_class) ?</p>
<p>The reason I ask is I have a C++ library (don't want to change it) that is sharing an object with C code and I want to use a struct to represent the object coming from the C++ library. I'm only interested in the attributes of the object.</p>
<p>I know the ideal situation would be to have Example_class wrap arround a common structure between the C and C++ code but it is not going to be easy to change the C++ library in use.</p>
| [
{
"answer_id": 422953,
"author": "Mike Thompson",
"author_id": 2754,
"author_profile": "https://Stackoverflow.com/users/2754",
"pm_score": 0,
"selected": false,
"text": "struct ReallyAClass\n{\n ReallyAClass();\n virtual !ReallAClass();\n\n /// etc etc etc\n};\n"
},
{
"a... | 2009/01/08 | [
"https://Stackoverflow.com/questions/422830",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42303/"
] |
422,837 | <p>I'd rather do this:</p>
<pre><code>say $shop->ShopperDueDate->andand->day_name();
</code></pre>
<p>vs. this:</p>
<pre><code>say $shop->ShopperDueDate->day_name() if $shop->ShopperDueDate;
</code></pre>
<p>Any ideas?</p>
<p>(This idea is inspired by the Ruby <a href="http://andand.rubyforge.org/" rel="nofollow noreferrer">andand</a> extension.)</p>
<p>(Actually it is inspired by the Groovy language, but most people don't know that ;-)</p>
<p><strong>update</strong>: I think that both maybe() and eval {} are good solutions. This isn't ruby so I can't expect to read all of the methods/functions from left to right anyway, so maybe could certainly be a help. And then of course eval really is the perl way to do it.</p>
| [
{
"answer_id": 422905,
"author": "pjf",
"author_id": 19422,
"author_profile": "https://Stackoverflow.com/users/19422",
"pm_score": 3,
"selected": false,
"text": "eval eval {\n say $shop->ShopperDueDate->day_name();\n};\n eval undef my $day_name = eval { $shop->ShopperDueDate->day_name... | 2009/01/08 | [
"https://Stackoverflow.com/questions/422837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12448/"
] |
422,840 | <p>What i want is to take an integer represented as a string, for example "1234", and convert it to a file called int, containing a 32-bit big endian integer, with the value 1234.</p>
<p>The only way I have figured out to do this is something like</p>
<pre><code>echo 1234 | awk '{printf "0: %08X", $1}' | xxd -r > int
</code></pre>
<p>which is a bit nasty!</p>
<p>Does anyone know a better way?</p>
| [
{
"answer_id": 422859,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 3,
"selected": false,
"text": "printf \"0: %08X\" 1234 | xxd -r > int\n"
},
{
"answer_id": 422882,
"author": "Community",
"author_id": -1... | 2009/01/08 | [
"https://Stackoverflow.com/questions/422840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11084/"
] |
422,847 | <p>The only thing I don't have an automated tool for when working with SQL Server is a program that can create <code>INSERT INTO</code> scripts. I don't desperately need it so I'm not going to spend money on it. I'm just wondering if there is anything out there that can be used to generate INSERT INTO scripts given an existing database without spending lots of money.</p>
<p>I've searched through SQL Server Management Studio Express with no luck in finding such a feature. If it exists in SSMSE then I've never found it.</p>
| [
{
"answer_id": 422857,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 5,
"selected": true,
"text": "sp_msforeachtable Tasks –> Generate Scripts Tasks –> Generate Scripts Next Advanced Next"
},
{
"answer_id": 857... | 2009/01/08 | [
"https://Stackoverflow.com/questions/422847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392/"
] |
422,848 | <p>The java.library.path property appears to be read-only. For example when you run ant on the following buildfile</p>
<pre><code><project name="MyProject" default="showprops" basedir=".">
<property name="java.library.path" value="test"/>
<property name="some.other.property" value="test1"/>
<target name="showprops">
<echo>java.library.path=${java.library.path}</echo>
<echo>some.other.property=${some.other.property}</echo>
</target>
</project>
</code></pre>
<p>you get</p>
<pre><code>> ant -version
Apache Ant version 1.6.5 compiled on June 2 2005
> ant -Djava.library.path=commandlinedefinedpath
Buildfile: build.xml
showprops:
[echo] java.library.path=commandlinedefinedpath
[echo] some.other.property=test1
BUILD SUCCESSFUL
Total time: 0 seconds
</code></pre>
<p>The output indicates that the <strong>java.library.path</strong> hasn't been changed, but <strong>some.other.property</strong> was set correctly. </p>
<p>I would like to know how to modify the java.library.path within a buildfile. Specifying the java.library.path on the ant command line is not really an easy option, because the library path location is not know at that time.</p>
<p>Note: I would like this to work so that I can specify the location of native libraries used in a unit test. </p>
| [
{
"answer_id": 674411,
"author": "flicken",
"author_id": 12880,
"author_profile": "https://Stackoverflow.com/users/12880",
"pm_score": 0,
"selected": false,
"text": "<?xml version=\"1.0\"?>\n <project name=\"example\" default=\"run\">\n <taskdef name=\"groovy\"\n classname=\"org... | 2009/01/08 | [
"https://Stackoverflow.com/questions/422848",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10814/"
] |
422,865 | <p>I'm using a DataGridView in my WinForms application. My main objective is to make the Enter key not move to the next row in the grid. I still want the enter key to validate and end edit mode.</p>
<p>I found <a href="http://social.msdn.microsoft.com/forums/en-US/winformsdatacontrols/thread/a44622c0-74e1-463b-97b9-27b87513747e/#faq9" rel="noreferrer">this FAQ entry</a> and subclassed DataGridView to override ProcessDialogKey(). If the key pressed is Enter, I call EndEdit(), otherwise I call base.ProcessDialogKey().</p>
<p>It works great, except the CellValidating event isn't fired.</p>
<p>Currently, I'm just manually calling my validation logic before I call EndEdit, but it seems like I'm missing something.</p>
<p>I guess I could call OnCellValidating, but then I'd be worried I'm missing some other event. What I really want is some flavour of EndEdit() that behaves just like pressing enter on the last row of a grid with adding disabled.</p>
| [
{
"answer_id": 813771,
"author": "JJO",
"author_id": 99141,
"author_profile": "https://Stackoverflow.com/users/99141",
"pm_score": 5,
"selected": true,
"text": " protected override bool ProcessDialogKey(Keys keyData)\n {\n if (keyData == Keys.Enter)\n {\n D... | 2009/01/08 | [
"https://Stackoverflow.com/questions/422865",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4794/"
] |
422,902 | <p>As probably many people around here I read a few webcomics. <a href="http://www.drowtales.com" rel="nofollow noreferrer">Drowtales</a> is my favorite, but that's besides the point.</p>
<p>For a long time a thought has been nagging me at the back of my head: webcomics are drawn pictures. They are not photographs. There should be a lot of redundancy (less colors, more flat colored areas, etc.) and thus they should be easily compressible at quite high rates while still maintaining lossless quality. Still it seems that the best tool to compress them is the same old lossy JPEG.</p>
<p>How so? Are there not better things invented? I'm not an expert in data compression, so my own meager attempts at finding some better algorithm have been fruitless. Best I could find was <a href="http://pmt.sourceforge.net/pngcrush/" rel="nofollow noreferrer">Pngcrush</a>, but it still is way behind JPEG in terms of compression.</p>
<p>I would like to hear an expert opinion on this. Is this idea of mine foolish and doomed to failure? Or is there perhaps some way that people have found or that I could look into?</p>
<p>This, of course, comes from the selfish desire to decrease load times. :)</p>
<p><strong>Added:</strong> Some people seem to miss the point, so I'll clarify:</p>
<p>Webcomic images should have a lot of redundancy in them so they should be easily compressible. <strong>Is it not possible to somehow compress them so that they would be both lossless AND smaller than JPEG?</strong> Or at the very least compress them better than JPEG while still retaining the quality.</p>
<p>Since they would be for <strong>web</strong> the specialized compressor should still probably emit PNG or JPEG - just compressed with a modified algorithm for better results.</p>
| [
{
"answer_id": 422983,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "jpegtran -optimise pngnq optipng -i0"
},
{
"answer_id": 423033,
"author": "Norman Ramsey",
"author_id": 41661,... | 2009/01/08 | [
"https://Stackoverflow.com/questions/422902",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41360/"
] |
422,903 | <p>I need to access the crypto functions of OpenSSL to encode Blowfish data in a CBC streams. I've googled and found some Blowfish libraries (hand written) and some OpenSSL wrappers (none of the seem complete.)</p>
<p>In the end, I need to access the certain OpenSSL functions, such as the full blowfish.h library of <a href="http://www.openssl.org/docs/crypto/blowfish.html" rel="nofollow noreferrer">commands</a>. What's the pythonic/right way of accessing them? Using something like SWIG to allow Python/C bindings, or is there a better way?</p>
<p>Thanks!</p>
| [
{
"answer_id": 521542,
"author": "joeforker",
"author_id": 36330,
"author_profile": "https://Stackoverflow.com/users/36330",
"pm_score": 3,
"selected": false,
"text": "import M2Crypto\nfrom M2Crypto import EVP\nimport base64\nimport struct\n\nkey = '0' * 16 # security FTW\niv = '' # init... | 2009/01/08 | [
"https://Stackoverflow.com/questions/422903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35335/"
] |
422,929 | <p>Whenever I use Html.ActionLink it always Html encodes my display string. For instance I want my link to look like this:</p>
<pre><code><a href="/posts/422/My-Post-Title-Here">More&hellip;</a>
</code></pre>
<p>it outputs like this: <a href="/posts/422/My-Post-Title-Here">More&hellip;</a></p>
<p>&hellip is "..." incase you were wondering.</p>
<p>However the actionlink outputs the actual text "&hellip;" as the link text. I have the same problem with if I want to output this:</p>
<pre><code><a href="/posts/422/My-Post-Title-Here"><em>My-Post-Title-Here</em></a>
</code></pre>
<p>I wind up with:
<a href="/posts/422/My-Post-Title-Here"><em>My-Post-Title-Here</em></a></p>
<p>Any idea how to do this?</p>
| [
{
"answer_id": 422968,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 7,
"selected": true,
"text": "<a href='@Url.Action(\"Posts\", ...)'>More…</a>\n @Html.ActionLink(HttpUtility.HtmlDecode(\"More…\"), \"Po... | 2009/01/08 | [
"https://Stackoverflow.com/questions/422929",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17744/"
] |
422,932 | <p>When I retrieve any Scalar value from the database, I usually write code like this for nullable fields.</p>
<pre><code>cmd.ExecuteScalar() == DBNull.Value ? 0 : (int)cmd.ExecuteScalar()
</code></pre>
<p>But I don't like it because it executes the Executescalar statement twice. It's an extra trip to the server for my website and in favor of performance I don't want to do this.</p>
<p>Is there any way I can get rid of this extra ExecuteScalar()?</p>
| [
{
"answer_id": 422937,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 4,
"selected": false,
"text": "var o = cmd.ExecuteScalar();\nreturn o == DBNull.Value ? 0 : (int)o;\n"
},
{
"answer_id": 422939,
"author": ... | 2009/01/08 | [
"https://Stackoverflow.com/questions/422932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33052/"
] |
422,940 | <p>I am trying to do simple tutorial in Visual Studio
let someNumber = (2 + 2)
print_int someNumber
but it says print_int is undefined. printfn works.
Could the book I'm using be outdated? </p>
| [
{
"answer_id": 2314960,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "#r \"FSharp.PowerPack.Compatibility.dll\";;\n#nowarn \"62\";;\n"
}
] | 2009/01/08 | [
"https://Stackoverflow.com/questions/422940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2636656/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.