qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
78,181 | <p>If I am given a <code>MemoryStream</code> that I know has been populated with a <code>String</code>, how do I get a <code>String</code> back out?</p>
| [
{
"answer_id": 78190,
"author": "Brian",
"author_id": 320,
"author_profile": "https://Stackoverflow.com/users/320",
"pm_score": 7,
"selected": false,
"text": "<Extension()> _\nPublic Function ReadAll(ByVal memStream As MemoryStream) As String\n ' Reset the stream otherwise you will ju... | 2008/09/16 | [
"https://Stackoverflow.com/questions/78181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/320/"
] |
78,184 | <p>I'm a beginning C++ programmer / network admin, but I figure I can learn how to do this if someone points me in the right direction. Most of the tutorials are demonstrated using old code that no longer works for some reason. </p>
<p>Since I'm on Linux, all I need is an explanation on how to write raw Berkeley sockets. Can someone give me a quick run down?</p>
| [
{
"answer_id": 78209,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "#include <sys/socket.h>\n#include <sys/types.h>\n\nint socket(int protocolFamily, int Type, int Protocol)\n// returns a socket ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/78184",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
78,230 | <p>I am just getting started with flex and am using the SDK (not Flex Builder). I was wondering what's the best way to compile a mxml file from an ant build script. </p>
| [
{
"answer_id": 222331,
"author": "jgormley",
"author_id": 29738,
"author_profile": "https://Stackoverflow.com/users/29738",
"pm_score": 3,
"selected": false,
"text": "<?xml version=\"1.0\"?>\n\n<project name=\"flexapptest\" default=\"buildAndRun\" basedir=\".\">\n\n <!-- \n mak... | 2008/09/16 | [
"https://Stackoverflow.com/questions/78230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1227001/"
] |
78,233 | <p>I have a dataset that I have modified into an xml document and then used a xsl sheet to transform into an Excel xml format in order to allow the data to be opened programatically from my application. I have run into two problems with this:</p>
<ol>
<li><p>Excel is not the default Windows application to open Excel files, therefore when Program.Start("xmlfilename.xml") is run, IE is opened and the XML file is not very readable.</p></li>
<li><p>If you rename the file to .xlsx, you receive a warning, "This is not an excel file, do you wish to continue". This is not ideal for customers.</p></li>
</ol>
<p>Ideally, I would like Windows to open the file in Excel without modifying the default OS setting for opening Excel files. Office interop is a possibility, but seems like a little overkill for this application. Does anyone have any ideas to make this work?</p>
<p>The solution is in .Net/C#, but I am open to other possibilities to create a clean solution.</p>
| [
{
"answer_id": 78292,
"author": "MagicKat",
"author_id": 8505,
"author_profile": "https://Stackoverflow.com/users/8505",
"pm_score": 2,
"selected": true,
"text": "Process.Start(@\"C:\\Program Files\\Microsoft Office\\Officexx\\excel.exe\", \"yourfile.xml\");\n"
},
{
"answer_id": ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/78233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2916/"
] |
78,277 | <p>When can 64-bit writes be guaranteed to be atomic, when programming in C on an Intel x86-based platform (in particular, an Intel-based Mac running MacOSX 10.4 using the Intel compiler)? For example:</p>
<pre><code>unsigned long long int y;
y = 0xfedcba87654321ULL;
/* ... a bunch of other time-consuming stuff happens... */
y = 0x12345678abcdefULL;
</code></pre>
<p>If another thread is examining the value of y after the first assignment to y has finished executing, I would like to ensure that it sees either the value 0xfedcba87654321 or the value 0x12345678abcdef, and not some blend of them. I would like to do this without any locking, and if possible without any extra code. My hope is that, when using a 64-bit compiler (the 64-bit Intel compiler), on an operating system capable of supporting 64-bit code (MacOSX 10.4), that these 64-bit writes will be atomic. Is this always true?</p>
| [
{
"answer_id": 78383,
"author": "Chris Hanson",
"author_id": 714,
"author_profile": "https://Stackoverflow.com/users/714",
"pm_score": 5,
"selected": false,
"text": "NOP"
},
{
"answer_id": 78399,
"author": "Mike Dimmick",
"author_id": 6970,
"author_profile": "https://... | 2008/09/16 | [
"https://Stackoverflow.com/questions/78277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
78,278 | <p>How do I write a clean implementation of the strategy pattern in Perl? I want to do it in a way that leverages Perl's features.</p>
| [
{
"answer_id": 78301,
"author": "Leon Timmermans",
"author_id": 4727,
"author_profile": "https://Stackoverflow.com/users/4727",
"pm_score": 2,
"selected": false,
"text": "sort { lc($a) cmp lc($b) } @items\n"
},
{
"answer_id": 83715,
"author": "tsee",
"author_id": 13164,
... | 2008/09/16 | [
"https://Stackoverflow.com/questions/78278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1227001/"
] |
78,296 | <p>What are some reasons why PHP would force errors to show, no matter what you tell it to disable?</p>
<p>I have tried </p>
<pre><code>error_reporting(0);
ini_set('display_errors', 0);
</code></pre>
<p>with no luck.</p>
| [
{
"answer_id": 17019832,
"author": "komodosp",
"author_id": 1495940,
"author_profile": "https://Stackoverflow.com/users/1495940",
"pm_score": 1,
"selected": false,
"text": "set_error_handler()"
},
{
"answer_id": 34137690,
"author": "ob-ivan",
"author_id": 2184166,
"au... | 2008/09/16 | [
"https://Stackoverflow.com/questions/78296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14322/"
] |
78,303 | <p>I'm toying with my first remoting project and I need to create a RemotableType DLL. I know I can compile it by hand with csc, but I wonder if there are some facilities in place on Visual Studio to handle the Remoting case, or, more specificly, to tell it that a specific file should be compiled as a .dll without having to add another project to a solution exclusively to compile a class or two into DLLs. </p>
<p>NOTE: I know I should toy with my first WCF project, but this has to run on 2.0.</p>
| [
{
"answer_id": 17019832,
"author": "komodosp",
"author_id": 1495940,
"author_profile": "https://Stackoverflow.com/users/1495940",
"pm_score": 1,
"selected": false,
"text": "set_error_handler()"
},
{
"answer_id": 34137690,
"author": "ob-ivan",
"author_id": 2184166,
"au... | 2008/09/16 | [
"https://Stackoverflow.com/questions/78303",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5190/"
] |
78,336 | <p>I need to figure out the hard drive name for a solaris box and it is not clear to me what the device name is. On linux, it would be something like <code>/dev/hda</code> or <code>/dev/sda</code>, but on solaris I am getting a bit lost in the partitions and what the device is called. I think that entries like <code>/dev/rdsk/c0t0d0s0</code> are the partitions, how is the whole hard drive referenced?</p>
| [
{
"answer_id": 8568676,
"author": "jlliagre",
"author_id": 211665,
"author_profile": "https://Stackoverflow.com/users/211665",
"pm_score": 2,
"selected": false,
"text": "c0t0d0s2"
}
] | 2008/09/16 | [
"https://Stackoverflow.com/questions/78336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13912/"
] |
78,389 | <p>I'm new to RhinoMocks, and trying to get a grasp on the syntax in addition to what is happening under the hood.</p>
<p>I have a user object, we'll call it User, which has a property called IsAdministrator. The value for IsAdministrator is evaluated via another class that checks the User's security permissions, and returns either true or false based on those permissions. I'm trying to mock this User class, and fake the return value for IsAdministrator in order to isolate some Unit Tests.</p>
<p>This is what I'm doing so far:</p>
<pre><code>public void CreateSomethingIfUserHasAdminPermissions()
{
User user = _mocks.StrictMock<User>();
SetupResult.For(user.IsAdministrator).Return(true);
// do something with my User object
}
</code></pre>
<p>Now, I'm expecting that Rhino is going to 'fake' the call to the property getter, and just return true to me. Is this incorrect? Currently I'm getting an exception because of dependencies in the IsAdministrator property.</p>
<p>Can someone explain how I can achieve my goal here?</p>
| [
{
"answer_id": 79719,
"author": "Josh",
"author_id": 11702,
"author_profile": "https://Stackoverflow.com/users/11702",
"pm_score": 5,
"selected": true,
"text": "public class FakeUserType: User\n{\n //overriding code here\n}\n"
}
] | 2008/09/16 | [
"https://Stackoverflow.com/questions/78389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/769/"
] |
78,392 | <p>I have an application that works pretty well in Ubuntu, Windows and the Xandros that come with the Asus EeePC.</p>
<p>Now we are moving to the <a href="http://en.wikipedia.org/wiki/Aspire_One" rel="nofollow noreferrer">Acer Aspire One</a> but I'm having a lot of trouble making php-gtk to compile under the Fedora-like (Linpus Linux Lite) Linux that come with it.</p>
| [
{
"answer_id": 99021,
"author": "levhita",
"author_id": 7946,
"author_profile": "https://Stackoverflow.com/users/7946",
"pm_score": 2,
"selected": true,
"text": "#!/bin/bash\nsudo yum install yum-utils\n#We don't want to update the main gtk2 by mistake so we download them\n#manually and ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/78392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7946/"
] |
78,431 | <p>I would like to replicate this in python:</p>
<pre><code>gvimdiff <(hg cat file.txt) file.txt
</code></pre>
<p>(hg cat file.txt outputs the most recently committed version of file.txt)</p>
<p>I know how to pipe the file to gvimdiff, but it won't accept another file:</p>
<pre><code>$ hg cat file.txt | gvimdiff file.txt -
Too many edit arguments: "-"
</code></pre>
<p>Getting to the python part...</p>
<pre><code># hgdiff.py
import subprocess
import sys
file = sys.argv[1]
subprocess.call(["gvimdiff", "<(hg cat %s)" % file, file])
</code></pre>
<p>When subprocess is called it merely passes <code><(hg cat file)</code> onto <code>gvimdiff</code> as a filename.</p>
<p>So, is there any way to redirect a command as bash does?
For simplicity's sake just cat a file and redirect it to diff:</p>
<pre><code>diff <(cat file.txt) file.txt
</code></pre>
| [
{
"answer_id": 78459,
"author": "Mark Hattarki",
"author_id": 14424,
"author_profile": "https://Stackoverflow.com/users/14424",
"pm_score": 2,
"selected": false,
"text": "import commands\n\nstatus, output = commands.getstatusoutput(\"gvimdiff <(hg cat file.txt) file.txt\")\n"
},
{
... | 2008/09/16 | [
"https://Stackoverflow.com/questions/78431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12650/"
] |
78,447 | <p>How to create a DOM from a User's input in PHP5?</p>
| [
{
"answer_id": 78465,
"author": "Adam Wright",
"author_id": 1200,
"author_profile": "https://Stackoverflow.com/users/1200",
"pm_score": 2,
"selected": false,
"text": "$dom = new DOMDocument();\n$dom->loadXML($xml);\n"
},
{
"answer_id": 89750,
"author": "Community",
"autho... | 2008/09/16 | [
"https://Stackoverflow.com/questions/78447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12854/"
] |
78,450 | <p>I'm trying to use Python with ReportLab 2.2 to create a PDF report.<br>
According to the <a href="http://www.reportlab.com/docs/userguide.pdf" rel="noreferrer">user guide</a>,</p>
<blockquote>
<p>Special TableStyle Indeces [sic]</p>
<p>In any style command the first row index may be set to one of the special strings 'splitlast' or 'splitfirst' to indicate that the style should be used only for the last row of a split table, or the first row of a continuation. This allows splitting tables with nicer effects around the split.</p>
</blockquote>
<p>I've tried using several style elements, including:</p>
<pre><code>('TEXTCOLOR', (0, 'splitfirst'), (1, 'splitfirst'), colors.black)
('TEXTCOLOR', (0, 'splitfirst'), (1, 0), colors.black)
('TEXTCOLOR', (0, 'splitfirst'), (1, -1), colors.black)
</code></pre>
<p>and none of these seems to work. The first generates a TypeError with the message: </p>
<pre><code>TypeError: cannot concatenate 'str' and 'int' objects
</code></pre>
<p>and the latter two generate TypeErrors with the message:</p>
<pre><code>TypeError: an integer is required
</code></pre>
<p>Is this functionality simply broken or am I doing something wrong? If the latter, what am I doing wrong?</p>
| [
{
"answer_id": 94869,
"author": "DLJessup",
"author_id": 14382,
"author_profile": "https://Stackoverflow.com/users/14382",
"pm_score": 2,
"selected": false,
"text": "class XTable(Table):\n def onSplit(self, T, byRow=1):\n T.setStyle(TableStyle([\n ('TEXTCOLOR', (0, 1),... | 2008/09/16 | [
"https://Stackoverflow.com/questions/78450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14382/"
] |
78,468 | <p>I am trying to understand left outer joins in LINQ to Entity. For example I have the following 3 tables:</p>
<p>Company, CompanyProduct, Product</p>
<p>The CompanyProduct is linked to its two parent tables, Company and Product.</p>
<p>I want to return all of the Company records and the associated CompanyProduct whether the CompanyProduct exists or not for a given product. In Transact SQL I would go from the Company table using left outer joins as follows: </p>
<pre><code>SELECT * FROM Company AS C
LEFT OUTER JOIN CompanyProduct AS CP ON C.CompanyID=CP.CompanyID
LEFT OUTER JOIN Product AS P ON CP.ProductID=P.ProductID
WHERE P.ProductID = 14 OR P.ProductID IS NULL
</code></pre>
<p>My database has 3 companies, and 2 CompanyProduct records assocaited with the ProductID of 14. So the results from the SQL query are the expected 3 rows, 2 of which are connected to a CompanyProduct and Product and 1 which simply has the Company table and nulls in the CompanyProduct and Product tables. </p>
<p>So how do you write the same kind of join in LINQ to Entity to acheive a similiar result? </p>
<p>I have tried a few different things but can't get the syntax correct.</p>
<p>Thanks.</p>
| [
{
"answer_id": 78714,
"author": "dimarzionist",
"author_id": 10778,
"author_profile": "https://Stackoverflow.com/users/10778",
"pm_score": 0,
"selected": false,
"text": "from s in db.Employees\njoin e in db.Employees on s.ReportsTo equals e.EmployeeId\njoin er in EmployeeRoles on s.Emplo... | 2008/09/16 | [
"https://Stackoverflow.com/questions/78468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
78,471 | <p>How can I find out the date a MS SQL Server 2000 object was last modified?</p>
<p>I need to get a list of all the views, procs, functions etc that were modified since Aug 15th. In sysObjects I can see the date objects were created but I need to know when they were last altered.</p>
<p>NB: this is an SQL 2000 database.</p>
| [
{
"answer_id": 2342967,
"author": "Allov",
"author_id": 130480,
"author_profile": "https://Stackoverflow.com/users/130480",
"pm_score": 4,
"selected": false,
"text": "USE [Your_DB] \nSELECT * FROM INFORMATION_SCHEMA.ROUTINES\n"
},
{
"answer_id": 22472528,
"author": "Sudhir... | 2008/09/16 | [
"https://Stackoverflow.com/questions/78471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10422/"
] |
78,474 | <p>Using only ANSI C, what is the best way to, with fair certainty, determine if a C style string is either a integer or a real number (i.e float/double)?</p>
| [
{
"answer_id": 78485,
"author": "nutbar",
"author_id": 14425,
"author_profile": "https://Stackoverflow.com/users/14425",
"pm_score": 2,
"selected": false,
"text": "."
},
{
"answer_id": 78565,
"author": "Patrick_O",
"author_id": 11084,
"author_profile": "https://Stacko... | 2008/09/16 | [
"https://Stackoverflow.com/questions/78474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9418/"
] |
78,493 | <p>I once read that one way to obtain a unique filename in a shell for temp files was to use a double dollar sign (<code>$$</code>). This does produce a number that varies from time to time... but if you call it repeatedly, it returns the same number. (The solution is to just use the time.)</p>
<p>I am curious to know what <code>$$</code> actually is, and why it would be suggested as a way to generate unique filenames.</p>
| [
{
"answer_id": 78504,
"author": "Joe Skora",
"author_id": 14057,
"author_profile": "https://Stackoverflow.com/users/14057",
"pm_score": 8,
"selected": true,
"text": "$$"
},
{
"answer_id": 78546,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stacko... | 2008/09/16 | [
"https://Stackoverflow.com/questions/78493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14345/"
] |
78,497 | <p>Does anyone know of any resources that talk about best practices or design patterns for shell scripts (sh, bash etc.)?</p>
| [
{
"answer_id": 739034,
"author": "Stefano Borini",
"author_id": 78374,
"author_profile": "https://Stackoverflow.com/users/78374",
"pm_score": 9,
"selected": true,
"text": "CommandLineOptions__config_file=\"\"\nCommandLineOptions__debug_level=\"\"\n\ngetopt_results=`getopt -s bash -o c:d:... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78497",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14437/"
] |
78,536 | <p>I want to do something like:</p>
<pre><code>MyObject myObj = GetMyObj(); // Create and fill a new object
MyObject newObj = myObj.Clone();
</code></pre>
<p>And then make changes to the new object that are not reflected in the original object.</p>
<p>I don't often need this functionality, so when it's been necessary, I've resorted to creating a new object and then copying each property individually, but it always leaves me with the feeling that there is a better or more elegant way of handling the situation.</p>
<p>How can I clone or deep copy an object so that the cloned object can be modified without any changes being reflected in the original object?</p>
| [
{
"answer_id": 78612,
"author": "johnc",
"author_id": 5302,
"author_profile": "https://Stackoverflow.com/users/5302",
"pm_score": 12,
"selected": true,
"text": "ICloneable"
},
{
"answer_id": 78856,
"author": "Ryan Lundy",
"author_id": 5486,
"author_profile": "https://... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3742/"
] |
78,548 | <p>What is your way of passing data to Master Page (using ASP.NET MVC) without breaking MVC rules?</p>
<p>Personally, I prefer to code abstract controller (base controller) or base class which is passed to all views.</p>
| [
{
"answer_id": 746011,
"author": "Generic Error",
"author_id": 40944,
"author_profile": "https://Stackoverflow.com/users/40944",
"pm_score": 7,
"selected": true,
"text": "public class MasterViewData\n{\n public ICollection<string> Navigation { get; set; }\n}\n"
},
{
"answer_id... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/347616/"
] |
78,560 | <p>I have an SQL Server database where I have the data and log files stored on an external USB drive. I switch the external drive between my main development machine in my office and my laptop when not in my office. I am trying to use sp_detach_db and sp_attach_db when moving between desktop and laptop machines. I find that this works OK on the desktop - I can detach and reattach the database there no problems. But on the laptop I cannot reattach the database (the database was actually originally created on the laptop and the first detach happened there). When I try to reattach on the laptop I get the following error:</p>
<p>Unable to open the physical file "p:\SQLData\AppManager.mdf". Operating system error 5: "5(error not found)"</p>
<p>I find a lot of references to this error all stating that it is a permissions issue. So I went down this path and made sure that the SQL Server service account has appropriate permissions. I have also created a new database on this same path and been able to succesfully detach and reattach it. So I am confident permissions is not the issue.</p>
<p>Further investigation reveals that I cannot rename, copy or move the data files as Windows thinks they are locked - even when the SQL Server service is stopped. Process Explorer does not show up any process locking the files. </p>
<p>How can I find out what is locking the files and unlock them.</p>
<p>I have verified that the databases do not show up in SSMS - so SQL Server does not still think they exist.</p>
<p><strong>Update 18/09/2008</strong></p>
<p>I have tried all of the suggested answers to date with no success. However trying these suggestions has helped to clarify the situation. I can verify the following:</p>
<ol>
<li>I can successfully detach and reattach the database only when the external drive is attached to the server that a copy of the database is restored to - effectively the server where the database is "created" - lets call this the "Source Server". </li>
<li>I can move, copy or rename the data and log files, after detaching the database, while the external drive is still attached to the Source Server. </li>
<li>As soon as I move the external drive to another machine the data and log files are "locked", although the 2 tools that I have tried - Process Explorer and Unlocker, both find no locking handles attached to the files. </li>
</ol>
<p>NB. After detaching the database I tried both stopping the SQL Server service and shutting down the Source Server prior to moving the external drive - still with no success.</p>
<p>So at this stage all that I can do to move data between desktop and laptop is to make a backup of the data onto the external drive, move the external drive, restore the data from the backup. Works OK but takes a bit more time as the database is a reasonable size (1gb). Anyway this is the only choice I have at this stage even though I was trying to avoid having to go down this path.</p>
| [
{
"answer_id": 47219578,
"author": "Ali Sheikhpour",
"author_id": 4700922,
"author_profile": "https://Stackoverflow.com/users/4700922",
"pm_score": 0,
"selected": false,
"text": "group or usernames"
}
] | 2008/09/17 | [
"https://Stackoverflow.com/questions/78560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10135/"
] |
78,592 | <p>In perl one would simply do the following to store and iterate over a list of names</p>
<pre><code>my @fruit = (apple, orange, kiwi);
foreach (@fruit) {
print $_;
}
</code></pre>
<p>What would the equivalent be in bash?</p>
| [
{
"answer_id": 78601,
"author": "emk",
"author_id": 12089,
"author_profile": "https://Stackoverflow.com/users/12089",
"pm_score": 4,
"selected": false,
"text": "FRUITS=\"apple orange kiwi\"\nfor FRUIT in $FRUITS; do\n echo $FRUIT\ndone\n"
},
{
"answer_id": 78618,
"author": "... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10747/"
] |
78,619 | <p>What is the fastest way you know to convert a floating-point number to an int on an x86 CPU. Preferrably in C or assembly (that can be in-lined in C) for any combination of the following:</p>
<ul>
<li>32/64/80-bit float -> 32/64-bit integer</li>
</ul>
<p>I'm looking for some technique that is faster than to just let the compiler do it.</p>
| [
{
"answer_id": 78820,
"author": "akauppi",
"author_id": 14455,
"author_profile": "https://Stackoverflow.com/users/14455",
"pm_score": 3,
"selected": false,
"text": "lua_Number"
},
{
"answer_id": 119538,
"author": "Suma",
"author_id": 16673,
"author_profile": "https://... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10184/"
] |
78,696 | <p>I'm trying to find out if there is any way to elevate a specific function within an application. For example, I have an app with system and user settings that are stored in the registry, I only need elevation for when the system settings need to be changed. </p>
<p>Unfortunately all of the info I've come across talks about only starting a new process with elevated privileges. </p>
| [
{
"answer_id": 93379,
"author": "Andrei Belogortseff",
"author_id": 17037,
"author_profile": "https://Stackoverflow.com/users/17037",
"pm_score": 4,
"selected": false,
"text": "HRESULT \nCreateElevatedComObject (HWND hwnd, REFGUID guid, REFIID iid, void **ppv)\n{\n WCHAR monikerName[1... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14509/"
] |
78,716 | <p>A while ago, I started on a project where I designed a html-esque XML schema so that authors could write their content (educational course material) in a simplified format which would then be transformed into HTML via XSLT. I played around (struggled) with it for a while and got it to a very basic level but then was too annoyed by the limitations I was encountering (which may well have been limitations of my knowledge) and when I read a blog suggesting to ditch XSLT and just write your own XML-to-whatever parser in your language of choice, I eagerly jumped onto that and it's worked out brilliantly.</p>
<p>I'm still working on it to this day (<em>I'm actually supposed to be working on it right now, instead of playing on SO</em>), and I am seeing more and more things which make me think that the decision to ditch XSLT was a good one.</p>
<p>I know that XSLT has its place, in that it is an accepted standard, and that if everyone is writing their own interpreters, 90% of them will end up on <a href="http://thedailywtf.com" rel="noreferrer">TheDailyWTF</a>. But given that it is a <a href="http://en.wikipedia.org/wiki/Functional_programming" rel="noreferrer">functional style language</a> instead of the procedural style which most programmers are familiar with, for someone embarking on a project such as my own, <strong>would you recommend they go down the path that I did, or stick it out with XSLT</strong>?</p>
| [
{
"answer_id": 1270668,
"author": "Adam Batkin",
"author_id": 120808,
"author_profile": "https://Stackoverflow.com/users/120808",
"pm_score": 5,
"selected": false,
"text": "<ReleaseNotes>\n <FixedBugs>\n <Bug id=\"123\" component=\"Admin\">Error when clicking the Foo button</Bu... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] |
78,717 | <p>I have a 'foreach' macro I use frequently in C++ that works for most STL containers:</p>
<pre><code>#define foreach(var, container) \
for(typeof((container).begin()) var = (container).begin(); \
var != (container).end(); \
++var)
</code></pre>
<p>(Note that 'typeof' is a gcc extension.) It is used like this:</p>
<pre><code>std::vector< Blorgus > blorgi = ...;
foreach(blorgus, blorgi) {
blorgus->draw();
}
</code></pre>
<p>I would like to make something similar that iterates over a map's values. Call it "foreach_value", perhaps. So instead of writing</p>
<pre><code>foreach(pair, mymap) {
pair->second->foo();
}
</code></pre>
<p>I would write</p>
<pre><code>foreach_value(v, mymap) {
v.foo();
}
</code></pre>
<p>I can't come up with a macro that will do this, because it requires declaring two variables: the iterator and the value variable ('v', above). I don't know how to do that in the initializer of a for loop, even using gcc extensions. I could declare it just before the foreach_value call, but then it will conflict with other instances of the foreach_value macro in the same scope. If I could suffix the current line number to the iterator variable name, it would work, but I don't know how to do that.</p>
| [
{
"answer_id": 78780,
"author": "Tom Leys",
"author_id": 11440,
"author_profile": "https://Stackoverflow.com/users/11440",
"pm_score": 3,
"selected": false,
"text": "// Valid C++ code (which does nothing useful)\n{\n int a = 21; // Which could be storage of your value type\n}\n// a out ... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14528/"
] |
78,752 | <p>I have read that using database keys in a URL is a bad thing to do.</p>
<p>For instance,</p>
<p>My table has 3 fields: <code>ID:int</code>, <code>Title:nvarchar(5)</code>, <code>Description:Text</code></p>
<p>I want to create a page that displays a record. Something like ...</p>
<pre><code>http://server/viewitem.aspx?id=1234
</code></pre>
<ol>
<li><p>First off, could someone elaborate on why this is a bad thing to do?</p></li>
<li><p>and secondly, what are some ways to work around using primary keys in a url?</p></li>
</ol>
| [
{
"answer_id": 78814,
"author": "mislav",
"author_id": 11687,
"author_profile": "https://Stackoverflow.com/users/11687",
"pm_score": 1,
"selected": false,
"text": "\"/questions/12345/delete\""
}
] | 2008/09/17 | [
"https://Stackoverflow.com/questions/78752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14396/"
] |
78,757 | <p>How can I programmatically make a query in MS Access default to landscape when printed, specifically when viewing it as a PivotChart? I'm currently attempting this in MS Access 2003, but would like to see a solution for any version.</p>
| [
{
"answer_id": 79635,
"author": "ahockley",
"author_id": 8209,
"author_profile": "https://Stackoverflow.com/users/8209",
"pm_score": 3,
"selected": true,
"text": "Function SetLandscape()\n Application.Printer.Orientation = acPRORLandscape\nEnd Function\n"
},
{
"answer_id": 7974... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3155/"
] |
78,799 | <p>What I'm talking about here are nested classes. Essentially, I have two classes that I'm modeling. A DownloadManager class and a DownloadThread class. The obvious OOP concept here is composition. However, composition doesn't necessarily mean nesting, right?</p>
<p>I have code that looks something like this:</p>
<pre><code>class DownloadThread:
def foo(self):
pass
class DownloadManager():
def __init__(self):
dwld_threads = []
def create_new_thread():
dwld_threads.append(DownloadThread())
</code></pre>
<p>But now I'm wondering if there's a situation where nesting would be better. Something like:</p>
<pre><code>class DownloadManager():
class DownloadThread:
def foo(self):
pass
def __init__(self):
dwld_threads = []
def create_new_thread():
dwld_threads.append(DownloadManager.DownloadThread())
</code></pre>
| [
{
"answer_id": 78858,
"author": "dF.",
"author_id": 3002,
"author_profile": "https://Stackoverflow.com/users/3002",
"pm_score": 8,
"selected": true,
"text": "class Foo(object):\n class __metaclass__(type):\n .... \n"
},
{
"answer_id": 78968,
"author": "tim.tadh",
... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78799",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10708/"
] |
78,801 | <p>Running a rails site right now using SQLite3.</p>
<p>About once every 500 requests or so, I get a</p>
<p>ActiveRecord::StatementInvalid (SQLite3::BusyException: database is locked:...</p>
<p>What's the way to fix this that would be minimally invasive to my code?</p>
<p>I'm using SQLLite at the moment because you can store the DB in source control which makes backing up natural and you can push changes out very quickly. However, it's obviously not really set up for concurrent access. I'll migrate over to MySQL tomorrow morning.</p>
| [
{
"answer_id": 78870,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": "https://Stackoverflow.com/users/3153",
"pm_score": 0,
"selected": false,
"text": "- Open the database\ndb = sqlite3.open(\"filename\")\n\n-- Ten attempts are made to proceed, if the database is locked... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14559/"
] |
78,826 | <p>How do you use <code>gen_udp</code> in Erlang to do <a href="https://en.wikipedia.org/wiki/Multicast" rel="nofollow noreferrer">multicasting</a>? I know its in the code, there is just no documentation behind it. Sending out data is obvious and simple. I was wondering on how to add memberships. Not only adding memberships at start-up, but adding memberships while running would be useful too.</p>
| [
{
"answer_id": 81149,
"author": "Bwooce",
"author_id": 15290,
"author_profile": "https://Stackoverflow.com/users/15290",
"pm_score": 4,
"selected": false,
"text": " {ok, Socket} = gen_udp:open(Port, [binary, {active, false},\n {reuseaddr, true},{i... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10432/"
] |
78,849 | <p>I have an image (mx) and i want to get the uint of the pixel that was clicked.</p>
<p>Any ideas?</p>
| [
{
"answer_id": 79221,
"author": "enobrev",
"author_id": 14651,
"author_profile": "https://Stackoverflow.com/users/14651",
"pm_score": 3,
"selected": false,
"text": "package {\n import flash.display.Bitmap;\n import flash.display.BitmapData;\n import flash.display.Loader;\n im... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1748529/"
] |
78,852 | <p>Mapping a collection of enums with NHibernate</p>
<p>Specifically, using Attributes for the mappings.</p>
<p>Currently I have this working mapping the collection as type Int32 and NH seems to take care of it, but it's not exactly ideal.</p>
<p>The error I receive is "Unable to determine type" when trying to map the collection as of the type of the enum I am trying to map.</p>
<p>I found a post that said to define a class as</p>
<pre><code>public class CEnumType : EnumStringType {
public CEnumType() : base(MyEnum) { }
}
</code></pre>
<p>and then map the enum as CEnumType, but this gives "CEnumType is not mapped" or something similar.</p>
<p>So has anyone got experience doing this?</p>
<p>So anyway, just a simple reference code snippet to give an example with</p>
<pre><code> [NHibernate.Mapping.Attributes.Class(Table = "OurClass")]
public class CClass : CBaseObject
{
public enum EAction
{
do_action,
do_other_action
};
private IList<EAction> m_class_actions = new List<EAction>();
[NHibernate.Mapping.Attributes.Bag(0, Table = "ClassActions", Cascade="all", Fetch = CollectionFetchMode.Select, Lazy = false)]
[NHibernate.Mapping.Attributes.Key(1, Column = "Class_ID")]
[NHibernate.Mapping.Attributes.Element(2, Column = "EAction", Type = "Int32")]
public virtual IList<EAction> Actions
{
get { return m_class_actions; }
set { m_class_actions = value;}
}
}
</code></pre>
<p>So, anyone got the correct attributes for me to map this collection of enums as actual enums? It would be really nice if they were stored in the db as strings instead of ints too but it's not completely necessary.</p>
| [
{
"answer_id": 80485,
"author": "alvin",
"author_id": 15121,
"author_profile": "https://Stackoverflow.com/users/15121",
"pm_score": 1,
"selected": false,
"text": " public virtual ContractGroups Group\n {\n get\n {\n if (GroupString.IsNullOrEmpty())\n ... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/924607/"
] |
78,869 | <p>I'm looking around for a Java <a href="http://en.wikipedia.org/wiki/Code_signing" rel="noreferrer">code signing</a> certificate so my Java applets don't throw up such scary security warnings. However, all the places I've found offering them charge (in my opinion) way too much, like over USD200 per year. While doing research, a code signing certificate seems almost exactly the same as an <a href="http://en.wikipedia.org/wiki/SSL" rel="noreferrer">SSL</a> certificate.</p>
<p>The main question I have: is it possible to buy an SSL certificate, but use it to sign Java applets?</p>
| [
{
"answer_id": 27676751,
"author": "flup",
"author_id": 1973271,
"author_profile": "https://Stackoverflow.com/users/1973271",
"pm_score": 1,
"selected": false,
"text": "/**\n * Check whether this certificate can be used for code signing.\n * @throws CertificateException if not.\n */\npri... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78869",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14569/"
] |
78,884 | <p>I have an xslt sheet with some text similar to below:</p>
<pre><code><xsl:text>I am some text, and I want to be bold</xsl:text>
</code></pre>
<p>I would like some text to be bold, but this doesn't work.</p>
<pre><code><xsl:text>I am some text, and I want to be <strong>bold<strong></xsl:text>
</code></pre>
<p>The deprecated b tag doesn't work either. How do I format text within an xsl:text tag?</p>
| [
{
"answer_id": 78904,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 3,
"selected": false,
"text": "<fo:inline font-weight=\"bold\"><xsl:text>Bold text</xsl:text></fo:inline>\n"
},
{
"answer_id": 80522,
"author": "jel... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5989/"
] |
78,905 | <p>More specifically I am trying to make the mailto component show within my template; the same way as an article does. </p>
<p>By default the mailto component opens in a new window. So far I changed the code so it opens on the same window, but that way the whole template is gone.</p>
<p>Any suggestions?</p>
| [
{
"answer_id": 279605,
"author": "Bingy",
"author_id": 69518,
"author_profile": "https://Stackoverflow.com/users/69518",
"pm_score": 2,
"selected": false,
"text": "<jdoc:include type=\"component\" />\n"
}
] | 2008/09/17 | [
"https://Stackoverflow.com/questions/78905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/131/"
] |
78,909 | <p>I have a few scripts on a site I recently started maintaining. I get those Object Not Found errors in IE6 (which Firefox fails to report in its Error Console?). What's the best way to debug these- any good cross-browser-compatible IDEs, or javascript debugging libraries of some sort?</p>
| [
{
"answer_id": 78930,
"author": "dimarzionist",
"author_id": 10778,
"author_profile": "https://Stackoverflow.com/users/10778",
"pm_score": 1,
"selected": false,
"text": "debugger;\n"
}
] | 2008/09/17 | [
"https://Stackoverflow.com/questions/78909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14563/"
] |
78,913 | <p>What is the single most effective practice to prevent <a href="http://en.wikipedia.org/wiki/Arithmetic_overflow" rel="nofollow noreferrer">arithmetic overflow</a> and <a href="http://en.wikipedia.org/wiki/Arithmetic_underflow" rel="nofollow noreferrer">underflow</a>?</p>
<p>Some examples that come to mind are:</p>
<ul>
<li>testing based on valid input ranges</li>
<li>validation using formal methods</li>
<li>use of invariants</li>
<li>detection at runtime using language features or libraries (this does not prevent it)</li>
</ul>
| [
{
"answer_id": 78936,
"author": "Eclipse",
"author_id": 8701,
"author_profile": "https://Stackoverflow.com/users/8701",
"pm_score": 3,
"selected": true,
"text": "class CheckedInt\n{\nprivate: \n int Value;\n\npublic:\n // Constructor\n CheckedInt(int src) : Value(src) {}\n\n ... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3836/"
] |
78,924 | <p>I have written a message handler function in Outlook's Visual Basic (we're using Outlook 2003 and Exchange Server) to help me sort out incoming email. </p>
<p>It is working for me, except sometimes the rule fails and Outlook deactivates it. </p>
<p>Then I turn the rule back on and manually run it on my Inbox to catch up. The rule spontaneously fails and deactivates several times a day. </p>
<p>I would love to fix this once and for all.</p>
| [
{
"answer_id": 79000,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": " Public WithEvents myOlItems As Outlook.Items\n\n Public Sub Application_Startup()\n ' Reference the items in the Inb... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
78,932 | <p>I have the following HTML <code><select></code> element:</p>
<pre><code><select id="leaveCode" name="leaveCode">
<option value="10">Annual Leave</option>
<option value="11">Medical Leave</option>
<option value="14">Long Service</option>
<option value="17">Leave Without Pay</option>
</select>
</code></pre>
<p>Using a JavaScript function with the <code>leaveCode</code> number as a parameter, how do I select the appropriate option in the list?</p>
| [
{
"answer_id": 78945,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 11,
"selected": true,
"text": "function selectElement(id, valueToSelect) { \n let element = document.getElementById(id);\n element.value ... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6340/"
] |
78,974 | <p>I've written a control that inherits from the <code>System.Web.UI.WebControls.DropDownList</code> and so I don't have any code in front for this control, but I still want to set the OutputCache directive. I there any way to set this in the C# code, say with an attribute or something like that? </p>
<p>I'm particularly hoping to be able to replicate the <code>VaryByParam</code> property</p>
| [
{
"answer_id": 79012,
"author": "dimarzionist",
"author_id": 10778,
"author_profile": "https://Stackoverflow.com/users/10778",
"pm_score": 1,
"selected": false,
"text": "Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));\nResponse.Cache.SetCacheability(HttpCacheability.Server);\nRes... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2975/"
] |
78,978 | <p>I'm working on a regular expression in a <code>.NET</code> project to get a specific tag. I would like to match the entire DIV tag and its contents:</p>
<pre><code><html>
<head><title>Test</title></head>
<body>
<p>The first paragraph.</p>
<div id='super_special'>
<p>The Store paragraph</p>
</div>
</body>
</head>
</code></pre>
<p>Code:</p>
<pre><code> Regex re = new Regex("(<div id='super_special'>.*?</div>)", RegexOptions.Multiline);
if (re.IsMatch(test))
Console.WriteLine("it matches");
else
Console.WriteLine("no match");
</code></pre>
<p>I want to match this:</p>
<pre><code><div id="super_special">
<p>Anything could go in here...doesn't matter. Let's get it all</p>
</div>
</code></pre>
<p>I thought <code>.</code> was supposed to get all characters, but it seems to having trouble with the carriage returns. What is my regex missing?</p>
<p>Thanks.</p>
| [
{
"answer_id": 78985,
"author": "mopoke",
"author_id": 14054,
"author_profile": "https://Stackoverflow.com/users/14054",
"pm_score": 1,
"selected": false,
"text": "m{<div id=\"super_special\">.*?</span>}s\n"
},
{
"answer_id": 78995,
"author": "Vinko Vrsalovic",
"author_id... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27870/"
] |
79,041 | <p>I have a web system which has a classical parent-children menu saved in a database, with fields id as the PK, and parent_id to pointing to the owning menu. (Yes, I know this doesn't scale very well, but that's another topic). </p>
<p>So for these records (id-parent_id pairs):</p>
<pre><code>0-7 0-4 4-9 4-14 4-16 9-6
</code></pre>
<p>I have this tree:</p>
<pre><code>0
├ 7
└ 4
├ 9
| └ 6
├ 14
└ 16
</code></pre>
<p>I'm needing to hide a top node, so I have to make a list of all the childrens of that certain node, i.e. for 4, they will be (9, 6, 14, 16). Order doesn't matters.</p>
<p>I'm confused... does this fits into the classical tree problems? or is it a graph one?</p>
<p>How can I compose this structure and solve this problem using php?</p>
| [
{
"answer_id": 79067,
"author": "Blorgbeard",
"author_id": 369,
"author_profile": "https://Stackoverflow.com/users/369",
"pm_score": 2,
"selected": true,
"text": "nodeList = {}\nenumerateNodes(rootNode, nodeList);\n\nfunction enumerateNodes(node, nodeList) {\n nodeList += node;\n for... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/861/"
] |
79,054 | <p>Why does Leopard mangle some symbols with $non_lazy_ptr? More importantly what is the best method to fix undefined symbol errors because a symbol has been mangled with $non_lazy_ptr?</p>
| [
{
"answer_id": 3062322,
"author": "Ciryon",
"author_id": 22012,
"author_profile": "https://Stackoverflow.com/users/22012",
"pm_score": 1,
"selected": false,
"text": "extern NSString* const someString;"
},
{
"answer_id": 3462790,
"author": "Tom S.",
"author_id": 393049,
... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79054",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
79,111 | <p>Kind of a special case problem:</p>
<ul>
<li>I start a process with <code>System.Diagnostics.Process.Start(..)</code></li>
<li>The process opens a splash screen -- this splash screen becomes the main window.</li>
<li>The splash screen closes and the 'real' UI is shown. The main window (splash screen) is now invalid.</li>
<li>I still have the Process object, and I can query its handle, module, etc. But the main window handle is now invalid.</li>
</ul>
<p>I need to get the process's UI (or UI handle) at this point. Assume I cannot change the behavior of the process to make this any easier (or saner).</p>
<p>I have looked around online but I'll admit I didn't look for more than an hour. Seemed like it should be somewhat trivial :-(</p>
| [
{
"answer_id": 79201,
"author": "Ash",
"author_id": 5023,
"author_profile": "https://Stackoverflow.com/users/5023",
"pm_score": 3,
"selected": false,
"text": "FindWindow"
},
{
"answer_id": 79205,
"author": "MB.",
"author_id": 11961,
"author_profile": "https://Stackove... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14656/"
] |
79,121 | <p>So, im trying to write some code that utilizes Nvidia's CUDA architecture. I noticed that copying to and from the device was really hurting my overall performance, so now I am trying to move a large amount of data onto the device.</p>
<p>As this data is used in numerous functions, I would like it to be global. Yes, I can pass pointers around, but I would really like to know how to work with globals in this instance. </p>
<p>So, I have device functions that want to access a device allocated array.</p>
<p>Ideally, I could do something like:</p>
<pre><code>__device__ float* global_data;
main()
{
cudaMalloc(global_data);
kernel1<<<blah>>>(blah); //access global data
kernel2<<<blah>>>(blah); //access global data again
}
</code></pre>
<p>However, I havent figured out how to create a dynamic array. I figured out a work around by declaring the array as follows:</p>
<pre><code>__device__ float global_data[REALLY_LARGE_NUMBER];
</code></pre>
<p>And while that doesn't require a cudaMalloc call, I would prefer the dynamic allocation approach.</p>
| [
{
"answer_id": 79256,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "float* devPtr;\ncudaMalloc((void**)&devPtr, 256 * sizeof(*devPtr));\ncudaMemset(devPtr, 0, 256 * sizeof(*devPtr));\n"
},
{
... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79121",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14621/"
] |
79,126 | <p>I'm building a function to extend the <code>Enum.Parse</code> concept that</p>
<ul>
<li>Allows a default value to be parsed in case that an Enum value is not found</li>
<li>Is case insensitive</li>
</ul>
<p>So I wrote the following:</p>
<pre><code>public static T GetEnumFromString<T>(string value, T defaultValue) where T : Enum
{
if (string.IsNullOrEmpty(value)) return defaultValue;
foreach (T item in Enum.GetValues(typeof(T)))
{
if (item.ToString().ToLower().Equals(value.Trim().ToLower())) return item;
}
return defaultValue;
}
</code></pre>
<p>I am getting a Error Constraint cannot be special class <code>System.Enum</code>.</p>
<p>Fair enough, but is there a workaround to allow a Generic Enum, or am I going to have to mimic the <code>Parse</code> function and pass a type as an attribute, which forces the ugly boxing requirement to your code.</p>
<p><strong>EDIT</strong> All suggestions below have been greatly appreciated, thanks.</p>
<p>Have settled on (I've left the loop to maintain case insensitivity - I am using this when parsing XML)</p>
<pre><code>public static class EnumUtils
{
public static T ParseEnum<T>(string value, T defaultValue) where T : struct, IConvertible
{
if (!typeof(T).IsEnum) throw new ArgumentException("T must be an enumerated type");
if (string.IsNullOrEmpty(value)) return defaultValue;
foreach (T item in Enum.GetValues(typeof(T)))
{
if (item.ToString().ToLower().Equals(value.Trim().ToLower())) return item;
}
return defaultValue;
}
}
</code></pre>
<p><strong>EDIT:</strong> (16th Feb 2015) Christopher Currens has posted <a href="https://stackoverflow.com/a/8086788">a compiler enforced type-safe generic solution in MSIL or F#</a> below, which is well worth a look, and an upvote. I will remove this edit if the solution bubbles further up the page.</p>
<p><strong>EDIT 2:</strong> (13th Apr 2021) As this has now been addressed, and supported, since C# 7.3, I have changed the accepted answer, though full perusal of the top answers is worth it for academic, and historical, interest :)</p>
| [
{
"answer_id": 79148,
"author": "dimarzionist",
"author_id": 10778,
"author_profile": "https://Stackoverflow.com/users/10778",
"pm_score": 3,
"selected": false,
"text": "public static TValue ParseEnum<TValue>(string value, TValue defaultValue)\n where TValue : struct // ... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5302/"
] |
79,129 | <p>For the life of me, I cannot get the SqlProfileProvider to work in an MVC project that I'm working on.</p>
<p>The first interesting thing that I realized is that Visual Studio does not automatically generate the ProfileCommon proxy class for you. That's not a big deal since it's simpy a matter of extending the ProfileBase class. After creating a ProfileCommon class, I wrote the following Action method for creating the user profile.</p>
<pre><code>[AcceptVerbs("POST")]
public ActionResult CreateProfile(string company, string phone, string fax, string city, string state, string zip)
{
MembershipUser user = Membership.GetUser();
ProfileCommon profile = ProfileCommon.Create(user.UserName, user.IsApproved) as ProfileCommon;
profile.Company = company;
profile.Phone = phone;
profile.Fax = fax;
profile.City = city;
profile.State = state;
profile.Zip = zip;
profile.Save();
return RedirectToAction("Index", "Account");
}</code></pre>
<p>The problem that I'm having is that the call to ProfileCommon.Create() cannot cast to type ProfileCommon, so I'm not able to get back my profile object, which obviously causes the next line to fail since profile is null.</p>
<p>Following is a snippet of my web.config:</p>
<p><pre><code><profile defaultProvider="AspNetSqlProfileProvider" automaticSaveEnabled="false" enabled="true">
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ApplicationServices" applicationName="/" />
</providers>
<properties>
<add name="FirstName" type="string" />
<add name="LastName" type="string" />
<add name="Company" type="string" />
<add name="Phone" type="string" />
<add name="Fax" type="string" />
<add name="City" type="string" />
<add name="State" type="string" />
<add name="Zip" type="string" />
<add name="Email" type="string" >
</properties>
</profile></pre></code></p>
<p>The MembershipProvider is working without a hitch, so I know that the connection string is good.</p>
<p>Just in case it's helpful, here is my ProfileCommon class:</p>
<pre><code>public class ProfileCommon : ProfileBase
{
public virtual string Company
{
get
{
return ((string)(this.GetPropertyValue("Company")));
}
set
{
this.SetPropertyValue("Company", value);
}
}
public virtual string Phone
{
get
{
return ((string)(this.GetPropertyValue("Phone")));
}
set
{
this.SetPropertyValue("Phone", value);
}
}
public virtual string Fax
{
get
{
return ((string)(this.GetPropertyValue("Fax")));
}
set
{
this.SetPropertyValue("Fax", value);
}
}
public virtual string City
{
get
{
return ((string)(this.GetPropertyValue("City")));
}
set
{
this.SetPropertyValue("City", value);
}
}
public virtual string State
{
get
{
return ((string)(this.GetPropertyValue("State")));
}
set
{
this.SetPropertyValue("State", value);
}
}
public virtual string Zip
{
get
{
return ((string)(this.GetPropertyValue("Zip")));
}
set
{
this.SetPropertyValue("Zip", value);
}
}
public virtual ProfileCommon GetProfile(string username)
{
return ((ProfileCommon)(ProfileBase.Create(username)));
}
}</code></pre>
<p>Any thoughts on what I might be doing wrong? Have any of the rest of you successfully integrated a ProfileProvider with your ASP.NET MVC projects?</p>
<p>Thank you in advance...</p>
| [
{
"answer_id": 80594,
"author": "Mladen Mihajlovic",
"author_id": 11421,
"author_profile": "https://Stackoverflow.com/users/11421",
"pm_score": 3,
"selected": false,
"text": "ProfileCommon profile = (ProfileCommon)ProfileCommon.Create(user.UserName, user.IsApproved) as ProfileCommon;\n"
... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79129",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10792/"
] |
79,133 | <p>In other words:</p>
<ol>
<li>Log on as Bert (who is an administrator)</li>
<li>Using fast user switching, log on as Ernie (Bert remains logged on)</li>
<li>Switch back to Bert</li>
<li>Bert logs Ernie off</li>
</ol>
<p>What is the best way to achieve step 4?</p>
| [
{
"answer_id": 42917620,
"author": "Babak",
"author_id": 4676,
"author_profile": "https://Stackoverflow.com/users/4676",
"pm_score": 3,
"selected": true,
"text": "sudo launchctl bootout user/$(id -u <username>)"
}
] | 2008/09/17 | [
"https://Stackoverflow.com/questions/79133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4676/"
] |
79,165 | <p>I read the Git manual, FAQ, Git - SVN crash course, etc. and they all explain this and that, but nowhere can you find a simple instruction like:</p>
<p>SVN repository in: <code>svn://myserver/path/to/svn/repos</code></p>
<p>Git repository in: <code>git://myserver/path/to/git/repos</code></p>
<pre><code>git-do-the-magic-svn-import-with-history \
svn://myserver/path/to/svn/repos \
git://myserver/path/to/git/repos
</code></pre>
<p>I don't expect it to be that simple, and I don't expect it to be a single command. But I do expect it not to try to explain anything - just to say what steps to take given this example.</p>
| [
{
"answer_id": 79178,
"author": "jfm3",
"author_id": 11138,
"author_profile": "https://Stackoverflow.com/users/11138",
"pm_score": 10,
"selected": true,
"text": "$ git svn clone http://svn/repo/here/trunk\n"
},
{
"answer_id": 79188,
"author": "Eugene Yokota",
"author_id":... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79165",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14690/"
] |
79,197 | <p>What's a simple way to combine <strong>feed</strong> and <strong>feed2</strong>? I want the items from <strong>feed2</strong> to be added to <strong>feed</strong>. Also I want to avoid duplicates as <strong>feed</strong> might already have items when a question is tagged with both WPF and Silverlight.</p>
<pre><code>Uri feedUri = new Uri("http://stackoverflow.com/feeds/tag/silverlight");
XmlReader reader = XmlReader.Create(feedUri.AbsoluteUri);
SyndicationFeed feed = SyndicationFeed.Load(reader);
Uri feed2Uri = new Uri("http://stackoverflow.com/feeds/tag/wpf");
XmlReader reader2 = XmlReader.Create(feed2Uri.AbsoluteUri);
SyndicationFeed feed2 = SyndicationFeed.Load(reader2);
</code></pre>
| [
{
"answer_id": 79376,
"author": "Frater",
"author_id": 14746,
"author_profile": "https://Stackoverflow.com/users/14746",
"pm_score": 1,
"selected": false,
"text": "SyndicationFeed newFeed = feed.clone;\nforeach(SyndicationItem item in feed2.items)\n{\n if (!newFeed.contains(item))\n ... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1133/"
] |
79,215 | <p>For example, if I have a page located in Views/Home/Index.aspx and a JavaScript file located in Views/Home/Index.js, how do you reference this on the aspx page?</p>
<p>The example below doesn't work even though the compiler says the path is correct</p>
<pre><code><script src="Index.js" type="text/javascript"></script>
</code></pre>
<p>The exact same issue has been posted here in more detail:
<a href="http://forums.asp.net/p/1319380/2619991.aspx" rel="nofollow noreferrer">http://forums.asp.net/p/1319380/2619991.aspx</a></p>
<p>If this is not currently possible, will it be in the future? If not, how is everyone managing their javascript resources for large Asp.net MVC projects? Do you just create a folder structure in the Content folder that mirrors your View folder structure? YUCK!</p>
| [
{
"answer_id": 79246,
"author": "Chris Pietschmann",
"author_id": 7831,
"author_profile": "https://Stackoverflow.com/users/7831",
"pm_score": 2,
"selected": false,
"text": "<script type=\"text/javascript\" src=\"<%=VirtualPathUtility.ToAbsolute(\"~/Views/Home/Index.js\") %>\"></script>\n... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10941/"
] |
79,229 | <p>In your experience, how often should Oracle database statistics be run? Our team of developers recently discovered that statistics hadn't been run our production box in over 2 1/2 months. That sounds like a long time to me, but I'm not a DBA.</p>
| [
{
"answer_id": 16741489,
"author": "grokster",
"author_id": 502441,
"author_profile": "https://Stackoverflow.com/users/502441",
"pm_score": 4,
"selected": false,
"text": "SELECT owner, table_name, last_analyzed FROM all_tables ORDER BY last_analyzed DESC NULLS LAST; --Tables.\nSELECT own... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79229",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
79,241 | <p>When working with tables in Oracle, how do you know when you are setting up a good index versus a bad index?</p>
| [
{
"answer_id": 166669,
"author": "WW.",
"author_id": 14663,
"author_profile": "https://Stackoverflow.com/users/14663",
"pm_score": 0,
"selected": false,
"text": "WHERE CompanyCode = ? AND Amount BETWEEN 100 AND 200\n"
}
] | 2008/09/17 | [
"https://Stackoverflow.com/questions/79241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
79,244 | <p>How to make sure that all derived C++/CLI classes will override the ICloneable::Clone() method of the base class?</p>
<p>Do you think I should worry about this? Or this is not a responsibility of the base class' writer?</p>
<p><strong>Amendment:</strong> Sorry, I forgot to mention that the base class is a non-abstract class.</p>
| [
{
"answer_id": 79327,
"author": "Philip Rieck",
"author_id": 12643,
"author_profile": "https://Stackoverflow.com/users/12643",
"pm_score": 2,
"selected": false,
"text": "public ref class ClonableBase abstract\n{\n public:\n virtual void Clone() = 0;\n}\n"
},
{
"answer_id": 7943... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79244",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14385/"
] |
79,258 | <p>Is there a tool that will find for me all the css classes that I am referencing in my HTML that don't actually exist?</p>
<p>ie. if I have <ul class="topnav" /> in my HTML and the topnav class doesn't exist in any of the referenced CSS files.</p>
<p>This is similar to <a href="https://stackoverflow.com/questions/33242/how-can-i-find-unused-images-and-css-styles-in-a-website">SO#33242</a>, which asks how to find unused CSS styles. This isn't a duplicate, as that question asks which CSS classes are not used. This is the opposite problem.</p>
| [
{
"answer_id": 79433,
"author": "mislav",
"author_id": 11687,
"author_profile": "https://Stackoverflow.com/users/11687",
"pm_score": 3,
"selected": true,
"text": "function forItems(a, f) {\n for (var i = 0; i < a.length; i++) f(a.item(i))\n}\n\nfunction classExists(className) {\n var p... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4640/"
] |
79,264 | <p>Is there a program or API I can code against to extract individual files from a Windows Vista Complete PC Backup image?</p>
<p>I like the idea of having a complete image to restore from, but hate the idea that I have to make two backups, one for restoring individual files, and one for restoring my computer in the event of a catastrophic failure.</p>
| [
{
"answer_id": 79433,
"author": "mislav",
"author_id": 11687,
"author_profile": "https://Stackoverflow.com/users/11687",
"pm_score": 3,
"selected": true,
"text": "function forItems(a, f) {\n for (var i = 0; i < a.length; i++) f(a.item(i))\n}\n\nfunction classExists(className) {\n var p... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2581/"
] |
79,266 | <p>When attempting to understand how a SQL statement is executing, it is sometimes recommended to look at the explain plan. What is the process one should go through in interpreting (making sense) of an explain plan? What should stand out as, "Oh, this is working splendidly?" versus "Oh no, that's not right."</p>
| [
{
"answer_id": 79300,
"author": "convex hull",
"author_id": 10747,
"author_profile": "https://Stackoverflow.com/users/10747",
"pm_score": 2,
"selected": false,
"text": "Seq Scan on my_table (cost=0.00..15558.92 rows=620092 width=78)\n"
},
{
"answer_id": 79326,
"author": "dpo... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
79,275 | <p>I have a form like this:</p>
<pre><code><form name="mine">
<input type=text name=one>
<input type=text name=two>
<input type=text name=three>
</form>
</code></pre>
<p>When user types a value in 'one', I sometimes want to skip the field 'two', depending on what he typed. For example, if user types '123' and uses Tab to move to next field, I want to skip it and go to field three.</p>
<p>I tried to use <code>OnBlur</code> and <code>OnEnter</code>, without success. </p>
<p><strong>Try 1:</strong></p>
<pre><code><form name="mine">
<input type=text name=one onBlur="if (document.mine.one.value='123') document.three.focus();>
<input type=text name=two>
<input type=text name=three>
</form>
</code></pre>
<p><strong>Try 2:</strong></p>
<pre><code><form name="mine">
<input type=text name=one>
<input type=text name=two onEnter="if (document.mine.one.value='123') document.three.focus();>
<input type=text name=three>
</form>
</code></pre>
<p>but none of these works. Looks like the browser doesn't allow you to mess with focus while the focus is changing. </p>
<p>BTW, all this tried with Firefox on Linux.</p>
| [
{
"answer_id": 79317,
"author": "dimarzionist",
"author_id": 10778,
"author_profile": "https://Stackoverflow.com/users/10778",
"pm_score": 3,
"selected": true,
"text": "<INPUT tabindex=\"3\" type=\"submit\" name=\"mySubmit\">\n"
},
{
"answer_id": 79345,
"author": "John Boker"... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79275",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14690/"
] |
79,292 | <p>Can databases (MySQL in particular, any SQL--MS, Oracle, Postgres--in general) do mass updates, and figure out on their own what the new value should be? Say for example I've got a database with information about a bunch of computers, and all of these computers have drives of various sizes--anywhere from 20 to 250 GB. Then one day we upgrade every single computer by adding a 120 GB hard drive. Is there a way to say something like</p>
<pre><code>update computers set total_disk_space = (whatever that row's current total_disk_space is plus 120)
</code></pre>
| [
{
"answer_id": 79305,
"author": "Tom Leys",
"author_id": 11440,
"author_profile": "https://Stackoverflow.com/users/11440",
"pm_score": 2,
"selected": false,
"text": "update computers set total_disk_space = total_disk_space + 120;\n"
},
{
"answer_id": 79313,
"author": "Stephen... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14701/"
] |
79,322 | <p>The documentation with the module itself is pretty thin, and just tends to point to MOP.</p>
| [
{
"answer_id": 79569,
"author": "Dave Rolsky",
"author_id": 9832,
"author_profile": "https://Stackoverflow.com/users/9832",
"pm_score": 6,
"selected": true,
"text": "Moose::Meta"
}
] | 2008/09/17 | [
"https://Stackoverflow.com/questions/79322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11289/"
] |
79,352 | <p>I have a method that can return either a single object or a collection of objects. I want to be able to run object.collect on the result of that method whether or not it is a single object or a collection already. How can i do this?</p>
<pre><code>profiles = ProfileResource.search(params)
output = profiles.collect do | profile |
profile.to_hash
end
</code></pre>
<p>If profiles is a single object, I get a NoMethodError exception when I try to execute collect on that object.</p>
| [
{
"answer_id": 79416,
"author": "Matt Haley",
"author_id": 14142,
"author_profile": "https://Stackoverflow.com/users/14142",
"pm_score": 1,
"selected": false,
"text": "profiles = [ProfileResource.search(params)].flatten\noutput = profiles.collect do |profile|\n profile.to_hash\nend\n"... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1486/"
] |
79,360 | <p>I've drawn an ellipse in the XZ plane, and set my perspective slightly up on the Y-axis and back on the Z, looking at the center of ellipse from a 45-degree angle, using gluPerspective() to set my viewing frustrum.</p>
<p><a href="http://www.flickr.com/photos/rampion/2863703051/" rel="nofollow noreferrer" title="ellipse by rampion, on Flickr"><img src="https://farm4.static.flickr.com/3153/2863703051_a768ed86a9_m.jpg" width="240" height="187" alt="ellipse" /></a></p>
<p>Unrotated, the major axis of the ellipse spans the width of my viewport. When I rotate 90-degrees about my line-of-sight, the major axis of the ellipse now spans the height of my viewport, thus deforming the ellipse (in this case, making it appear less eccentric).</p>
<p><a href="http://www.flickr.com/photos/rampion/2863703073/" rel="nofollow noreferrer" title="rotated ellipse by rampion, on Flickr"><img src="https://farm4.static.flickr.com/3187/2863703073_24c6549d4b_m.jpg" width="240" height="187" alt="rotated ellipse" /></a></p>
<p>What do I need to do to prevent this deformation (or at least account for it), so rotation about the line-of-sight preserves the perceived major axis of the ellipse (in this case, causing it to go beyond the viewport)?</p>
| [
{
"answer_id": 79459,
"author": "Martin",
"author_id": 2581,
"author_profile": "https://Stackoverflow.com/users/2581",
"pm_score": 2,
"selected": false,
"text": "void gluPerspective( GLdouble fovy,\n GLdouble aspect,\n GLdouble zNear,\n ... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79360",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9859/"
] |
79,367 | <p>I have a query:</p>
<pre><code>SELECT *
FROM Items
WHERE column LIKE '%foo%'
OR column LIKE '%bar%'
</code></pre>
<p>How do I order the results?</p>
<p>Let's say I have rows that match 'foo' and rows that match 'bar' but I also have a row with 'foobar'.</p>
<p>How do I order the returned rows so that the first results are the ones that matched more LIKEs? </p>
| [
{
"answer_id": 79393,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 2,
"selected": false,
"text": "select *, case when col like '%foo%' and col like '%bar%' then 2 end \nelse 1 end as ordcol \nfrom items \nwhere col ... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79367",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
79,381 | <p>I am wanting to access a website from a different port than 80 or 8080. Is this possible? I just want to view the website but through a different port. I do not have a router. I know this can be done because I have a browser that accessing websites through different ports, Called XB Browser by Xero Bank.</p>
<hr>
<p>Thanks for the answers. So, if I setup a proxy on one computer, I could have it go from my computer, to another computer that then returns the website to me. Would this bypass logging software?</p>
| [
{
"answer_id": 79464,
"author": "etchasketch",
"author_id": 14640,
"author_profile": "https://Stackoverflow.com/users/14640",
"pm_score": 3,
"selected": false,
"text": "ssh -L 22222:<target_website>:80 <home_computer>\n"
}
] | 2008/09/17 | [
"https://Stackoverflow.com/questions/79381",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14769/"
] |
79,445 | <p>I'd like to write a simple C# application to monitor the line-in audio and give me the current (well, the rolling average) beats per minute.</p>
<p>I've seen <a href="http://www.gamedev.net/page/resources/_/technical/math-and-physics/beat-detection-algorithms-r1952" rel="noreferrer">this gamedev article</a>, and that was absolutely no help. I went through and tried to implement what he was doing but it just wasn't working.</p>
<p>I know there have to be tons of solutions for this, because lots of DJ software does it, but I'm not having any luck in finding any open-source library or instructions on doing it myself.</p>
| [
{
"answer_id": 81666,
"author": "Hallgrim",
"author_id": 15454,
"author_profile": "https://Stackoverflow.com/users/15454",
"pm_score": 5,
"selected": false,
"text": "double[] signal = stream.Take(1024);\n"
}
] | 2008/09/17 | [
"https://Stackoverflow.com/questions/79445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14758/"
] |
79,455 | <p>Given this example:</p>
<pre><code><img class="a" />
<img />
<img class="a" />
<img class="a" id="active" />
<img class="a" />
<img class="a" />
<img />
<img class="a" />
</code></pre>
<p><em>(I've just used img tags as an example, that's not what it is in my code)</em></p>
<p>Using jQuery, how would you select the img tags with class "a" that are adjacent to #active (the middle four, in this example)?</p>
<p>You could do it fairly easily by looping over all the following and preceding elements, stopping when the filter condition fails, but I was wondering if jQuery could it natively?</p>
| [
{
"answer_id": 79767,
"author": "Prestaul",
"author_id": 5628,
"author_profile": "https://Stackoverflow.com/users/5628",
"pm_score": 0,
"selected": false,
"text": "$('#active ~ img.a').hide();\n"
},
{
"answer_id": 79861,
"author": "nickf",
"author_id": 9021,
"author_p... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] |
79,461 | <p>I have a <code>div</code> with two images and an <code>h1</code>. All of them need to be vertically aligned within the div, next to each other. One of the images needs to be <code>absolute</code> positioned within the <code>div</code>.</p>
<p>What is the CSS needed for this to work on all common browsers?</p>
<pre class="lang-html prettyprint-override"><code><div id="header">
<img src=".." ></img>
<h1>testing...</h1>
<img src="..."></img>
</div>
</code></pre>
| [
{
"answer_id": 79513,
"author": "dimarzionist",
"author_id": 10778,
"author_profile": "https://Stackoverflow.com/users/10778",
"pm_score": -1,
"selected": false,
"text": "<div id=\"header\" style=\"display: table-cell; vertical-align:middle;\">\n"
},
{
"answer_id": 79550,
"au... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5232/"
] |
79,466 | <p>(sorry I should have been clearer with the code the first time I posted this. Hope this makes sense)</p>
<p>File "size_specification.rb"</p>
<pre><code>class SizeSpecification
def fits?
end
end
</code></pre>
<p>File "some_module.rb"</p>
<pre><code>require 'size_specification'
module SomeModule
def self.sizes
YAML.load_file(File.dirname(__FILE__) + '/size_specification_data.yml')
end
end
</code></pre>
<p>File "size_specification_data.yml</p>
<pre><code>---
- !ruby/object:SizeSpecification
height: 250
width: 300
</code></pre>
<p>Then when I call</p>
<pre><code>SomeModule.sizes.first.fits?
</code></pre>
<p>I get an exception because "sizes" are Object's not SizeSpecification's so they don't have a "fits" function.</p>
| [
{
"answer_id": 80075,
"author": "robertpostill",
"author_id": 11219,
"author_profile": "https://Stackoverflow.com/users/11219",
"pm_score": 0,
"selected": false,
"text": "class SizeSpecification\n include SomeModule\n def fits? \n end\nend\n"
},
{
"answer_id": 94745,
"... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14796/"
] |
79,474 | <p>I've set up Passenger in development (Mac OS X) and it works flawlessly. The only problem came later: now I have a custom <code>GEM_HOME</code> path and ImageMagick binaries installed in <code>"/usr/local"</code>. I can put them in one of the shell rc files that get sourced and this solves the environment variables for processes spawned from the console; but what about Passenger? The same application cannot find my gems when run this way.</p>
| [
{
"answer_id": 79615,
"author": "Brian Phillips",
"author_id": 7230,
"author_profile": "https://Stackoverflow.com/users/7230",
"pm_score": 1,
"selected": false,
"text": "SetEnv"
},
{
"answer_id": 80003,
"author": "manveru",
"author_id": 8367,
"author_profile": "https:... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11687/"
] |
79,490 | <p>How can I get a history of uptimes for my debian box? After a reboot, I dont see an option for the uptime command to print a history of uptimes. If it matters, I would like to use these uptimes for graphing a page in php to show my webservers uptime lengths between boots.</p>
<p>Update:
Not sure if it is based on a length of time or if last gets reset on reboot but I only get the most recent boot timestamp with the last command. last -x also does not return any further info. Sounds like a script is my best bet.</p>
<p>Update:
Uptimed is the information I am looking for, not sure how to grep that info in code. Managing my own script for a db sounds like the best fit for an application.</p>
| [
{
"answer_id": 79515,
"author": "roo",
"author_id": 716,
"author_profile": "https://Stackoverflow.com/users/716",
"pm_score": 5,
"selected": false,
"text": "last"
},
{
"answer_id": 79540,
"author": "etchasketch",
"author_id": 14640,
"author_profile": "https://Stackove... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/777/"
] |
79,493 | <p>I want to use Apple's or RedHat's built-in Apache but I want to use Perl 5.10 and mod_perl. What's the least intrusive way to accomplish this? I want the advantage of free security patching for the vendor's Apache, dav, php, etc., but I care a lot about which version of Perl I use and what's in my @INC path. I don't mind compiling my own mod_perl.</p>
| [
{
"answer_id": 80032,
"author": "Gary Richardson",
"author_id": 2506,
"author_profile": "https://Stackoverflow.com/users/2506",
"pm_score": 1,
"selected": false,
"text": "/opt/"
},
{
"answer_id": 83080,
"author": "Michael Cramer",
"author_id": 1496728,
"author_profile... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14783/"
] |
79,496 | <p>I am looking for a way to connect to Facebook by allowing the user to enter in their username and password and have our app connect to their account and get their contacts so that they can invite them to join their group on our site. I have written a Facebook app before, but this is not an app as much as it is a connector so that they can invite all their friends or just some to the site we are working on.</p>
<p>I have seen several other sites do this and also connect to Yahoo, Gmail and Hotmail contacts. I don't think they are using Facebook Connect to do this since it is so new, but they may be. </p>
<p>Any solution in any language is fine as I can port whatever example to use C#. I cannot find anything specifically on Google or Facebook to address this specific problem. Any help is appreciated. </p>
<p>I saw a first answer get removed that had suggested I might need to scrape the friends page. The more I look around, this might be what I need to do. Any other way I think will require the person to add it as an app. I am wondering how a answer can get removed, maybe that user deleted it.</p>
| [
{
"answer_id": 1606882,
"author": "Jon Hadley",
"author_id": 161525,
"author_profile": "https://Stackoverflow.com/users/161525",
"pm_score": 3,
"selected": false,
"text": "def invite_friends(request): \n #HTML escape function for invitation content. \n from cgi import escape \n ... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79496",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11196/"
] |
79,498 | <p>I have determined that my JSON, coming from the server, is valid (making the ajax call manually), but I would really like to use JQuery. I have also determined that the "post" URL, being sent to the server, is correct, using firebug. However, the error callback is still being triggered (parse error). I also tried datatype: text.</p>
<p>Are there other options that I should include?</p>
<pre><code>$(function() {
$("#submit").bind("click", function() {
$.ajax({
type: "post",
url: "http://myServer/cgi-bin/broker" ,
datatype: "json",
data: {'start' : start,'end' : end},
error: function(request,error){
alert(error);
},
success: function(request) {
alert(request.length);
}
}); // End ajax
}); // End bind
}); // End eventlistener
</code></pre>
| [
{
"answer_id": 79617,
"author": "Adam Weber",
"author_id": 9324,
"author_profile": "https://Stackoverflow.com/users/9324",
"pm_score": 5,
"selected": true,
"text": "contentType: \"application/json; charset=utf-8\"\n"
},
{
"answer_id": 9664708,
"author": "Bohdan Hdal",
"au... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2755/"
] |
79,538 | <p>I just installed Ubuntu 8.04 and I'm taking a course in Java so I figured why not install a IDE while I am installing it. So I pick my IDE of choice, Eclipse, and I make a very simple program, Hello World, to make sure everything is running smoothly. When I go to use Scanner for user input I get a very odd error:</p>
<p><b>My code:</b><pre>import java.util.Scanner;</p>
<p>class test {
public static void main (String [] args) {
Scanner sc = new Scanner(System.in);
System.out.println("hi");
}
}</pre></p>
<p><b>The output:</b></p>
<pre>
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Scanner cannot be resolved to a type
Scanner cannot be resolved to a type
at test.main(test.java:5)
</pre>
| [
{
"answer_id": 473785,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "# update-alternatives --config javac"
},
{
"answer_id": 60959558,
"author": "boi yeet",
"author_id": 12864849,... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/97220/"
] |
79,602 | <p>I am writing a web application that requires user interaction via email. I'm curious if there is a best practice or recommended source for learning about processing email. I am writing my application in Python, but I'm not sure what mail server to use or how to format the message or subject line to account for automated processing. I'm also looking for guidance on processing bouncebacks. </p>
| [
{
"answer_id": 79670,
"author": "Jerub",
"author_id": 14648,
"author_profile": "https://Stackoverflow.com/users/14648",
"pm_score": 3,
"selected": true,
"text": "$ dig google.com txt\n...snip...\n;; ANSWER SECTION:\ngoogle.com. 300 IN TXT \"v=spf1 include:_netblocks.google.com ~all\... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/322887/"
] |
79,612 | <p>Looking for a <code>Linux application</code> <em>(or Firefox extension)</em> that will allow me to scrape an HTML mockup and keep the page's integrity.</p>
<p>Firefox does an almost perfect job but doesn't grab images referenced in the CSS.</p>
<p>The Scrapbook extension for Firefox gets everything, but flattens the directory structure. </p>
<p>I wouldn't terribly mind if all folders became children of the <code>index</code> page.</p>
| [
{
"answer_id": 79645,
"author": "Gilean",
"author_id": 6305,
"author_profile": "https://Stackoverflow.com/users/6305",
"pm_score": 4,
"selected": true,
"text": "wget --mirror –w 2 –p --HTML-extension –-convert-links http://www.yourdomain.com\n"
},
{
"answer_id": 79657,
"autho... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13320/"
] |
79,632 | <p>I have a two tables joined with a join table - this is just pseudo code:</p>
<pre><code>Library
Book
LibraryBooks
</code></pre>
<p>What I need to do is if i have the id of a library, i want to get all the libraries that all the books that this library has are in.</p>
<p>So if i have Library 1, and Library 1 has books A and B in them, and books A and B are in Libraries 1, 2, and 3, is there an elegant (one line) way todo this in rails?</p>
<p>I was thinking:</p>
<pre><code>l = Library.find(1)
allLibraries = l.books.libraries
</code></pre>
<p>But that doesn't seem to work. Suggestions?</p>
| [
{
"answer_id": 79646,
"author": "Jim Puls",
"author_id": 6010,
"author_profile": "https://Stackoverflow.com/users/6010",
"pm_score": 2,
"selected": false,
"text": "l.books.map {|b| b.libraries}\n"
},
{
"answer_id": 79770,
"author": "bouchard",
"author_id": 14843,
"aut... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4322/"
] |
79,669 | <p>I need to copy about 40 databases from one server to another. The new databases should have new names, but all the same tables, data and indexes as the original databases. So far I've been: </p>
<p>1) creating each destination database<br>
2) using the "<a href="http://msdn.microsoft.com/en-us/library/ms140052.aspx" rel="noreferrer">Tasks->Export Data</a>" command to create and populate tables for each database individually<br>
3) rebuilding all of the indexes for each database with a SQL script </p>
<p>Only three steps per database, but I'll bet there's an easier way. Do any MS SQL Server experts out there have any advice?</p>
| [
{
"answer_id": 79691,
"author": "Leon Bambrick",
"author_id": 49,
"author_profile": "https://Stackoverflow.com/users/49",
"pm_score": 7,
"selected": true,
"text": "(on source server...)\nBACKUP DATABASE Northwind\n TO DISK = 'c:\\Northwind.bak'\n\n(target server...)\nRESTORE FILELISTONL... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13728/"
] |
79,677 | <p>I need to speed up a program for the Nintendo DS which doesn't have an FPU, so I need to change floating-point math (which is emulated and slow) to fixed-point.</p>
<p>How I started was I changed floats to ints and whenever I needed to convert them, I used <strong>x>>8</strong> to convert the fixed-point variable x to the actual number and <strong>x<<8</strong> to convert to fixed-point. Soon I found out it was impossible to keep track of what needed to be converted and I also realized it would be difficult to change the precision of the numbers (8 in this case.)</p>
<p>My question is, how should I make this easier and still fast? Should I make a FixedPoint class, or just a FixedPoint8 typedef or struct with some functions/macros to convert them, or something else? Should I put something in the variable name to show it's fixed-point?</p>
| [
{
"answer_id": 79701,
"author": "Bart",
"author_id": 4343,
"author_profile": "https://Stackoverflow.com/users/4343",
"pm_score": 3,
"selected": false,
"text": "#define SCALE(x) (x>>8)\n#define UNSCALE(x) (x<<8)\n\nxPositionUnscaled = UNSCALE(10);\nxPositionScaled = SCALE(xPositionUnscale... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/813/"
] |
79,688 | <p>What's the best way to calculate percentile rankings (e.g. the 90th percentile or the median score) in MSSQL 2005?</p>
<p>I'd like to be able to select the 25th, median, and 75th percentiles for a single column of scores (preferably in a single record so I can combine with average, max, and min). So for example, table output of the results might be:</p>
<pre><code>Group MinScore MaxScore AvgScore pct25 median pct75
----- -------- -------- -------- ----- ------ -----
T1 52 96 74 68 76 84
T2 48 98 74 68 75 85
</code></pre>
| [
{
"answer_id": 79766,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "select @n = count(*) from tbl1\nselect @median = @n / 2\nselect @p75 = @n * 3 / 4\nselect @p90 = @n * 9 / 10\n\nselect top 1 sc... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3420/"
] |
79,693 | <p>How do you get all the classes in a namespace through reflection in C#?</p>
| [
{
"answer_id": 79706,
"author": "Ryan Farley",
"author_id": 1627,
"author_profile": "https://Stackoverflow.com/users/1627",
"pm_score": 5,
"selected": false,
"text": "using System.Reflection;\nusing System.Collections.Generic;\n//...\n\nstatic List<string> GetClasses(string nameSpace)\n{... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
79,709 | <p>I have a function inside a loop inside a function. The inner function acquires and stores a large vector of data in memory (as a global variable... I'm using "R" which is like "S-Plus"). The loop loops through a long list of data to be acquired. The outer function starts the process and passes in the list of datasets to be acquired.</p>
<pre><code>for (dataset in list_of_datasets) {
for (datachunk in dataset) {
<process datachunk>
<store result? as vector? where?>
}
}
</code></pre>
<p>I programmed the inner function to store each dataset before moving to the next, so all the work of the outer function occurs as side effects on global variables... a big no-no. Is this better or worse than collecting and returning a giant, memory-hogging vector of vectors? Is there a superior third approach?</p>
<p>Would the answer change if I were storing the data vectors in a database rather than in memory? Ideally, I'd like to be able to terminate the function (or have it fail due to network timeouts) without losing all the information processed prior to termination.</p>
| [
{
"answer_id": 79827,
"author": "leif",
"author_id": 14257,
"author_profile": "https://Stackoverflow.com/users/14257",
"pm_score": 1,
"selected": false,
"text": "help(environment)\n\n# You might do something like this:\n\nouter <- function(datasets) {\n # create the return environment\n... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
79,736 | <p>This is my first real question of need for any of those Gridview experts out there in the .NET world.</p>
<p>I an creating a Gridview from codebehind and I am holding a bunch of numerical data in the columns. Although, I do add the comma in the number fields from codebehind. When I load it to the Gridview, I have the sorting ability turned on, BUT the gridview chooses to ALPHA sort rather than sorting numerically because I add in those commas.</p>
<p>So I need help. Anyone willing to give this one a shot? I need to change some of my columns in the gridview to numerical sort rather than the alpha sort it is using.</p>
| [
{
"answer_id": 97441,
"author": "TonyOssa",
"author_id": 3276,
"author_profile": "https://Stackoverflow.com/users/3276",
"pm_score": 0,
"selected": false,
"text": "[DllImport(\"Shlwapi.dll\", CharSet = CharSet.Unicode)]\nprivate static extern int StrCmpLogicalW(string psz1, string psz2);... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79736",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7644/"
] |
79,737 | <p>This question may be too product specifc but I'd like to know if anyone is exporting bug track data from HP Quality Center.</p>
<p>HP Quality Center (QC) has an old school COM API but I'd rather use a web service or maybe even screen scraper to export the data into an excel spreadsheet.</p>
<p>In any case, what's the best way to export bug tracking data from hosted HP Quality Center?</p>
| [
{
"answer_id": 80813,
"author": "granth",
"author_id": 11210,
"author_profile": "https://Stackoverflow.com/users/11210",
"pm_score": 4,
"selected": true,
"text": "TDAPIOLELib.TDConnection connection = new TDAPIOLELib.TDConnection(); \nconnection.InitConnectionEx(\"http://SERVER:8080/qcbi... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3048/"
] |
79,745 | <p>We have an application which needs to use Direct3D. Specifically, it needs at least DirectX 9.0c version 4.09.0000.0904. While this should be present on all newer XP machines it might not be installed on older XP machines. How can I programmatically (using C++) determine if it is installed? I want to be able to give an information message to the user that Direct3D will not be available.</p>
| [
{
"answer_id": 79817,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": true,
"text": "DWORD dwVersion;\nDWORD dwRevision;\nif (DirectXSetupGetVersion(&dwVersion, &dwRevision))\n{\n printf(\"DirectX version is %d... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5022/"
] |
79,754 | <p>No matter what I do sys.exit() is called by unittest, even the most trivial examples. I can't tell if my install is messed up or what is going on.</p>
<pre><code>IDLE 1.2.2 ==== No Subprocess ====
>>> import unittest
>>>
>>> class Test(unittest.TestCase):
def testA(self):
a = 1
self.assertEqual(a,1)
>>> unittest.main()
option -n not recognized
Usage: idle.pyw [options] [test] [...]
Options:
-h, --help Show this message
-v, --verbose Verbose output
-q, --quiet Minimal output
Examples:
idle.pyw - run default set of tests
idle.pyw MyTestSuite - run suite 'MyTestSuite'
idle.pyw MyTestCase.testSomething - run MyTestCase.testSomething
idle.pyw MyTestCase - run all 'test*' test methods
in MyTestCase
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
unittest.main()
File "E:\Python25\lib\unittest.py", line 767, in __init__
self.parseArgs(argv)
File "E:\Python25\lib\unittest.py", line 796, in parseArgs
self.usageExit(msg)
File "E:\Python25\lib\unittest.py", line 773, in usageExit
sys.exit(2)
SystemExit: 2
>>>
</code></pre>
| [
{
"answer_id": 79826,
"author": "Allen",
"author_id": 6043,
"author_profile": "https://Stackoverflow.com/users/6043",
"pm_score": 3,
"selected": false,
"text": "unittest.main()"
},
{
"answer_id": 79833,
"author": "Joe Skora",
"author_id": 14057,
"author_profile": "htt... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3176/"
] |
79,764 | <p>I know there have been a few threads on this before, but I have tried absolutely everything suggested (that I could find) and nothing has worked for me thus far...</p>
<p>With that in mind, here is what I'm trying to do:</p>
<p>First, I want to allow users to publish pages and give them each a subdomain of their choice (ex: <code>user.example.com</code>). From what I can gather, the best way to do this is to map <code>user.example.com</code> to <code>example.com/user</code> with mod_rewrite and <code>.htaccess</code> - is that correct?</p>
<p>If that is correct, can somebody give me explicit instructions on how to do this?</p>
<p>Also, I am doing all of my development locally, using MAMP, so if somebody could tell me how to set up my local environment to work in the same manner (I've read this is more difficult), I would greatly appreciate it. Honestly, I have been trying a everything to no avail, and since this is my first time doing something like this, I am completely lost.</p>
<p><em>Some of these answers have been REALLY helpful, but for the system I have in mind, manually adding a subdomain for each user is not an option. What I'm really asking is how to do this on the fly, and redirect <code>wildcard.example.com</code> to <code>example.com/wildcard</code> -- the way Tumblr is set up is a perfect example of what I'd like to do.</em></p>
| [
{
"answer_id": 79811,
"author": "Ryan Farley",
"author_id": 1627,
"author_profile": "https://Stackoverflow.com/users/1627",
"pm_score": 5,
"selected": true,
"text": "http://myname.example.com"
},
{
"answer_id": 80122,
"author": "joelhardi",
"author_id": 11438,
"author... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14891/"
] |
79,774 | <p>Ok - a bit of a mouthful. So the problem I have is this - I need to store a Date for expiry where <em>only</em> the date part is required and I don't want any timezone conversion. So for example if I have an expiry set to "08 March 2008" I want that value to be returned to any client - no matter what their timezone is.
The problem with remoting it as a DateTime is that it gets stored/sent as "08 March 2008 00:00", which means for clients connecting from any timezone West of me it gets converted and therefore flipped to "07 March 2008"
Any suggestions for cleanly handling this scenario ? Obviously sending it as a string would work. anything else ?
thanks,
Ian</p>
| [
{
"answer_id": 79837,
"author": "Timothy Carter",
"author_id": 4660,
"author_profile": "https://Stackoverflow.com/users/4660",
"pm_score": 1,
"selected": true,
"text": "public struct Date\n{\n public int Month; //or string instead of int\n public int Day;\n public int Year;\n}\n... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14871/"
] |
79,780 | <p>I've had a new found interest in building a small, efficient web server in C and have had some trouble parsing POST methods from the HTTP Header. Would anyone have any advice as to how to handle retrieving the name/value pairs from the "posted" data?</p>
<pre><code>POST /test HTTP/1.1
Host: test-domain.com:7017
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://test-domain.com:7017/index.html
Cookie: __utma=43166241.217413299.1220726314.1221171690.1221200181.16; __utmz=43166241.1220726314.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none)
Cache-Control: max-age=0
Content-Type: application/x-www-form-urlencoded
Content-Length: 25
field1=asfd&field2=a3f3f3
// ^-this
</code></pre>
<p>I see no tangible way to retrieve the bottom line as a whole and ensure that it works every time. I'm not a fan of hard-coding in anything.</p>
| [
{
"answer_id": 47447856,
"author": "Oliver",
"author_id": 2984198,
"author_profile": "https://Stackoverflow.com/users/2984198",
"pm_score": 0,
"selected": false,
"text": "/r/n"
}
] | 2008/09/17 | [
"https://Stackoverflow.com/questions/79780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14877/"
] |
79,789 | <p>I have a list of timesheet entries that show a start and stop time. This is sitting in a MySQL database. I need to create bar charts based on this data with the 24 hours of the day along the bottom and the amount of man-hours worked for each hour of the day.</p>
<p>For example, if Alice worked a job from 15:30 to 19:30 and Bob worked from 12:15 to 17:00, the chart would look like this:</p>
<p><a href="https://i.stack.imgur.com/HHrs0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HHrs0.png" alt="Example Chart"></a></p>
<p>I have a WTFey solution right now that involves a spreadsheet going out to column DY or something like that. The needed resolution is 15-minute intervals.</p>
<p>I'm assuming this is something best done in the database then exported for chart creation. Let me know if I'm missing any details. Thanks.</p>
| [
{
"answer_id": 80125,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "create an array named timetable with 24 entries\ninitialise timetable to zero\n\nfor each user in SQLtable\n firsthour = user.... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9867/"
] |
79,797 | <p>How do I convert a datetime <em>string in local time</em> to a <em>string in UTC time</em>?</p>
<p>I'm sure I've done this before, but can't find it and SO will hopefully help me (and others) do that in future.</p>
<p><strong>Clarification</strong>: For example, if I have <code>2008-09-17 14:02:00</code> in my local timezone (<code>+10</code>), I'd like to generate a string with the equivalent <code>UTC</code> time: <code>2008-09-17 04:02:00</code>.</p>
<p>Also, from <a href="http://lucumr.pocoo.org/2011/7/15/eppur-si-muove/" rel="noreferrer">http://lucumr.pocoo.org/2011/7/15/eppur-si-muove/</a>, note that in general this isn't possible as with DST and other issues there is no unique conversion from local time to UTC time.</p>
| [
{
"answer_id": 79808,
"author": "Chuck Callebs",
"author_id": 14877,
"author_profile": "https://Stackoverflow.com/users/14877",
"pm_score": 5,
"selected": false,
"text": "def local_to_utc(t):\n secs = time.mktime(t)\n return time.gmtime(secs)\n\ndef utc_to_local(t):\n secs = cal... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3715/"
] |
79,816 | <p>I'd like a short smallest possible javascript routine that when a mousedown occurs on a button it first responds just like a mouseclick and then if the user keeps the button pressed it responds as if the user was continously sending mouseclicks and after a while with the button held down acts as if the user was accelerating their mouseclicks...basically think of it like a keypress repeat with acceleration in time.<br>
i.e. user holds down mouse button (x=call function) - x___x___x___x__x__x_x_x_x_xxxxxxx</p>
| [
{
"answer_id": 79830,
"author": "Thomas",
"author_id": 14637,
"author_profile": "https://Stackoverflow.com/users/14637",
"pm_score": 2,
"selected": false,
"text": "window.setTimeout"
},
{
"answer_id": 79862,
"author": "Quintin Robinson",
"author_id": 12707,
"author_pr... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14907/"
] |
79,843 | <p>The situation is this:</p>
<ul>
<li>You have a Hibernate context with an
object graph that has some lazy
loading defined. </li>
<li>You want to use
the Hibernate objects in your UI as
is without having to copy the data
somewhere. </li>
<li>There are different UI
contexts that require different
amounts of data. </li>
<li>The data is too
big to just eager load the whole
graph each time.</li>
</ul>
<p>What is the best means to load all the appropriate objects in the object graph in a configurable way so that they can be accessed without having to go back to the database to load more data?</p>
<p>Any help.</p>
| [
{
"answer_id": 79933,
"author": "sirrocco",
"author_id": 5246,
"author_profile": "https://Stackoverflow.com/users/5246",
"pm_score": 3,
"selected": true,
"text": "new ClientRepo().LoadClientBy(id)\n .WithOrders()\n .WithBonus()\n .OrderByName(... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14893/"
] |
79,856 | <p>In a stored procedure, I need to get the count of the results of another stored procedure. Specifically, I need to know if it returns any results, or an empty set.</p>
<p>I could create a temp table/table variable, exec the stored procedure into it, and then run a select count on that data. But I really don't care about the data itself, all I need is the count (or presence/absence of data). I was wondering if there is a more efficient way of getting just that information.</p>
<p>I don't want to just copy the contents of the other stored procedure and rewrite it as a select count. The stored procedure changes too frequently for that to be workable.</p>
| [
{
"answer_id": 80158,
"author": "Ricardo C",
"author_id": 232589,
"author_profile": "https://Stackoverflow.com/users/232589",
"pm_score": 0,
"selected": false,
"text": "DECLARE @res AS TABLE (\n [EmpID] [int] NOT NULL,\n [EmpName] [varchar](30) NULL,\n [MgrID] [int] NULL\n)\n\nI... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10630/"
] |
79,891 | <p>While we try to set up as many unit tests as time allows for our applications, I always find the amount of UI-level tests lacking. There are many options out there, but I'm not sure what would be a good place to start. </p>
<p>What is your preferred unit testing tool for testing Swing applications? Why do you like it?</p>
| [
{
"answer_id": 1001008,
"author": "Dema",
"author_id": 407003,
"author_profile": "https://Stackoverflow.com/users/407003",
"pm_score": 2,
"selected": false,
"text": " Scenario: Dialog manipulation\n Given the frame \"SwingSet\" is visible\n And the frame \"SwingSet\" is the conta... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13812/"
] |
79,918 | <p>How are folks integrating various static analysis tools such as PMD, Checkstyle, and FindBugs so that they are used together in some uniform way? In particular, I'm interested in generating a single uniform report that includes warnings from all tools. Also, I want to be able to mark-up my code with reasonably consistent looking warning suppressions.</p>
<p>My question here is not meant to address tool "overlap" where, say, PMD and Checkstyle are looking for the same things. That is another issue.</p>
<p>Please see some of my <a href="https://stackoverflow.com/questions/4080/what-code-analysis-tools-do-you-use-for-your-java-projects#79845"> thoughts on the matter in an answer</a> to <a href="https://stackoverflow.com/questions/4080/what-code-analysis-tools-do-you-use-for-your-java-projects">a related question</a>.</p>
| [
{
"answer_id": 84051,
"author": "Greg Mattes",
"author_id": 13940,
"author_profile": "https://Stackoverflow.com/users/13940",
"pm_score": 0,
"selected": false,
"text": "/absolute-path/filename:line-number:column-number: warning(tool-name): message"
}
] | 2008/09/17 | [
"https://Stackoverflow.com/questions/79918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13940/"
] |
79,923 | <ul>
<li>What are the stack and heap?</li>
<li>Where are they located physically in a computer's memory?</li>
<li>To what extent are they controlled by the OS or language run-time?</li>
<li>What is their scope?</li>
<li>What determines their sizes?</li>
<li>What makes one faster?</li>
</ul>
| [
{
"answer_id": 79936,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": "https://Stackoverflow.com/users/3153",
"pm_score": 11,
"selected": false,
"text": "delete"
},
{
"answer_id": 80094,
"author": "Don Neufeld",
"author_id": 13097,
"author_profile": "... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13161/"
] |
79,928 | <p>I want to run text through a filter to ensure it is all UTF-8 encoded. What is the recommended way to do this with PHP?</p>
| [
{
"answer_id": 83711,
"author": "Tometzky",
"author_id": 15862,
"author_profile": "https://Stackoverflow.com/users/15862",
"pm_score": 0,
"selected": false,
"text": "preg_match('/^.*$/Du', $value)\n"
}
] | 2008/09/17 | [
"https://Stackoverflow.com/questions/79928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.