qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
360,232
<p>Building on <a href="https://stackoverflow.com/questions/318553/getting-emacs-to-untabify-when-saving-files">Getting Emacs to untabify when saving certain file types (and only those file types)</a> , I'd like to run a hook to untabify my C++ files when I start modifying the buffer. I tried adding hooks to untabify the buffer on load, but then it untabifies all my writable files that are autoloaded when emacs starts.</p> <p>(For those that wonder why I'm doing this, it's because where I work enforces the use of tabs in files, which I'm happy to comply with. The problem is that I mark up my files to tell me when lines are too long, but the regexp matches the number of characters in the line, not how much space the line takes up. 4 tabs in a line can push it far over my 132 character limit, but the line won't be marked appropriately. Thus, I need a way to tabify and untabify automatically.)</p>
[ { "answer_id": 360396, "author": "Alex B", "author_id": 6180, "author_profile": "https://Stackoverflow.com/users/6180", "pm_score": 1, "selected": false, "text": "(defun untabify-buffer ()\n \"Untabify current buffer\"\n (interactive)\n (untabify (point-min) (point-max)))\n\n(defun un...
2008/12/11
[ "https://Stackoverflow.com/questions/360232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45425/" ]
360,234
<p>I want to read an specific xml node and its value for example</p> <pre><code>&lt;customers&gt; &lt;name&gt;John&lt;/name&gt; &lt;lastname&gt;fetcher&lt;/lastname&gt; &lt;/customer&gt; </code></pre> <p>and my code behind should be some thing like this (I don't know how it should be though):</p> <pre><code>Response.Write(xml.Node[&quot;name&quot;].Value) </code></pre> <p>As I said it is just an example because I don't know how to do it.</p>
[ { "answer_id": 360250, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "document.Descendant(\"name\").Value\n" }, { "answer_id": 360258, "author": "Rich", "author_id": 13449, ...
2008/12/11
[ "https://Stackoverflow.com/questions/360234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44852/" ]
360,241
<p>I have a visual studio 2005 solution which has a web application and a class library project. The web application has a reference to the library project. I'd like the library project's code documentation XML to output to the web application's bin folder, along with the library's DLL. I can't seem to find any easy way of doing this.</p>
[ { "answer_id": 369002, "author": "Mike Strother", "author_id": 21320, "author_profile": "https://Stackoverflow.com/users/21320", "pm_score": 0, "selected": false, "text": "copy \"$(TargetDir)$(TargetName).xml\" \"$(SolutionDir)MyWebProject1\\bin\\$(TargetName).xml\"\ncopy \"$(TargetDir)$...
2008/12/11
[ "https://Stackoverflow.com/questions/360241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21320/" ]
360,254
<p>If I try to use a closure on an event handler the compiler complains with :</p> <p>Incompatible types: "method pointer and regular procedure"</p> <p>which I understand.. but is there a way to use a clouser on method pointers? and how to define if can?</p> <p>eg : </p> <pre><code>Button1.Onclick = procedure( sender : tobject ) begin ... end; </code></pre> <p>Thanks!</p>
[ { "answer_id": 388690, "author": "Hans-Eric", "author_id": 39348, "author_profile": "https://Stackoverflow.com/users/39348", "pm_score": 3, "selected": false, "text": "Button1.OnClick := procedure( sender : tobject ) of object begin\n ...\nend;\n" }, { "answer_id": 410745, "...
2008/12/11
[ "https://Stackoverflow.com/questions/360254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45439/" ]
360,259
<p>Can anyone recommend a decent SFTP library for use with Windows C++ apps? If a cross-platform one is available then all the better, but it's not essential. It's for use with a commercial application, so paying for something isn't an issue.</p> <p>I am using the superb <a href="http://www.codeproject.com/KB/MFC/UltimateTCPIP.aspx" rel="noreferrer">Ultimate TCP/IP</a> library which supports FTP-S but not SFTP (yeh, I know, confusing isn't it!).</p> <p>I've come across the <a href="http://www.chilkatsoft.com/ssh-sftp-c++.asp" rel="noreferrer">Chilkat</a> library, which looks very good, but wondered if there are any others that people have used.</p>
[ { "answer_id": 26006716, "author": "Desphilboy", "author_id": 2023625, "author_profile": "https://Stackoverflow.com/users/2023625", "pm_score": 3, "selected": false, "text": "main()\n{\npSFTPConnector sshc = new SFTPConnector(L\".\\\\\", L\"127.0.0.1\", 22, L\"sftpuser\",L\"sftppasswor...
2008/12/11
[ "https://Stackoverflow.com/questions/360259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9236/" ]
360,265
<p><a href="http://leepoint.net/notes-java/data/expressions/22compareobjects.html" rel="nofollow noreferrer">http://leepoint.net/notes-java/data/expressions/22compareobjects.html</a></p> <blockquote> <p>It turns out that defining equals() isn't trivial; in fact it's moderately hard to get it right, especially in the case of subclasses. The best treatment of the issues is in Horstmann's Core Java Vol 1.</p> </blockquote> <p>If equals() must always be overridden, then what is a good approach for not being cornered into having to do object comparison? What are some good "design" alternatives?</p> <p>EDIT:</p> <p>I'm not sure this is coming across the way that I had intended. Maybe the question should be more along the lines of "Why would you want to compare two objects?" Based upon your answer to that question, is there an alternative solution to comparison? I don't mean, a different implementation of equals. I mean, not using equality at all. I think the key point is to start with that question, why would you want to compare two objects.</p>
[ { "answer_id": 360301, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": 1, "selected": false, "text": "Integer a = Integer.valueOf( 2 );\nInteger b = Integer.valueOf( 2 );\n\na == b \n" }, { "answer_id": 360305, ...
2008/12/11
[ "https://Stackoverflow.com/questions/360265", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
360,273
<p>Is there a built in way in SQL Server 2005 to audit things specifically like deleting a stored procedure? Is there a history table that I can query? We have a mystery sproc that has disappeared a few times now.</p>
[ { "answer_id": 28206602, "author": "Daniel Calbimonte", "author_id": 4504629, "author_profile": "https://Stackoverflow.com/users/4504629", "pm_score": 0, "selected": false, "text": " CREATE TRIGGER ddl_drop_procedure \n ON DATABASE \n FOR DROP_PROCEDURE\n AS \n RAISERROR ('Yo...
2008/12/11
[ "https://Stackoverflow.com/questions/360273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12064/" ]
360,277
<p>So for viewing a current object's state at runtime, I really like what the Visual Studio Immediate window gives me. Just doing a simple</p> <pre><code>? objectname </code></pre> <p>Will give me a nicely formatted 'dump' of the object. </p> <p><strong>Is there an easy way to do this in code, so I can do something similar when logging?</strong></p>
[ { "answer_id": 360302, "author": "Ricardo Villamil", "author_id": 19314, "author_profile": "https://Stackoverflow.com/users/19314", "pm_score": 3, "selected": false, "text": "MyObject\n Property1 = value\n Property2 = value2\n OtherObject\n OtherProperty = value ...\n" }...
2008/12/11
[ "https://Stackoverflow.com/questions/360277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19020/" ]
360,288
<p>Has anyone attempted this? Is it possible, and if so, what kind of problems will I run into if I try to accomplish it?</p>
[ { "answer_id": 18719053, "author": "alecho", "author_id": 1112785, "author_profile": "https://Stackoverflow.com/users/1112785", "pm_score": 2, "selected": false, "text": "$components" } ]
2008/12/11
[ "https://Stackoverflow.com/questions/360288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39086/" ]
360,289
<p>I a have a multithread application (MIDAS) that makes uses of windows messages to communicate with itself.</p> <p>MAIN FORM</p> <p>The main form receives windows messages sent by the RDM LogData(‘DataToLog’) </p> <p>Because windows messages are used they have the following attributes </p> <ol> <li>Received messages are Indivisible</li> <li>Received messages are Queued in the order they are sent </li> </ol> <p><strong>QUESTION:</strong></p> <p>Can you Suggest a better way doing this without using windows messages ?</p> <p><strong>MAIN FORM CODE</strong> </p> <pre><code>const UM_LOGDATA = WM_USER+1002; type TLogData = Record Msg : TMsgNum; Src : Integer; Data : String; end; PLogData = ^TLogData; TfrmMain = class(TForm) // private procedure LogData(var Message: TMessage); message UM_LOGDATA; public // end; procedure TfrmMain.LogData(var Message: TMessage); var LData : PLogData; begin LData := PLogData(Message.LParam); SaveData(LData.Msg,LData.Src,LData.Data); Dispose(LData); end; </code></pre> <p><strong>RDM CODE</strong></p> <pre><code>procedure TPostBoxRdm.LogData(DataToLog : String); var WMsg : TMessage; LData : PLogData; Msg : TMsgNum; begin Msg := MSG_POSTBOX_RDM; WMsg.LParamLo := Integer(Msg); WMsg.LParamHi := Length(DataToLog); new(LData); LData.Msg := Msg; LData.Src := 255; LData.Data := DataToLog; WMsg.LParam := Integer(LData); PostMessage(frmMain.Handle, UM_LOGDATA, Integer(Msg), WMsg.LParam); end; </code></pre> <p>EDIT:</p> <p>Why I want to get rid of the windows messages:</p> <ul> <li>I would like to convert the application into a windows service </li> <li>When the system is busy – the windows message buffer gets full and things slows down</li> </ul>
[ { "answer_id": 360613, "author": "gabr", "author_id": 4997, "author_profile": "https://Stackoverflow.com/users/4997", "pm_score": 2, "selected": false, "text": "OtlComm.pas" }, { "answer_id": 360819, "author": "Mick", "author_id": 12458, "author_profile": "https://Sta...
2008/12/11
[ "https://Stackoverflow.com/questions/360289", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17560/" ]
360,307
<p>I was reading a review of the new Intel Atom 330, where they noted that Task Manager shows 4 cores - two physical cores, plus two more simulated by Hyperthreading.</p> <p>Suppose you have a program with two threads. Suppose also that these are the only threads doing any work on the PC, everything else is idle. What is the probability that the OS will put both threads on the same core? This has huge implications for program throughput.</p> <p>If the answer is anything other than 0%, are there any mitigation strategies other than creating more threads?</p> <p>I expect there will be different answers for Windows, Linux, and Mac OS X. <hr> Using <a href="https://stackoverflow.com/questions/360307/multicore-hyperthreading-how-are-threads-distributed#360326">sk's answer</a> as Google fodder, then following the links, I found the <a href="http://msdn.microsoft.com/en-us/library/ms683194(VS.85).aspx" rel="nofollow noreferrer">GetLogicalProcessorInformation</a> function in Windows. It speaks of "logical processors that share resources. An example of this type of resource sharing would be hyperthreading scenarios." This implies that <a href="https://stackoverflow.com/questions/360307/multicore-hyperthreading-how-are-threads-distributed#360385">jalf</a> is correct, but it's not quite a definitive answer. </p>
[ { "answer_id": 3358040, "author": "bart", "author_id": 230899, "author_profile": "https://Stackoverflow.com/users/230899", "pm_score": 3, "selected": false, "text": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Diagnostics;\nusing System.Runtime.Inte...
2008/12/11
[ "https://Stackoverflow.com/questions/360307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5987/" ]
360,321
<p>Do you write <code>createSomething()</code> or <code>addSomething()</code>?</p> <p>Do you write <code>readSomething()</code>, <code>getSomething()</code> or <code>fetchSomething()</code>?</p> <p>This is totally a petty gripe. In the meeting room we refer to it as CRUD, but in actual code, it's becoming AGUD.</p> <p>What's your naming convention of preference? Does it matter?</p> <p>thnx.</p>
[ { "answer_id": 7358359, "author": "Bilal Ahmad", "author_id": 936265, "author_profile": "https://Stackoverflow.com/users/936265", "pm_score": 2, "selected": false, "text": "readXXXX()" } ]
2008/12/11
[ "https://Stackoverflow.com/questions/360321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45441/" ]
360,334
<p>Hey I was wondering if there were any way to upload images in ASP? I am working on my school's server and I don't really know what is installed and what isn't I Googled a little and came up with "Persits.Upload.1" I tried to instantiate the object with this line:</p> <p><code>Set Upload = Server.CreateObject("Persits.Upload.1")</code></p> <p>It gave me this error, </p> <blockquote> <p>Server object error 'ASP 0177 : 800401f3'<br> Server.CreateObject Failed </p> </blockquote> <p>Am I to assume the component is not installed on the server and/or what should I do for uploading images?</p> <p>Thanks</p>
[ { "answer_id": 360363, "author": "Xetius", "author_id": 274, "author_profile": "https://Stackoverflow.com/users/274", "pm_score": 1, "selected": false, "text": "<INPUT type=file name=filename>" }, { "answer_id": 15159844, "author": "Matteo Bononi 'peorthyr'", "author_id":...
2008/12/11
[ "https://Stackoverflow.com/questions/360334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27620/" ]
360,338
<p>As the question states, i am a C#/Java programmer who is interested in (re)learning C++. As you know C#/Java have a somewhat strict project file structure (especially Java). I find this structure to be very helpful and was wondering if it is a) good practice to do a similar structure in a C++, b) if so, what is the best way to setup it up?</p> <p>i know there is the basic 'headers' and 'source' folders, but is there a better way?</p>
[ { "answer_id": 360372, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 3, "selected": true, "text": "namespace foo { \nnamespace bar {\n // declare/define the stuff (classes, functions) here\n} } // foo::ba...
2008/12/11
[ "https://Stackoverflow.com/questions/360338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18811/" ]
360,348
<p>I have an existing bare git repository located in /home/myaccount/git/project. I am currently using it over ssh from my local machine without any problems. I want to add a second user on the server which only shall access to this git repository (maybe move the repo outside my account folder?). How? Using latest version of git and ubuntu on slicehost.</p> <p>I have this setup: user: sleepyhead user: developer1 group: git. both sleepyhead and developer1 are members of this group repository /home/sleepyhead/git/project1</p> <p>I want to: move repository to a proper place, either /home/git/project1 or /usr/local/git/project1. What is recommended? developer1 should permissions to read and write project1 with git. no other permissions should be given.</p> <p>I do not know how to properly set the permissions and to restrict developer1 to only have access using git to project1.</p>
[ { "answer_id": 361164, "author": "orip", "author_id": 37020, "author_profile": "https://Stackoverflow.com/users/37020", "pm_score": 4, "selected": false, "text": "~/.ssh/authorized_keys" } ]
2008/12/11
[ "https://Stackoverflow.com/questions/360348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50718/" ]
360,365
<p>Currently I am saving a UIImage to the photos album using UIImageWriteToSavedPhotosAlbum, which works fine.</p> <p>Is there a way to then open the Photos app showing the just-saved photo? (I assume my app must close before opening Photos, which is fine.)</p> <p>Simply opening the Photos app to the Saved Photos Album would be a not-quite-as-good alternative if the above isn't possible.</p> <p>Thanks.</p>
[ { "answer_id": 380862, "author": "lostInTransit", "author_id": 46297, "author_profile": "https://Stackoverflow.com/users/46297", "pm_score": 2, "selected": false, "text": "UIImagePickerViewController" } ]
2008/12/11
[ "https://Stackoverflow.com/questions/360365", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44003/" ]
360,368
<p>There must be an easy way to do this, but somehow I can wrap my head around it. The best way I can describe what I want is a lambda function for a class. I have a library that expects as an argument an uninstantiated version of a class to work with. It then instantiates the class itself to work on. The problem is that I'd like to be able to dynamically create versions of the class, to pass to the library, but I can't figure out how to do it since the library expects an uninstantiated version. The code below describes the problem:</p> <pre><code>class Double: def run(self,x): return x*2 class Triple: def run(self,x): return x*3 class Multiply: def __init__(self,mult): self.mult = mult def run(self,x): return x*self.mult class Library: def __init__(self,c): self.c = c() def Op(self,val): return self.c.run(val) op1 = Double op2 = Triple #op3 = Multiply(5) lib1 = Library(op1) lib2 = Library(op2) #lib3 = Library(op3) print lib1.Op(2) print lib2.Op(2) #print lib3.Op(2) </code></pre> <p>I can't use the generic Multiply class, because I must instantiate it first which breaks the library "AttributeError: Multiply instance has no <strong>call</strong> method". Without changing the Library class, is there a way I can do this?</p>
[ { "answer_id": 360403, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 2, "selected": false, "text": "__call__" }, { "answer_id": 360415, "author": "Moe", "author_id": 3051, "author_profile": "https://St...
2008/12/11
[ "https://Stackoverflow.com/questions/360368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27478/" ]
360,369
<p>Hey. I have an object that has a string property called BackgroundColor. This string is the hexidecimal representation of a color. I cannot change this object.</p> <p>I'm binding a collection of these objects to a listView. What I would like to do is bind the background of the listview's row to the BackgroundColor property of the object that is displayed in the row.</p> <p>What is the best way to to this?</p>
[ { "answer_id": 360579, "author": "Robert Macnee", "author_id": 19273, "author_profile": "https://Stackoverflow.com/users/19273", "pm_score": 3, "selected": false, "text": "<Grid xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\n xmlns:sys=\"clr-namespace:System;as...
2008/12/11
[ "https://Stackoverflow.com/questions/360369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20518/" ]
360,373
<p>I remember seeing in a sample a while ago that it is possible to break up a windsor configuration file into multiple ones and reference them from the app.config in a way that they get parsed automatically.</p> <p>Of course I didn't bookmark it and now I can't find it and my Windsor.Config.xml file is creeping up on 600 lines. Can anyone tell me how to do this?</p> <p>Currently I just instantiate my container directly off the file: IWindsorContainer container = new WindsorContainer("Windsor.Config.xml");</p> <p>But I'd like to break it up, reference the xml in the app.config and have it included automatically. </p>
[ { "answer_id": 360394, "author": "Watson", "author_id": 25807, "author_profile": "https://Stackoverflow.com/users/25807", "pm_score": 2, "selected": true, "text": "<include uri=\"file://Configurations/facilities.xml\">\n<include uri=\"file://Configurations/services.xml\">\n" } ]
2008/12/11
[ "https://Stackoverflow.com/questions/360373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
360,378
<p>This relates to Composite Application Guidance for WPF, or Prism.</p> <p>I have one "MainRegion" in my shell. My various modules will be loaded into this main region. I can populate a list of available modules in a menu and select them to load. On the click of the menu I do:</p> <pre><code>var module = moduleEnumerator.GetModule(moduleName); moduleLoader.Initialize(new[] { module }); </code></pre> <p>At the first time all works ok, because the Initialize() methods of the modules are executed, but after Module1, Module2 and Module3 are initialized, nothing happens when I click to load Module2 again.</p> <p>My question: how can I activate a module on demand, after its initialize method has been executed?</p> <p>Thank you for your help!</p>
[ { "answer_id": 897219, "author": "NJE", "author_id": 90576, "author_profile": "https://Stackoverflow.com/users/90576", "pm_score": 3, "selected": true, "text": "// Get a view from the container.\nvar view = Container.Resolve<MyView>();\n\n// Get the region.\nvar region = RegionManager.Re...
2008/12/11
[ "https://Stackoverflow.com/questions/360378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28029/" ]
360,392
<p>We are scheduling a task programatically. However, the executable to be scheduled could be installed in a path that has spaces. ie c:\program Files\folder\folder\folder program\program.exe</p> <p>When we provide this path as a parameter to the Tasjk Scheduler it fails to start because it cannot find the executable. It obviously needs to be enclosed in quotes ("). </p> <p>The problem we are having is that even when we enclosed the path in quotes when we pass it as a paramemter (cmd + "\" + path + "\") it still doesnt include the quotes in the path that is used to schedule the task.</p> <p>Anyone have any idea how to force the quotes to be included in the path?</p> <p><strong>EDIT: Answer to comment:</strong></p> <p>We had the same idea, and here is the problem. the ~1 format is based on the index of the folder, so if say you had these 3 folders:</p> <pre><code>Program Applications Program Files Program Zips </code></pre> <p>then the path would be: progra~2</p> <p>Now if you say there are over 10 of those folders, the path could possibly look like: progr~12.</p> <p>Now, not to say this is not a viable solution, but having to count the folders to find the right one and then use the index to build the path is a little cumbersome and not very clean IMO.</p> <p>We are hoping there is a better way.</p> <p><strong>EDIT 2: Added applicable code snippet</strong></p> <p>You asked for the code: this is how we build the Args string that we pass to the scheduler:</p> <pre><code>string args = "/CREATE /RU SYSTEM /SC " + taskSchedule + " /MO " + taskModifier + " /SD " + taskStartDate + " /ST " + taskStartTime + " /TN " + taskName + " /TR \"" + taskSource + "\""; </code></pre> <p>where taskSource is the path to the application.</p>
[ { "answer_id": 360690, "author": "TheSoftwareJedi", "author_id": 18941, "author_profile": "https://Stackoverflow.com/users/18941", "pm_score": 3, "selected": true, "text": "string args = \"/CREATE /RU SYSTEM /SC \" + taskSchedule + \" /MO \" + taskModifier + \" /SD \" + taskStartDate + \...
2008/12/11
[ "https://Stackoverflow.com/questions/360392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42518/" ]
360,402
<p>I have a csv imported into my Hyperion v8.3 bqy file. I have some custom columns and a pivot already created. I just want to refresh the data. In the past, I would hit Process Current and it would direct me to my computer and I could select the csv file to update from. Now it will not do that. It doesn't go to my computer at all.</p> <p>Any ideas?</p>
[ { "answer_id": 360690, "author": "TheSoftwareJedi", "author_id": 18941, "author_profile": "https://Stackoverflow.com/users/18941", "pm_score": 3, "selected": true, "text": "string args = \"/CREATE /RU SYSTEM /SC \" + taskSchedule + \" /MO \" + taskModifier + \" /SD \" + taskStartDate + \...
2008/12/11
[ "https://Stackoverflow.com/questions/360402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
360,409
<p>I have a XML File like that</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;Configurations&gt; &lt;EmailConfiguration&gt; &lt;userName&gt;xxxx&lt;/userName&gt; &lt;password&gt;xxx&lt;/password&gt; &lt;displayName&gt;xxxxx&lt;/displayName&gt; &lt;hostAddress&gt;xxxx&lt;/hostAddress&gt; &lt;sslEnable&gt;xxx&lt;/sslEnable&gt; &lt;port&gt;xxx&lt;/port&gt; &lt;/EmailConfiguration&gt; &lt;LogConfiguration&gt; &lt;logEnable&gt;true&lt;/logEnable&gt; &lt;generalEnable&gt;true&lt;/generalEnable&gt; &lt;warningEnable&gt;true&lt;/warningEnable&gt; &lt;errorEnable&gt;true&lt;/errorEnable&gt; &lt;/LogConfiguration&gt; &lt;/Configurations&gt; </code></pre> <p>and I am using it as config file for my code and I want to retrieve their values (innerText) like that</p> <pre><code>bool logEnable = value comes from XML (logEnable) bool warningEnable = value comes from XML (warningEnable) bool errorEnable = value comes from XML (errorEnable) bool generalEnable = value comes from XML (generalEnable) </code></pre> <p>So how can I read their values to assign them to the boolean variables and if I wanted to change one of their values with false, How would I be able to do that ?</p> <p>Thanks...</p> <p>Regards...</p> <p>P.s : If you wrote more explanatory codes, It would be so much appreciated.</p> <p>Thanks again...</p>
[ { "answer_id": 360518, "author": "NerdFury", "author_id": 6146, "author_profile": "https://Stackoverflow.com/users/6146", "pm_score": 4, "selected": true, "text": "public class Options\n{\n public string UserName { get; set; }\n public string Password { get; set; }\n public stri...
2008/12/11
[ "https://Stackoverflow.com/questions/360409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44852/" ]
360,421
<p>Is there a way to define styles for a combination of classes? For example, I'd like my HTML to look like this, but the output to render in the appropriate color:</p> <pre><code>&lt;span class="red"&gt;Red Text&lt;/span&gt;&lt;br/&gt; &lt;span class="green"&gt;Green Text&lt;/span&gt;&lt;br/&gt; &lt;span class="red green"&gt;Yellow Text&lt;/span&gt;&lt;br/&gt; </code></pre> <p><strong>Edit:</strong> The above seems to be confusing people when it was just an example; so here is another example:</p> <pre><code>&lt;style&gt; .style1 { background-color: #fff; } .style2 { background-color: #eee; } .style1.highlight { color: red; } .style2.highlight { color: blue; } &lt;/style&gt; &lt;ul&gt; &lt;li class="action style1"&gt;Do Action 1&lt;/li&gt; &lt;li class="action style2"&gt;Do Action 2&lt;/li&gt; &lt;li class="action style1 highlight"&gt;Do Action 1&lt;/li&gt; &lt;li class="action style2 highlight"&gt;Do Action 2&lt;/li&gt; &lt;/ul&gt; &lt;script language="javascript" type="text/javascript"&gt; $("li.action").bind("click", function(e) { e.preventDefault(); // Do some stuff $(this).addClass("highlight"); $(this).unbind("click"); }); &lt;/script&gt; </code></pre> <p>Again, this is just an <em>example</em>, so don't get hung up on alternating elements or anything like that. What I'm trying to avoid is having to duplicate the bind function for each different styleN or having to write an elseif structure that checks for each styleN class. Unfortunately this code doesn't work in IE 6 or 7 - the highlighted text for both .style1 and .style2 elements end up being blue.</p>
[ { "answer_id": 360450, "author": "ieure", "author_id": 45224, "author_profile": "https://Stackoverflow.com/users/45224", "pm_score": 4, "selected": true, "text": "span.red.green { color: yellow; }\n" }, { "answer_id": 360451, "author": "Tarik", "author_id": 44852, "au...
2008/12/11
[ "https://Stackoverflow.com/questions/360421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3420/" ]
360,422
<p>I'm trying to use reflection to get a property from a class. Here is some sample code of what I'm seeing:</p> <pre><code> using System.Reflection; namespace ConsoleApplication { class Program { static void Main(string[] args) { PropertyInfo[] tmp2 = typeof(TestClass).GetProperties(); PropertyInfo test = typeof(TestClass).GetProperty( "TestProp", BindingFlags.Public | BindingFlags.NonPublic); } } public class TestClass { public Int32 TestProp { get; set; } } } </code></pre> <p>When I trace through this, this is what I see:</p> <ul> <li>When I fetch all properties using <code>GetProperties()</code>, the resulting array has one entry, for property <code>TestProp</code>.</li> <li>When I try to fetch <code>TestProp</code> using <code>GetProperty()</code>, I get null back.</li> </ul> <p>I'm a little stumped; I haven't been able to find anything in the MSDN regarding <code>GetProperty()</code> to explain this result to me. Any help?</p> <p>EDIT:</p> <p>If I add <code>BindingFlags.Instance</code> to the <code>GetProperties()</code> call, no properties are found, period. This is more consistent, and leads me to believe that <code>TestProp</code> is not considered an instance property for some reason. </p> <p>Why would that be? What do I need to do to the class for this property to be considered an instance property?</p>
[ { "answer_id": 360427, "author": "Andrew Rollings", "author_id": 40410, "author_profile": "https://Stackoverflow.com/users/40410", "pm_score": 5, "selected": true, "text": "BindingFlags.Instance" }, { "answer_id": 360438, "author": "bruno conde", "author_id": 31136, "...
2008/12/11
[ "https://Stackoverflow.com/questions/360422", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8169/" ]
360,431
<p>For this dropdownlist in HTML:</p> <pre><code>&lt;select id="countries"&gt; &lt;option value="1"&gt;Country&lt;/option&gt; &lt;/select&gt; </code></pre> <p>I would like to open the list (the same as left-clicking on it). Is this possible using JavaScript (or more specifically jQuery)?</p>
[ { "answer_id": 360448, "author": "Andreas Grech", "author_id": 44084, "author_profile": "https://Stackoverflow.com/users/44084", "pm_score": 2, "selected": false, "text": "onclick" }, { "answer_id": 360474, "author": "ieure", "author_id": 45224, "author_profile": "htt...
2008/12/11
[ "https://Stackoverflow.com/questions/360431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/343/" ]
360,449
<p>I'm trying to run a 3d array but the code just crashes in windows when i run it, here's my code;</p> <pre><code>#include &lt;iostream&gt; using namespace std; int main(){ int myArray[10][10][10]; for (int i = 0; i &lt;= 9; ++i){ for (int t = 0; t &lt;=9; ++t){ for (int x = 0; x &lt;= 9; ++t){ myArray[i][t][x] = i+t+x; } } } for (int i = 0; i &lt;= 9; ++i){ for (int t = 0; t &lt;=9; ++t){ for (int x = 0; x &lt;= 9; ++t){ cout &lt;&lt; myArray[i][t][x] &lt;&lt; endl; } } } system("pause"); } </code></pre> <p>can someone throw me a quick fix / explanation</p>
[ { "answer_id": 360463, "author": "David Norman", "author_id": 34502, "author_profile": "https://Stackoverflow.com/users/34502", "pm_score": 5, "selected": true, "text": "for (int x = 0; x <= 9; ++t){\n" }, { "answer_id": 360595, "author": "JohnMcG", "author_id": 1674, ...
2008/12/11
[ "https://Stackoverflow.com/questions/360449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33061/" ]
360,454
<p>Back in college, only the use of pseudo code was evangelized more than OOP in my curriculum. Just like commenting (and other preached 'best practices'), I found that in crunch time psuedocode was often neglected. So my question is...who actually uses it a lot of the time? Or do you only use it when an algorithm is really hard to conceptualize entirely in your head? I'm interested in responses from everyone: wet-behind-the-ears junior developers to grizzled vets who were around back in the punch card days.</p> <p>As for me personally, I mostly only use it for the difficult stuff.</p>
[ { "answer_id": 360490, "author": "Chris Cudmore", "author_id": 18907, "author_profile": "https://Stackoverflow.com/users/18907", "pm_score": 1, "selected": false, "text": "public void doBigJob( params )\n{\n doTask1( params);\n doTask2( params);\n doTask3( params);\n}\nprivate v...
2008/12/11
[ "https://Stackoverflow.com/questions/360454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25664/" ]
360,466
<p>This UpdatePanel is contained by an UserControl. When the LinkButton is pressed arow should be added in another GridView. When an user is logged in this control is working well. The problems appears when an user is not logged in and try to push that button. No event triggers. Someone suggested me to give a permission for accessing this control in web.config. That didn't work. Anyone has another idea?</p> <pre><code>&lt;asp:UpdatePanel runat="server" UpdateMode="Conditional" EnableViewState="true" ID="IngredientsUpdatePanel"&gt; &lt;ContentTemplate&gt; &lt;asp:ObjectDataSource ID="sourceIngredients" runat="server" SelectMethod="GetAll"&gt; &lt;/asp:ObjectDataSource&gt; &lt;asp:GridView ID="Ingredients" AllowPaging="true" runat="server" DataKeyNames="IngredientId" EnableViewState="true" DataSourceID="sourceIngredients" PageSize="5" AutoGenerateColumns="false" HorizontalAlign="Center" OnSelectedIndexChanged="Ingredients_SelectedIndexChanged"&gt; &lt;RowStyle HorizontalAlign="Center" /&gt; &lt;HeaderStyle Font-Bold="true" ForeColor="Black" /&gt; &lt;Columns&gt; &lt;asp:TemplateField HeaderText="Ingrediente" ItemStyle-Font-Size="10"&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID="lblId" Text='&lt;%# Bind("IngredientId") %&gt;' Visible="false" runat="server"/&gt; &lt;asp:Label ID="lblPrice" Text='&lt;%# Bind("Price") %&gt;' Visible="false" runat="server"/&gt; &lt;asp:Label ID="lblDescr" Text='&lt;%# Bind("Description") %&gt;' Visible="false" runat="server"/&gt; &lt;asp:Label ID="lblName" Text='&lt;%# Bind("Name") %&gt;' Visible="false" runat="server"/&gt; &lt;asp:Label ID="lblPict" Text='&lt;%# Bind("Picture") %&gt;' Visible="false" runat="server"/&gt; &lt;div style="text-align:left;"&gt; &lt;img id="img" style="float:right;" src='&lt;%# Eval("Picture") %&gt;' height="75" runat="server" alt="Picture" /&gt; &lt;b&gt; &lt;%# Eval("Name") %&gt; &lt;/b&gt; &lt;br /&gt; &lt;br /&gt; Price: &lt;b&gt;&lt;%# Eval("Price") %&gt;&lt;/b&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;/div&gt; &lt;hr /&gt; &lt;div style="text-align:left;"&gt; &lt;b&gt;Description&lt;/b&gt; &lt;/div&gt; &lt;div style="width:300px;"&gt; &lt;%# Eval("Description") %&gt; &lt;/div&gt; &lt;br /&gt; &lt;asp:LinkButton Enabled="true" runat="server" Text="Add" CommandName="Select" ID="cmdAdd" /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;/ContentTemplate&gt; </code></pre> <p></p>
[ { "answer_id": 365009, "author": "Ionel Bratianu", "author_id": 45468, "author_profile": "https://Stackoverflow.com/users/45468", "pm_score": 2, "selected": true, "text": " <Columns>\n <asp:ButtonField Text=\"Add\" CommandName=\"Select\" /> \n <asp:TemplateField>\n ...
2008/12/11
[ "https://Stackoverflow.com/questions/360466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45468/" ]
360,467
<p>I have a table that looks a bit like this actors(forename, surname, stage_name);</p> <p>I want to update stage_name to have a default value of</p> <pre><code>forename." ".surname </code></pre> <p>So that</p> <pre><code>insert into actors(forename, surname) values ('Stack', 'Overflow'); </code></pre> <p>would produce the record</p> <pre><code>'Stack' 'Overflow' 'Stack Overflow' </code></pre> <p>Is this possible?</p> <p>Thanks :)</p>
[ { "answer_id": 360484, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 2, "selected": false, "text": "CURRENT_TIMESTAMP" }, { "answer_id": 360493, "author": "Bill Karwin", "author_id": 20860, "author_profile...
2008/12/11
[ "https://Stackoverflow.com/questions/360467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33604/" ]
360,473
<p>What's the most natural way to model a group of objects that form a set? For example, you might have a bunch of user objects who are all subscribers to a mailing list.</p> <p>Obviously you could model this as an array, but then you have to order the elements and whoever is using your interface might be confused as to why you're encoding arbitrary ordering data.</p> <p>You can use a hash where the members are keys that map to "1" or "true", but in most languages there are restrictions on what data types a hash key can be.</p> <p>What's the standard way to do this in modern languages (PHP, Perl, Ruby, Python, etc)?</p>
[ { "answer_id": 360485, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 2, "selected": true, "text": "set" }, { "answer_id": 360500, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://...
2008/12/11
[ "https://Stackoverflow.com/questions/360473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25068/" ]
360,476
<p>How can I write a semi transparent text on an Image (Jpg,Bmp), or a transparent text (color as same background Image) but with a shadow, something I want to do to watermark the images.</p> <p>I want to accomplish that using Delphi win32.</p>
[ { "answer_id": 360495, "author": "X-Ray", "author_id": 14031, "author_profile": "https://Stackoverflow.com/users/14031", "pm_score": 2, "selected": false, "text": "img.Canvas.Brush.Style:=bsClear;\nimg.Canvas.Font.Color:=clBlack;\nimg.Canvas.TextOut(0, 0, 'hi there');\n" }, { "an...
2008/12/11
[ "https://Stackoverflow.com/questions/360476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24462/" ]
360,480
<p>It seems that there're 6 variations to CBC-MAC algorithm. I've been trying to match the MAC algorithm on the PINPad 1000SE [which per manual is ISO 9797-1 Algorithm 1].</p> <p>I got an excellent start from <a href="http://bytes.com/topic/net/answers/654069-iso-iec-9797-1-cbc-mac-using-vb-net" rel="nofollow noreferrer">here</a>.</p> <p>And I coded the algorithm as below:</p> <pre><code>public static byte[] CalculateMAC(this IPinPad pinpad, byte[] message, byte[] key) { //Divide the key with Key1[ first 64 bits] and key2 [last 64 bits] var key1 = new byte[8]; Array.Copy(key, 0, key1, 0, 8); var key2 = new byte[8]; Array.Copy(key, 8, key2, 0, 8); //64 bits //divide the message into 8 bytes blocks //pad the last block with "80" and "00","00","00" until it reaches 8 bytes //if the message already can be divided by 8, then add //another block "80 00 00 00 00 00 00 00" Action&lt;byte[], int&gt; prepArray = (bArr, offset) =&gt; { bArr[offset] = 0; //80 for (var i = offset + 1; i &lt; bArr.Length; i++) bArr[i] = 0; }; var length = message.Length; var mod = length &gt; 8? length % 8: length - 8; var newLength = length + ((mod &lt; 0) ? -mod : (mod &gt; 0) ? 8 - mod : 0); //var newLength = length + ((mod &lt; 0) ? -mod : (mod &gt; 0) ? 8 - mod : 8); Debug.Assert(newLength % 8 == 0); var arr = new byte[newLength]; Array.Copy(message, 0, arr, 0, length); //Encoding.ASCII.GetBytes(message, 0, length, arr, 0); prepArray(arr, length); //use initial vector {0,0,0,0,0,0,0,0} var vector = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }; //encrypt by DES CBC algorith with the first key KEY 1 var des = new DESCryptoServiceProvider { Mode = CipherMode.CBC }; var cryptor = des.CreateEncryptor(key1, vector); var outputBuffer = new byte[arr.Length]; cryptor.TransformBlock(arr, 0, arr.Length, outputBuffer, 0); //Decrypt the result by DES ECB with the second key KEY2 [Original suggestion] //Now I'm Encrypting var decOutputBuffer = new byte[outputBuffer.Length]; des.Mode = CipherMode.ECB; var decryptor = des.CreateEncryptor(key2, vector); //var decryptor = des.CreateDecryptor(key2, vector); decryptor.TransformBlock(outputBuffer, 0, outputBuffer.Length, decOutputBuffer, 0); //Encrypt the result by DES ECB with the first key KEY1 var finalOutputBuffer = new byte[decOutputBuffer.Length]; var cryptor2 = des.CreateEncryptor(key1, vector); cryptor2.TransformBlock(decOutputBuffer, 0, decOutputBuffer.Length, finalOutputBuffer, 0); //take the first 4 bytes as the MAC var rval = new byte[4]; Array.Copy(finalOutputBuffer, 0, rval, 0, 4); return rval; } </code></pre> <p>Then I discovered there're 3 padding schemes and the one that gave me a start may not necessarily be right. The manual came to my rescue again. It seems the device only pads with 0s. Additional block is also nowhere mentioned so I made the below changes:</p> <pre><code> Action&lt;byte[], int&gt; prepArray = (bArr, offset) =&gt; { bArr[offset] = 0; ... } </code></pre> <p>No additional block (if mod 0 [divisible by 8] do not change array length)</p> <pre><code>var newLength = length + ((mod &lt; 0) ? -mod : (mod &gt; 0) ? 8 - mod : 0); </code></pre> <p>The original suggestion wanted me to decrypt at the second step... but Valery <a href="http://www.derkeiler.com/Newsgroups/microsoft.public.dotnet.security/2005-04/0180.html" rel="nofollow noreferrer">here</a> suggests that it's encrypt all the way. So I changed Decrypt to Encrypt. But still I'm unable to get the requisite MAC...</p> <p>Manual says for key "6AC292FAA1315B4D8234B3A3D7D5933A" [since the key should be 16 bytes, I figured the key here's hex string so I took byte values of 6A, C2, 92, FA... new byte[] { 106, 194, 146, ...] the MAC should be 7B,40,BA,95 [4 bytes] if the message is [0x1a + byte array of MENTERODOMETER]</p> <p>Can someone help? Please?</p> <hr> <p>Since Pinpad requires that the first character in message is a 0x1a...</p> <pre><code>public static byte[] CalculateAugmentedMAC(this IPinPad pinpad, string message, byte[] key) { var arr = new byte[message.Length + 1]; var source = Encoding.ASCII.GetBytes(message); arr[0] = 0x1a; //ClearScreenIndicator Array.Copy(source, 0, arr, 1, source.Length); return CalculateMAC(pinpad, arr, key); } </code></pre> <p>I'm calling the code above with this input:</p> <pre><code>var result = pad.CalculateAugmentedMAC("MENTERODOMETER", new byte[] { 106, 194, 146, 250, 161, 49, 91, 77, 130, 52, 179, 163, 215, 213, 147, 58 }); </code></pre>
[ { "answer_id": 1459874, "author": "Aleksander Adamowski", "author_id": 171960, "author_profile": "https://Stackoverflow.com/users/171960", "pm_score": 2, "selected": false, "text": "DESEDEISO9797ALG1MACWITHISO7816-4PADDING" }, { "answer_id": 1459901, "author": "leppie", "...
2008/12/11
[ "https://Stackoverflow.com/questions/360480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28413/" ]
360,491
<p>I'm wanting to use jQuery to wrap a mailto: anchor around an email address, but it's also grabbing the whitepace that the CMS is generating.</p> <p>Here's the HTML I have to work with, the script as I have it and a copy of the output.</p> <p>HTML</p> <pre><code>&lt;div class="field field-type-text field-field-email"&gt; &lt;div class="field-item"&gt; name@example.com &lt;/div&gt; &lt;/div&gt; </code></pre> <p>jQuery JavaScript</p> <pre><code>$(document).ready(function(){ $('div.field-field-email .field-item').each(function(){ var emailAdd = $(this).text(); $(this).wrapInner('&lt;a href="mailto:' + emailAdd + '"&gt;&lt;/a&gt;'); }); }); </code></pre> <p>Generated HTML</p> <pre><code>&lt;div class="field field-type-text field-field-email"&gt; &lt;div class="field-items"&gt;&lt;a href="mailto:%0A%20%20%20%20name@example.com%20%20%20%20"&gt; name@example.com &lt;/a&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>Though I suspect that others reading this question might want to just strip the leading and tailing whitespace, I'm quite happy to lose all the whitespace considering it's an email address I'm wrapping.</p>
[ { "answer_id": 360496, "author": "Andreas Grech", "author_id": 44084, "author_profile": "https://Stackoverflow.com/users/44084", "pm_score": 9, "selected": true, "text": "replace" }, { "answer_id": 360533, "author": "Tuxmentat", "author_id": 15963, "author_profile": "...
2008/12/11
[ "https://Stackoverflow.com/questions/360491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16124/" ]
360,492
<p>I'm fooling around with <a href="http://pipes.yahoo.com" rel="nofollow noreferrer">Yahoo! pipes</a> and I'm hitting a wall with some regular expression. Now I'm familiar with regular expressions from Perl but the rules just seem to be different in Yahoo! pipes.</p> <p><a href="https://i.stack.imgur.com/6I6Ok.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6I6Ok.png" alt="Screenshot of my pipe"></a> </p> <p>What I'm doing is fetching a page and trying to turn it into a feed, my regex for stripping out the link from the HTML works fine but the title which I want to be what was in <em>&lt;i&gt;</em> tags just outputs the original text. </p> <p>Sample text that matches in Perl and on this <a href="http://www.quanetic.com/regex.php" rel="nofollow noreferrer">online regexp tester</a>:</p> <blockquote> <p>&lt;a rel="nofollow" target="_blank" HREF="http://changed.to/protect/the-guilty.html"&gt;&lt;i&gt;"Fee Fi Fo Fun" (English Man)&lt;/i&gt;&lt;/a&gt; (See also this other site &lt;a rel="nofollow" target="_blank" href="http://stackoverflow.com"&gt;Nada&lt;/a&gt;) Some other text here</p> </blockquote>
[ { "answer_id": 360610, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 4, "selected": true, "text": "(?i).*?<i>([^<]*).* [ ] g [x] s [ ] m [ ] i\n" } ]
2008/12/11
[ "https://Stackoverflow.com/questions/360492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3848/" ]
360,507
<p>I wonder if there is a less verbose way to do Input Verification in my methods. For example, i commonly write stuff like this:</p> <pre><code>public string SomeFunction(string param1, int param2) { if(string.IsNullOrEmpty(param1)){ throw new ArgumentException("bla", "param1"); } if(param2 &lt; 0 || param2 &gt; 100 || param2 == 53) { throw new ArgumentOutOfRangeException("eek", "param2"); } } </code></pre> <p>Now, I wonder if there is a way to set up constraints on the parameters and have the compiler already handle that for me? I believe that this is called "Contract" and I remember seeing that Spec# is supposed to do that, but that seems to be an experimental research project at the moment.</p> <p>So I wonder: Is there anything that can give a clean enforcing of Constraints (at least the simple and often recurring ones like string.IsNullOrEmpty) for input parameters for .net 3.5 SP1 and ideally .net 3.0 already?</p>
[ { "answer_id": 360548, "author": "Drejc", "author_id": 6482, "author_profile": "https://Stackoverflow.com/users/6482", "pm_score": 2, "selected": false, "text": "public string SomeFunction(string param1, int param2)\n{\n CheckParameterNotNull(param1);\n CheckParameterRange(param2, ...
2008/12/11
[ "https://Stackoverflow.com/questions/360507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91/" ]
360,520
<p>My company has been evaluating Spring MVC to determine if we should use it in one of our next projects. So far I love what I've seen, and right now I'm taking a look at the Spring Security module to determine if it's something we can/should use. </p> <p>Our security requirements are pretty basic; a user just needs to be able to provide a username and password to be able to access certain parts of the site (such as to get info about their account); and there are a handful of pages on the site (FAQs, Support, etc) where an anonymous user should be given access.</p> <p>In the prototype I've been creating, I have been storing a "LoginCredentials" object (which just contains username and password) in Session for an authenticated user; some of the controllers check to see if this object is in session to get a reference to the logged-in username, for example. I'm looking to replace this home-grown logic with Spring Security instead, which would have the nice benefit of removing any sort of "how do we track logged in users?" and "how do we authenticate users?" from my controller/business code. </p> <p>It seems like Spring Security provides a (per-thread) "context" object to be able to access the username/principal info from anywhere in your app...</p> <pre><code>Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal(); </code></pre> <p>... which seems very un-Spring like as this object is a (global) singleton, in a way.</p> <p>My question is this: if this is the standard way to access information about the authenticated user in Spring Security, what is the accepted way to inject an Authentication object into the SecurityContext so that it is available for my unit tests when the unit tests require an authenticated user?</p> <p>Do I need to wire this up in the initialization method of each test case?</p> <pre><code>protected void setUp() throws Exception { ... SecurityContextHolder.getContext().setAuthentication( new UsernamePasswordAuthenticationToken(testUser.getLogin(), testUser.getPassword())); ... } </code></pre> <p>This seems overly verbose. Is there an easier way? </p> <p>The <code>SecurityContextHolder</code> object itself seems very un-Spring-like...</p>
[ { "answer_id": 396029, "author": "Pavel", "author_id": 48340, "author_profile": "https://Stackoverflow.com/users/48340", "pm_score": 5, "selected": false, "text": "public class MyUserDetails implements UserDetails {\n // this is your custom UserDetails implementation to serve as a pri...
2008/12/11
[ "https://Stackoverflow.com/questions/360520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4249/" ]
360,530
<p>I would like to know how to change the colour of the equality sign and double quotes for html documents in the eclipse PDT IDE. I can change most colours in Preferences -> Web &amp; XML -> HTML Files -> syntax coloring, but can't change the characters <code>=</code> or <code>"</code> e.g. in an anchor tag <code>&lt;a href=""&gt;</code>.</p> <p>How to change these colours?</p>
[ { "answer_id": 396029, "author": "Pavel", "author_id": 48340, "author_profile": "https://Stackoverflow.com/users/48340", "pm_score": 5, "selected": false, "text": "public class MyUserDetails implements UserDetails {\n // this is your custom UserDetails implementation to serve as a pri...
2008/12/11
[ "https://Stackoverflow.com/questions/360530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/69346/" ]
360,597
<p>I have a class hierarchy, this one:</p> <pre><code>type TMatrix = class protected //... public constructor Create(Rows, Cols: Byte); //... type TMinMatrix = class(TMatrix) private procedure Allocate; procedure DeAllocate; public constructor Create(Rows, Cols: Byte); constructor CreateCopy(var that: TMinMatrix); destructor Destroy; end; </code></pre> <p>So as you see, both derived and base class constructors have the same parameter list. I explicitly call base class constructor from derived one:</p> <pre><code>constructor TMinMatrix.Create(Rows, Cols: Byte); begin inherited; //... end; </code></pre> <p>Is it necessary to explicitly call base class constructor in Delphi? May be I need to put overload or override to clear what I intend to do? I know how to do it in C++ - you need explicit call of a base class constructor only if you want to pass some parameters to it - but I haven`t much experience in Delphi programming.</p>
[ { "answer_id": 360693, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 2, "selected": false, "text": "type\n TMatrix = class\n protected\n //...\n public\n constructor Create(Rows, Cols: Byte);\n //...\ntype...
2008/12/11
[ "https://Stackoverflow.com/questions/360597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28298/" ]
360,612
<p>I'm working on a toolkit (sort of a live-CD Lisp-in-a-Box) for people new to Common Lisp, and I want to make sure it is broadly satisfying. What is attractive to you about Lisp? What do/did/would you need to get you started and keep you interested?</p> <p>What I have so far: SBCL 10.22, Emacs 22.3, SLIME, and LTK bundled together and configured on a Linux live-CD that boots entirely to RAM.</p> <hr> <p>I've now released the result of this; it is available at the <a href="http://www.jasonfruit.com/thnake" rel="nofollow noreferrer">Thnake website</a>.</p>
[ { "answer_id": 361351, "author": "Brian Carper", "author_id": 23070, "author_profile": "https://Stackoverflow.com/users/23070", "pm_score": 3, "selected": false, "text": "hello-world" } ]
2008/12/11
[ "https://Stackoverflow.com/questions/360612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21778/" ]
360,615
<p>In postgres I am fairly sure you can do something like this</p> <pre><code>SELECT authors.stage_name, count(select id from books where books.author_id = authors.id) FROM authors, books; </code></pre> <p>Essentially, in this example I would like to return a list of authors and how many books each has written.... in the same query.</p> <p>Is this possible? I suspect this approach is rather naive..</p> <p>Thanks :)</p>
[ { "answer_id": 360647, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 0, "selected": false, "text": "SELECT authors.stage_name, count(*) \nFROM authors INNER JOIN books on books.author_id = authors.id\nGROUP BY author...
2008/12/11
[ "https://Stackoverflow.com/questions/360615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33604/" ]
360,628
<p>I'm trying to embed an xsl into a XML file. The reason for doing this is to create a single file that could be moved to different computers, this would prevent the need to move the xsl file. </p> <p>The xsl file is creating a table and grabbing a test step from the xml and whether it passed or failed, pretty simple.<br> The issue I'm having, I think, is that the xsl has javascript and its being displayed when the xml is loaded in IE. </p> <p>When I load the xml file with IE, the javascript is displayed above the table and below the table the xml is displayed.</p> <p>Here is how my document is laid-out :</p> <pre><code>&lt;!DOCTYPE doc [ &lt;!ATTLIST xsl:stylesheet id ID #REQUIRED&gt; ]&gt; &lt;doc&gt; &lt;xsl:stylesheet id="4.1.0" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="http://www.ni.com/TestStand" xmlns:vb_user="http://www.ni.com/TestStand/" &gt; &lt;xsl:template match="xsl:stylesheet" /&gt; &lt;xsl:text disable-output-escaping="yes"&gt; &lt;msxsl:script language="vbscript" implements-prefix="vb_user"&gt; option explicit 'This function will return the localized decimal point for a decimal number Function GetLocalizedDecimalPoint () dim lDecPoint lDecPoint = Mid(CStr(1.1),2,1) GetLocalizedDecimalPoint = lDecPoint End Function &lt;/msxsl:script&gt; &lt;msxsl:script language="javascript" implements-prefix="user"&gt;&lt;![CDATA[ // This style sheet will not show tables instead of graphs for arrays of values if // 1. TSGraph control is not installed on the machine // 2. Using the stylesheet in windows XP SP2. Security settings prevent stylesheets from creatign the GraphControl using scripting. // Refer to the TestStand Readme for more information. //more javascript functions //code to build table and insert data from the xml &lt;/xsl:stylesheet&gt; &lt;Reports&gt; &lt;Report Type='UUT' Title='UUT Report' Link='-1-2008-12-3-10-46-52-713' UUTResult='Failed' StepCount='51'&gt; // rest of xml &lt;/Report&gt; &lt;/Reports&gt; &lt;/doc&gt; </code></pre>
[ { "answer_id": 361237, "author": "Dimitre Novatchev", "author_id": 36305, "author_profile": "https://Stackoverflow.com/users/36305", "pm_score": 4, "selected": false, "text": "<xsl:template>" } ]
2008/12/11
[ "https://Stackoverflow.com/questions/360628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7617/" ]
360,643
<p>I used to have one class for one file. For example <em>car.cs</em> has the class <em>car</em>. But as I program more classes, I would like to add them to the same file. For example <em>car.cs</em> has the class <em>car</em> and the <em>door</em> class, etc.</p> <p>My question is good for Java, C#, PHP or any other programming language. Should I try not having multiple classes in the same file or is it ok?</p>
[ { "answer_id": 360735, "author": "Ryan Lundy", "author_id": 5486, "author_profile": "https://Stackoverflow.com/users/5486", "pm_score": 5, "selected": false, "text": "public class Customer { /* whatever */ }\n\npublic class CustomerCollection : List<Customer> { /* whatever */ }\n" } ]
2008/12/11
[ "https://Stackoverflow.com/questions/360643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21386/" ]
360,649
<p>Is there a way to vertically stack selected td elments? I would like to have the same table, though display it differently using only css. Would this be possible, or do I have to have separate html markups? I would like to try to have the same html markup, though use different css for different sites/looks.</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td class="vertical" id="one" &gt;i'm&lt;/td&gt; &lt;td class="vertical" id="two" &gt;above&lt;/td&gt; &lt;td class="vertical" id="three" &gt;this&lt;/td&gt; &lt;td class="horizontal" id="four" &gt;i'm horizontal&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre>
[ { "answer_id": 360674, "author": "Eduardo Molteni", "author_id": 2385, "author_profile": "https://Stackoverflow.com/users/2385", "pm_score": 3, "selected": true, "text": "<table>\n <tr>\n <td class=\"vertical\">i'm</td>\n <td class=\"horizontal\" rowspan=\"3\">i'm horizontal</td...
2008/12/11
[ "https://Stackoverflow.com/questions/360649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20641/" ]
360,673
<p>Is there a way to do gradients in css/html/javascript only that will work across all the major browsers? (MS IE 5+, Firefox, Opera, Safari)?</p> <p>Edit: I would like to do this for backgrounds (header, main panel, side panels). Also, would like to have vertical line gradients as well.</p> <p>Edit: after reading the responses, let's open this up to Javascript solutions as well, since HTML/CSS by itself makes it tougher to achieve.</p>
[ { "answer_id": 360811, "author": "Jimmy", "author_id": 4435, "author_profile": "https://Stackoverflow.com/users/4435", "pm_score": 2, "selected": false, "text": "var parent = document.getElementByID('foo');\nfor(var i=0; i< count; i++) {\n var div = document.createElement('div');\n ...
2008/12/11
[ "https://Stackoverflow.com/questions/360673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20641/" ]
360,694
<p>If you have a web application that will run inside a network, it makes sense for it to support windows authentication (active directory?).</p> <p>Would it make sense to use AD security model as well, or would I make my own roles/security module that some admin would have to configure for each user?</p> <p>I've never dealt with windows security before, so I am very confused as to how I should be handling security for a web application that runs within a windows network.</p> <p>I guess there are 2 major points I have to tackle:</p> <pre><code>1. authentication 2. authorization </code></pre> <p>I have a feeling that best-practice would say to handle authorization myself, but use AD authentication right?</p>
[ { "answer_id": 360717, "author": "Ian G", "author_id": 31765, "author_profile": "https://Stackoverflow.com/users/31765", "pm_score": 4, "selected": true, "text": "web.config" } ]
2008/12/11
[ "https://Stackoverflow.com/questions/360694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39677/" ]
360,725
<p>I am fetching an array of floats from my database but the array I get has converted the values to strings.</p> <p>How can I convert them into floats again without looping through the array?<br /> Alternatively, how can I fetch the values from the database without converting them to strings?</p> <hr /> <h3>EDIT:</h3> <ul> <li><p>I am using the Zend Framework and I am using PDO_mysql. The values are stored one per column and that is a requirement so I can't serialize them.</p> </li> <li><p><code>array_map('floatval', $array)</code> only works on single dimensional arrays.</p> </li> <li><p>I can't <code>floatval</code> the single elements when I use them because I have to pass an array to my flash chart.</p> </li> <li><p>The momentary, non-generic solution is to extract the rows and do <code>array_map('floatval',$array)</code> with each row.</p> </li> </ul>
[ { "answer_id": 360736, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 6, "selected": true, "text": "$floats = array_map('floatval', $nonFloats);\n" }, { "answer_id": 360744, "author": "Kris", "author_id": 18565...
2008/12/11
[ "https://Stackoverflow.com/questions/360725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11995/" ]
360,748
<p>I understand Big-O notation, but I don't know how to calculate it for many functions. In particular, I've been trying to figure out the computational complexity of the naive version of the Fibonacci sequence:</p> <pre><code>int Fibonacci(int n) { if (n &lt;= 1) return n; else return Fibonacci(n - 1) + Fibonacci(n - 2); } </code></pre> <p>What is the computational complexity of the Fibonacci sequence and how is it calculated?</p>
[ { "answer_id": 360768, "author": "Jason Cohen", "author_id": 4926, "author_profile": "https://Stackoverflow.com/users/4926", "pm_score": 7, "selected": false, "text": "F(n)" }, { "answer_id": 360773, "author": "mmx", "author_id": 33708, "author_profile": "https://Stac...
2008/12/11
[ "https://Stackoverflow.com/questions/360748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40516/" ]
360,751
<p>I would like to have an app include a custom font for rendering text, load it, and then use it with standard <code>UIKit</code> elements like <code>UILabel</code>. Is this possible?</p>
[ { "answer_id": 361613, "author": "August", "author_id": 30966, "author_profile": "https://Stackoverflow.com/users/30966", "pm_score": 4, "selected": false, "text": "fontWithName:size:" }, { "answer_id": 370257, "author": "Genericrich", "author_id": 39932, "author_prof...
2008/12/11
[ "https://Stackoverflow.com/questions/360751", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18017/" ]
360,753
<p>So I'm a newbie to TDD, and I successfully created a nice little sample app using the MVP pattern. The major problem to my current solution is that its blocking the UI thread, So I was trying to setup the Presenter to use the SynchronizationContext.Current, but when I run my tests the SynchronizationContext.Current is null.</p> <p>Presenter Before Threading</p> <pre><code>public class FtpPresenter : IFtpPresenter { ... void _view_GetFilesClicked(object sender, EventArgs e) { _view.StatusMessage = Messages.Loading; try { var settings = new FtpAuthenticationSettings() { Site = _view.FtpSite, Username = _view.FtpUsername, Password = _view.FtpPassword }; var files = _ftpService.GetFiles(settings); _view.FilesDataSource = files; _view.StatusMessage = Messages.Done; } catch (Exception ex) { _view.StatusMessage = ex.Message; } } ... } </code></pre> <p>Test Before Threading</p> <pre><code>[TestMethod] public void Can_Get_Files() { var view = new FakeFtpView(); var presenter = new FtpPresenter(view, new FakeFtpService(), new FakeFileValidator()); view.GetFiles(); Assert.AreEqual(Messages.Done, view.StatusMessage); } </code></pre> <p>Now after I added a SynchronizationContext Threading to the Presenter I tried to set a AutoResetEvent on my Fake View for the StatusMessage, but when I run the test the SynchronizationContext.Current is null. I realize that the threading model I'm using in my new Presenter isn't perfect, but is this the right technique for Testing Multithreading? Why is my SynchronizationContext.Current null? What should I do instead?</p> <p>Presenter After Threading</p> <pre><code>public class FtpPresenter : IFtpPresenter { ... void _view_GetFilesClicked(object sender, EventArgs e) { _view.StatusMessage = Messages.Loading; try { var settings = new FtpAuthenticationSettings() { Site = _view.FtpSite, Username = _view.FtpUsername, Password = _view.FtpPassword }; // Wrap the GetFiles in a ThreadStart var syncContext = SynchronizationContext.Current; new Thread(new ThreadStart(delegate { var files = _ftpService.GetFiles(settings); syncContext.Send(delegate { _view.FilesDataSource = files; _view.StatusMessage = Messages.Done; }, null); })).Start(); } catch (Exception ex) { _view.StatusMessage = ex.Message; } } ... } </code></pre> <p>Test after threading</p> <pre><code>[TestMethod] public void Can_Get_Files() { var view = new FakeFtpView(); var presenter = new FtpPresenter(view, new FakeFtpService(), new FakeFileValidator()); view.GetFiles(); view.GetFilesWait.WaitOne(); Assert.AreEqual(Messages.Done, view.StatusMessage); } </code></pre> <p>Fake View</p> <pre><code>public class FakeFtpView : IFtpView { ... public AutoResetEvent GetFilesWait = new AutoResetEvent(false); public event EventHandler GetFilesClicked = delegate { }; public void GetFiles() { GetFilesClicked(this, EventArgs.Empty); } ... private List&lt;string&gt; _statusHistory = new List&lt;string&gt;(); public List&lt;string&gt; StatusMessageHistory { get { return _statusHistory; } } public string StatusMessage { get { return _statusHistory.LastOrDefault(); } set { _statusHistory.Add(value); if (value != Messages.Loading) GetFilesWait.Set(); } } ... } </code></pre>
[ { "answer_id": 360780, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": true, "text": " public FtpPresenter() : this(null) { }\n\n public FtpPresenter( SynchronizationContext context )\n {\n this...
2008/12/11
[ "https://Stackoverflow.com/questions/360753", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37881/" ]
360,758
<p>I have a server that hosts my Subversion code base. That server is currently a <a href="http://en.wikipedia.org/wiki/Windows_Server_2003" rel="noreferrer">Windows Server 2003</a> box, and my IT administrator wants to update it to <a href="http://en.wikipedia.org/wiki/Windows_Server_2008" rel="noreferrer">Windows Server 2008</a>.</p> <p>This means that I'm going to need to move my Subversion repository while the server gets built up and was wondering what the best practices are for moving the repository to a new server.</p> <p>It seems like, looking online, the recommended way is to use:</p> <pre><code>svnadmin dump /path/to/repository &gt; repository-name.dmp </code></pre> <p>And then use:</p> <pre><code>svnadmin create repository-name svnadmin load repository-name&lt; repository-name.dmp </code></pre> <p>To import the repository.</p> <p>Does the method above seem like the best approach?</p>
[ { "answer_id": 360919, "author": "alexandrul", "author_id": 19756, "author_profile": "https://Stackoverflow.com/users/19756", "pm_score": 5, "selected": false, "text": "svnadmin create repository-name --fs-type fsfs\nsvnadmin load repository-name --force-uuid < repository-name.dmp\n" ...
2008/12/11
[ "https://Stackoverflow.com/questions/360758", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10420/" ]
360,766
<p>I'd like to define a generic type, whose actual type parameter can only be</p> <ol> <li>One of the numeric primitive wrapper classes (<code>Long</code>, <code>Integer</code>, <code>Float</code>, <code>Double</code>)</li> <li><code>String</code></li> </ol> <p>I can meet the first requirement with a definition like this</p> <pre><code>public final class MyClass&lt;T extends Number&gt; { // Implementation omitted } </code></pre> <p>But I can't figure out how to meet both of them. I suspect this is not actually possible, because AFAIK there's no way to specify "or" semantics when defining a formal type parameter, though you can specify "and" semantics using a definition such as</p> <pre><code>public final class MyClass&lt;T extends Runnable &amp; Serializable &gt; { // Implementation omitted } </code></pre> <p>Cheers, Don</p>
[ { "answer_id": 360796, "author": "Dave L.", "author_id": 3093, "author_profile": "https://Stackoverflow.com/users/3093", "pm_score": 4, "selected": false, "text": "public static <T extends Object & Comparable<? super T>> T max(Collection<? extends T> coll)\n" }, { "answer_id": 36...
2008/12/11
[ "https://Stackoverflow.com/questions/360766", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
360,777
<p>I have an animation and I want it to play it just only once. From where can I set so when I export to SWF the default will be AUTO LOOPING disabled.</p> <p>Thanks</p>
[ { "answer_id": 24054393, "author": "Khadka Pushpendra", "author_id": 2318637, "author_profile": "https://Stackoverflow.com/users/2318637", "pm_score": 0, "selected": false, "text": "<param name='loop' value='false' />\n\n<object type='application/x-shockwave-flash' data='sourcefile' widt...
2008/12/11
[ "https://Stackoverflow.com/questions/360777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44973/" ]
360,782
<p>Given either the binary or string representation of an IPv6 address and its prefix length, what's the best way to extract the prefix in Python?</p> <p>Is there a library that would do this for me, or would I have to:</p> <ol> <li>convert the address from string to an int (inet_ntop)</li> <li>Mask out the prefix</li> <li>Convert prefix back to binary </li> <li>Convert binary to string (inet_ntop)</li> </ol>
[ { "answer_id": 360989, "author": "Martin v. Löwis", "author_id": 33006, "author_profile": "https://Stackoverflow.com/users/33006", "pm_score": 3, "selected": true, "text": "py> p=ipaddr.IPv6(\"2001:888:2000:d::a2\")\npy> p.SetPrefix(64)\npy> p\nIPv6('2001:888:2000:d::a2/64')\npy> p.netwo...
2008/12/11
[ "https://Stackoverflow.com/questions/360782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4883/" ]
360,789
<p>I want to otherwise block code execution on the main thread while still allowing UI changes to be displayed.</p> <p>I tried to come up with a simplified example version of what I'm trying to do; and this is the best I could come up with. Obviously it doesn't demonstrate the behavior I'm wanting or I wouldn't be posting the question. I just hope it gives some code context to back my poor explanation of the problem I'm hoping to solve.</p> <p>Within a button click handler on a form I have this:</p> <pre><code> private void button2_Click(object sender, EventArgs e) { AutoResetEvent autoResetEvent = new AutoResetEvent(false); new Thread(delegate() { // do something that takes a while. Thread.Sleep(1000); // Update UI w/BeginInvoke this.BeginInvoke(new ThreadStart( delegate() { this.Text = "Working... 1"; this.Refresh(); Thread.Sleep(1000); // gimme a chance to see the new text })); // do something else that takes a while. Thread.Sleep(1000); // Update UI w/Invoke this.Invoke(new ThreadStart( delegate() { this.Text = "Working... 2"; this.Refresh(); Thread.Sleep(1000); // gimme a chance to see the new text })); // do something else that takes a while. Thread.Sleep(1000); autoResetEvent.Set(); }).Start(); // I want the UI to update during this 4 seconds, even though I'm // blocking the mainthread if (autoResetEvent.WaitOne(4000, false)) { this.Text = "Event Signalled"; } else { this.Text = "Event Wait Timeout"; } Thread.Sleep(1000); // gimme a chance to see the new text this.Refresh(); } </code></pre> <p>If I didn't set a timout on the WaitOne() the app would deadlock on the Invoke() call.</p> <hr> <p>As to why I'd want to do this, I've been tasked with moving one subsystem of an app to do work in a background thread, but still have it block user's workflow (the main thread) only sometimes and for certain types of work related to that subsystem only.</p>
[ { "answer_id": 360944, "author": "Maghis", "author_id": 45355, "author_profile": "https://Stackoverflow.com/users/45355", "pm_score": 2, "selected": false, "text": "private void button1_Click(object sender, EventArgs e)\n{\n // this is the UI thread\n\n ThreadPool.QueueUserWorkItem...
2008/12/11
[ "https://Stackoverflow.com/questions/360789", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16260/" ]
360,816
<p>For some reason I can't use <code>runat="server"</code> as an attribute for the input tag in order for the jQuery to display the image button and work. Is something wrong without <code>runat="server"</code>? It works fine. And I want the format to be "yyyy/mm/dd" and also I need it for the server because this is where I check to see if the date manually entered is a valid date and that it matches the accepted format. I really want to use an <code>asp:button</code> but since I can't use <code>runat="server"</code> attribute I don't know what to do since that is required for asp controls</p> <pre><code>&lt;script language="javascript" type="text/javascript"&gt; $(document).ready(function(){ $("#datepicker").datepicker({ showOn: "both", buttonImage: "/Content/img/calendar.gif", buttonImageOnly: true }); }); &lt;/script&gt; </code></pre>
[ { "answer_id": 360832, "author": "Jimmy", "author_id": 4435, "author_profile": "https://Stackoverflow.com/users/4435", "pm_score": 4, "selected": true, "text": "<input id='datepicker' runat='server' class='datepicker' />\n\n$(document).ready(function(){\n$(\".datepicker\").datepicker({ s...
2008/12/11
[ "https://Stackoverflow.com/questions/360816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39809/" ]
360,830
<p>I'm trying to retrieve data from an SQL Server 2000 server, and place into Excel. Which sounds simple I know. I'm currently Copying, and Pasting into Excel, from Management Studio</p> <p>The problem is one of the columns is an address, and it’s not retaining the newlines. These new lines have to stay in the same cell in excel, I.E cannot take up 3 rows, for 3 lines of an address.</p> <p>In the SQL Data CHAR(10) and CHAR(13) are included, and other software pick up on these correctly.</p> <p>EDIT: Sorry I forgot to metion, I want the lines to be present in the cell, but not span multiple cells.</p>
[ { "answer_id": 360886, "author": "Tmdean", "author_id": 45084, "author_profile": "https://Stackoverflow.com/users/45084", "pm_score": 2, "selected": true, "text": "Sub FixNewlines()\n For Each Cell In UsedRange\n Cell.FormulaR1C1 = Replace(Cell.FormulaR1C1, Chr(13), \"\")\n ...
2008/12/11
[ "https://Stackoverflow.com/questions/360830", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18405/" ]
360,831
<p>I have a scenario in which I'm going to need an arbitrary number of servers to provide the same SOAP web service. I would like to generate one set of proxy classes and be able to supply them with a location to point them at the different servers at runtime. Unfortunately, it looks as though the <code>wsdl:port</code> node (child of <code>wsdl:service</code>) requires the address of a specific server to be hardcoded. It appears that due to this the URL will be baked into my proxy classes. I know that I could potentially modify this by hand-editing the generated proxy classes, or modifying the code generation, but I'd really prefer not to resort to that. I feel like there's got to be a better way to solve this problem. I just want to decouple the interface definition from the location that the service will be residing at. I'm using VS2008 and C#.NET if that's of any help though best would be a language-agnostic (SOAP or WSDL specific) general solution to this problem.</p>
[ { "answer_id": 360967, "author": "rbrayb", "author_id": 9922, "author_profile": "https://Stackoverflow.com/users/9922", "pm_score": 2, "selected": false, "text": "Service svc = new Service ();\nsvc.url = \"Value read from config. file or some such\"\noutput = svc.method (input);\n" }, ...
2008/12/11
[ "https://Stackoverflow.com/questions/360831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2327/" ]
360,836
<p>Now this is all way simplified, but here goes:</p> <p>I have a User Control that consists only of a single *.ascx file. The control has no code-behind: it's just a script with a few functions, like this:</p> <pre><code>&lt;%@ Control Language="VB" EnableViewState="False" ClassName="MyControlType" %&gt; &lt;script runat="server"&gt; Public Function MyFunction() As String return "CalledMyFunction!" End Function &lt;/script&gt; </code></pre> <p>That's the entire file. I can successfully add this control to an aspx page using markup like so:</p> <pre><code>&lt;%@ Register Src="~/path/to/Control.ascx" TagPrefix="aaa" TagName="MyControl" %&gt; ... &lt;aaa:MyControl runat="server" id="MyControl1" /&gt; </code></pre> <p>Now what I want to do is call MyFunction from the page's code-behind, like this:</p> <pre><code>Dim someString As String = MyControl1.MyFunction() </code></pre> <p>Unfortunately, I can't do that. Instead, I get a compile error to the effect of "<code>'MyFunction' is not a member of 'System.Web.UI.UserControl'.</code>"</p> <p>I've also tried this:</p> <pre><code>Dim someString As String = DirectCast(MyControl1, MyControlType).MyFunction() </code></pre> <p>and then the compiler tells me, "<code>Type 'MyControlType' is not defined.</code>"</p> <p>I've played with this a lot, and I just can't make it work. All efforts to cast MyControl1 to a more exact type have failed, as have other work-arounds. I suspect the problem is that the ascx file without a code-behind is unable to be compiled to an assembly but the code-behind wants to be compiled to an assembly and therefore the compiler gets confused about what type the control is.</p> <p>What do I need to do to be able to call that function?</p> <p>[edit]<br> So I'm just gonna have to add code-behind for the user control. It's what I wanted to do anyway. I'd still like to know how to do this without needing one, though.</p>
[ { "answer_id": 361052, "author": "BigJump", "author_id": 8542, "author_profile": "https://Stackoverflow.com/users/8542", "pm_score": 0, "selected": false, "text": "<script ruant=\"server\"> \n" }, { "answer_id": 361078, "author": "BigJump", "author_id": 8542, "author_...
2008/12/11
[ "https://Stackoverflow.com/questions/360836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3043/" ]
360,844
<p>I'd like to implement a <a href="http://en.wikipedia.org/wiki/Bloom_filter" rel="noreferrer">bloom filter</a> using MySQL (other a suggested alternative).</p> <p>The problem is as follows:</p> <p>Suppose I have a table that stores 8 bit integers, with these following values:</p> <pre><code>1: 10011010 2: 00110101 3: 10010100 4: 00100110 5: 00111011 6: 01101010 </code></pre> <p>I'd like to find all results that are bitwise AND to this:</p> <pre><code>00011000 </code></pre> <p>The results should be rows 1 and 5.</p> <p>However, in my problem, they aren't 8 bit integers, but rather n-bit integers. How do I store this, and how do I query? Speed is key.</p>
[ { "answer_id": 361093, "author": "Alexei Tenitski", "author_id": 45508, "author_profile": "https://Stackoverflow.com/users/45508", "pm_score": 4, "selected": false, "text": "number\n\n154\n53\n148\n38\n59\n106\n" }, { "answer_id": 28498755, "author": "cWarren", "author_id...
2008/12/11
[ "https://Stackoverflow.com/questions/360844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43005/" ]
360,849
<p>From what I understand, in TDD you have to write a failing test first, then write the code to make it pass, then refactor. But what if your code already accounts for the situation you want to test?</p> <p>For example, lets say I'm TDD'ing a sorting algorithm (this is just hypothetical). I might write unit tests for a couple of cases: <br></p> <p>input = 1, 2, 3<br> output = 1, 2, 3 <br> <br> input = 4, 1, 3, 2<br> output = 1, 2, 3, 4 <br> etc... <p> To make the tests pass, I wind up using a quick 'n dirty bubble-sort. Then I refactor and replace it with the more efficient merge-sort algorithm. Later, I realize that we need it to be a stable sort, so I write a test for that too. Of course, the test will never fail because merge-sort is a stable sorting algorithm! Regardless, I still need this test incase someone refactors it again to use a different, possibly unstable sorting algorithm. <p> Does this break the TDD mantra of always writing failing tests? I doubt anyone would recommend I waste the time to implement an unstable sorting algorithm just to test the test case, then reimplement the merge-sort. How often do you come across a similar situation and what do you do?</p>
[ { "answer_id": 360875, "author": "David Norman", "author_id": 34502, "author_profile": "https://Stackoverflow.com/users/34502", "pm_score": 2, "selected": false, "text": "assertTrue(x = 1);\n" } ]
2008/12/11
[ "https://Stackoverflow.com/questions/360849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32998/" ]
360,851
<p>What is the syntax to concatenate text into a binding expression for an asp.net webpage (aspx).</p> <p>For example if I had a hyperlink that was being bound like this:</p> <pre><code>&lt;asp:HyperLink id="lnkID" NavigateUrl='&lt;%# Bind("Link") %&gt;' Target="_blank" Text="View" runat="server"/&gt; </code></pre> <p>How do you change, say, the Text to concatenate a bound value with a string? Variations like this aren't quite right.</p> <pre><code>Text='&lt;%# Bind("ID") + " View" %&gt;' </code></pre> <p>neither does</p> <pre><code>Text='&lt;%# String.Concat(Bind("ID"), " View") %&gt;' </code></pre>
[ { "answer_id": 360865, "author": "Andrew Rollings", "author_id": 40410, "author_profile": "https://Stackoverflow.com/users/40410", "pm_score": 2, "selected": false, "text": "String.Format(\"{0}{1}\"" }, { "answer_id": 360936, "author": "TheEmirOfGroofunkistan", "author_id...
2008/12/11
[ "https://Stackoverflow.com/questions/360851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1874/" ]
360,877
<pre><code>private static final GridLayout layout = new GridLayout( 3, 1, 1, 0 ); </code></pre> <p>in this line of code what do the numbers represent and how do you use them to arrange the checkboxes and buttons in the window?</p>
[ { "answer_id": 361593, "author": "Joe Liversedge", "author_id": 4552, "author_profile": "https://Stackoverflow.com/users/4552", "pm_score": 3, "selected": false, "text": "public GridLayout(int rows,\n int cols,\n int hgap,\n int vgap)\n\...
2008/12/11
[ "https://Stackoverflow.com/questions/360877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
360,889
<p>I'm looking for a tool (or a set of tools) for Windows that will perform the following:</p> <ol> <li>Capture UDP packets from a specific network interface to a file.</li> <li>Play a stream of packets from a file through a network interface.</li> <li>In addition to 2: replay the original packets to a different host than the original one.</li> </ol> <p>I've already got 1 and 2, but I can't find a tool to do 3.</p> <p>For capturing I can use <a href="http://www.wireshark.org" rel="noreferrer">Wireshark</a>, for playback <a href="http://www.colasoft.com/packet_player/index.php?click=text" rel="noreferrer">Colasoft Packet Player</a>, but I couldn't find a way to change the host the packets are sent to.</p> <p>The tool should work on Windows XP SP2/3.</p>
[ { "answer_id": 13054921, "author": "spxl", "author_id": 1207973, "author_profile": "https://Stackoverflow.com/users/1207973", "pm_score": 3, "selected": true, "text": "bittwiste" } ]
2008/12/11
[ "https://Stackoverflow.com/questions/360889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33982/" ]
360,899
<p>I have been working on this for the greater part of the day and I cant seem to make this part of my code work. The intent of the code is to allow the user to input a set of values in order to calculate the missing value. As an additional feature I placed a CheckBox on the form to allow the user to do further calculation. That is where my problem lies. I know the code works because if I change the formula the value that appears in tb3_aic.Text changes per the formula. However, when I use the below the answer does not change like it should. Please reference the attached code. If a jpg image is needed of the formula I can e-mail it. </p> <pre><code> void Calc3Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(tb3_skv.Text) | String.IsNullOrEmpty(tb3_kva.Text) | String.IsNullOrEmpty(tb3_z.Text)) { MessageBox.Show("Enter all required values", "Missing Data", MessageBoxButtons.OK); } //If user does not enter all the values required for the calculation show error message box else { if (!String.IsNullOrEmpty(tb3_skv.Text) &amp; !String.IsNullOrEmpty(tb3_kva.Text) &amp; !String.IsNullOrEmpty(tb3_z.Text)) { //If motor load check box is not checked and required values are entered calculate AIC based on formula. int y; decimal x, z, a; x = decimal.Parse(tb3_skv.Text); y = int.Parse(tb3_kva.Text); a = decimal.Parse(tb3_z.Text); z = (y * 1000) / (x * 1.732050808m) / (a / 100); //the m at the end of the decimal allows for the multiplication of decimals tb3_aic.Text = z.ToString(); tb3_aic.Text = Math.Round(z,0).ToString(); } if (cb3_ml.Checked==true) {//If Motor Load CB is checked calculate the following int y, b; decimal x, z, a; x = decimal.Parse(tb3_skv.Text); y = int.Parse(tb3_kva.Text); a = decimal.Parse(tb3_z.Text); b = int.Parse(tb3_ml.Text); z = ((y * 1000) / (x * 1.732050808m) / (a / 100))+((b / 100)*(6*y)/(x*1.732050808m)*1000); tb3_aic.Text = z.ToString(); tb3_aic.Text = Math.Round(z,5).ToString(); } } </code></pre> <p>I am grateful for any help that can be provided. </p> <p>Thank you, Greg Rutledge</p>
[ { "answer_id": 360946, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 2, "selected": false, "text": "int y, b;\n" }, { "answer_id": 360952, "author": "Programmin Tool", "author_id": 21691, "author_profile": ...
2008/12/11
[ "https://Stackoverflow.com/questions/360899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45151/" ]
360,912
<p>If an application† crashes,</p> <p><a href="https://i.stack.imgur.com/o8DiZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o8DiZ.png" alt="enter image description here"></a></p> <p>I hit "Debug" and Visual Studio is my currently registered Just-In-Time (JIT) debugger:</p> <p><a href="https://i.stack.imgur.com/SKRAS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SKRAS.png" alt="enter image description here"></a></p> <p>Visual Studio appears, but there's no way to debug anything:</p> <p><a href="https://i.stack.imgur.com/Yc8tK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Yc8tK.png" alt="enter image description here"></a></p> <ul> <li>I do not see any disassembly</li> <li>I do not see any registers (assuming it runs on a CPU with registers)</li> <li>The call stack is empty (assuming the CPU has a stack pointer)</li> <li>I do not see any symbols (assuming it had any)</li> <li>I do not see reconstructed source code from reflection (assuming it was managed)</li> </ul> <p>Other JIT debugger products are able to show disassembly, but they are either command-line based (<a href="http://www.microsoft.com/whdc/devtools/debugging/default.mspx" rel="nofollow noreferrer">Debugging Tools for Windows</a>), or do not support symbols (<a href="http://www.ollydbg.de/" rel="nofollow noreferrer">OllyDbg</a>, <a href="http://en.wikipedia.org/wiki/Borland_Delphi" rel="nofollow noreferrer">Delphi</a>). Additionally, my question is about debugging using Visual Studio, since I already have it installed, and it is already my registered JIT.</p> <p>How do you debug a program using Visual Studio?</p> <p><strong>Alternatively</strong>: has anyone written a graphical debugger that supports the Microsoft symbol server?</p> <p>† Not, necessarily, written in Visual Studio.</p> <p><strong>Edit:</strong> Changes title to <strong>process</strong> rather than <strong>application</strong>, since the latter somehow implies "<em>my</em> application."</p> <p><strong>Edit:</strong> Assume the original application was written in assembly language by Steve Gibson. That is, there is no source code or debug information. Visual Studio should still be able to show me an assembly dump.</p>
[ { "answer_id": 2464489, "author": "i_am_jorf", "author_id": 74815, "author_profile": "https://Stackoverflow.com/users/74815", "pm_score": 1, "selected": false, "text": "http://msdl.microsoft.com/download/symbols" } ]
2008/12/11
[ "https://Stackoverflow.com/questions/360912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
360,913
<p>How do I update my subversion repository so it can accept updates to the log message field? I've got a Windows installation and I changed the pre-revprop-change.tmpl file name to a batch file, but now when I try to update a the log message property my tortoise svn just hangs and the property isn't updated. Am I doing something wrong? </p> <p>Since its so small, my pre-revprop-change.bat file is below</p> <pre><code>REPOS="$1" REV="$2" USER="$3" PROPNAME="$4" ACTION="$5" if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:log" ]; then exit 0; fi echo "Changing revision properties other than svn:log is prohibited" &gt;&amp;2 exit 1 </code></pre>
[ { "answer_id": 2464489, "author": "i_am_jorf", "author_id": 74815, "author_profile": "https://Stackoverflow.com/users/74815", "pm_score": 1, "selected": false, "text": "http://msdl.microsoft.com/download/symbols" } ]
2008/12/11
[ "https://Stackoverflow.com/questions/360913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18927/" ]
360,928
<p>I have a table (SQL 2000) with over 10,000,000 records. Records get added at a rate of approximately 80,000-100,000 per week. Once a week a few reports get generated from the data. The reports are typically fairly slow to run because there are few indexes (presumably to speed up the INSERTs). One new report could really benefit from an additional index on a particular "char(3)" column.</p> <p>I've added the index using Enterprise Manager (Manage Indexes -> New -> select column, OK), and even rebuilt the indexes on the table, but the SELECT query has not sped up at all. Any ideas?</p> <p><strong>Update</strong>:</p> <p>Table definition:</p> <pre><code>ID, int, PK Source, char(3) &lt;--- column I want indexed ... About 20 different varchar fields ... CreatedDate, datetime Status, tinyint ExternalID, uniqueidentifier </code></pre> <p>My test query is just:</p> <pre><code>select top 10000 [field list] where Source = 'abc' </code></pre>
[ { "answer_id": 361403, "author": "jmucchiello", "author_id": 44065, "author_profile": "https://Stackoverflow.com/users/44065", "pm_score": 0, "selected": false, "text": " select top 10000 \n" } ]
2008/12/11
[ "https://Stackoverflow.com/questions/360928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1664/" ]
360,935
<p>I have a menu of report links in my master page. I need to append an ID to the end of each whenever the user changes a value on the child page. What's a good way to accomplish this?</p> <p>UPDATE: I should have mentioned that the child update is happening inside an UpdatePanel, meaning the master page is not reloaded when the change happens.</p>
[ { "answer_id": 361010, "author": "jrcs3", "author_id": 3819, "author_profile": "https://Stackoverflow.com/users/3819", "pm_score": 2, "selected": false, "text": "public partial class _default : System.Web.UI.MasterPage\n{\n protected string m_myString = string.Empty;\n public strin...
2008/12/11
[ "https://Stackoverflow.com/questions/360935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23935/" ]
360,943
<p>I have a problem on how to read text from file and perform operations on it for example</p> <p>i have this text file that include</p> <p>//name-//sex---------//birth //m1//m2//m3</p> <pre><code>fofo, male, 1986, 67, 68, 69 momo, male, 1986, 99, 98, 100 Habs, female, 1988, 99, 100, 87 toto, male, 1989, 67, 68, 69 lolo, female, 1990, 89, 80, 87 soso, female, 1988, 99, 100, 83 </code></pre> <p>now i know how to read line by line till i reach null .</p> <p>but this time I want later to perform and average function to get the average of the first colume of numbers m1</p> <p>and then get the average of m1 for females only and for males only</p> <p>and some other operations that i can do no problem</p> <hr> <p>I need help i don't know how to get it what i have in mind is to read each line in the text file and put it in a string then split the string (str.Split(','); ) but how to get the m1 record on each string I'm really confused should i use regex to get the integers ? should i use an array 2d? I'm totally lost, any ideas? </p> <p>please if u can improve any ideas by a code sample that will be great and a kindness initiation from u.</p> <p>and after i done it i will post it for you guys to check.</p> <p>{ as a girl I Think I made the wrong decision to join the IT community :-( }</p>
[ { "answer_id": 360996, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "List<T>" }, { "answer_id": 361033, "author": "Tim Jarvis", "author_id": 10387, "author_profile": ...
2008/12/11
[ "https://Stackoverflow.com/questions/360943", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
360,961
<p>I've got a table, called faq_questions with the following structure:</p> <pre><code>id int not_null auto_increment, question varchar(255), sort_order int </code></pre> <p>I'm attempting to build a query that given a sort order, selects the row with the next highest sort order. </p> <p>Example:</p> <pre><code>id question sort_order 1 'This is question 1' 10 2 'This is question 2' 9 3 'This is another' 8 4 'This is another one' 5 5 'This is yet another' 4 </code></pre> <p>Ok, so imagine I pass in 5 for my known sort order (id 4), I need it to return the row with id 3. Since there's no guarantee that sort_order will be contiguous I can't just select known_sort_order + 1. </p> <p>Thanks! </p>
[ { "answer_id": 360975, "author": "Eran Galperin", "author_id": 10585, "author_profile": "https://Stackoverflow.com/users/10585", "pm_score": 6, "selected": true, "text": "SELECT id,question FROM `questions` \nWHERE `sort_order` > sort_order_variable\nORDER BY sort_order ASC \nLIMIT 1\n" ...
2008/12/11
[ "https://Stackoverflow.com/questions/360961", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1742702/" ]
360,968
<p>I'm seeing some code I've inherited that looks like the following:</p> <pre><code>@interface SomeClass (private) </code></pre> <p>This is within <code>SomeClass.m</code>, the implementation file. There is an accompanying header file which doesn't suggest that the class is using a category. Is <code>(private)</code> in this case just a poor name given to a category for <code>SomeClass</code>? And I'm assuming it's perfectly legitimate to specify categories such as these in an implementation?</p>
[ { "answer_id": 361140, "author": "Abizern", "author_id": 41116, "author_profile": "https://Stackoverflow.com/users/41116", "pm_score": 6, "selected": true, "text": "@interface NSString (Capitals)\n\n-(NSString *)alternateCaps:(NSString *)aString;\n\n@end\n" } ]
2008/12/11
[ "https://Stackoverflow.com/questions/360968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40882/" ]
360,982
<p>I was searching here about converting a string like "16:20" to a DateTime type without losing the format, I said I dont want to add dd/MM/yyy or seconds or AM/PM, because db just accept this format.</p> <p>I tried with Cultures yet</p> <p>Thanks in Advance</p>
[ { "answer_id": 360998, "author": "MartinHN", "author_id": 2972, "author_profile": "https://Stackoverflow.com/users/2972", "pm_score": 2, "selected": false, "text": "DateTime dt = new DateTime(2008, 12, 11, Convert.ToInt32(\"16\"), Convert.ToInt32(\"32\"), 0);\n" }, { "answer_id":...
2008/12/11
[ "https://Stackoverflow.com/questions/360982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1388553/" ]
360,990
<p>I am looking to get a list of the column names returned from a Model. Anyone know how this would be done, any help would be greatly appreciated.</p> <p>Example Code:</p> <pre><code>var project = db.Projects.Single(p =&gt; p.ProjectID.Equals(Id)); </code></pre> <p>This code would return the Projects object, how would I get a list of all the column names in this Model.</p> <p>Thanks</p>
[ { "answer_id": 361201, "author": "shahkalpesh", "author_id": 23574, "author_profile": "https://Stackoverflow.com/users/23574", "pm_score": 2, "selected": true, "text": "DataContext" }, { "answer_id": 362745, "author": "tsquillario", "author_id": 45509, "author_profile...
2008/12/11
[ "https://Stackoverflow.com/questions/360990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45509/" ]
360,992
<p>Can anyone explain the differences between <strong>Protocols</strong> and <strong>Categories</strong> in Objective-C? When do you use one over the other?</p>
[ { "answer_id": 361067, "author": "mipadi", "author_id": 28804, "author_profile": "https://Stackoverflow.com/users/28804", "pm_score": 8, "selected": true, "text": "NSObject" }, { "answer_id": 361072, "author": "e.James", "author_id": 33686, "author_profile": "https://...
2008/12/11
[ "https://Stackoverflow.com/questions/360992", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40882/" ]
361,002
<p>For fun, I'm trying to write one of my son's favorite board games as a piece of software. Eventually I expect to build a WPF UI on top of it, but right now I'm building the machine that models the games and its rules.</p> <p>As I do this, I keep seeing problems that I think are common to many board games, and perhaps others have already solved them better than I will. </p> <p>(Note that AI to play the game, and patterns around high performance are not interesting to me.)</p> <p>So far my patterns are:</p> <ul> <li><p>Several immutable types representing entities in the game box, e.g. dice, checkers, cards, a board, spaces on the board, money, etc.</p></li> <li><p>An object for each player, which contains the players resources (e.g. money, score), their name, etc.</p></li> <li><p>An object that represents the state of the game: the players, who's turn it is, the layout of the peices on the board, etc.</p></li> <li><p>A state machine that manages the turn sequence. For example, many games have a small pre-game where each player rolls to see who goes first; that's the start state. When a player's turn starts, first they roll, then they move, then they have to dance in place, then other players guess what breed of chicken they are, then they receive points.</p></li> </ul> <p>Is there some prior art I can take advantage of?</p> <p><strong>EDIT:</strong> One thing I realized recently is that game state can be split in to two categories:</p> <ul> <li><p><strong>Game artifact state</strong>. "I have $10" or "my left hand is on blue".</p></li> <li><p><strong>Game sequence state</strong>. "I have rolled doubles twice; the next one puts me in jail". A state machine may make sense here.</p></li> </ul> <p><strong>EDIT:</strong> What I'm really looking for here is the <em>best</em> way to implement multiplayer turn-based games like Chess or Scrabble or Monopoly. I'm sure I could create such a game by just working through it start to finish, but, like other Design Patterns, there are probably some ways to make things go much more smoothly that aren't obvious without careful study. That's what I'm hoping for. </p>
[ { "answer_id": 361254, "author": "Stefan", "author_id": 19307, "author_profile": "https://Stackoverflow.com/users/19307", "pm_score": 3, "selected": false, "text": "1 2 3 \n4 (5) 6 BoardArray 5 = row 2, col 2\n7 8 9 \n" }, { "answer_id": 558437, "author": "Andrew Top",...
2008/12/11
[ "https://Stackoverflow.com/questions/361002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5314/" ]
361,049
<p>I have a web application deployed in an internet hosting provider. This web application consumes a WCF Service deployed at an IIS server located at my company’s application server, in order to have data access to the company’s database, the network guys allowed me to expose this WCF service through a firewall for security reasons. A diagram would look like this. </p> <blockquote> <p>[Hosted page] ---> (Internet) ---> |Firewall <code>&lt;Public IP&gt;:&lt;Port-X &gt;</code>| ---> [IIS with WCF Service <code>&lt;Comp. Network Ip&gt;:&lt;Port-Y&gt;</code>]</p> </blockquote> <p>I also wanted to use wsHttpBinding to take advantage of its security features, and encrypt sensible information.</p> <p>After trying it out I get the following error:</p> <blockquote> <p>Exception Details: System.ServiceModel.EndpointNotFoundException: The message with To 'http://:/service/WCFService.svc' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.</p> </blockquote> <p>Doing some research I found out that wsHttpBinding uses WS-Addressing standards, and reading about this standard I learned that the SOAP header is enhanced to include tags like ‘MessageID’, ‘ReplyTo’, ‘Action’ and ‘To’.</p> <p>So I’m guessing that, because the client application endpoint specifies the Firewall IP address and Port, and the service replies with its internal network address which is different from the Firewall’s IP, then WS-Addressing fires the above message. Which I think it’s a very good security measure, but it’s not quite useful in my scenario.</p> <p>Quoting the WS-Addressing standard submission (<a href="http://www.w3.org/Submission/ws-addressing/" rel="nofollow noreferrer">http://www.w3.org/Submission/ws-addressing/</a>) </p> <blockquote> <p>"Due to the range of network technologies currently in wide-spread use (e.g., NAT, DHCP, firewalls), many deployments cannot assign a meaningful global URI to a given endpoint. To allow these ‘anonymous’ endpoints to initiate message exchange patterns and receive replies, WS-Addressing defines the following well-known URI for use by endpoints that cannot have a stable, resolvable URI. <a href="http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous" rel="nofollow noreferrer">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a>"</p> </blockquote> <p><strong>HOW can I configure my wsHttpBinding Endpoint to address my Firewall’s IP and to ignore or bypass the address specified in the ‘To’ WS-Addressing tag in the SOAP message header? Or do I have to change something in my service endpoint configuration?</strong></p> <p>Help and guidance will be much appreciated.</p> <p>Marko.</p> <p>P.S.: While I find any solution to this, I’m using basicHttpBinding with absolutely no problem of course.</p>
[ { "answer_id": 362108, "author": "Mitch Baker", "author_id": 37896, "author_profile": "https://Stackoverflow.com/users/37896", "pm_score": 4, "selected": true, "text": "[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]\n" } ]
2008/12/11
[ "https://Stackoverflow.com/questions/361049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45516/" ]
361,066
<p>I recently <a href="https://stackoverflow.com/questions/353912/functional-programming-state-vs-reassignment">asked a question</a> about functional programming, and received (good!) answers that prompted more questions (as seems to be the case with learning, sometimes). Here are a couple examples:</p> <ol> <li><p>One answer made reference to an advantage of immutable data structures: each thread can have its own copy. Now, to me, this sounds rather like a version control system (to use an analogy), where instead of locking code that someone has checked out so that it can't be modified by anyone else, everyone can check out their own copies. Sounds good. However, in VCS you have the concept of "merging" changes, in the case that two people changed the same stuff. It seems like this issue could certainly come up in a multithreaded scenario... so how is "merging" done when it's important that threads see the most recent data?</p></li> <li><p><a href="https://stackoverflow.com/questions/353912/functional-programming-state-vs-reassignment#355040">This answer</a> talked about the case where operations were being performed in a loop on an object, and how you can use a new object each time through instead of updating an old one. However, let's say the <code>bankAccount</code> is being updated in a non-loop scenario--for example a GUI banking system. The operator clicks the "Change Interest Rate" button, which fires an event that would (in C# for example) do something like <code>bankAccount.InterestRate = newRateFromUser</code>. I feel like I'm being dense here, but hopefully my example makes sense: there has to be some way that the object is updated, right? Several other things may depend on the the new data.</p></li> </ol> <p>Anyway, if you can help me get my head around the paradigm shift, I'd be appreciative. I remember my brain going through similar "stupid phases" when learning OOP after a background of the simple procedural imperative approach to coding.</p>
[ { "answer_id": 361379, "author": "tsimon", "author_id": 1685, "author_profile": "https://Stackoverflow.com/users/1685", "pm_score": 3, "selected": false, "text": "String s1 = \"there\";\nString s2 = s1.Insert(0, \"hello \");\n\nConsole.Writeline(\"string 1: \" + s1);\nConsole.Writeline(\...
2008/12/11
[ "https://Stackoverflow.com/questions/361066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38803/" ]
361,069
<p>An answer and subsequent <a href="https://stackoverflow.com/questions/360899/c-math-problem#360931">debate in the comments</a> in another thread prompted me to ask:</p> <p>In C# || and &amp;&amp; are the short-circuited versions of the logical operators | and &amp; respectively.<br /></p> <p>Example usage:</p> <pre><code>if (String.IsNullOrEmpty(text1) | String.IsNullOrEmpty(text2) | String.IsNullOrEmpty(text3)) { //... } </code></pre> <p>versus:</p> <pre><code>if (String.IsNullOrEmpty(text1) || String.IsNullOrEmpty(text2) || String.IsNullOrEmpty(text3)) { //... } </code></pre> <p>In terms of coding practice which is the better to use and why?</p> <p>Note: I do realize this question is similar to <a href="https://stackoverflow.com/questions/89154/benefits-of-using-short-circuit-evaluation">this question</a> but I believe it warrants a language specific discussion.</p>
[ { "answer_id": 361085, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 7, "selected": true, "text": "bool nullorempty = str == null || str.Length == 0;\n" }, { "answer_id": 361106, "author": "Grant Wagner", ...
2008/12/11
[ "https://Stackoverflow.com/questions/361069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33226/" ]
361,077
<p>Today I ran into a problem were I needed to remote-debug a program. The program was launched from another system, so I really don't have an opportunity to interact with it on the command line. I could change its source easily though.</p> <p>What I needed to happen was for the program to start normally, and then wait for me to attach to it with a debugger. I couldn't come up with a way to do it that made me happy. I did find the bug, but without the help of the debugger.</p> <pre><code>while(true) { } </code></pre> <p>Kept the process alive, and then I could "set next statement" with the debugger, but it seemed awkward and rude.</p> <pre><code>Console.ReadLine(); </code></pre> <p>Seemed odd to type since there wasn't actually a Console for me to press <strong>enter</strong> at. (It didn't work, either. Set next statement and then run takes you back into the ReadLine() wait.)</p> <p>So what kind of code can I insert into a .NET/CLR/C# program that says "wait here until I can attach with a debugger"?</p>
[ { "answer_id": 361124, "author": "Steven Behnke", "author_id": 42588, "author_profile": "https://Stackoverflow.com/users/42588", "pm_score": 3, "selected": false, "text": "System.Diagnostics.Debugger.Break()" }, { "answer_id": 361125, "author": "Arron S", "author_id": 166...
2008/12/11
[ "https://Stackoverflow.com/questions/361077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8173/" ]
361,097
<p>I have a service that sometimes calls a batch file. The batch file takes 5-10 seconds to execute:</p> <pre><code>System.Diagnostics.Process proc = new System.Diagnostics.Process(); // Declare New Process proc.StartInfo.FileName = fileName; proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; proc.StartInfo.CreateNoWindow = true; proc.Start(); proc.WaitForExit(); </code></pre> <p>The file does exist and the code works when I run the same code in-console. However when it runs inside the service, it hangs up at <code>WaitForExit()</code>. I have to kill the batch file from the Process in order to continue. (I am certain the file exists, as I can see it in the processes list.)</p> <p>How can I fix this hang-up?</p> <h1>Update #1:</h1> <p>Kevin's code allows me to get output. One of my batch files is still hanging. </p> <blockquote> <p>"C:\EnterpriseDB\Postgres\8.3\bin\pg_dump.exe" -i -h localhost -p 5432 -U postgres -F p -a -D -v -f "c:\backupcasecocher\backupdateevent2008.sql" -t "\"public\".\"dateevent\"" "DbTest" </p> </blockquote> <p>The other batch file is:</p> <blockquote> <p>"C:\EnterpriseDB\Postgres\8.3\bin\vacuumdb.exe" -U postgres -d DbTest</p> </blockquote> <p>I have checked the path and the <code>postgresql</code> path is fine. The output directory does exist and still works outside the service. Any ideas?</p> <h1>Update #2:</h1> <p>Instead of the path of the batch file, I wrote the "C:\EnterpriseDB\Postgres\8.3\bin\pg_dump.exe" for the <code>proc.StartInfo.FileName</code> and added all parameters to <code>proc.StartInfo.Arguments</code>. The results are unchanged, but I see the <code>pg_dump.exe</code> in the process window. Again this only happens inside the service.</p> <h1>Update #3:</h1> <p>I have run the service with a user in the administrator group, to no avail. I restored <code>null</code> for the service's username and password</p> <h1>Update #4:</h1> <p>I created a simple service to write a trace in the event log and execute a batch file that contains "dir" in it. It will now hang at <code>proc.Start();</code> - I tried changing the Account from LocalSystem to <strong>User</strong> and I set the admnistrator user and password, still nothing.</p>
[ { "answer_id": 361121, "author": "kemiller2002", "author_id": 1942, "author_profile": "https://Stackoverflow.com/users/1942", "pm_score": 6, "selected": true, "text": "proc.StartInfo.FileName = target;\nproc.StartInfo.RedirectStandardError = true;\nproc.StartInfo.Redir...
2008/12/11
[ "https://Stackoverflow.com/questions/361097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13913/" ]
361,115
<p>I tried to make a dynamic 2D array of <code>char</code> as follow:</p> <pre><code>char** ppMapData = (char**)malloc(sizeof(char*)*iMapHeight); for (int i=0; i&lt; iMapHeight; i++) { ppMapData[i] = (char*)malloc(sizeof(char)*iMapWidth); //do something } // do something for (int i=0; i&lt;iMapHeight; i++) free(ppMapData[i]); free(ppMapData); </code></pre> <p>It looks fine to me; however, when it comes to run time, my program crash at the line which calls <code>free(ppMapData[i])</code>. Any ideas what is the problem here. Thank you very much.</p>
[ { "answer_id": 361131, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 2, "selected": false, "text": "vector<vector<char> >" }, { "answer_id": 361246, "author": "jmucchiello", "author_id": 44065, "au...
2008/12/11
[ "https://Stackoverflow.com/questions/361115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
361,130
<p>When selecting a block of text (possibly spanning across many DOM nodes), is it possible to extract the selected text and nodes using Javascript?</p> <p>Imagine this HTML code:</p> <pre><code>&lt;h1&gt;Hello World&lt;/h1&gt;&lt;p&gt;Hi &lt;b&gt;there!&lt;/b&gt;&lt;/p&gt; </code></pre> <p>If the user initiated a mouseDown event starting at "World..." and then a mouseUp even right after "there!", I'm hoping it would return:</p> <pre><code>Text : { selectedText: "WorldHi there!" }, Nodes: [ { node: "h1", offset: 6, length: 5 }, { node: "p", offset: 0, length: 16 }, { node: "p &gt; b", offset: 0, length: 6 } ] </code></pre> <p>I've tried putting the HTML into a textarea but that will only get me the selectedText. I haven't tried the <code>&lt;canvas&gt;</code> element but that may be another option.</p> <p>If not JavaScript, is there a way this is possible using a Firefox extension? </p>
[ { "answer_id": 364476, "author": "Borgar", "author_id": 27388, "author_profile": "https://Stackoverflow.com/users/27388", "pm_score": 5, "selected": true, "text": "// selection objects will differ between browsers\nfunction getSelection () {\n return ( msie ) \n ? document.selection\...
2008/12/11
[ "https://Stackoverflow.com/questions/361130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45435/" ]
361,135
<p>I have a table where I store customer sales (on periodicals, like newspaper) data. The product is stored by issue. Example</p> <pre> custid prodid issue qty datesold 1 123 2 12 01052008 2 234 1 5 01022008 1 123 1 5 01012008 2 444 2 3 02052008 </pre> <p>How can I retrieve (whats a faster way) the get last issue for all products, for a specific customer? Can I have samples for both SQL Server 2000 and 2005? Please note, the table is over 500k rows.</p> <p>Thanks</p>
[ { "answer_id": 361146, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "SELECT prodid, max(issue) FROM sales WHERE custid = ? GROUP BY prodid;\n" }, { "answer_id": 361183, "author": "Pat...
2008/12/11
[ "https://Stackoverflow.com/questions/361135", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23667/" ]
361,137
<p>Is it possible to bypass the Freemarker cache when certain templates are requested? I realise that I'll probably have to implement my own TemplateLoader in order to do this, but even so, I can't see a way to check the cache when say template A is requested, but bypass it when template B is requested?</p> <p>If this is not possible, I'll just have to disable caching completely.</p>
[ { "answer_id": 361242, "author": "Dan Vinton", "author_id": 21849, "author_profile": "https://Stackoverflow.com/users/21849", "pm_score": 2, "selected": false, "text": "configuration.setTemplateUpdateDelay(0);\n" }, { "answer_id": 972122, "author": "toluju", "author_id": ...
2008/12/11
[ "https://Stackoverflow.com/questions/361137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
361,151
<p>I made an html file called test.html then I navigated to it as "<a href="http://site.com/test.html?test1=a" rel="nofollow noreferrer">http://site.com/test.html?test1=a</a>" but the textbox stayed blank. Why is this? </p> <p>Super simple code</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Test&lt;/title&gt; &lt;/head&gt; &lt;body &gt; &lt;input type=text name="test1"&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
[ { "answer_id": 361158, "author": "Sydius", "author_id": 43496, "author_profile": "https://Stackoverflow.com/users/43496", "pm_score": 3, "selected": true, "text": "<html>\n<head>\n <title>Test</title>\n</head>\n<body>\n <input type=\"text\" name=\"test1\" value=\"<?php echo htmlspe...
2008/12/11
[ "https://Stackoverflow.com/questions/361151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39143/" ]
361,161
<p>I have a Rails app that lets a user construct a database query by filling out an extensive form. I wondered the best practice for checking form parameters in Rails. Previously, I have had my <code>results</code> method (the one to which the form submits) do the following:</p> <pre><code>if params[:name] &amp;&amp; !params[:name].blank? @name = params[:name] else flash[:error] = 'You must give a name' redirect_to :action =&gt; 'index' return end </code></pre> <p>But for several form fields, seeing this repeated for each one got tiresome. I couldn't just stick them all in some loop to check for each field, because the fields are set up differently:</p> <ul> <li>a single key: <code>params[:name]</code></li> <li>a key and a sub-key: <code>params[:image][:font_size]</code></li> <li>only expect some form fields to be filled out if another field was set</li> </ul> <p>Etc. This was also repetitive, because I was setting <code>flash[:error]</code> for each missing/invalid parameter, and redirecting to the same URL for each one. I switched to using a <code>before_filter</code> that checks for all necessary form parameters and only returns true if everything's okay. Then the my <code>results</code> method continues, and variables are just assigned flat-out, with no checking involved:</p> <pre><code>@name = params[:name] </code></pre> <p>In my <code>validate_form</code> method, I have sections of code like the following:</p> <pre><code>if ( params[:analysis_type][:to_s] == 'development' || params[:results_to_generate].include?('graph') ) {:graph_type =&gt; :to_s, :graph_width =&gt; :to_s, :theme =&gt; :to_s}.each do |key, sub_key| unless params[key] &amp;&amp; params[key][sub_key] flash[:error] = "Cannot leave '#{Inflector.humanize(key)}' blank" redirect_to(url) return false end end end </code></pre> <p>I was just wondering if I'm going about this in the best way, or if I'm missing something obvious when it comes to parameter validation. I worry this is still not the most efficient technique, because I have several blocks where I assign a value to <code>flash[:error]</code>, then redirect to the same URL, then return false.</p> <p><em>Edit to clarify:</em> The reason I don't have this validation in model(s) currently is for two reasons:</p> <ul> <li>I'm not trying to gather data from the user in order to create or update a row in the database. None of the data the user submits is saved after they log out. It's all used right when they submit it to search the database and generate some stuff.</li> <li>The query form takes in data pertaining to several models, and it takes in other data that doesn't pertain to a model at all. E.g. graph type and theme as shown above do not connect to any model, they just convey information about how the user wants to display his results.</li> </ul> <p><em>Edit to show improved technique:</em> I make use of application-specific exceptions now, thanks to Jamis Buck's <a href="http://weblog.jamisbuck.org/2007/3/7/raising-the-right-exception" rel="noreferrer">Raising the Right Exception article</a>. For example:</p> <pre><code>def results if params[:name] &amp;&amp; !params[:name].blank? @name = params[:name] else raise MyApp::MissingFieldError end if params[:age] &amp;&amp; !params[:age].blank? &amp;&amp; params[:age].numeric? @age = params[:age].to_i else raise MyApp::MissingFieldError end rescue MyApp::MissingFieldError =&gt; err flash[:error] = "Invalid form submission: #{err.clean_message}" redirect_to :action =&gt; 'index' end </code></pre>
[ { "answer_id": 361699, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 6, "selected": true, "text": "class MyForm < ActiveForm\n validates_presence_of :name\n validates_presence_of :graph_size, :if => # ...blah blah \nend\n\nf...
2008/12/11
[ "https://Stackoverflow.com/questions/361161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38743/" ]
361,163
<p>I want to use pretty 3d button images on my website. However, currently the way this works is the text is part of the image.</p> <p>So, when I want to change the text (or make a new button) it's a 10 minute editing chore instead of a 20 second text change.</p> <p>I've seen a few websites that have a blank button with text on it.</p> <p>The real trick is making the <em>entire</em> image clickable. I've been able to make the link inside an image visible but that's a poor UI. Users will expect to click the button anywhere and failure to behave that way will frustrate them.</p> <p>It seems like they're wrapping a .DIV tag with an image background around a Hyperlink.</p> <pre> &lt;Div (class w/ image> &lt;a> text &lt;/a> </pre> <p>EXAMPLE: <a href="https://www.box.net/signup/g" rel="nofollow noreferrer">https://www.box.net/signup/g</a></p> <p>Anyone have any insight or explanation of how this works?'</p> <p>CODE SAMPLE</p> <pre><code>&lt;a href="#" class="button" style="position: relative;left:-5px;" onmousedown="return false;" onclick="document.forms['register_form'].submit(); return false;"&gt; &lt;span&gt; My text &lt;/span&gt; &lt;/a&gt; </code></pre>
[ { "answer_id": 361171, "author": "Jimmy", "author_id": 4435, "author_profile": "https://Stackoverflow.com/users/4435", "pm_score": 0, "selected": false, "text": "a { \n width: something ; \n height: something; \n display: block; \n background: url('hi.png'); \n }\n" }, { ...
2008/12/11
[ "https://Stackoverflow.com/questions/361163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4906/" ]
361,175
<p>Been using the code below to return a single record from the database. I have read that ExecuteScalar is the right way to return a single record. I have never been able to get ExecuteScalar to work though. How would I change this to return a single value in VB.Net using ExecuteScalar?</p> <pre><code> Dim oracleConnection As New OracleConnection oracleConnection.ConnectionString = LocalConnectionString() Dim cmd As New OracleCommand() Dim o racleDataAdapter As New OracleClient.OracleDataAdapter cmd.Connection = oracleConnection cmd.CommandText = "FALCON.CMS_DATA.GET_MAX_CMS_TH" cmd.CommandType = CommandType.StoredProcedure cmd.Parameters.Add(New OracleParameter("i_FACID_C", OracleType.Char)).Value = facilityShortName cmd.Parameters.Add(New OracleParameter("RS_MAX", OracleType.Cursor)).Direction = ParameterDirection.Output Try Using oracleConnection oracleConnection.Open() Using oracleDataAdapter oracleDataAdapter = New OracleClient.OracleDataAdapter(cmd) Dim workingDataSet As DataSet oracleDataAdapter.TableMappings.Add("OutputSH", "RS_MAX") workingDataSet = New DataSet oracleDataAdapter.Fill(workingDataSet) For Each row As DataRow In workingDataSet.Tables(0).Rows Return CDate(row("MAXDATE")) Next End Using End Using </code></pre>
[ { "answer_id": 372242, "author": "Brian Schmitt", "author_id": 30492, "author_profile": "https://Stackoverflow.com/users/30492", "pm_score": 0, "selected": false, "text": "oracleConnection.Open\nDim obj as object 'Object to hold our return value\nobj = cmd.ExecuteScalar()\noracleConnecti...
2008/12/11
[ "https://Stackoverflow.com/questions/361175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38349/" ]
361,193
<p>I'm the developer of twittertrend.net, I was wondering if there was a faster way to get headers of a URL, besides doing curl_multi? I process over 250 URLs a minute, and I need a really fast way to do this from a PHP standpoint. Either a bash script could be used and then output the headers or C appliation, anything that could be faster? I have primarily only programmed in PHP, but I can learn. Currently, CURL_MULTI (with 6 URLs provided at once, does an ok job, but I would prefer something faster? Ultimately I would like to stick with PHP for any MySQL storing and processing.</p> <p>Thanks, James Hartig</p>
[ { "answer_id": 361263, "author": "Pras", "author_id": 45435, "author_profile": "https://Stackoverflow.com/users/45435", "pm_score": 1, "selected": false, "text": "curl_setopt ($ch, CURLOPT_HEADER, 1);\ncurl_setopt ($ch, CURLOPT_NOBODY, 1);\ncurl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);\n...
2008/12/11
[ "https://Stackoverflow.com/questions/361193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45530/" ]
361,204
<p>I am trying to use ASP to create a connection to my database and i have the following connection code:</p> <pre><code>Set objConn = ConnectDB() Set objRS = objConn.Execute(query) </code></pre> <p>I have an include file that I have at the top of my page:</p> <pre><code>&lt;!--#include FILE=dbcano.inc--&gt; </code></pre> <p>And I get this error when I call my page:</p> <blockquote> <p>Microsoft VBScript runtime error '800a01f4' Variable is undefined: 'ConnectDB' patti_trinkets.asp, line 9</p> </blockquote> <p>The <code>ConnectDB()</code> is a function I created that is stored within the <code>dbcano.inc</code> file.</p> <p>Any suggestions as to why I am getting this error when I call my page?</p> <p>My full code can be found here: <a href="http://pastie.org/337183" rel="nofollow noreferrer">http://pastie.org/337183</a></p>
[ { "answer_id": 361263, "author": "Pras", "author_id": 45435, "author_profile": "https://Stackoverflow.com/users/45435", "pm_score": 1, "selected": false, "text": "curl_setopt ($ch, CURLOPT_HEADER, 1);\ncurl_setopt ($ch, CURLOPT_NOBODY, 1);\ncurl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);\n...
2008/12/11
[ "https://Stackoverflow.com/questions/361204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
361,209
<p>I've got two controls, a TextBlock and a PopUp. When the user clicks (MouseDown) on the textblock, I want to display the popup. I would think that I could do this with an EventTrigger on the Popup, but I can't use setters in an EventTrigger, I can only start storyboards. I want to do this strictly in XAML, because the two controls are in a template and I don't know how I'd find the popup in code.</p> <p>This is what conceptually I want to do, but can't because you can't put a setter in an EventTrigger (like you can with a DataTrigger):</p> <pre><code>&lt;TextBlock x:Name="CCD"&gt;Some text&lt;/TextBlock&gt; &lt;Popup&gt; &lt;Popup.Style&gt; &lt;Style&gt; &lt;Style.Triggers&gt; &lt;EventTrigger SourceName="CCD" RoutedEvent="MouseDown"&gt; &lt;Setter Property="Popup.IsOpen" Value="True" /&gt; &lt;/EventTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/Popup.Style&gt; ... </code></pre> <p>What is the best way to show a popup strictly in XAML when an event happens on a different control?</p>
[ { "answer_id": 361302, "author": "bendewey", "author_id": 37881, "author_profile": "https://Stackoverflow.com/users/37881", "pm_score": 3, "selected": false, "text": "<Window x:Class=\"WpfApplication1.Window1\"\n xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\n ...
2008/12/11
[ "https://Stackoverflow.com/questions/361209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4572/" ]
361,225
<p>I'd like to create a custom loading screen for a JavaFX application. Don't want the user to see the Java coffee cup icon, I want to put my own graphic there!</p> <p>I've found out how to provide a static image, or even an animated GIF, but I'm more interested in a Flash-like screen where I can specify what the state of the image looks like at certain percentages.</p> <p>Any ideas?</p>
[ { "answer_id": 23728365, "author": "ufukomer", "author_id": 3650955, "author_profile": "https://Stackoverflow.com/users/3650955", "pm_score": -1, "selected": false, "text": "stage.getIcons().add(new Image(\"images/myimage.png\"));\n" }, { "answer_id": 24479931, "author": "dro...
2008/12/11
[ "https://Stackoverflow.com/questions/361225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2197/" ]
361,231
<p>I have a cookie which is generated from a servlet and that I would like to be persistent - that is, set the cookie, close down IE, start it back up, and still be able to read the cookie. The code that I'm using is the following:</p> <pre><code>HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance() .getExternalContext().getResponse(); Cookie cookie = new Cookie("someKey", "someValue"); cookie.setMaxAge(7 * 24 * 60 * 60); response.addCookie(cookie); </code></pre> <p>This works great in firefox, but in IE 6/7, the cookie is not saved between browser restarts. I've checked everything that I can think of in my settings, but can't figure out what would be causing the cookie to be deleted. As far as I know, calling setMaxAge with a positive number makes the cookie persistent. Any ideas why this would be going wrong?</p> <p><b>Edit</b></p> <p>I have verified, using the more info trick suggested by Olaf, that the cookie is attempting to be set as a session cookie, not a persistent cookie; the max age is set to "end of session". So it doesn't seem like the max age is being set for IE - I have verified that in Firefox, the max age is set correctly. I still have no idea what's going on.</p>
[ { "answer_id": 4187173, "author": "Briguy37", "author_id": 508537, "author_profile": "https://Stackoverflow.com/users/508537", "pm_score": 0, "selected": false, "text": "public static String encodeString(String s) {\n String encodedString = s;\n\n try{\n encodedString = URLE...
2008/12/11
[ "https://Stackoverflow.com/questions/361231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1322/" ]
361,247
<p>I have some data that I want to store somewhere in my Rails app because I use it for generating form fields, checking a submitted form to ensure its values are valid, etc. Basically, I want the data in one location because I make use of it in several places.</p> <p>Previously, I was defining an <code>initialize</code> method in my controller and initializing instance variables within that method, e.g. <code>@graph_types = ['bar', 'line']</code>. This seemed a bad idea because that's really all <code>initialize</code> was being used for (initializing those values) and the instance variables could be changed later, which I don't want.</p> <p>Now, I define constants outside of any method in my controller, right up at the top after my filters, and I freeze them, e.g. <code>GraphTypes = ['bar', 'line'].freeze</code>.</p> <p>I didn't want to store such data in a config file because then I would have to keep track of an extra file, read in the file and parse it, etc. I didn't want to store this data in the database because that seems like overkill; I don't need to do any crazy LEFT OUTER JOIN-type queries combining available graph types with another of my constants, say <code>Themes = ['Keynote', 'Odeo', '37 Signals', 'Rails Keynote'].freeze</code>. I didn't want to store the data in environment.rb because this data only pertains to a particular controller.</p> <p>Considering all this, am I going about this 'the Ruby way'?</p>
[ { "answer_id": 362247, "author": "Daniel Lucraft", "author_id": 11951, "author_profile": "https://Stackoverflow.com/users/11951", "pm_score": 2, "selected": false, "text": "GRAPH_TYPES" }, { "answer_id": 364712, "author": "user37011", "author_id": 37011, "author_profi...
2008/12/11
[ "https://Stackoverflow.com/questions/361247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38743/" ]
361,248
<p>Does VbScript have a native implementation for Regex? I need to validate e-mail addresses on an old ASP application.</p> <p>Any pointers would be great.</p>
[ { "answer_id": 361273, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": 4, "selected": true, "text": "Function ValidEmail(ByVal emailAddress) \n\n'this function will use regular expressions to check an '\n'email address for v...
2008/12/11
[ "https://Stackoverflow.com/questions/361248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965/" ]
361,258
<p>I was going through some code and came across a scenario where my combobox has not been initialized yet. This is in .NET 2.0 and in the following code, this.cbRegion.SelectedValue is null.</p> <pre><code>int id = (int)this.cbRegion.SelectedValue; </code></pre> <p>This code threw a null reference exception instead of an invalid cast exception. I was wondering if anyone knew why it would throw a null reference exception instead of a invalid cast?</p>
[ { "answer_id": 361303, "author": "liggett78", "author_id": 19762, "author_profile": "https://Stackoverflow.com/users/19762", "pm_score": 3, "selected": false, "text": "object o = null;\nint a = (int)o;\n" } ]
2008/12/11
[ "https://Stackoverflow.com/questions/361258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23502/" ]
361,266
<p>If I have a base class such that</p> <pre><code>public abstract class XMLSubscription &lt;T extends XMLMessage&gt; </code></pre> <p>Is it possible to write a method in XMLSubscription that returns a class object of T?</p> <p>The only possible solution that I came up with is to have each descendant of XMLSubscription have a method like:</p> <pre><code>public class XMLStatusSubscription extends XMLSubscription&lt;XMLStatusMessage&gt; { public Class &lt;XMLStatusMessage&gt; getExpectedMessageType() { return XMLStatusMessage.class; } } </code></pre>
[ { "answer_id": 361288, "author": "Greg Case", "author_id": 462, "author_profile": "https://Stackoverflow.com/users/462", "pm_score": 3, "selected": true, "text": "Class" }, { "answer_id": 361308, "author": "kdgregory", "author_id": 42126, "author_profile": "https://St...
2008/12/11
[ "https://Stackoverflow.com/questions/361266", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7949/" ]
361,285
<p>I'm writing a basic crawler that simply caches pages with PHP.</p> <p>All it does is use <code>get_file_contents</code> to get contents of a webpage and regex to get all the links out <code>&lt;a href="URL"&gt;DESCRIPTION&lt;/a&gt;</code> - at the moment it returns:</p> <pre><code>Array { [url] =&gt; URL [desc] =&gt; DESCRIPTION } </code></pre> <p>The problem I'm having is figuring out the logic behind determining whether the page link is local or sussing out whether it may be in a completely different local directory.</p> <p>It could be any number of combinations: i.e. <code>href="../folder/folder2/blah/page.html"</code> or <code>href="google.com"</code> or <code>href="page.html"</code> - the possibilities are endless.</p> <p>What would be the correct algorithm to approach this? I don't want to lose any data that could be important.</p>
[ { "answer_id": 361320, "author": "Kornel", "author_id": 27009, "author_profile": "https://Stackoverflow.com/users/27009", "pm_score": 3, "selected": true, "text": "foreach(DOMDocument::loadHTML($source)->getElementsByTagName('a') as $a)\n{\n $a->getAttribute('href');\n}\n" } ]
2008/12/11
[ "https://Stackoverflow.com/questions/361285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24416/" ]
361,301
<p>Is there any way I can vary caching by a controller action parameter using the <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.outputcacheattribute(v=vs.108).aspx" rel="nofollow noreferrer">outputcache</a> attribute? We have <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.outputcacheattribute.varybyparam(v=vs.108).aspx" rel="nofollow noreferrer">varybyparam</a> which will not work if my parameters are embedded within the URL in a REST manner.</p>
[ { "answer_id": 865003, "author": "Simon_Weaver", "author_id": 16940, "author_profile": "https://Stackoverflow.com/users/16940", "pm_score": 3, "selected": false, "text": "[OutputCache(CacheProfile = \"ContentPage\", VaryByParam = \"mode\")]\npublic ActionResult Index(string key, string m...
2008/12/11
[ "https://Stackoverflow.com/questions/361301", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33764/" ]