qid int64 4 19.1M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
430,188 | <p>I'm trying to learn more about db interactions which has me developing a local app to get started. Well, basically, what I've done so far has had some mixed results and I've changed so much stuff I'm not even sure what I've change at this point, lol. I'm not quite sure one of my tables was correct, so I've decided to just start that over. Here's what I want my silly local app to do.</p>
<ul>
<li>Store up to 9 specific RSS feeds (I did url/links before but I don't want to get confused by anything I did before so I'm changing it to RSS feeds)</li>
<li>1 feed will be populated by default (so every user has that one common feed - which they can change)</li>
<li>Feeds should be stored in some ordering scheme so they can be retrieved/printed in the same order they were entered in.</li>
</ul>
<p>There will be an edit screen with 9 text fields, populated by corresponding db entries, so something like:</p>
<pre><code>feed 1: <input type="text" value="http://rss.news.yahoo.com/rss/topstories"> **the default feed for everyone, but they can change it**
feed 2: <input type="text" value="http://content.usatoday.com">
feed 3: <input type="text" value="http://newsrss.bbc.co.uk/rss/newsonl.../world/rss.xml">
feed 4: <input type="text" value="">
feed 5: <input type="text" value="">
feed 6: <input type="text" value="">
feed 7: <input type="text" value="">
feed 8: <input type="text" value="">
feed 9: <input type="text" value="">
<input type="submit" value="update">
</code></pre>
<p>I want to be able to edit/add new feeds here and retrieve those feeds in the same order - this was a big source of my confusion in my prior attempt.</p>
<p>There will be an output screen which outputs the feed URLs in the same order.</p>
<p>I have 2 tables, <strong>users</strong> and now <strong>feeds</strong>, I believe my users table is fine, it basically stores a little personal information. I think everthing there should be pretty obvious. The 'state' column is going to store a 2-character state abbreviation from a select/dropdown and I've indexed it as I'd like to be able to search for users by state. I'm not having any issues retrieving/editing/updating that data.</p>
<pre><code>CREATE TABLE users (
user_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
first_name VARCHAR(20) NOT NULL,
last_name VARCHAR(40) NOT NULL,
state CHAR(2) NOT NULL,
email VARCHAR(60) NOT NULL,
pass CHAR(32) NOT NULL,
registration_date DATETIME NOT NULL,
PRIMARY KEY(user_id),
UNIQUE (email),
INDEX login (email, pass),
INDEX state (state)
);
</code></pre>
<p>Here's my new feeds table</p>
<pre><code>CREATE TABLE feeds (
user_id SMALLINT UNSIGNED NOT NULL,
feed_url VARCHAR(255) NOT NULL DEFAULT 'http://rss.news.yahoo.com/rss/topstories',
feed_id SMALLINT UNSIGNED NOT NULL DEFAULT 1,
PRIMARY KEY(user_id, feed_url)
);
</code></pre>
<p>When a user enters a new feed, let's say for feed #2, the value would be inserted into feed_url and feed_id would be inserted with a value of <strong>2</strong>. If feed #3 is entered, feed_id would be inserted with a value of <strong>3</strong>. That should give me something to ORDER BY to retrieve records in order, right?</p>
<p><strong>The data edit screen should always display the feeds how they were entered.<br>
The data output screen should always display the feeds how they were entered.</strong></p>
<p>So, does this look proper and am I missing some things? My feed_url VARCHAR(255) might not be foolproof but I'm only going to be testing with short urls. It could always be easily bumped up, too.</p>
| [
{
"answer_id": 485180,
"author": "Rob Williams",
"author_id": 26682,
"author_profile": "https://Stackoverflow.com/users/26682",
"pm_score": 0,
"selected": false,
"text": "feeds users feeds feed_id feed_id feed_sequence users email pass pass CHAR VARCHAR CHAR feedUrl1 feedUrl9"
}
] | 2009/01/09 | [
"https://Stackoverflow.com/questions/430188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
430,226 | <p>I need to poll a web service, in this case twitter's API, and I'm wondering what the conventional wisdom is on this topic. I'm not sure whether this is important, but I've always found feedback useful in the past.</p>
<p>A couple scenarios I've come up with:</p>
<ol>
<li><p>The querying process starts every X seconds, eg a cron job runs a python script</p></li>
<li><p>A process continually loops and queries at each iteration, eg ... well, here is where I enter unfamiliar territory. Do I just run a python script that doesn't end?</p></li>
</ol>
<p>Thanks for your advice.</p>
<p>ps - regarding the particulars of twitter: I know that it sends emails for following and direct messages, but sometimes one might want the flexibility of parsing @replies. In those cases, I believe polling is as good as it gets.</p>
<p>pps - twitter limits bots to 100 requests per 60 minutes. I don't know if this also limits web scraping or rss feed reading. Anyone know how easy or hard it is to be whitelisted?</p>
<p>Thanks again.</p>
| [
{
"answer_id": 430258,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 3,
"selected": false,
"text": "import time\npolling_interval = 36.0 # (100 requests in 3600 seconds)\nrunning= True\nwhile running:\n start= time.clock... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
430,237 | <p>Is it possible to use JavaScript to open an HTML select to show its option list?</p>
| [
{
"answer_id": 1489537,
"author": "Phil",
"author_id": 180753,
"author_profile": "https://Stackoverflow.com/users/180753",
"pm_score": 5,
"selected": false,
"text": "opacity=.01 opacity=100"
},
{
"answer_id": 1545498,
"author": "Jason de Belle",
"author_id": 187382,
"... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] |
430,256 | <p>Does .net have a way to determine whether the local filesystem is case-sensitive?</p>
| [
{
"answer_id": 430265,
"author": "M4N",
"author_id": 19635,
"author_profile": "https://Stackoverflow.com/users/19635",
"pm_score": 5,
"selected": true,
"text": "string file = Path.GetTempPath() + Guid.NewGuid().ToString().ToLower();\nFile.CreateText(file).Close();\nbool isCaseInsensitive... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2338/"
] |
430,264 | <p>Given an enum that has assigned values, what is the best way to get the next or previous enum given a value. For example, consider this enum:</p>
<pre><code>public enum TimeframeType {
None = 0,
[Description("1 month")]
Now = 30,
[Description("1-3 months")]
Short = 90,
[Description("3-6 months")]
Medium = 180,
[Description("6+ months")]
Long = 360
}
</code></pre>
<p>Is there a good way create a function that would do EnumPrevious(TimeframeType.Short) returns TimeframeType.Now and EnumNext(TimeframeType.Short) would return TimeframeType.Medium?</p>
<p>I already wrote an ugly implementation of EnumNext but I'm not convinced that it is the best way to do so. I'm hoping someone else has already tackled this problem.</p>
<pre><code>public static T EnumNext<T>(T value) where T : struct {
T[] values = (T[])Enum.GetValues(typeof(T));
int i;
for (i = 0; i < values.Length; i++) {
if (object.Equals(value, values[i])) {
break;
}
}
if (i >= values.Length - 1) {
return values[values.Length - 1];
} else {
return values[i + 1];
}
}
</code></pre>
| [
{
"answer_id": 430267,
"author": "Jimmy McNulty",
"author_id": 53523,
"author_profile": "https://Stackoverflow.com/users/53523",
"pm_score": 4,
"selected": true,
"text": "public class TimeFrame: IComparable\n{\n private int days;\n\n public int Days\n {\n set \n {\n ... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40161/"
] |
430,274 | <p>Found the following in an Oracle-based application that we're migrating <em>(generalized)</em>:</p>
<pre><code>SELECT
Table1.Category1,
Table1.Category2,
count(*) as Total,
count(Tab2.Stat) AS Stat
FROM Table1, Table2
WHERE (Table1.PrimaryKey = Table2.ForeignKey(+))
GROUP BY Table1.Category1, Table1.Category2
</code></pre>
<p>What does <code>(+)</code> do in a WHERE clause? I've never seen it used like that before.</p>
| [
{
"answer_id": 430291,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 5,
"selected": false,
"text": "(+) OUTER JOIN OUTER JOIN SELECT\n Table1.Category1,\n Table1.Category2,\n COUNT(*) AS Total,\n COUNT(Tabl... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15031/"
] |
430,280 | <p>Any idea how to render a PDF using iTextSharp so that it renders the page using CSS. The css can either be embedded in the HTML or passed in separately, I don't really care, just want it to work. </p>
<p>Specific code examples would be <em>greatly</em> appreciated.</p>
<p>Also, I would really like to stick with iTextSharp, though if you do have suggestions for something else, it's got to be free, open source, and have a license that permits using it in commercial software.</p>
| [
{
"answer_id": 430544,
"author": "lubos hasko",
"author_id": 275,
"author_profile": "https://Stackoverflow.com/users/275",
"pm_score": 4,
"selected": true,
"text": "<table> iTextSharp.SimpleTable"
},
{
"answer_id": 34415793,
"author": "Noureddine HALA",
"author_id": 57072... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430280",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/194/"
] |
430,282 | <p>I am looking into captive portals for my organization. I see a lot of them out there that will allow a user to pass once they a.)enter credentials or b.)pay money. What I'm looking for is a bit different. Let me go into some basics about my system, I am running a windows based network using active directory and an internal DNS. I have an intranet in which our employees use daily and it uses the person's Windows credentials to authenticate them on the system. </p>
<p>The employees have to enter time daily, and if they don't then I would like to have a captive portal redirect them to their time entry page and not let them out into the vast internet world until their time is entered. </p>
<p>I am a developer so I can write a script that returns a True or False to the system, but what I need is a system that can interact with AD logons and that can run this script once a user requests access outside out network.</p>
<p><strong>EDIT:</strong>
I accepted an answer as the answer to my question, however, after looking into the coding for the sockets based method I do not have the time. </p>
<p>as a workaround, I have found that my firewall has a customizable disclaimer page that allows javascript. I will query a webservice to see if time is entered then trigger the disclaimer page's "Allow" function, otherwise i will redirect to the time entry page. seems like a simple enough solution, the only issue is if the person keeps their browser session open overnight.</p>
| [
{
"answer_id": 430544,
"author": "lubos hasko",
"author_id": 275,
"author_profile": "https://Stackoverflow.com/users/275",
"pm_score": 4,
"selected": true,
"text": "<table> iTextSharp.SimpleTable"
},
{
"answer_id": 34415793,
"author": "Noureddine HALA",
"author_id": 57072... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48450/"
] |
430,313 | <p>Consider the following snippet:</p>
<pre><code> using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
namespace ForumLogins {
public class VBULLETIN {
HttpWebRequest request;
public void ForumLogins(string url) {
request = (HttpWebRequest)WebRequest.Create(url);
}
}
}
</code></pre>
<p>According to MSDN the "Create" method can return 4 exceptions. Now I cant dissolve those exceptions.. because well otherwise the class wont function. But what should I do? Should I still wrap it in a try/catch block? and in the catch "throw a new exception".. or let the person who implments this class handle the exceptions? </p>
<p>Cuz this is a constructor .. and I guess constructors arnt really supposed to fail? </p>
| [
{
"answer_id": 430331,
"author": "JoshBerke",
"author_id": 26160,
"author_profile": "https://Stackoverflow.com/users/26160",
"pm_score": 1,
"selected": false,
"text": "try\n{\n if (string.isNullOrEmpty(url))\n {\n //This will stop the arugment null exception and you can throw a ... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50312/"
] |
430,314 | <p>I have table rows of data in html being filled from a CGI application. I want each row to have a check box next to it so I can delete multiple rows, just like in gmail. </p>
<p>I figured out the basic text form and was able to send it to the CGI program to delete the row, but I don't want to have to type in the row name to delete a single file at a time. </p>
<p>What does the code look like on both sides (html-browser and C-CGI app) for forms when you can select multiple deletions through check boxes? Is there an example somewhere? (I am limited to JS and HTML but I think JS is for validation anyway, don't need that right now. C coding on the CGI app side.) </p>
<p>Thank You. </p>
| [
{
"answer_id": 430331,
"author": "JoshBerke",
"author_id": 26160,
"author_profile": "https://Stackoverflow.com/users/26160",
"pm_score": 1,
"selected": false,
"text": "try\n{\n if (string.isNullOrEmpty(url))\n {\n //This will stop the arugment null exception and you can throw a ... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52256/"
] |
430,324 | <p>I'm looking over my syllabus for my theoretical computer science class and within the heading of Context Free Grammars it lists "closure properties". I have looked through my textbook on this subject and found quite little. The little it does have is a bit above my head at the moment (I haven't taken the course yet) but I understand a little.</p>
<p>I was wondering if this idea of closures within context free grammars is the same as or related to the idea of closures within functional programming. It talks about combining grammars and resolving overlaps as far as I can tell. There are a lot of parts to the section within the book I don't understand yet, so I'm unsure about whether these ideas are the same.</p>
<p>(A little more context: I'm writing an email to the professor asking if the course can be switched to Ruby or Python from Perl. If these concepts are related, that could be another reason we should use Ruby over Perl.)</p>
| [
{
"answer_id": 430343,
"author": "Darius Bacon",
"author_id": 27024,
"author_profile": "https://Stackoverflow.com/users/27024",
"pm_score": 3,
"selected": false,
"text": "def adder(n): return lambda m: n + m\n"
},
{
"answer_id": 430451,
"author": "joel.neely",
"author_id"... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34235/"
] |
430,326 | <pre><code>$story_query = "SELECT table_name, id FROM planning WHERE parent = '$novelnum'";
$story_result = db_query($story_query);
while($story_row = db_fetch_array($story_result)) {
$taleTable_Name = $story_row['table_name'];
$postid[] = $story_row['id'];
$q2 = "Select * from $taleTable_Name where approved='Y' order by id";
$bset2 = db_query($q2);
while($rset2 = db_fetch_array($bset2)) {
$i[] = $rset2['id'];
$t[] = $rset2['thread'];
$s[] = $rset2['subject'];
$a[] = $rset2['author'];
$d[] = $rset2['datestamp'];
}
}
if(isset($d)) {
$fc = count($d);
if($fc > 20) {
$xs = $fc - 20;
}
else {
$xs = 0;
}
for($c=$xs;$c<$fc;$c++) {
if($s[$c] != "") {
$newpost .= $d[$c];
$newpost .= " <a href='../forums/read.php?f=";
$newpost .= end($postid);
$newpost .= "&i=";
$newpost .= $i[$c];
$newpost .= "&t=";
$newpost .= $t[$c];
$newpost .= "'>" ;
$newpost .= $s[$c];
$newpost .= "</a> by ";
$newpost .= $a[$c];
$newpost .= $taleTable_Name;
$newpost .= "<br>\n";
}
}
}
else {
$newpost = "There are no posts for this scroll yet.";
}
</code></pre>
<p>The above code correctly presents me with all the entries found with $taleTable_Name, but only presents the last variable of $postid when I print $newpost. I want the id ($postid to match the table_name ($taleTable_Name) so that the url created actually goes to the correct forum.</p>
| [
{
"answer_id": 430532,
"author": "George Stocker",
"author_id": 16587,
"author_profile": "https://Stackoverflow.com/users/16587",
"pm_score": 2,
"selected": false,
"text": "$story_query = \"SELECT table_name, id FROM planning WHERE parent = '$novelnum'\";\n$story_result = db_query($story... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
430,330 | <p>I have an enumeration for Status for a Task. Some of the statuses are considered obsolete, and I have marked them as obsolete, as seen below:</p>
<pre><code>public enum TaskStatus
{
[Description("")]
NotSet = 0,
Pending = 1,
Ready = 2,
Open = 3,
Completed = 4,
Closed = 5,
[Description("On Hold")][Obsolete]
OnHold = 6,
[Obsolete]
Canceled = 7
}
</code></pre>
<p>In my user interface I populate a drop down with values on the enumerations, but I want to ignore ones that are marked as obsolete. How would I got about doing this?</p>
| [
{
"answer_id": 430341,
"author": "Cristian Libardo",
"author_id": 16526,
"author_profile": "https://Stackoverflow.com/users/16526",
"pm_score": 3,
"selected": true,
"text": "var availableTaks = typeof (TaskStatus).GetFields(BindingFlags.Static | BindingFlags.GetField | BindingFlags.Publi... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1768/"
] |
430,346 | <p>Why doesn't Java include support for unsigned integers? </p>
<p>It seems to me to be an odd omission, given that they allow one to write code that is less likely to produce overflows on unexpectedly large input. </p>
<p>Furthermore, using unsigned integers can be a form of self-documentation, since they indicate that the value which the unsigned int was intended to hold is never supposed to be negative. </p>
<p>Lastly, in some cases, unsigned integers can be more efficient for certain operations, such as division. </p>
<p>What's the downside to including these?</p>
| [
{
"answer_id": 430754,
"author": "starblue",
"author_id": 49246,
"author_profile": "https://Stackoverflow.com/users/49246",
"pm_score": 4,
"selected": false,
"text": "int long long BigInteger long int short byte"
},
{
"answer_id": 6850755,
"author": "Jyro117",
"author_id"... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23903/"
] |
430,349 | <p>When the source of an iframe is:</p>
<pre><code>javascript:'';
</code></pre>
<p>as in:</p>
<pre><code><iframe id="SpControlFrame1" name="SpControlFrame1" src="javascript:'';" path_src="index.php?cmd=YYY" ></iframe>
</code></pre>
<p>What is going on? What does the src="javascript:'';" tell the browser to do?</p>
<p>what does the "path_src" do?</p>
<p>Thanks
Chris</p>
| [
{
"answer_id": 430359,
"author": "Ates Goral",
"author_id": 23501,
"author_profile": "https://Stackoverflow.com/users/23501",
"pm_score": 5,
"selected": true,
"text": "javascript:'http://stackoverflow.com'; void() javascript:void(window.open(\"dom_spy.html\"))\n javascript:(function () {... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29505/"
] |
430,358 | <p>I now have it set up so that when people go to a "thank you" page after filling out a form, they go to a page that says: </p>
<pre><code> thanks for coming <a href="<?php echo $_SERVER['HTTP_REFERER'] ?>here's a link back to where you came from</a>
</code></pre>
<p>What I want is for it to say:</p>
<pre><code> thanks for coming <a href="<?php echo $_SERVER['HTTP_REFERER'] ?>here's a link back to <?php echo TITLE OF REFERRING PAGE ?></a>
</code></pre>
<p>Is there a simple way to do this?</p>
| [
{
"answer_id": 430372,
"author": "Rob Allen",
"author_id": 149,
"author_profile": "https://Stackoverflow.com/users/149",
"pm_score": 3,
"selected": true,
"text": "<?php\n\n $_Session[\"referrerTitle\"] = $pageTitle;\n\n ?>\n <p> thanks for coming <a href=\"<?= $_SERVER['HTTP_REFERER']... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43035/"
] |
430,388 | <p>We have a modem terminal application written in VB6. It works great for what we need it to do, but there is a new requirement to initiate a VPN connection when dialing a particular provider. I've looked over some related posts and it looks like this may be possible using the RAS API. Can anyone suggest resources/advice for working with this API beyond MSDN?</p>
<p>Difficulty - .NET is not an option. </p>
| [
{
"answer_id": 436600,
"author": "Jeremy",
"author_id": 19174,
"author_profile": "https://Stackoverflow.com/users/19174",
"pm_score": 2,
"selected": true,
"text": "USAGE:\n rasdial entryname [username [password|*]] [/DOMAIN:domain]\n [/PHONE:phonenumber] [/CALLBACK:... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430388",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23114/"
] |
430,401 | <p>Anyone have a link to what the C++ standard says regarding a compiler removing global and static symbols? I thought you weren't guaranteed that the compiler will remove global symbols if they're not referenced. A colleague of mine asserts that if your global symbols are included in the main translation unit, those symbols will not be removed even if they're not referenced. </p>
| [
{
"answer_id": 430947,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 0,
"selected": false,
"text": "main 3.6.2p3 3.7.1p2 3.2p2 1.9p7"
}
] | 2009/01/10 | [
"https://Stackoverflow.com/questions/430401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45459/"
] |
430,403 | <p>I have a localization issue.</p>
<p>One of my industrious coworkers has replaced all the strings throughout our application with constants that are contained in a dictionary. That dictionary gets various strings placed in it once the user selects a language (English by default, but target languages are German, Spanish, French, Portuguese, Mandarin, and Thai).</p>
<p>For our test of this functionality, we wanted to change a button to include text which has a ñ character, which appears both in Spanish and in the Arial Unicode MS font (which we're using throughout the application).</p>
<p>Problem is, the ñ is appearing as a square block, as if the program did not know how to display it. When I debug into that particular string being read from disk, the debugger reports that character as a square block as well.</p>
<p>So where is the failure? I think it could be in a few places:</p>
<p>1) Notepad may not be unicode aware, so the ñ displayed there is not the same as what vs2008 expects, and so the program interprets the character as a square (EDIT: notepad shows the same characters as vs; ie, they both show the ñ. In the same place.).</p>
<p>2) vs2008 can't handle ñ. I find that very, very hard to believe.</p>
<p>3) The text is read in properly, but the default font for vs2008 can't display it, which is why the debugger shows a square.</p>
<p>4) The text is not read in properly, and I should use something other than a regular StreamReader to get strings.</p>
<p>5) The text is read in properly, but the default String class in C# doesn't handle ñ well. I find that very, very hard to believe.</p>
<p>6) The version of Arial Unicode MS I have doesn't have ñ, despite it being listed as one of the 50k characters by <a href="http://www.fileinfo.info" rel="nofollow noreferrer">http://www.fileinfo.info</a>.</p>
<p>Anything else I could have left out?</p>
<p>Thanks for any help!</p>
| [
{
"answer_id": 430511,
"author": "scottm",
"author_id": 53007,
"author_profile": "https://Stackoverflow.com/users/53007",
"pm_score": 1,
"selected": false,
"text": "using(StreamReader sr = new StreamReader(File.Open(\"file.txt\", FileMode.Open), Encoding.UTF8))\n{\n// add your string to ... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21981/"
] |
430,413 | <p>Compiling a file that uses OpenGL with Visual C++, when I try to include the gl.h header file I get about 150 unhelpful compile errors:</p>
<p>error C2144: syntax error : 'void' should be preceded by ';'</p>
<p>error C4430: missing type specifier - int assumed. Note: C++ does not support default-int</p>
<p>error C2146: syntax error : missing ';' before identifier 'glAccum'</p>
<p>etc.</p>
| [
{
"answer_id": 430433,
"author": "Ates Goral",
"author_id": 23501,
"author_profile": "https://Stackoverflow.com/users/23501",
"pm_score": 2,
"selected": false,
"text": "extern \"C\" {\n#include \"gl.h\"\n}\n"
},
{
"answer_id": 430628,
"author": "Rob Kennedy",
"author_id":... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53602/"
] |
430,424 | <p>I would like to detect whether the OS I'm compiling on is Windows. Is there a simple macro I can check to verify that?</p>
| [
{
"answer_id": 430435,
"author": "Phil Hord",
"author_id": 33342,
"author_profile": "https://Stackoverflow.com/users/33342",
"pm_score": 6,
"selected": true,
"text": "__WIN32__ #if defined (__WIN32__)\n // Windows stuff\n#endif\n _WIN32 __CYGWIN32__ _MSC_VER #define g++ -D __WIN32__ you... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430424",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53602/"
] |
430,439 | <p>I have a PHP file which I have used mod rewrite to make a .jpg extension. I want to grab an image from a url</p>
<p>example: <a href="http://msn.com/lol.gif" rel="nofollow noreferrer">http://msn.com/lol.gif</a></p>
<p>take the data and then display it in my .jpg with jpeg headers, so as far as the user is concerned it is a normal image. Is this possible and if so can anyone give me some pointers?</p>
| [
{
"answer_id": 430563,
"author": "Luis Melgratti",
"author_id": 17032,
"author_profile": "https://Stackoverflow.com/users/17032",
"pm_score": 2,
"selected": false,
"text": "header('Content-type: image/jpeg');\n$pic = imagecreatefromgif($url);\nImagejpeg($pic);\nImageDestroy($pic);\n head... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26823/"
] |
430,446 | <p>I have been trying to learn how to use eclipse for J2ee web development and have heard alot of great things about it. I have had a lot of success my self When starting a project from scratch and building everything within the eclipse work space. This was all fun and games however. </p>
<p>For part of my job, I am part of a team that builds web application with it's own well defined directory structure that has been in existence for many years. Lots of hooks in the build script depend on the directory structure, as well as source repository. </p>
<p>We have been using IDEa for a long time but the version is quite outdated, </p>
<p>I would like to leave the directory structure alone but be able to take advantage of some of the newer features available in eclipse. However, my very newbie impression of eclipse seems that eclipse is insistent you that you play by it's rules, import everything to it's workspace, and bend to it's will. I've been able to linking source folders for strict java development, but I have had no such luck with a dynamic web project. </p>
<p>I am sure I've missed something, and am hoping someone will point me at a decent tutorial to solve my problems as I would really like to get over my IDEa dependence for code assistence with J2EE develpoment. </p>
| [
{
"answer_id": 430563,
"author": "Luis Melgratti",
"author_id": 17032,
"author_profile": "https://Stackoverflow.com/users/17032",
"pm_score": 2,
"selected": false,
"text": "header('Content-type: image/jpeg');\n$pic = imagecreatefromgif($url);\nImagejpeg($pic);\nImageDestroy($pic);\n head... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
430,458 | <p>I want to format an int as a currency in C#, but with no fractions. For example, 100000 should be "$100,000", instead of "$100,000.00" (which 100000.ToString("C") gives).</p>
<p>I know I can do this with 100000.ToString("$#,0"), but that's $-specific. Is there a way to do it with the currency ("C") formatter?</p>
| [
{
"answer_id": 11755397,
"author": "Suraj Shrestha",
"author_id": 1448795,
"author_profile": "https://Stackoverflow.com/users/1448795",
"pm_score": 1,
"selected": false,
"text": "using System.Globalization\n@string.Format(new CultureInfo(\"en-IN\"), \"{0:c}\", moneyvalue)\n"
}
] | 2009/01/10 | [
"https://Stackoverflow.com/questions/430458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53607/"
] |
430,479 | <p>Suppose I have this in C++:</p>
<pre><code>void test(int &i, int &j)
{
++i;
++j;
}
</code></pre>
<p>The values are altered inside the function and then used outside. How could I write a code that does the same in Java? I imagine I could return a class that encapsulates both values, but that seems really cumbersome.</p>
| [
{
"answer_id": 430491,
"author": "Bombe",
"author_id": 43582,
"author_profile": "https://Stackoverflow.com/users/43582",
"pm_score": 3,
"selected": false,
"text": "public void test(int[] values) {\n ++values[0];\n ++values[1];\n}\n"
},
{
"answer_id": 430496,
"author": "... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
430,485 | <h2>The issue</h2>
<p>I have a <code><div></code> on a page which is initially hidden with a <code>visibility: hidden; position: absolute</code>. The issue is that if a <code><div></code> hidden this way contains a table which uses <code>border-collapse: collapse</code> and has a border set on it cells, that border still shows "through" the hidden <code><div></code> on IE.</p>
<p>Try this for yourself by running the code below on IE6 or IE7. You should get a white page, but instead you will see:</p>
<p><a href="http://img.skitch.com/20090110-enuxpb5aduqceush46dyuf4wk7.png">alt text http://img.skitch.com/20090110-enuxpb5aduqceush46dyuf4wk7.png</a></p>
<h2>Possible workaround</h2>
<p>Since this is happening on IE and not on other browsers, I assume that this is an IE bug. One workaround is to add the following code which will override the border:</p>
<pre><code>.hide table tr td {
border: none;
}
</code></pre>
<p>I am wondering:</p>
<ul>
<li>Is this a known IE bug?</li>
<li>Is there a more elegant solution/workaround?</li>
</ul>
<h2>The code</h2>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style type="text/css">
/* Style for tables */
.table tr td {
border: 1px solid gray;
}
.table {
border-collapse: collapse;
}
/* Class used to hide a section */
.hide {
visibility: hidden;
position: absolute;
}
</style>
</head>
<body>
<div class="hide">
<table class="table">
<tr>
<td>Gaga</td>
</tr>
</table>
</div>
</body>
</html>
</code></pre>
| [
{
"answer_id": 680429,
"author": "jthompson",
"author_id": 76514,
"author_profile": "https://Stackoverflow.com/users/76514",
"pm_score": 2,
"selected": false,
"text": "display: none;\n"
},
{
"answer_id": 1713215,
"author": "avernet",
"author_id": 5295,
"author_profile... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5295/"
] |
430,499 | <p>I would like to make a display object fullscreen in my Flex application. I understand it is easy to make the complete Stage fullscreen in flex <a href="http://blog.flexexamples.com/2007/08/07/creating-full-screen-flex-applications/" rel="nofollow noreferrer">(example)</a>. But I have two charts on my Stage and I would like to make one of the charts full screen on clicking a button (or on double clicking on the chart area) and as per my understanding a ColumnChart is a DisplayObject <a href="http://livedocs.adobe.com/flex/3/langref/mx/charts/ColumnChart.html" rel="nofollow noreferrer">(API reference)</a>.</p>
<p>Is it possible to do so? and if it is possible then please post the code snippet.</p>
<p>Thanks</p>
| [
{
"answer_id": 431535,
"author": "ForYourOwnGood",
"author_id": 48728,
"author_profile": "https://Stackoverflow.com/users/48728",
"pm_score": 0,
"selected": false,
"text": "\nprivate var myLeftColumnChart : ColumnChart;\nprivate var myRightColumnChart : ColumnChart;\n\nprivate function o... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20301/"
] |
430,525 | <p>I've looked all over the <a href="http://haxe.org/" rel="nofollow noreferrer">Haxe</a> Flash Command-line compiler website but was unable to find any detailed <strong>documentation of the <a href="http://haxe.org/doc/start/flash" rel="nofollow noreferrer">HXML files</a></strong> <em>(scroll down to the "Changing SWF properties" section)</em> which describe the compile.</p>
<p>Anybody know of a reference <a href="http://haxe.org/wiki/search?s=HXML" rel="nofollow noreferrer">source?</a></p>
<hr>
<p>Found HXML:</p>
<ul>
<li><strong>-swf</strong> MyApp.swf .... <em>Compile to SWF</em></li>
<li><strong>-main</strong> MyAppClass .... <em>Entry-point Class (.AS file)</em></li>
<li><strong>-swf-header</strong> 200:300:25:FFFFFF .... <em>Width:Height:FPS:BackColor (of SWF)</em></li>
</ul>
<hr>
<p><strong>Edit:</strong> Scroll down for my answer with the <strong>complete list</strong> of commands.</p>
| [
{
"answer_id": 430939,
"author": "artificialidiot",
"author_id": 7988,
"author_profile": "https://Stackoverflow.com/users/7988",
"pm_score": 4,
"selected": true,
"text": "haxe --help\n"
},
{
"answer_id": 36089523,
"author": "Mihail Ignatiev",
"author_id": 2823972,
"au... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41021/"
] |
430,538 | <p>I'm trying to set the editing style property of a UITableViewCell in a Cocoa Touch (iPhone) app. </p>
<p>For an example of what this looks like, check out the Contacts app, where you can see the little green plus sign to the left of some of the cells. </p>
<p>The UITableViewCell inspector in Interface Builder has an editing style drop down, but it doesn't seem to do anything. </p>
<p>Likewise there is a CodeSense completion of an undocumented method called -setEditingStyle: for a UITableViewCell that doesn't seem to work either. </p>
<p>Is this a setting in the table view data source? Has anyone outside of Apple gotten this to work?</p>
| [
{
"answer_id": 430558,
"author": "Frank Schmitt",
"author_id": 27951,
"author_profile": "https://Stackoverflow.com/users/27951",
"pm_score": 6,
"selected": true,
"text": "- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexP... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27951/"
] |
430,548 | <p>Here is my code:</p>
<pre><code>records_hash = records[:id].inject({}) { |result,h|
if result.has_key?(h)
result[h] += 1
else
result[h] = 1
end
result
}
@test2 = records_hash.each{|key,value| puts "#{key} is #{value}"}
</code></pre>
<p>My output should look like this:</p>
<pre><code>bozo is 3
bubba is 4
bonker is 5
</code></pre>
<p>But it renders on the page (<code><%= @test2 %></code>) as this:</p>
<pre><code>bozo3bubba4bonker5
</code></pre>
<p>I've tried .each_key & .each-value with similar blocks and they all return the same string above. I run the same code in IRB and it works as expected.</p>
<p>What am I doing wrong?</p>
| [
{
"answer_id": 430552,
"author": "Matt Haley",
"author_id": 14142,
"author_profile": "https://Stackoverflow.com/users/14142",
"pm_score": 1,
"selected": false,
"text": "puts @test2 = \"\"\n@test2 = records_hash.each { |k,v| s<< \"#{k} is #{v}\" }\n @test2 .each"
},
{
"answer_id":... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32154/"
] |
430,554 | <p>When I cut and paste from a Word document into VIM, quotes get translated into a-circumflex followed by <99>, where the <99> is a single byte representation. (Which I know because when I move to it, typing a single 'l' moves me right to the over all four characters).</p>
<p>I want to do search and replace, and I know enough to find the a-cirumflex digraph using control-K a>, but I can't figure out how to search for the <99>, and searching for the literal /<99> doesn't work.</p>
<p>So I really have two questions: </p>
<p>What help topic should I consult in vim to learn about what sort of a beast the <99> is (since it doesn't seem to be a digraph) (or maybe it IS a digraph and I'm missing something)?</p>
<p>How do I search for a single character represented by <99>?</p>
| [
{
"answer_id": 430566,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 6,
"selected": true,
"text": "ga"
}
] | 2009/01/10 | [
"https://Stackoverflow.com/questions/430554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10888/"
] |
430,555 | <p>After many years of hearing about Vertex Buffer Objects (VBOs), I finally decided to experiment with them (my stuff isn't normally performance critical, obviously...)</p>
<p>I'll describe my experiment below, but to make a long story short, I'm seeing indistinguishable performance between "simple" direct mode (glBegin()/glEnd()), vertex array (CPU side) and VBO (GPU side) rendering modes. I'm trying to understand why this is, and under what conditions I can expect to see the VBOs significantly outshine their primitive (pun intended) ancestors.</p>
<h2>Experiment Details</h2>
<p>For the experiment, I generated a (static) 3D Gaussian cloud of a large number of points. Each point has vertex & color information associated with it. Then I rotated the camera around the cloud in successive frames in sort of an "orbiting" behavior. Again, the points are static, only the eye moves (via gluLookAt()). The data are generated once prior to any rendering & stored in two arrays for use in the rendering loop. </p>
<p>For direct rendering, the entire data set is rendered in a single glBegin()/glEnd() block with a loop containing a single call each to glColor3fv() and glVertex3fv().</p>
<p>For vertex array and VBO rendering, the entire data set is rendered with a single glDrawArrays() call.</p>
<p>Then, I simply run it for a minute or so in a tight loop and measure average FPS with the high performance timer.</p>
<h2>Performance Results ##</h2>
<p>As mentioned above, performance was indistinguishable on both my desktop machine (XP x64, 8GB RAM, 512 MB Quadro 1700), and my laptop (XP32, 4GB ram, 256 MB Quadro NVS 110). It did scale as expected with the number of points, however. Obviously, I also disabled vsync.</p>
<p>Specific results from laptop runs (rendering w/GL_POINTS):</p>
<p>glBegin()/glEnd():</p>
<ul>
<li>1K pts --> 603 FPS</li>
<li>10K pts --> 401 FPS</li>
<li>100K pts --> 97 FPS</li>
<li>1M pts --> 14 FPS </li>
</ul>
<p>Vertex Arrays (CPU side):</p>
<ul>
<li>1K pts --> 603 FPS</li>
<li>10K pts --> 402 FPS</li>
<li>100K pts --> 97 FPS</li>
<li>1M pts --> 14 FPS</li>
</ul>
<p>Vertex Buffer Objects (GPU side):</p>
<ul>
<li>1K pts --> 604 FPS</li>
<li>10K pts --> 399 FPS</li>
<li>100K pts --> 95 FPS</li>
<li>1M pts --> 14 FPS</li>
</ul>
<p>I rendered the same data with GL_TRIANGLE_STRIP and got similarly indistinguishable (though slower as expected due to extra rasterization). I can post those numbers too if anybody wants them.
.</p>
<h2>Question(s)</h2>
<ul>
<li>What gives?</li>
<li>What do I have to do to realize the promised performance gain of VBOs?</li>
<li>What am I missing?</li>
</ul>
| [
{
"answer_id": 549219,
"author": "Slava V",
"author_id": 37141,
"author_profile": "https://Stackoverflow.com/users/37141",
"pm_score": 3,
"selected": false,
"text": "glBufferData GL_ARRAY_BUFFER GL_STATIC_DRAW GL_DYNAMIC_DRAW glBufferData GL_ELEMENT_ARRAY_BUFFER pts vbo glb/e ratio\n... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430555",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23934/"
] |
430,573 | <p>I have an ASP.NET webforms application with a Menu control. How does one hide a particular menu item via code? I've seen a few articles pointing out how to do it with ASP.Net membership/roles-based security, but this particular use case has nothing to do with that. I simply need a way to programmatically remove a menu item from code. Any help would be appreciated. </p>
| [
{
"answer_id": 430578,
"author": "jwalkerjr",
"author_id": 689,
"author_profile": "https://Stackoverflow.com/users/689",
"pm_score": 4,
"selected": true,
"text": "mnuMyMenu.Items.Remove(mnuMyMenu.Items(1))\n"
},
{
"answer_id": 3694719,
"author": "Vijay Gaur",
"author_id":... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430573",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/689/"
] |
430,582 | <p>I am building an application, where I have this little survey module, which sends out a simple sms to the phone number I give and has to collect the response(if the user fires it) and show it to me. I am using to django build my project. I have tried django-sms google code project, but I couldn't post messages back from my mobile to my server. I have browsed through many tutorials on sms-gateways/carriers. But I am lost. Can anyone help me in suggesting a tutorial about sending sms from my application(django) to any cellphone? And regarding sending sms to cellphone, would it cost me(just as how i send sms from one cellphone to another)?</p>
| [
{
"answer_id": 21103956,
"author": "Jarod Reyes",
"author_id": 1160063,
"author_profile": "https://Stackoverflow.com/users/1160063",
"pm_score": 5,
"selected": false,
"text": "# Download the Python helper library from twilio.com/docs/python/install \nfrom twilio.rest import TwilioRestCli... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430582",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45629/"
] |
430,590 | <p>I asked about getting iTextSharp to render a PDF from HTML and a CSS sheet before <a href="https://stackoverflow.com/questions/430280/render-pdf-in-itextsharp-from-html-with-css">here</a> but it seems like that may not be possible... So I guess I will have to try something else.</p>
<p>Is there an open source .NET/C# library out there that can take HTML <strong><em>and</em></strong> CSS as input and render it correctly? </p>
<p>I must reiterate... the library MUST be free and preferably something with a fairly liberal license. I'm working with basically no budget here.</p>
| [
{
"answer_id": 430596,
"author": "Norman Ramsey",
"author_id": 41661,
"author_profile": "https://Stackoverflow.com/users/41661",
"pm_score": 5,
"selected": true,
"text": "htmldoc --webpage -t pdf --size letter --fontsize 10pt index.html > index.pdf\n"
},
{
"answer_id": 2719075,
... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/194/"
] |
430,592 | <p>I have </p>
<pre><code>class Cab(models.Model):
name = models.CharField( max_length=20 )
descr = models.CharField( max_length=2000 )
class Cab_Admin(admin.ModelAdmin):
ordering = ('name',)
list_display = ('name','descr', )
# what to write here to make descr using TextArea?
admin.site.register( Cab, Cab_Admin )
</code></pre>
<p>how to assign TextArea widget to 'descr' field in admin interface?</p>
<p><strong>upd:</strong><br>
In <strong>Admin</strong> interface only!</p>
<p>Good idea to use ModelForm.</p>
| [
{
"answer_id": 430620,
"author": "mipadi",
"author_id": 28804,
"author_profile": "https://Stackoverflow.com/users/28804",
"pm_score": 3,
"selected": false,
"text": "models.CharField models.TextField descr"
},
{
"answer_id": 430642,
"author": "ayaz",
"author_id": 23191,
... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21152/"
] |
430,599 | <p>I am struggling with getting this encryption decryption to work right.
I am using <a href="http://www.chaosink.co.uk/files/code/encryptionutils.zip" rel="nofollow noreferrer">this</a> class provided by Wolfwyrd and <a href="https://stackoverflow.com/questions/359342/an-effective-method-for-encrypting-a-license-file">this</a> instructions.</p>
<p>Below is the code:</p>
<pre><code>RSACryptoServiceProvider rsaKey = EncryptionUtils.GetRSAFromSnkFile(@"c\:a.snk");
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.PreserveWhitespace = true;
xmlDoc.LoadXml("<foo />");
SignXml(xmlDoc, rsaKey); //http://msdn.microsoft.com/en-us/library/ms229745.aspx
bool result = VerifyXml(xmlDoc, rsaKey); //http://msdn.microsoft.com/en-us/library/ms229950.aspx
System.Diagnostics.Debug.Write(result); //false
</code></pre>
<p>returns <code>false</code>. Note, I used the same snk file, and its the same encrypted xml document I am trying to verify, why is it returning <code>false</code>? What am I missing?</p>
| [
{
"answer_id": 463390,
"author": "Rasmus Faber",
"author_id": 5542,
"author_profile": "https://Stackoverflow.com/users/5542",
"pm_score": 1,
"selected": false,
"text": "private static RSACryptoServiceProvider GetRSAFromSnkBytes(byte[] snkBytes)\n{\n if (snkBytes == null)\n throw new ... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53619/"
] |
430,601 | <p>I'm trying to save data in a TClientDataSet to an XML file, but it doesn't like some of my fields. The helpfile says to create a definition, in one of two ways: either with the xmlmapper.exe file in my \bin folder or with an IDOMDocument interface.</p>
<p>Problem is, xmlmapper.exe isn't there, and IDOMDocument is one of those annoying structures that Delphi 2009 was released without writing up documentation for. So I have to choose between a non-existent EXE or an interface with no documentation and no indication of which objects implement it or how to create them.</p>
<p>Does anyone know what I'm supposed to do in this case?</p>
| [
{
"answer_id": 9270649,
"author": "Andrew Burke",
"author_id": 1208109,
"author_profile": "https://Stackoverflow.com/users/1208109",
"pm_score": -1,
"selected": false,
"text": "void __fastcall SaveToFile(const System::UnicodeString FileName = System::UnicodeString(), TDataPacketFormat Fo... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32914/"
] |
430,602 | <p>I have a PHP script that pushes the headers to allow a file to download. This script works fine when it called via a hyperlink or through the browser using link. This is how it looks like:</p>
<pre><code><a href="download.php?file=test.mp3&properFilename=Testing File">Download</a>
</code></pre>
<p>I want this to be a button (sbumit) instead, so I did this:</p>
<pre><code><form action="download.php?file=test.mp3&properFilename=Testing File" method="get">
<input type="submit" value="Download Audio" name="download"/>
</form>
</code></pre>
<p>However, this doesn't work. When I click on it. It initiates the download dialog box but the filename is empty. It shows file name as ".mp3" (without quotes)! That same link via the hyperlink shows the exact file name "Testing File". Why is this?? Here is the PHP snippet concerned:</p>
<pre><code>$filename = '../'.$_GET['file'];
$properFilename = $_GET['properFilename'].'.mp3';
header("Content-Disposition: attachment; filename=\"".basename($properFilename)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filename));
readfile("$filename");
exit();
</code></pre>
<p><strong>Thank you for any help</strong>. This has been driving me mad all day and night!!!</p>
| [
{
"answer_id": 430608,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 4,
"selected": true,
"text": "<form action=\"download.php\" method=\"GET\">\n <input type=\"submit\" value=\"Download Audio\" name=\"download... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51649/"
] |
430,614 | <p>How can I get the url from a running instance of firefox using .NET 2.0 windows/console app? C# or VB codes will do.</p>
<p>Thanks!</p>
| [
{
"answer_id": 430697,
"author": "Rob Kennedy",
"author_id": 33732,
"author_profile": "https://Stackoverflow.com/users/33732",
"pm_score": 2,
"selected": false,
"text": "WWW_GetWindowInfo"
},
{
"answer_id": 2452858,
"author": "Foole",
"author_id": 145621,
"author_prof... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430614",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18413/"
] |
430,648 | <p>Lets say I have 5 pages: A, B, C, D, and E. I also have a horizontal menu, and each item has a light gray background.</p>
<p>Each menu item has a:hover that gives it a medium-gray background, but I want the active page to have a black background, so I define</p>
<pre><code>#black {
background-color: #000;
}
</code></pre>
<p>Now when the user is on B.php, I want the B menu item to carry the #black id. What is the best way of doing this?</p>
| [
{
"answer_id": 430660,
"author": "dylanfm",
"author_id": 38795,
"author_profile": "https://Stackoverflow.com/users/38795",
"pm_score": 2,
"selected": false,
"text": "<body> ul.navigation a:link, ul.navigation a:visited {background-color:#eee}\nul.navigation a:active, ul.navigation a:hove... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29595/"
] |
430,672 | <p>I need a smart pointer for my project which can be send to several methods as parameter. I have checked <em>auto_ptr</em> and <em>shared_ptr</em> from boost. But IMO, that is not suitable for my requirements. Following are my findings</p>
<p>auto_ptr : When passed to another method, ownership will be transferred and underlying pointer will get deleted when that method's scope ends. We can workaround this by passing auto_ptr by reference, but there is no compile time mechanism to ensure it is always passed by reference. If by mistake, user forgot to pass a reference, it will make problems.</p>
<p>boost::shared_ptr : This looks promising and works correctly for my need. But I feel this is overkill for my project as it is a very small one. </p>
<p>So I decided to write a trivial templated pointer container class which can't be copied by value and take care about deleting the underlying pointer. Here it is</p>
<pre><code>template <typename T>
class simple_ptr{
public:
simple_ptr(T* t){
pointer = t;
}
~simple_ptr(){
delete pointer;
}
T* operator->(){
return pointer;
}
private:
T* pointer;
simple_ptr(const simple_ptr<T>& t);
};
</code></pre>
<p>Is this implementation correct? I have made copy constructor as private, so that compiler will alert when someone tries to pass it by value.</p>
<p>If by chance the pointer is deleted, delete operation on the destructor will throw assertion error. How can I workaround this? </p>
<p>I am pretty new to C++ and your suggestion are much appreciated.</p>
<p>Thanks</p>
| [
{
"answer_id": 430683,
"author": "Ed Carrel",
"author_id": 50013,
"author_profile": "https://Stackoverflow.com/users/50013",
"pm_score": 1,
"selected": false,
"text": "if (pointer) {\n delete pointer;\n pointer = NULL;\n} else {\n error(\"Attempted to free already freed pointer.... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50419/"
] |
430,681 | <p>Reviewing Conery's storefront, and I dont understand why he used Linqs auto-generated classes (ie Order class) and then he has another Order class defined that is not a partial class. WHen using repository pattern should one manually create the classes, and disregard Datacontext altogether? </p>
| [
{
"answer_id": 623232,
"author": "Ian Suttle",
"author_id": 19421,
"author_profile": "https://Stackoverflow.com/users/19421",
"pm_score": 3,
"selected": true,
"text": "using (MyDataContext data = new MyDataContext())\n{\n SomeThing thing = data.Things(t => t.ID == 1);\n return thin... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49632/"
] |
430,687 | <p>Does anyone know of a windows build of mod_throttle for Apache 2.2 or lower?</p>
<p>Or perhaps another means by which to throttle bandwidth. I need to throttle as low as 64k for a local speed test demonstration</p>
<p>Preferably Apache rather than a browser plug-in too.</p>
<p>Thanks!</p>
| [
{
"answer_id": 623232,
"author": "Ian Suttle",
"author_id": 19421,
"author_profile": "https://Stackoverflow.com/users/19421",
"pm_score": 3,
"selected": true,
"text": "using (MyDataContext data = new MyDataContext())\n{\n SomeThing thing = data.Things(t => t.ID == 1);\n return thin... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36076/"
] |
430,689 | <p>I have a tough one here, but I think the benefit will be great...</p>
<p>I'm using the following CSS hack with PHP. The U variable in the file below is a constant, previously defined (before I include this file) as the URL such as <a href="http://example.com/" rel="nofollow noreferrer">http://example.com/</a>. The P constant variable is defined as the physical file path like /var/www/example.com/. (The reason I have to use U and P for absolute pathing is because I use pretty URLs via Apache RewriteRule and it messes up the relative pathing.)</p>
<p>As you can see, I'm using the "link rel" technique to load a default style sheet, and for one for IE, and then another one for IE6. But for Safari and Opera, I tried the linkrel CSS hack technique and it failed -- FF was loading and interpreting the Opera and Safari stylesheets when I thought it might fail on the linkrel tag. So, I had to switch it to an inline CSS and use an @import url() call, but that failed because Opera and Safari wouldn't interpret the @import url() call. So, I had no choice but to switch context back to PHP and load it inline with a require() statement.</p>
<p>Well, the current arrangement in the file below works, but it means that the stylesheet for Opera and Safari is loading with all browsers (it's just not interpreted except by Opera and Safari). </p>
<p>I'd like to know how to get the linkrel or the @import working for Opera and Safari, instead.</p>
<pre><code><?php ?>
<? /*
***************************************************
DEFAULT STYLING (AND FIREFOX)
***************************************************
*/ ?>
<link rel="stylesheet" media="all" href="<?= U ?>css/default.css"/>
<style type='text/css'>
<? /*
***************************************************
SAFARI & GOOGLE CHROME STYLING (WEBKIT STYLING)
***************************************************
NOTE A LINKREL WILL GET INTERPRETED BY FF IF YOU DO IT LIKE THIS...
<link rel="stylesheet" media="screen and (-webkit-min-device-pixel-ratio:0)"
href="<?= U ?>css/safari.css"/>
...SO THAT CAN'T WORK. ALSO, IF YOU USE AN @import url('<?= U ?>css/safari.css'); TO
REPLACE WHERE I HAVE THE require() BELOW, THAT WON'T WORK EITHER BECAUSE
OPERA AND SAFARI DON'T SEEM TO UNDERSTAND THE @import DIRECTIVE IN CSS.
*/ ?>
@media screen and (-webkit-min-device-pixel-ratio:0){
<? require(P . 'css/safari.css'); ?>
}
<? /*
***************************************************
OPERA STYLING
***************************************************
*/ ?>
@media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0){
<? require(P . 'css/opera.css'); ?>
}
</style>
<? /*
***************************************************
IE (ALL) STYLING
***************************************************
*/ ?>
<!--[if IE]>
<link rel="stylesheet" media="all" href="<?= U ?>css/ie.css"/>
<![endif]-->
<? /*
***************************************************
IE6 STYLING
***************************************************
*/ ?>
<!--[if lte IE 6]>
<link rel="stylesheet" media="all" href="<?= U ?>css/ie6.css"/>
<![endif]-->
</code></pre>
| [
{
"answer_id": 430960,
"author": "runeh",
"author_id": 2906,
"author_profile": "https://Stackoverflow.com/users/2906",
"pm_score": 1,
"selected": false,
"text": "@import (-webkit-min-device-pixel-ratio:10000)"
},
{
"answer_id": 455774,
"author": "mercator",
"author_id": 2... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
430,704 | <p>I was asking a related question but messed the title up and no-one would understand it. Since I am able now to ask the question more precisely, I decided to reformulate it in a new question and close the old one. Sorry for that.</p>
<p>So what I want to do is passing data (my custom user's nickname as stored in the db) to the LoginUserControl. This login gets rendered from the master page via Html.RenderPartial(), so what I really need to do is making sure that, say ViewData["UserNickname"] is present on every call. But I don't want to populate ViewData["UserNickname"] in each and every action of every controller, so I decided to use <a href="http://www.asp.net/Learn/mvc/tutorial-13-cs.aspx" rel="noreferrer">this approach</a> and create an abstract base controller which will do the work for me, like so:</p>
<pre><code>public abstract class ApplicationController : Controller
{
private IUserRepository _repUser;
public ApplicationController()
{
_repUser = RepositoryFactory.getUserRepository();
var loggedInUser = _repUser.FindById(User.Identity.Name); //Problem!
ViewData["LoggedInUser"] = loggedInUser;
}
}
</code></pre>
<p>This way, whatever my deriving Controller does, the user information will already be present.</p>
<p>So far, so good. Now for the problem:</p>
<p>I can't call User.Identity.Name because <code>User</code> is already null. This is not the case in all of my deriving controllers, so this is specific for the abstract base controller.</p>
<p>I am setting the User.Identity.Name via FormsAuthentication at another place in the code, but I think this can't be the problem - afaik User.Identity.Name can be null, but not User itself.</p>
<p>It looks to me like the HttpContext is not available (since also null ;-) and that I am missing a simple yet important point here. Can anyone give me some hints? I would really appreciate it.</p>
| [
{
"answer_id": 430765,
"author": "keeney",
"author_id": 48046,
"author_profile": "https://Stackoverflow.com/users/48046",
"pm_score": 3,
"selected": false,
"text": "HttpContext currentContext = HttpContext.Current;\nstring userName = currentContext.User.Identity.Name;\n"
},
{
"an... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53102/"
] |
430,713 | <p>I am creating a small console app that needs a progress bar. Something like...</p>
<pre><code>Conversion: 175/348 Seconds |========== | 50%
</code></pre>
<p>My question is, how do you erase characters already printed to the console? When I reach the 51st percentage, I have to erase this line from the console and insert a new line. In my current solution, this is what happens...</p>
<pre><code>Conversion: 175/348 Seconds |========== | 50%
Conversion: 179/348 Seconds |========== | 52%
Conversion: 183/348 Seconds |========== | 54%
Conversion: 187/348 Seconds |=========== | 56%
</code></pre>
<p>Code I use is...</p>
<pre><code>print "Conversion: $converted_seconds/$total_time Seconds $progress_bar $converted_percentage%\n";
</code></pre>
<p>I am doing this in Linux using PHP(only I will use the app - so please excuse the language choice). So, the solution should work on the Linux platform - but if you have a solution that's cross platform, that would be preferable.</p>
| [
{
"answer_id": 430720,
"author": "GnomeCubed",
"author_id": 53475,
"author_profile": "https://Stackoverflow.com/users/53475",
"pm_score": 5,
"selected": true,
"text": "<?php\nfor( $i=0;$i<10;$i++){\n print \"$i \\r\";\n sleep(1);\n}\n?>\n"
},
{
"answer_id": 430752,
"author"... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15595/"
] |
430,726 | <p>I just want know all the small problems that got between you and your final solution when you were new to Erlang.</p>
<p>For example, here are the first speedbumps I had:</p>
<ol>
<li>Use controlling_process(Socket, Pid) if you spawn off in multiple threads. Right packet to the right thread. </li>
<li>You going to start talking to another server? Remember to net_adm:ping('car@bsd-server'). in the shell. Else no communication will get through.</li>
<li>Timer:sleep(10), if you want to do nothing. Always useful when debugging. </li>
</ol>
| [
{
"answer_id": 591950,
"author": "archaelus",
"author_id": 9040,
"author_profile": "https://Stackoverflow.com/users/9040",
"pm_score": 3,
"selected": false,
"text": "sys dbg toolbar rr/1 length/1 element/2 code:load(Mod), sys:suspend(Pid), sys:change_code(Pid, Mod, undefined, undefined),... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15054/"
] |
430,736 | <p>My server is in Dallas. I'm in New York City.. and both PHP and MySQL have configuration variables for setting the timezone.</p>
<p>How do I get them all to work together? What dates should I store in MySQL? How do I get PHP to handle changing the date based on the user's preference?</p>
<p>Bear in mind: I don't think I'm ever having PHP explicitly set the date, it's always using "NOW()" in queries.. however I foresee the need to do this. How would this be done?</p>
<p>I'm hoping SO's experience can help me out here.</p>
| [
{
"answer_id": 430740,
"author": "Soviut",
"author_id": 46914,
"author_profile": "https://Stackoverflow.com/users/46914",
"pm_score": 0,
"selected": false,
"text": "date_default_timezone_set()"
},
{
"answer_id": 430797,
"author": "vava",
"author_id": 6258,
"author_pro... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430736",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
430,751 | <p>I have a "description" field indexed in Lucene.This field contains a book's description.
How do i achieve "All of these words" functionality on this field using BooleanQuery class?
For example if a user types in "top selling book" then it should return books which have all of these words in its description.</p>
<p>Thanks!</p>
| [
{
"answer_id": 430776,
"author": "Peter Becker",
"author_id": 19820,
"author_profile": "https://Stackoverflow.com/users/19820",
"pm_score": 0,
"selected": false,
"text": "BooleanQuery.add(Query, BooleanClause.Occur)\n BooleanClause.Occur.MUST"
},
{
"answer_id": 430789,
"autho... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40907/"
] |
430,755 | <p>I've been working with web start for a couple years now and have experience with signing the jars and what not. I am taking my first attempt at deploying a RCP app with web start and though I have in fact signed all of the jars with the same certificate I keep getting this error: 'jar resources in jnlp are not signed by the same certificate'</p>
<p>Has anyone else came across this? If so, any ideas on how to fix?</p>
| [
{
"answer_id": 430761,
"author": "asalamon74",
"author_id": 21348,
"author_profile": "https://Stackoverflow.com/users/21348",
"pm_score": 5,
"selected": true,
"text": "<resources>\n ...\n <extension name=\"other\" href=\"other.jnlp\"/>\n</resources>\n"
},
{
"answer_id": 5650210... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27657/"
] |
430,759 | <p>I would like to be able to match a string literal with the option of escaped quotations.
For instance, I'd like to be able to search "this is a 'test with escaped\' values' ok" and have it properly recognize the backslash as an escape character. I've tried solutions like the following:</p>
<pre><code>import re
regexc = re.compile(r"\'(.*?)(?<!\\)\'")
match = regexc.search(r""" Example: 'Foo \' Bar' End. """)
print match.groups()
# I want ("Foo \' Bar") to be printed above
</code></pre>
<p>After looking at this, there is a simple problem that the escape character being used, "<code>\</code>", can't be escaped itself. I can't figure out how to do that. I wanted a solution like the following, but negative lookbehind assertions need to be fixed length:</p>
<pre><code># ...
re.compile(r"\'(.*?)(?<!\\(\\\\)*)\'")
# ...
</code></pre>
<p>Any regex gurus able to tackle this problem? Thanks.</p>
| [
{
"answer_id": 430763,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 1,
"selected": false,
"text": "/(?<!\\\\)'((?:\\\\'|[^'])*)(?<!\\\\)'/\n private final static String TESTS[] = {\n \"'testing 123'\",\n \"'t... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49701/"
] |
430,771 | <p>I'm currently trying to extend a friend's OCaml program. It's a huge collection of functions needed for some data analysis.. Since I'm not really an OCaml crack I'm currently stuck on a (for me) strange List implementation:</p>
<pre><code>type 'a cell = Nil
| Cons of ('a * 'a llist)
and 'a llist = (unit -> 'a cell);;
</code></pre>
<p>I've figured out that this implements some sort of "lazy" list, but I have absolutely no idea how it really works. I need to implement an Append and a Map Function based on the above type. Has anybody got an idea how to do that?</p>
<p>Any help would really be appreciated!</p>
| [
{
"answer_id": 430887,
"author": "starblue",
"author_id": 49246,
"author_profile": "https://Stackoverflow.com/users/49246",
"pm_score": 4,
"selected": true,
"text": "let rec append l1 l2 = \n match l1 () with\n Nil -> l2 | \n (Cons (a, l)) -> fun () -> (Cons (a, append l... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430771",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43960/"
] |
430,809 | <p>Suppose I want to create a REST interface to find the average of a list of numbers. Assume that the numbers are submitted one at a time. How would you do this?</p>
<ol>
<li>POST a number to <a href="https://example.com/api/average" rel="nofollow noreferrer">https://example.com/api/average</a></li>
<li>If this is the first number a hash will be returned</li>
<li>POST a number to <a href="https://example.com/api/average/hash" rel="nofollow noreferrer">https://example.com/api/average/hash</a>
....</li>
<li>GET <a href="https://example.com/api/average/hash" rel="nofollow noreferrer">https://example.com/api/average/hash</a> to find the average</li>
<li>DELETE <a href="https://example.com/api/average/hash" rel="nofollow noreferrer">https://example.com/api/average/hash</a> since we don't need it any more</li>
</ol>
<p>Is this the right way to do it? Any suggestions?</p>
| [
{
"answer_id": 430817,
"author": "Peter Hilton",
"author_id": 2670,
"author_profile": "https://Stackoverflow.com/users/2670",
"pm_score": 3,
"selected": false,
"text": "/list/{id} {id} POST /list /list/{id} Location POST /list/{id} GET /list/{id}/average DELETE /list/{id} GET /list/{id}/... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
430,811 | <p>A friend asked me last week how to enumerate or list all variables within a program/function/etc. for the purposes of debugging (essentially getting a snapshot of everything so you can see what variables are set to, or if they are set at all). I looked around a bit and found a relatively good way for Python:</p>
<pre>
#!/usr/bin/python
foo1 = "Hello world"
foo2 = "bar"
foo3 = {"1":"a",
"2":"b"}
foo4 = "1+1"
for name in dir():
myvalue = eval(name)
print name, "is", type(name), "and is equal to ", myvalue
</pre>
<p>which will output something like:</p>
<pre>
__builtins__ is <type 'str'> and is equal to <module '__builtin__' (built-in)>
__doc__ is <type 'str'> and is equal to None
__file__ is <type 'str'> and is equal to ./foo.py
__name__ is <type 'str'> and is equal to __main__
foo1 is <type 'str'> and is equal to Hello world
foo2 is <type 'str'> and is equal to bar
foo3 is <type 'str'> and is equal to {'1': 'a', '2': 'b'}
foo4 is <type 'str'> and is equal to 1+1
</pre>
<p>I have so far found a partial way in PHP (courtesy of <a href="http://www.phpro.org/examples/List-all-variables.html" rel="noreferrer">link text</a>) but it only lists all variables and their types, not the contents:</p>
<pre>
<?php
// create a few variables
$bar = 'foo';
$foo ='bar';
// create a new array object
$arrayObj = new ArrayObject(get_defined_vars());
// loop over the array object and echo variables and values
for($iterator = $arrayObj->getIterator(); $iterator->valid(); $iterator->next())
{
echo $iterator->key() . ' => ' . $iterator->current() . '<br />';
}
?>
</pre>
<p><strong>So I put it to you: how do you list all variables and their contents in your favorite language?</strong></p>
<hr>
<p>Edit by <a href="https://stackoverflow.com/users/6309/vonc">VonC</a>: I propose this question follows the spirit of a little "<a href="https://stackoverflow.com/questions/172184">code-challenge</a>".<br>
If you do not agree, just edit and remove the tag and the link.</p>
| [
{
"answer_id": 430819,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "static class Program { // formatted for minimal vertical space\n static object foo1 = \"Hello world\", foo2 = \"ba... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430811",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31056/"
] |
430,839 | <p>I'm trying hard to understand when and what I must relase in Cocoa Touch as it doesn't have garbage collection.</p>
<p>This code block is from apples iphone sample PeriodicElements and they release anElement and rawElementArray but not thePath, firstLetter, existingArray and tempArray?</p>
<p>I would have thought that at least tempArray and existingArray should be released.</p>
<p>Could some brainy person please explain to me why?</p>
<p>Thanks :)</p>
<pre><code>- (void)setupElementsArray {
NSDictionary *eachElement;
// create dictionaries that contain the arrays of element data indexed by
// name
self.elementsDictionary = [NSMutableDictionary dictionary];
// physical state
self.statesDictionary = [NSMutableDictionary dictionary];
// unique first characters (for the Name index table)
self.nameIndexesDictionary = [NSMutableDictionary dictionary];
// create empty array entries in the states Dictionary or each physical state
[statesDictionary setObject:[NSMutableArray array] forKey:@"Solid"];
[statesDictionary setObject:[NSMutableArray array] forKey:@"Liquid"];
[statesDictionary setObject:[NSMutableArray array] forKey:@"Gas"];
[statesDictionary setObject:[NSMutableArray array] forKey:@"Artificial"];
// read the element data from the plist
NSString *thePath = [[NSBundle mainBundle] pathForResource:@"Elements" ofType:@"plist"];
NSArray *rawElementsArray = [[NSArray alloc] initWithContentsOfFile:thePath];
// iterate over the values in the raw elements dictionary
for (eachElement in rawElementsArray)
{
// create an atomic element instance for each
AtomicElement *anElement = [[AtomicElement alloc] initWithDictionary:eachElement];
// store that item in the elements dictionary with the name as the key
[elementsDictionary setObject:anElement forKey:anElement.name];
// add that element to the appropriate array in the physical state dictionary
[[statesDictionary objectForKey:anElement.state] addObject:anElement];
// get the element's initial letter
NSString *firstLetter = [anElement.name substringToIndex:1];
NSMutableArray *existingArray;
// if an array already exists in the name index dictionary
// simply add the element to it, otherwise create an array
// and add it to the name index dictionary with the letter as the key
if (existingArray = [nameIndexesDictionary valueForKey:firstLetter])
{
[existingArray addObject:anElement];
} else {
NSMutableArray *tempArray = [NSMutableArray array];
[nameIndexesDictionary setObject:tempArray forKey:firstLetter];
[tempArray addObject:anElement];
}
// release the element, it is held by the various collections
[anElement release];
}
// release the raw element data
[rawElementsArray release];
// create the dictionary containing the possible element states
// and presort the states data
self.elementPhysicalStatesArray = [NSArray arrayWithObjects:@"Solid",@"Liquid",@"Gas",@"Artificial",nil];
[self presortElementsByPhysicalState];
// presort the dictionaries now
// this could be done the first time they are requested instead
[self presortElementInitialLetterIndexes];
self.elementsSortedByNumber = [self presortElementsByNumber];
self.elementsSortedBySymbol = [self presortElementsBySymbol];
</code></pre>
<p>} </p>
| [
{
"answer_id": 430846,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "rawElementsArray +alloc anElement thePath tempArray +alloc +new -copy"
},
{
"answer_id": 430916,
"author": "Martin... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
430,840 | <p>I have tables association such as (CaseClient is a bridge table):</p>
<ul>
<li>Cases has many CaseClients</li>
<li>Client has many CaseClients</li>
<li>ClientType has many CaseClient</li>
</ul>
<p>The easiest way just use the view in database but I heard that with linq you can join this somehow? Or should I just created view in the database and linq query agains that view?</p>
<p>I am appreciated your comment</p>
| [
{
"answer_id": 430846,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "rawElementsArray +alloc anElement thePath tempArray +alloc +new -copy"
},
{
"answer_id": 430916,
"author": "Martin... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53659/"
] |
430,849 | <p>I would like my <strong>ListBox</strong> to number each <strong>ListItem</strong> using its index + 1.</p>
<p>How would I do that to the <strong>Text</strong> property of a <strong>TextBlock</strong> in a <strong>DataTemplate</strong> of the <strong>ListBox</strong>?</p>
| [
{
"answer_id": 430856,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 1,
"selected": false,
"text": "ListBoxItem SelectedIndex + 1 SelectedIndex ListBoxItems ListBox ListBox"
}
] | 2009/01/10 | [
"https://Stackoverflow.com/questions/430849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40568/"
] |
430,879 | <p>I have two ASP.NET web application. One is responsible for processing some info and <strong>writing to a log file</strong>, and the other application is reponsible for <strong>reading the log</strong> file and displays the information based on user request.</p>
<p>Here's my code for the Writer</p>
<pre><code>public static void WriteLog(String PathToLogFile, String Message)
{
Mutex FileLock = new Mutex(false, "LogFileMutex");
try
{
FileLock.WaitOne();
using (StreamWriter sw = File.AppendText(FilePath))
{
sw.WriteLine(Message);
sw.Close();
}
}
catch (Exception ex)
{
LogUtil.WriteToSystemLog(ex);
}
finally
{
FileLock.ReleaseMutex();
}
}
</code></pre>
<p>And here's my code for the Reader :</p>
<pre><code>private String ReadLog(String PathToLogFile)
{
FileStream fs = new FileStream(
PathToLogFile, FileMode.Open,
FileAccess.Read, FileShare.ReadWrite);
StreamReader Reader = new StreamReader(fs);
return Reader.ReadToEnd();
}
</code></pre>
<p>My question, is the above code enough to prevent locking in a web garden environemnt? </p>
<p><strong>EDIT 1 :</strong> Dirty read is okay.
<strong>EDIT 2 :</strong> Creating Mutex with new Mutex(false, "LogFileMutex"), closing StreamWriter</p>
| [
{
"answer_id": 431136,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 2,
"selected": false,
"text": "using (Mutex FileLock = new Mutex(true, \"LogFileMutex\"))\n{\n // ...\n}\n"
}
] | 2009/01/10 | [
"https://Stackoverflow.com/questions/430879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10629/"
] |
430,899 | <p>Anyone can point me to the error please?</p>
<p>Note: this is a simplified test case extracted from my real app.
Thus the weird usage of 3 entity managers and
em1.getTransaction().begin();
em1.clear();
em1.close();
at the end of each section.
In real app it happens in different times.
HibernateUtil is basically copied from the tutorial.</p>
<pre><code> HibernateUtil.open();
EntityManager em1 = HibernateUtil.reserveEntityManager();
em1.getTransaction().begin();
StringType st1 = new StringType();
st1.setName("a");
em1.persist(st1);
em1.getTransaction().commit();
em1.getTransaction().begin();
em1.clear();
em1.close();
EntityManager em2 = HibernateUtil.reserveEntityManager();
em2.getTransaction().begin();
StringType st2 = new StringType();
st2.setName("a");
st2.setId(st1.getId());
em2.merge(st2);
em2.getTransaction().commit();
em2.getTransaction().begin();
em2.clear();
em2.close();
EntityManager em3 = HibernateUtil.reserveEntityManager();
em3.getTransaction().begin();
StringType st3 = new StringType();
st3.setName("a");
st3.setId(st1.getId());
[b]em3.merge(st3);[/b]
em3.getTransaction().commit();
em3.getTransaction().begin();
em3.clear();
em3.close();
public static EntityManager reserveEntityManager()
{
return emf.createEntityManager();
}
public static void open()
{
try
{
emf = Persistence.createEntityManagerFactory("manager1");
}
catch (Throwable e)
{
throw new ExceptionInInitializerError(e);
}
}
</code></pre>
<p>javax.persistence.OptimisticLockException: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [WebOrganizer.classes.types.StringType#174]
at org.hibernate.ejb.AbstractEntityManagerImpl.wrapStaleStateException(AbstractEntityManagerImpl.java:646)
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:600)
at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:237)
at WebOrganizer.web.servlets.TypeServlet.test2(TypeServlet.java:356)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:517)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:669)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:956)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:110)
at org.testng.TestRunner.runWorkers(TestRunner.java:720)
at org.testng.TestRunner.privateRun(TestRunner.java:590)
at org.testng.TestRunner.run(TestRunner.java:484)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:332)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:327)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:299)
at org.testng.SuiteRunner.run(SuiteRunner.java:204)
at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:864)
at org.testng.TestNG.runSuitesLocally(TestNG.java:830)
at org.testng.TestNG.run(TestNG.java:748)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:124)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)</p>
<p>Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [WebOrganizer.classes.types.StringType#174]
at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:261)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:120)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:53)
at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:677)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:661)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:665)
at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:228)
... 28 more </p>
| [
{
"answer_id": 431496,
"author": "cliff.meyers",
"author_id": 41754,
"author_profile": "https://Stackoverflow.com/users/41754",
"pm_score": 1,
"selected": false,
"text": "EntityTransaction tx1 = em1.getTransaction();\n// make your modifications\nem1.merge(st1);\ntx1.commit();\n"
},
{... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
430,904 | <p>is it possible to make nant run a publish on mvc project or a good old web application project<br>
and after the publish make nant FTP the files to the web server</p>
<p><strong><em>UPDATE:</em></strong> found the solution to the ftp problem<br>
<a href="http://www.spinthemoose.com/~ftptask/" rel="nofollow noreferrer">Nant ftp task</a> thanks Paco</p>
<p>what i mean by publich<br>
is there a command line application or nant task that can public like visual studio publish... </p>
| [
{
"answer_id": 431173,
"author": "Paco",
"author_id": 13376,
"author_profile": "https://Stackoverflow.com/users/13376",
"pm_score": 4,
"selected": true,
"text": "<target name=\"copyToPublish\">\n <delete dir=\"${dir.publish}\" />\n <mkdir dir=\"${dir.publish}\" />\n <mkdir dir=\... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31296/"
] |
430,912 | <p>I am developing a site in vertigoserver. Now I need to test the webpage in webserver.</p>
<p>I am using the webserver Host-Europe VirtualServer 3.0.</p>
<ol>
<li>Now what are the steps I need to upload the PHP pages?</li>
<li>What is the software needed to upload MySQL queries?</li>
<li>Are there any tutorials or suggestions?</li>
</ol>
| [
{
"answer_id": 430920,
"author": "Paul Dixon",
"author_id": 6521,
"author_profile": "https://Stackoverflow.com/users/6521",
"pm_score": 4,
"selected": true,
"text": "mysql -h<hostname> -u<username> -p<password> mydatabase < dump.mysql\n"
}
] | 2009/01/10 | [
"https://Stackoverflow.com/questions/430912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44984/"
] |
430,922 | <p>What is a good way to calculate difference (in a sense what should be added and deleted from one table to get another) between tables in MySQL?</p>
| [
{
"answer_id": 430923,
"author": "vava",
"author_id": 6258,
"author_profile": "https://Stackoverflow.com/users/6258",
"pm_score": 1,
"selected": false,
"text": "SELECT DISTINCT id FROM a WHERE NOT EXISTS (SELECT * FROM b WHERE a.id = b.id);\nSELECT DISTINCT id FROM b WHERE NOT EXISTS (SE... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430922",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6258/"
] |
430,927 | <p>I usually write C# programs for myself, or just parts of other applications. Now, I have been working on a project that I would like to eventually commercialize and I am interested in the easiest way to deploy a simple application from VS 2008 that will primarily be downloaded and installed. I am not just interested in installer choices, but build options, exception handling settings, and any other essential details.</p>
<p>The documentation on MSDN is a little overwhelming. Just the section on deployment how-to's has over 100 topics!</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms184415.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms184415.aspx</a></p>
<p>What should I focus on and in what order? Does anyone have a personal checklist that they run through just to make sure all of the bases are covered?</p>
| [
{
"answer_id": 430923,
"author": "vava",
"author_id": 6258,
"author_profile": "https://Stackoverflow.com/users/6258",
"pm_score": 1,
"selected": false,
"text": "SELECT DISTINCT id FROM a WHERE NOT EXISTS (SELECT * FROM b WHERE a.id = b.id);\nSELECT DISTINCT id FROM b WHERE NOT EXISTS (SE... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50859/"
] |
430,928 | <p>I'm currently using jQuery, as well as swfObject to dynamically embed the swf movie into my web page.</p>
<p>I currently having a problem on embeding immem's music player into my web page, as their embed code doesn't have any loading screen. So, when I replace the element using swfObject, that area will generally blank. In worst case, it means that user won't know that the embed song is loading.</p>
<p>So, I'm trying to find out the way to bind an event after that flash got loaded. Since my plan would be placing image with huge <code>z-index</code> on the top and use this trigger to hide the image. I think I've tried to use <code>$('#embed').load(function(){ ... });</code>, with no luck.</p>
<p>Does somebody have any solution for this? I just wonder if that is possible, since I don't want to get hacking with the flash and try to add 'loader' to the flash file.</p>
<p><strong>Some more note:</strong> To make it more clear, I want to embed imeem's music player into my webpage. So, I really don't have any control over the flash file, i.e. I can't create a flash file by myself.</p>
| [
{
"answer_id": 431210,
"author": "Crescent Fresh",
"author_id": 45433,
"author_profile": "https://Stackoverflow.com/users/45433",
"pm_score": 2,
"selected": false,
"text": "<body onload=\"...\""
}
] | 2009/01/10 | [
"https://Stackoverflow.com/questions/430928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52035/"
] |
430,937 | <p>I'm currently in the creation of a javascript function library. Mainly for my own use, but you can never be sure if someone else ends up using it in their projects, I'm atleast creating it as if that could happen.<br>
Most methods only work if the variables that are passed are of the correct datatype. Now my question is: What is the best way to alert users that the variable is not of the correct type? Should one throw an error like this?</p>
<pre><code>function foo(thisShouldBeAString){ //just pretend that this is a method and not a global function
if(typeof(thisShouldBeAString) === 'string') {
throw('foo(var), var should be of type string');
}
#yadayada
}
</code></pre>
<p>I know that javascript does internal type conversion, but this can create very weird results (ie '234' + 5 = '2345' but '234' * 1 = 234) and this could make my methods do very weird things.</p>
<p><b>EDIT</b><br>
To make things extra clear: I do not wish to do type conversion, the variables passed should be of the correct type. What is the best way to tell the user of my library that the passed variables are not of the correct type?</p>
| [
{
"answer_id": 430975,
"author": "epascarello",
"author_id": 14104,
"author_profile": "https://Stackoverflow.com/users/14104",
"pm_score": 1,
"selected": false,
"text": "throw"
},
{
"answer_id": 431135,
"author": "AnthonyWJones",
"author_id": 17516,
"author_profile": ... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430937",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35197/"
] |
430,941 | <p>Are there any free libraries that would "print" to a PDF without actually having to install a PDF printer on the system. I want something that can be completely self contained in my application. The reason I say I want it to "print" is that I've tried and tried to find a solution for directly converting from HTML with CSS to PDF, but it does't seem very possible. So I want to use the System.Windows.Forms.WebBrowser control to render the page first and then output that rendering to PDF. I just don't want the user to be required to install a PDFPrinter.</p>
| [
{
"answer_id": 430945,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 1,
"selected": false,
"text": "Process"
}
] | 2009/01/10 | [
"https://Stackoverflow.com/questions/430941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/194/"
] |
430,942 | <p>Right, I'm trying to get a label with text in it (done already obviously), which scrolls across the screen.</p>
<p>The text that is input into the label is done by a UITextField and a UIButton. This updates fine.</p>
<p>But I'm trying to get the UILabel to resize accordingly to the amount of text input, so that the WHOLE lot of text scrolls across the screen.</p>
<p>This is the code I have at the moment for the scrolling label:</p>
<pre><code>[lblMessage setText: txtEnter.text];
CABasicAnimation *scrollText;
scrollText=[CABasicAnimation animationWithKeyPath:@"position.x"];
scrollText.duration = 3.0;
scrollText.repeatCount = 10000;
scrollText.autoreverses = NO;
scrollText.fromValue = [NSNumber numberWithFloat:500];
scrollText.toValue = [NSNumber numberWithFloat:-120.0];
[[lblMessage layer] addAnimation:scrollText forKey:@"scrollTextKey"];
</code></pre>
<p>The problem is, sometimes is starts scrolling in the middle of the screen, and sometimes vanishes before it has fully gone acrosss.</p>
<p>It also cuts of text due to the label being one size.. I don't know how to change this.</p>
<p>Thanks in advance.</p>
<p>Dom </p>
| [
{
"answer_id": 431260,
"author": "Brad Larson",
"author_id": 19679,
"author_profile": "https://Stackoverflow.com/users/19679",
"pm_score": 4,
"selected": true,
"text": "[lblMessage setText: txtEnter.text];\n[lblMessage sizeToFit];\nscrollView.contentSize = lblMessage.frame.size;\n"
}
] | 2009/01/10 | [
"https://Stackoverflow.com/questions/430942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53677/"
] |
430,955 | <p>What is the fast and effective way to open Form2 from Form1?</p>
<p>I work in WinCE (limited memory and CPU power) so this becomes important.</p>
| [
{
"answer_id": 430999,
"author": "Michael Haren",
"author_id": 29,
"author_profile": "https://Stackoverflow.com/users/29",
"pm_score": 1,
"selected": false,
"text": "OtherFormClass NewForm = new OtherFormClass();\nNewForm.Show();\n"
},
{
"answer_id": 457372,
"author": "Quibbl... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43907/"
] |
430,966 | <p>I hope this question is not a RTFM one.
I am trying to write a Python script that extracts links from a standard HTML webpage (the <code><link href...</code> tags).
I have searched the web for matching regexen and found many different patterns. Is there any agreed, standard regex to match links?</p>
<p>Adam</p>
<p><strong>UPDATE:</strong>
I am actually looking for two different answers: </p>
<ol>
<li>What's the library solution for parsing HTML links. <a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow noreferrer">Beautiful Soup</a> seems to be a good solution (thanks, <code>Igal Serban</code> and <code>cletus</code>!) </li>
<li>Can a link be defined using a regex?</li>
</ol>
| [
{
"answer_id": 431006,
"author": "PEZ",
"author_id": 44639,
"author_profile": "https://Stackoverflow.com/users/44639",
"pm_score": 1,
"selected": false,
"text": "re.findall(r'''<link\\s+.*?href=['\"](.*?)['\"].*?(?:</link|/)>''', html, re.I)\n"
},
{
"answer_id": 431087,
"auth... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51197/"
] |
430,973 | <p>I know that there are many free and not so free compression libraries out there, but for the project i am working on, i need to be able to take file data from a stream and put it into some kind zip or pack file, but without compression, because i will need to access these files quickly without having to wait for them to decompress.</p>
<p>Anyone know how this could be approached, or if there are some libraries out there that do this that i am not aware of?</p>
| [
{
"answer_id": 430978,
"author": "Michael Haren",
"author_id": 29,
"author_profile": "https://Stackoverflow.com/users/29",
"pm_score": 4,
"selected": true,
"text": "tar tar"
}
] | 2009/01/10 | [
"https://Stackoverflow.com/questions/430973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18811/"
] |
430,990 | <p>I have been studying SOAP and WSDL in preparation for implementing a web service. One thing that I have encountered that puzzles me is that some of the URIs that I have seen use a trailing slash such as:</p>
<pre><code>http://www.w3.org/some-namespace/
</code></pre>
<p>while other examples that I have studied omit this trailing slash. I really have several questions regarding this:</p>
<ul>
<li>What is the significance of the trailing slash?</li>
<li>Is the URI, http://www.w3.org/some-namespace the same as http://www.w3.org/some-namespace/?</li>
<li>If they are not the same, how do I decide when one form is warranted versus another?</li>
<li>I have read the guidelines given by w3c regarding URI's and these appear to indicate that that URI should be considered equal only if the case-sensitive comparison of the URI strings are considered equal. Is this interpretation correct?</li>
</ul>
| [
{
"answer_id": 430996,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": " Uri uri = new Uri(@\"http://www.w3.org/some-namespace/\");\n Console.WriteLine(new Uri(uri, \"foo\")); // http... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430990",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19674/"
] |
430,993 | <p>Say I add a function to an outstanding Interface.
In Visual Studio, within a class which implements it I can right click the Interface declaration and re-implement it. This will update the code to reflect the changes made. Is there anyway to do the same thing in eclipse?
It'd be nice if there was.
I've searched the net, alas no joy.</p>
| [
{
"answer_id": 431026,
"author": "Hank Gay",
"author_id": 4203,
"author_profile": "https://Stackoverflow.com/users/4203",
"pm_score": 3,
"selected": true,
"text": "CTRL+1 ⌘ CTRL"
}
] | 2009/01/10 | [
"https://Stackoverflow.com/questions/430993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17510/"
] |
430,997 | <p>In rails, is it recommended to use form helpers? Internally, everything boils down to plain html then why not write the html directly? Performance will obviously be better in writing direct html than using helpers. Is using form helpers like a convention or something that rails developers must follow?</p>
| [
{
"answer_id": 431012,
"author": "Sebastian Dietz",
"author_id": 52837,
"author_profile": "https://Stackoverflow.com/users/52837",
"pm_score": 2,
"selected": false,
"text": "<% form_for :person, @person, :url => { :action => \"create\" } do |f| %>\n <%= f.text_field :first_name %>\n <%... | 2009/01/10 | [
"https://Stackoverflow.com/questions/430997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45942/"
] |
431,010 | <p>I would like to ask for a reccomended solution for this:
We have a list of Competitions.
Each competition has defined fee that a participatior has to pay
We have Participators
I have to know has a Participator that is on a Competition paid the fee or not. I am thinking about 2 solutions and the thing is it has to be the most appropriate solution in Domain Driven Design.
First is to create a Dictionary in Competition instead of a List, the dictionary would have be of type <Participator, bool>.
The secont is perhaps create a different class that has 2 fields, a participator and feePaid. And in Competiton I would have a list of object of that new class.</p>
<p>Thank you</p>
| [
{
"answer_id": 431074,
"author": "Ray Tayek",
"author_id": 51292,
"author_profile": "https://Stackoverflow.com/users/51292",
"pm_score": 3,
"selected": false,
"text": "class Participator {\n}\nclass Competition {\n Currency fee\n}\nclass Entry {\n Competition competition\n Parti... | 2009/01/10 | [
"https://Stackoverflow.com/questions/431010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46739/"
] |
431,013 | <p>For an ASP.NET C# application, we will need to restrict access based on IP address. What is the best way to accomplish this?</p>
| [
{
"answer_id": 431028,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 4,
"selected": false,
"text": "/// <summary>\n/// HTTP module to restrict access by IP address\n/// </summary>\n\npublic class SecurityHttpModule : I... | 2009/01/10 | [
"https://Stackoverflow.com/questions/431013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49544/"
] |
431,025 | <p>Consider a reasonably large website (2M+ pageviews / m, lots of users) with 2 frontend servers: one front server in the US, and one in Europe. Two dedicated URL bring the visitors on one of the server, one in the french language, the other one in english. Both sites share exactly the same data.</p>
<p>What would be the most cost effective solution? (DB used at my company: MySQL)</p>
<p><strong>1/ A single Master server on Amazon EC2 (US), and slaves on the frontend servers?</strong> </p>
<ul>
<li><p>Advantages: no master-master rep, meaning no risk of data conflict with autoincrement and duplicates on unique columns, etc..</p></li>
<li><p>Drawbacks: The lag! Won't there be too much lagging for writing in the US when you are in Europe?
Another drawback could be the lack of quick n dirty solution in case the master dies. And what about having slaves on same server as front?</p></li>
</ul>
<p><strong>2/ Two Amazon EC2 instances, one in the US, one in Europe, acting as master-master replication servers. Plus two slaves on each of the frontends?</strong></p>
<ul>
<li><p>Adv: Speed, and security of data. Of course there is no load balancer, but making a hack to switch the master to the other one seems pretty trivial.</p></li>
<li><p>Drwbcks: Price. And the risk of corruption on the DB</p></li>
</ul>
<p><strong>3/ Any other solution ?</strong></p>
<p>As it is my first time working with servers in 2 continents, I would really appreciate learning from you experience in that area, including MySQL or not, including EC2 or not.</p>
<p>Thanks
Marshall</p>
| [
{
"answer_id": 431116,
"author": "Gary Richardson",
"author_id": 2506,
"author_profile": "https://Stackoverflow.com/users/2506",
"pm_score": 2,
"selected": false,
"text": "top"
}
] | 2009/01/10 | [
"https://Stackoverflow.com/questions/431025",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50871/"
] |
431,041 | <p>I have XAMP 1.6.8 and IIS 5.0 installed on my PC(Windows XP SP3).</p>
<p>I'm unable to run them simultaneously. If IIS service is running, Apache throws the following error:</p>
<p>(OS 10048)Only one usage of each socket address (protocol/network address/port) is normally permitted. : make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down Unable to open logs Note the errors or messages above, and press the key to exit. 24...</p>
<p>Windows could not start the Apache2 on Local Computer. For more information, review the System Event Log. If this is a non-Microsoft service, contact the service vendor, and refer to service-specific error code 1.</p>
<hr />
<h3>Edit:</h3>
<p>Apache runs on a different port 3128. And IIS (asp.net) usually runs on a different port.</p>
| [
{
"answer_id": 431062,
"author": "gbjbaanb",
"author_id": 13744,
"author_profile": "https://Stackoverflow.com/users/13744",
"pm_score": 4,
"selected": true,
"text": "\"Listen 80\" Listen 192.168.0.2:80"
}
] | 2009/01/10 | [
"https://Stackoverflow.com/questions/431041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46795/"
] |
431,044 | <p>I am designing a psychology experiment with java applets. I have to make my java applets full screen. What is the best way of doing this and how can I do this. </p>
<p>Since I haven't been using java applets for 3 years(The last time I've used it was for a course homework :) ) I have forgotten most of the concepts. I googled and found that link:
<a href="http://www.daniweb.com/forums/thread101963.html" rel="noreferrer">Dani web</a></p>
<p>But in the method described in above link you have to put a JFrame inside the applet which I have no idea how to do it.</p>
<p>Whatever I need a quick and dirty method b'cause I don't have much time and this is the reason why I asked it here.</p>
<p>Thanx in advance</p>
| [
{
"answer_id": 431394,
"author": "Ran Biron",
"author_id": 931,
"author_profile": "https://Stackoverflow.com/users/931",
"pm_score": 3,
"selected": false,
"text": "JFrame frame = new JFrame();\n//more initialization code here\nDimension dim = Toolkit.getDefaultToolkit().getScreenSize();\... | 2009/01/10 | [
"https://Stackoverflow.com/questions/431044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50676/"
] |
431,053 | <p>What's the best way to get the rank of the rows in addition to the row data in MYSQL?</p>
<p>For instance, say I have a list of students and I want to rank on the GPA. I know I can order by the GPA, but what's the quickest way to have MYSQL return the rank as well in the rowdata I get back?</p>
| [
{
"answer_id": 431065,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 4,
"selected": true,
"text": "rownum SELECT @rownum := @rownum + 1 rownum, \n t.* \n FROM (SELECT @rownum:=0) r, \n (SELECT * FROM stu... | 2009/01/10 | [
"https://Stackoverflow.com/questions/431053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42914/"
] |
431,080 | <p>Quick one, but thought I'd ask.</p>
<p>Is there a better way of getting the column values from a model's column than something like this?</p>
<pre><code>Item.count(:all, :group => 'status').reject! { |i, e| i.blank? }.collect { |i,e| i}
</code></pre>
| [
{
"answer_id": 431109,
"author": "sikachu",
"author_id": 52035,
"author_profile": "https://Stackoverflow.com/users/52035",
"pm_score": -1,
"selected": false,
"text": "Item.count(:all, :group => \"status\", :conditions => \"status != ''\"}\n"
},
{
"answer_id": 431164,
"author"... | 2009/01/10 | [
"https://Stackoverflow.com/questions/431080",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52092/"
] |
431,081 | <p>This is related to
<a href="https://stackoverflow.com/questions/431045/linux-device-driver-unsave-fxsave-fxrstor-bug-any-precedents">this question</a>.</p>
<p>I'm not an expert on Linux device drivers or kernel modules, but I've been reading "Linux Device Drivers" [O'Reilly] by Rubini & Corbet and a number of online sources, but I haven't been able to find anything on this specific issue yet.</p>
<p>When is a kernel or driver module allowed to use floating-point registers? <BR>
If so, who is responsible for saving and restoring their contents? <BR>
(Assume x86-64 architecture) </p>
<p>If I understand correctly, whenever a KM is running, it is using a hardware context (or hardware thread or register set -- whatever you want to call it) that has been preempted from some application thread. If you write your KM in c, the compiler will correctly insure that the general-purpose registers are properly saved and restored (much as in an application), but that doesn't automatically happen with floating-point registers. For that matter, a lot of KMs can't even assume that the processor has any floating-point capability.</p>
<p>Am I correct in guessing that a KM that wants to use floating-point has to carefully save and restore the floating-point state? Are there standard kernel functions for doing this?</p>
<p>Are the coding conventions for this spelled out anywhere?<BR> Are they different for SMP-non SMP drivers? <BR> Are they different for older non-preemptive kernels and newer preemptive kernels?</p>
| [
{
"answer_id": 431323,
"author": "jpalecek",
"author_id": 51831,
"author_profile": "https://Stackoverflow.com/users/51831",
"pm_score": 4,
"selected": true,
"text": "kernel_fpu_begin() kernel_fpu_end() preempt_disable() preempt_enable()"
}
] | 2009/01/10 | [
"https://Stackoverflow.com/questions/431081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40756/"
] |
431,082 | <p>Using POSIX threads & C++, I have an "Insert operation" which can only be done safely one at a time.</p>
<p>If I have multiple threads waiting to insert using pthread_join then spawning a new thread
when it finishes. Will they all receive the "thread complete" signal at once and spawn multiple inserts or is it safe to assume that the thread that receives the "thread complete" signal first will spawn a new thread blocking the others from creating new threads.</p>
<pre><code>/* --- GLOBAL --- */
pthread_t insertThread;
/* --- DIFFERENT THREADS --- */
// Wait for Current insert to finish
pthread_join(insertThread, NULL);
// Done start a new one
pthread_create(&insertThread, NULL, Insert, Data);
</code></pre>
<hr>
<p>Thank you for the replies</p>
<p>The program is basically a huge hash table which takes requests from clients through Sockets.</p>
<p>Each new client connection spawns a new thread from which it can then perform multiple operations, specifically lookups or inserts. lookups can be conducted in parallel. But inserts need to be "re-combined" into a single thread. You could say that lookup operations could be done without spawning a new thread for the client, however they can take a while causing the server to lock, dropping new requests. The design tries to minimize system calls and thread creation as much as possible. </p>
<p>But now that i know it's not safe the way i first thought I should be able to cobble something together</p>
<p>Thanks</p>
| [
{
"answer_id": 431114,
"author": "gimpf",
"author_id": 15529,
"author_profile": "https://Stackoverflow.com/users/15529",
"pm_score": 3,
"selected": true,
"text": "insert_finished insert insert"
},
{
"answer_id": 432776,
"author": "zootreeves",
"author_id": 51467,
"aut... | 2009/01/10 | [
"https://Stackoverflow.com/questions/431082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51467/"
] |
431,091 | <p>It's possible to declare variables with the below structure in C++</p>
<pre><code>private:
public:
protected:
float bla1;
float bla2;
float bla3;
</code></pre>
<p>Is there an equivalent in C#? It seems rather tedious having to repeat yourself;</p>
<pre><code>protected float bla1;
protected float bla2;
protected float bla3;
</code></pre>
| [
{
"answer_id": 431099,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 3,
"selected": false,
"text": "protected float bla1, bla2, bla3;\n"
}
] | 2009/01/10 | [
"https://Stackoverflow.com/questions/431091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17540/"
] |
431,107 | <p>We have started using Spring framework in my project. After becoming acquainted with the basic features (IoC) we have started using spring aop and spring security as well.</p>
<p>The problem is that we now have more than 8 different context files and I feel we didn't give enough thought for the organization of those files and their roles. New files were introduced as the project evolved.
We have different context files for: metadata, aop, authorization, services, web resources (it's a RESTful application). So when a developer wants to add a new bean it's not always clear in which file he should add it. We need methodology.</p>
<p>The question:</p>
<p>Is there a best practice for spring files organization?</p>
<p>Should the context files encapsulate layers (DAL , Business Logic, Web) or use cases ? or Flows? </p>
| [
{
"answer_id": 11130632,
"author": "Kariem",
"author_id": 12039,
"author_profile": "https://Stackoverflow.com/users/12039",
"pm_score": 1,
"selected": false,
"text": "META-INF/spring src/\n+-- main/\n| +-- java/\n| \\-- resources/\n| +-- META-INF/\n| | \\-- spring/ ... | 2009/01/10 | [
"https://Stackoverflow.com/questions/431107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52954/"
] |
431,119 | <p>To me it was the If statement, I'm psyched up, since then I believed that computers are very intelligent, or I can at least make it appear intelligent because of it.</p>
| [
{
"answer_id": 431124,
"author": "Kristopher Johnson",
"author_id": 1175,
"author_profile": "https://Stackoverflow.com/users/1175",
"pm_score": 4,
"selected": false,
"text": "10 PRINT \"Commodore sucks! \"\n20 GOTO 10\n"
},
{
"answer_id": 431133,
"author": "coobird",
"au... | 2009/01/10 | [
"https://Stackoverflow.com/questions/431119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11432/"
] |
431,120 | <p>Does anyone got an ideia on how to get client side image resize using flash.</p>
<p>Example:
Client chooses an image with 1200x800 and before it uploads it flash will turn it into half of it or something.</p>
<p>Any thoughts?</p>
| [
{
"answer_id": 449751,
"author": "Scott Evernden",
"author_id": 11397,
"author_profile": "https://Stackoverflow.com/users/11397",
"pm_score": 1,
"selected": false,
"text": "function resize(obm:BitmapData, scale:Number): BitmapData {\n var resizeMatrix:Matrix = new Matrix();\n resizeM... | 2009/01/10 | [
"https://Stackoverflow.com/questions/431120",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52730/"
] |
431,123 | <p>can some one help me with the following JSF dataTable? here I am getting data from database table and I used dataTable binding, but I don't know why it displays the rows 3 times in the screen, but if I remove the binding then it displays only one time.</p>
<hr>
<pre><code><h:dataTable binding="#{threadController.dataTable}" var="category" value="#{threadController.queryCategories}" border="1" cellpadding="2" cellspacing="0">
<h:column>
<img src="../../images/directory.jpg" alt="Forum Icon" />
</h:column>
<h:column>
<h:form>
<h:commandLink value="#{category.cname}" action="#{threadController.categoryDateItem}" />
</h:form>
</h:column>
</code></pre>
<h2> </h2>
<pre><code>// defined globally
private HtmlDataTable dataTable;
private HtmlInputHidden dataItemId = new HtmlInputHidden();
public String categoryDateItem() {
category = (Category) dataTable.getRowData();
System.out.println("category action by select: "+category.getCname());
dataItemId.setValue(category.getId());
return "editItem"; // Navigation case.
}
@SuppressWarnings("unchecked")
public ArrayList<Category> getQueryCategories(){
return (ArrayList<Category>)HibernateUtil.getSession().createCriteria(Category.class).list();
}
</code></pre>
<hr>
<p>output:</p>
<pre><code> myText myText myText
</code></pre>
| [
{
"answer_id": 456262,
"author": "billjamesdev",
"author_id": 13824,
"author_profile": "https://Stackoverflow.com/users/13824",
"pm_score": 0,
"selected": false,
"text": "// Somewhere near the top of the handler class.. create a cache variable:\nprivate ArrayList<Category> qCategories = ... | 2009/01/10 | [
"https://Stackoverflow.com/questions/431123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
431,138 | <p>When doing thread synchronization in C# should I also lock an object when I read a value or just changing it?</p>
<p>for example I have Queue<T> object. Should I just lock it when doing the Enqueue and Dequeue or should I also lock it when checking values like Count?</p>
| [
{
"answer_id": 431150,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 0,
"selected": false,
"text": "int long Count Int32"
},
{
"answer_id": 431161,
"author": "Cristian Libardo",
"author_id": 16526,
... | 2009/01/10 | [
"https://Stackoverflow.com/questions/431138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20183/"
] |
431,159 | <p>Is there an existing Java library that could tell me whether a String contains English language text or not (e.g. I need to be able to distinguish French or Italian text -- the function needs to return false for French and Italian, and true for English)?</p>
| [
{
"answer_id": 431328,
"author": "Neil Coffey",
"author_id": 48933,
"author_profile": "https://Stackoverflow.com/users/48933",
"pm_score": 3,
"selected": false,
"text": " Locale.ENGLISH,\n \"he_=38426;the=38122;nd_=20901;ed_=20519;and=18417;ing=16248;to_=15295;ng_=15281;er_=15192;a... | 2009/01/10 | [
"https://Stackoverflow.com/questions/431159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
431,165 | <p>Okay, I've got my normal app which is in portrait mode. I can force my app to go to landscape mode for a view (using navigationcontroller and viewcontroller) like this:</p>
<pre><code>- (void)viewWillAppear:(BOOL)animated {
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
}
</code></pre>
<p>But then when I go back to the main menu (tableview) it goes straight back to portrait. I try this code:</p>
<pre><code>- (void)viewWillAppear:(BOOL)animated {
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
}
</code></pre>
<p>But that doesn't work..</p>
<p>Any ideas?</p>
| [
{
"answer_id": 433514,
"author": "Domness",
"author_id": 53677,
"author_profile": "https://Stackoverflow.com/users/53677",
"pm_score": 3,
"selected": false,
"text": "- (void)viewWillAppear:(BOOL)animated {\n [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];\n\n... | 2009/01/10 | [
"https://Stackoverflow.com/questions/431165",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53677/"
] |
431,201 | <p>Suppose I have two branches of a project IMClient-MacOS and IMClient-Windows, and their code only differs by (let's say) one directory main/. All the other directories contain system-independent code and are interchangeable.</p>
<p>Some workers work on the Windows version, and some work on the MacOS version. How do they prevent overwriting changing into the main/ directory when they merge from their counterparts' branch? Is there a way to merge in Git that will always ignore the OS-dependent directory?</p>
| [
{
"answer_id": 431498,
"author": "sikachu",
"author_id": 52035,
"author_profile": "https://Stackoverflow.com/users/52035",
"pm_score": 1,
"selected": false,
"text": ".gitignore cherry-picking git cherry-pick refspec main"
},
{
"answer_id": 431555,
"author": "Norman Ramsey",
... | 2009/01/10 | [
"https://Stackoverflow.com/questions/431201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10675/"
] |
431,203 | <p>This question is inspired by Jon Skeet's answer:
<a href="https://stackoverflow.com/questions/431091/is-there-a-c-equivalent-to-cs-access-modifier-regions#431105">Is there a c# equivalent to c++'s access-modifier regions</a></p>
<p>He makes a comment that it is possible for the order of fields in a file to matter. I am guessing that this has to do with the order that the fields are initialized, but I think it's a dangerous enough thing to code based on this side effect that it warranted its own question and discussion. </p>
<p>Are there other thoughts around how the order of fields within your code file could be manipulated and what impact that might have?</p>
| [
{
"answer_id": 431221,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "using System;\n\nclass First\n{\n static int a = 10;\n public static int b = CalculateB();\n static int c = 5;\... | 2009/01/10 | [
"https://Stackoverflow.com/questions/431203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26160/"
] |
431,205 | <p>How would I go about programmatically changing the desktop background in Mac OS X? I'd like to use python, but I'm interested in any way possible. Could I hook up to Terminal and call a certain command?</p>
| [
{
"answer_id": 431279,
"author": "dF.",
"author_id": 3002,
"author_profile": "https://Stackoverflow.com/users/3002",
"pm_score": 6,
"selected": true,
"text": "sudo easy_install appscript from appscript import app, mactypes\napp('Finder').desktop_picture.set(mactypes.File('/your/filename.... | 2009/01/10 | [
"https://Stackoverflow.com/questions/431205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1615/"
] |
431,206 | <p>Firstly,</p>
<p>Using <b>plain</b> C++, without ATL, MFC attempting to use COM Object interface.</p>
<p>Using <b>oleview</b> (OLE/COM Object viewer) - used to engineer the IDL code.</p>
<p>At this stage, using <b>MIDL</b> Compiler, now I'm having trouble trying to produce the following:</p>
<p>Syntax on cmd line:</p>
<p>midl /nologo /env win32 /tlb ".\S8_.tlb" /h ".\S8_.h" /iid ".\S8_i.c" S8.idl</p>
<ul>
<li>A corresponding .TLB (Type Library)
</li>
<li>A .H (header)
</li>
<li>An IID definitions include file (*_i.c)
</li>
<li>A proxy (*_p.c)
</li>
</ul>
<p>MIDL compiler error:</p>
<p>S8.IDL(513) : error MIDL2025 : syntax error : expecting a type specification near "S8SimObject"</p>
<pre><code> HRESULT LinkSimObjects(
[in] S8SimObject* SourceObject, ####line 513 ####
[in] S8SimObject* DestObject,
[in] float TravelTime);
</code></pre>
| [
{
"answer_id": 431279,
"author": "dF.",
"author_id": 3002,
"author_profile": "https://Stackoverflow.com/users/3002",
"pm_score": 6,
"selected": true,
"text": "sudo easy_install appscript from appscript import app, mactypes\napp('Finder').desktop_picture.set(mactypes.File('/your/filename.... | 2009/01/10 | [
"https://Stackoverflow.com/questions/431206",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51078/"
] |
431,208 | <p>HI Guys,</p>
<p>I own a website I have a section called "mobile Section" this section contain many catagories (Nameoftheobject + a picture + little description and a download link)
Now the section is considered as an internal section. I want to view random records from that section on the first page (I dont know Like RSS but not Rss) showing
the name of the object and to which subcategories it belong and its picture if possible.
I hope any one understand what I'm trying to say. </p>
<p>This is my website <a href="http://www.sy-stu.com" rel="nofollow noreferrer">HERE</a> and this the link of the internal page <a href="http://www.sy-stu.com/stu/prog.php?PHPSESSID=249686f422aa4d8b1d06afaf44d7eee6" rel="nofollow noreferrer">HERE</a> check the block that say Mobile Section Its kinda a mess.
is there any script or a tech to view it in a proper way to view it show me examples if possible</p>
<p>I'm using php and MySQL</p>
<p>Thanx in advance</p>
| [
{
"answer_id": 431248,
"author": "DavGarcia",
"author_id": 40161,
"author_profile": "https://Stackoverflow.com/users/40161",
"pm_score": -1,
"selected": false,
"text": "SELECT TOP 1 Name, Picture, Description, Link\nFROM Software\nWHERE Category = 'Mobile Section'\nORDER BY NEWID()\n"
... | 2009/01/10 | [
"https://Stackoverflow.com/questions/431208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
431,217 | <p>For anyone who places braces thus:</p>
<pre><code>void f() {
stuff();
}
</code></pre>
<p>How do you prefer to place braces after long initializer lists?<br>
The same way?</p>
<pre><code>Object::Object()
: foo(1)
, bar(2) {
stuff();
}
</code></pre>
<p>Or make an exception so you actually see where the init list ends?</p>
<pre><code>Object::Object()
: foo(1)
, bar(2)
{
stuff();
}
</code></pre>
<p>Or leave a blank line?</p>
<pre><code>Object::Object()
: foo(1)
, bar(2) {
stuff();
}
</code></pre>
<p>Or maybe make a weird hybrid?</p>
<pre><code>Object::Object()
: foo(1)
, bar(2)
{
stuff();
}
</code></pre>
<p>Or abuse indentation</p>
<pre><code>Object::Object()
: foo(1)
, bar(2) {
stuff();
}
Object::Object() : foo(1)
, bar(2) {
stuff();
}
</code></pre>
<p>In this small example all are pretty but crank a dozen initializers and a moderately long function body and this quickly changes.</p>
| [
{
"answer_id": 431227,
"author": "Paul Beckingham",
"author_id": 14356,
"author_profile": "https://Stackoverflow.com/users/14356",
"pm_score": 2,
"selected": false,
"text": "Object::Object ()\n : foo (1)\n , bar (2)\n{\n ...\n}\n"
},
{
"answer_id": 431238,
"author": "Andru... | 2009/01/10 | [
"https://Stackoverflow.com/questions/431217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
431,230 | <p>Open up a Rails console and enter this:</p>
<pre><code>2.weeks.ago.between? 2.weeks.ago, 1.week.ago
</code></pre>
<p>Did it give you true or false? No really, try it a few more times and it will give you different answers.</p>
<p>Now, I'm thinking that because we're comparing 2.weeks.ago with 2.weeks.ago, the time between evaluating the two statements is causing this behavior.</p>
<p>I can't say for sure, but I am guessing that the between? method is not inclusive and so if a few milliseconds elapsed between the two statements, the above code will evaluate to true because it will be in between the two dates compared.</p>
<p>However, if the CPU manages to process this quickly enough such that the time elapsed is ignorable, then it will evaluate to false.</p>
<p>Can anyone shed some light on this? It is an edge case at best in a system where this might be critical, but it was giving me a headache when my tests passed and failed seemingly at random.</p>
<p>Oddly enough, this doesn't happen when doing:</p>
<pre><code> Date.yesterday.between? Date.yesterday, Date.tomorrow
</code></pre>
| [
{
"answer_id": 431347,
"author": "Tony Fontenot",
"author_id": 42357,
"author_profile": "https://Stackoverflow.com/users/42357",
"pm_score": 1,
"selected": false,
"text": "2.weeks.ago"
},
{
"answer_id": 435312,
"author": "Ryan Bigg",
"author_id": 15245,
"author_profil... | 2009/01/10 | [
"https://Stackoverflow.com/questions/431230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6291/"
] |
431,233 | <p>I'm trying to use the Server class from Cassini to include a basic web server in my own application. I just started playing around with it to get familiar with the way the server works and I setup a simple app that is as follows:</p>
<pre><code> static void Main(string[] args)
{
Server server = new Server(80, "/", @"C:\Projects\");
server.Start();
Console.ReadLine();
server.Stop();
}
</code></pre>
<p>It lets me browse through the directories, however if I try to click on a file, a C# source file (*.cs) for example, it gives the following error:</p>
<blockquote>
<p>Server Error in '/' Application.</p>
<p>This type of page is not served.</p>
<p>Description: The type of page you have
requested is not served because it has
been explicitly forbidden. The
extension '.cs' may be incorrect.<br>
Please review the URL below and make
sure that it is spelled correctly.</p>
</blockquote>
<p>I tried searching for that error text in the Cassini libraries, but didn't find anything.</p>
<p>Where is this error coming from? How can I make it serve up any file?
I know it's meant to do asp.net and HTML, but I want it to also server up any file like a normal server would.</p>
| [
{
"answer_id": 431326,
"author": "Kev",
"author_id": 419,
"author_profile": "https://Stackoverflow.com/users/419",
"pm_score": 3,
"selected": true,
"text": ".cs c:\\windows\\microsoft.net\\v2.0.50727\\CONFIG\\web.config <httpHandlers> <add path=\"*.cs\" verb=\"*\" type=\"System.Web.HttpF... | 2009/01/10 | [
"https://Stackoverflow.com/questions/431233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/194/"
] |
431,249 | <p>I have moderate size solution in Visual Studio which takes around 5 minutes to build (It take that long because of FxCop and other post build steps).
My problem is, Visual Studio stops responding while it's building. You can't continue working as VS almost hangs. I tried using two VS instances, just using one for build, but it keeps crashing every now and then.</p>
<p>My question is, How to not waste time looking at Visual Studio building your large/moderate project. Are there any best practices for this?</p>
| [
{
"answer_id": 431264,
"author": "DavGarcia",
"author_id": 40161,
"author_profile": "https://Stackoverflow.com/users/40161",
"pm_score": 3,
"selected": false,
"text": "<CreateItem Include=\"server1;server2;server3;server2\">\n <Output ItemName=\"IISServer\" TaskParameter=\"Include\"/>\n... | 2009/01/10 | [
"https://Stackoverflow.com/questions/431249",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50481/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.