qid int64 4 19.1M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
35,700 | <p>What things should be kept most in mind when writing cross-platform applications in C? Targeted platforms: 32-bit Intel based PC, Mac, and Linux. I'm especially looking for the type of versatility that Jungle Disk has in their USB desktop edition ( <a href="http://www.jungledisk.com/desktop/download.aspx" rel="noreferrer">http://www.jungledisk.com/desktop/download.aspx</a> )</p>
<p>What are tips and "gotchas" for this type of development?</p>
| [
{
"answer_id": 372091,
"author": "flolo",
"author_id": 36472,
"author_profile": "https://Stackoverflow.com/users/36472",
"pm_score": 0,
"selected": false,
"text": "int c;\nfread(&c, sizeof(int), 1, file);\n"
}
] | 2008/08/30 | [
"https://Stackoverflow.com/questions/35700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/356/"
] |
35,743 | <p>According to <a href="http://msdn.microsoft.com/en-us/library/bb386454.aspx" rel="noreferrer">Microsoft</a> the FileUpload control is not compatible with an AJAX UpdatePanel. </p>
<p>I am aware that a PostBackTrigger can be added to the submit button of the form like this:</p>
<pre><code><Triggers>
<asp:PostBackTrigger ControlID="Button1" />
</Triggers>
</code></pre>
<p>The problem is that this forces the form to perform a full post-back which voids out the whole point of using the UpdatePanel in the first place. Is there a workaround to this issue that does not cause the whole page to refresh?</p>
| [
{
"answer_id": 36859,
"author": "palotasb",
"author_id": 3063,
"author_profile": "https://Stackoverflow.com/users/3063",
"pm_score": 2,
"selected": false,
"text": "AJAX HTML iframe"
},
{
"answer_id": 217722,
"author": "user10859",
"author_id": 10859,
"author_profile":... | 2008/08/30 | [
"https://Stackoverflow.com/questions/35743",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3677/"
] |
35,753 | <p>Right now I'm developing mostly in C/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). </p>
<p>Except for the performances (a problem that could be sometimes solved thanks to the ease of interfacing Python with C modules), do you think it is proper for production use in the development of stand-alone complex applications (think for example to a word processor or a graphic tool)?</p>
<p>What IDE would you suggest? The IDLE provided with Python is not enough even for small projects in my opinion.</p>
| [
{
"answer_id": 35759,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 4,
"selected": false,
"text": "assert"
}
] | 2008/08/30 | [
"https://Stackoverflow.com/questions/35753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3373/"
] |
35,785 | <p>What is the Java analogue of .NET's XML serialization?</p>
| [
{
"answer_id": 4067429,
"author": "so_mv",
"author_id": 186858,
"author_profile": "https://Stackoverflow.com/users/186858",
"pm_score": 4,
"selected": false,
"text": "FREE Simple"
},
{
"answer_id": 18681762,
"author": "Mishax",
"author_id": 1766655,
"author_profile": ... | 2008/08/30 | [
"https://Stackoverflow.com/questions/35785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3583/"
] |
35,805 | <p>If I create a class <code>A</code> as follows:</p>
<pre><code>class A:
def __init__(self):
self.name = 'A'
</code></pre>
<p>Inspecting the <code>__dict__</code> member looks like <code>{'name': 'A'}</code></p>
<p>If however I create a class <code>B</code>:</p>
<pre><code>class B:
name = 'B'
</code></pre>
<p><code>__dict__</code> is empty.</p>
<p>What is the difference between the two, and why doesn't <code>name</code> show up in <code>B</code>'s <code>__dict__</code>?</p>
| [
{
"answer_id": 35823,
"author": "Carl Meyer",
"author_id": 3207,
"author_profile": "https://Stackoverflow.com/users/3207",
"pm_score": 7,
"selected": true,
"text": "B.name B.__dict__ b = B(); b.__dict__ b.name B.name"
},
{
"answer_id": 39755,
"author": "Tendayi Mawushe",
... | 2008/08/30 | [
"https://Stackoverflow.com/questions/35805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3154/"
] |
35,817 | <p>When using os.system() it's often necessary to escape filenames and other arguments passed as parameters to commands. How can I do this? Preferably something that would work on multiple operating systems/shells but in particular for bash.</p>
<p>I'm currently doing the following, but am sure there must be a library function for this, or at least a more elegant/robust/efficient option:</p>
<pre><code>def sh_escape(s):
return s.replace("(","\\(").replace(")","\\)").replace(" ","\\ ")
os.system("cat %s | grep something | sort > %s"
% (sh_escape(in_filename),
sh_escape(out_filename)))
</code></pre>
<p><em>Edit:</em> I've accepted the simple answer of using quotes, don't know why I didn't think of that; I guess because I came from Windows where ' and " behave a little differently.</p>
<p>Regarding security, I understand the concern, but, in this case, I'm interested in a quick and easy solution which os.system() provides, and the source of the strings is either not user-generated or at least entered by a trusted user (me).</p>
| [
{
"answer_id": 35857,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 8,
"selected": true,
"text": "def shellquote(s):\n return \"'\" + s.replace(\"'\", \"'\\\\''\") + \"'\"\n"
},
{
"answer_id": 35858,
"autho... | 2008/08/30 | [
"https://Stackoverflow.com/questions/35817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3715/"
] |
35,837 | <p>I've been using git for some time now on Windows (with msysGit) and I like the idea of distributed source control. Just recently I've been looking at Mercurial (hg) and it looks interesting. However, I can't wrap my head around the differences between hg and git.</p>
<p>Has anyone made a side-by-side comparison between git and hg? I'm interested to know what differs hg and git without having to jump into a fanboy discussion.</p>
| [
{
"answer_id": 892688,
"author": "Martin Geisler",
"author_id": 110204,
"author_profile": "https://Stackoverflow.com/users/110204",
"pm_score": 8,
"selected": false,
"text": "git-instaweb.sh git fetch <project-to-union-merge>\nGIT_INDEX_FILE=.git/tmp-index git-read-tree FETCH_HEAD\nGIT_I... | 2008/08/30 | [
"https://Stackoverflow.com/questions/35837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3713/"
] |
35,842 | <p>How do I get the id of my Java process? </p>
<p>I know there are several platform-dependent hacks, but I would prefer a more generic solution.</p>
| [
{
"answer_id": 35885,
"author": "Wouter Coekaerts",
"author_id": 3432,
"author_profile": "https://Stackoverflow.com/users/3432",
"pm_score": 10,
"selected": true,
"text": "ManagementFactory.getRuntimeMXBean().getName() \"12345@hostname\" 12345 long pid = ProcessHandle.current().pid();\n"... | 2008/08/30 | [
"https://Stackoverflow.com/questions/35842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3583/"
] |
35,848 | <p>I have a VB6.0 project and I want to convert it in VB.Net.</p>
<p>In my VB6.0 application some of the MDI Child form’s height is 17000 and width is 13000. Now I want to set the same form size in VB.Net forms, but it allows maximum form width = 1036, height = 780 for resolution 1024x768.</p>
<p>How can I increase form size with same resolution?</p>
<p>Also I want to print this from so, I can not use auto scroll property of vb.net forms.</p>
<p>Thaks</p>
| [
{
"answer_id": 154479,
"author": "Eduardo Molteni",
"author_id": 2385,
"author_profile": "https://Stackoverflow.com/users/2385",
"pm_score": 1,
"selected": false,
"text": "Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load\n Me.Heigh... | 2008/08/30 | [
"https://Stackoverflow.com/questions/35848",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2528/"
] |
35,849 | <p>So we've discussed logging in passing at my place of work and I was wondering if some of you guys here could give me some ideas of your approaches?</p>
<p>Typically our scenario is, no logging really at all, and mostly .NET apps, winforms/WPF clients talking through web services or direct to a db.</p>
<p>So, the real question is, where or what would you log? At the moment we have users reporting error messages - so I would assume log startups/shutdowns, exceptions...</p>
<p>Do you take it to calls to the web services or db? Page loads?</p>
<p>How do you get a good idea of what the user was trying to do at the time?</p>
<p>Is it better to go all the way and log everything across multiple attempts/days, or log only what you need to (given hdd is cheap).</p>
<p>I guess that's a few questions, but I wanted to get more of an idea of what the actual practice is out there in larger shops!</p>
| [
{
"answer_id": 35875,
"author": "Tristan Juricek",
"author_id": 3436,
"author_profile": "https://Stackoverflow.com/users/3436",
"pm_score": 1,
"selected": false,
"text": "info(\"waaah\") warning(\"waah\")"
}
] | 2008/08/30 | [
"https://Stackoverflow.com/questions/35849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3717/"
] |
35,870 | <p>I have a list of more than 15 thousand latitude and longitude coordinates. Given any X,Y coordinates, what is the fastest way to find the closest coordinates on the list?</p>
| [
{
"answer_id": 35946,
"author": "Jeremy",
"author_id": 3657,
"author_profile": "https://Stackoverflow.com/users/3657",
"pm_score": 3,
"selected": false,
"text": "select *\n from dealers\n where latitude >= minlat\n and latitude <= maxlat\n and longitude >= minlong\n ... | 2008/08/30 | [
"https://Stackoverflow.com/questions/35870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3725/"
] |
35,879 | <p>I am building an open search add-on for Firefox/IE and the image needs to be Base64 Encoded so how can I base 64 encode the favicon I have?</p>
<p>I am only familiar with PHP</p>
| [
{
"answer_id": 35891,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 7,
"selected": true,
"text": " <?php\n $im = file_get_contents('filename.gif');\n $imdata = base64_encode($im); \n?> \n <img width=\"16\" he... | 2008/08/30 | [
"https://Stackoverflow.com/questions/35879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/115/"
] |
35,896 | <p>Is there a portable, not patent-restricted way to play compressed sound files in C# / .Net? I want to play short "jingle" sounds on various events occuring in the program.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.media.soundplayer.aspx" rel="noreferrer">System.Media.SoundPlayer</a> can handle only WAV, but those are typically to big to embed in a downloadable apllication. MP3 is protected with patents, so even if there was a fully managed decoder/player it wouldn't be free to redistribute. The best format available would seem to be OGG Vorbis, but I had no luck getting any C# Vorbis libraries to work (I managed to extract a raw PCM with <a href="https://github.com/mono/csvorbis" rel="noreferrer">csvorbis</a> but I don't know how to play it afterwards).</p>
<p>I neither want to distribute any binaries with my application nor depend on P/Invoke, as the project should run at least on Windows and Linux. I'm fine with bundling .Net assemblies as long as they are license-compatible with GPL.</p>
<p>[this question is a follow up to a <a href="http://lists.ximian.com/pipermail/mono-devel-list/2007-June/023863.html" rel="noreferrer">mailing list discussion on mono-dev</a> mailing list a year ago]</p>
| [
{
"answer_id": 36050,
"author": "skolima",
"author_id": 3205,
"author_profile": "https://Stackoverflow.com/users/3205",
"pm_score": 4,
"selected": true,
"text": "System.Media.SoundPlayer using (var file = new FileStream(oggFilename, FileMode.Open, FileAccess.Read))\n{\n var player = new... | 2008/08/30 | [
"https://Stackoverflow.com/questions/35896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3205/"
] |
35,905 | <p>I've created a few <code>autorun</code> script files on various USB devices that run <code>bash</code> scripts when they mount. These scripts run "in the background", how do I get them to run in a terminal window? (Like the "Application in Terminal" gnome Launcher type.)</p>
| [
{
"answer_id": 35924,
"author": "Vagnerr",
"author_id": 3720,
"author_profile": "https://Stackoverflow.com/users/3720",
"pm_score": 4,
"selected": true,
"text": "gnome-terminal -e top --title Testing\n"
},
{
"answer_id": 35925,
"author": "Steve Moon",
"author_id": 3660,
... | 2008/08/30 | [
"https://Stackoverflow.com/questions/35905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3715/"
] |
35,914 | <p>Here's the situation: I am trying to launch an application, but the location of the .exe isn't known to me. Now, if the file extension is registered (in Windows), I can do something like:</p>
<pre><code>Process.Start("Sample.xls");
</code></pre>
<p>However, I need to pass some command line arguments as well. I couldn't get this to work</p>
<pre><code> Process p = new Process();
p.StartInfo.FileName = "Sample.xls";
p.StartInfo.Arguments = "/r"; // open in read-only mode
p.Start();
</code></pre>
<p>Any suggestions on a mechanism to solve this?</p>
<p><strong>Edit</strong> @ aku</p>
<p>My StackOverflow search skills are weak; I did not find that post. Though I generally dislike peering into the registry, that's a great solution. Thanks!</p>
| [
{
"answer_id": 35930,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 3,
"selected": true,
"text": "Process.Start"
}
] | 2008/08/30 | [
"https://Stackoverflow.com/questions/35914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2258/"
] |
35,922 | <p>I've played around with GTK, TK, wxPython, Cocoa, curses and others. They are are fairly horrible to use.. GTK/TK/wx/curses all seem to basically be direct-ports of the appropriate C libraries, and Cocoa basically mandates using both PyObjC and Interface Builder, both of which I dislike..</p>
<p>The Shoes GUI library for Ruby is great.. It's very sensibly designed, and very "rubyish", and borrows some nice-to-use things from web development (like using hex colours codes, or <code>:color => rgb(128,0,0)</code>)</p>
<p>As the title says: are there any nice, "Pythonic" GUI toolkits?</p>
| [
{
"answer_id": 106696,
"author": "Ed Leafe",
"author_id": 19399,
"author_profile": "https://Stackoverflow.com/users/19399",
"pm_score": 4,
"selected": false,
"text": "obj.BackColor = \"red\"\nobj.BackColor = (255, 0, 0)\nobj.BackColor = \"FF0000\"\nobj.BackColor = \"#FF0000\"\n"
}
] | 2008/08/30 | [
"https://Stackoverflow.com/questions/35922",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/745/"
] |
35,948 | <p>I'm using Google App Engine and Django templates.<br>
I have a table that I want to display the objects look something like:<br></p>
<pre><code>Object Result:
Items = [item1,item2]
Users = [{name='username',item1=3,item2=4},..]
</code></pre>
<p>The Django template is:</p>
<pre><code><table>
<tr align="center">
<th>user</th>
{% for item in result.items %}
<th>{{item}}</th>
{% endfor %}
</tr>
{% for user in result.users %}
<tr align="center">
<td>{{user.name}}</td>
{% for item in result.items %}
<td>{{ user.item }}</td>
{% endfor %}
</tr>
{% endfor %}
</table>
</code></pre>
<p>Now the <a href="http://www.djangoproject.com/documentation/0.96/templates/#variables" rel="noreferrer">Django documention</a> states that when it sees a <strong>.</strong> in variables<br>
It tries several things to get the data, one of which is dictionary lookup which is exactly what I want but doesn't seem to happen...</p>
| [
{
"answer_id": 35978,
"author": "David Webb",
"author_id": 3171,
"author_profile": "https://Stackoverflow.com/users/3171",
"pm_score": 3,
"selected": false,
"text": "{{ user.item }} \"item\" item {{ user.name }} name user name"
},
{
"answer_id": 37190,
"author": "Nic Wise",
... | 2008/08/30 | [
"https://Stackoverflow.com/questions/35948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3117/"
] |
35,950 | <p>I need an associative container that makes me index a certain object through a string, but that also keeps the order of insertion, so I can look for a specific object by its name or just iterate on it and retrieve objects in the same order I inserted them.</p>
<p>I think this <a href="http://www.ddj.com/cpp/184406207" rel="nofollow noreferrer">hybrid of linked list and hash map</a> should do the job, but before I tried to use <code>std::tr1::unordered_map</code> thinking that it was working in that way I described, but it wasn't. So could someone explain me the meaning and behavior of <code>unordered_map</code>?</p>
<hr>
<p>@wesc: I'm sure std::map is implemented by STL, while I'm sure std::hash_map is NOT in the STL (I think older version of Visual Studio put it in a namespace called stdext).</p>
<p>@cristopher: so, if I get it right, the difference is in the implementation (and thus performances), not in the way it behaves externally.</p>
| [
{
"answer_id": 35965,
"author": "Christopher",
"author_id": 3186,
"author_profile": "https://Stackoverflow.com/users/3186",
"pm_score": 3,
"selected": true,
"text": "operator< operator( key ) => index"
}
] | 2008/08/30 | [
"https://Stackoverflow.com/questions/35950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3373/"
] |
35,954 | <p>I have a query that originally looks like this:</p>
<pre><code>select c.Id, c.Name, c.CountryCode, c.CustomerNumber, cacc.AccountNumber, ca.Line1, ca.CityName, ca.PostalCode
from dbo.Customer as c
left join dbo.CustomerAddress as ca on ca.CustomerId = c.Id
left join dbo.CustomerAccount as cacc on cacc.CustomerId = c.Id
where c.CountryCode = 'XX' and (cacc.AccountNumber like '%C17%' or c.Name like '%op%'
or ca.Line1 like '%ae%' or ca.CityName like '%ab%' or ca.PostalCode like '%10%')
</code></pre>
<p>On a database with 90,000 records this query takes around 7 seconds to execute (obviously all the joins and likes are taxing). </p>
<p>I have been trying to find a way to bring the query execution time down with full-text search on the columns concerned. However, I haven't seen an example of a full-text search that has three table joins like this, especially since my join condition is not part of the search term.</p>
<p>Is there a way to do this in full-text search?</p>
<hr>
<p>@David</p>
<p>Yep, there are indexes on the Ids.</p>
<p>I've tried adding indexes on the CustomerAddress stuff (CityName, PostalCode, etc.) and it brought down the query to 3 seconds, but I still find that too slow for something like this.</p>
<p>Note that all of the text fields (with the exception of the ids) are nvarchars, and Line1 is an nvarchar 1000, so that might affect the speed, but still.</p>
| [
{
"answer_id": 35965,
"author": "Christopher",
"author_id": 3186,
"author_profile": "https://Stackoverflow.com/users/3186",
"pm_score": 3,
"selected": true,
"text": "operator< operator( key ) => index"
}
] | 2008/08/30 | [
"https://Stackoverflow.com/questions/35954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/372/"
] |
35,973 | <p>What is the best approach to define additional data for typedef enums in C?</p>
<p>Example:</p>
<pre><code>typedef enum {
kVizsla = 0,
kTerrier = 3,
kYellowLab = 10
} DogType;
</code></pre>
<p>Now I would like to define names for each, for example <code>kVizsla</code> should be "vizsla".
I currently use a function that returns a string using a large switch block.</p>
| [
{
"answer_id": 35998,
"author": "dmckee --- ex-moderator kitten",
"author_id": 2509,
"author_profile": "https://Stackoverflow.com/users/2509",
"pm_score": 1,
"selected": false,
"text": "char *DogList[] = {\n \"vizsla\", /* element 0 */\n NULL,\n NULL,\n NULL,\n \"terrier\", /* eleme... | 2008/08/30 | [
"https://Stackoverflow.com/questions/35973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3740/"
] |
35,974 | <p>I'm working on an email solution in SQL Server ONLY that will use Database Mail to send out HTML formatted emails. The catch is that the images in the HTML need to be embedded in the outgoing email. This wouldn't be a problem if I were using a .net app to generate & send the emails but, unfortunately, all I have is SQL Server.</p>
<p>Is it possible for SQL Server to embed images on its own?</p>
| [
{
"answer_id": 36173,
"author": "nathan_jr",
"author_id": 3769,
"author_profile": "https://Stackoverflow.com/users/3769",
"pm_score": 1,
"selected": false,
"text": "<img src=\"data:image/png;base64[your encoded image here...]"
},
{
"answer_id": 166446,
"author": "Josef",
... | 2008/08/30 | [
"https://Stackoverflow.com/questions/35974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3742/"
] |
35,983 | <p>Let's say I have committed some bad changes to Subversion repository. Then I commit good changes, that I want to keep.</p>
<p>What would be easiest way to roll back those bad changes in Eclipse, and keep the good changes? Assuming that files relating to bad changes are not same as those relating to the good changes. How things change if good changes were made to same files as bad changes?</p>
<p>I am mostly looking a way to do this via Eclipse plugins (Subclipse or Subversive) but commandline commands are also interesting.</p>
| [
{
"answer_id": 36063,
"author": "Fernando Barrocal",
"author_id": 2274,
"author_profile": "https://Stackoverflow.com/users/2274",
"pm_score": 6,
"selected": true,
"text": "Replace with... Latest from Repository Branch Merge svn revert svn merge"
}
] | 2008/08/30 | [
"https://Stackoverflow.com/questions/35983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1431/"
] |
35,988 | <p>Is there a way to conveniently define a C-like structure in Python? I'm tired of writing stuff like:</p>
<pre><code>class MyStruct():
def __init__(self, field1, field2, field3):
self.field1 = field1
self.field2 = field2
self.field3 = field3
</code></pre>
| [
{
"answer_id": 35990,
"author": "Mark Biek",
"author_id": 305,
"author_profile": "https://Stackoverflow.com/users/305",
"pm_score": 6,
"selected": false,
"text": "myStruct = {'field1': 'some val', 'field2': 'some val'}\n print myStruct['field1']\nmyStruct['field2'] = 'some other values'\... | 2008/08/30 | [
"https://Stackoverflow.com/questions/35988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3738/"
] |
35,991 | <p>I'm considering using Django for a project I'm starting (fyi, a browser-based game) and one of the features I'm liking the most is using <code>syncdb</code> to automatically create the database tables based on the Django models I define (a feature that I can't seem to find in any other framework).
I was already thinking this was too good to be true when I saw this in the <a href="https://docs.djangoproject.com/en/dev/ref/django-admin/" rel="noreferrer">documentation</a>:</p>
<blockquote>
<p>Syncdb will not alter existing tables</p>
<p>syncdb will only create tables for models which have not yet been installed. It will never issue ALTER TABLE statements to match changes made to a model class after installation. Changes to model classes and database schemas often involve some form of ambiguity and, in those cases, Django would have to guess at the correct changes to make. There is a risk that critical data would be lost in the process.</p>
<p>If you have made changes to a model and wish to alter the database tables to match, use the sql command to display the new SQL structure and compare that to your existing table schema to work out the changes.</p>
</blockquote>
<p>It seems that altering existing tables will have to be done "by hand".</p>
<p>What I would like to know is the best way to do this. Two solutions come to mind:</p>
<ul>
<li>As the documentation suggests, make the changes manually in the DB;</li>
<li>Do a backup of the database, wipe it, create the tables again (with syncdb, since now it's creating the tables from scratch) and import the backed-up data (this might take too long if the database is big)</li>
</ul>
<p>Any ideas?</p>
| [
{
"answer_id": 36015,
"author": "David Webb",
"author_id": 3171,
"author_profile": "https://Stackoverflow.com/users/3171",
"pm_score": 3,
"selected": false,
"text": "initial_data django-admin.py dumpdata fixtures django-admin.py loaddata initial_data.json syncdb manage.py test"
},
{
... | 2008/08/30 | [
"https://Stackoverflow.com/questions/35991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2841/"
] |
35,999 | <p>How can I execute <code>a.exe</code> using the Cygwin shell?</p>
<p>I created a C file in Eclipse on Windows and then used Cygwin to navigate to the directory. I called gcc on the C source file and <code>a.exe</code> was produced. I would like to run <code>a.exe</code>.</p>
| [
{
"answer_id": 36006,
"author": "kaiz.net",
"author_id": 3714,
"author_profile": "https://Stackoverflow.com/users/3714",
"pm_score": -1,
"selected": false,
"text": "> a\n"
},
{
"answer_id": 36016,
"author": "Jason Weathered",
"author_id": 3736,
"author_profile": "http... | 2008/08/30 | [
"https://Stackoverflow.com/questions/35999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/572/"
] |
36,001 | <p>I have a table defined (see code snippet below). How can I add a constraint or whatever so that the LastUpdate column is automatically updated anytime the row is changed?</p>
<pre><code>CREATE TABLE dbo.Profiles
(
UserName varchar(100) NOT NULL,
LastUpdate datetime NOT NULL CONSTRAINT DF_Profiles_LastUpdate DEFAULT (getdate()),
FullName varchar(50) NOT NULL,
Birthdate smalldatetime NULL,
PageSize int NOT NULL CONSTRAINT DF_Profiles_PageSize DEFAULT ((10)),
CONSTRAINT PK_Profiles PRIMARY KEY CLUSTERED (UserName ASC),
CONSTRAINT FK_Profils_Users FOREIGN KEY (UserName) REFERENCES dbo.Users (UserName) ON UPDATE CASCADE ON DELETE CASCADE
)
</code></pre>
| [
{
"answer_id": 36068,
"author": "Kevin Fairchild",
"author_id": 3743,
"author_profile": "https://Stackoverflow.com/users/3743",
"pm_score": 5,
"selected": false,
"text": "CREATE TRIGGER KeepUpdated on Profiles\nFOR UPDATE, INSERT AS \nUPDATE dbo.Profiles \nSET LastUpdate = GetDate()\nWHE... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3747/"
] |
36,014 | <p>I'm working on a project using the <a href="http://antlr.org" rel="noreferrer">ANTLR</a> parser library for C#. I've built a grammar to parse some text and it works well. However, when the parser comes across an illegal or unexpected token, it throws one of many exceptions. The problem is that in some cases (not all) that my try/catch block won't catch it and instead stops execution as an unhandled exception.</p>
<p>The issue for me is that I can't replicate this issue anywhere else but in my full code. The call stack shows that the exception definitely occurs within my try/catch(Exception) block. The only thing I can think of is that there are a few ANTLR assembly calls that occur between my code and the code throwing the exception and this library does not have debugging enabled, so I can't step through it. I wonder if non-debuggable assemblies inhibit exception bubbling? The call stack looks like this; external assembly calls are in Antlr.Runtime:</p>
<pre>
Expl.Itinerary.dll!TimeDefLexer.mTokens() Line 1213 C#
Antlr3.Runtime.dll!Antlr.Runtime.Lexer.NextToken() + 0xfc bytes
Antlr3.Runtime.dll!Antlr.Runtime.CommonTokenStream.FillBuffer() + 0x22c bytes
Antlr3.Runtime.dll!Antlr.Runtime.CommonTokenStream.LT(int k = 1) + 0x68 bytes
Expl.Itinerary.dll!TimeDefParser.prog() Line 109 + 0x17 bytes C#
Expl.Itinerary.dll!Expl.Itinerary.TDLParser.Parse(string Text = "", Expl.Itinerary.IItinerary Itinerary = {Expl.Itinerary.MemoryItinerary}) Line 17 + 0xa bytes C#
</pre>
<p>The code snippet from the bottom-most call in Parse() looks like:</p>
<pre><code> try {
// Execution stopped at parser.prog()
TimeDefParser.prog_return prog_ret = parser.prog();
return prog_ret == null ? null : prog_ret.value;
}
catch (Exception ex) {
throw new ParserException(ex.Message, ex);
}
</code></pre>
<p>To me, a catch (Exception) clause should've captured any exception whatsoever. Is there any reason why it wouldn't?</p>
<p><strong>Update:</strong> I traced through the external assembly with Reflector and found no evidence of threading whatsoever. The assembly seems to just be a runtime utility class for ANTLR's generated code. The exception thrown is from the TimeDefLexer.mTokens() method and its type is NoViableAltException, which derives from RecognitionException -> Exception. This exception is thrown when the lexer cannot understand the next token in the stream; in other words, invalid input. This exception is SUPPOSED to happen, however it should've been caught by my try/catch block.</p>
<p>Also, the rethrowing of ParserException is really irrelevant to this situation. That is a layer of abstraction that takes any exception during parse and convert to my own ParserException. The exception handling problem I'm experiencing is never reaching that line of code. In fact, I commented out the "throw new ParserException" portion and still received the same result.</p>
<p>One more thing, I modified the original try/catch block in question to instead catch NoViableAltException, eliminating any inheritance confusion. I still received the same result.</p>
<p>Someone once suggested that sometimes VS is overactive on catching handled exceptions when in debug mode, but this issue also happens in release mode.</p>
<p>Man, I'm still stumped! I hadn't mentioned it before, but I'm running VS 2008 and all my code is 3.5. The external assembly is 2.0. Also, some of my code subclasses a class in the 2.0 assembly. Could a version mismatch cause this issue?</p>
<p><strong>Update 2:</strong> I was able to eliminate the .NET version conflict by porting relevant portions of my .NET 3.5 code to a .NET 2.0 project and replicate the same scenario. I was able to replicate the same unhandled exception when running consistently in .NET 2.0.</p>
<p>I learned that ANTLR has recently released 3.1. So, I upgraded from 3.0.1 and retried. It turns out the generated code is a little refactored, but the same unhandled exception occurs in my test cases.</p>
<p><strong>Update 3:</strong>
I've replicated this scenario in a <a href="http://www.explodingcoder.com/cms/files/TestAntlr-3.1.zip" rel="noreferrer">simplified VS 2008 project</a>. Feel free to download and inspect the project for yourself. I've applied all the great suggestions, but have not been able to overcome this obstacle yet.</p>
<p>If you can find a workaround, please do share your findings. Thanks again!</p>
<hr>
<p>Thank you, but VS 2008 automatically breaks on unhandled exceptions. Also, I don't have a Debug->Exceptions dialog. The NoViableAltException that is thrown is fully intended, and designed to be caught by user code. Since it is not caught as expected, program execution halts unexpectedly as an unhandled exception.</p>
<p>The exception thrown is derived from Exception and there is no multi-threading going on with ANTLR.</p>
| [
{
"answer_id": 36047,
"author": "ljs",
"author_id": 3394,
"author_profile": "https://Stackoverflow.com/users/3394",
"pm_score": 3,
"selected": false,
"text": "using System.Threading;\n\n...\n\nvoid Application_ThreadException(object sender, ThreadExceptionEventArgs e) {\n throw new Pars... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3347/"
] |
36,028 | <p>How do I assign a method's output to a textbox value without code behind?</p>
<pre><code><%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Public TextFromString As String = "test text test text"
Public TextFromMethod As String = RepeatChar("S", 50) 'SubSonic.Sugar.Web.GenerateLoremIpsum(400, "w")
Public Function RepeatChar(ByVal Input As String, ByVal Count As Integer)
Return New String(Input, Count)
End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Test Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<%=TextFromString%>
<br />
<asp:TextBox ID="TextBox1" runat="server" Text="<%# TextFromString %>"></asp:TextBox>
<br />
<%=TextFromMethod%>
<br />
<asp:TextBox ID="TextBox2" runat="server" Text="<%# TextFromMethod %>"></asp:TextBox>
</div>
</form>
</body>
</html>
</code></pre>
<p>it was mostly so the designer guys could use it in the aspx page. Seems like a simple thing to push a variable value into a textbox to me.</p>
<p>It's also confusing to me why</p>
<pre><code><asp:Label runat="server" ID="label1"><%=TextFromString%></asp:Label>
</code></pre>
<p>and</p>
<pre><code><asp:TextBox ID="TextBox3" runat="server">Hello</asp:TextBox>
</code></pre>
<p>works but </p>
<pre><code><asp:TextBox ID="TextBox4" runat="server"><%=TextFromString%></asp:TextBox>
</code></pre>
<p>causes a compilation error.</p>
| [
{
"answer_id": 36164,
"author": "Toran Billups",
"author_id": 2701,
"author_profile": "https://Stackoverflow.com/users/2701",
"pm_score": 1,
"selected": false,
"text": "<input type=\"text\" id=\"TextBox4\" runat=\"server\" value=\"<%=TextFromString%>\" />\n"
},
{
"answer_id": 362... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3747/"
] |
36,039 | <p>C++ seems to be rather grouchy when declaring templates across multiple files. More specifically, when working with templated classes, the linker expect all method definitions for the class in a single compiler object file. When you take into account headers, other declarations, inheritance, etc., things get really messy. </p>
<p>Are there any general advice or workarounds for organizing or redistributing templated member definitions across multiple files?</p>
| [
{
"answer_id": 94890,
"author": "jwfearn",
"author_id": 10559,
"author_profile": "https://Stackoverflow.com/users/10559",
"pm_score": 2,
"selected": false,
"text": "extern"
}
] | 2008/08/30 | [
"https://Stackoverflow.com/questions/36039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4381/"
] |
36,058 | <p>I have a popup window containing a form which gathers data for a report.
When I click submit in that window, I want it to close the popup, and open the report in the original window that called the popup.</p>
<p>I think I can open the report in the correct window by using</p>
<pre><code>{ :target => <name of window> }
</code></pre>
<p>in the <code>form_tag</code>, but I don't know how to determine or set the name of the originating window.</p>
<p>I also don't know how to close the popup window.</p>
| [
{
"answer_id": 36065,
"author": "Craig",
"author_id": 1611,
"author_profile": "https://Stackoverflow.com/users/1611",
"pm_score": 0,
"selected": false,
"text": "# The submit button in your child window's view:\n<%= button_to_function 'Save', \"$('my_form').submit(); window.opener.locatio... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
36,064 | <p>I am attempting to update a project from ASP.NET MVC Preview 3 to Preview 5 and it seems that Controller.ReadFromRequest(string key) has been removed from the Controller class. Does anyone know of any alternatives to retrieving information based on an identifier from a form?</p>
| [
{
"answer_id": 36206,
"author": "Dane O'Connor",
"author_id": 1946,
"author_profile": "https://Stackoverflow.com/users/1946",
"pm_score": 2,
"selected": false,
"text": "public static T ReadFromRequest < T > (this Controller controller, string key) \n{\n // Setup\n HttpContextBase c... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36064",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3412/"
] |
36,077 | <p>I'm looking for an answer in MS VC++.</p>
<p>When debugging a large C++ application, which unfortunately has a very extensive usage of C++ exceptions. Sometimes I catch an exception a little later than I actually want.</p>
<p>Example in pseudo code:</p>
<pre><code>FunctionB()
{
...
throw e;
...
}
FunctionA()
{
...
FunctionB()
...
}
try
{
Function A()
}
catch(e)
{
(<--- breakpoint)
...
}
</code></pre>
<p>I can catch the exception with a breakpoint when debugging. But I can't trace back if the exception occurred in <code>FunctionA()</code> or <code>FunctionB()</code>, or some other function. (Assuming extensive exception use and a huge version of the above example).</p>
<p>One solution to my problem is to determine and save the call stack <strong>in the exception constructor</strong> (i.e. before it is caught). But this would require me to derive all exceptions from this base exception class. It would also require a lot of code, and perhaps slow down my program.</p>
<p>Is there an easier way that requires less work? Without having to change my large code base?</p>
<p>Are there better solutions to this problem in other languages?</p>
| [
{
"answer_id": 36223,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 2,
"selected": false,
"text": "#include <execinfo.h> // Backtrace\n#include <cxxabi.h> // Demangling\n\nvector<Str> backtrace(size_t numskip) {\n vec... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3153/"
] |
36,079 | <p>In my PHP web app, I want to be notified via email whenever certain errors occur. I'd like to use my Gmail account for sending these. How could this be done?</p>
| [
{
"answer_id": 36086,
"author": "maxsilver",
"author_id": 1477,
"author_profile": "https://Stackoverflow.com/users/1477",
"pm_score": 2,
"selected": false,
"text": "<?php\nrequire_once \"Mail.php\";\n\n$from = \"Sandra Sender <sender@example.com>\";\n$to = \"Ramona Recipient <recipient@e... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/356/"
] |
36,081 | <p>I'm trying to leverage the using block more and more these days when I have an object that implements IDisposable but one thing I have not figured out is how to catch an exception as I would in a normal try/catch/finally ... any code samples to point me in the right direction?</p>
<p>Edit: The question was modified after reading through the replies. It was "How to Throw an exception in a using block with .NET 2.0?" but I was actually looking for a way to catch these exceptions inside a using block.</p>
<hr>
<p>I'm looking for more detail on rolling my own catching block inside a using block.</p>
<p>Edit: What I wanted to avoid is having to use a try/catch/finally inside my using block like @Blair showed. But maybe this is a non issue...</p>
<p>Edit: @Blair, this is exactly what I was looking for, thanks for the detailed reply!</p>
| [
{
"answer_id": 36094,
"author": "Quibblesome",
"author_id": 1143,
"author_profile": "https://Stackoverflow.com/users/1143",
"pm_score": 2,
"selected": false,
"text": "IDisposable disposable = null;\ntry\n{\n disposable = new WhateverYouWantedToMake();\n}\nfinally\n{\n disposable.Di... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2701/"
] |
36,101 | <p>How do I "name" a browser window in ROR, such that I can open a page in it later, from another (popup) window (using the target="name" html parameter)</p>
| [
{
"answer_id": 36131,
"author": "John Topley",
"author_id": 1450,
"author_profile": "https://Stackoverflow.com/users/1450",
"pm_score": 4,
"selected": true,
"text": "<script type=\"text/javascript\">\n window.name = \"MyWindow\";\n</script>\n app/helpers/application_helper.rb def window... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3764/"
] |
36,108 | <p>Some WPF controls (like the <code>Button</code>) seem to happily consume all the available space in its' container if you don't specify the height it is to have.</p>
<p>And some, like the ones I need to use right now, the (multiline) <code>TextBox</code> and the <code>ListBox</code> seem more worried about just taking the space necessary to fit their contents, and no more. </p>
<p>If you put these guys in a cell in a <code>UniformGrid</code>, they will expand to fit the available space. However, <code>UniformGrid</code> instances are not right for all situations. What if you have a grid with some rows set to a * height to divide the height between itself and other * rows? What if you have a <code>StackPanel</code> and you have a <code>Label</code>, a <code>List</code> and a <code>Button</code>, how can you get the list to take up all the space not eaten by the label and the button?</p>
<p>I would think this would really be a basic layout requirement, but I can't figure out how to get them to fill the space that they could (putting them in a <code>DockPanel</code> and setting it to fill also doesn't work, it seems, since the <code>DockPanel</code> only takes up the space needed by its' subcontrols).</p>
<p>A resizable GUI would be quite horrible if you had to play with <code>Height</code>, <code>Width</code>, <code>MinHeight</code>, <code>MinWidth</code> etc. </p>
<p>Can you bind your <code>Height</code> and <code>Width</code> properties to the grid cell you occupy? Or is there another way to do this?</p>
| [
{
"answer_id": 36634,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 8,
"selected": false,
"text": "HorizontalContentAlignment=\"Stretch\"\n HorizontalAlignment=\"Stretch\"\n"
},
{
"answer_id": 36741,
"author"... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2122/"
] |
36,109 | <p>The following shell script takes a list of arguments, turns Unix paths into WINE/Windows paths and invokes the given executable under WINE.</p>
<pre><code>#! /bin/sh
if [ "${1+set}" != "set" ]
then
echo "Usage; winewrap EXEC [ARGS...]"
exit 1
fi
EXEC="$1"
shift
ARGS=""
for p in "$@";
do
if [ -e "$p" ]
then
p=$(winepath -w $p)
fi
ARGS="$ARGS '$p'"
done
CMD="wine '$EXEC' $ARGS"
echo $CMD
$CMD
</code></pre>
<p>However, there's something wrong with the quotation of command-line arguments.</p>
<pre><code>$ winewrap '/home/chris/.wine/drive_c/Program Files/Microsoft Research/Z3-1.3.6/bin/z3.exe' -smt /tmp/smtlib3cee8b.smt
Executing: wine '/home/chris/.wine/drive_c/Program Files/Microsoft Research/Z3-1.3.6/bin/z3.exe' '-smt' 'Z: mp\smtlib3cee8b.smt'
wine: cannot find ''/home/chris/.wine/drive_c/Program'
</code></pre>
<p>Note that:</p>
<ol>
<li>The path to the executable is being chopped off at the first space, even though it is single-quoted.</li>
<li>The literal "\t" in the last path is being transformed into a tab character.</li>
</ol>
<p>Obviously, the quotations aren't being parsed the way I intended by the shell. How can I avoid these errors?</p>
<p>EDIT: The "\t" is being expanded through two levels of indirection: first, <code>"$p"</code> (and/or <code>"$ARGS"</code>) is being expanded into <code>Z:\tmp\smtlib3cee8b.smt</code>; then, <code>\t</code> is being expanded into the tab character. This is (seemingly) equivalent to</p>
<pre><code>Y='y\ty'
Z="z${Y}z"
echo $Z
</code></pre>
<p>which yields </p>
<pre><code>zy\tyz
</code></pre>
<p>and <em>not</em></p>
<pre><code>zy yz
</code></pre>
<p>UPDATE: <code>eval "$CMD"</code> does the trick. The "<code>\t</code>" problem seems to be echo's fault: "If the first operand is -n, or if any of the operands contain a backslash ( '\' ) character, the results are implementation-defined." (<a href="http://www.opengroup.org/onlinepubs/009695399/utilities/echo.html" rel="nofollow noreferrer">POSIX specification of <code>echo</code></a>)</p>
| [
{
"answer_id": 36113,
"author": "Kyle Cronin",
"author_id": 658,
"author_profile": "https://Stackoverflow.com/users/658",
"pm_score": 0,
"selected": false,
"text": "/home/chris/.wine/drive_c/Program Files/Microsoft\\ Research/Z3-1.3.6/bin/z3.exe\n"
},
{
"answer_id": 42005,
"a... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1412/"
] |
36,114 | <p>I know I must be missing something, but in a <code>while</code> statement how does the variable hold the data, when it finishes the first pass and goes into the second pass?</p>
<hr>
<p>{</p>
<pre><code>int num1 = 0 ;
int num2 = 0;
int num3 = 0;
while (num1 < 10)
{cout << "enter your first number: ";
cin >> num1;
cout << "Enter your second number: ";
cin >> num2;
num1 = num1 + num2 ;
cout << "Number 1 is now: " << num1 <<endl;
cout << "Enter Number 3: " ;
cin >> num3;
num1 = num1 + num3;
cout << "Number 1 is now: " << num1 << endl;
num1++;
};
</code></pre>
<p>In this code. The Variable doesn't hold the data. I'm not sure what I'm doing wrong!</p>
| [
{
"answer_id": 36155,
"author": "James Sutherland",
"author_id": 1739,
"author_profile": "https://Stackoverflow.com/users/1739",
"pm_score": 2,
"selected": false,
"text": "int a = 0;\n\nwhile(a < 10)\n{\n int b = 0;\n\n cout << \"a: \" << a << \" b: \" << b << \"\\n\";\n\n a++;\... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/335696/"
] |
36,129 | <p>I'm reading through head first design patterns at the moment and while the book is excellent I also would like to see how these are actually used in the real world.</p>
<p>If you know of a good example of design pattern usage (preferably in a OSS program so we can have a look :) then please list it below.</p>
| [
{
"answer_id": 36167,
"author": "rp.",
"author_id": 2536,
"author_profile": "https://Stackoverflow.com/users/2536",
"pm_score": 3,
"selected": true,
"text": "namespace PublishSubscribe\n{\n public partial class Form1 : Form\n {\n Form2 f2 = new Form2();\n\n public For... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36129",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1603/"
] |
36,139 | <p>What is the best way of creating an alphabetically sorted list in Python?</p>
| [
{
"answer_id": 36143,
"author": "rix0rrr",
"author_id": 2474,
"author_profile": "https://Stackoverflow.com/users/2474",
"pm_score": 5,
"selected": false,
"text": "list.sort()\n"
},
{
"answer_id": 36156,
"author": "Eli Courtwright",
"author_id": 1694,
"author_profile":... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3205/"
] |
36,144 | <p>I'm trying to open a new browser tab with the results of a POST request. I'm trying to do so using a function containing the following code:</p>
<pre><code>var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interface
s.nsIWindowMediator);
var browserWindow = windowManager.getMostRecentWindow("navigator:browser");
var browser = browserWindow.getBrowser();
if(browser.mCurrentBrowser.currentURI.spec == "about:blank")
browserWindow.loadURI(url, null, postData, false);
else
browser.loadOneTab(url, null, null, postData, false, false);
</code></pre>
<p>I'm using a string as url, and JSON data as postData. Is there something I'm doing wrong?</p>
<p>What happens, is a new tab is created, the location shows the URL I want to post to, but the document is blank. The Back, Forward, and Reload buttons are all grayed out on the browser. It seems like it did everything except executed the POST. If I leave the postData parameter off, then it properly runs a GET.</p>
<p>Build identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1</p>
| [
{
"answer_id": 36216,
"author": "Marius",
"author_id": 1585,
"author_profile": "https://Stackoverflow.com/users/1585",
"pm_score": 0,
"selected": false,
"text": "function openAndReuseOneTabPerURL(url) {\n var wm = Components.classes[\"@mozilla.org/appshell/window-mediator;1\"]\n ... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3288/"
] |
36,183 | <p>I'm trying to write a regex function that will identify and replace a single instance of a match within a string without affecting the other instances. For example, I have this string:</p>
<pre><code>12||34||56
</code></pre>
<p>I want to replace the second set of pipes with ampersands to get this string:</p>
<pre><code>12||34&&56
</code></pre>
<p>The regex function needs to be able to handle x amount of pipes and allow me to replace the nth set of pipes, so I could use the same function to make these replacements:</p>
<pre><code>23||45||45||56||67 -> 23&&45||45||56||67
23||34||98||87 -> 23||34||98&&87
</code></pre>
<p>I know that I could just split/replace/concat the string at the pipes, and I also know that I can match on <code>/\|\|/</code> and iterate through the resulting array, but I'm interested to know if it's possible to write a single expression that can do this. Note that this would be for Javascript, so it's possible to generate a regex at runtime using <code>eval()</code>, but it's not possible to use any Perl-specific regex instructions.</p>
| [
{
"answer_id": 36191,
"author": "Sam Hasler",
"author_id": 2541,
"author_profile": "https://Stackoverflow.com/users/2541",
"pm_score": 5,
"selected": true,
"text": "\"23||45||45||56||67\".replace(/^((?:[0-9]+\\|\\|){n})([0-9]+)\\|\\|/,\"$1$2&&\")\n function pipe_replace(str,n) {\n var ... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2289/"
] |
36,260 | <p>I'm writing an interpreter for an experimental language. Three of the main constructs of the language are definitions, statements, and expressions. Definitions can contain statements and expressions, statements can contain definitions and expressions, and one kind of expression can contain statements. I represent all of these using union types so I can easily use pattern matching on them. Ideally, I would like to put the code for these in different files, but OMake complains about circular dependency issues. As far as I know, circular type definitions across modules are not allowed.</p>
<p>The only way I know of to solve this is to define all three types at once:</p>
<pre><code>type defn = ...
and stmt = ...
and expr = ...
</code></pre>
<p>It seems like this requires all the code for types to be in the same file. Is there any way around this? How do you deal with circular definitions in your code?</p>
| [
{
"answer_id": 216062,
"author": "J D",
"author_id": 13924,
"author_profile": "https://Stackoverflow.com/users/13924",
"pm_score": 4,
"selected": false,
"text": "type ('stmt, 'expr) defn = ...\ntype ('defn, 'expr) stmt = ...\ntype ('defn, 'stmt) expr = ...\n"
}
] | 2008/08/30 | [
"https://Stackoverflow.com/questions/36260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1891/"
] |
36,274 | <p>What is Lazy Loading?</p>
<p>[Edit after reading a few answers]
Why do people use this term so often? </p>
<p>Say you just use a ASP/ADO recordset and load it with data or ADO.NET Datasource for a gridview.</p>
<p>I guess I should have asked why people use the term Lazy Loading, what "other" types are their?</p>
| [
{
"answer_id": 36291,
"author": "Eli Courtwright",
"author_id": 1694,
"author_profile": "https://Stackoverflow.com/users/1694",
"pm_score": 3,
"selected": false,
"text": "class Item(Model):\n ...\n @property\n def total(self):\n if not hasattr(self, \"_total\"):\n ... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3747/"
] |
36,294 | <p>Looks like here in StackOveflow there is a group of <strong>F#</strong> enthusiasts. </p>
<p>I'd like to know better this language, so, apart from the <a href="http://en.wikipedia.org/wiki/Functional_programming" rel="noreferrer">functional programming theory</a>, can you point me to the better starting points to start using the F# language? I mean, tutorials, how-tos, but first of all working samples to have the chance to start doing something and enjoy the language.</p>
<p>Thanks a lot</p>
<p>Andrea</p>
| [
{
"answer_id": 36393,
"author": "ljs",
"author_id": 3394,
"author_profile": "https://Stackoverflow.com/users/3394",
"pm_score": 6,
"selected": true,
"text": "#light\n > #light;;\n > let f x y = x + y;;\n\n val f : int -> int -> int\n\n > f 1 2;;\n val it : int = 3\n let sumStuff x ... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36294",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1178/"
] |
36,314 | <p>I've seen references to curried functions in several articles and blogs but I can't find a good explanation (or at least one that makes sense!)</p>
| [
{
"answer_id": 36321,
"author": "Kyle Cronin",
"author_id": 658,
"author_profile": "https://Stackoverflow.com/users/658",
"pm_score": 11,
"selected": true,
"text": "function add (a, b) {\n return a + b;\n}\n\nadd(3, 4); // returns 7\n function add (a) {\n return function (b) {\n ret... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3786/"
] |
36,315 | <p>It'd be really nice to target my Windows Forms app to the .NET 3.5 SP1 <em>client</em> framework. But, right now I'm using the <code>HttpUtility.HtmlDecode</code> and <code>HttpUtility.UrlDecode</code> functions, and the MSDN documentation doesn't point to any alternatives inside of, say, System.Net or something.</p>
<p>So, short from reflectoring the source code and copying it into my assembly---which I don't think would be worth it---are there alternatives inside of the .NET 3.5 SP1 client framework that you know of, to replace this functionality? It seems a bit strange that they'd restrict these useful functions to server-only code.</p>
| [
{
"answer_id": 36359,
"author": "Jeremy McGee",
"author_id": 3546,
"author_profile": "https://Stackoverflow.com/users/3546",
"pm_score": 1,
"selected": false,
"text": "HttpUtility System.Web.dll c:\\windows\\Microsoft.NET\\Framework\\ ..."
},
{
"answer_id": 4389349,
"author":... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3191/"
] |
36,326 | <p>I know it is a good idea to store configuration data in app.config (e.g. database connection strings) instead of hardcoing it, even if I am writing an application just for myself. But is there a way to update the configuration data stored in app.config from the program that is using it?</p>
| [
{
"answer_id": 36335,
"author": "Domenic",
"author_id": 3191,
"author_profile": "https://Stackoverflow.com/users/3191",
"pm_score": 1,
"selected": false,
"text": "a UserScopedSettingAttribute"
}
] | 2008/08/30 | [
"https://Stackoverflow.com/questions/36326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3205/"
] |
36,344 | <p>I'm trying to "install SGML::Parser::OpenSP" from the cpan shell, but it fails on the first "make test". I also get the same error if I go into the build directory and run make test.</p>
<p>I believe this bit of the output below is the relevant part. Note the Symbol not found when perl gets to the "use" line for the new library. The file listed there exists and is readable. When I run the unix command "nm" it <em>does</em> show the symbol.</p>
<p>I don't know what to make of the symbol not found error. I'm not running as admin/root if that matters. This is on a mac, 10.4.11 My googling turned up some hints that this can happen if gcc is called instead of g++, but I believe that is set up correctly.</p>
<p>What else could it be, and how can I try to fix?</p>
<p>Here's the excerpt from running make test:</p>
<pre><code>PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/01basic...........1/4
# Failed test 'use SGML::Parser::OpenSP;'
# at t/01basic.t line 14.
# Tried to use 'SGML::Parser::OpenSP'.
# Error: Can't load '/Users/joshgold/.cpan/build/SGML-Parser-OpenSP-0.994/blib/arch/auto/SGML/Parser/OpenSP/OpenSP.bundle' for module SGML::Parser::OpenSP: dlopen(/Users/joshgold/.cpan/build/SGML-Parser-OpenSP-0.994/blib/arch/auto/SGML/Parser/OpenSP/OpenSP.bundle, 2): Symbol not found: __ZTI15SGMLApplication
# Referenced from: /Users/joshgold/.cpan/build/SGML-Parser-OpenSP-0.994/blib/arch/auto/SGML/Parser/OpenSP/OpenSP.bundle
# Expected in: dynamic lookup
# at (eval 3) line 2
# Compilation failed in require at (eval 3) line 2.
# BEGIN failed--compilation aborted at (eval 3) line 2.
</code></pre>
| [
{
"answer_id": 36335,
"author": "Domenic",
"author_id": 3191,
"author_profile": "https://Stackoverflow.com/users/3191",
"pm_score": 1,
"selected": false,
"text": "a UserScopedSettingAttribute"
}
] | 2008/08/30 | [
"https://Stackoverflow.com/questions/36344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
36,347 | <p>Java has generics and C++ provides a very strong programming model with <code>template</code>s.
So then, what is the difference between C++ and Java generics?</p>
| [
{
"answer_id": 36364,
"author": "Alexandru Nedelcu",
"author_id": 3280,
"author_profile": "https://Stackoverflow.com/users/3280",
"pm_score": 8,
"selected": true,
"text": "template <typename T> T sum(T a, T b) { return a + b; }\n <T extends Something> T sum(T a, T b) { return a.add ( b )... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1556/"
] |
36,350 | <p>I have a method which takes params object[] such as:</p>
<pre><code>void Foo(params object[] items)
{
Console.WriteLine(items[0]);
}
</code></pre>
<p>When I pass two object arrays to this method, it works fine:</p>
<pre><code>Foo(new object[]{ (object)"1", (object)"2" }, new object[]{ (object)"3", (object)"4" } );
// Output: System.Object[]
</code></pre>
<p>But when I pass a single object[], it does not take my object[] as the first param, instead it takes its all elements like I wanted to pass them one by one:</p>
<pre><code>Foo(new object[]{ (object)"1", (object)"2" });
// Output: 1, expected: System.Object[]
</code></pre>
<p>How do I pass a single object[] as a first argument to a params array?</p>
| [
{
"answer_id": 36360,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 2,
"selected": false,
"text": "Foo(new Object[] { new object[]{ (object)\"1\", (object)\"2\" }});\n"
},
{
"answer_id": 36361,
"author": "... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36350",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31505/"
] |
36,407 | <p>What Firefox add-ons do you use that are useful for programmers?</p>
| [
{
"answer_id": 36433,
"author": "Dan Herbert",
"author_id": 392,
"author_profile": "https://Stackoverflow.com/users/392",
"pm_score": 1,
"selected": false,
"text": "Miscellaneous Display Ruler"
}
] | 2008/08/30 | [
"https://Stackoverflow.com/questions/36407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3305/"
] |
36,417 | <p>What is a good way to remove the code from display pages when developing with PHP. Often the pages I work on need to be editted by an outside person. This person is often confused by lots of blocks of PHP, and also likes to break my code.</p>
<p>I've tried moving blocks of code out into functions, so now there are functions spread out all throughout the HTML now. As some pages become more complex it becomes a program again, and processing POSTs are questionable.</p>
<p>What can I be doing better in my PHP development?</p>
| [
{
"answer_id": 36428,
"author": "different",
"author_id": 3654,
"author_profile": "https://Stackoverflow.com/users/3654",
"pm_score": 0,
"selected": false,
"text": "$userName = \"John Doe\";\n$dateOfBirth = \"04/02/1982\";\n\nfunction calculateUserAgeFromBirth($userName, $dateOfBirth)\n"... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3800/"
] |
36,430 | <p>I'm not sure of all of them, but what are the commands to do things like update Ruby, download a new gem, or update an existing gem? What other important things are there?</p>
<p>Since it might matter, I'm running Windows.</p>
| [
{
"answer_id": 36452,
"author": "John Topley",
"author_id": 1450,
"author_profile": "https://Stackoverflow.com/users/1450",
"pm_score": 1,
"selected": false,
"text": "sudo gem install gemname\nsudo gem update gemname\n"
},
{
"answer_id": 36463,
"author": "Joseph Pecoraro",
... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/572/"
] |
36,455 | <p>Older K&R (2nd ed.) and other C-language texts I have read that discuss the implementation of a dynamic memory allocator in the style of <code>malloc()</code> and <code>free()</code> usually also mention, in passing, something about data type alignment restrictions. Apparently certain computer hardware architectures (CPU, registers, and memory access) restrict how you can store and address certain value types. For example, there may be a requirement that a 4 byte (<code>long</code>) integer must be stored beginning at addresses that are multiples of four.</p>
<p>What restrictions, if any, do major platforms (Intel & AMD, SPARC, Alpha) impose for memory allocation and memory access, or can I safely ignore aligning memory allocations on specific address boundaries?</p>
| [
{
"answer_id": 36466,
"author": "Rob Walker",
"author_id": 3631,
"author_profile": "https://Stackoverflow.com/users/3631",
"pm_score": 1,
"selected": false,
"text": "struct\n{ \n char A;\n int B;\n char C;\n int D;\n};\n struct\n{ \n char A;\n char C;\n int B;\n i... | 2008/08/30 | [
"https://Stackoverflow.com/questions/36455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
36,475 | <p>What would be the best way to design a threaded commenting system so that it doesn't hammer the database?</p>
| [
{
"answer_id": 36629,
"author": "Mark Harrison",
"author_id": 116,
"author_profile": "https://Stackoverflow.com/users/116",
"pm_score": 2,
"selected": false,
"text": "select * from my_table\n start with parent = :TOP_ARTICLE\n connect by prior child = parent;\n"
}
] | 2008/08/30 | [
"https://Stackoverflow.com/questions/36475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1745/"
] |
36,498 | <p>I would like to quickly send email from the command line. I realize there are probably a number of different ways to do this.</p>
<p>I'm looking for a simple way to do this from a linux terminal (likely a bash shell but anything should do) and an alternative way to do this on Windows. I want to be able to whip up an email right on the command line or have the flexibility to pipe the message into the command line program. How would you go about doing this? If you have small scripts that would be fine as well.</p>
| [
{
"answer_id": 36499,
"author": "aryeh",
"author_id": 3288,
"author_profile": "https://Stackoverflow.com/users/3288",
"pm_score": 4,
"selected": false,
"text": "$ echo \"This is the email body\" | mail -s \"This is the subject\" me@email.com\n $ cat | mail -s \"A few lines off the top of... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/792/"
] |
36,502 | <p>I know Windows Vista (and XP) cache recently loaded DLL's in memory...</p>
<p>How can this be disabled via the command prompt?</p>
| [
{
"answer_id": 36529,
"author": "The How-To Geek",
"author_id": 291,
"author_profile": "https://Stackoverflow.com/users/291",
"pm_score": 4,
"selected": true,
"text": "sc config Superfetch start= disabled\n"
}
] | 2008/08/31 | [
"https://Stackoverflow.com/questions/36502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/383/"
] |
36,504 | <p>I see a lot of talk on here about functional languages and stuff. Why would you use one over a "traditional" language? What do they do better? What are they worse at? What's the ideal functional programming application?</p>
| [
{
"answer_id": 1440354,
"author": "RD1",
"author_id": 175097,
"author_profile": "https://Stackoverflow.com/users/175097",
"pm_score": 3,
"selected": false,
"text": "* The average corporate programmer, e.g. most of the people I work with, will not understand it and most work environments ... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/655/"
] |
36,511 | <p>I'm attempting to create a dataset based on the properties of an object. For example, I have an instance of a Person class with properties including ID, Forename, Surname, DOB etc. Using reflection, I'm adding columns to a new dataset based on the object properties:</p>
<pre><code>For Each pi As PropertyInfo In person.GetType().GetProperties()
Dim column As New DataColumn(pi.Name, pi.PropertyType)
table.Columns.Add(column)
Next
</code></pre>
<p>My problem is that some of those properies are nullable types which aren't supported by datasets. Is there any way to extract the underlying system type from a nullable type?</p>
<p>Thanks.</p>
| [
{
"answer_id": 36519,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 1,
"selected": false,
"text": "if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))\n"
},
{
"answer_id": 44108,
... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
36,515 | <p>I have a page with a Google Maps mashup that has pushpins that are color-coded by day (Monday, Tuesday, etc.) The IFrame containing the map is dynamically sized, so it gets resized when the browser window is resized. </p>
<p>I'd like to put a legend in the corner of the map window that tells the user what each color means. The Google Maps API includes a <code><a href="http://code.google.com/apis/maps/documentation/reference.html#GScreenOverlay" rel="nofollow noreferrer">GScreenOverlay</a></code> class that has the behavior that I want, but it only lets you specify an image to use as an overlay, and I'd prefer to use a DIV with text in it. What's the easiest way to position a DIV over the map window in (for example) the lower left corner that'll automatically stay in the same place relative to the corner when the browser window is resized?</p>
| [
{
"answer_id": 36821,
"author": "Tom",
"author_id": 3715,
"author_profile": "https://Stackoverflow.com/users/3715",
"pm_score": 2,
"selected": false,
"text": "<div id=\"wrapper\">\n <div id=\"map\" style=\"width:400px;height:400px;\"></div>\n <div id=\"legend\"> ... marker descriptio... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1482/"
] |
36,533 | <p>my primary language is spanish, but I use all my software in english, including windows; however I'd like to use speech recognition in spanish.</p>
<p>Do you know if there's a way to use vista's speech recognition in other language than the primary os language?</p>
| [
{
"answer_id": 483699,
"author": "guerda",
"author_id": 32043,
"author_profile": "https://Stackoverflow.com/users/32043",
"pm_score": 2,
"selected": false,
"text": "Windows Speech Recognition \"change language\""
},
{
"answer_id": 1441205,
"author": "Eric Brown",
"author_... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1782/"
] |
36,563 | <p>I'm writing a simple app that's going to have a tiny form sitting in one corner of the screen, updating itself.</p>
<p>I'd really love for that form to be transparent and to have the transparency be user-configurable.</p>
<p>Is there any easy way to achieve this?</p>
| [
{
"answer_id": 36576,
"author": "Eric Haskins",
"author_id": 100,
"author_profile": "https://Stackoverflow.com/users/100",
"pm_score": 0,
"selected": false,
"text": "Form.Opacity"
},
{
"answer_id": 36577,
"author": "Cameron MacFarland",
"author_id": 3820,
"author_prof... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/305/"
] |
36,567 | <p>I'm looking into writing a audio syntesizer in Java, and was wondering if anybody has any advice or good resources for writing such a program. I'm looking for info on generating raw sound waves, how to output them into a usable form (playing over speakers), as well as general theory on the topic. Thanks guys.</p>
| [
{
"answer_id": 38203,
"author": "secr",
"author_id": 4085,
"author_profile": "https://Stackoverflow.com/users/4085",
"pm_score": 4,
"selected": true,
"text": "typedef struct _WAVstruct\n{\n char headertag[4];\n unsigned int remnantlength;\n char fileid[4];\n\n char fmtchunkta... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
36,585 | <p>I have a column which is of type nvarchar(max). How do I find the length of the string (or the number of bytes) for the column for each row in the table?</p>
| [
{
"answer_id": 36592,
"author": "Joseph Pecoraro",
"author_id": 792,
"author_profile": "https://Stackoverflow.com/users/792",
"pm_score": 1,
"selected": false,
"text": "desc tablename;\n SELECT *, LENGTH(fieldname) AS len FROM tablename\n"
},
{
"answer_id": 2943468,
"author":... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1208/"
] |
36,605 | <p>What is the simplest and most elegant way to simulate the hover pseudo-class for non-Anchor tags in IE6?</p>
<p>I am specifically trying to change the cursor in this instance to that of a pointer.</p>
| [
{
"answer_id": 36609,
"author": "Jon Galloway",
"author_id": 5,
"author_profile": "https://Stackoverflow.com/users/5",
"pm_score": 4,
"selected": false,
"text": "body { behavior:url(\"csshover.htc\"); }\n"
},
{
"answer_id": 36892,
"author": "Nathan Peretic",
"author_id": ... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36605",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3821/"
] |
36,608 | <p>I have a record set that includes a date field, and want to determine how many unique dates are represented in the record set.</p>
<p>Something like:</p>
<pre><code>Record.find(:all).date.unique.count
</code></pre>
<p>but of course, that doesn't seem to work.</p>
| [
{
"answer_id": 36618,
"author": "Natalie Weizenbaum",
"author_id": 2518,
"author_profile": "https://Stackoverflow.com/users/2518",
"pm_score": 7,
"selected": true,
"text": "SELECT COUNT(DISTINCT date) FROM records\n Record.count('date', :distinct => true)\n"
},
{
"answer_id": 402... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3764/"
] |
36,621 | <p>I'm taking the leap: my PHP scripts will ALL fail gracefully!</p>
<p>At least, that's what I'm hoping for...`</p>
<p>I don't want to wrap (practically) every single line in <code>try...catch</code> statements, so I think my best bet is to make a custom error handler for the beginning of my files.</p>
<p>I'm testing it out on a practice page:</p>
<pre><code>function customError($level,$message,$file,$line,$context) {
echo "Sorry, an error has occured on line $line.<br />";
echo "The function that caused the error says $message.<br />";
die();
}
set_error_handler("customError");
echo($imAFakeVariable);
</code></pre>
<p>This works fine, returning:</p>
<blockquote>
<p>Sorry, an error has occurred on line 17. The function that caused the
error says Undefined variable: imAFakeVariable.</p>
</blockquote>
<p>However, this setup doesn't work for undefined functions.</p>
<pre><code>function customError($level,$message,$file,$line,$context) {
echo "Sorry, an error has occured on line $line.<br />";
echo "The function that caused the error says $message.<br />";
die();
}
set_error_handler("customError");
imAFakeFunction();
</code></pre>
<p>This returns:</p>
<blockquote>
<p>Fatal error: Call to undefined function: imafakefunction() in
/Library/WebServer/Documents/experimental/errorhandle.php on line 17</p>
</blockquote>
<p>Why isn't my custom error handler catching undefined functions? Are there other problems that this will cause?</p>
| [
{
"answer_id": 36625,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 1,
"selected": false,
"text": "try..catch"
},
{
"answer_id": 36705,
"author": "Ross",
"author_id": 2025,
"author_profile": "https:... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1615/"
] |
36,636 | <p>I asked a question about Currying and closures were mentioned.
What is a closure? How does it relate to currying?</p>
| [
{
"answer_id": 36639,
"author": "Kyle Cronin",
"author_id": 658,
"author_profile": "https://Stackoverflow.com/users/658",
"pm_score": 7,
"selected": false,
"text": "function makeCounter () {\n var count = 0;\n return function () {\n count += 1;\n return count;\n }\n}\n\nvar x = ... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36636",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3786/"
] |
36,646 | <p>Does anyone use <a href="http://phing.info/trac/" rel="nofollow noreferrer">Phing</a> to deploy PHP applications, and if so how do you use it? We currently have a hand-written "setup" script that we run whenever we deploy a new instance of our project. We just check out from SVN and run it. It sets some basic configuration variables, installs or reloads the database, and generates a v-host for the site instance.</p>
<p>I have often thought that maybe we should be using <a href="http://phing.info/trac/" rel="nofollow noreferrer">Phing</a>. I haven't used ant much, so I don't have a real sense of what <a href="http://phing.info/trac/" rel="nofollow noreferrer">Phing</a> is supposed to do other than script the copying of files from one place to another much as our setup script does. What are some more advanced uses that you can give examples of to help me understand why we would or would not want to integrate <a href="http://phing.info/trac/" rel="nofollow noreferrer">Phing</a> into our process?</p>
| [
{
"answer_id": 6323542,
"author": "cweiske",
"author_id": 282601,
"author_profile": "https://Stackoverflow.com/users/282601",
"pm_score": 2,
"selected": false,
"text": "exec exec"
}
] | 2008/08/31 | [
"https://Stackoverflow.com/questions/36646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/577/"
] |
36,647 | <p>Does Python have a unit testing framework compatible with the standard xUnit style of test framework? If so, what is it, where is it, and is it any good?</p>
| [
{
"answer_id": 36648,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 6,
"selected": true,
"text": "unittest doctest nose unittest unittest doctest"
},
{
"answer_id": 36654,
"author": "John Millikin",
"au... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/577/"
] |
36,656 | <p>I'm parsing text from a file and storing it in a string. The problem is that some of the text in the original files contains <code>ASCII art</code> and whatnot that I would like to preserve. When I print out the string on the <code>HTML page</code>, even if it does have the same formatting and everything since it is in <code>HTML</code>, the spacing and line breaks are not preserved. What is the best way to print out the text in <code>HTML</code> exactly as it was in the original text file?<br>
I would like to give an example, but unfortunately, I was not able to get it to display correctly in this markdown editor :P<br>
Basically, I would like suggestions on how to display <code>ASCII art in HTML</code>.</p>
| [
{
"answer_id": 36657,
"author": "UnkwnTech",
"author_id": 115,
"author_profile": "https://Stackoverflow.com/users/115",
"pm_score": 3,
"selected": false,
"text": "nl2br() \\n \\r\\n <br>"
},
{
"answer_id": 36658,
"author": "Grant",
"author_id": 30,
"author_profile": "... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3831/"
] |
36,701 | <p>Is it completely against the Java way to create struct like objects?</p>
<pre><code>class SomeData1 {
public int x;
public int y;
}
</code></pre>
<p>I can see a class with accessors and mutators being more Java like.</p>
<pre><code>class SomeData2 {
int getX();
void setX(int x);
int getY();
void setY(int y);
private int x;
private int y;
}
</code></pre>
<p>The class from the first example is notationally convenient.</p>
<pre><code>// a function in a class
public int f(SomeData1 d) {
return (3 * d.x) / d.y;
}
</code></pre>
<p>This is not as convenient.</p>
<pre><code>// a function in a class
public int f(SomeData2 d) {
return (3 * d.getX()) / d.getY();
}
</code></pre>
| [
{
"answer_id": 36734,
"author": "Bartosz Bierkowski",
"author_id": 3666,
"author_profile": "https://Stackoverflow.com/users/3666",
"pm_score": 7,
"selected": true,
"text": "public property String foo; \na->Foo = b->Foo;\n"
},
{
"answer_id": 36874,
"author": "Spoike",
"a... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3836/"
] |
36,707 | <p>Are there good reasons why it's a better practice to have only one return statement in a function? </p>
<p>Or is it okay to return from a function as soon as it is logically correct to do so, meaning there may be many return statements in the function?</p>
| [
{
"answer_id": 36714,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 11,
"selected": true,
"text": "public void DoStuff(Foo foo)\n{\n if (foo != null)\n {\n ...\n }\n}\n public void DoStuff(Foo foo)\n{\n ... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36707",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/381/"
] |
36,715 | <p>When using host headers to host multiple websites on the same IP address in IIS, is there any way of accessing that website from a browser running on the local machine?</p>
<p>This is normally required when a given web component only allows configuration from the local machine. It's also useful when things like ASP.Net's built in error handling isn't working and you can only view the error in the browser but don't want to allow remote users to see it. </p>
<p>This has baffled me for a while and everytime I come across it I end up giving up in frustration and reconfigure stuff so I can accomplish such tasks remotely.</p>
<p><strong>Added:</strong> @Ishmaeel - modifying hosts doesn't seem to help - you either get a 400 error (if all websites have host headers) or whichever site is configured without a host header.</p>
| [
{
"answer_id": 35499622,
"author": "Anders Bornholm",
"author_id": 1425531,
"author_profile": "https://Stackoverflow.com/users/1425531",
"pm_score": 0,
"selected": false,
"text": "$ telnet localhost 80\n GET / HTTP/1.1\nHost: www.example.com\n"
}
] | 2008/08/31 | [
"https://Stackoverflow.com/questions/36715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1521/"
] |
36,733 | <p>I am working on a project management web application. The user has a variety of ways to display a list of tasks. When viewing a list page, they click on task and are redirected to the task edit page. </p>
<p>Since they are coming from a variety of ways, I am just curious as to the <strong>best</strong> way to <strong>redirect</strong> the user back to the calling page. I have some ideas, but would like to get other developers input.</p>
<p>Would you store the <strong>calling</strong> url in session? as a cookie? I like the concept of using an object <strong>handle</strong> the redirection.</p>
| [
{
"answer_id": 36735,
"author": "Rob Cooper",
"author_id": 832,
"author_profile": "https://Stackoverflow.com/users/832",
"pm_score": 1,
"selected": false,
"text": "public partial class _Default : System.Web.UI.Page \n{\n\n void Redirect(string url, string messsage)\n {\n Red... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1768/"
] |
36,742 | <p>My GPS logger occassionally leaves "unfinished" lines at the end of the log files. I think they're only at the end, but I want to check all lines just in case. </p>
<p>A sample complete sentence looks like:</p>
<pre><code>$GPRMC,005727.000,A,3751.9418,S,14502.2569,E,0.00,339.17,210808,,,A*76
</code></pre>
<p>The line should start with a <code>$</code> sign, and end with an <code>*</code> and a two character hex checksum. I don't care if the checksum is correct, just that it's present. It also needs to ignore "ADVER" sentences which don't have the checksum and are at the start of every file.</p>
<p>The following Python code might work: </p>
<pre><code>import re
from path import path
nmea = re.compile("^\$.+\*[0-9A-F]{2}$")
for log in path("gpslogs").files("*.log"):
for line in log.lines():
if not nmea.match(line) and not "ADVER" in line:
print "%s\n\t%s\n" % (log, line)
</code></pre>
<p>Is there a way to do that with <code>grep</code> or <code>awk</code> or something simple? I haven't really figured out how to get <code>grep</code> to do what I want.</p>
<p><strong>Update</strong>: Thanks @Motti and @Paul, I was able to get the following to do almost what I wanted, but had to use single quotes and remove the trailing <code>$</code> before it would work:</p>
<pre><code>grep -nvE '^\$.*\*[0-9A-F]{2}' *.log | grep -v ADVER | grep -v ADPMB
</code></pre>
<p>Two further questions arise, how can I make it ignore blank lines? And can I combine the last two <code>grep</code>s?</p>
| [
{
"answer_id": 36779,
"author": "Motti",
"author_id": 3848,
"author_profile": "https://Stackoverflow.com/users/3848",
"pm_score": 2,
"selected": false,
"text": "grep -Ev \"^\\$.*\\*[0-9A-Fa-f]{2}$\" a.txt | grep -v ADVER\n grep -v ADVER"
},
{
"answer_id": 36842,
"author": "Pa... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3715/"
] |
36,748 | <p>What's the best way to asynchronously load an BitmapImage in C# using WPF? </p>
| [
{
"answer_id": 40774,
"author": "bentford",
"author_id": 946,
"author_profile": "https://Stackoverflow.com/users/946",
"pm_score": 0,
"selected": false,
"text": "public class ResizeFolderBackgroundWorker : BackgroundWorker\n{\n\n public ResizeFolderBackgroundWorker(string sourceFolder... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36748",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3837/"
] |
36,760 | <p>I have three tables: page, attachment, page-attachment</p>
<p>I have data like this:</p>
<pre><code>page
ID NAME
1 first page
2 second page
3 third page
4 fourth page
attachment
ID NAME
1 foo.word
2 test.xsl
3 mm.ppt
page-attachment
ID PAGE-ID ATTACHMENT-ID
1 2 1
2 2 2
3 3 3
</code></pre>
<p>I would like to get the number of attachments per page <strong>also when that number is 0</strong>. I have tried with: </p>
<pre><code>select page.name, count(page-attachment.id) as attachmentsnumber
from page
inner join page-attachment on page.id=page-id
group by page.id
</code></pre>
<p>I am getting this output: </p>
<pre><code>NAME ATTACHMENTSNUMBER
second page 2
third page 1
</code></pre>
<p>I would like to get this output:</p>
<pre><code>NAME ATTACHMENTSNUMBER
first page 0
second page 2
third page 1
fourth page 0
</code></pre>
<p>How do I get the 0 part?</p>
| [
{
"answer_id": 36762,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 6,
"selected": true,
"text": "select page.name, count(page-attachment.id) as attachmentsnumber \nfrom page \n left outer join page-attachment on page... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2138/"
] |
36,806 | <p>I have been sold on mod_wsgi and apache rather than mod_python.
I have all the parts installed (django, apache, mod_wsgi) but have run into a problem deploying.</p>
<p>I am on osx 10.5 with apache 2.2 and django 1.0b2, mod_wsgi-2.3</p>
<p>My application is called tred.</p>
<p>Here are the relevant files:
httpd-vhosts (included in httpd-conf)</p>
<pre>
NameVirtualHost tred:80
ServerName tred
Alias /admin_media /usr/lib/python2.5/site-packages/django/contrib/admin/media
Order allow,deny
Allow from all
Alias /media /Users/dmg/Sites/tred/media
Order allow,deny
Allow from all
Alias / /Users/dmg/Sites/tred/
Order allow,deny
Allow from all
WSGIScriptAlias / /Users/dmg/Sites/tred/mod_wsgi-handler.wsgi
WSGIDaemonProcess tred user=dmg group=staff processes=1 threads=10
WSGIProcessGroup tred
</pre>
<p>mod_wsgi-handle.wsgi</p>
<pre>
import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
os.environ['DJANGO_SETTINGS_MODULE'] = 'tred.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
</pre>
<p>When I go to <a href="http://tred" rel="noreferrer">http://tred</a> I get a directory listing rather than the rendered website. I think I have followed the tutorials correctly but it is obviously not right. What can I do to make this work?</p>
| [
{
"answer_id": 37009,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 4,
"selected": true,
"text": "Alias /"
},
{
"answer_id": 37218,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "h... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3431280/"
] |
36,812 | <p>Currently, I am writing up a bit of a product-based CMS as my first project.</p>
<p>Here is my question. How can I add additional data (products) to my Product model?</p>
<p>I have added '/admin/products/add' to my urls.py, but I don't really know where to go from there. How would i build both my view and my template? Please keep in mind that I don't really know all that much Python, and i am very new to Django</p>
<p>How can I do this all without using this existing django admin interface.</p>
| [
{
"answer_id": 36935,
"author": "Carl Meyer",
"author_id": 3207,
"author_profile": "https://Stackoverflow.com/users/3207",
"pm_score": 4,
"selected": true,
"text": "from django.conf.urls.defaults import *\nfrom django.views.generic.create_update import create_object\n\nfrom my_products_a... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2592/"
] |
36,813 | <p>When and how should table stats gathering be performed for Oracle, version 9 and up? How would you go about gathering stats for a large database, where stats gathering would collide with "business hours".</p>
| [
{
"answer_id": 117066,
"author": "Nick Pierpoint",
"author_id": 4003,
"author_profile": "https://Stackoverflow.com/users/4003",
"pm_score": 3,
"selected": false,
"text": "dbms_stats.export_table_stats\n dbms_stats.import_table_stats\n schema database"
}
] | 2008/08/31 | [
"https://Stackoverflow.com/questions/36813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3839/"
] |
36,831 | <p>I'm writing C# code that uses the windows IP Helper API. One of the functions I'm trying to call is "<a href="http://msdn.microsoft.com/en-us/library/aa365920(VS.85).aspx" rel="nofollow noreferrer">GetBestInterface</a>" that takes a 'uint' representation of an IP. What I need is to parse a textual representation of the IP to create the 'uint' representation.</p>
<p>I've found some examples via Google, like <a href="http://www.justin-cook.com/wp/2006/11/28/convert-an-ip-address-to-ip-number-with-php-asp-c-and-vbnet/" rel="nofollow noreferrer">this one</a> or <a href="http://www.codeguru.com/csharp/.net/net_general/internet/article.php/c10651" rel="nofollow noreferrer">this one</a>, but I'm pretty sure there should be a standard way to achieve this with .NET. Only problem is, I can't find this standard way. IPAddress.Parse seems to be in the right direction, but it doesn't supply any way of getting a 'uint' representation...</p>
<p>There is also a way of doing this using IP Helper, using the <a href="http://msdn.microsoft.com/en-us/library/bb408412(VS.85).aspx" rel="nofollow noreferrer">ParseNetworkString</a>, but again, I'd rather use .NET - I believe the less I rely on pInvoke the better.</p>
<p>So, anyone knows of a standard way to do this in .NET?</p>
| [
{
"answer_id": 36841,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 5,
"selected": true,
"text": "var ipAddress = IPAddress.Parse(\"some.ip.address\");\nvar ipBytes = ipAddress.GetAddressBytes();\nvar ip = (uint)ipBytes [3] << 2... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36831",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1596/"
] |
36,832 | <p>In C++ when a virtual function is called from within a constructor it doesn't behave like a virtual function.</p>
<p>I think everyone who encountered this behavior for the first time was surprised but on second thought it made sense:</p>
<p>As long as the derived constructor has not been executed the object is <strong>not</strong> yet a <em>derived</em> instance.</p>
<p>So how can a derived function be called? The preconditions haven't had the chance to be set up. Example:</p>
<pre><code>class base {
public:
base()
{
std::cout << "foo is " << foo() << std::endl;
}
virtual int foo() { return 42; }
};
class derived : public base {
int* ptr_;
public:
derived(int i) : ptr_(new int(i*i)) { }
// The following cannot be called before derived::derived due to how C++ behaves,
// if it was possible... Kaboom!
virtual int foo() { return *ptr_; }
};
</code></pre>
<p>It's exactly the same for Java and .NET yet they chose to go the other way, and is possibly the only reason for <em>the principle of least surprise</em>? </p>
<p>Which do you think is the correct choice?</p>
| [
{
"answer_id": 75026,
"author": "Lars Truijens",
"author_id": 1242,
"author_profile": "https://Stackoverflow.com/users/1242",
"pm_score": 0,
"selected": false,
"text": "type\n TComponent = class\n public\n constructor Create(AOwner: TComponent); virtual; // virtual constructor\n en... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3848/"
] |
36,861 | <p>I've run into a strange syntax in <a href="http://boo.codehaus.org/Closures" rel="nofollow noreferrer">Boo Language Guide</a> :</p>
<pre><code>setter = { value | a = value }
</code></pre>
<p>What does the | operator mean?</p>
| [
{
"answer_id": 36869,
"author": "dF.",
"author_id": 3002,
"author_profile": "https://Stackoverflow.com/users/3002",
"pm_score": 4,
"selected": true,
"text": "setter = { value | a = value }\n setter = def(value):\n a = value\n"
}
] | 2008/08/31 | [
"https://Stackoverflow.com/questions/36861",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2313/"
] |
36,862 | <p>With SVN, I had a single big repository I kept on a server, and checked-out on a few machines. This was a pretty good backup system, and allowed me easily work on any of the machines. I could checkout a specific project, commit and it updated the 'master' project, or I could checkout the entire thing.</p>
<p>Now, I have a bunch of git repositories, for various projects, several of which are on github. I also have the SVN repository I mentioned, imported via the git-svn command..</p>
<p>Basically, I like having all my code (not just projects, but random snippets and scripts, some things like my CV, articles I've written, websites I've made and so on) in one big repository I can easily clone onto remote machines, or memory-sticks/harddrives as backup.</p>
<p>The problem is, since it's a private repository, and git doesn't allow checking out of a specific folder (that I could push to github as a separate project, but have the changes appear in both the master-repo, and the sub-repos)</p>
<p>I <em>could</em> use the git submodule system, but it doesn't act how I want it too (submodules are pointers to other repositories, and don't really contain the actual code, so it's useless for backup)</p>
<p>Currently I have a folder of git-repos (for example, ~/code_projects/proj1/.git/ ~/code_projects/proj2/.git/), and after doing changes to proj1 I do <code>git push github</code>, then I copy the files into ~/Documents/code/python/projects/proj1/ and do a single commit (instead of the numerous ones in the individual repos). Then do <code>git push backupdrive1</code>, <code>git push mymemorystick</code> etc</p>
<p>So, the question: How do your personal code and projects with git repositories, and keep them synced and backed-up?</p>
| [
{
"answer_id": 36905,
"author": "Spoike",
"author_id": 3713,
"author_profile": "https://Stackoverflow.com/users/3713",
"pm_score": 2,
"selected": false,
"text": "git-submodule repo"
},
{
"answer_id": 37006,
"author": "Damien Diederen",
"author_id": 3844,
"author_profi... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/745/"
] |
36,876 | <p>I am using forms authentication. My users are redirected to a page (written in web.config) when they login, but some of them may not have the privilages to access this default page. In this case, I want them to redirect to another page but RedirectFromLoginPage method always redirects to the default page in web.config. How do I make the users login, and then redirect to a page which depends on some criteria?</p>
| [
{
"answer_id": 36879,
"author": "Joseph Daigle",
"author_id": 507,
"author_profile": "https://Stackoverflow.com/users/507",
"pm_score": 4,
"selected": true,
"text": "SetAuthCookie"
},
{
"answer_id": 11499845,
"author": "peyman",
"author_id": 1528166,
"author_profile":... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31505/"
] |
36,877 | <p>How can I set the cookies in my <code>PHP apps</code> as <code>HttpOnly cookies</code>?</p>
| [
{
"answer_id": 36880,
"author": "Polsonby",
"author_id": 137,
"author_profile": "https://Stackoverflow.com/users/137",
"pm_score": 3,
"selected": false,
"text": "header(\"Set-Cookie: hidden=value; httpOnly\");\n"
},
{
"answer_id": 36882,
"author": "Marius",
"author_id": 1... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3871/"
] |
36,881 | <p>I have an activity that has a TabHost containing a set of TabSpecs each with a listview containing the items to be displayed by the tab. When each TabSpec is created, I set an icon to be displayed in the tab header.</p>
<p>The TabSpecs are created in this way within a <code>setupTabs()</code> method which loops to create the appropriate number of tabs:</p>
<pre><code>TabSpec ts = mTabs.newTabSpec("tab");
ts.setIndicator("TabTitle", iconResource);
ts.setContent(new TabHost.TabContentFactory(
{
public View createTabContent(String tag)
{
...
}
});
mTabs.addTab(ts);
</code></pre>
<p>There are a couple of instances where I want to be able to change the icon which is displayed in each tab during the execution of my program. Currently, I am deleting all the tabs, and calling the above code again to re-create them.</p>
<pre><code>mTabs.getTabWidget().removeAllViews();
mTabs.clearAllTabs(true);
setupTabs();
</code></pre>
<p>Is there a way to replace the icon that is being displayed without deleting and re-creating all of the tabs?</p>
| [
{
"answer_id": 68078,
"author": "dmazzoni",
"author_id": 7193,
"author_profile": "https://Stackoverflow.com/users/7193",
"pm_score": 6,
"selected": true,
"text": "TabHost TabSpec TabSpec mTabs.getTabWidget() TabWidget ViewGroup getChildCount() getChildAt() TabWidget ViewGroup LinearLayou... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1197/"
] |
36,889 | <p>We've been running <a href="http://eaccelerator.net/" rel="noreferrer" title="eAccelerator">eAccelerator</a> on each of 3 webservers and are looking to move to a <a href="http://www.danga.com/memcached/" rel="noreferrer" title="memcache">memcache</a> pool across all 3, hopefully reducing by about 2/3 our db lookups.</p>
<p>One of the handy things about eAccelerator is the web-based control interface (<a href="http://eaccelerator.net/browser/eaccelerator/tags/0.9.5-rc1/control.php" rel="noreferrer" title="control.php">control.php</a>), which has proved very useful when we've had to flush the cache unexpectedly, quickly monitor which scripts are in cache, etc.</p>
<p>We've been looking but haven't found anything that offers the same type of functionality for memcache - does anyone know if such a thing exists?</p>
<p>Obviously flushing cache etc is easy enough with memcache on the console, but our particular set-up means we may have guys monitoring our front-end and needing to flush the cache who will not necessarily have shell access on the servers. </p>
| [
{
"answer_id": 26085210,
"author": "Bainternet",
"author_id": 783536,
"author_profile": "https://Stackoverflow.com/users/783536",
"pm_score": 3,
"selected": false,
"text": "github"
}
] | 2008/08/31 | [
"https://Stackoverflow.com/questions/36889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2287/"
] |
36,890 | <p>I'd like to add a method to my existing server's CORBA interface. Will that require recompiling all clients?</p>
<p>I'm using TAO.</p>
| [
{
"answer_id": 20404774,
"author": "shijie xu",
"author_id": 910118,
"author_profile": "https://Stackoverflow.com/users/910118",
"pm_score": 0,
"selected": false,
"text": " remoteObjRef->invoke(\"methodname\", args); // send(\"methodname\", args)\n"
}
] | 2008/08/31 | [
"https://Stackoverflow.com/questions/36890",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3583/"
] |
36,901 | <p>What do <code>*args</code> and <code>**kwargs</code> mean?</p>
<pre><code>def foo(x, y, *args):
def bar(x, y, **kwargs):
</code></pre>
| [
{
"answer_id": 36908,
"author": "Peter Hoffmann",
"author_id": 720,
"author_profile": "https://Stackoverflow.com/users/720",
"pm_score": 13,
"selected": true,
"text": "*args **kwargs *args def foo(*args):\n for a in args:\n print(a) \n\nfoo(1)\n# 1\n\nfoo(1,2,3)\n# 1\n# ... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2572/"
] |
36,906 | <p>I want to swap two integers, and I want to know which of these two implementations will be faster:
The obvious way with a temp variable:</p>
<pre><code>void swap(int* a, int* b)
{
int temp = *a;
*a = *b;
*b = temp;
}
</code></pre>
<p>Or the xor version that I'm sure most people have seen:</p>
<pre><code>void swap(int* a, int* b)
{
*a ^= *b;
*b ^= *a;
*a ^= *b;
}
</code></pre>
<p>It seems like the first uses an extra register, but the second one is doing three loads and stores while the first only does two of each. Can someone tell me which is faster and why? The why being more important.</p>
| [
{
"answer_id": 36948,
"author": "Tim Ring",
"author_id": 3685,
"author_profile": "https://Stackoverflow.com/users/3685",
"pm_score": 0,
"selected": false,
"text": "PUSH A\nA=B\nPOP B\n"
},
{
"answer_id": 44911,
"author": "paperhorse",
"author_id": 4498,
"author_profil... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3869/"
] |
36,915 | <p>We have been working with CVS for years, and frequently find it useful to "sticky" a single file here and there.</p>
<p>Is there any way to do this in subversion, specifically from TortoiseSVN?</p>
| [
{
"answer_id": 36948,
"author": "Tim Ring",
"author_id": 3685,
"author_profile": "https://Stackoverflow.com/users/3685",
"pm_score": 0,
"selected": false,
"text": "PUSH A\nA=B\nPOP B\n"
},
{
"answer_id": 44911,
"author": "paperhorse",
"author_id": 4498,
"author_profil... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3798/"
] |
36,932 | <p>I'm mainly a C# developer, but I'm currently working on a project in Python.</p>
<p>How can I represent the equivalent of an Enum in Python? </p>
| [
{
"answer_id": 36937,
"author": "Alexandru Nedelcu",
"author_id": 3280,
"author_profile": "https://Stackoverflow.com/users/3280",
"pm_score": 10,
"selected": false,
"text": "class Animal:\n DOG = 1\n CAT = 2\n\nx = Animal.DOG\n name value from enum import Enum\n\nclass Animal(Enum)... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3880/"
] |
36,953 | <p>Can people point me to resources on lexing, parsing and tokenising with Python?</p>
<p>I'm doing a little hacking on an open source project (<a href="http://www.hotwire-shell.org/" rel="noreferrer">hotwire</a>) and wanted to do a few changes to the code that <a href="http://code.google.com/p/hotwire-shell/source/browse/trunk/hotwire/externals/shlex.py" rel="noreferrer">lexes</a>, <a href="http://code.google.com/p/hotwire-shell/source/browse/trunk/hotwire/command.py" rel="noreferrer">parses and tokenises</a> the commands entered into it. As it is real working code it is fairly complex and a bit hard to work out.</p>
<p>I haven't worked on code to lex/parse/tokenise before, so I was thinking one approach would be to work through a tutorial or two on this aspect. I would hope to learn enough to navigate around the code I actually want to alter. Is there anything suitable out there? (Ideally it could be done in an afternoon without having to buy and read the dragon book first ...)</p>
<p><strong>Edit:</strong> (7 Oct 2008) None of the below answers quite give what I want. With them I could generate parsers from scratch, but I want to learn how to write my own basic parser from scratch, not using lex and yacc or similar tools. Having done that I can then understand the existing code better. </p>
<p>So could someone point me to a tutorial where I can build a basic parser from scratch, using just python?</p>
| [
{
"answer_id": 137207,
"author": "Torsten Marek",
"author_id": 9567,
"author_profile": "https://Stackoverflow.com/users/9567",
"pm_score": 4,
"selected": false,
"text": ">>> from pyparsing import Word, alphas\n>>> greet = Word( alphas ) + \",\" + Word( alphas ) + \"!\" # <-- grammar defi... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36953",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3189/"
] |
36,956 | <p>A Windows Forms application of ours pulls records from a view on SQL Server through ADO.NET and a SOAP web service, displaying them in a data grid. We have had several cases with ~25,000 rows, which works relatively smoothly, but a potential customer needs to have many times that much in a single list.</p>
<p>To figure out how well we scale right now, and how (and how far) we can realistically improve, I'd like to implement a simulation: instead of displaying actual data, have the SQL Server send fictional, random data. The client and transport side would be mostly the same; the view (or at least the underlying table) would of course work differently. The user specifies the amount of fictional rows (e.g. 100,000).</p>
<p>For the time being, I just want to know how long it takes for the client to retrieve and process the data and is just about ready to display it.</p>
<p>What I'm trying to figure out is this: how do I make the SQL Server send such data?</p>
<p>Do I:</p>
<ol>
<li>Create a stored procedure that has to be run beforehand to fill an actual table?</li>
<li>Create a function that I point the view to, thus having the server generate the data 'live'?</li>
<li>Somehow replicate and/or randomize existing data?</li>
</ol>
<p>The first option sounds to me like it would yield the results closest to the real world. Because the data is actually 'physically there', the <code>SELECT</code> query would be quite similar performance-wise to one on real data. However, it taxes the server with an otherwise meaningless operation. The fake data would also be backed up, as it would live in one and the same database — unless, of course, I delete the data after each benchmark run.</p>
<p>The second and third option tax the server <em>while</em> running the actual simulation, thus potentially giving unrealistically slow results.</p>
<hr>
<p>In addition, I'm unsure how to create those rows, short of using a loop or cursor. I can use <code>SELECT top <n> random1(), random2(), […] FROM foo</code> if <code>foo</code> actually happens to have <code><n></code> entries, but otherwise I'll (obviously) only get as many rows as <code>foo</code> happens to have. A <code>GROUP BY newid()</code> or similar doesn't appear to do the trick.</p>
| [
{
"answer_id": 37004,
"author": "Sören Kuklau",
"author_id": 1600,
"author_profile": "https://Stackoverflow.com/users/1600",
"pm_score": 0,
"selected": false,
"text": "WHILE (SELECT count(1) FROM benchmark) < 100000\n INSERT INTO benchmark\n SELECT TOP 100000 * FROM actualData\n"
}
] | 2008/08/31 | [
"https://Stackoverflow.com/questions/36956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1600/"
] |
36,959 | <p>In MS SQL Server, I create my scripts to use customizable variables:</p>
<pre><code>DECLARE @somevariable int
SELECT @somevariable = -1
INSERT INTO foo VALUES ( @somevariable )
</code></pre>
<p>I'll then change the value of <code>@somevariable</code> at runtime, depending on the value that I want in the particular situation. Since it's at the top of the script it's easy to see and remember.</p>
<p>How do I do the same with the PostgreSQL client <code>psql</code>?</p>
| [
{
"answer_id": 36989,
"author": "Craig Walker",
"author_id": 3488,
"author_profile": "https://Stackoverflow.com/users/3488",
"pm_score": 6,
"selected": false,
"text": "SELECT * FROM foo WHERE bar = ':myvariable'\n \\set myvariable '\\'somestring\\'' \nSELECT * FROM foo WHERE bar = :myva... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3488/"
] |
36,984 | <p>So right now my project has a few custom dialogs that do things like prompt the user for his birthday, or whatever. Right now they're just doing things like setting a <code>this.Birthday</code> property once they get an answer (which is of type <code>DateTime?</code>, with the null indicating a "Cancel"). Then the caller inspects the <code>Birthday</code> property of the dialog it created to figure out what the user answered.</p>
<p>My question is, <em>is there a more standard pattern for doing stuff like this?</em> I know we can set <code>this.DialogResult</code> for basic OK/Cancel stuff, but is there a more general way in Windows Forms for a form to indicate "here's the data I collected"?</p>
| [
{
"answer_id": 37008,
"author": "Murph",
"author_id": 1070,
"author_profile": "https://Stackoverflow.com/users/1070",
"pm_score": 2,
"selected": false,
"text": "if (Dialog == Ok)\n{\n // Do Stuff with the entered values\n}\nelse\n{\n // Respond appropriately to the user cancelling ... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3191/"
] |
36,991 | <p>So, I am a total beginner in any kind of <code>Windows</code> related programming. I have been playing around with the <code>Windows</code> <code>API</code> and came across a couple of examples on how to initialize create windows and such. </p>
<p>One example creates a regular window (I abbreviated some of the code):</p>
<pre><code>int WINAPI WinMain( [...] )
{
[...]
// Windows Class setup
wndClass.cbSize = sizeof( wndClass );
wndClass.style = CS_HREDRAW | CS_VREDRAW;
[...]
// Register class
RegisterClassEx( &wndClass );
// Create window
hWnd = CreateWindow( szAppName, "Win32 App",
WS_OVERLAPPEDWINDOW,
0, 0, 512, 384,
NULL, NULL, hInstance, NULL );
[...]
}
</code></pre>
<p>The second example creates a dialog box (no abbreviations except the WinMain arguments):</p>
<pre><code>int WINAPI WinMain( [...] )
{
// Create dialog box
DialogBox(hInstance,
MAKEINTRESOURCE(IDD_MAIN_DLG),
NULL,
(DLGPROC)DialogProc);
}
</code></pre>
<p>The second example does not contain any call to the register function. It just creates the DialogBox with its DialogProc process attached. </p>
<p>This works fine, but I am wondering if there is a benefit of registering the window class and then creating the dialog box (if this is at all possible). </p>
| [
{
"answer_id": 37008,
"author": "Murph",
"author_id": 1070,
"author_profile": "https://Stackoverflow.com/users/1070",
"pm_score": 2,
"selected": false,
"text": "if (Dialog == Ok)\n{\n // Do Stuff with the entered values\n}\nelse\n{\n // Respond appropriately to the user cancelling ... | 2008/08/31 | [
"https://Stackoverflow.com/questions/36991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2386/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.