qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
428,072
<p>I need to determine if a specific application is running from a SQL Server 2005 job. The issue is that one of our applications we use to send data will hang, causing problems with any subsequent jobs that invokes it. If I can also obtain the CPU time, I can determine if it's likely a hung process.</p> <p>A list of running applications would be good, but being able to lookup a specific executable name with the CPU time would be fantastic!</p>
[ { "answer_id": 428213, "author": "Nick Kavadias", "author_id": 40067, "author_profile": "https://Stackoverflow.com/users/40067", "pm_score": 0, "selected": false, "text": "Process(all) application name hostname" } ]
2009/01/09
[ "https://Stackoverflow.com/questions/428072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8944/" ]
428,073
<p>Currently our Java application uses the values held within a tab delimited *.cfg file. We need to change this application so that it now uses an XML file.</p> <p>What is the best/simplest library to use in order to read in values from this file?</p>
[ { "answer_id": 428091, "author": "Guillaume", "author_id": 23704, "author_profile": "https://Stackoverflow.com/users/23704", "pm_score": 7, "selected": true, "text": "import java.io.File;\nimport javax.xml.parsers.DocumentBuilder;\nimport javax.xml.parsers.DocumentBuilderFactory;\nimport...
2009/01/09
[ "https://Stackoverflow.com/questions/428073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42435/" ]
428,085
<p>How do I set a path for DLL files to be searched in Visual Studio for a particular project alone?</p> <p>Now I am setting it in the environment <code>path</code> variable, but I would like better control over this.</p>
[ { "answer_id": 2916103, "author": "Multicollinearity", "author_id": 351293, "author_profile": "https://Stackoverflow.com/users/351293", "pm_score": 7, "selected": false, "text": "PATH=C:\\WINDOWS\\Temp;%PATH%\n PATH=%PATH%;$(TargetDir)\\DLLS\n" }, { "answer_id": 57218631, "au...
2009/01/09
[ "https://Stackoverflow.com/questions/428085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22076/" ]
428,109
<p>Given a filename in the form <code>someletters_12345_moreleters.ext</code>, I want to extract the 5 digits and put them into a variable.</p> <p>So to emphasize the point, I have a filename with x number of characters then a five digit sequence surrounded by a single underscore on either side then another set of x number of characters. I want to take the 5 digit number and put that into a variable.</p> <p>I am very interested in the number of different ways that this can be accomplished.</p>
[ { "answer_id": 428118, "author": "FerranB", "author_id": 40441, "author_profile": "https://Stackoverflow.com/users/40441", "pm_score": 11, "selected": true, "text": "echo 'someletters_12345_moreleters.ext' | cut -d'_' -f 2\n INPUT='someletters_12345_moreleters.ext'\nSUBSTRING=$(echo $INP...
2009/01/09
[ "https://Stackoverflow.com/questions/428109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39666/" ]
428,110
<p>In my iPhone app, I have put a UIBarBUtton of type UIBarButtonSystemItemTrash in my UIToolBar. When pressed, I'd like to replicate the animation of Mail.app: the bin opens, the UIView folds and flies into it.<br> Is there a way to access this animation ithrough the iPhone SDK? </p> <p>Presently I am using a custom made animation, but there are some limits; for example, I cannot animate the bin itself. Do you have any suggestion? Code samples?</p> <p>Cheers,<br> Davide</p>
[ { "answer_id": 430855, "author": "rpetrich", "author_id": 4007, "author_profile": "https://Stackoverflow.com/users/4007", "pm_score": 6, "selected": true, "text": "CATransition *animation = [CATransition animation];\nanimation.type = @\"suckEffect\";\nanimation.duration = 2.0f;\nanimatio...
2009/01/09
[ "https://Stackoverflow.com/questions/428110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52224/" ]
428,112
<p>I am using JavaScript and jQuery. My main file has <code>My.js</code> and Ajax.</p> <h3>My.js</h3> <pre><code>function build_one(){ alert("inside build_one"); } </code></pre> <h3>My main file</h3> <pre><code>&lt;script type="text/javascript"&gt; .. // Here I want to make call function defined in My.js build_one() .. // Here is the Ajax call $.ajax({ type:'POST', url: 'ajax.php', data:'id='+id , success: function(data){ $("#response").html(data); } }); ... &lt;/script&gt; </code></pre> <p>How do I make the build_one() function call before the Ajax function?</p>
[ { "answer_id": 428137, "author": "d4nt", "author_id": 1039, "author_profile": "https://Stackoverflow.com/users/1039", "pm_score": 4, "selected": true, "text": "<script type=\"text/javascript\" src=\"My.js\"></script>\n<script type=\"text/javascript\">\n\n build_one();\n\n $.ajax({\...
2009/01/09
[ "https://Stackoverflow.com/questions/428112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44984/" ]
428,121
<p>I have an application that gets installed with a Wise installer (EDIT: Wise creates a Setup.exe file, not an MSI). Upon installation, an icon is set for a certain file type:</p> <pre><code>HKEY_CLASSES_ROOT\.auz\DefaultIcon = C:\Path\To\App\some_icon.ico,0 </code></pre> <p>Right after the installation, however, Explorer chooses to display this icon using the generic "white sheet + application icon" icon, which is different (and not provided by me).</p> <p>Upon first launch, the application itself registers icons and other file associations, so that the last run version "owns" those documents. At that point, <strong>Explorer changes the icon</strong> for this file type and displays the correct one, but when I look at the registry, the value for <strong>DefaultIcon is exactly the same</strong>.</p> <p><strong>This is what I've tried so far</strong></p> <ul> <li>Removing all entries from the registry, and writing them myself.</li> <li>After the installation, "touching" the value of DefaultIcon, and then launching a small little program that only calls <a href="http://msdn.microsoft.com/en-us/library/bb762118.aspx" rel="nofollow noreferrer">SHChangeNotify(SHCNE_ASSOCCHANGED)</a> (my program does this after updating the file associations in the registry).</li> <li>After the installation, killing and restarting Explorer.</li> <li>After the installation, using TweakUI to "repair" the icons on the desktop.</li> </ul> <p>None of these work. The only way to get the correct icon is to let the program itself install it. I can't find any change in the registry. I'm pulling my hair off.</p> <p><strong>What I would like to avoid</strong></p> <ul> <li>Testing with another installer software</li> <li>Changing the installation script too much (I don't have Wise itself, as the installer gets built on another machine on demand).</li> <li>Embed the icons in the executable.</li> </ul> <p>Any suggestions on how to get Explorer to display the correct icon after installation?</p>
[ { "answer_id": 428137, "author": "d4nt", "author_id": 1039, "author_profile": "https://Stackoverflow.com/users/1039", "pm_score": 4, "selected": true, "text": "<script type=\"text/javascript\" src=\"My.js\"></script>\n<script type=\"text/javascript\">\n\n build_one();\n\n $.ajax({\...
2009/01/09
[ "https://Stackoverflow.com/questions/428121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2095/" ]
428,124
<p>What I want is, I think, relatively simple:</p> <pre><code>&gt; Bin = &lt;&lt;"Hello.world.howdy?"&gt;&gt;. &gt; split(Bin, "."). [&lt;&lt;"Hello"&gt;&gt;, &lt;&lt;"world"&gt;&gt;, &lt;&lt;"howdy?"&gt;&gt;] </code></pre> <p>Any pointers?</p>
[ { "answer_id": 428332, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "re:split(<<\"Hello.world.howdy?\">>, \"\\\\.\").\n" }, { "answer_id": 428852, "author": "archaelus", "author_i...
2009/01/09
[ "https://Stackoverflow.com/questions/428124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21000/" ]
428,126
<p>does anyone know how to return a value from a (sql) database into an MSBuild script? I want to get the value into a property so I can pass it to subsequent build tasks.</p> <p>I am fiddling round with something like the following at the moment, but this is returning -1 to indicate the query has executed successfully, whereas what I want is the actual result of the query. (SqlExecute from the community tasks).</p> <pre><code> &lt;SqlExecute Command="select count(*) from dbo.trade" ConnectionString="XXXX" &gt; &lt;Output PropertyName="TradeCount" TaskParameter="Result" /&gt; &lt;/SqlExecute&gt; &lt;Message Text="$(TradeCount)" /&gt; </code></pre>
[ { "answer_id": 428484, "author": "NeedHack", "author_id": 44950, "author_profile": "https://Stackoverflow.com/users/44950", "pm_score": 1, "selected": false, "text": "this._result = command.ExecuteNonQuery();\n <Exec Command=\"osql -n -S $(DatabaseMachineName) -E -q &quot;select coun...
2009/01/09
[ "https://Stackoverflow.com/questions/428126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44950/" ]
428,144
<p>On RedHat Enterprise Linux 5 the latest Ruby version available via RPM is 1.8.5. My Rails app requires 1.8.6 or above so I need to compile Ruby from source.</p> <p>I have tried the following to build it and it seems to build ok, but then I'm seeing gcc compilation errors when trying to run a plug-in which requires RubyInline.</p> <p>There seems to be a lack of decent documentation for building Ruby from source, suitable for running Rails apps.</p> <p>Here's how I compiled Ruby:</p> <pre><code>./configure --prefix=/usr --with-openssl-include=/usr/include/openssl --with-openssl-lib=/usr/lib64/openssl/engines make sudo make install </code></pre> <p>I wonder whether there are specific compile flags I need to build this on a 64-bit system. The actual error I'm seeing is </p> <pre><code> error executing "gcc -shared -fPIC -g -O2 -I /usr/lib/ruby/1.8/x86_64-linux -I /usr/include -L/usr/lib -o \"/home/deploy/.ruby_inline/Inline_ImageScience_aa58.so\" \"/home/deploy/.ruby_inline/Inline_ImageScience_aa58.c\" -lfreeimage -lstdc++ ": </code></pre> <p>Any advice would be greatly appreciated</p>
[ { "answer_id": 428314, "author": "Jörg W Mittag", "author_id": 2988, "author_profile": "https://Stackoverflow.com/users/2988", "pm_score": 3, "selected": true, "text": "--disable-pthread configure --enable-pthread --enable-pthread --enable-pthread" } ]
2009/01/09
[ "https://Stackoverflow.com/questions/428144", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1174/" ]
428,147
<p>We have a set of databases that have a table defined with an Identity column as the primary key. As a sub-set of these are replicated to other servers, a seed system was created so that they could never clash. That system was by using a starting seed with an increment of 50.</p> <p>In this way the table on DB1 would generate 30001, 30051 etc, where Database2 would generate 30002, 30052 and so on.</p> <p>I am looking at adding another database into this system (it is split for scaling/loading purposes) and have discovered that the identites have got out of sync on one or two of the databases - i.e. database 3 that should have numbers ending in 3, doesn't anymore. The seeding and increments is still correct according to the table design.</p> <p>I am obviously going to have to work around this problem somehow (probably by setting a high initial value), but can anyone tell me what would cause them to get out of sync like this? From a query on the DB I can see the sequence went as follows: 32403,32453, 32456, 32474, 32524, 32574 and has continued in increments of 50 ever since it went wrong.</p> <p>As far as I am aware no bulk-inserts or DTS or anything like that has put new data into these tables.</p> <p>Second (bonus) question - how to reset the identity so that it goes back to what I want it to actually be!</p> <p>EDIT:</p> <p>I know the design is in principle a bit ropey - I didn't ask for criticism of it, I just wondered how it could have got out of sync. I inherited this system and changing the column to a GUID - whilst undoubtedly the best theoretical solution - is probably not going to happen. The system evolved from a single DB to multiple DBs when the load got too large (a few hundred GBs currently). Each ID in this table will be referenced in many other places - sometimes a few hundred thousand times each (multiplied by about 40,000 for each item). Updating all those will not be happening ;-)</p>
[ { "answer_id": 428162, "author": "Otávio Décio", "author_id": 48684, "author_profile": "https://Stackoverflow.com/users/48684", "pm_score": 2, "selected": false, "text": "DBCC CHECKIDENT (orders, RESEED, 999)\n" }, { "answer_id": 428172, "author": "P Daddy", "author_id": ...
2009/01/09
[ "https://Stackoverflow.com/questions/428147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16156/" ]
428,149
<p>i have very simple problem. I need to create model, that represent element of ordered list. This model can be implemented like this:</p> <pre><code>class Item(models.Model): data = models.TextField() order = models.IntegerField() </code></pre> <p>or like this:</p> <pre><code>class Item(models.Model): data = models.TextField() next = models.ForeignKey('self') </code></pre> <p>What way is preferred? What drawbacks have each solution?</p>
[ { "answer_id": 428189, "author": "Guillaume", "author_id": 23704, "author_profile": "https://Stackoverflow.com/users/23704", "pm_score": 5, "selected": true, "text": "n n UPDATE item.order = item.order + 1 FROM item WHERE order > 3\nINSERT INTO item (order, ...) VALUES (3, ...)\n" }, ...
2009/01/09
[ "https://Stackoverflow.com/questions/428149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42371/" ]
428,158
<p>I need to run multiple instances of a C program in VxWorks (VxWorks has a global namespace). The problem is that the C program defines global variables (which are intended for use by a specific instance of that program) which conflict in the global namespace. I would like to make minimal changes to the program in order to make this work. All ideas welcomed! </p> <p>Regards</p> <p>By the way ... This isn't a good time to mention that global variables are not best practice!</p>
[ { "answer_id": 428402, "author": "Benoit", "author_id": 10703, "author_profile": "https://Stackoverflow.com/users/10703", "pm_score": 0, "selected": false, "text": "int global1;\nint global2;\n\nint someApp()\n{\n global2 = global1 + 3;\n ...\n}\n\nTO:\ntypedef struct appGlobStruct {...
2009/01/09
[ "https://Stackoverflow.com/questions/428158", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23435/" ]
428,183
<p>I want to re-write a method that has way too many nested <code>if</code> statements.</p> <p>I came up with this approach and wanted your opinions:</p> <pre><code>public void MyMethod() { bool hasFailed = false; try { GetNewOrders(out hasFailed); if(!hasFailed) CheckInventory(out hasFailed); if(!hasFailed) PreOrder(out hasFailed); // etc } catch(Exception ex) { } finally { if(hasFailed) { // do something } } } </code></pre>
[ { "answer_id": 428204, "author": "Graeme Perrow", "author_id": 1821, "author_profile": "https://Stackoverflow.com/users/1821", "pm_score": 4, "selected": true, "text": "BOOL ok = CallSomeFunction();\nif( ok ) ok = CallSomeOtherFunction();\nif( ok ) ok = CallYetAnotherFunction();\nif( ok ...
2009/01/09
[ "https://Stackoverflow.com/questions/428183", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39677/" ]
428,196
<p>This is just a question to satisfy my curiosity. But to me it is interesting.</p> <p>I wrote this little simple benchmark. It calls 3 variants of Regexp execution in a random order a few thousand times:</p> <p>Basically, I use the same pattern but in different ways.</p> <ol> <li><p>Your ordinary way without any <code>RegexOptions</code>. Starting with .NET 2.0 these do not get cached. But should be "cached" because it is held in a pretty global scope and not reset.</p></li> <li><p>With <code>RegexOptions.Compiled</code></p></li> <li><p>With a call to the static <code>Regex.Match(pattern, input)</code> which does get cached in .NET 2.0</p></li> </ol> <p>Here is the code:</p> <pre><code>static List&lt;string&gt; Strings = new List&lt;string&gt;(); static string pattern = ".*_([0-9]+)\\.([^\\.])$"; static Regex Rex = new Regex(pattern); static Regex RexCompiled = new Regex(pattern, RegexOptions.Compiled); static Random Rand = new Random(123); static Stopwatch S1 = new Stopwatch(); static Stopwatch S2 = new Stopwatch(); static Stopwatch S3 = new Stopwatch(); static void Main() { int k = 0; int c = 0; int c1 = 0; int c2 = 0; int c3 = 0; for (int i = 0; i &lt; 50; i++) { Strings.Add("file_" + Rand.Next().ToString() + ".ext"); } int m = 10000; for (int j = 0; j &lt; m; j++) { c = Rand.Next(1, 4); if (c == 1) { c1++; k = 0; S1.Start(); foreach (var item in Strings) { var m1 = Rex.Match(item); if (m1.Success) { k++; }; } S1.Stop(); } else if (c == 2) { c2++; k = 0; S2.Start(); foreach (var item in Strings) { var m2 = RexCompiled.Match(item); if (m2.Success) { k++; }; } S2.Stop(); } else if (c == 3) { c3++; k = 0; S3.Start(); foreach (var item in Strings) { var m3 = Regex.Match(item, pattern); if (m3.Success) { k++; }; } S3.Stop(); } } Console.WriteLine("c: {0}", c1); Console.WriteLine("Total milliseconds: " + (S1.Elapsed.TotalMilliseconds).ToString()); Console.WriteLine("Adjusted milliseconds: " + (S1.Elapsed.TotalMilliseconds).ToString()); Console.WriteLine("c: {0}", c2); Console.WriteLine("Total milliseconds: " + (S2.Elapsed.TotalMilliseconds).ToString()); Console.WriteLine("Adjusted milliseconds: " + (S2.Elapsed.TotalMilliseconds*((float)c2/(float)c1)).ToString()); Console.WriteLine("c: {0}", c3); Console.WriteLine("Total milliseconds: " + (S3.Elapsed.TotalMilliseconds).ToString()); Console.WriteLine("Adjusted milliseconds: " + (S3.Elapsed.TotalMilliseconds*((float)c3/(float)c1)).ToString()); } </code></pre> <p>Everytime I call it the result is along the lines of:</p> <pre> Not compiled and not automatically cached: Total milliseconds: 6185,2704 Adjusted milliseconds: 6185,2704 Compiled and not automatically cached: Total milliseconds: 2562,2519 Adjusted milliseconds: 2551,56949184038 Not compiled and automatically cached: Total milliseconds: 2378,823 Adjusted milliseconds: 2336,3187176891 </pre> <p>So there you have it. Not much, but about 7-8% difference.</p> <p>It is not the only mystery. I cannot explain why the first way would be that much slower because it is never re-evaluated but held in a global static variable.</p> <p>By the way, this is on .Net 3.5 and Mono 2.2 which behave exactly the same. On Windows.</p> <p>So, any ideas, why the compiled variant would even fall behind?</p> <p>EDIT1:</p> <p>After fixing the code the results now look like this:</p> <pre> Not compiled and not automatically cached: Total milliseconds: 6456,5711 Adjusted milliseconds: 6456,5711 Compiled and not automatically cached: Total milliseconds: 2668,9028 Adjusted milliseconds: 2657,77574842168 Not compiled and automatically cached: Total milliseconds: 6637,5472 Adjusted milliseconds: 6518,94897724836 </pre> <p>Which pretty much obsoletes all of the other questions as well.</p> <p>Thanks for the answers.</p>
[ { "answer_id": 428259, "author": "P Daddy", "author_id": 36388, "author_profile": "https://Stackoverflow.com/users/36388", "pm_score": 2, "selected": false, "text": "RegexRunner Regex Regex Regex Regex Regex Regex RegexTree Regex Regex" }, { "answer_id": 428265, "author": "Ma...
2009/01/09
[ "https://Stackoverflow.com/questions/428196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51710/" ]
428,214
<p>I have small problem with my .net 2.0 winforms application. I want to embed a few different icons to app.</p> <p>There are also other requirements:</p> <ul> <li>must be automatic rebuildable by ms-build; using external gui apps for preparation isn't allowed</li> <li>application must contain versioninfo.</li> </ul> <p>After embeding multiple icons, I want to register let's say two file associations to application documents / extension files.</p> <pre><code>[Registry] ... Root: HKCR; Subkey: "MyFileExt\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\MyApp.exe,2" </code></pre> <p>where "2" it's icon index.</p> <p>I know that I need to use somehow old-style Win32 resource file.</p> <p>I also found somewhere that if using Visual Studio 2005 it's possible to add 'native resource file' but it doesn't exist in 2008 anymore.</p> <p>Is it possible to meet all this requirements and if yes - how?</p>
[ { "answer_id": 428271, "author": "Matt Warren", "author_id": 4500, "author_profile": "https://Stackoverflow.com/users/4500", "pm_score": 0, "selected": false, "text": "buttonPlay.Image = Properties.Resources.Navigation_Media_Pause;\n buttonPlay.Image = Properties.Resources.Navigation_Med...
2009/01/09
[ "https://Stackoverflow.com/questions/428214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39656/" ]
428,216
<p>I'm trying to read a 16-bit greyscale TIFF file (BitsPerSample=16) using a small C program to convert into an array of floating point numbers for further analysis. The pixel data are, according to the header information, in a single strip of 2048x2048 pixels. Encoding is little-endian.<br> With that header information, I was expecting to be able to read a single block of 2048x2048x2 bytes and interpret it as 2048x2048 2-byte integers. What I in fact get is a picture <a href="http://users.aber.ac.uk/ruw/unlinked/15_inRT_0p457.png" rel="nofollow noreferrer">split into four quadrants</a> of 1024x1024 pixels each, the lower two of which contain only zeros. Each of the top two quadrants look like I expected the whole picture to look: <a href="http://users.aber.ac.uk/ruw/unlinked/15_inRT_0p457.png" rel="nofollow noreferrer">alt text http://users.aber.ac.uk/ruw/unlinked/15_inRT_0p457.png</a><br> If I read the <a href="http://users.aber.ac.uk/ruw/unlinked/15_inRT_0p457_gimp.png" rel="nofollow noreferrer">same file into Gimp</a> or Imagemagick, both tell me that they have to reduce to 8-bit (which doesn't help me - I need the full range), but the pixels turn up in the right places: <a href="http://users.aber.ac.uk/ruw/unlinked/15_inRT_0p457_gimp.png" rel="nofollow noreferrer">alt text http://users.aber.ac.uk/ruw/unlinked/15_inRT_0p457_gimp.png</a> This would suggest that my idea about how the data are arranged within the one strip is wrong. On the other hand, the file must be correctly formatted in terms of the header information as otherwise Gimp wouldn't get it right. Where am I going wrong?</p> <p>Output from tiffdump:<br> 15_inRT_0p457.tiff:<br> Magic: 0x4949 Version: 0x2a<br> Directory 0: offset 8 (0x8) next 0 (0)<br> ImageWidth (256) LONG (4) 1&lt;2048><br> ImageLength (257) LONG (4) 1&lt;2048><br> BitsPerSample (258) SHORT (3) 1&lt;16><br> Compression (259) SHORT (3) 1&lt;1><br> Photometric (262) SHORT (3) 1&lt;1><br> StripOffsets (273) LONG (4) 1&lt;4096><br> Orientation (274) SHORT (3) 1&lt;1><br> RowsPerStrip (278) LONG (4) 1&lt;2048><br> StripByteCounts (279) LONG (4) 1&lt;8388608><br> XResolution (282) RATIONAL (5) 1&lt;126.582><br> YResolution (283) RATIONAL (5) 1&lt;126.582><br> ResolutionUnit (296) SHORT (3) 1&lt;3><br> 34710 (0x8796) LONG (4) 1&lt;0><br> (Tag 34710 is camera information; to make sure this doesn't somehow make any difference, I've zeroed the whole range from the end of the image file directory to the start of data at 0x1000, and that in fact doesn't make any difference.)</p>
[ { "answer_id": 429135, "author": "user53343", "author_id": 53343, "author_profile": "https://Stackoverflow.com/users/53343", "pm_score": 2, "selected": true, "text": "#define PPR 2048;\n#define BPP 2;\nlong *pix;\npix=malloc(PPR*PPR*sizeof(long));\nfread(pix,BPP,PPR*PPR,in);\n for (m=0;m...
2009/01/09
[ "https://Stackoverflow.com/questions/428216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53343/" ]
428,225
<p>I just started Shader programming(GLSL) and created a few with RenderMonkey. Now I want to use this Shaders in my java code. Are there any simple examples of how I do that?</p>
[ { "answer_id": 545083, "author": "Alexander Stolz", "author_id": 2450, "author_profile": "https://Stackoverflow.com/users/2450", "pm_score": 4, "selected": true, "text": "int v = gl.glCreateShader(GL.GL_VERTEX_SHADER);\nint f = gl.glCreateShader(GL.GL_FRAGMENT_SHADER);\n\nBufferedReader ...
2009/01/09
[ "https://Stackoverflow.com/questions/428225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2450/" ]
428,237
<p>I'm writing a C# program to convert a FoxPro database to XML, and everything works except the memo field is blank. Is there something I'm missing to convert that bit?</p> <p>I'm using C# .Net 3.5 SP1, Visual FoxPro 9 SP 1 OLE DB Driver. Connection string is okay, as all other data is being pulled properly.</p> <p>When I converted the FoxPro database to SQL Server, the memo field is also blank there, so I can't convert twice.</p>
[ { "answer_id": 436096, "author": "Jonathan DeMarks", "author_id": 39421, "author_profile": "https://Stackoverflow.com/users/39421", "pm_score": 3, "selected": true, "text": " public static object GetDbaseOrFoxproRawValue(string DBPath, string TableName, string ColumnName, \n ...
2009/01/09
[ "https://Stackoverflow.com/questions/428237", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39421/" ]
428,238
<p>Hmmm, a new odd issue that has just started. Every now and then VS drops a whole bunch of projects from the solution. It will say at the top of Solution explorer "42 projects" when it is displaying only about 20 or so. Closing VS and re-opening it fixes this, although it is a bit of a pain as it takes a little while for the .sln to open again.</p> <p>We run VS2005 and mainly work on a 42 project solution targetting the Compact Framework 2.00. I'm pretty much the only one using Resharper here (despite my recommendations to others and their occasional oOoing and ahhing at its beauty) so i use CTRL+T to find classes but when i've been hitting SHFT + ALT + L to select the item in the solution explorer (to view the history in TFS) it hasn't matched anything which is how i've noticed this issue.</p> <p>Anyone experienced this before?</p>
[ { "answer_id": 436096, "author": "Jonathan DeMarks", "author_id": 39421, "author_profile": "https://Stackoverflow.com/users/39421", "pm_score": 3, "selected": true, "text": " public static object GetDbaseOrFoxproRawValue(string DBPath, string TableName, string ColumnName, \n ...
2009/01/09
[ "https://Stackoverflow.com/questions/428238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1143/" ]
428,243
<p>I'm designing a database of statistics about the operation of mechanical equipment. Each batch of data will contain hundreds of statistics, so I'm trying to decide whether to create a single table with hundreds of columns or to split it up into multiple tables, each containing related statistics. For example, I could have one table containing the statistics related to malfunctions, another table with the statistics related to jams, etc.</p> <p>Using multiple tables would make the system more complex overall, though conceptually it might be easier for me to deal with several smaller tables than one big one.</p> <p>Would there be any performance benefits to splitting things up? It seems like querying a table with a few dozen columns would probably be faster than querying one with hundreds of columns.</p> <p>Does anyone have any experience with this sort of thing? I'm using Oracle for this project, although this is something I'll likely run into with out databases in the future, so answers for any database would be appreciated.</p>
[ { "answer_id": 428343, "author": "Jeremy", "author_id": 53368, "author_profile": "https://Stackoverflow.com/users/53368", "pm_score": 0, "selected": false, "text": "machine\nid\nname\ndescription\n\nstatus_flag\nid\ncaption\n\nmachine_history\nmachine_id\nstatus_flag_id\ninformation\n" ...
2009/01/09
[ "https://Stackoverflow.com/questions/428243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1694/" ]
428,256
<p>What would be the best approach / LayoutManager for a JPanel that needed to display the components shown in the image? (Note that the fields should resize horizontally when the size of the window is changed, but not the labels).</p> <p>I'm currently trying (and struggling) to do it with a GridBagLayout. Is this the correct approach or is there a better way? Should I be trying to divide + conquer the seperate sections maybe?</p> <p>Any thoughts or advice would be gratefully appreciated. :-)</p> <p><a href="http://img261.imageshack.us/img261/2091/layouthb6.png" rel="nofollow noreferrer">http://img261.imageshack.us/img261/2091/layouthb6.png</a></p> <p>PS If you read this and there's no image, please bear with me whilst I fix it!</p>
[ { "answer_id": 428334, "author": "jjnguy", "author_id": 2598, "author_profile": "https://Stackoverflow.com/users/2598", "pm_score": 4, "selected": false, "text": "JPanels JPanel JPanels GridBagLayout GridBagLayout GridBagConstraint .gridx GridBagConstraint.gridx = 0 GridBagConstraint.gri...
2009/01/09
[ "https://Stackoverflow.com/questions/428256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19629/" ]
428,257
<p>I have a datalist control which some controls(ex: button) are in it. I want to write some code into click event of button which is in the datalist control. But in the code behind page I can't see the name of controls into datalist. How can I solve this problem?</p>
[ { "answer_id": 428293, "author": "cmsjr", "author_id": 23114, "author_profile": "https://Stackoverflow.com/users/23114", "pm_score": 2, "selected": false, "text": "private void DataList_ItemCreated(object sender,\n System.Web.UI.WebControls.DataListItemEventArgs e)\n {\n if ...
2009/01/09
[ "https://Stackoverflow.com/questions/428257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/439507/" ]
428,262
<p>Ok I want some opinions how I can fix this mess of a method!</p> <p>It has WAY to many nested 'if' statements.</p> <p>But realize I have to know exactly where the method fails, currently in each of the respective 'else' clause I am logging the error (the failed 'if' condition').</p> <p><b>Note: ignore any logic behind the things, please focus on the style and structure as I have made all the function names up etc.</b></p> <p>Here is the skeleton structure:</p> <pre><code> public void MyMethod() { try { bool tryAgain = false; string filename = DownloadFile(); if( IsFileFormatOk(filename) ) { blah = GetBlah(filename); if(blah.ID &gt; 0) { if(ImportFile(filename) { string username = GetUserFromFile(filename); if(isValidUser(username)) { // few more levels to go // // // } else { LogError(filename, ...); // specific to this if statement tryAgain = true; } } else { LogError(filename, ...); // specific to this if statement tryAgain = true; } } else { LogError(filename, ...); // specific to this if statement tryAgain = true; } } else { LogError(filename, ...); // specific to this if statement tryAgain = true; } } catch { } finally { if(tryAgain) { // blah } } } </code></pre>
[ { "answer_id": 428302, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 1, "selected": false, "text": "if (condition) {\n // Block1\n} else {\n // Block2\n}\n if (condition) {\n Block(...);\n} else {\n Block2(...);\n...
2009/01/09
[ "https://Stackoverflow.com/questions/428262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39677/" ]
428,264
<p>To illustrate the question check the following code:</p> <pre><code>class MyDescriptor(object): def __get__(self, obj, type=None): print "get", self, obj, type return self._v def __set__(self, obj, value): self._v = value print "set", self, obj, value return None class SomeClass1(object): m = MyDescriptor() class SomeClass2(object): def __init__(self): self.m = MyDescriptor() x1 = SomeClass1() x2 = SomeClass2() x1.m = 1000 # -&gt; set &lt;__main__.MyDescriptor object at 0xb787c7ec&gt; &lt;__main__.SomeClass1 object at 0xb787cc8c&gt; 10000 x2.m = 1000 # I guess that this overwrites the function. But why? # -&gt; print x1.m # -&gt; get &lt;__main__.MyDescriptor object at 0xb787c7ec&gt; &lt;__main__.SomeClass1 object at 0xb787cc8c&gt; &lt;class '__main__.SomeClass1'&gt; 10000 print x2.m # -&gt; 10000 </code></pre> <ol> <li>Why doesn't <strong>x2.m = 1000</strong> not call the <strong>__set__</strong>-function? It seems that this overwrites the function. But why?</li> <li>Where is <strong>_v</strong> in x1? It is not in <strong>x1._v</strong></li> </ol>
[ { "answer_id": 428357, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 3, "selected": true, "text": "_v _v SomeClass1 SomeClass2 _v SomeClass1 x2 _v class MyDescriptor(object):\n def __get__(self, obj, type=None):\n print...
2009/01/09
[ "https://Stackoverflow.com/questions/428264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51200/" ]
428,267
<p>Given you have the following class (bad C#, but you get the drift):</p> <pre><code>public abstract class AmICircular { // assume Children is never null private List&lt;AmICircular&gt; Children {get;set;} // assume target is never null public void Add(AmICircular target) { target.PerformCircularReferenceCheck(this); Children.Add(target); } // throws when a circular reference is detected protected abstract void PerformCircularReferenceCheck(AmICircular target); } </code></pre> <p>How would you implement PerformCircularReferenceCheck? And, no, this isn't homework.</p> <p>The naive implementation, imo, would be to do a reference check on <code>this</code> and all children, then call PerformCircularReferenceCheck on <code>target</code>, passing <code>this</code>. But I'm wondering if there are better, proven effective, ways to do this, such as adding a method to collapse the entire Children tree of references for <code>this</code> and <code>target</code> and then examine the results (less pressure on the stack?), or perhaps avoid the check entirely by using a different (maybe self-checking!) collection other than List&lt;T>? </p> <p>How would you do this?</p> <p><em>edit: As stefan pointed out, it is only necessary to determine if this is reachable by the target</em></p>
[ { "answer_id": 428619, "author": "MSalters", "author_id": 15416, "author_profile": "https://Stackoverflow.com/users/15416", "pm_score": 3, "selected": false, "text": "R = {this} CR = {this.children} this target this" } ]
2009/01/09
[ "https://Stackoverflow.com/questions/428267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
428,276
<p>I have a shared folder in a server and I need to remotely execute a command on some files. How do I do that? </p> <p>What services need to be running on the server to make that work?</p> <p>Some details: Only C# can be used. Nothing can be installed in the server.</p>
[ { "answer_id": 428370, "author": "chakrit", "author_id": 3055, "author_profile": "https://Stackoverflow.com/users/3055", "pm_score": 1, "selected": false, "text": "PsExec \\\\yourServerName -u yourUserName cmd.exe\n lanmanserver TermService" }, { "answer_id": 428373, "author"...
2009/01/09
[ "https://Stackoverflow.com/questions/428276", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53179/" ]
428,280
<p>I am trying to accomplish something that seemed quite simple... </p> <p>I have 3 <code>div</code>s that contain a radiobutton and some content:</p> <pre><code> Content of DIV1, [] this can be as long or as tall as wanted [] Content of DIV2 [] Content of DIV3 </code></pre> <p>It's easy to create rounded corners for each div using any techniques found on <a href="https://stackoverflow.com/questions/7089/what-is-the-best-way-to-create-rounded-corners-using-css">other posts</a> here. Yet, I haven't been able to do that only for the hover event, ie I would like to see the rounded box appear around the div only when the mouse hovers over it. Has anyone seen an example of this being done somewhere?</p> <p><strong>Edit</strong>: I'm already using Prototype and Scriptaculous. I can't add jQuery just for this.</p>
[ { "answer_id": 428418, "author": "Antony Delaney", "author_id": 53366, "author_profile": "https://Stackoverflow.com/users/53366", "pm_score": 3, "selected": true, "text": "print(\"<div id=\"output\" class=\"div\"></div>\n\n\n\n<script>\n\n jQuery(document).ready(function() {\n\n $(...
2009/01/09
[ "https://Stackoverflow.com/questions/428280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25152/" ]
428,282
<p>I'm faced with a design decision that doesn't smell to me, but gives me pause. Take a look at the following code sample:</p> <pre><code>public interface IGenerator { ///&lt;summary&gt; /// Combines two generators; performs magic as well /// &lt;/summary&gt; BaseGenerator Combine(BaseGenerator next); ///&lt;summary&gt; /// Does what a generator does. /// &lt;/summary&gt; object GenerateLolKThx(); } public abstract class BaseGenerator : IGenerator { ///&lt;summary&gt; /// Combines two generators; performs magic as well /// &lt;/summary&gt; public BaseGenerator Combine(BaseGenerator next) { // do stuff that I really don't want implementors to try and do // because its complex and can result in bad juju if done wrong return SuperSecretCombine(this, next); } ///&lt;summary&gt; /// Does what a generator does. /// &lt;/summary&gt; public abstract object GenerateLolKThx(); /* other base class methods */ } </code></pre> <p>I don't want to go into more detail about WHY I don't want to trust implementors with the Combine method; suffice it to say its complex. I do, however, want to do my best to force anybody who wants to implement IGenerator to extend BaseGenerator, as that's the only way to properly combine two generators. This is enforced by the interface itself.</p> <p>I'm worried that there are unexpected issues (indicated by a "smell") caused by my referencing an implementation of an interface within that interface. But I also know that this sort of thing isn't unheard of in CS, nor is it in and of itself bad (i.e., an XML schema that describes XSDs and language compilers that are written in the language they compile).</p>
[ { "answer_id": 428296, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": false, "text": "IGenerator FredsGenerator Combine FredsGenerator FredsGenerator using System;\ninterface IFoo {\n void Bar();\n}\n...
2009/01/09
[ "https://Stackoverflow.com/questions/428282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
428,285
<p>I need to correlate a PDF and a XML file in BizTalk using the PDF filename and value in the XML. How can I read a PDF-file into an orchestration? I somehow have to handle it as XML ...</p> <p>The reason for the correlation is that I have to have both the PDF and the XML from the sending system before I can write them in a specific order to the receiving system (the PDF file has to be delivered <strong><em>before</em></strong> the XML meta file is sent.). </p>
[ { "answer_id": 434661, "author": "David Hall", "author_id": 2660, "author_profile": "https://Stackoverflow.com/users/2660", "pm_score": 4, "selected": true, "text": "System.Xml.XmlDocument" } ]
2009/01/09
[ "https://Stackoverflow.com/questions/428285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/298/" ]
428,308
<p>I have a set of word documents that contains a lot of non-embedded images in them. The url that the images point to no longer exist. I would like to programmatically change the domain name of the url to something else. How can I go about doing this in Java or Python ?</p>
[ { "answer_id": 428525, "author": "Chris Lawlor", "author_id": 21245, "author_profile": "https://Stackoverflow.com/users/21245", "pm_score": 1, "selected": false, "text": "Sub HlinkChanger()\nDim oRange As Word.Range\nDim oField As Field\nDim link As Variant\nWith ActiveDocument\n.Range.A...
2009/01/09
[ "https://Stackoverflow.com/questions/428308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27474/" ]
428,313
<p>Suppose I create a very simple socket connection, how can one programatically:</p> <ol> <li>Find out what interface (ip address / NIC) is being used. </li> <li>Force the other interface</li> </ol>
[ { "answer_id": 428802, "author": "j_random_hacker", "author_id": 47984, "author_profile": "https://Stackoverflow.com/users/47984", "pm_score": 5, "selected": true, "text": "socket() bind() listen() accept() bind() INADDR_ANY socket() connect() host:port bind() socket() connect() connect(...
2009/01/09
[ "https://Stackoverflow.com/questions/428313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21634/" ]
428,364
<p>Does such a thing exist for <a href="http://en.wikipedia.org/wiki/Yaml" rel="noreferrer">YAML</a> (aka <a href="http://yaml.org" rel="noreferrer">YAML</a>)?</p> <p>If this existed at one time, it must have been obliterated because the latest search turned up nada. It looks like there are plenty of implementations that <strong>dump</strong> from Javascript to YAML output only, but having trouble finding an implementation that supports both dump and load.</p> <p>Is anyone working on such a thing ... or is the demand simply far too low for this.</p>
[ { "answer_id": 1745396, "author": "Apex", "author_id": 51452, "author_profile": "https://Stackoverflow.com/users/51452", "pm_score": 3, "selected": false, "text": ";(function(){\n YAML = {\n valueOf: function(token) {\n return eval('(' + token + ')')\n },\n\n tokenize: fun...
2009/01/09
[ "https://Stackoverflow.com/questions/428364", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42223/" ]
428,368
<p>I upgraded a website I've been working on (<a href="http://barsannapolis.com" rel="nofollow noreferrer">http://barsannapolis.com</a>) to a CSS Layout, and things appeared to go well for the most part. The site renders correctly in Firefox, Chrome, IE 7, and Safari, but the design appears to be complete borked in IE 6. Does anybody have any guidance regarding how to get the problems fixed. Perhaps there is something simple I am overlooking?</p> <p>Also, are there any IE tools that make it easier to live-edit the CSS, like firebug.</p>
[ { "answer_id": 428399, "author": "John Dunagan", "author_id": 28939, "author_profile": "https://Stackoverflow.com/users/28939", "pm_score": 4, "selected": true, "text": "width:30px; _width: 20px;" }, { "answer_id": 770112, "author": "Paul D. Waite", "author_id": 20578, ...
2009/01/09
[ "https://Stackoverflow.com/questions/428368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4767/" ]
428,376
<p>I am trying decide on how I want to handle the UI for an external-facing web app. Because it is external, latency caused by page bloat could be an issue.</p> <p>I have used jQuery some in the past, and I am evaluating the Telerik controls now. I have seen a lot of good recommendations on the Telerik controls, including some on StackOverflow. Indeed they do seem fairly full-featured. I also have no doubt that I can develop the application much more quickly using those controls than I can with jQuery. However, I am worried that they will cause too much bloat on my pages. </p> <p>Do any of you have experience comparing the performance of these controls against a purely jQuery implementation? Specifically,</p> <ul> <li>Is the RadScriptManager from Telerik really any better than the MS Ajax ScriptManager? </li> <li>Are there performance issues in general with the Telerik controls?</li> <li>Is there any plug-in for jQuery that comes close to the grid functionality of RadGrid?</li> </ul> <p>Any other related information would be useful as well.</p>
[ { "answer_id": 428875, "author": "Crescent Fresh", "author_id": 45433, "author_profile": "https://Stackoverflow.com/users/45433", "pm_score": 1, "selected": false, "text": "NextPrev AllowNaturalSort=\"false\"" }, { "answer_id": 10062201, "author": "Mehdi Shojaei", "author...
2009/01/09
[ "https://Stackoverflow.com/questions/428376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29426/" ]
428,377
<p>How do I draw a class in UML that uses a web service?</p>
[ { "answer_id": 428455, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 3, "selected": true, "text": "--------------------\n| <<wsdl:service>> |\n--------------------\n| MyWebService |\n--------------------\n| ...
2009/01/09
[ "https://Stackoverflow.com/questions/428377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40676/" ]
428,384
<p>I'm trying to enforce integrity on a table in a way which I do not think a Constraint can...</p> <pre><code>CREATE TABLE myData ( id INTEGER IDENTITY(1,1) NOT NULL, fk_item_id INTEGER NOT NULL, valid_from DATETIME NOT NULL, invlaid_from DATETIME NOT NULL ) </code></pre> <p>The constraint I want to apply is that there should never be any entries for the same "fk_item_id" with overlapping dates.</p> <p>Note:</p> <p>invalid_from is the instant immediately after the valid period.<br> This means that the following two periods are fine... </p> <ul> <li>'2008 Jan 01 00:00' -> '2008 Feb 01 00:00' (All of Jan) </li> <li>'2008 Feb 01 00:00' -> '2008 Mar 01 00:00' (All of Feb) </li> </ul> <p>I can check that rule in a trigger. When the trigger does find an illegal insert/update, however, what is the best way to prevent the "illegal" inserts/updates from happening? </p> <p>(If <em>inserted</em> includes two valid records and two invalid records, can I stop just the two invalid records?) </p> <p>Cheers,<br> Dems.</p> <p><strong>EDIT:</strong></p> <p>In the case I had above, a constraint using a function worked well. But I never worked out why the RAISERROR didn't work in the trigger version. </p> <p>I thought it was because the trigger is an AFTER trigger, and that I'd need a BEFORE trigger, but that doesn't appear to be an option...</p>
[ { "answer_id": 428405, "author": "cmsjr", "author_id": 23114, "author_profile": "https://Stackoverflow.com/users/23114", "pm_score": 3, "selected": true, "text": "create table triggertest (id int null, val varchar(20))\nGo\ncreate trigger after on [dbo].triggertest\nfor Update \nas\nBe...
2009/01/09
[ "https://Stackoverflow.com/questions/428384", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53341/" ]
428,406
<p>I was wondering what is the best way (if at all possible) to determine on the server side if a given HttpRequest was sent via ajax?</p>
[ { "answer_id": 428518, "author": "alex", "author_id": 50564, "author_profile": "https://Stackoverflow.com/users/50564", "pm_score": 3, "selected": true, "text": "if (sm1.IsInAsyncPostBack)\n{\n //code here\n}\n <asp:ScriptManager id=\"sm1\" runat=\"server\" />\n" } ]
2009/01/09
[ "https://Stackoverflow.com/questions/428406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1789/" ]
428,410
<p>Is there an "easy" way to select either a file OR a folder from the same dialog?</p> <p>In many apps I create I allow for both files or folders as input. Until now i always end up creating a switch to toggle between file or folder selection dialogs or stick with drag-and-drop functionality only. </p> <p>Since this seems such a basic thing i would imagine this has been created before, but googling does not result in much information. So it looks like i would need to start from scratch and create a custom selection Dialog, but I rather not introduce any problems by reinventing the wheel for such a trivial task.</p> <p>Anybody any tips or existing solutions?</p> <p>To keep the UI consistent it would be nice if it is possible to extend the OpenFileDialog (or the FolderBrowserDialog).</p>
[ { "answer_id": 431151, "author": "barry", "author_id": 35709, "author_profile": "https://Stackoverflow.com/users/35709", "pm_score": 3, "selected": false, "text": "Imports System \nImports System.Text \nImports System.Windows.Forms \nImports System.Runtime.InteropServices \n\nPub...
2009/01/09
[ "https://Stackoverflow.com/questions/428410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35709/" ]
428,414
<p>I'm trying to write a custom function that will let me retrieve a cell from the first row in a range that meets x number of criteria. I imagine this would be very similar to the way SUMIFS works, just simpler in that it doesn't continue processing after the first match. </p> <p>Does anyone know code to reproduce the SUMIFS (excel 07) function in VBA?</p> <p>So, for example, if I have a table in excel like:</p> <pre><code>W X Y Z a b 6 1 a b 7 2 b b 7 3 </code></pre> <p>I want to be able to write a function that will give me the value in column Z where columns W=a, X=b, Y>=7 (in other words the value 2).</p> <p>SUMIFS can approximately do this, assuming the record I want is unique and I'm looking to return a number. For my purposes though, those assumptions won't work.</p>
[ { "answer_id": 428570, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": 2, "selected": false, "text": "strFile = Workbooks(1).FullName\nstrCon = \"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\" & strFile _\n & \";Extended...
2009/01/09
[ "https://Stackoverflow.com/questions/428414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1946/" ]
428,416
<p>I am setting up a LAMP server and would like to set Apache's umask setting to 002 so that all Apache-created files have the group write permission bit set (so members of the same group can overwrite the files).</p> <p>Does anyone know how to do this? I know that on Ubuntu, you can use the /etc/apache2/envvars file to configure the umask, but the server is running CentOS.</p> <p><strong>Update</strong> This question is related to another I asked a while ago (<a href="https://stackoverflow.com/questions/174715/linux-users-and-groups-for-a-lamp-server">Linux users and groups for a LAMP server</a>). If prefered, please update this other question with what the best set-up is to use for having a developer user on a server that can edit files created by the apache user.</p>
[ { "answer_id": 429027, "author": "Martin v. Löwis", "author_id": 33006, "author_profile": "https://Stackoverflow.com/users/33006", "pm_score": 4, "selected": true, "text": "umask /etc/init.d/ umask" }, { "answer_id": 1315147, "author": "Patrick Fisher", "author_id": 16118...
2009/01/09
[ "https://Stackoverflow.com/questions/428416", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25517/" ]
428,452
<p>Does <a href="http://blogs.msdn.com/kcwalina/archive/2005/09/26/474010.aspx#474122" rel="nofollow noreferrer">Krzysztof's</a> recommendation apply to constructors? If so, how do you implement it properly?</p> <blockquote> <p>We recommend using Collection, ReadOnlyCollection, or KeyedCollection for outputs and properties and interfaces IEnumerable, ICollection, IList for inputs. </p> </blockquote> <p>For example, </p> <pre><code>public ClassA { private Collection&lt;String&gt; strings; public Collection&lt;String&gt; Strings { get { return strings; } } public ClassA(IEnumerable&lt;String&gt; strings) { this.strings = strings; // this does not compile this.strings = strings as Collection&lt;String&gt;; // compiles (and usually runs?) } } </code></pre>
[ { "answer_id": 428465, "author": "ChrisW", "author_id": 49942, "author_profile": "https://Stackoverflow.com/users/49942", "pm_score": 4, "selected": true, "text": "Collection<String> IEnumerable<String>" }, { "answer_id": 428466, "author": "Marc Gravell", "author_id": 233...
2009/01/09
[ "https://Stackoverflow.com/questions/428452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3619/" ]
428,458
<p>I'm using SQL Server 2005 and would like to know how I can get a list of all tables with the number of records in each.</p> <p>I know I can get a list of tables using the <code>sys.tables</code> view, but I'm unable to find the count.</p> <p>Thank you</p>
[ { "answer_id": 428468, "author": "Paul Lefebvre", "author_id": 25615, "author_profile": "https://Stackoverflow.com/users/25615", "pm_score": 2, "selected": false, "text": "SELECT \n [TableName] = so.name, \n [RowCount] = MAX(si.rows) \nFROM \n sysobjects so, \n sysindexes si ...
2009/01/09
[ "https://Stackoverflow.com/questions/428458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
428,461
<p>I'm trying to read a feed from Yahoo Pipes into a Silverlight Application. I keep getting a SecurityException, which sounds like a cross domain policy problem, but Yahoo pipes, if you go through the pipes.yahooapis domain, has a cross domain policy, so should be ok. I tried the exact same code, but going to the Digg API, and it works fine (although this is rest rather than an rss feed). Could my error have nothing to do with Cross Domain policies?</p> <p>I use the following code for the web request :</p> <pre><code> WebClient wc = new WebClient(); wc.DownloadStringAsyncCompleted += new DownloadStringCompletedEventHandler(wc_DlStrCompleted); wc.DownloadStringAsync(new Uri(yahooPipesUrl)); </code></pre> <p>The exception I get is a System.Security.SecurityException.</p> <p>The url I'm trying is this one </p> <p><a href="http://pipes.yahooapis.com/pipes/pipe.run?_id=4rBri9Ef3RG8CEGLLe2fWQ&amp;_render=rss&amp;feedUrl=http://feeds.feedburner.com/follesoe" rel="nofollow noreferrer">http://pipes.yahooapis.com/pipes/pipe.run?_id=4rBri9Ef3RG8CEGLLe2fWQ&amp;_render=rss&amp;feedUrl=http://feeds.feedburner.com/follesoe</a></p>
[ { "answer_id": 428997, "author": "Michael S. Scherotter", "author_id": 27306, "author_profile": "https://Stackoverflow.com/users/27306", "pm_score": 1, "selected": false, "text": "<?xml version=\"1.0\"?>\n<!DOCTYPE cross-domain-policy SYSTEM \"http://www.adobe.com/xml/dtds/cross-domain-p...
2009/01/09
[ "https://Stackoverflow.com/questions/428461", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22712/" ]
428,470
<p>I have created an intranet for our company using PHP. The same menu appears on every page, and includes links to sensitive pages and documents (like Word files).</p> <p>Currently only in-office employees have access to the site, but we'd like to open it up to some out-of-office contractors. The catch is that I'd have to restrict access for certain content.</p> <p>I know <a href="http://www.elated.com/articles/password-protecting-your-pages-with-htaccess" rel="nofollow noreferrer">how to password-protect site directories with Apache</a>, but I'd rather hide the menu options themselves.</p> <p>How would you approach this?</p> <p><strong>Clarification</strong>: This is in an environment where everyone is logged in to our Windows network, locally or via VPN, but currently nobody has to log in to see my intranet site. The ideal solution would not require them to do anything extra, if that's possible.</p>
[ { "answer_id": 428500, "author": "Ben", "author_id": 11522, "author_profile": "https://Stackoverflow.com/users/11522", "pm_score": 2, "selected": false, "text": "$username = $_SERVER['PHP_AUTH_USER'];\n$user_id = lookup_user_id($username); // a function you write that looks up their user...
2009/01/09
[ "https://Stackoverflow.com/questions/428470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4376/" ]
428,494
<p>I hope I can explain this clearly enough. I have my main form (A) and it opens 1 child form (B) using form.Show() and a second child form (C) using form.Show(). Now I want child form B to open a form (D) using form.ShowDialog(). When I do this, it blocks form A and form C as well. Is there a way to open a modal dialog and only have it block the form that opened it?</p>
[ { "answer_id": 428556, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": false, "text": "[STAThread]\nstatic void Main() {\n Application.EnableVisualStyles();\n Button loadB, loadC;\n Form formA = ...
2009/01/09
[ "https://Stackoverflow.com/questions/428494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/343/" ]
428,513
<p>I have a page with a button that when I click, it retrieves data from a database and stores it into a datatable and binds it to a GridView. This datatable is stored in a Session variable. I also have a button that exports specified columns from the datatable to an excel file, but when I click the export button a second time, I get the following error:</p> <p>Object reference not set to an instance of an object.</p> <p>It seems to happen at this line:</p> <p>dtExport.Columns["Business"].ColumnName = "Licensee";</p> <p>I think I know why, the original column is called "Business", but when I export, I want to export the column header as Licensee, so I change the ColumnName to "Licensee"; however when I call Export a second time, it is looking for dtExport.Columns["Business"] again which it does not find, so it throws an error. Do I just need to check if the column as already been renamed to resolve this or is there another way?</p> <p>Here is the code that does the Export:</p> <pre><code>private void ExportExcel() { DataTable dtExport = Session["dtSearchResults"] as DataTable; dtExport.Columns["Business"].ColumnName = "Licensee"; List&lt;int&gt; columnSelect = new List&lt;int&gt;(); columnSelect.Add(dtExport.Columns["Licensee"].Ordinal); columnSelect.Add(dtExport.Columns["Name"].Ordinal); columnSelect.Add(dtExport.Columns["Address"].Ordinal); columnSelect.Add(dtExport.Columns["City"].Ordinal); columnSelect.Add(dtExport.Columns["State"].Ordinal); columnSelect.Add(dtExport.Columns["Zip"].Ordinal); int[] ColList = columnSelect.ToArray(); GridViewExportUtil.ExportDetails(dtExport, ColList, GridViewExportUtil.ExportFormat.Excel, string.Format("{0}_{1}-{2}-{3}{4}", "SearchResults", DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Year, ".xls")); } </code></pre> <p>When you change a ColumnName, does it persit, even if you get a new DataTable from Session again?</p>
[ { "answer_id": 428537, "author": "Shawn", "author_id": 26, "author_profile": "https://Stackoverflow.com/users/26", "pm_score": 3, "selected": true, "text": "DataTable dtExport = (Session[\"dtSearchResults\"] as DataTable).Copy();\n" }, { "answer_id": 428552, "author": "Fabriz...
2009/01/09
[ "https://Stackoverflow.com/questions/428513", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33690/" ]
428,529
<p>On this project I am working on right now, one of the newest feature requests is to output expense information which is stored into expense report that matches an Excel worksheet they already use for all of their expense reporting. </p> <p>I was curious if there was a way that I could take this excel worksheet (with all of its layout already done) and just fill in the parts that our system tracks and then serve it up as an .xls file to the user without having to do Excel Automation or any other method that requires Excel to be installed on the server.</p> <p>Note: development environment is ASP.NET 2.0</p>
[ { "answer_id": 428607, "author": "cgreeno", "author_id": 6088, "author_profile": "https://Stackoverflow.com/users/6088", "pm_score": 3, "selected": true, "text": "string ConnectionString=@\"Provider=Microsoft.Jet.OLEDB.4.0;\n Data Source=C:\\Test Projects\\Excel exampl...
2009/01/09
[ "https://Stackoverflow.com/questions/428529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22164/" ]
428,542
<p>I wonder if it is possible (and how) to provide a class in Objective-C with something like:</p> <pre><code>Person.Select(@"Name").OrderAsc(@"Name").Where(@"Id").EqualTo(1).And(@"Id").NotEqualTo(2).Load&lt;Array&gt; </code></pre> <p>That could be very handy for a project I'm doing.</p> <p>I like this way of coding present in Django &amp; SubSonic.</p>
[ { "answer_id": 429163, "author": "Ashley Clark", "author_id": 4556, "author_profile": "https://Stackoverflow.com/users/4556", "pm_score": 2, "selected": false, "text": "NSArray *people = /* array of people objects */\n\nNSPredicate *pred = [NSPredicate predicateWithFormat:@\"Id = 1 AND I...
2009/01/09
[ "https://Stackoverflow.com/questions/428542", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53185/" ]
428,553
<p><strong>EDIT</strong>: This issue has been fixed by google in gtest 1.4.0; <a href="http://code.google.com/p/googletest/issues/detail?id=114" rel="nofollow noreferrer">see the original bug report</a> for more information.</p> <p>I've recently switched to gtest for my C++ testing framework, and one great feature of it which I am presently unable to use is the ability to generate JUnit-style XML test reports, which could then be read in by our hudson build server.</p> <p>The XML output generated by the gtest test suite all looks legit:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;testsuite tests="370" failures="0" disabled="0" errors="0" time="45.61" name="AllTests"&gt; &lt;testsuite name="application" tests="7" failures="0" disabled="0" errors="0" time="8.953"&gt; &lt;testcase name="zero_tasks_on_bootup" status="run" time="0" classname="application" /&gt; ...etc. &lt;/testsuite&gt; &lt;/testsuite&gt; </code></pre> <p>I've also tried adding a JUnitReport task to my ant build script, which works fine, and generates XML like so:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;testsuite tests="370" failures="0" disabled="0" errors="0" time="45.61" name="AllTests"&gt; &lt;testsuite name="application" tests="7" failures="0" disabled="0" errors="0" time="8.953"&gt; &lt;testcase name="zero_tasks_on_bootup" status="run" time="0" classname="application" /&gt; ...etc. &lt;/testsuite&gt; &lt;/testsuite&gt; </code></pre> <p>The problem is, whenever I tell ant to publish the JUnit test results, and then point it to either the raw test result XML, or the compiled result generated in the ant JUnitReport task, hudson always complains about finding no test results there.</p> <p>I'm not a java guy, so I can't tell what's going on here, and I can't find an example of how the JUnit XML ought to look like. Can someone help to point me in the right direction?</p>
[ { "answer_id": 428575, "author": "duffymo", "author_id": 37213, "author_profile": "https://Stackoverflow.com/users/37213", "pm_score": 3, "selected": false, "text": " <target name=\"junit\" depends=\"compile-tests\" description=\"run all unit tests\">\n <mkdir dir=\"${reports}\"/...
2009/01/09
[ "https://Stackoverflow.com/questions/428553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14302/" ]
428,559
<p>Some methods in the Flex API such as <a href="http://livedocs.adobe.com/flex/3/langref/mx/managers/CursorManager.html#setCursor()" rel="nofollow noreferrer">CursorManager.setCursor(cursorClass:Class, priority:int = 2, xOffset:Number = 0, yOffset:Number = 0)</a> take a parameter of type Class for a graphic. This example lets you specify a JPG/BMP/SWF as the cursor, but the only way I know to get a Class from an image file is using [Embed] in MXML, and this needs to be done dynamically in AS3 in my case.</p> <p>There must be a standard solution? Is there a good reason these Flex classes take a Class in the first place?</p> <p>EDIT: I don't actually care about emulating the [Embed] tag's behaviour. I just want to be able to use an image file path with CursorManager. I'm sure I've seen this done in other situations, and surely the Flex people figured these things would not always be hard-coded?</p> <p>EDIT2: To further simplify the problem, what I'm ideally looking for is a way to do the following:<code>CursorManager.setCursor(someHandyFunction("myCursor.png"))</code> If this is even possible, the question is what <code>someHandyFunction</code> should do?!</p>
[ { "answer_id": 430208, "author": "Christian Nunciato", "author_id": 32129, "author_profile": "https://Stackoverflow.com/users/32129", "pm_score": 2, "selected": false, "text": "package\n{\n import flash.display.Bitmap;\n import mx.core.Application;\n\n public class MyLoadedImage...
2009/01/09
[ "https://Stackoverflow.com/questions/428559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13220/" ]
428,571
<p>The more and more advanced compilers, languages, and frameworks we have that either automate tasks, or hide certain intricacies from us, do they ultimately make us dumber programmers?</p> <p><a href="https://stackoverflow.com/users/21706/jim-c">Jim C</a> gives the following analogy of a calculator:</p> <blockquote> <p>Any one extract a square root lately, by using paper and pencil? We use a calculator or simple call a function in our favorite programming language. How many of us know what the calculator does or even the function?</p> </blockquote> <p>So why don't we all just tell our kids to forget learning math, that's what we have calculators for? Wouldn't that inherently make our kids dumber?</p>
[ { "answer_id": 428612, "author": "Dmitri Nesteruk", "author_id": 9476, "author_profile": "https://Stackoverflow.com/users/9476", "pm_score": 0, "selected": false, "text": "[DllImport]" }, { "answer_id": 428637, "author": "bradheintz", "author_id": 40093, "author_profi...
2009/01/09
[ "https://Stackoverflow.com/questions/428571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17744/" ]
428,573
<p>Does anyone know of any good tools/utilities for managing <code>Web.Config</code> files between different build/deployment environments?</p> <p>For example, I have a WCF project that in development I don't want to enable SSL, but I do want it enabled in production. I want different logging settings, different DB connection strings, different error handling, different file paths... Even some different Unity framework bindings (wire up mocks for unit testing instead of the real objects for deployment).</p> <p>Maintaining individual copies of the <code>Web.Config</code> is a pain, because adding a new web service means editing multiple files and keeping them in sync.</p> <p>I've also noticed that if you muck with the <code>Web.Config</code> too much by hand, Visual Studio will choke if you try to use the "add item" wizard to, say, add a new Web Service for WCF, since it has to modify the Web.Config to add the endpoint,a nd can't parse it any more. So I have to be careful not to invalidate the existing Web.Config.</p> <p>I also thought about just using some regex to do replacements and just building a new <code>Web.Config</code> in a pre-build command. That seems like the best option so far...</p> <p>Any other ideas? It seems like this should be a very common issue, since the <code>Web.Config</code> should probably never be the same between development and production deployments.</p> <hr> <p><strong><em>Update:</em></strong></p> <p>I decided to write a quick console app that will take all the xml files in a given directory and merge them into one, and only include certain files based on the name.</p> <p>So I can make in a directory:</p> <p><strong>WebConfig_All</strong></p> <pre><code>&lt;configuration&gt; &lt;configSections&gt; ... &lt;/configSections&gt; &lt;system.web&gt; ... &lt;/system.web&gt; &lt;/configuration&gt; </code></pre> <p><strong>connectionStrings_Debug</strong></p> <pre><code>&lt;configuration&gt; &lt;connectionStrings&gt; &lt;add name="connstr" connectionString="...dev..." /&gt; &lt;/connectionStrings&gt; &lt;/configuration&gt; </code></pre> <p><strong>connectionStrings_Release</strong></p> <pre><code>&lt;configuration&gt; &lt;connectionStrings&gt; &lt;add name="connstr" connectionString="...prod..." /&gt; &lt;/connectionStrings&gt; &lt;/configuration&gt; </code></pre> <p>Then run my command line tool, and pass in the configuration (Debug, Release, custom...) And it will merge all the files that end in <code>_All" or</code>_&lt;configuration&gt;`.</p> <p>So now I have 80% of my Web.Config in a single <code>WebConfig_All</code> file, and the 20% custom stuff in separate files per build configuration. I can then run my command line tool as a pre-build task in VisualStudio, or from NAnt, or wherever I want...</p> <p>I also made my XML merge logic good enough to handle stuff like:</p> <pre><code>&lt;x&gt; &lt;y a="1"&gt; &lt;z a="1"/&gt; &lt;/y&gt; &lt;/x&gt; </code></pre> <p>merge with</p> <pre><code>&lt;x&gt; &lt;y a="1"&gt; &lt;z a="2"/&gt; &lt;/y&gt; &lt;y a="2"/&gt; &lt;/x&gt; </code></pre> <p>results in:</p> <pre><code>&lt;x&gt; &lt;y a="1"&gt; &lt;z a="1"/&gt; &lt;z a="2"/&gt; &lt;/y&gt; &lt;y a="2"/&gt; &lt;/x&gt; </code></pre> <p>Looking good so far... :)</p> <hr> <p><em>Followup:</em></p> <p>This topic is a little old now, so I wanted to point out that VisualStudio 2010 has a feature to do web.config transformations built-in: <a href="http://msdn.microsoft.com/en-us/vstudio/Video/ff801895" rel="noreferrer">http://msdn.microsoft.com/en-us/vstudio/Video/ff801895</a></p> <p>Of course in typical Microsoft fashion of only implementing any feature 50% of the way, it only works for web projects using web deploy. There is a plugin to enable transformations in other projects, located here: <a href="http://www.hanselman.com/blog/SlowCheetahWebconfigTransformationSyntaxNowGeneralizedForAnyXMLConfigurationFile.aspx" rel="noreferrer">http://www.hanselman.com/blog/SlowCheetahWebconfigTransformationSyntaxNowGeneralizedForAnyXMLConfigurationFile.aspx</a></p> <p>You could also use a tool like <a href="http://inedo.com/buildmaster/overview" rel="noreferrer">BuildMaster</a> to manage config files (along with builds, tests, DB scripts, etc...)</p>
[ { "answer_id": 435082, "author": "Dan", "author_id": 50442, "author_profile": "https://Stackoverflow.com/users/50442", "pm_score": 5, "selected": true, "text": ".\n.\n.\n<appSettings configSource=\"config\\appSettings.config\"/>\n<nlog configSource=\"config\\nlog.config\"/>\n<application...
2009/01/09
[ "https://Stackoverflow.com/questions/428573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28278/" ]
428,617
<p>What is a <em>closure</em>? Do we have them in .NET?</p> <p>If they do exist in .NET, could you please provide a code snippet (preferably in C#) explaining it?</p>
[ { "answer_id": 428621, "author": "Dan Monego", "author_id": 32771, "author_profile": "https://Stackoverflow.com/users/32771", "pm_score": 4, "selected": false, "text": " delegate int testDel();\n\n static void Main(string[] args)\n {\n int foo = 4;\n testDel myClos...
2009/01/09
[ "https://Stackoverflow.com/questions/428617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1443363/" ]
428,630
<p>In ANSI C++, how can I assign the cout stream to a variable name? What I want to do is, if the user has specified an output file name, I send output there, otherwise, send it to the screen. So something like:</p> <pre><code>ofstream outFile; if (outFileRequested) outFile.open("foo.txt", ios::out); else outFile = cout; // Will not compile because outFile does not have an // assignment operator outFile &lt;&lt; "whatever" &lt;&lt; endl; </code></pre> <p>I tried doing this as a Macro function as well:</p> <pre><code>#define OUTPUT outFileRequested?outFile:cout OUTPUT &lt;&lt; "whatever" &lt;&lt; endl; </code></pre> <p>But that gave me a compiler error as well.</p> <p>I supposed I could either use an IF-THEN block for every output, but I'd like to avoid that if I could. Any ideas? </p>
[ { "answer_id": 428674, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 6, "selected": true, "text": "std::ostream std::ofstream std::cout std::ostream std::ofstream realOutFile;\n\nif(outFileRequested)\n realOutFile...
2009/01/09
[ "https://Stackoverflow.com/questions/428630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12576/" ]
428,634
<p>What is the difference between storing a datatable in Session vs Cache? What are the advantages and disadvantages?</p> <p>So, if it is a simple search page which returns result in a datatable and binds it to a gridview. If user 'a' searches and user 'b' searches, is it better to store it in Session since each user would most likely have different results or can I still store each of their searches in Cache or does that not make sense since there is only one cache. I guess basically what I am trying to say is that would the Cache be overwritten.</p>
[ { "answer_id": 428647, "author": "Martin Clarke", "author_id": 2422, "author_profile": "https://Stackoverflow.com/users/2422", "pm_score": 5, "selected": false, "text": "Are they going to access the data frequently? \n Is it going to change? \n Is it acceptable for user a and user b to...
2009/01/09
[ "https://Stackoverflow.com/questions/428634", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33690/" ]
428,642
<p>Can a list box have double click event on its items?</p>
[ { "answer_id": 428685, "author": "Jeff Martin", "author_id": 13100, "author_profile": "https://Stackoverflow.com/users/13100", "pm_score": 3, "selected": false, "text": "<select ondblclick = \"handler\" ... >\n" } ]
2009/01/09
[ "https://Stackoverflow.com/questions/428642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
428,643
<p>Can someone just help me refresh my mind?</p> <p>How do you specify hex values in a Visual Basic 6 / VBScript Source? </p> <p>It's not <strong>0x</strong>ABCD as it is in C++, that's what I can remember... It was something similar... But what?</p>
[ { "answer_id": 428661, "author": "lc.", "author_id": 44853, "author_profile": "https://Stackoverflow.com/users/44853", "pm_score": 2, "selected": false, "text": "&H<hex-value> &HABCD" }, { "answer_id": 428678, "author": "BobTheBuilder", "author_id": 53119, "author_pro...
2009/01/09
[ "https://Stackoverflow.com/questions/428643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/999/" ]
428,645
<p>Is it possible to use single XML file for Ruby on Rails as an ActiveRecord database? </p>
[ { "answer_id": 428699, "author": "sikachu", "author_id": 52035, "author_profile": "https://Stackoverflow.com/users/52035", "pm_score": 4, "selected": true, "text": "to_xml" } ]
2009/01/09
[ "https://Stackoverflow.com/questions/428645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27257/" ]
428,670
<p>Assume that all text box controls in my .Net Windows application created by dragging a TextBox control onto the Form editor should have the following default properties (some text box instances can override these properties) : <br></p> <p><b>Text Align: Centre <br/> Resize : As per content <br/> Dock: Left, Top and Right<br/> </b></p> <p>Now, it becomes cumbersome and manually boring task to set these properties every time it is needed. Is there any way by which these properties can be defaulted at an "Assembly level". I know that User controls will solve the problem, but that I believe that it is a costly solution, and I think that there should be a simpler and more elegant solution for this problem. Thanks</p>
[ { "answer_id": 428692, "author": "Igor Zelaya", "author_id": 22769, "author_profile": "https://Stackoverflow.com/users/22769", "pm_score": 0, "selected": false, "text": " class Class1:TextBox{\n public Class1():base(){\n this.TextAlign = HorizontalAlignment.Center;\n ...
2009/01/09
[ "https://Stackoverflow.com/questions/428670", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
428,682
<p>I'm trying to make sure my work is 508 compliant more and more these days, but noticed that VS2008 doesn't throw an error if you have a 100% table driven layout instead of css. </p> <p>I always thought that to be 508 compliant you needed to drop the "tables for layout" idea ...</p> <p>If this is true, how can I force studio to make these errors instead of warnings?</p>
[ { "answer_id": 6119074, "author": "Don Zacharias", "author_id": 90358, "author_profile": "https://Stackoverflow.com/users/90358", "pm_score": 0, "selected": false, "text": "th" } ]
2009/01/09
[ "https://Stackoverflow.com/questions/428682", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2701/" ]
428,703
<p>I have several constant defined for a webservice, and I would like to make these available to consuming client. Both the server and client are .Net.</p> <p>I think it is possible to achieve this by using enum's, but many of my constants are text string with spaces, so I would have to write an extra function to convert the enum into the equivalent text string.</p> <p>So, is there any way of defining the constants in the web service so they would then be available to the client??</p> <p>Update (Kev): I want to expose them to the client via the web service itself, not via a separate assembly. Update #2 (Paige): So if I understand you, I will then have a new List object <em>containing</em> the constants, but how does the client use that? Wouldn't it look like (roughly): dim constants as List = mywebservice.GetConstants() dim someresult as Integer = mywebservice.somefunction(constants(3)) Unless I misunderstand you, that totally defeats the point of defining constants.</p>
[ { "answer_id": 429016, "author": "Paige Watson", "author_id": 30862, "author_profile": "https://Stackoverflow.com/users/30862", "pm_score": 0, "selected": false, "text": "public class Win32Message {\n public const int WM_ACTIVATE =0x0006;\n public const int WM_ACTIVATEAPP = 0x001...
2009/01/09
[ "https://Stackoverflow.com/questions/428703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8678/" ]
428,704
<p>I use python cgi for our intranet application.</p> <p>When I measure time, the script takes 4s to finish. But after that, it still takes another 11s to show the screen in the browser. The screen is build with tables (size: 10 KB, 91 KB uncompressed) and has a large css file (5 KB, 58 KB uncompressed).</p> <p>I used YSlow and did as much optimization as suggested. Gzipping etc. Firebug Net says: 11s for the file.</p> <p>How do I measure where these last 11 seconds are needed for? Is it just the size of the HTML, or the table structure? Anyone more ideas for tweaking?</p>
[ { "answer_id": 429016, "author": "Paige Watson", "author_id": 30862, "author_profile": "https://Stackoverflow.com/users/30862", "pm_score": 0, "selected": false, "text": "public class Win32Message {\n public const int WM_ACTIVATE =0x0006;\n public const int WM_ACTIVATEAPP = 0x001...
2009/01/09
[ "https://Stackoverflow.com/questions/428704", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37986/" ]
428,715
<p>With <a href="http://en.wikipedia.org/wiki/Language_Integrated_Query#LINQ_to_SQL" rel="noreferrer">LINQ to SQL</a> in a ASP.NET MVC website I can display objects (records) from my database table.</p> <p>Now I would like to create a new object and save it back to the database.</p> <p>In my Controller, I do this:</p> <pre><code> var dataContext = new MessageDataContext(); Message message = new Message(); message.Action = "save"; message.Body = "record"; message.Parameter = "234"; </code></pre> <p>And now I want to SAVE it with something like this:</p> <pre><code>message.Save(); </code></pre> <p>Or perhaps:</p> <pre><code>dataContext.SubmitChanges(message); </code></pre> <p>But neither of these work.</p> <p>What is the syntax here to:</p> <ul> <li>add new objects and save them to the database?</li> <li>make changes on existing objects and save them to the database?</li> </ul>
[ { "answer_id": 428749, "author": "Kev", "author_id": 419, "author_profile": "https://Stackoverflow.com/users/419", "pm_score": 6, "selected": true, "text": "dataContext.Messages.InsertOnSubmit(message);\ndataContext.SubmitChanges();\n Messages" }, { "answer_id": 428757, "auth...
2009/01/09
[ "https://Stackoverflow.com/questions/428715", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
428,723
<p>I am using this statement to find all files recursively:</p> <pre><code>fileNames = System.IO.Directory.GetFiles(path, "*.*", System.IO.SearchOption.AllDirectories); </code></pre> <p>The total number of files that are found is sgnificantly lower than wehen using Windows XP Search Companion. This is not caused by hidden files, I checked that. It looks like some directories with a deep nesting level are skipped by GetFiles, but not by Windows Search Companion. GetFiles counts the same number of files as "dir /s" in a command prompt. Anyone have a clue?</p> <p>Thanks, Neeva</p>
[ { "answer_id": 428764, "author": "chakrit", "author_id": 3055, "author_profile": "https://Stackoverflow.com/users/3055", "pm_score": 0, "selected": false, "text": "dir/s/as \ndir/s/ah\n" }, { "answer_id": 429021, "author": "chakrit", "author_id": 3055, "author_profil...
2009/01/09
[ "https://Stackoverflow.com/questions/428723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
428,732
<p>I am asp.net-MVC using the BeginForm syntax in my source ciew page and I was told if you want the form to submit you have to have the submit Button at the end of the using statement. I don't want to use a Button to call the desired Action I have an Actionlink set up like so:</p> <pre><code> &lt;%=Html.ActionLink("" + CreateMore, "Create", "", new { @class = "Create" })%&gt; </code></pre> <p>and I want the form to submit when this actionlink is clicked since they are both going to the same action.. and I don't want to be able to see a Submit button:</p> <pre><code> &lt;input type="submit" /&gt; </code></pre> <p>because the link looks better</p>
[ { "answer_id": 428795, "author": "Corey Downie", "author_id": 44861, "author_profile": "https://Stackoverflow.com/users/44861", "pm_score": 4, "selected": true, "text": "$(function(){\n $('input:submit').hide(); //hide the submit button\n $('#submitLinkID').click(function(){ // bind t...
2009/01/09
[ "https://Stackoverflow.com/questions/428732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39809/" ]
428,742
<p>I have a signed cab on an aspx page. I am seeing the following inconsistent behavior. Any insights would be highly appreciated.</p> <ol> <li>On some machines, the cab is downloaded and installed on every page refresh.</li> <li>On few of those machines, the IE "install cab" dialog pops up on every page refresh, while on the others it pops up only once. </li> </ol> <p>Additional info:</p> <ol> <li>The CAB contains a .NET DLL</li> <li>The CAB is slightly large (around 30 MB), hence recurring download behavior is a pain</li> </ol> <p>Target browsers are IE6 and IE7, and the behavior is common to both!</p>
[ { "answer_id": 428795, "author": "Corey Downie", "author_id": 44861, "author_profile": "https://Stackoverflow.com/users/44861", "pm_score": 4, "selected": true, "text": "$(function(){\n $('input:submit').hide(); //hide the submit button\n $('#submitLinkID').click(function(){ // bind t...
2009/01/09
[ "https://Stackoverflow.com/questions/428742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
428,750
<p>I have a function that accepts an anonymous function as an argument and sets it to a variable (scoped) for reference. I then try to execute another function with that reference but it obviously fails since that function is out of scope.</p> <p>I was wondering if anyone knew of a simple way of passing the anonymous function straight through as an anonymous function, avoiding the scoping issue?</p> <p><strong>EDIT</strong>: To clarify, the el element is defined after the function is isolated from the arguments list. Additionally, the el element is a part of the arguments list as well. Were this code to be used by only me, I would likely have used a two argument list with the second argument being an array or hash object but unfortunately this code is going to be used by some folks who are less familiar with JS or even coding for that matter.</p> <p>Thanks for the help!</p> <p>Here is the relevant portion of my code:</p> <pre><code>locate : function(){ if ((!arguments)||(!arguments.length)) return; arguments = [].splice.call(arguments,0); //This just converts arguments into an array for (var i=0;i&lt;arguments.length;i++){ if (typeof(arguments[i])=='function'){ var tf = arguments.splice(i,1); break; }; }; if (!tf) return; JAS.Globals.eventListen('click',el,tf); } </code></pre> <p>This is abbreviated so just trust that el is defined. JAS.Globals.eventListen is just an intelligent addEventListener.</p>
[ { "answer_id": 428783, "author": "Prestaul", "author_id": 5628, "author_profile": "https://Stackoverflow.com/users/5628", "pm_score": 0, "selected": false, "text": "for (var i=0;i<arguments.length;i++){\n if (typeof(arguments[i])=='function'){\n JAS.Globals.eventListen('click',...
2009/01/09
[ "https://Stackoverflow.com/questions/428750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53402/" ]
428,766
<p>Do you know a quick way to implement method(s) from an Interface to a Class. If yes, how can you do it?</p> <p>Situation : I have an Interface used by over 15 concrete classes. I added a new method and I need to implement this new method in all concrete class.</p> <p><strong>Update</strong></p> <p>All my concrete class implement the interface and all the method fine. Later, I add a new method in the interface. To be able to compile, I need to implement the new method in all class. I do not want to go 1 by 1 on each class to implement the method. Is there a way, like "Right clicking the new method" in the interface that will go in all concrete class and all automaticly the new method. This way I will not have to open all class?</p>
[ { "answer_id": 428791, "author": "Igor Zelaya", "author_id": 22769, "author_profile": "https://Stackoverflow.com/users/22769", "pm_score": 0, "selected": false, "text": "public class MyClass:MyInteface{\n\n}\n" }, { "answer_id": 428799, "author": "aku", "author_id": 1196,...
2009/01/09
[ "https://Stackoverflow.com/questions/428766", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13913/" ]
428,798
<p>What scenarios would warrant the use of the "<a href="http://en.wikipedia.org/wiki/MapReduce" rel="noreferrer">Map and Reduce</a>" algorithm?</p> <p><br /> Is there a .NET implementation of this algorithm? </p>
[ { "answer_id": 603970, "author": "Joel Martinez", "author_id": 5416, "author_profile": "https://Stackoverflow.com/users/5416", "pm_score": 5, "selected": false, "text": "var wordOccurrences = words\n .GroupBy(w => w)\n .Select(intermediate => new\n ...
2009/01/09
[ "https://Stackoverflow.com/questions/428798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1443363/" ]
428,829
<p>Are there any heap data structure implementations out there, fibonacci, binary, or binomial?</p> <p>Reference: These are data structures used to implement priority queues, not the ones used to allocate dynamic memory. See <a href="http://en.wikipedia.org/wiki/Heap_(data_structure)" rel="noreferrer">http://en.wikipedia.org/wiki/Heap_(data_structure)</a></p> <p>Thanks, Dave</p>
[ { "answer_id": 30058236, "author": "nbilal", "author_id": 1126685, "author_profile": "https://Stackoverflow.com/users/1126685", "pm_score": 2, "selected": false, "text": "SortedSet<KeyValuePair<K,V>> Comparer Comparer class KeyValueComparer<K, V> : IComparer<KeyValuePair<K,V>> where K:IC...
2009/01/09
[ "https://Stackoverflow.com/questions/428829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6996/" ]
428,835
<p>I've been considering making a quick little iPhone web app.</p> <p>I started reading about and experimenting with the special meta tags and attributes documented at <a href="https://developer.apple.com/webapps/index.php" rel="nofollow noreferrer">Apple's Web Apps Dev Center</a>:</p> <ul> <li>viewport</li> <li>apple-mobile-web-app-capable</li> <li>apple-mobile-web-app-status-bar-style</li> <li>-webkit-border-radius</li> <li>-webkit-border-image</li> <li>autocorrect</li> <li>autocapitalize</li> <li>apple-touch-icon</li> <li>-webkit-text-size-adjust</li> </ul> <p>This got me thinking that there must be a good guide I can follow to best mimic the default style and behavior of the device's non-web applications.</p> <p>I then stumbled upon the <a href="http://joehewitt.com/" rel="nofollow noreferrer">Joe Hewitt</a>'s <a href="http://code.google.com/p/iui/" rel="nofollow noreferrer">iUI project</a>.</p> <p>It's got two demos that are pretty impressive:</p> <ul> <li><a href="http://iui.googlecode.com/svn/tags/REL-current/samples/music.html" rel="nofollow noreferrer">Music Demo</a></li> <li><a href="http://iui.googlecode.com/svn/tags/REL-current/samples/digg/index.html" rel="nofollow noreferrer">Digg Demo</a></li> </ul> <p>Are there alternative libraries, guides, or other resources I should use?</p>
[ { "answer_id": 3214267, "author": "felixlaumon", "author_id": 387831, "author_profile": "https://Stackoverflow.com/users/387831", "pm_score": 1, "selected": false, "text": "jQTouch" }, { "answer_id": 19208015, "author": "caktux", "author_id": 2639784, "author_profile"...
2009/01/09
[ "https://Stackoverflow.com/questions/428835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/83/" ]
428,836
<p>I'm using this code for login, but when I enter a username and password it just loads the page and the login page again is displayed. Why does this happen?</p> <pre><code>&lt;?php session_start(); if(!isset($_POST['username']) || !isset($_POST['password']) || empty($_POST['username']) || empty($_POST['password'])) { ?&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt; &lt;title&gt;Welcome to yachts database &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/title&gt; &lt;script type="text/javascript"&gt; function validate() { var username=document.getElementById("username").value; var password=document.getElementById("password").value; if(username.length==0) { alert("Please enter your user name"); document.getElementById("username").focus(); document.getElementById("username").select(); return false; } if(password.length==0) { alert("Please enter your password"); document.getElementById("password").focus(); document.getElementById("password").select(); return false; } submitOK="false"; } &lt;/script&gt; &lt;?php include("styles.txt"); ?&gt; &lt;/head&gt; &lt;body onLoad="self.focus();document.login.username.focus()"&gt; &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt; &lt;center&gt;&lt;font size=5 color=blue&gt;&lt;b&gt;University of ....... &lt;/b&gt;&lt;/font&gt;&lt;/center&gt; &lt;center&gt;&lt;font size=5 color=blue&gt;&lt;b&gt;Yachts Database Project&lt;/b&gt;&lt;/font&gt;&lt;/center&gt; &lt;form name="login" method="post" action="&lt;?php $_SERVER['PHP_SELF'];?&gt;" onSubmit="return validate()"&gt; &lt;table width="350" border="1" align="center" cellpadding=0 cellspacing=0 bgcolor=#ffffff bordercolor=#ffffff&gt; &lt;tr&gt; &lt;th colspan=2 height=30 bgcolor=#050E8C&gt;&lt;font size=4 color=#ffffff&gt;Please, enter user name and password&lt;/font&gt;&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th bgcolor=#E0E0FF&gt;&lt;font size=4 color=#2020ff&gt;User name&lt;/font&gt;&lt;/th&gt; &lt;td bgcolor=#E0E0FF align=center&gt;&lt;input type="text" name="username" id="username" size="30"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th bgcolor=#E0E0FF&gt;&lt;font size=4 color=#2020ff&gt;Password&lt;/font&gt;&lt;/th&gt; &lt;td bgcolor=#E0E0FF align=center&gt;&lt;input type="password" name=" password" id="password" size="30"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td bgcolor=#E0E0FF colspan=2 align=right&gt;&lt;input type="submit" name="login" value="&amp;nbsp;&amp;nbsp;Login&amp;nbsp;&amp;nbsp;"&gt;&amp;nbsp;&amp;nbsp;&lt;input type="reset" name="reset" value="&amp;nbsp;&amp;nbsp;Reset&amp;nbsp;&amp;nbsp;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=register.php class=links&gt;Register&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; &lt;?php } else { $connect= mysql_connect("localhost","root") or die ("Sorry, Can not connect to database"); mysql_select_db("login") or die (mysql_error()); $username1=$_POST['username']; $password1=$_POST['password']; if($username1 &amp;&amp; $password1) { $query="SELECT * FROM users WHERE username='$username1' AND password='$password1'"; $result=mysql_query($query,$connect) or die(mysql_error()); $rowcount=mysql_num_rows($result); } if($rowcount) { //$_SESSION['username']=$rowcount['username']; $user1=$username1; $pass1=$password1; session_register("user1"); session_register("pass1"); header("location: main.php"); } else { ?&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt; &lt;title&gt;Welcome to yachts database &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/title&gt; &lt;script type="text/javascript"&gt; function validate() { var username=document.getElementById("username").value; var password=document.getElementById("password").value; if(username.length==0) { alert("Please enter your user name"); document.getElementById("username").focus(); document.getElementById("username").select(); return false; } if(password.length==0) { alert("Please enter your password"); document.getElementById("password").focus(); document.getElementById("password").select(); return false; } submitOK="false"; } &lt;/script&gt; &lt;?php include("styles.txt"); ?&gt; &lt;/head&gt; &lt;body onLoad="self.focus();document.login.username.focus()"&gt; &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt; &lt;center&gt;&lt;font size=5 color=blue&gt;&lt;b&gt;University of ....... &lt;/b&gt;&lt;/font&gt;&lt;/center&gt; &lt;center&gt;&lt;font size=5 color=blue&gt;&lt;b&gt;Yachts Database Project&lt;/b&gt;&lt;/font&gt;&lt;/center&gt; &lt;form name="login" method="post" action="&lt;?php echo $_SERVER['PHP_SELF'];?&gt;" onSubmit="return validate()"&gt; &lt;table width="350" border="1" align="center" cellpadding=0 cellspacing=0 bgcolor=#ffffff bordercolor=#ffffff&gt; &lt;tr&gt; &lt;th colspan=2 height=30 bgcolor=#050E8C&gt;&lt;font size=4 color=#ffffff&gt;Please, enter user name and password&lt;/font&gt;&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th bgcolor=#E0E0FF&gt;&lt;font size=4 color=#2020ff&gt;User name&lt;/font&gt;&lt;/th&gt; &lt;td bgcolor=#E0E0FF align=center&gt;&lt;input type="text" name="username" id="username" size="30"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th bgcolor=#E0E0FF&gt;&lt;font size=4 color=#2020ff&gt;Password&lt;/font&gt;&lt;/th&gt; &lt;td bgcolor=#E0E0FF align=center&gt;&lt;input type="password" name=" password" id="password" size="30"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td bgcolor=#E0E0FF colspan=2 height=30 align=right&gt;&lt;input type="submit" name="login" value="&amp;nbsp;&amp;nbsp;Login&amp;nbsp;&amp;nbsp;"&gt;&amp;nbsp;&amp;nbsp;&lt;input type="reset" name="reset" value="&amp;nbsp;&amp;nbsp;Reset&amp;nbsp;&amp;nbsp;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=register.php class=links&gt;Register&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td bgcolor=#E0E0FF colspan=2 height=30 align=center&gt;&lt;font size=3 color=#ff0000&gt;User name or Password wrong!&lt;/font&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; &lt;?php } } ?&gt; </code></pre>
[ { "answer_id": 428910, "author": "Sean Edwards", "author_id": 53315, "author_profile": "https://Stackoverflow.com/users/53315", "pm_score": 0, "selected": false, "text": "<input type=\"password\" name=\" password\" id=\"password\" size=\"30\">\n" }, { "answer_id": 428922, "au...
2009/01/09
[ "https://Stackoverflow.com/questions/428836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
428,842
<p>just wondering if anyone could suggest why I might be getting an error? I'm currently trying to execute a macro in a workbook by calling the Application.Run method that the interop exposes.</p> <p>It's currently throwing the following COM Exception:</p> <pre><code>{System.Runtime.InteropServices.COMException (0x800A03EC): Cannot run the macro Macro1'. The macro may not be available in this workbook or all macros may be disabled. </code></pre> <p>I've put the containing workbook in a trusted location, set all of the security settings to their minimum values, and trusted programmatic access to my object model. I'm entirely out of ideas and Google's failed me so far!</p> <p>Has anyone done this, or can you suggest anything which I could try?</p> <p>Many thanks!</p>
[ { "answer_id": 22752362, "author": "Swab.Jat", "author_id": 1664410, "author_profile": "https://Stackoverflow.com/users/1664410", "pm_score": 0, "selected": false, "text": "App.Run(\"Abc.xlsm!CalcSomething\");\n\nApp.Run(\"MainModule!CalcSomething\");\n\nApp.Run(\"Abc.xlsm.CalcSomething\...
2009/01/09
[ "https://Stackoverflow.com/questions/428842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4019/" ]
428,862
<p>I've got a record management web application which displays a master record on one screen and AJAXes dynamically built editors into an editor div, which I've used JQuery to make draggable. That works.</p> <p>Even though the div isn't a window, I thought it might be a nice idea to make it act a bit more like one, so I coded in a "close" button. The structure looks like this:</p> <pre><code>&lt;div id="editor"&gt; &lt;div id="draghandle" /&gt; &lt;div id="closebutton" /&gt; &lt;div id="editorbody" /&gt; &lt;/div&gt; </code></pre> <p>Editorbody is variable-dimension depending on what people are trying to enter.</p> <p>Draghandle's width is set at 100% of editor. Closebutton is set up in CSS as <code>float:right</code>.</p> <p>My problem is that, in IE6 and IE7, the close button floats too far right. It's always against the right edge of the window, no matter where I drag the editor div around to. In Firefox and Safari it looks like I expected it to - the window is as wide as editorbody and closebutton sits in the top right corner.</p> <p>I'm not particularly attached to float:right, just looking for a way to set up the CSS that'll give me the same result across all browsers. Any ideas?</p> <h3>"Screenshots"</h3> <p>Here's a mockup of what I'd like to do on jsbin (thanks, redsquare)</p> <p><a href="http://jsbin.com/ikaka" rel="nofollow noreferrer" title="sample code">sample code</a></p> <p>I'm working with legally sensitive information so I can't provide screenshots of the app. I have, however, taken some shots and blocked out the text and interface, leaving only the window structure.</p> <p><a href="http://i278.photobucket.com/albums/kk93/Glazius_bucket/InIE7.png" rel="nofollow noreferrer" title="how it looks in IE7">how it looks in IE7</a></p> <p><a href="http://i278.photobucket.com/albums/kk93/Glazius_bucket/InFirefox.png" rel="nofollow noreferrer" title="how it looks in Firefox 3">how it looks in firefox 3</a></p>
[ { "answer_id": 428872, "author": "bchhun", "author_id": 48500, "author_profile": "https://Stackoverflow.com/users/48500", "pm_score": 0, "selected": false, "text": "* + html #editor #closebutton /* IE7 */, * html #editor #closebutton /* IE6 */ {margin-right: 100px;} // insert whatever va...
2009/01/09
[ "https://Stackoverflow.com/questions/428862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34384/" ]
428,870
<p>Consider the following code:</p> <pre><code> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init If Page.IsPostBack Then If ViewState("test") IsNot Nothing Then Response.Write((ViewState("test").ToString)) Else Response.Write("Viewstate is empty.") End If Else ViewState("test") = "viewstate is working." End If End Sub </code></pre> <p>This code doesn't work on a particular page in my application. Viewstate is not turned off in the Page directive. I can't figure out what's going on. : \</p> <p>Oh i just figured it out. See if you notice it.</p> <blockquote> <p>.&lt;</p> </blockquote>
[ { "answer_id": 428876, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<configuration>\n <appSettings>\n <Pages EnableViewState=\"false\" />\n </appSettings>\n</configuration>\n" }, { ...
2009/01/09
[ "https://Stackoverflow.com/questions/428870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26/" ]
428,884
<p>I'm looking for the easiest way to play a MP3 file in C. I am looking for either a library, in which I could just call the function on the filename, or an executable that will just run and quit. Please suggest.</p>
[ { "answer_id": 429040, "author": "friol", "author_id": 23034, "author_profile": "https://Stackoverflow.com/users/23034", "pm_score": 5, "selected": false, "text": "#include <conio.h>\n#include \"inc/fmod.h\"\n\nFSOUND_SAMPLE* handle;\n\nint main ()\n{\n // init FMOD sound system\n FS...
2009/01/09
[ "https://Stackoverflow.com/questions/428884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53429/" ]
428,895
<p>I have a python application that relies on a file that is downloaded by a client from a website.</p> <p>The website is not under my control and has no API to check for a "latest version" of the file.</p> <p>Is there a simple way to access the file (in python) via a URL and check it's date (or size) without having to download it to the clients machine each time?</p> <p><strong>update:</strong> Thanks to those who mentioned the"last-modified" date. This is the correct parameter to look at.</p> <p>I guess I didn't state the question well enough. How do I do this from a python script? I want to application to check the file and then download it if (last-modified date &lt; current file date).</p>
[ { "answer_id": 428986, "author": "Gumbo", "author_id": 53114, "author_profile": "https://Stackoverflow.com/users/53114", "pm_score": 2, "selected": false, "text": "creation-date" }, { "answer_id": 52595452, "author": "JBB", "author_id": 9367412, "author_profile": "htt...
2009/01/09
[ "https://Stackoverflow.com/questions/428895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30862/" ]
428,896
<p>Does anyone know if the IsNullOrEmpty bug is fixed in 3.0 or later? I currently came across the (NullReferenceException) bug in 2.0 and I have found documentation stating that is supposed to be fixed in the next release, but no definitive answer.</p>
[ { "answer_id": 428935, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "using System;\n\nclass Test\n{\n static void Main(string[] args)\n {\n Console.WriteLine(\"starting\");\n ...
2009/01/09
[ "https://Stackoverflow.com/questions/428896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53388/" ]
428,908
<p>So maybe I want to have values between -1.0 and 1.0 as floats. It's clumsy having to write this and bolt it on top using extension methods IMO.</p>
[ { "answer_id": 428912, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 4, "selected": false, "text": ".NextDouble()" }, { "answer_id": 428975, "author": "chakrit", "author_id": 3055, "author_profile":...
2009/01/09
[ "https://Stackoverflow.com/questions/428908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51816/" ]
428,916
<p>The only field I cannot grab is the <code>description</code> field from our AD. The error is:</p> <blockquote> <p><em>Cannot get the data of the row from the OLE DB provider "ADsDSOObject" for linked server "ADSI". Could not convert the data value due to reasons other than sign mismatch or overflow.</em></p> </blockquote> <p>Is there some datatype I can use to handle the object it is trying to return?</p>
[ { "answer_id": 9925620, "author": "TheSavo", "author_id": 1143782, "author_profile": "https://Stackoverflow.com/users/1143782", "pm_score": 0, "selected": false, "text": "Description ADsDSOObject ADO For Each Do until ... EOF" } ]
2009/01/09
[ "https://Stackoverflow.com/questions/428916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18431/" ]
428,918
<p>I'm working with a date in this format: <code>yyyy-mm-dd</code>.</p> <p>How can I increment this date by one day?</p>
[ { "answer_id": 428942, "author": "krosenvold", "author_id": 23691, "author_profile": "https://Stackoverflow.com/users/23691", "pm_score": 6, "selected": false, "text": "add(Calendar.DATE, 1);" }, { "answer_id": 428947, "author": "Ross", "author_id": 29173, "author_pro...
2009/01/09
[ "https://Stackoverflow.com/questions/428918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48094/" ]
428,920
<p>I would like to start tomcat (Web Server) as a privileged user, and then bring it back to an unprivileged user once it has started. Is there a way to do this programatically, or in general with Linux?</p> <p>Thanks.</p>
[ { "answer_id": 429120, "author": "geocar", "author_id": 37507, "author_profile": "https://Stackoverflow.com/users/37507", "pm_score": 3, "selected": true, "text": "-Djava.net.preferIPv4Stack=true" }, { "answer_id": 429303, "author": "Alnitak", "author_id": 6782, "auth...
2009/01/09
[ "https://Stackoverflow.com/questions/428920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/400427/" ]
428,927
<p>i can't find a way to do multiple row tabs with ASP.net ajax tab control. I also can't find a tutorial or example on using CSS to make multiple row of tabs.</p> <p>In case you don't understand what i'm looking for here is a image of what i'm looking for <a href="http://bp1.blogger.com/_WCGCQYWEaxs/Rq1c2bLNMDI/AAAAAAAAABU/0sKw_CrKLL4/s1600-h/dsd.jpg" rel="nofollow noreferrer">http://bp1.blogger.com/_WCGCQYWEaxs/Rq1c2bLNMDI/AAAAAAAAABU/0sKw_CrKLL4/s1600-h/dsd.jpg</a></p> <p>Can someone give me a link on how to achieve multiple row of tabs?</p>
[ { "answer_id": 428945, "author": "Oli", "author_id": 12870, "author_profile": "https://Stackoverflow.com/users/12870", "pm_score": 3, "selected": true, "text": "li float:left ul li <ul id=\"nav\">\n <li><a href=\"#\">link</a></li>\n <li><a href=\"#\">link</a></li>\n <li><a href=...
2009/01/09
[ "https://Stackoverflow.com/questions/428927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28647/" ]
428,933
<p>When I insert records into a long table,I am getting the error "Conversion failed when converting the varchar value 'NULL' to data type int" How can I determine which column errors out?</p> <p>The table has many fields and millions of records. Each iteration takes 10 minutes to bomb when I try to insert "NULL" string into integer column somewhere. I thought SQL server can tell me exact name of the column :(</p>
[ { "answer_id": 428978, "author": "Jamie Barrows", "author_id": 53353, "author_profile": "https://Stackoverflow.com/users/53353", "pm_score": 2, "selected": false, "text": "ISNULL(col1,0)\n" }, { "answer_id": 428992, "author": "George Mastros", "author_id": 1408129, "a...
2009/01/09
[ "https://Stackoverflow.com/questions/428933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
428,957
<p>According to the <a href="http://www.timeanddate.com/calendar/custom.html?year=2008&amp;country=22&amp;month=12&amp;typ=2&amp;months=2&amp;display=0&amp;space=0&amp;fdow=1&amp;wno=1&amp;hol=" rel="noreferrer">official (gregorian) calendar</a>, the week number for 29/12/2008 is 1, because after the last day of week 52 (i.e. 28/12) there are three or less days left in the year. Kinda weird, but OK, rules are rules.</p> <p>So according to this calendar, we have these boundary values for 2008/2009</p> <ul> <li>28/12 is week 52</li> <li>29/12 is week 1</li> <li>1/1 is week 1</li> <li>8/1 is week 2</li> </ul> <p>C# offers a GregorianCalendar class, that has a function <code>GetWeekOfYear(date, rule, firstDayOfWeek)</code>. </p> <p>The parameter <code>rule</code> is an enumeration with 3 possible values: <code>FirstDay, FirstFourWeekDay, FirstFullWeek</code>. From what I've understood I should go for the <code>FirstFourWeekDay</code> rule, but I tried all of them just in case.</p> <p>The last parameter informs which week day should be considered the first day of the week, according to that calendar it's Monday so Monday it is.</p> <p>So I fired up a quick and dirty console app to test this:</p> <pre><code>using System; using System.Globalization; namespace CalendarTest { class Program { static void Main(string[] args) { var cal = new GregorianCalendar(); var firstWeekDay = DayOfWeek.Monday; var twentyEighth = new DateTime(2008, 12, 28); var twentyNinth = new DateTime(2008, 12, 29); var firstJan = new DateTime(2009, 1, 1); var eightJan = new DateTime(2009, 1, 8); PrintWeekDays(cal, twentyEighth, firstWeekDay); PrintWeekDays(cal, twentyNinth, firstWeekDay); PrintWeekDays(cal, firstJan, firstWeekDay); PrintWeekDays(cal, eightJan, firstWeekDay); Console.ReadKey(); } private static void PrintWeekDays(Calendar cal, DateTime dt, DayOfWeek firstWeekDay) { Console.WriteLine("Testing for " + dt.ToShortDateString()); Console.WriteLine("--------------------------------------------"); Console.Write(CalendarWeekRule.FirstDay.ToString() + "\t\t"); Console.WriteLine(cal.GetWeekOfYear(dt, CalendarWeekRule.FirstDay, firstWeekDay)); Console.Write(CalendarWeekRule.FirstFourDayWeek.ToString() + "\t"); Console.WriteLine(cal.GetWeekOfYear(dt, CalendarWeekRule.FirstFourDayWeek, firstWeekDay)); Console.Write(CalendarWeekRule.FirstFullWeek.ToString() + "\t\t"); Console.WriteLine(cal.GetWeekOfYear(dt, CalendarWeekRule.FirstFullWeek, firstWeekDay)); Console.WriteLine("--------------------------------------------"); } } } </code></pre> <p>... and this what I get</p> <pre><code>Testing for 28.12.2008 -------------------------------------------- FirstDay 52 FirstFourDayWeek 52 FirstFullWeek 51 -------------------------------------------- Testing for 29.12.2008 -------------------------------------------- FirstDay 53 FirstFourDayWeek 53 FirstFullWeek 52 -------------------------------------------- Testing for 01.01.2009 -------------------------------------------- FirstDay 1 FirstFourDayWeek 1 FirstFullWeek 52 -------------------------------------------- Testing for 08.01.2009 -------------------------------------------- FirstDay 2 FirstFourDayWeek 2 FirstFullWeek 1 -------------------------------------------- </code></pre> <p>So as we see, none of the combinations above matches the official calendar (if you are in a hurry, just see that 29/12 never gets week #1).</p> <p>What am I getting wrong here? Maybe there's something glaring that I am missing? (it's Friday and late work hours here in Belgium, bear with me ;))</p> <p>Edit: Maybe I should explain: what I need is a function that works for any year, returning the same results as the gregorian calendar I linked. So no special workarounds for 2008. </p>
[ { "answer_id": 429018, "author": "Mike Scott", "author_id": 43649, "author_profile": "https://Stackoverflow.com/users/43649", "pm_score": -1, "selected": false, "text": "FirstFourDayWeek if ( weekNumber > 52 )\n weekNumber = 1;\n" }, { "answer_id": 435681, "author": "Sco...
2009/01/09
[ "https://Stackoverflow.com/questions/428957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/79101/" ]
428,959
<p>I am doing a little debugging, and so I want to log the eventArgs value</p> <p>I have a simple line that basically does:</p> <pre><code>logLine = "e.Value: " + IIf(e.Value Is Nothing, "", e.Value.ToString()) </code></pre> <p>The way I understand the IIF function, if the e.Value is Nothing (null) then it should return the empty string, if not it should return the .ToString of the value. I am, however getting a NullReferenceException. This doesn't make sense to me.</p> <p>Any idea's?</p>
[ { "answer_id": 428968, "author": "Philip Fourie", "author_id": 11123, "author_profile": "https://Stackoverflow.com/users/11123", "pm_score": 2, "selected": false, "text": "IIF" }, { "answer_id": 428969, "author": "bdukes", "author_id": 2688, "author_profile": "https:/...
2009/01/09
[ "https://Stackoverflow.com/questions/428959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18821/" ]
428,967
<p>Let's for a moment assume that you're programming in a language that uses camelcase words for identifiers, by convention. All you Ruby types with your underscore-separated method names get to sit this one out.</p> <p>What approach do you take to capitalising the letters after the first when your name contains an acronym? For example, would you call a method createSQLBuffer or createSqlBuffer? Do you have a policy in place dictating what to do in this situation? Moreover, can anyone link me some articles advacating one or the other specifically, or in fact anything that covers this at all?</p> <p>I know it's not really a big deal, but for some reason I sometimes come across a method/class/variable capitalised one way and thing it would look more natural the other. The strange thing is that I'm not even sure it's consistent; it would not surprise me to discover that I like all uppercase for certain names, and lowercased for others.</p> <p>Anyone want to share their opinions on this?</p>
[ { "answer_id": 428990, "author": "bdukes", "author_id": 2688, "author_profile": "https://Stackoverflow.com/users/2688", "pm_score": 2, "selected": false, "text": "createSqlBuffer createIOBuffer" }, { "answer_id": 429017, "author": "JeeBee", "author_id": 17832, "author...
2009/01/09
[ "https://Stackoverflow.com/questions/428967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45664/" ]
429,002
<p>The documentation seems to suggest that in order for me to import Java classes into JRuby, that they must be in a JAR file:</p> <p>"In order to use resources within a jar file from JRuby the jar file must either be on the classpath or you can make it available with the require method" (<a href="http://wiki.jruby.org/wiki/Calling_Java_from_JRuby#Require_a_jar_file_to_make_resources_in_the_jar_discoverable_within_JRuby" rel="nofollow noreferrer">http://wiki.jruby.org/wiki/Calling_Java_from_JRuby#Require_a_jar_file_to_make_resources_in_the_jar_discoverable_within_JRuby</a>)</p> <p>Is it at all possible to import .class files directly?</p> <p>Thanks!</p>
[ { "answer_id": 429092, "author": "bjnortier", "author_id": 35448, "author_profile": "https://Stackoverflow.com/users/35448", "pm_score": 4, "selected": true, "text": "require 'java'\nrequire 'target/foo/Bar'\n\nmodule Foo\n include_package 'foo'\nend\n\nputs Foo::Bar.new\n foo.Bar@1582a...
2009/01/09
[ "https://Stackoverflow.com/questions/429002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35448/" ]
429,005
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/1284381/why-is-it-a-bad-practice-to-return-generated-html-instead-of-json-or-is-it">Why is it a bad practice to return generated HTML instead of JSON? Or is it?</a> </p> </blockquote> <p>It seems to me that any interception of this could provide instant trouble because anyone could just send any HTML/script back to the client.</p> <p>The only reason I'm interested in doing this is because of the huge pain it is for front-end developers every time there's a DOM structure/CSS change so you now have to go figure out where in the Javascript HTML building process you may have to update. </p> <p>How do you guys deal with this? Are there things I can do to reduce any risk or is ut just straight up bad idea?</p>
[ { "answer_id": 429072, "author": "James A. Rosen", "author_id": 1190, "author_profile": "https://Stackoverflow.com/users/1190", "pm_score": 5, "selected": true, "text": "eval eval" }, { "answer_id": 429106, "author": "Luca Matteis", "author_id": 50394, "author_profile...
2009/01/09
[ "https://Stackoverflow.com/questions/429005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6705/" ]
429,022
<p>I'm interested in providing a general "I'm making an ajax call" notification ... similar to how most of google's services have a little red loading notification when it's busy making a call. Is there a way of globally tapping into some event that I can use to show/hide that notification if there is an active call?</p> <p>We're not using the jQuery ajax apis, we're using the MVC Ajax stuff ... such as Ajax.BeginForm, or Ajax.ActionLink.</p>
[ { "answer_id": 429085, "author": "Darin Dimitrov", "author_id": 29407, "author_profile": "https://Stackoverflow.com/users/29407", "pm_score": 3, "selected": false, "text": "jQuery.ajax({\n url: 'url_to_send_ajax_request_to',\n beforeSend: function(XMLHttpRequest) {\n jQuery(...
2009/01/09
[ "https://Stackoverflow.com/questions/429022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5416/" ]
429,035
<p>I'm looking for a method to resize the page width Crystal Reports gives me to place fields in my .rpt file.</p> <p>So far I have discovered if I right click on the report, select 'design'/'printer setup', I can select the size of the paper I want the report to print out on. If I select 'Orientation/Landscape' I can increase the width of the page and I can place more fields on the report.</p> <p>My goal: Place all of my fields on my report (around 25 of them) and export the data to Excel. Right now I do not have enough width to place all of the fields in the .rpt file.</p> <p>Is there a way to increase the width of the page to an arbitrary number?</p>
[ { "answer_id": 31573659, "author": "ariscris", "author_id": 213310, "author_profile": "https://Stackoverflow.com/users/213310", "pm_score": -1, "selected": false, "text": "var repDoc = new ReportDocument();\nrepDoc.Load(rpt_path);\n\nISCDReportClientDocument clientDoc = repDoc.ReportClie...
2009/01/09
[ "https://Stackoverflow.com/questions/429035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7561/" ]
429,039
<p>Hi im learning LISP and well, all day i program php for a living, so i was messing around with php.net and found the eval function... so i started playing around!</p> <p>I would love to know more about how to use eval to do crazy stuff, i know you can make functions with this and everything... but i wanted to ask why the next code wont work:</p> <pre><code>$var = "echo \"FOZZ\";"; for($i = 0; $i &lt; 100; $i++) $var = "eval(\"".$var."\");"; print $var; eval($var); </code></pre> <p>Also what other stuff is interesting with eval!</p>
[ { "answer_id": 429073, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 0, "selected": false, "text": "$var eval() eval()" } ]
2009/01/09
[ "https://Stackoverflow.com/questions/429039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47846/" ]
429,068
<p>I'm having a hard time trying to get my team comfortable with interface based programming ... anyone have some suggestions?</p>
[ { "answer_id": 429109, "author": "Andrew Hare", "author_id": 34211, "author_profile": "https://Stackoverflow.com/users/34211", "pm_score": 2, "selected": false, "text": "class User\n{\n public String GetFirstName() { return \"foo\"; }\n}\n\nclass App\n{\n void Run()\n {\n ...
2009/01/09
[ "https://Stackoverflow.com/questions/429068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2701/" ]
429,076
<p>In my code, when a button is clicked the progress bar is set to marquee and then my BackgroundWorker is called but when the BackgroundWorker is called the progress bar freezes or disappears. I use the BackgroundWorker to seperate the RefreshReport method of the ReportViewer from the UI thread. Any help is appreciated. Thanks!</p> <pre><code> Private Sub btnOtherReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOtherReport.Click rvReport.ProcessingMode = ProcessingMode.Remote rvReport.ShowParameterPrompts = False rvReport.ServerReport.ReportServerUrl = New Uri("REPORT_SERVER_URL") rvReport.ServerReport.ReportPath = "REPORT_PATH" rvReport.BackColor = Color.White BackgroundWorker1.RunWorkerAsync() End Sub Private Sub BackgroundWorker1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork RefreshReport() End Sub Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted pbReports.Style = ProgressBarStyle.Blocks pbReports.Value = 100 End Sub Public Sub RefreshReport() rvReport.BeginInvoke(New MethodInvoker(AddressOf rvReport.RefreshReport)) End Sub </code></pre>
[ { "answer_id": 429393, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 3, "selected": true, "text": ".BeginInvoke() RefreshReport() BackgroundWorker.DoWork() rvReport.RefreshReport() Private Sub BackgroundWorker1_DoWork(...
2009/01/09
[ "https://Stackoverflow.com/questions/429076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/299/" ]
429,104
<p>I'm writng a small application in PHP + MySQL and have come to the point where there is an object that has a couple (8 so far but not expected to increase) of flags associated with it. The flags are pretty much unrelated although there are some combinations that would make no sense. The object represents a row in a DB (has some methods for saving/loading it too) so the question also applies to choosing a storage method.</p> <p>The question is - <strong>how to best represent them both in code and DB?</strong> I can think of several ways:</p> <p>One way to store them in the DB is in a single integer field as bitwise flags. On the PHP side then I can imagine several ways of representing them:</p> <ul> <li>Simply export the integer value and define a couple of flag constants; Let every place that needs the flags do their own bitwise magic;</li> <li>Define class methods <code>GetFlag()</code>, <code>SetFlag()</code> and <code>UnsetFlag()</code> that do the bitwise magic on a private integer variable; These methods would then be passed one of the flag constants as a parameters.</li> <li>Define methods <code>GetFlagA()</code>, <code>GetFlagB()</code> etc. (along with Set and Unset counterparts);</li> <li>Define a bunch of member variables that each represent one flag; Set them on loading from the DB and gather them when saving.</li> <li>Create a member variable that is an array of all the flag values. Use predefined constants as array indices to access each flag. Also fill/gather the array on loading/saving.</li> </ul> <p>Another way would be to store them in the DB as separate BIT fields. In PHP that would then translate to several member variables. IMHO this would complicate the queries.</p> <p>And the last way would be to define anothed table for all the flags and an intermediate table for many-to-many relationship between flags and the original objects. IMHO the messiest of all solutions, considering that there would be only like 3 tables otherwise.</p> <p>I haven't done much PHP development so I don't know what the best practice would be. In C# I would probably store them as bitwise flags and make properties that do the bitwise magic on a private integer. But PHP doesn't have properties (I'm using latest stable version)...</p>
[ { "answer_id": 430440, "author": "Preston", "author_id": 25213, "author_profile": "https://Stackoverflow.com/users/25213", "pm_score": 6, "selected": true, "text": "CREATE TABLE mytable (myfield BIT(8));\n INSERT INTO mytable VALUES (b'00101000');\n SELECT * FROM mytable;\n+------------+...
2009/01/09
[ "https://Stackoverflow.com/questions/429104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41360/" ]
429,112
<p>Quite often, in programming we get situations where <code>null</code> checks show up in particularly large numbers. I'm talking about things like:</p> <pre><code>if (doc != null) { if (doc.Element != null) { ... and so on } else throw new Exception("Element cannot be null"); } else { throw new Exception("document cannot be null"); } </code></pre> <p>Basically, the whole thing turns into an unreadable nightmare, so I'm wondering: is there an easier way to describe what I'm trying to do above? (In addition to null checks, I get things like <code>string.IsNullOrEmpty</code> from time to time.)</p> <p><strong>Accepted answer:</strong> I accepted the answer that has <a href="http://blog.getpaint.net/2008/12/06/a-fluent-approach-to-c-parameter-validation/" rel="noreferrer">this link</a> because the approach described is innovative, and is precisely what I want. Thanks Shawn!</p>
[ { "answer_id": 429132, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 4, "selected": false, "text": "doc.Element.whatever(\"foo\");\n" }, { "answer_id": 429134, "author": "Dan Monego", "author_id": 32771, ...
2009/01/09
[ "https://Stackoverflow.com/questions/429112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9476/" ]
429,114
<p>I have the following situation I think would be best to show in sample program code. I have a Java class that extends <code>JPanel</code>. In this class are two objects which are two more <code>JPanels</code>. In one of the <code>JPanel</code> objects is a <code>JTable</code> object. I added a listener to this <code>JTable</code> that detects a double click. When it detects a double click, I want to fire a method in the top class. How do I reference this method in Java?</p> <pre><code>public class TopPanel extends JPanel { JPanel OnePanel; JPanel TwoPanel; public void MethodToFire; } public class OnePanel extends JPanel { JTable TheTable; } public class TheTable extends JTable { public TheTable { this.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){ if (e.getClickCount() == 2){ SYNTAX CALLING THE METHOD IN TopPanel } } } ); } } </code></pre>
[ { "answer_id": 429158, "author": "James Schek", "author_id": 17871, "author_profile": "https://Stackoverflow.com/users/17871", "pm_score": 3, "selected": false, "text": "TheTable.this.callMethod() TopPanel TheTable mouseClicked(...) {\n TopTable t = (TopTable)TheTable.this.getParent();...
2009/01/09
[ "https://Stackoverflow.com/questions/429114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41615/" ]
429,125
<p>Yes, I do understand the difference between them. What I want to know is: why OVERRIDE a method? What is the good in doing it? In case of overload: the only advantage is you haven't to think in different names to functions?</p>
[ { "answer_id": 429142, "author": "lc.", "author_id": 44853, "author_profile": "https://Stackoverflow.com/users/44853", "pm_score": 2, "selected": false, "text": "Divide(float, float) Divide(int, int)" }, { "answer_id": 429236, "author": "Johannes Schaub - litb", "author_i...
2009/01/09
[ "https://Stackoverflow.com/questions/429125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50754/" ]
429,136
<p>I have these tables:</p> <pre><code>customer -------- customer_id int name varchar(255) order ----- order_id int customer_id int discount boolean </code></pre> <p>I can get the number of orders made by each customer with a query like:</p> <pre><code>select c.id, count(o.order_id) from customer c left join order as o using c.customer_id = o.customer_id group by 1 </code></pre> <p>Alternatively, I can get the number of discounted orders made by each customer with:</p> <pre><code>select c.id, count(o.order_id) from customer c left join order as o using c.customer_id = o.customer_id and o.discount = true group by 1 </code></pre> <p>But I can't figure out a way to get both in a single query. I've tried the following:</p> <pre><code>select c.id, count(o.order_id), count(o2.order_id) from customer c left join order as o using c.customer_id = o.customer_id left join order as o2 using c.customer_id = o2.customer_id and o2.discount = true group by 1 </code></pre> <p>But it didn't work. Is it possible to calculate both in a single (MySql) query?</p> <p>Cheers, Don</p>
[ { "answer_id": 429166, "author": "Paul Dixon", "author_id": 6521, "author_profile": "https://Stackoverflow.com/users/6521", "pm_score": 3, "selected": true, "text": "select c.id, count(o.order_id),sum(if(o.discount,1,0))\nfrom customer c \nleft join order as o using c.customer_id = o.cus...
2009/01/09
[ "https://Stackoverflow.com/questions/429136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]