qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
268,592
<p>For my website I configured some custom error pages. If I generate a 404, the redirect works fine. When hitting a 400, the "bad request" text shows up instead of the configured URl.</p> <p>As a test I copied the URL from 404 to 400. No change. Then I changed the redirect to a file. No change.</p> <p>Any ideas?</p>
[ { "answer_id": 268688, "author": "DOK", "author_id": 27637, "author_profile": "https://Stackoverflow.com/users/27637", "pm_score": 0, "selected": false, "text": "customErrors defaultRedirect error redirect" }, { "answer_id": 2506144, "author": "Nikita Ignatov", "author_id": 40185, "author_profile": "https://Stackoverflow.com/users/40185", "pm_score": 3, "selected": false, "text": "<system.webServer>\n <httpErrors errorMode=\"Custom\">\n <error statusCode=\"400\" subStatusCode=\"-1\" path=\"_path\" responseMode=\"Redirect\" />\n </httpErrors>\n</system.webServer>\n" }, { "answer_id": 12687262, "author": "Roman O", "author_id": 873053, "author_profile": "https://Stackoverflow.com/users/873053", "pm_score": 2, "selected": false, "text": "Response.TrySkipIisCustomErrors = true;\n <configuration>\n <system.webServer>\n <httpErrors existingResponse=\"PassThrough\" />\n </system.webServer>\n</configuration>\n" }, { "answer_id": 64915366, "author": "Alexander Mihailov", "author_id": 4956504, "author_profile": "https://Stackoverflow.com/users/4956504", "pm_score": 0, "selected": false, "text": "web.config <system.webServer>\n <httpErrors errorMode=\"Custom\" existingResponse=\"Replace\">\n <remove statusCode=\"400\" subStatusCode=\"-1\" />\n ...\n <error statusCode=\"400\" prefixLanguageFilePath=\"YOUR_PATH\" path=\"YOUR_HTML_FILE\" responseMode=\"File\" />\n ...\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
268,595
<p>I am trying to put version information to my C# GUI framework retrieved from the latest ClearCase label. This was originally done from Visual Soursafe as below. </p> <pre><code>vssDB = new VSSDatabaseClass(); vssDB.Open( databaseName, "vssadmin", "vssadmin" ); VSSItem item = vssDB.get_VSSItem( @"$\BuildDCP.bat", false ); foreach(VSSVersion vssVersion in item.get_Versions(0)) { // Pull the first non-blank label and use that if ( vssVersion.Label != "" ) { labelID = vssVersion.Label.ToString(); break; } } </code></pre> <p>I am trying to do something similar using ClearCase since we changed our source code control from VSS to CC. Any help would be greatly appreciated.</p> <p>Thanks!</p>
[ { "answer_id": 269624, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 2, "selected": true, "text": "Dim CC As New ClearCase.Application \nDim labelID As String\nSet aVersion = CC.Version(\"[Path-To]\\BuildDCP.bat\");\nSet someLabels = Ver.Labels;\nIf (someLabels.Count > 0) Then \n ' the first label listed is the most recently applied\n labelID = someLabels.Item(1).Type.Name\nEndIf\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
268,604
<p>This code:</p> <pre><code>#include &lt;iostream&gt; int main( int, char **argv ) { std::cout &lt;&lt; 1.23e45 &lt;&lt; std::endl; } </code></pre> <p>prints </p> <blockquote> <p>1.23e+045</p> </blockquote> <p>when compiled with MS Visual Studio 2003, and</p> <blockquote> <p>1.23e+45</p> </blockquote> <p>on my Linux machine. </p> <p>How can I specify the width of the exponent field (and why is there a difference in the first place)?</p>
[ { "answer_id": 268693, "author": "Pieter", "author_id": 5822, "author_profile": "https://Stackoverflow.com/users/5822", "pm_score": 2, "selected": true, "text": "// on linux\nstd::cout << std::scientific << 1.23e4 << std::endl\n 1.230000e+04\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19863/" ]
268,627
<p>A quick question: When declaring the DLLImport Attribute in .Net, where does the runtime look to resolve that DLL dependency? Would I have to dump the DLL and all of <em>its</em> dependencies in the bin folder?</p>
[ { "answer_id": 268631, "author": "kͩeͣmͮpͥ ͩ", "author_id": 26479, "author_profile": "https://Stackoverflow.com/users/26479", "pm_score": 2, "selected": false, "text": "echo %PATH%" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13286/" ]
268,629
<p>I am running my <code>HTTPServer</code> in a separate thread (using the threading module which has no way to stop threads...) and want to stop serving requests when the main thread also shuts down.</p> <p>The Python documentation states that <code>BaseHTTPServer.HTTPServer</code> is a subclass of <code>SocketServer.TCPServer</code>, which supports a <code>shutdown</code> method, but it is missing in <code>HTTPServer</code>.</p> <p>The whole <code>BaseHTTPServer</code> module has very little documentation :(</p>
[ { "answer_id": 268660, "author": "Ali Afshar", "author_id": 28380, "author_profile": "https://Stackoverflow.com/users/28380", "pm_score": 6, "selected": true, "text": "def serve_forever(self):\n \"\"\"Handle one request at a time until doomsday.\"\"\"\n while 1:\n self.handle_request()\n while 1 while self.should_be_running def stop_serving_forever(self):\n \"\"\"Stop handling requests\"\"\"\n self.should_be_running = 0\n # Make a fake request to the server, to really force it to stop.\n # Otherwise it will just stop on the next request.\n # (Exercise for the reader.)\n self.make_a_fake_request_to_myself()\n class StoppableRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer):\n\n stopped = False\n allow_reuse_address = True\n\n def __init__(self, *args, **kw):\n SimpleXMLRPCServer.SimpleXMLRPCServer.__init__(self, *args, **kw)\n self.register_function(lambda: 'OK', 'ping')\n\n def serve_forever(self):\n while not self.stopped:\n self.handle_request()\n\n def force_stop(self):\n self.server_close()\n self.stopped = True\n self.create_dummy_request()\n\n def create_dummy_request(self):\n server = xmlrpclib.Server('http://%s:%s' % self.server_address)\n server.ping()\n" }, { "answer_id": 268686, "author": "gimel", "author_id": 6491, "author_profile": "https://Stackoverflow.com/users/6491", "pm_score": 5, "selected": false, "text": "HTTPServer TCPServer.shutdown\n\n\n>>> import BaseHTTPServer\n>>> h=BaseHTTPServer.HTTPServer(('',5555), BaseHTTPServer.BaseHTTPRequestHandler)\n>>> h.shutdown\n<bound method HTTPServer.shutdown of <BaseHTTPServer.HTTPServer instance at 0x0100D800>>\n>>> \n" }, { "answer_id": 4020093, "author": "wimerrill", "author_id": 487114, "author_profile": "https://Stackoverflow.com/users/487114", "pm_score": 4, "selected": false, "text": "[serverName].socket.close()" }, { "answer_id": 19211760, "author": "user2852263", "author_id": 2852263, "author_profile": "https://Stackoverflow.com/users/2852263", "pm_score": 5, "selected": false, "text": "import CGIHTTPServer\nimport BaseHTTPServer\n\nKEEP_RUNNING = True\n\ndef keep_running():\n return KEEP_RUNNING\n\nclass Handler(CGIHTTPServer.CGIHTTPRequestHandler):\n cgi_directories = [\"/cgi-bin\"]\n\nhttpd = BaseHTTPServer.HTTPServer((\"\", 8000), Handler)\n\nwhile keep_running():\n httpd.handle_request()\n" }, { "answer_id": 22493362, "author": "jsalter", "author_id": 770829, "author_profile": "https://Stackoverflow.com/users/770829", "pm_score": 3, "selected": false, "text": "def serve_forever(self, poll_interval=0.5):\n \"\"\"Handle one request at a time until shutdown.\n\n Polls for shutdown every poll_interval seconds. Ignores\n self.timeout. If you need to do periodic tasks, do them in\n another thread.\n \"\"\"\n self.__is_shut_down.clear()\n try:\n while not self.__shutdown_request:\n # XXX: Consider using another file descriptor or\n # connecting to the socket to wake this up instead of\n # polling. Polling reduces our responsiveness to a\n # shutdown request and wastes cpu at all other times.\n r, w, e = select.select([self], [], [], poll_interval)\n if self in r:\n self._handle_request_noblock()\n finally:\n self.__shutdown_request = False\n self.__is_shut_down.set()\n class MockWebServerFixture(object):\n def start_webserver(self):\n \"\"\"\n start the web server on a new thread\n \"\"\"\n self._webserver_died = threading.Event()\n self._webserver_thread = threading.Thread(\n target=self._run_webserver_thread)\n self._webserver_thread.start()\n\n def _run_webserver_thread(self):\n self.webserver.serve_forever()\n self._webserver_died.set()\n\n def _kill_webserver(self):\n if not self._webserver_thread:\n return\n\n self.webserver.shutdown()\n\n # wait for thread to die for a bit, then give up raising an exception.\n if not self._webserver_died.wait(5):\n raise ValueError(\"couldn't kill webserver\")\n" }, { "answer_id": 35358134, "author": "serup", "author_id": 3990012, "author_profile": "https://Stackoverflow.com/users/3990012", "pm_score": 1, "selected": false, "text": "import subprocess\ncmdkill = \"kill $(ps aux|grep '<name of your thread> true'|grep -v 'grep'|awk '{print $2}') 2> /dev/null\"\nsubprocess.Popen(cmdkill, stdout=subprocess.PIPE, shell=True)\n" }, { "answer_id": 35576127, "author": "Vianney Bajart", "author_id": 5968045, "author_profile": "https://Stackoverflow.com/users/5968045", "pm_score": 5, "selected": false, "text": "shutdown() server_close() server_forever() import http.server\n\nclass StoppableHTTPServer(http.server.HTTPServer):\n def run(self):\n try:\n self.serve_forever()\n except KeyboardInterrupt:\n pass\n finally:\n # Clean-up server (close socket, etc.)\n self.server_close()\n server = StoppableHTTPServer((\"127.0.0.1\", 8080),\n http.server.BaseHTTPRequestHandler)\nserver.run()\n import threading\n\nserver = StoppableHTTPServer((\"127.0.0.1\", 8080),\n http.server.BaseHTTPRequestHandler)\n\n# Start processing requests\nthread = threading.Thread(None, server.run)\nthread.start()\n\n# ... do things ...\n\n# Shutdown server\nserver.shutdown()\nthread.join()\n" }, { "answer_id": 50749656, "author": "Vlad Tudorache", "author_id": 9910960, "author_profile": "https://Stackoverflow.com/users/9910960", "pm_score": 2, "selected": false, "text": "import http.server\nimport os\nimport re\n\nclass PatientHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):\n stop_server = False\n base_directory = \"/static/\"\n # A file to use as an \"server stopped user information\" page.\n stop_command = \"/control/stop.html\"\n def send_head(self):\n self.path = os.path.normpath(self.path)\n if self.path == PatientHTTPRequestHandler.stop_command and self.address_string() == \"127.0.0.1\":\n # I wanted that only the local machine could stop the server.\n PatientHTTPRequestHandler.stop_server = True\n # Allow the stop page to be displayed.\n return http.server.SimpleHTTPRequestHandler.send_head(self)\n if self.path.startswith(PatientHTTPRequestHandler.base_directory):\n return http.server.SimpleHTTPRequestHandler.send_head(self)\n else:\n return self.send_error(404, \"Not allowed\", \"The path you requested is forbidden.\")\n\nif __name__ == \"__main__\":\n httpd = http.server.HTTPServer((\"127.0.0.1\", 8080), PatientHTTPRequestHandler)\n # A timeout is needed for server to check periodically for KeyboardInterrupt\n httpd.timeout = 1\n while not PatientHTTPRequestHandler.stop_server:\n httpd.handle_request()\n http://localhost:8080/static/ http://localhost:8080/static/styles/common.css http://localhost:8080/control/stop.html stop.html" }, { "answer_id": 62087704, "author": "Helgi", "author_id": 13642184, "author_profile": "https://Stackoverflow.com/users/13642184", "pm_score": 1, "selected": false, "text": "import http.server\nimport socketserver\nimport socket as sck\nimport os\nimport threading\n\n\nclass myserver:\n def __init__(self, PORT, LOCATION):\n self.thrd = threading.Thread(None, self.run)\n self.Directory = LOCATION\n self.Port = PORT\n hostname = sck.gethostname()\n ip_address = sck.gethostbyname(hostname)\n self.url = 'http://' + ip_address + ':' + str(self.Port)\n Handler = http.server.SimpleHTTPRequestHandler\n self.httpd = socketserver.TCPServer((\"\", PORT), Handler)\n print('Object created, use the start() method to launch the server')\n def run(self):\n print('listening on: ' + self.url )\n os.chdir(self.Directory)\n print('myserver object started') \n print('Use the objects stop() method to stop the server')\n self.httpd.serve_forever()\n print('Quit handling')\n\n print('Sever stopped')\n print('Port ' + str(self.Port) + ' should be available again.')\n\n\n def stop(self):\n print('Stopping server')\n self.httpd.shutdown()\n self.httpd.server_close()\n print('Need just one more request before shutting down'\n\n\n def start(self):\n self.thrd.start()\n\ndef help():\n helpmsg = '''Create a new server-object by initialising\nNewServer = webserver3.myserver(Port_number, Directory_String)\nThen start it using NewServer.start() function\nStop it using NewServer.stop()'''\n print(helpmsg)\n" }, { "answer_id": 64438136, "author": "Eric L", "author_id": 9762732, "author_profile": "https://Stackoverflow.com/users/9762732", "pm_score": 3, "selected": false, "text": "import threading\nimport time\nfrom http.server import ThreadingHTTPServer, SimpleHTTPRequestHandler\n\n\nclass MyServer(threading.Thread):\n def run(self):\n self.server = ThreadingHTTPServer(('localhost', 8000), SimpleHTTPRequestHandler)\n self.server.serve_forever()\n def stop(self):\n self.server.shutdown()\n\n\nif __name__ == '__main__':\n s = MyServer()\n s.start()\n print('thread alive:', s.is_alive()) # True\n time.sleep(2)\n s.stop()\n print('thread alive:', s.is_alive()) # False\n" }, { "answer_id": 67413124, "author": "Tom Pohl", "author_id": 20954, "author_profile": "https://Stackoverflow.com/users/20954", "pm_score": 0, "selected": false, "text": "from contextlib import contextmanager\nfrom functools import partial\nfrom http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer\nfrom threading import Thread\n\n\n@contextmanager\ndef http_server(host: str, port: int, directory: str):\n server = ThreadingHTTPServer(\n (host, port), partial(SimpleHTTPRequestHandler, directory=directory)\n )\n server_thread = Thread(target=server.serve_forever, name=\"http_server\")\n server_thread.start()\n\n try:\n yield\n finally:\n server.shutdown()\n server_thread.join()\n\n\ndef usage_example():\n import time\n\n with http_server(\"127.0.0.1\", 8087, \".\"):\n # now you can use the web server\n time.sleep(100)\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2260/" ]
268,648
<p>I'm scanning through a file looking for lines that match a certain regex pattern, and then I want to print out the lines that match but in alphabetical order. I'm sure this is trivial but vbscript isn't my background</p> <p>my array is defined as</p> <pre><code>Dim lines(10000) </code></pre> <p>if that makes any difference, and I'm trying to execute my script from a normal cmd prompt</p>
[ { "answer_id": 268659, "author": "Oskar", "author_id": 5472, "author_profile": "https://Stackoverflow.com/users/5472", "pm_score": 7, "selected": true, "text": "Set outputLines = CreateObject(\"System.Collections.ArrayList\")\n\n'add lines\noutputLines.Add output\noutputLines.Add output\n\noutputLines.Sort()\nFor Each outputLine in outputLines\n stdout.WriteLine outputLine\nNext\n" }, { "answer_id": 268788, "author": "Eric Weilnau", "author_id": 13342, "author_profile": "https://Stackoverflow.com/users/13342", "pm_score": 2, "selected": false, "text": "'Author: Eric Weilnau\n'Date Written: 7/16/2003\n'Description: QuickSortDataArray sorts a data array using the QuickSort algorithm.\n' Its arguments are the data array to be sorted, the low and high\n' bound of the data array, the integer index of the column by which the\n' data array should be sorted, and the string \"asc\" or \"desc\" for the\n' sort order.\n'\nSub QuickSortDataArray(dataArray, loBound, hiBound, sortField, sortOrder)\n Dim pivot(), loSwap, hiSwap, count\n ReDim pivot(UBound(dataArray))\n\n If hiBound - loBound = 1 Then\n If (sortOrder = \"asc\" and dataArray(sortField,loBound) > dataArray(sortField,hiBound)) or (sortOrder = \"desc\" and dataArray(sortField,loBound) < dataArray(sortField,hiBound)) Then\n Call SwapDataRows(dataArray, hiBound, loBound)\n End If\n End If\n\n For count = 0 to UBound(dataArray)\n pivot(count) = dataArray(count,int((loBound + hiBound) / 2))\n dataArray(count,int((loBound + hiBound) / 2)) = dataArray(count,loBound)\n dataArray(count,loBound) = pivot(count)\n Next\n\n loSwap = loBound + 1\n hiSwap = hiBound\n\n Do\n Do While (sortOrder = \"asc\" and dataArray(sortField,loSwap) <= pivot(sortField)) or sortOrder = \"desc\" and (dataArray(sortField,loSwap) >= pivot(sortField))\n loSwap = loSwap + 1\n\n If loSwap > hiSwap Then\n Exit Do\n End If\n Loop\n\n Do While (sortOrder = \"asc\" and dataArray(sortField,hiSwap) > pivot(sortField)) or (sortOrder = \"desc\" and dataArray(sortField,hiSwap) < pivot(sortField))\n hiSwap = hiSwap - 1\n Loop\n\n If loSwap < hiSwap Then\n Call SwapDataRows(dataArray,loSwap,hiSwap)\n End If\n Loop While loSwap < hiSwap\n\n For count = 0 to Ubound(dataArray)\n dataArray(count,loBound) = dataArray(count,hiSwap)\n dataArray(count,hiSwap) = pivot(count)\n Next\n\n If loBound < (hiSwap - 1) Then\n Call QuickSortDataArray(dataArray, loBound, hiSwap-1, sortField, sortOrder)\n End If\n\n If (hiSwap + 1) < hiBound Then\n Call QuickSortDataArray(dataArray, hiSwap+1, hiBound, sortField, sortOrder)\n End If\nEnd Sub\n" }, { "answer_id": 308735, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": 4, "selected": false, "text": "Const adVarChar = 200 'the SQL datatype is varchar\n\n'Create a disconnected recordset\nSet rs = CreateObject(\"ADODB.RECORDSET\")\nrs.Fields.append \"SortField\", adVarChar, 25\n\nrs.CursorType = adOpenStatic\nrs.Open\nrs.AddNew \"SortField\", \"Some data\"\nrs.Update\nrs.AddNew \"SortField\", \"All data\"\nrs.Update\n\nrs.Sort = \"SortField\"\n\nrs.MoveFirst\n\nDo Until rs.EOF\n strList=strList & vbCrLf & rs.Fields(\"SortField\") \n rs.MoveNext\nLoop \n\nMsgBox strList\n" }, { "answer_id": 5209248, "author": "Riccardo Quintan", "author_id": 636071, "author_profile": "https://Stackoverflow.com/users/636071", "pm_score": 5, "selected": false, "text": "for a = UBound(ArrayOfTerms) - 1 To 0 Step -1\n for j= 0 to a\n if ArrayOfTerms(j)>ArrayOfTerms(j+1) then\n temp=ArrayOfTerms(j+1)\n ArrayOfTerms(j+1)=ArrayOfTerms(j)\n ArrayOfTerms(j)=temp\n end if\n next\nnext \n" }, { "answer_id": 5779968, "author": "Carlos Nunez", "author_id": 314212, "author_profile": "https://Stackoverflow.com/users/314212", "pm_score": 1, "selected": false, "text": "'-------------------------------------\n ' quicksort\n ' Carlos Nunez, created: 25 April, 2010.\n '\n ' NOTE: partition function also\n ' required\n '-------------------------------------\nfunction qsort(list, first, last)\n Dim i, j\n if (typeName(list) <> \"Variant()\" or ubound(list) = 0) then exit function 'list passed must be a collection or array.\n\n 'if the set size is less than 3, we can do a simple comparison sort.\n if (last-first) < 3 then\n for i = first to last\n for j = first to last\n if list(i) < list(j) then\n swap list,i,j\n end if\n next\n next\n else\n dim p_idx\n\n 'we need to set the pivot relative to the position of the subset currently being sorted.\n 'if the starting position of the subset is the first element of the whole set, then the pivot is the median of the subset.\n 'otherwise, the median is offset by the first position of the subset.\n '-------------------------------------------------------------------------------------------------------------------------\n if first-1 < 0 then\n p_idx = round((last-first)/2,0)\n else\n p_idx = round(((first-1)+((last-first)/2)),0)\n end if\n\n dim p_nidx: p_nidx = partition(list, first, last, p_idx)\n if p_nidx = -1 then exit function\n\n qsort list, first, p_nidx-1\n qsort list, p_nidx+1, last\n end if\nend function\n\n\nfunction partition(list, first, last, idx)\n Dim i\n partition = -1\n\n dim p_val: p_val = list(idx)\n swap list,idx,last\n dim swap_pos: swap_pos = first\n for i = first to last-1 \n if list(i) <= p_val then\n swap list,i,swap_pos\n swap_pos = swap_pos + 1\n end if\n next\n swap list,swap_pos,last\n\n partition = swap_pos\nend function\n\nfunction swap(list,a_pos,b_pos)\n dim tmp\n tmp = list(a_pos)\n list(a_pos) = list(b_pos)\n list(b_pos) = tmp \nend function\n" }, { "answer_id": 10351062, "author": "Lewis Gordon", "author_id": 1361158, "author_profile": "https://Stackoverflow.com/users/1361158", "pm_score": 1, "selected": false, "text": "'@Function Name: Sort\n'@Author: Lewis Gordon\n'@Creation Date: 4/26/12\n'@Description: Sorts a given array either in ascending or descending order, as specified by the\n' order parameter. This array is then returned at the end of the function.\n'@Prerequisites: An array must be allocated and have all its values inputted.\n'@Parameters:\n' $ArrayToSort: This is the array that is being sorted.\n' $Order: This is the sorting order that the array will be sorted in. This parameter \n' can either be \"ASC\" or \"DESC\" or ascending and descending, respectively.\n'@Notes: This uses merge sort under the hood. Also, this function has only been tested for\n' integers and strings in the array. However, this should work for any data type that\n' implements the greater than and less than comparators. This function also requires\n' that the merge function is also present, as it is needed to complete the sort.\n'@Examples:\n' Dim i\n' Dim TestArray(50)\n' Randomize\n' For i=0 to UBound(TestArray)\n' TestArray(i) = Int((100 - 0 + 1) * Rnd + 0)\n' Next\n' MsgBox Join(Sort(TestArray, \"DESC\"))\n'\n'@Return value: This function returns a sorted array in the specified order.\n'@Change History: None\n\n'The merge function.\nPublic Function Merge(LeftArray, RightArray, Order)\n 'Declared variables\n Dim FinalArray\n Dim FinalArraySize\n Dim i\n Dim LArrayPosition\n Dim RArrayPosition\n\n 'Variable initialization\n LArrayPosition = 0\n RArrayPosition = 0\n\n 'Calculate the expected size of the array based on the two smaller arrays.\n FinalArraySize = UBound(LeftArray) + UBound(RightArray) + 1\n ReDim FinalArray(FinalArraySize)\n\n 'This should go until we need to exit the function.\n While True\n\n 'If we are done with all the values in the left array. Add the rest of the right array\n 'to the final array.\n If LArrayPosition >= UBound(LeftArray)+1 Then\n For i=RArrayPosition To UBound(RightArray)\n FinalArray(LArrayPosition+i) = RightArray(i)\n Next\n Merge = FinalArray\n Exit Function\n\n 'If we are done with all the values in the right array. Add the rest of the left array\n 'to the final array.\n ElseIf RArrayPosition >= UBound(RightArray)+1 Then\n For i=LArrayPosition To UBound(LeftArray)\n FinalArray(i+RArrayPosition) = LeftArray(i)\n Next\n Merge = FinalArray\n Exit Function\n\n 'For descending, if the current value of the left array is greater than the right array \n 'then add it to the final array. The position of the left array will then be incremented\n 'by one.\n ElseIf LeftArray(LArrayPosition) > RightArray(RArrayPosition) And UCase(Order) = \"DESC\" Then\n FinalArray(LArrayPosition+RArrayPosition) = LeftArray(LArrayPosition)\n LArrayPosition = LArrayPosition + 1\n\n 'For ascending, if the current value of the left array is less than the right array \n 'then add it to the final array. The position of the left array will then be incremented\n 'by one.\n ElseIf LeftArray(LArrayPosition) < RightArray(RArrayPosition) And UCase(Order) = \"ASC\" Then\n FinalArray(LArrayPosition+RArrayPosition) = LeftArray(LArrayPosition)\n LArrayPosition = LArrayPosition + 1\n\n 'For anything else that wasn't covered, add the current value of the right array to the\n 'final array.\n Else\n FinalArray(LArrayPosition+RArrayPosition) = RightArray(RArrayPosition)\n RArrayPosition = RArrayPosition + 1\n End If\n Wend\nEnd Function\n\n'The main sort function.\nPublic Function Sort(ArrayToSort, Order)\n 'Variable declaration.\n Dim i\n Dim LeftArray\n Dim Modifier\n Dim RightArray\n\n 'Check to make sure the order parameter is okay.\n If Not UCase(Order)=\"ASC\" And Not UCase(Order)=\"DESC\" Then\n Exit Function\n End If\n 'If the array is a singleton or 0 then it is sorted.\n If UBound(ArrayToSort) <= 0 Then\n Sort = ArrayToSort\n Exit Function\n End If\n\n 'Setting up the modifier to help us split the array effectively since the round\n 'functions aren't helpful in VBScript.\n If UBound(ArrayToSort) Mod 2 = 0 Then\n Modifier = 1\n Else\n Modifier = 0\n End If\n\n 'Setup the arrays to about half the size of the main array.\n ReDim LeftArray(Fix(UBound(ArrayToSort)/2))\n ReDim RightArray(Fix(UBound(ArrayToSort)/2)-Modifier)\n\n 'Add the first half of the values to one array.\n For i=0 To UBound(LeftArray)\n LeftArray(i) = ArrayToSort(i)\n Next\n\n 'Add the other half of the values to the other array.\n For i=0 To UBound(RightArray)\n RightArray(i) = ArrayToSort(i+Fix(UBound(ArrayToSort)/2)+1)\n Next\n\n 'Merge the sorted arrays.\n Sort = Merge(Sort(LeftArray, Order), Sort(RightArray, Order), Order)\nEnd Function\n" }, { "answer_id": 17359670, "author": "Leif Neland", "author_id": 1678652, "author_profile": "https://Stackoverflow.com/users/1678652", "pm_score": 0, "selected": false, "text": "arr(field_index,ptr_arr(row_index))\n arr(field_index,row_index)\n max_col=uBound(arr,1)\nresponse.write \"<table>\"\nfor n = 0 to uBound(arr,2)\n response.write \"<tr>\"\n row=ptr_arr(n)\n for i=0 to max_col\n response.write \"<td>\"&arr(i,row)&\"</td>\"\n next\n response.write \"</tr>\nnext\nresponse.write \"</table>\" \n" }, { "answer_id": 24898238, "author": "Andrew Dennison", "author_id": 1454085, "author_profile": "https://Stackoverflow.com/users/1454085", "pm_score": 2, "selected": false, "text": "cscript.exe //nologo YOUR-SCRIPT | Sort\n" }, { "answer_id": 27437223, "author": "Christopher J. Scharer", "author_id": 4287094, "author_profile": "https://Stackoverflow.com/users/4287094", "pm_score": 2, "selected": false, "text": "Option Explicit\n\nPublic Function Array_AdvancedBubbleSort(ByRef rarr_ArrayToSort(), ByVal rstr_SortOrder)\n' ==================================================================================\n' Date : 12/09/1999\n' Author : Christopher J. Scharer (CJS)\n' Description : Creates a sorted Array from a one dimensional array\n' in Ascending (default) or Descending order based on the rstr_SortOrder.\n' Variables :\n' rarr_ArrayToSort() The array to sort and return.\n' rstr_SortOrder The order to sort in, default ascending or D for descending.\n' ==================================================================================\n Const const_FUNCTION_NAME = \"Array_AdvancedBubbleSort\"\n Dim bln_Sorted\n Dim lng_Loop_01\n Dim str_SortOrder\n Dim str_Temp\n\n bln_Sorted = False\n str_SortOrder = Left(UCase(rstr_SortOrder), 1) 'We only need to know if the sort order is A(SENC) or D(ESEND)...and for that matter we really only need to know if it's D because we are defaulting to Ascending.\n Do While (bln_Sorted = False)\n bln_Sorted = True\n str_Temp = \"\"\n If (str_SortOrder = \"D\") Then\n 'Sort in descending order.\n For lng_Loop_01 = LBound(rarr_ArrayToSort) To (UBound(rarr_ArrayToSort) - 1)\n If (rarr_ArrayToSort(lng_Loop_01) < rarr_ArrayToSort(lng_Loop_01 + 1)) Then\n bln_Sorted = False\n str_Temp = rarr_ArrayToSort(lng_Loop_01)\n rarr_ArrayToSort(lng_Loop_01) = rarr_ArrayToSort(lng_Loop_01 + 1)\n rarr_ArrayToSort(lng_Loop_01 + 1) = str_Temp\n End If\n If (rarr_ArrayToSort((UBound(rarr_ArrayToSort) - 1) - (lng_Loop_01 - 1)) > rarr_ArrayToSort((UBound(rarr_ArrayToSort) - 1) - lng_Loop_01)) Then\n bln_Sorted = False\n str_Temp = rarr_ArrayToSort((UBound(rarr_ArrayToSort) - 1) - (lng_Loop_01 - 1))\n rarr_ArrayToSort((UBound(rarr_ArrayToSort) - 1) - (lng_Loop_01 - 1)) = rarr_ArrayToSort((UBound(rarr_ArrayToSort) - 1) - lng_Loop_01)\n rarr_ArrayToSort((UBound(rarr_ArrayToSort) - 1) - lng_Loop_01) = str_Temp\n End If\n Next\n Else\n 'Default to Ascending.\n For lng_Loop_01 = LBound(rarr_ArrayToSort) To (UBound(rarr_ArrayToSort) - 1)\n If (rarr_ArrayToSort(lng_Loop_01) > rarr_ArrayToSort(lng_Loop_01 + 1)) Then\n bln_Sorted = False\n str_Temp = rarr_ArrayToSort(lng_Loop_01)\n rarr_ArrayToSort(lng_Loop_01) = rarr_ArrayToSort(lng_Loop_01 + 1)\n rarr_ArrayToSort(lng_Loop_01 + 1) = str_Temp\n End If\n If (rarr_ArrayToSort((UBound(rarr_ArrayToSort) - 1) - (lng_Loop_01 - 1)) < rarr_ArrayToSort((UBound(rarr_ArrayToSort) - 1) - lng_Loop_01)) Then\n bln_Sorted = False\n str_Temp = rarr_ArrayToSort((UBound(rarr_ArrayToSort) - 1) - (lng_Loop_01 - 1))\n rarr_ArrayToSort((UBound(rarr_ArrayToSort) - 1) - (lng_Loop_01 - 1)) = rarr_ArrayToSort((UBound(rarr_ArrayToSort) - 1) - lng_Loop_01)\n rarr_ArrayToSort((UBound(rarr_ArrayToSort) - 1) - lng_Loop_01) = str_Temp\n End If\n Next\n End If\n Loop\nEnd Function\n\nPublic Function Array_BubbleSort(ByRef rarr_ArrayToSort())\n' ==================================================================================\n' Date : 03/18/2008\n' Author : Christopher J. Scharer (CJS)\n' Description : Sorts an array.\n' ==================================================================================\n Const const_FUNCTION_NAME = \"Array_BubbleSort\"\n Dim lng_Loop_01\n Dim lng_Loop_02\n Dim var_Temp\n\n For lng_Loop_01 = (UBound(rarr_ArrayToSort) - 1) To 0 Step -1\n For lng_Loop_02 = 0 To lng_Loop_01\n If rarr_ArrayToSort(lng_Loop_02) > rarr_ArrayToSort(lng_Loop_02 + 1) Then\n var_Temp = rarr_ArrayToSort(lng_Loop_02 + 1)\n rarr_ArrayToSort(lng_Loop_02 + 1) = rarr_ArrayToSort(lng_Loop_02)\n rarr_ArrayToSort(lng_Loop_02) = var_Temp\n End If\n Next\n Next\nEnd Function\n\nPublic Function Array_GetDimensions(ByVal rarr_Array)\n Const const_FUNCTION_NAME = \"Array_GetDimensions\"\n Dim int_Dimensions\n Dim int_Result\n Dim str_Dimensions\n\n int_Result = 0\n If IsArray(rarr_Array) Then\n On Error Resume Next\n Do\n int_Dimensions = -2\n int_Dimensions = UBound(rarr_Array, int_Result + 1)\n If int_Dimensions > -2 Then\n int_Result = int_Result + 1\n If int_Result = 1 Then\n str_Dimensions = str_Dimensions & int_Dimensions\n Else\n str_Dimensions = str_Dimensions & \":\" & int_Dimensions\n End If\n End If\n Loop Until int_Dimensions = -2\n On Error GoTo 0\n End If\n Array_GetDimensions = int_Result ' & \";\" & str_Dimensions\nEnd Function\n\nPublic Function Array_GetUniqueCombinations(ByVal rarr_Fields, ByRef robj_Combinations)\n Const const_FUNCTION_NAME = \"Array_GetUniqueCombinations\"\n Dim int_Element\n Dim str_Combination\n\n On Error Resume Next\n\n Array_GetUniqueCombinations = CBool(False)\n For int_Element = LBound(rarr_Fields) To UBound(rarr_Fields)\n str_Combination = rarr_Fields(int_Element)\n Call robj_Combinations.Add(robj_Combinations.Count & \":\" & str_Combination, 0)\n' Call Array_GetUniqueCombinationsSub(rarr_Fields, robj_Combinations, int_Element)\n Next 'int_Element\n For int_Element = LBound(rarr_Fields) To UBound(rarr_Fields)\n Call Array_GetUniqueCombinationsSub(rarr_Fields, robj_Combinations, int_Element)\n Next 'int_Element\n Array_GetUniqueCombinations = CBool(True)\nEnd Function 'Array_GetUniqueCombinations\n\nPublic Function Array_GetUniqueCombinationsSub(ByVal rarr_Fields, ByRef robj_Combinations, ByRef rint_LBound)\n Const const_FUNCTION_NAME = \"Array_GetUniqueCombinationsSub\"\n Dim int_Element\n Dim str_Combination\n\n On Error Resume Next\n\n Array_GetUniqueCombinationsSub = CBool(False)\n str_Combination = rarr_Fields(rint_LBound)\n For int_Element = (rint_LBound + 1) To UBound(rarr_Fields)\n str_Combination = str_Combination & \",\" & rarr_Fields(int_Element)\n Call robj_Combinations.Add(robj_Combinations.Count & \":\" & str_Combination, str_Combination)\n Next 'int_Element\n Array_GetUniqueCombinationsSub = CBool(True)\nEnd Function 'Array_GetUniqueCombinationsSub\n\nPublic Function Array_HeapSort(ByRef rarr_ArrayToSort())\n' ==================================================================================\n' Date : 03/18/2008\n' Author : Christopher J. Scharer (CJS)\n' Description : Sorts an array.\n' ==================================================================================\n Const const_FUNCTION_NAME = \"Array_HeapSort\"\n Dim lng_Loop_01\n Dim var_Temp\n Dim arr_Size\n\n arr_Size = UBound(rarr_ArrayToSort) + 1\n For lng_Loop_01 = ((arr_Size / 2) - 1) To 0 Step -1\n Call Array_SiftDown(rarr_ArrayToSort, lng_Loop_01, arr_Size)\n Next\n For lng_Loop_01 = (arr_Size - 1) To 1 Step -1\n var_Temp = rarr_ArrayToSort(0)\n rarr_ArrayToSort(0) = rarr_ArrayToSort(lng_Loop_01)\n rarr_ArrayToSort(lng_Loop_01) = var_Temp\n Call Array_SiftDown(rarr_ArrayToSort, 0, (lng_Loop_01 - 1))\n Next\nEnd Function\n\nPublic Function Array_InsertionSort(ByRef rarr_ArrayToSort())\n' ==================================================================================\n' Date : 03/18/2008\n' Author : Christopher J. Scharer (CJS)\n' Description : Sorts an array.\n' ==================================================================================\n Const const_FUNCTION_NAME = \"Array_InsertionSort\"\n Dim lng_ElementCount\n Dim lng_Loop_01\n Dim lng_Loop_02\n Dim lng_Index\n\n lng_ElementCount = UBound(rarr_ArrayToSort) + 1\n For lng_Loop_01 = 1 To (lng_ElementCount - 1)\n lng_Index = rarr_ArrayToSort(lng_Loop_01)\n lng_Loop_02 = lng_Loop_01\n Do While lng_Loop_02 > 0\n If rarr_ArrayToSort(lng_Loop_02 - 1) > lng_Index Then\n rarr_ArrayToSort(lng_Loop_02) = rarr_ArrayToSort(lng_Loop_02 - 1)\n lng_Loop_02 = (lng_Loop_02 - 1)\n End If\n Loop\n rarr_ArrayToSort(lng_Loop_02) = lng_Index\n Next\nEnd Function\n\nPrivate Function Array_Merge(ByRef rarr_ArrayToSort(), ByRef rarr_ArrayTemp(), ByVal rlng_Left, ByVal rlng_MiddleIndex, ByVal rlng_Right)\n' ==================================================================================\n' Date : 03/18/2008\n' Author : Christopher J. Scharer (CJS)\n' Description : Merges an array.\n' ==================================================================================\n Const const_FUNCTION_NAME = \"Array_Merge\"\n Dim lng_Loop_01\n Dim lng_LeftEnd\n Dim lng_ElementCount\n Dim lng_TempPos\n\n lng_LeftEnd = (rlng_MiddleIndex - 1)\n lng_TempPos = rlng_Left\n lng_ElementCount = (rlng_Right - rlng_Left + 1)\n Do While (rlng_Left <= lng_LeftEnd) _\n And (rlng_MiddleIndex <= rlng_Right)\n If rarr_ArrayToSort(rlng_Left) <= rarr_ArrayToSort(rlng_MiddleIndex) Then\n rarr_ArrayTemp(lng_TempPos) = rarr_ArrayToSort(rlng_Left)\n lng_TempPos = (lng_TempPos + 1)\n rlng_Left = (rlng_Left + 1)\n Else\n rarr_ArrayTemp(lng_TempPos) = rarr_ArrayToSort(rlng_MiddleIndex)\n lng_TempPos = (lng_TempPos + 1)\n rlng_MiddleIndex = (rlng_MiddleIndex + 1)\n End If\n Loop\n Do While rlng_Left <= lng_LeftEnd\n rarr_ArrayTemp(lng_TempPos) = rarr_ArrayToSort(rlng_Left)\n rlng_Left = (rlng_Left + 1)\n lng_TempPos = (lng_TempPos + 1)\n Loop\n Do While rlng_MiddleIndex <= rlng_Right\n rarr_ArrayTemp(lng_TempPos) = rarr_ArrayToSort(rlng_MiddleIndex)\n rlng_MiddleIndex = (rlng_MiddleIndex + 1)\n lng_TempPos = (lng_TempPos + 1)\n Loop\n For lng_Loop_01 = 0 To (lng_ElementCount - 1)\n rarr_ArrayToSort(rlng_Right) = rarr_ArrayTemp(rlng_Right)\n rlng_Right = (rlng_Right - 1)\n Next\nEnd Function\n\nPublic Function Array_MergeSort(ByRef rarr_ArrayToSort(), ByRef rarr_ArrayTemp(), ByVal rlng_FirstIndex, ByVal rlng_LastIndex)\n' ==================================================================================\n' Date : 03/18/2008\n' Author : Christopher J. Scharer (CJS)\n' Description : Sorts an array.\n' Note :The rarr_ArrayTemp array that is passed in has to be dimensionalized to the same size\n' as the rarr_ArrayToSort array that is passed in prior to calling the function.\n' Also the rlng_FirstIndex variable should be the value of the LBound(rarr_ArrayToSort)\n' and the rlng_LastIndex variable should be the value of the UBound(rarr_ArrayToSort)\n' ==================================================================================\n Const const_FUNCTION_NAME = \"Array_MergeSort\"\n Dim lng_MiddleIndex\n\n If rlng_LastIndex > rlng_FirstIndex Then\n ' Recursively sort the two halves of the list.\n lng_MiddleIndex = ((rlng_FirstIndex + rlng_LastIndex) / 2)\n Call Array_MergeSort(rarr_ArrayToSort, rarr_ArrayTemp, rlng_FirstIndex, lng_MiddleIndex)\n Call Array_MergeSort(rarr_ArrayToSort, rarr_ArrayTemp, lng_MiddleIndex + 1, rlng_LastIndex)\n ' Merge the results.\n Call Array_Merge(rarr_ArrayToSort, rarr_ArrayTemp, rlng_FirstIndex, lng_MiddleIndex + 1, rlng_LastIndex)\n End If\nEnd Function\n\nPublic Function Array_Push(ByRef rarr_Array, ByVal rstr_Value, ByVal rstr_Delimiter)\n Const const_FUNCTION_NAME = \"Array_Push\"\n Dim int_Loop\n Dim str_Array_01\n Dim str_Array_02\n\n 'If there is no delimiter passed in then set the default delimiter equal to a comma.\n If rstr_Delimiter = \"\" Then\n rstr_Delimiter = \",\"\n End If\n\n 'Check to see if the rarr_Array is actually an Array.\n If IsArray(rarr_Array) = True Then\n 'Verify that the rarr_Array variable is only a one dimensional array.\n If Array_GetDimensions(rarr_Array) <> 1 Then\n Array_Push = \"ERR, the rarr_Array variable passed in was not a one dimensional array.\"\n Exit Function\n End If\n If IsArray(rstr_Value) = True Then\n 'Verify that the rstr_Value variable is is only a one dimensional array.\n If Array_GetDimensions(rstr_Value) <> 1 Then\n Array_Push = \"ERR, the rstr_Value variable passed in was not a one dimensional array.\"\n Exit Function\n End If\n str_Array_01 = Split(rarr_Array, rstr_Delimiter)\n str_Array_02 = Split(rstr_Value, rstr_Delimiter)\n rarr_Array = Join(str_Array_01 & rstr_Delimiter & str_Array_02)\n Else\n On Error Resume Next\n ReDim Preserve rarr_Array(UBound(rarr_Array) + 1)\n If Err.Number <> 0 Then ' \"Subscript out of range\" An array that was passed in must have been Erased to re-create it with new elements (possibly when passing an array to be populated into a recursive function)\n ReDim rarr_Array(0)\n Err.Clear\n End If\n If IsObject(rstr_Value) = True Then\n Set rarr_Array(UBound(rarr_Array)) = rstr_Value\n Else\n rarr_Array(UBound(rarr_Array)) = rstr_Value\n End If\n End If\n Else\n 'Check to see if the rstr_Value is an Array.\n If IsArray(rstr_Value) = True Then\n 'Verify that the rstr_Value variable is is only a one dimensional array.\n If Array_GetDimensions(rstr_Value) <> 1 Then\n Array_Push = \"ERR, the rstr_Value variable passed in was not a one dimensional array.\"\n Exit Function\n End If\n rarr_Array = rstr_Value\n Else\n rarr_Array = Split(rstr_Value, rstr_Delimiter)\n End If\n End If\n Array_Push = UBound(rarr_Array)\nEnd Function\n\nPublic Function Array_QuickSort(ByRef rarr_ArrayToSort(), ByVal rlng_Low, ByVal rlng_High)\n' ==================================================================================\n' Date : 03/18/2008\n' Author : Christopher J. Scharer (CJS)\n' Description : Sorts an array.\n' Note :The rlng_Low variable should be the value of the LBound(rarr_ArrayToSort)\n' and the rlng_High variable should be the value of the UBound(rarr_ArrayToSort)\n' ==================================================================================\n Const const_FUNCTION_NAME = \"Array_QuickSort\"\n Dim var_Pivot\n Dim lng_Swap\n Dim lng_Low\n Dim lng_High\n\n lng_Low = rlng_Low\n lng_High = rlng_High\n var_Pivot = rarr_ArrayToSort((rlng_Low + rlng_High) / 2)\n Do While lng_Low <= lng_High\n Do While (rarr_ArrayToSort(lng_Low) < var_Pivot _\n And lng_Low < rlng_High)\n lng_Low = lng_Low + 1\n Loop\n Do While (var_Pivot < rarr_ArrayToSort(lng_High) _\n And lng_High > rlng_Low)\n lng_High = (lng_High - 1)\n Loop\n If lng_Low <= lng_High Then\n lng_Swap = rarr_ArrayToSort(lng_Low)\n rarr_ArrayToSort(lng_Low) = rarr_ArrayToSort(lng_High)\n rarr_ArrayToSort(lng_High) = lng_Swap\n lng_Low = (lng_Low + 1)\n lng_High = (lng_High - 1)\n End If\n Loop\n If rlng_Low < lng_High Then\n Call Array_QuickSort(rarr_ArrayToSort, rlng_Low, lng_High)\n End If\n If lng_Low < rlng_High Then\n Call Array_QuickSort(rarr_ArrayToSort, lng_Low, rlng_High)\n End If\nEnd Function\n\nPublic Function Array_SelectionSort(ByRef rarr_ArrayToSort())\n' ==================================================================================\n' Date : 03/18/2008\n' Author : Christopher J. Scharer (CJS)\n' Description : Sorts an array.\n' ==================================================================================\n Const const_FUNCTION_NAME = \"Array_SelectionSort\"\n Dim lng_ElementCount\n Dim lng_Loop_01\n Dim lng_Loop_02\n Dim lng_Min\n Dim var_Temp\n\n lng_ElementCount = UBound(rarr_ArrayToSort) + 1\n For lng_Loop_01 = 0 To (lng_ElementCount - 2)\n lng_Min = lng_Loop_01\n For lng_Loop_02 = (lng_Loop_01 + 1) To lng_ElementCount - 1\n If rarr_ArrayToSort(lng_Loop_02) < rarr_ArrayToSort(lng_Min) Then\n lng_Min = lng_Loop_02\n End If\n Next\n var_Temp = rarr_ArrayToSort(lng_Loop_01)\n rarr_ArrayToSort(lng_Loop_01) = rarr_ArrayToSort(lng_Min)\n rarr_ArrayToSort(lng_Min) = var_Temp\n Next\nEnd Function\n\nPublic Function Array_ShellSort(ByRef rarr_ArrayToSort())\n' ==================================================================================\n' Date : 03/18/2008\n' Author : Christopher J. Scharer (CJS)\n' Description : Sorts an array.\n' ==================================================================================\n Const const_FUNCTION_NAME = \"Array_ShellSort\"\n Dim lng_Loop_01\n Dim var_Temp\n Dim lng_Hold\n Dim lng_HValue\n\n lng_HValue = LBound(rarr_ArrayToSort)\n Do\n lng_HValue = (3 * lng_HValue + 1)\n Loop Until lng_HValue > UBound(rarr_ArrayToSort)\n Do\n lng_HValue = (lng_HValue / 3)\n For lng_Loop_01 = (lng_HValue + LBound(rarr_ArrayToSort)) To UBound(rarr_ArrayToSort)\n var_Temp = rarr_ArrayToSort(lng_Loop_01)\n lng_Hold = lng_Loop_01\n Do While rarr_ArrayToSort(lng_Hold - lng_HValue) > var_Temp\n rarr_ArrayToSort(lng_Hold) = rarr_ArrayToSort(lng_Hold - lng_HValue)\n lng_Hold = (lng_Hold - lng_HValue)\n If lng_Hold < lng_HValue Then\n Exit Do\n End If\n Loop\n rarr_ArrayToSort(lng_Hold) = var_Temp\n Next\n Loop Until lng_HValue = LBound(rarr_ArrayToSort)\nEnd Function\n\nPrivate Function Array_SiftDown(ByRef rarr_ArrayToSort(), ByVal rlng_Root, ByVal rlng_Bottom)\n' ==================================================================================\n' Date : 03/18/2008\n' Author : Christopher J. Scharer (CJS)\n' Description : Sifts the elements down in an array.\n' ==================================================================================\n Const const_FUNCTION_NAME = \"Array_SiftDown\"\n Dim bln_Done\n Dim max_Child\n Dim var_Temp\n\n bln_Done = False\n Do While ((rlng_Root * 2) <= rlng_Bottom) _\n And bln_Done = False\n If rlng_Root * 2 = rlng_Bottom Then\n max_Child = (rlng_Root * 2)\n ElseIf rarr_ArrayToSort(rlng_Root * 2) > rarr_ArrayToSort(rlng_Root * 2 + 1) Then\n max_Child = (rlng_Root * 2)\n Else\n max_Child = (rlng_Root * 2 + 1)\n End If\n If rarr_ArrayToSort(rlng_Root) < rarr_ArrayToSort(max_Child) Then\n var_Temp = rarr_ArrayToSort(rlng_Root)\n rarr_ArrayToSort(rlng_Root) = rarr_ArrayToSort(max_Child)\n rarr_ArrayToSort(max_Child) = var_Temp\n rlng_Root = max_Child\n Else\n bln_Done = True\n End If\n Loop\nEnd Function\n" }, { "answer_id": 70152210, "author": "Antoni Gual Via", "author_id": 1955444, "author_profile": "https://Stackoverflow.com/users/1955444", "pm_score": 0, "selected": false, "text": "a=split(\"this is a javascript array sort demo\",\" \")\n\nwscript.echo vbcrlf & \"alphabeticaly\"&vbcrlf\na=sort(a)\nfor each i in a\n wscript.echo i\nnext\nwscript.echo vbcrlf & \"by length\"&vbcrlf\na=sortbylength(a)\nfor each i in a\n wscript.echo i\nnext\n\nfunction sort(a)\nwith createobject(\"ScriptControl\")\n .Language = \"JScript\"\n .AddCode \"function sortvbs(a) {return a.toArray().sort().join('\\b')}\"\n sort= split(.Run(\"sortvbs\",a),chr(8))\n End With\nend function\n\n\nfunction sortbylength(a)\nwith createobject(\"ScriptControl\")\n .Language = \"JScript\"\n .AddCode \"function lensort(a,b){return((('' + a).length > ('' + b).length) ? 1 : ((('' + a).length < ('' + b).length) ? -1 : 0))}\" \n .Addcode \"function sortvbs(a) {return a.toArray().sort(lensort).join('\\b')}\"\n sortbylength= split(.Run(\"sortvbs\",a),chr(8))\n End With\nend function\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5472/" ]
268,651
<p>How do you do your Hibernate session management in a Java Desktop Swing application? Do you use a single session? Multiple sessions?</p> <p>Here are a few references on the subject:</p> <ul> <li><a href="http://www.hibernate.org/333.html" rel="noreferrer">http://www.hibernate.org/333.html</a></li> <li><a href="http://blog.schauderhaft.de/2008/09/28/hibernate-sessions-in-two-tier-rich-client-applications/" rel="noreferrer">http://blog.schauderhaft.de/2008/09/28/hibernate-sessions-in-two-tier-rich-client-applications/</a> </li> <li><a href="http://in.relation.to/Bloggers/HibernateAndSwingDemoApp" rel="noreferrer">http://in.relation.to/Bloggers/HibernateAndSwingDemoApp</a></li> </ul>
[ { "answer_id": 268784, "author": "Vladimir Dyuzhev", "author_id": 1163802, "author_profile": "https://Stackoverflow.com/users/1163802", "pm_score": 4, "selected": true, "text": "MyHibernateUtils.begin();\nSettings settings = DaoSettings.load();\n// update setttings here\nDaoSettings.save(settings);\nMyHibernateUtils.commit(); \n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/407003/" ]
268,652
<p>I'm using java and referring to the "double" datatype. To keep it short, I'm reading some values from standard input that I read in my code as doubles (I would much rather use something like BigInteger but right now it's not possible).</p> <p>I expect to get double values from the user but sometimes they might input things like: 999999999999999999999999999.9999999999 which I think is beyond an accurate representation for double and get's rounded to 1.0E27 (probably).</p> <p>I would like to get some pointers on how to detect whether a specific value would be unable to be accurately represented in a double and would require rounding (so that I could refuse that value or other such actions).</p> <p>Thank you very much</p>
[ { "answer_id": 268662, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "BigDecimal userAsDecimal = new BigDecimal(userInput);\ndouble userAsDouble = double.parseDouble(userInput);\nBigDecimal doubleToDecimal = new BigDecimal(userAsDouble);\nBigDecimal error = userAsDecimal.subtract(userAsDouble).abs();\n" }, { "answer_id": 268665, "author": "TcKs", "author_id": 20382, "author_profile": "https://Stackoverflow.com/users/20382", "pm_score": 2, "selected": false, "text": "double orig = GetSomeDouble();\ndouble test1 = orig - 1;\nif ( orig == test1 )\n SomethingIsWrong();\ndouble test2 = test1 + 1;\nif ( orig != test2 )\n SomethingIsWrong();\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15225/" ]
268,656
<p>I'm trying to control the main timeline of my flash application from a MovieClip that is a child of the main stage. Apparently, in ActionScript 2, you could do that using _root, but using root (since _root no longer exists) now gives an error:</p> <pre><code>root.play(); </code></pre> <p>"1061: Call to a possibly undefined method play through a reference with static type flash.display:DisplayObjectContainer."</p> <p>Using the Stage class also doesn't work:</p> <pre><code>stage.play(); </code></pre> <p>"1061: Call to a possibly undefined method play through a reference with static type flash.display:Stage."</p> <p>Is there any way to do this?</p>
[ { "answer_id": 268873, "author": "Andres", "author_id": 1815, "author_profile": "https://Stackoverflow.com/users/1815", "pm_score": 4, "selected": true, "text": "(root as MovieClip).play()\n" }, { "answer_id": 1944256, "author": "bagushutomo", "author_id": 236581, "author_profile": "https://Stackoverflow.com/users/236581", "pm_score": 0, "selected": false, "text": "public class Main() {\n var m = new Movie(this);\n} public class Movie(m:Main) { m.gotoAndPlay(\"somewhere\"); }\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25280/" ]
268,671
<p>I have a HQL query that can generate either an IList of results, or an IEnumerable of results. </p> <p>However, I want it to return an array of the Entity that I'm selecting, what would be the best way of accomplishing that? I can either enumerate through it and build the array, or use CopyTo() a defined array.</p> <p>Is there any better way? I went with the CopyTo-approach.</p>
[ { "answer_id": 268699, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 8, "selected": true, "text": "ToArray() IEnumerable query = ...;\nMyEntityType[] array = query.Cast<MyEntityType>().ToArray();\n public static void T[] PerformQuery<T>()\n{\n IEnumerable query = ...;\n T[] array = query.Cast<T>().ToArray();\n return array;\n}\n" }, { "answer_id": 5703033, "author": "Michael Joyce", "author_id": 623004, "author_profile": "https://Stackoverflow.com/users/623004", "pm_score": 6, "selected": false, "text": "using System.Linq;\n public static TSource[] ToArray<TSource>(this System.Collections.Generic.IEnumerable<TSource> source)\n IEnumerable<object> query = ...;\nobject[] bob = query.ToArray();\n" }, { "answer_id": 16970830, "author": "Philippe Matray", "author_id": 2409554, "author_profile": "https://Stackoverflow.com/users/2409554", "pm_score": 3, "selected": false, "text": "public static T[] ConvertToArray<T>(this IEnumerable<T> enumerable)\n{\n if (enumerable == null)\n throw new ArgumentNullException(\"enumerable\");\n\n return enumerable as T[] ?? enumerable.ToArray();\n}\n" }, { "answer_id": 35019023, "author": "Lug", "author_id": 435961, "author_profile": "https://Stackoverflow.com/users/435961", "pm_score": 3, "selected": false, "text": " private T[] GetArray<T>(IList<T> iList) where T: new()\n {\n var result = new T[iList.Count];\n\n iList.CopyTo(result, 0);\n\n return result;\n }\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268671", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33663/" ]
268,672
<p>I know about <a href="https://docs.oracle.com/javase/9/docs/api/java/util/SortedSet.html" rel="noreferrer"><code>SortedSet</code></a>, but in my case I need something that implements <code>List</code>, and not <code>Set</code>. So is there an implementation out there, in the API or elsewhere?</p> <p>It shouldn't be hard to implement myself, but I figured why not ask people here first?</p>
[ { "answer_id": 268691, "author": "Daniel Hiller", "author_id": 16193, "author_profile": "https://Stackoverflow.com/users/16193", "pm_score": 3, "selected": false, "text": "new ArrayList( new LinkedHashSet() )\n" }, { "answer_id": 268713, "author": "Calum", "author_id": 8434, "author_profile": "https://Stackoverflow.com/users/8434", "pm_score": 8, "selected": true, "text": "LinkedHashSet<E> List List List commons-collections4 List SetUniqueList SetUniqueList<E>" }, { "answer_id": 268719, "author": "Kieveli", "author_id": 15852, "author_profile": "https://Stackoverflow.com/users/15852", "pm_score": 0, "selected": false, "text": "UniqueArrayList add insert contains() add" }, { "answer_id": 268818, "author": "Yuval", "author_id": 2819, "author_profile": "https://Stackoverflow.com/users/2819", "pm_score": 4, "selected": false, "text": "class NoDuplicatesList<E> extends LinkedList<E> {\n @Override\n public boolean add(E e) {\n if (this.contains(e)) {\n return false;\n }\n else {\n return super.add(e);\n }\n }\n\n @Override\n public boolean addAll(Collection<? extends E> collection) {\n Collection<E> copy = new LinkedList<E>(collection);\n copy.removeAll(this);\n return super.addAll(copy);\n }\n\n @Override\n public boolean addAll(int index, Collection<? extends E> collection) {\n Collection<E> copy = new LinkedList<E>(collection);\n copy.removeAll(this);\n return super.addAll(index, copy);\n }\n\n @Override\n public void add(int index, E element) {\n if (this.contains(element)) {\n return;\n }\n else {\n super.add(index, element);\n }\n }\n} \n" }, { "answer_id": 269324, "author": "matt b", "author_id": 4249, "author_profile": "https://Stackoverflow.com/users/4249", "pm_score": 3, "selected": false, "text": "new ArrayList(set) new LinkedList(set) NoDuplicatesList contains() addAll()" }, { "answer_id": 1161673, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "SetUniqueList Set Array Set.toArray() SetUniqueTest SetUniqueList SetUniqueList public static void main(String[] args) {\n\n\nSetUniqueList pq = SetUniqueList.decorate(new ArrayList());\nSet s = new TreeSet();\n\nlong t1 = 0L;\nlong t2 = 0L;\nString t;\n\n\nt1 = System.nanoTime();\nfor (int i = 0; i < 200000; i++) {\n pq.add(\"a\" + Math.random());\n}\nwhile (!pq.isEmpty()) {\n t = (String) pq.remove(0);\n}\nt1 = System.nanoTime() - t1;\n\nt2 = System.nanoTime();\nfor (int i = 0; i < 200000; i++) {\n s.add(\"a\" + Math.random());\n}\n\ns.clear();\nString[] d = (String[]) s.toArray(new String[0]);\ns.clear();\nfor (int i = 0; i < d.length; i++) {\n t = d[i];\n\n}\nt2 = System.nanoTime() - t2;\n\nSystem.out.println((double)t1/1000/1000/1000); //seconds\nSystem.out.println((double)t2/1000/1000/1000); //seconds\nSystem.out.println(((double) t1) / t2); //comparing results\n" }, { "answer_id": 7679371, "author": "Jonathan", "author_id": 982873, "author_profile": "https://Stackoverflow.com/users/982873", "pm_score": -1, "selected": false, "text": "package com.bprog.collections;//my own little set of useful utilities and classes\n\nimport java.util.HashSet;\nimport java.util.ArrayList;\nimport java.util.List;\n/**\n*\n* @author Jonathan\n*/\npublic class UniqueList {\n\nprivate HashSet masterSet = new HashSet();\nprivate ArrayList growableUniques;\nprivate Object[] returnable;\n\npublic UniqueList() {\n growableUniques = new ArrayList();\n}\n\npublic UniqueList(int size) {\n growableUniques = new ArrayList(size);\n}\n\npublic void add(Object thing) {\n if (!masterSet.contains(thing)) {\n masterSet.add(thing);\n growableUniques.add(thing);\n }\n}\n\n/**\n * Casts to an ArrayList of unique values\n * @return \n */\npublic List getList(){\n return growableUniques;\n}\n\npublic Object get(int index) {\n return growableUniques.get(index);\n}\n\npublic Object[] toObjectArray() {\n int size = growableUniques.size();\n returnable = new Object[size];\n for (int i = 0; i < size; i++) {\n returnable[i] = growableUniques.get(i);\n }\n return returnable;\n }\n}\n package com.bprog.collections;\nimport com.bprog.out.Out;\n/**\n*\n* @author Jonathan\n*/\npublic class TestCollections {\n public static void main(String[] args){\n UniqueList ul = new UniqueList();\n ul.add(\"Test\");\n ul.add(\"Test\");\n ul.add(\"Not a copy\");\n ul.add(\"Test\"); \n //should only contain two things\n Object[] content = ul.toObjectArray();\n Out.pl(\"Array Content\",content);\n }\n}\n" }, { "answer_id": 8851072, "author": "neoreeprast", "author_id": 1097044, "author_profile": "https://Stackoverflow.com/users/1097044", "pm_score": -1, "selected": false, "text": "add HashSet.add() HashSet.consist() HashSet.add() true false" }, { "answer_id": 23275958, "author": "user3570018", "author_id": 3570018, "author_profile": "https://Stackoverflow.com/users/3570018", "pm_score": 4, "selected": false, "text": "ArrayList LinkedHashSet LinkedHashSet<E> hashSet = new LinkedHashSet<E>()\n LinkedHashSet LinkedHasSet ArrayList if (hashSet.add(E)) arrayList.add(E);\n ArrayList addAll" }, { "answer_id": 35788695, "author": "marcolopes", "author_id": 130028, "author_profile": "https://Stackoverflow.com/users/130028", "pm_score": 1, "selected": false, "text": "import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.LinkedHashSet;\n\n/**\n * Extends <tt>ArrayList</tt> and guarantees no duplicate elements\n */\npublic class UniqueArrayList<T> extends ArrayList<T> {\n\n private static final long serialVersionUID = 1L;\n\n public UniqueArrayList(int initialCapacity) {\n super(initialCapacity);\n }\n\n public UniqueArrayList() {\n super();\n }\n\n public UniqueArrayList(T[] array) {\n this(Arrays.asList(array));\n }\n\n public UniqueArrayList(Collection<? extends T> col) {\n addAll(col);\n }\n\n\n @Override\n public void add(int index, T e) {\n if (!contains(e)) super.add(index, e);\n }\n\n @Override\n public boolean add(T e) {\n return contains(e) ? false : super.add(e);\n }\n\n @Override\n public boolean addAll(Collection<? extends T> col) {\n Collection set=new LinkedHashSet(this);\n set.addAll(col);\n clear();\n return super.addAll(set);\n }\n\n @Override\n public boolean addAll(int index, Collection<? extends T> col) {\n Collection set=new LinkedHashSet(subList(0, index));\n set.addAll(col);\n set.addAll(subList(index, size()));\n clear();\n return super.addAll(set);\n }\n\n @Override\n public T set(int index, T e) {\n return contains(e) ? null : super.set(index, e);\n }\n\n /** Ensures element.equals(o) */\n @Override\n public int indexOf(Object o) {\n int index=0;\n for(T element: this){\n if (element.equals(o)) return index;\n index++;\n }return -1;\n }\n\n\n}\n" }, { "answer_id": 70198218, "author": "GerNi", "author_id": 17570655, "author_profile": "https://Stackoverflow.com/users/17570655", "pm_score": -1, "selected": false, "text": "while (searchResult != null && searchResult.hasMore()) {\n SearchResult nextElement = searchResult.nextElement();\n Attributes attributes = nextElement.getAttributes();\n\n String stringName = getAttributeStringValue(attributes, SearchAttribute.*attributeName*);\n \n if(!List.contains(stringName)){\n List.add(stringName);\n }\n}\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2819/" ]
268,674
<p>I have this ListBox which is bound to an ObservableCollection. Each object in the list implements an interface called ISelectable </p> <pre><code>public interface ISelectable : INotifyPropertyChanged { event EventHandler IsSelected; bool Selected { get; set; } string DisplayText { get; } } </code></pre> <p>I want to keep track of which object is selected regardless of how it is selected. The user could click on the representation of the object in the ListBox but it could also be that an object is selected via code. If the user selects an object via the ListBox I cast the the selected item to an ISelectable and set the Selected property to true.</p> <pre><code>ISelectable selectable = (ISelectable)e.AddedItems[0]; selectable.Selected = true; </code></pre> <p>My problem is that when I select the object using code I can't get ListBox to change the selected item. I'm using a DataTemplate to show the selected object in a different color which means everything is displayed correctly. But the ListBox has the last object the user clicked as the SelectedItem which means that item can't be clicked without first selecting another object in the list.</p> <p>Anyone got any idea on how to solve this? I pretty sure I can accomplish what I want by writing some custom code to handle the Mouse and Keyboard events but I rather not. I have tried adding a SelectedItem property to the collection and bind it to the ListBox's SelectItemProperty but no luck. </p>
[ { "answer_id": 269094, "author": "Sorskoot", "author_id": 31722, "author_profile": "https://Stackoverflow.com/users/31722", "pm_score": 0, "selected": false, "text": "private bool _Selected;\n public bool Selected\n {\n get\n {\n return _Selected;\n }\n set\n {\n if (PropertyChanged != null) \n PropertyChanged(this, new PropertyChangedEventArgs(\"Selected\"));\n\n _Selected = value;\n }\n }\n public ObservableCollection<testClass> tests = new ObservableCollection<testClass>();\n\n public Window1()\n {\n InitializeComponent();\n tests.Add(new testClass(\"Row 1\"));\n tests.Add(new testClass(\"Row 2\"));\n tests.Add(new testClass(\"Row 3\"));\n tests.Add(new testClass(\"Row 4\"));\n tests.Add(new testClass(\"Row 5\"));\n tests.Add(new testClass(\"Row 6\"));\n TheList.ItemsSource = tests;\n }\n\n private void Button_Click(object sender, RoutedEventArgs e)\n {\n tests[3].Selected = true;\n TheList.SelectedItem = tests[3];\n }\n <ListBox Grid.Row=\"0\" x:Name=\"TheList\"></ListBox> \n<Button Grid.Row=\"1\" Click=\"Button_Click\">Select 4th</Button>\n" }, { "answer_id": 270269, "author": "Ian Oakes", "author_id": 21606, "author_profile": "https://Stackoverflow.com/users/21606", "pm_score": 3, "selected": true, "text": "<List.Resources>\n <Style TargetType=\"ListBoxItem\">\n <Setter \n Property=\"IsSelected\" \n Value=\"{Binding \n Path=DataContext.Selected, \n RelativeSource={RelativeSource Self}}\" \n />\n </Style>\n</List.Resources>\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/143/" ]
268,680
<p>I would like to monitor the number of threads used by a specific process on Linux. Is there an easy way to get this information without impacting the performance of the process?</p>
[ { "answer_id": 272716, "author": "slav0nic", "author_id": 2201031, "author_profile": "https://Stackoverflow.com/users/2201031", "pm_score": 8, "selected": false, "text": "ps huH p <PID_OF_U_PROCESS> | wc -l\n" }, { "answer_id": 7216452, "author": "flexo", "author_id": 906726, "author_profile": "https://Stackoverflow.com/users/906726", "pm_score": 3, "selected": false, "text": "ps uH p <PID_OF_U_PROCESS> | wc -l\n" }, { "answer_id": 7216699, "author": "bdonlan", "author_id": 36723, "author_profile": "https://Stackoverflow.com/users/36723", "pm_score": 6, "selected": false, "text": "/proc/<pid>/task" }, { "answer_id": 21244557, "author": "jlliagre", "author_id": 211665, "author_profile": "https://Stackoverflow.com/users/211665", "pm_score": 3, "selected": false, "text": "ps -L -o pid= -p <pid> | wc -l\n ps 1 ps -o pid=" }, { "answer_id": 25459612, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": false, "text": "ps -eLf top" }, { "answer_id": 29772733, "author": "PbxMan", "author_id": 1652451, "author_profile": "https://Stackoverflow.com/users/1652451", "pm_score": 6, "selected": false, "text": "cat /proc/<PROCESS_PID>/status | grep Threads\n" }, { "answer_id": 33368739, "author": "Partly Cloudy", "author_id": 109079, "author_profile": "https://Stackoverflow.com/users/109079", "pm_score": 0, "selected": false, "text": "jstack" }, { "answer_id": 35421908, "author": "Avinash Reddy", "author_id": 4963254, "author_profile": "https://Stackoverflow.com/users/4963254", "pm_score": 3, "selected": false, "text": "$ ps H p pid-id $cat /proc/pid-id/status root@abc:~# cat /proc/8443/status\nName: abcdd\nState: S (sleeping)\nTgid: 8443\nVmSwap: 0 kB\nThreads: 4\nSigQ: 0/256556\nSigPnd: 0000000000000000\n" }, { "answer_id": 37713259, "author": "Thejaswi R", "author_id": 644289, "author_profile": "https://Stackoverflow.com/users/644289", "pm_score": 7, "selected": false, "text": "$ ps -o nlwp <pid>\n nlwp ps nlwp thcount $ ps -o thcount <pid>\n watch $ watch ps -o thcount <pid>\n $ ps -eo nlwp | tail -n +2 | awk '{ num_threads += $1 } END { print num_threads }'\n" }, { "answer_id": 42277270, "author": "Manuel Mndza Bañs", "author_id": 7575716, "author_profile": "https://Stackoverflow.com/users/7575716", "pm_score": 1, "selected": false, "text": "top -bc -H -n2 -p <pid> | awk '{if ($9 != \"0.0\" && $1 ~ /^[0-9]+$/) print $1 }' | sort -u | wc -l\n" }, { "answer_id": 46885192, "author": "Saeed Zahedian Abroodi", "author_id": 8584198, "author_profile": "https://Stackoverflow.com/users/8584198", "pm_score": 2, "selected": false, "text": "sudo apt-get install htop\n yum install htop\ndnf install htop [On Fedora 22+ releases]\n" }, { "answer_id": 63118210, "author": "Andreas Foteas", "author_id": 7948137, "author_profile": "https://Stackoverflow.com/users/7948137", "pm_score": 1, "selected": false, "text": "ps -eLf | grep <USER> | awk '{ num += $6 } END { print num }'\n <USER>" }, { "answer_id": 66134471, "author": "Serge Mosin", "author_id": 1573766, "author_profile": "https://Stackoverflow.com/users/1573766", "pm_score": 2, "selected": false, "text": "ps -o pid,nlwp,args -p <pid_1> <pid_2> ... <pid_N>\n watch watch ps -o pid,nlwp,args -p <pid_1> <pid_2> ... <pid_N>\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
268,698
<p>This is somewhat of a follow-up question to this <a href="https://stackoverflow.com/questions/267045/is-there-a-benefit-to-having-both-an-abstract-class-and-an-interface">question</a>.</p> <p>Suppose I have an inheritance tree as follows:</p> <pre><code>Car -&gt; Ford -&gt; Mustang -&gt; MustangGT </code></pre> <p>Is there a benefit to defining interfaces for <em>each</em> of these classes? Example:</p> <pre><code>ICar -&gt; IFord -&gt; IMustang -&gt; IMustangGT </code></pre> <p>I can see that maybe other classes (like <code>Chevy</code>) would want to implement <code>Icar</code> or <code>IFord</code> and maybe even <code>IMustang</code>, but probably not <code>IMustangGT</code> because it is so specific. Are the interfaces superfluous in this case?</p> <p>Also, I would think that any class that would want to implement <code>IFord</code> would definitely want to use its one inheritance by inheriting from <code>Ford</code> so as not to duplicate code. If that is a given, what is the benefit of also implementing <code>IFord</code>?</p>
[ { "answer_id": 268747, "author": "eddy147", "author_id": 30759, "author_profile": "https://Stackoverflow.com/users/30759", "pm_score": -1, "selected": false, "text": "class Ford{\n public function Foo(){\n ...\n Mustang mustang = new Mustang();\n return mustang.Foo();\n}\n" }, { "answer_id": 268754, "author": "JohnIdol", "author_id": 1311500, "author_profile": "https://Stackoverflow.com/users/1311500", "pm_score": 1, "selected": false, "text": "Make == Whatever" }, { "answer_id": 268850, "author": "coobird", "author_id": 17172, "author_profile": "https://Stackoverflow.com/users/17172", "pm_score": 3, "selected": false, "text": "Car -> Ford -> Escape -> EscapeHybrid\nCar -> Toyota -> Corolla -> CorollaHybrid\n wheels Drive() Steer() Car Car Ford Toyota Escape Corolla Escape EscapeHybrid FordsHybridDrive() Corolla CorollaHybrid ToyotasHybridDrive() HybridDrive() IHybrid HybridDrive() EscapeHybrid CorollaHybrid IHybrid Comparable" }, { "answer_id": 268886, "author": "yfeldblum", "author_id": 12349, "author_profile": "https://Stackoverflow.com/users/12349", "pm_score": 0, "selected": false, "text": "IMustangGT ICar IExpensiveCar" }, { "answer_id": 470770, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 3, "selected": false, "text": "IDriveable IHasWheels IList" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268698", "https://Stackoverflow.com", "https://Stackoverflow.com/users/132931/" ]
268,706
<p>I'm currently developing a Facebook application which will eventually end up on a Facebook Page. The problem is that I don't know how to remove the box header (handle?) with the application name and the close-button.</p> <p>I've seen other applications on Pages being able to remove the header. Look at Apples Page here: <a href="http://www.facebook.com/home.php#/pages/Apple-Students/11147074409" rel="nofollow noreferrer">http://www.facebook.com/home.php#/pages/Apple-Students/11147074409</a></p> <p>Is it because they use an IFrame? I've tried that as well but I still need to call setFBML and embed an IFrame inside it.</p>
[ { "answer_id": 268747, "author": "eddy147", "author_id": 30759, "author_profile": "https://Stackoverflow.com/users/30759", "pm_score": -1, "selected": false, "text": "class Ford{\n public function Foo(){\n ...\n Mustang mustang = new Mustang();\n return mustang.Foo();\n}\n" }, { "answer_id": 268754, "author": "JohnIdol", "author_id": 1311500, "author_profile": "https://Stackoverflow.com/users/1311500", "pm_score": 1, "selected": false, "text": "Make == Whatever" }, { "answer_id": 268850, "author": "coobird", "author_id": 17172, "author_profile": "https://Stackoverflow.com/users/17172", "pm_score": 3, "selected": false, "text": "Car -> Ford -> Escape -> EscapeHybrid\nCar -> Toyota -> Corolla -> CorollaHybrid\n wheels Drive() Steer() Car Car Ford Toyota Escape Corolla Escape EscapeHybrid FordsHybridDrive() Corolla CorollaHybrid ToyotasHybridDrive() HybridDrive() IHybrid HybridDrive() EscapeHybrid CorollaHybrid IHybrid Comparable" }, { "answer_id": 268886, "author": "yfeldblum", "author_id": 12349, "author_profile": "https://Stackoverflow.com/users/12349", "pm_score": 0, "selected": false, "text": "IMustangGT ICar IExpensiveCar" }, { "answer_id": 470770, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 3, "selected": false, "text": "IDriveable IHasWheels IList" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29886/" ]
268,736
<p>An svn repository I'm mirroring through git-svn has changed URL.</p> <p>In vanilla svn you'd just do <code>svn switch --relocate old_url_base new_url_base</code>.</p> <p>How can I do this using git-svn? </p> <p>Simply changing the svn url in the config file fails.</p>
[ { "answer_id": 268739, "author": "Adam Alexander", "author_id": 33164, "author_profile": "https://Stackoverflow.com/users/33164", "pm_score": 2, "selected": false, "text": "git-svn-id git-svn clone" }, { "answer_id": 268767, "author": "kch", "author_id": 13989, "author_profile": "https://Stackoverflow.com/users/13989", "pm_score": 7, "selected": true, "text": "file:// http:// url [svn-remote \"svn\"] .git/config url git svn fetch url git svn rebase -l url git svn rebase --rewrite-root" }, { "answer_id": 4061493, "author": "H Krishnan", "author_id": 492519, "author_profile": "https://Stackoverflow.com/users/492519", "pm_score": 5, "selected": false, "text": "svn-remote.svn.rewriteRoot .git/config git config svn-remote.svn.rewriteRoot <currentRepositoryURL>\n svn-remote.svn.rewriteUUID git config svn-remote.svn.rewriteUUID <currentRepositoryUUID>\n currentRepositoryUUID .git/svn/.metadata git config svn-remote.svn.url <newRepositoryURL>" }, { "answer_id": 8136337, "author": "UncleZeiv", "author_id": 60531, "author_profile": "https://Stackoverflow.com/users/60531", "pm_score": 4, "selected": false, "text": "svn-remote url fetch .git/config git svn fetch git svn rebase Unable to determine upstream SVN information from working tree history\n git svn git-svn-id .git/config svn-remote url fetch git svn rebase -l git svn git-svn-id .git/config svn-remote url fetch git svn rebase" }, { "answer_id": 18381709, "author": "krlmlr", "author_id": 946850, "author_profile": "https://Stackoverflow.com/users/946850", "pm_score": 2, "selected": false, "text": "git filter-branch svn switch --relocate git filter-branch git-svn-id .git/config git-svn git svn rebase git svn clone filter-branch #!/bin/sh\n\n# Must be called with two command-line args.\n# Example: git-svn-relocate.sh http://old.server https://new.server\nif [ $# -ne 2 ]\nthen\n echo \"Please invoke this script with two command-line arguments (old and new SVN URLs).\"\n exit $E_NO_ARGS\nfi\n\n# Prepare URLs for regex search and replace.\noldUrl=`echo $1 | awk '{gsub(\"[\\\\\\.]\", \"\\\\\\\\\\\\\\&\");print}'`\nnewUrl=`echo $2 | awk '{gsub(\"[\\\\\\&]\", \"\\\\\\\\\\\\\\&\");print}'`\n\nfilter=\"sed \\\"s|^git-svn-id: $oldUrl|git-svn-id: $newUrl|g\\\"\"\ngit filter-branch --msg-filter \"$filter\" -- --all\n\nsed -i.backup -e \"s|$oldUrl|$newUrl|g\" .git/config\n\nrm -rf .git/svn\ngit svn rebase\n" }, { "answer_id": 18385514, "author": "krlmlr", "author_id": 946850, "author_profile": "https://Stackoverflow.com/users/946850", "pm_score": 1, "selected": false, "text": "git_fast_filter git-filter-branch git_fast_filter git-filter-branch master git_fast_filter git_fast_filter chmod +x git init (cd path/to/old/repo && git-fast-export --branches --tags --progress=100) | \\\n path/to/git_fast_filter/commit_filter.py | git-fast-import\n .git/config .git/info .git/svn git-svn git branch refs/remotes/git-svn master refs/remotes/git-svn .git/config svn-remote git svn info refs/remotes/git-svn git-svn git svn rebase commit_filter.py IN_REPO OUT_REPO #!/usr/bin/python\n\nfrom git_fast_filter import Commit, FastExportFilter\nimport re\nimport sys\n\nIN_REPO = \"https://svn.code.sf.net/p/matsim/code\"\nOUT_REPO = \"https://svn.code.sf.net/p/matsim/source\"\n\nIN_REPO_RE = re.compile(\"^git-svn-id: %s\" % re.escape(IN_REPO), re.M)\nOUT_REPO_RE = \"git-svn-id: %s\" % OUT_REPO\n\ndef my_commit_callback(commit):\n commit.message = IN_REPO_RE.sub(OUT_REPO_RE, commit.message)\n sys.stderr.write(\".\")\n\nfilter = FastExportFilter(commit_callback = my_commit_callback)\nfilter.run()\n" }, { "answer_id": 20880050, "author": "Ben Challenor", "author_id": 161298, "author_profile": "https://Stackoverflow.com/users/161298", "pm_score": 0, "selected": false, "text": "git svn rebase -l old new old new cd new git fetch ../old git tag old FETCH_HEAD new old new old git checkout master master git rebase --root --onto old new git update-ref --no-deref refs/remotes/git-svn master refs/remotes/svn/trunk rm -r .git/svn git svn info" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13989/" ]
268,750
<p>I have a JFrame with a menu bar and a canvas covering all the remaining surface. When I click on the menu bar, the menu opens <strong>behind</strong> the Canvas and I can't see it. Has anyone experienced this? Other than resizing the Canvas (which I am reluctant to do) is there any solution?</p> <p>Thanks,<br/> Vlad</p>
[ { "answer_id": 268815, "author": "basszero", "author_id": 287, "author_profile": "https://Stackoverflow.com/users/287", "pm_score": 4, "selected": true, "text": "// Call this sometime before you use your menus \nJPopupMenu.setDefaultLightWeightPopupEnabled(false)\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1155998/" ]
268,771
<p>Ok, so I have this regex:</p> <pre><code>( |^|&gt;)(((((((\+|00)(31|32)( )?(\(0\))?)|0)([0-9]{2})(-)?( )?)?)([0-9]{7}))|((((((\+|00)(31|32)( )?(\(0\))?)|0)([0-9]{3})(-)?( )?)?)([0-9]{6}))|((((((\+|00)(31|32)( )?(\(0\))?)|0)([0-9]{1})(-)?( )?)?)([0-9]{8})))( |$|&lt;) </code></pre> <p>It formats Dutch and Belgian phone numbers (I only want those hence the 31 and 32 as country code).</p> <p>Its not much fun to decipher but as you can see it also has a lot duplicated. but now it does handles it very accurately</p> <p>All the following European formatted phone numbers are accepted</p> <pre><code>0031201234567 0031223234567 0031612345678 +31(0)20-1234567 +31(0)223-234567 +31(0)6-12345678 020-1234567 0223-234567 06-12345678 0201234567 0223234567 0612345678 </code></pre> <p>and the following false formatted ones are not</p> <pre><code>06-1234567 (mobile phone number in the Netherlands should have 8 numbers after 06 ) 0223-1234567 (area code with home phone) </code></pre> <p>as opposed to this which is good.</p> <pre><code>020-1234567 (area code with 3 numbers has 7 numbers for the phone as opposed to a 4 number area code which can only have 6 numbers for phone number) </code></pre> <p>As you can see it's the '-' character that makes it a little difficult but I need it in there because it's a part of the formatting usually used by people, and I want to be able to parse them all.</p> <p>Now is my question... do you see a way to simplify this regex (or even improve it if you see a fault in it), while keeping the same rules?</p> <p>You can test it at <a href="http://regextester.com/" rel="nofollow noreferrer">regextester.com</a></p> <p>(The '( |^|>)' is to check if it is at the start of a word with the possibility it being preceded by either a new line or a '>'. I search for the phone numbers in HTML pages.) </p>
[ { "answer_id": 268810, "author": "Pistos", "author_id": 28558, "author_profile": "https://Stackoverflow.com/users/28558", "pm_score": 3, "selected": false, "text": "if number =~ /...../ # Dutch mobiles\n # ...\nelsif number =~ /..../ # Belgian landlines\n # ...\n# etc.\nend\n" }, { "answer_id": 268852, "author": "dbr", "author_id": 745, "author_profile": "https://Stackoverflow.com/users/745", "pm_score": 2, "selected": false, "text": "phone_no_patterns = [\n /[0-9]{13}/, # 0031201234567\n /+(31|32)\\(0\\)\\d{2}-\\d{7}/ # +31(0)20-1234567\n # ..etc..\n]\ndef check_number(num):\n for pattern in phone_no_patterns:\n if num matches pattern:\n return match.groups\n" }, { "answer_id": 268856, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 2, "selected": false, "text": "(-)?( )?\n +31(0)6-12345678\n+31(0)6 12345678\n +31(0)6- 12345678\n (-)?( )?\n (-| )?\n" }, { "answer_id": 269151, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 5, "selected": true, "text": "(-)?( )? -? ? [- ]? ( |^|>)\n(\n ((((((\\+|00)(31|32)( )?(\\(0\\))?)|0)([0-9]{2})(-)?( )?)?)([0-9]{7})) |\n ((((((\\+|00)(31|32)( )?(\\(0\\))?)|0)([0-9]{3})(-)?( )?)?)([0-9]{6})) |\n ((((((\\+|00)(31|32)( )?(\\(0\\))?)|0)([0-9]{1})(-)?( )?)?)([0-9]{8}))\n)\n( |$|<)\n ( |^|>)\n(\n (((\\+|00)(31|32)( )?(\\(0\\))?)|0)\n (((([0-9]{2})(-)?( )?)?)([0-9]{7})) |\n (((([0-9]{3})(-)?( )?)?)([0-9]{6})) |\n (((([0-9]{1})(-)?( )?)?)([0-9]{8}))\n)\n( |$|<)\n ( |^|>)\n(\n (((\\+|00)3[12] ?(\\(0\\))?)|0)\n (((([0-9]{2})-? ?)?)[0-9]{7}) |\n (((([0-9]{3})-? ?)?)[0-9]{6}) |\n (((([0-9]{1})-? ?)?)[0-9]{8})\n)\n( |$|<)\n ( |^|>)\n(\n (((\\+|00)3[12] ?(\\(0\\))?)|0) # International prefix or leading zero\n ([0-9]{2}-? ?[0-9]{7}) | # xx-xxxxxxx\n ([0-9]{3}-? ?[0-9]{6}) | # xxx-xxxxxx\n ([0-9]{1}-? ?[0-9]{8}) # x-xxxxxxxx\n)\n( |$|<)\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16805/" ]
268,778
<p>I have a class called EventConsumer which defines an event EventConsumed and a method OnEventConsumed as follows:</p> <pre><code>public event EventHandler EventConsumed; public virtual void OnEventConsumed(object sender, EventArgs e) { if (EventConsumed != null) EventConsumed(this, e); } </code></pre> <p>I need to add attributes to the at OnEventConsumed runtime, so I'm generating a subclass using System.Reflection.Emit. What I want is the MSIL equivalent of this:</p> <pre><code>public override void OnEventConsumed(object sender, EventArgs e) { base.OnEventConsumed(sender, e); } </code></pre> <p>What I have so far is this:</p> <pre><code>... MethodInfo baseMethod = typeof(EventConsumer).GetMethod("OnEventConsumed"); MethodBuilder methodBuilder = typeBuilder.DefineMethod("OnEventConsumed", baseMethod.Attributes, baseMethod.CallingConvention, typeof(void), new Type[] {typeof(object), typeof(EventArgs)}); ILGenerator ilGenerator = methodBuilder.GetILGenerator(); // load the first two args onto the stack ilGenerator.Emit(OpCodes.Ldarg_1); ilGenerator.Emit(OpCodes.Ldarg_2); // call the base method ilGenerator.EmitCall(OpCodes.Callvirt, baseMethod, new Type[0] ); // return ilGenerator.Emit(OpCodes.Ret); ... </code></pre> <p>I create the type, create an instance of the type, and call its OnEventConsumed function, and I get:</p> <pre><code>Common Language Runtime detected an invalid program. </code></pre> <p>...which is not exactly helpful. What am I doing wrong? What's the correct MSIL to call the base class's event handler?</p>
[ { "answer_id": 268803, "author": "TcKs", "author_id": 20382, "author_profile": "https://Stackoverflow.com/users/20382", "pm_score": 0, "selected": false, "text": "public virtual void OnEventConsumed(object sender, EventArgs e)\n{\n if (EventConsumed != null)\n EventConsumed(this, e);\n}\n public virtual void OnEventConsumed(EventArgs e)\n{\n EventHandler handler = this.EventConsumed;\n if ( null != handler ) handler( this, e );\n}\n" }, { "answer_id": 268821, "author": "Simon", "author_id": 15371, "author_profile": "https://Stackoverflow.com/users/15371", "pm_score": 1, "selected": false, "text": "// load 'this' and the first two args onto the stack\nilGenerator.Emit(OpCodes.Ldarg_0);\nilGenerator.Emit(OpCodes.Ldarg_1);\nilGenerator.Emit(OpCodes.Ldarg_2);\n\n// call the base method\nilGenerator.EmitCall(OpCodes.Call, baseMethod, new Type[0] );\n\n// return\nilGenerator.Emit(OpCodes.Ret);\n" }, { "answer_id": 268829, "author": "Cory Foy", "author_id": 4083, "author_profile": "https://Stackoverflow.com/users/4083", "pm_score": 4, "selected": true, "text": "\n.method public hidebysig virtual instance void OnEventConsumed(object sender, class [mscorlib]System.EventArgs e) cil managed\n {\n .maxstack 8\n L_0000: nop \n L_0001: ldarg.0 \n L_0002: ldarg.1 \n L_0003: ldarg.2 \n L_0004: call instance void SubclassSpike.BaseClass::OnEventConsumed(object, class [mscorlib]System.EventArgs)\n L_0009: nop \n L_000a: ret \n }\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268778", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15371/" ]
268,782
<p>How do I implement the WS addressing using WCF?</p>
[ { "answer_id": 3519385, "author": "Shameer Kunjumohamed", "author_id": 423735, "author_profile": "https://Stackoverflow.com/users/423735", "pm_score": 0, "selected": false, "text": "<textMessageEncoding messageVersion=\"Soap11WSAddressing10\"/>\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
268,802
<p>In my Silverlight app I want a multi-line text box to expand every time the user hits Enter.</p> <p>The difficult part is how to calculate the correct height based on the number of text lines.</p> <p>I have tried the following but the textbox becomes too small:</p> <pre><code>box.Height = box.FontSize*lineCount + box.Padding.Top + box.Padding.Bottom + box.BorderThickness.Top + box.BorderThickness.Bottom; </code></pre> <p>What am I missing here? Or maybe it can be done automatically somehow?</p> <p>Thanks, Jacob</p> <p><strong>Edit:</strong> I suspect the problem to be in the FontSize property (does it use another size unit?)</p>
[ { "answer_id": 2683688, "author": "Mike Blandford", "author_id": 28643, "author_profile": "https://Stackoverflow.com/users/28643", "pm_score": 0, "selected": false, "text": "TextBox SizeChanged ActualHeight TextBlock ActualHeight" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30056/" ]
268,808
<p>I have a need to determine what security group(s) a user is a member of from within a SQL Server Reporting Services report. Access to the report will be driven by membership to one of two groups: 'report_name_summary' and 'report_name_detail'. Once the user is executing the report, we want to be able to use their membership (or lack of membership) in the 'report_name_detail' group to determine whether or not a "drill down" should be allowed.</p> <p>I don't know of any way out of the box to access the current user's AD security group membership, but am open to any suggestions for being able to access this info from within the report.</p>
[ { "answer_id": 285601, "author": "PJ8", "author_id": 35490, "author_profile": "https://Stackoverflow.com/users/35490", "pm_score": 4, "selected": true, "text": "Public Function ShouldReportBeHidden() As Boolean\nDim Principal As New System.Security.Principal.WindowsPrincipal(System.Security.Principal.WindowsIdentity.GetCurrent())\nIf (Principal.IsInRole(\"MyADGroup\")) Then\n Return False\nElse\n Return True\nEnd If\nEnd Function\n" }, { "answer_id": 18133807, "author": "Ralph177", "author_id": 315641, "author_profile": "https://Stackoverflow.com/users/315641", "pm_score": 1, "selected": false, "text": "Public Function IsMemberOfGroup() As Boolean\n\nIf System.Threading.Thread.CurrentPrincipal.IsInRole(\"MyADGroup\") Then\n Return True\nElse\n Return False\nEnd If\n\nEnd Function\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268808", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1680/" ]
268,814
<p>Consider this:</p> <pre><code>public class TestClass { private String a; private String b; public TestClass() { a = "initialized"; } public void doSomething() { String c; a.notify(); // This is fine b.notify(); // This is fine - but will end in an exception c.notify(); // "Local variable c may not have been initialised" } } </code></pre> <p>I don't get it. "b" is never initialized but will give the same run-time error as "c", which is a compile-time error. Why the difference between local variables and members?</p> <p><strong>Edit</strong>: making the members private was my initial intention, and the question still stands...</p>
[ { "answer_id": 268909, "author": "Yuval", "author_id": 2819, "author_profile": "https://Stackoverflow.com/users/2819", "pm_score": 5, "selected": false, "text": "TestClass tc = new TestClass();\n new false null null" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24545/" ]
268,816
<p>What are some strategies to achieve code separation in AJAX applications?</p> <p>I am building a PHP application that I would like to have a nice AJAX front end on. I have long since learned to use some kind of templating in my PHP code to make sure I maintain good separation between my logic and display code, but I'm having trouble finding good ways to do this with the JavaScript code on the front end. I'm using jQuery to make the fetching of XML data and DOM manipulation easy, but I'm finding that the logic and layout code is starting to intermix.</p> <p>The real problem is that I get XML data from the back end that then has to be reformatted and helpful text has to be wrapped around it (directions and the like). I've thought about sending over already formatted HTML, but that would require extensive reworking of the backend, and there must be a better way than what I have come up with on my own.</p>
[ { "answer_id": 268847, "author": "James Hughes", "author_id": 34671, "author_profile": "https://Stackoverflow.com/users/34671", "pm_score": 2, "selected": false, "text": "var XMLFormatter = function(){\n /* PRIVATE AREA */\n\n /* PUBLIC API */\n return {\n formatXML : function(xml){\n /* DO SOMETHING RETURN SOMETHING */\n }\n }\n}();\n function useClass(){\n $('#test').update(XMLFormatter.formatXML(someXML))\n}\n" }, { "answer_id": 269074, "author": "hugoware", "author_id": 17091, "author_profile": "https://Stackoverflow.com/users/17091", "pm_score": 2, "selected": false, "text": "var FilterControl = function() {\n\n //the \"event\"\n var self = this;\n this.onLoadComplete = function() { };\n\n //This is the command that calls the event\n this.load = function() {\n //do some work\n ...\n\n //Call the event\n self.onLoadComplete();\n };\n};\n\n//somewhere else in the code\nvar filter = new FilterControl();\nfilter.onLoadComplete = function() {\n //unique calls just for this control\n};\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24215/" ]
268,820
<p>I have a servlet that I would like to run within ColdFusion MX 7. I would like to make use of an existing ColdFusion DSN as a javax.sql.DataSource, if possible.</p> <p>I thought something like </p> <pre><code>coldfusion.server.ServiceFactory.getDataSourceService().getDatasource(dsname); </code></pre> <p>would work, but unfortunately the servlet returns</p> <pre><code>java.lang.NoClassDefFoundError: coldfusion/server/ServiceFactory </code></pre>
[ { "answer_id": 272072, "author": "AlexJReid", "author_id": 32320, "author_profile": "https://Stackoverflow.com/users/32320", "pm_score": 1, "selected": true, "text": "Context context = new InitialContext();\nDataSource ds = (DataSource)context.lookup(\"mydatasource\"); \n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32320/" ]
268,824
<p>We're working now on the design of a new API for our product, which will be exposed via web services. We have a dispute whether we should use strict parameters with well defined types (my opinion) or strings that will contain XML in whatever structure needed. It is quite obvious that ideally using a strict signature is safer, and it will allow our users to use tools like wsdl2java. OTOH, our product is developing rapidly, and if the parameters of a service will have to be changed, using XML (passed as a string or anyType - not complex type, which is well defined type) will not require the change of the interface.</p> <p>So, what I'm asking for is basically rule of thumb recommendations - would you prefer using strict types or flexible XML? Have you had any significant problems using either way?</p> <p>Thanks, Eran</p>
[ { "answer_id": 272072, "author": "AlexJReid", "author_id": 32320, "author_profile": "https://Stackoverflow.com/users/32320", "pm_score": 1, "selected": true, "text": "Context context = new InitialContext();\nDataSource ds = (DataSource)context.lookup(\"mydatasource\"); \n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268824", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26039/" ]
268,835
<p>I am new to Hibernate and attempting to run a java/spring example that retrieves data from a table in MS SqlServer. Everytime I try to run the program, the data source loads ok. But when spring tries to load the session facotry it gets the following error:</p> <pre><code>Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [ml/spring/src/applicationContext.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/transaction/TransactionManager Caused by: java.lang.NoClassDefFoundError: javax/transaction/TransactionManager </code></pre> <p>Below is the application Context file I am using:</p> <pre><code>&lt;!-- Data source bean --&gt; &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" &gt; &lt;property name="driverClassName"&gt; &lt;value&gt;com.microsoft.jdbc.sqlserver.SQLServerDriver&lt;/value&gt;&lt;/property&gt; &lt;property name="url"&gt; &lt;value&gt;jdbc:microsoft:sqlserver://machine:port&lt;/value&gt;&lt;/property&gt; &lt;property name="username"&gt;&lt;value&gt;user&lt;/value&gt;&lt;/property&gt; &lt;property name="password"&gt;&lt;value&gt;password&lt;/value&gt;&lt;/property&gt; &lt;/bean&gt; &lt;!-- Session Factory Bean --&gt; &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt; &lt;property name="dataSource"&gt;&lt;ref local="dataSource"/&gt;&lt;/property&gt; &lt;property name="mappingResources"&gt; &lt;list&gt; &lt;value&gt;authors.hbm.xml&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;property name="hibernateProperties"&gt; &lt;value&gt; hibernate.dialect=net.sf.hibernate.dialect.SQLServerDialect &lt;/value&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt; &lt;property name="sessionFactory" ref="sessionFactory" /&gt; &lt;/bean&gt; </code></pre>
[ { "answer_id": 268883, "author": "toolkit", "author_id": 3295, "author_profile": "https://Stackoverflow.com/users/3295", "pm_score": 4, "selected": false, "text": "jta-1.1.jar\n" }, { "answer_id": 43872451, "author": "Georgios Syngouroglou", "author_id": 1123501, "author_profile": "https://Stackoverflow.com/users/1123501", "pm_score": 0, "selected": false, "text": "<dependency>\n <groupId>javax.transaction</groupId>\n <artifactId>jta</artifactId>\n <version>1.1</version>\n</dependency>\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
268,836
<p>Can someone explain why there is the need to add an out or in parameter to indicate that a generic type is Co or Contra variant in C# 4.0?</p> <p>I've been trying to understand why this is important and why the compiler can't just figure it out..</p> <p>Thanks,</p> <p>Josh</p>
[ { "answer_id": 268871, "author": "yfeldblum", "author_id": 12349, "author_profile": "https://Stackoverflow.com/users/12349", "pm_score": 1, "selected": false, "text": "in out in out" }, { "answer_id": 268900, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 3, "selected": false, "text": "abstract out ref" }, { "answer_id": 268954, "author": "Edward Kmett", "author_id": 34707, "author_profile": "https://Stackoverflow.com/users/34707", "pm_score": 3, "selected": false, "text": " class Foo { .. } \n\n class Bar : Foo { .. } \n IEnumerator<Bar> IEnumerator<Foo> IEnumerator<Bar> Bar Bar Foo IEqualityComparer<Foo> Foo Bar IEqualityComparer<Bar> IEqualityComparer<Foo> Foo Bar Foo" }, { "answer_id": 268972, "author": "Scott Dorman", "author_id": 1559, "author_profile": "https://Stackoverflow.com/users/1559", "pm_score": 1, "selected": false, "text": "out ref" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26160/" ]
268,853
<p>This is just to satisfy my own curiosity.</p> <p>Is there an implementation of this:</p> <pre><code>float InvSqrt (float x) { float xhalf = 0.5f*x; int i = *(int*)&amp;x; i = 0x5f3759df - (i&gt;&gt;1); x = *(float*)&amp;i; x = x*(1.5f - xhalf*x*x); return x; } </code></pre> <p>in C#? If it exists, post the code. </p> <p>I guess I should have mentioned I was looking for a "safe" implementation... Either way, the BitConverter code solves the problem. The union idea is interesting. I'll test it and post my results.</p> <p>Edit: As expected, the unsafe method is the quickest, followed by using a union (inside the function), followed by the BitConverter. The functions were executed 10000000 times, and the I used the System.Diagnostics.Stopwatch class for timing. The results of the calculations are show in brackets.</p> <pre><code>Input: 79.67 BitConverter Method: 00:00:01.2809018 (0.1120187) Union Method: 00:00:00.6838758 (0.1120187) Unsafe Method: 00:00:00.3376401 (0.1120187) </code></pre> <p>For completeness, I tested the built-in Math.Pow method, and the "naive" method (1/Sqrt(x)).</p> <pre><code>Math.Pow(x, -0.5): 00:00:01.7133228 (0.112034710535584) 1 / Math.Sqrt(x): 00:00:00.3757084 (0.1120347) </code></pre> <p>The difference between 1 / Math.Sqrt() is so small that I don't think one needs to resort to the Unsafe Fast InvSqrt() method in C# (or any other unsafe method). Unless one <em>really</em> needs to squeeze out that last bit of juice from the CPU... 1/Math.Sqrt() is also much more accurate.</p>
[ { "answer_id": 268901, "author": "Bradley Grainger", "author_id": 23633, "author_profile": "https://Stackoverflow.com/users/23633", "pm_score": 4, "selected": false, "text": "float InvSqrt(float x)\n{\n float xhalf = 0.5f * x;\n int i = BitConverter.SingleToInt32Bits(x);\n i = 0x5f3759df - (i >> 1);\n x = BitConverter.Int32BitsToSingle(i);\n x = x * (1.5f - xhalf * x * x);\n return x;\n}\n float InvSqrt(float x)\n{\n float xhalf = 0.5f * x;\n int i = BitConverter.ToInt32(BitConverter.GetBytes(x), 0);\n i = 0x5f3759df - (i >> 1);\n x = BitConverter.ToSingle(BitConverter.GetBytes(i), 0);\n x = x * (1.5f - xhalf * x * x);\n return x;\n}\n unsafe float InvSqrt(float x) { ... }\n" }, { "answer_id": 268905, "author": "Edward Kmett", "author_id": 34707, "author_profile": "https://Stackoverflow.com/users/34707", "pm_score": 5, "selected": true, "text": "[StructLayout(LayoutKind.Explicit, Size=4)]\nprivate struct IntFloat {\n [FieldOffset(0)]\n public float floatValue;\n\n [FieldOffset(0)]\n public int intValue;\n\n // redundant assignment to avoid any complaints about uninitialized members\n IntFloat(int x) {\n floatValue = 0;\n intValue = x;\n }\n\n IntFloat(float x) { \n intValue = 0;\n floatValue = x;\n }\n\n public static explicit operator float (IntFloat x) {\n return x.floatValue;\n }\n\n public static explicit operator int (IntFloat x) { \n return x.intValue;\n }\n\n public static explicit operator IntFloat (int i) {\n return new IntFloat(i);\n }\n public static explicit operator IntFloat (float f) { \n return new IntFloat(f);\n }\n}\n" }, { "answer_id": 268933, "author": "Tamas Czinege", "author_id": 8954, "author_profile": "https://Stackoverflow.com/users/8954", "pm_score": 3, "selected": false, "text": "0x5f3759df 0x5f375a86" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9825/" ]
268,865
<p>Someone left the organisation but before leaving, he locked all the files for an unknown reason. </p> <p>How do you unlock them all so that the other developers can work?</p>
[ { "answer_id": 12187348, "author": "AaronLS", "author_id": 84206, "author_profile": "https://Stackoverflow.com/users/84206", "pm_score": 3, "selected": false, "text": "tf workspace /delete /server:http://machinename:8080/tfs/DefaultCollection someMachine123;someUser:1\n someMachine123;someUser:1 someUser:1 someUser workspaces workspace" }, { "answer_id": 36756931, "author": "Dennis T --Reinstate Monica--", "author_id": 3490817, "author_profile": "https://Stackoverflow.com/users/3490817", "pm_score": -1, "selected": false, "text": "/*Find correct row*/\nSELECT LockStatus, PendingChangeId, *\nFROM tbl_PendingChange\nWHERE TargetServerItem like '%<<fileName>>%'\n\n/*Set lock status to NULL (mine was set to 2 initially)*/\nUPDATE tbl_PendingChange SET LockStatus = NULL WHERE\nTargetServerItem like '%<fileName>>%'\nAND PendingChangeId = <<PendingChangeId from above>>\n" }, { "answer_id": 69739449, "author": "aseman arabsorkhi", "author_id": 9194245, "author_profile": "https://Stackoverflow.com/users/9194245", "pm_score": 0, "selected": false, "text": "tf undo /workspace:workspaceName;DomainName\\UserName $/file path in your solution\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24975/" ]
268,884
<p>I am trying to convert an access datetime field to a mysdl format, using the following string:</p> <pre><code>select str_to_date('04/03/1974 12:21:22', '%Y %m %d %T'); </code></pre> <p>While I do not get an error, I do not get the expected result, instead I get this:</p> <pre><code>+---------------------------------------------------+ | str_to_date('04/03/1974 12:21:22', '%Y %m %d %T') | +---------------------------------------------------+ | NULL | +---------------------------------------------------+ 1 row in set, 1 warning (0.01 sec) </code></pre> <p>The access dates are in this format:</p> <pre><code>06.10.2008 14:19:08 </code></pre> <p>I am not sure what I am missing.</p> <p>As a side question, I am wondering if it is possible when importing a csv file to change the data in a column before? I want to replace the insert_date and update_date fields with my own dates, and I am not sure if it would be easier to do this before importing or after.</p> <p>Many thanks for assistance.</p>
[ { "answer_id": 268942, "author": "andyhky", "author_id": 2764, "author_profile": "https://Stackoverflow.com/users/2764", "pm_score": 3, "selected": true, "text": "select str_to_date('04/03/1974 12:21:22', '%m/%d/%Y %T');\n select str_to_date('06.10.2008 14:19:08', '%m.%d.%Y %T');\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
268,885
<p>What's the best way to write a LINQ query that inserts a record and then returns the primary key of that newly inserted record using C# ?</p>
[ { "answer_id": 268888, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 6, "selected": true, "text": "MyTable record = new MyTable();\nrecord.Name = \"James Curran\";\ndb.MyTable.InsertOnSubmit(record);\ndb.SubmitChanges();\nConsole.WriteLine(\"record inserted as ID : {0}\", record.Id);\n" }, { "answer_id": 11699824, "author": "kazem", "author_id": 787931, "author_profile": "https://Stackoverflow.com/users/787931", "pm_score": 3, "selected": false, "text": "// Create a new Order object.\nOrder ord = new Order\n{\n OrderID = 12000,\n ShipCity = \"Seattle\",\n OrderDate = DateTime.Now\n // …\n};\n\n// Add the new object to the Orders collection.\ndb.Orders.InsertOnSubmit(ord);\n\n// Submit the change to the database.\ntry\n{\n db.SubmitChanges();\n}\ncatch (Exception e)\n{\n Console.WriteLine(e);\n // Make some adjustments.\n // ...\n // Try again.\n db.SubmitChanges();\n}\nreturn ord.OrderID;\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26809/" ]
268,891
<p>I've got this python dictionary "mydict", containing arrays, here's what it looks like :</p> <pre><code>mydict = dict( one=['foo', 'bar', 'foobar', 'barfoo', 'example'], two=['bar', 'example', 'foobar'], three=['foo', 'example']) </code></pre> <p>i'd like to replace all the occurrences of "example" by "someotherword". </p> <p>While I can already think of a few ways to do it, is there a most "pythonic" method to achieve this ?</p>
[ { "answer_id": 269043, "author": "jfs", "author_id": 4279, "author_profile": "https://Stackoverflow.com/users/4279", "pm_score": 3, "selected": true, "text": "for arr in mydict.values():\n for i, s in enumerate(arr):\n if s == 'example':\n arr[i] = 'someotherword'\n" }, { "answer_id": 270535, "author": "Brian", "author_id": 9493, "author_profile": "https://Stackoverflow.com/users/9493", "pm_score": 2, "selected": false, "text": "replacements = {'example' : 'someotherword'}\n\nnewdict = dict((k, [replacements.get(x,x) for x in v]) \n for (k,v) in mydict.iteritems())\n for l in mydict.values():\n l[:]=[replacements.get(x,x) for x in l]\n" }, { "answer_id": 271294, "author": "Ryan Ginstrom", "author_id": 10658, "author_profile": "https://Stackoverflow.com/users/10658", "pm_score": 1, "selected": false, "text": "for key, val in mydict.items():\n mydict[key] = [\"someotherword\" if x == \"example\" else x for x in val]\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35100/" ]
268,898
<h3>Duplicate:</h3> <blockquote> <p><a href="https://stackoverflow.com/questions/263945/what-happens-if-you-call-erase-on-a-map-element-while-iterating-from-begin-to-e">What happens if you call erase on a map element while iterating from begin to end</a></p> <p><a href="https://stackoverflow.com/questions/180516/how-to-filter-items-from-a-stdmap">How to filter items from a stdmap</a><br></p> </blockquote> <p>I have a map <code>map1&lt;string,vector&lt;string&gt;&gt;</code> i have a iterator for this map &quot;itr&quot;. i want to delete the entry from this map which is pointed by &quot;itr&quot;. i can use the function map1.erase(itr); after this line the iterator &quot;itr&quot; becomes invalid. as per my requirement in my project,the iterator must point to the next element. can any body help me regerding this thans in advance:) santhosh</p>
[ { "answer_id": 268964, "author": "Igor Semenov", "author_id": 11401, "author_profile": "https://Stackoverflow.com/users/11401", "pm_score": 2, "selected": false, "text": "map<...>::iterator tmp(iter++);\nmap1.erase(tmp);\n" }, { "answer_id": 268979, "author": "Leon Timmermans", "author_id": 4727, "author_profile": "https://Stackoverflow.com/users/4727", "pm_score": 0, "selected": false, "text": "#include <boost/next_prior.hpp>\n\nmap<string,vector<string> >::iterator next = boost::next(itr);\nmap1.erase(iter);\niter = next;\n" }, { "answer_id": 269061, "author": "Luc Touraille", "author_id": 20984, "author_profile": "https://Stackoverflow.com/users/20984", "pm_score": 3, "selected": false, "text": "myMap.erase(itr++)\n itr" }, { "answer_id": 269717, "author": "Martin York", "author_id": 14065, "author_profile": "https://Stackoverflow.com/users/14065", "pm_score": 1, "selected": false, "text": "map.erase(iter++); // Post increment. Increments iterator,\n // returns previous value for use in erase method\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
268,899
<p>Multistrings (double null-terminated string of null-separated strings) are common in the Windows API. What's a good method for converting a multistring returned from an API to a C# string collection and vice versa?</p> <p>I'm especially interested in proper handling of character encoding (Windows XP an later).</p> <p>The following method seems to be okay for creating a multistring, but I don't have an example of decoding a multistring.</p> <pre><code>static string StringArrayToMultiString( ICollection&lt;string&gt; stringArray ) { StringBuilder multiString = new StringBuilder(); if (stringArray != null) { foreach (string s in stringArray) { multiString.Append(s); multiString.Append('\0'); } } return multiString.ToString(); } </code></pre>
[ { "answer_id": 268944, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": false, "text": "static string[] MultiStringToArray(string multiString)\n{\n return multiString.TrimEnd('\\0').Split('\\0');\n}\n \\0 StringArrayToMultiString params string[] static string StringArrayToMultiString(params string[] values)\n{\n if (values == null) throw new ArgumentNullException(\"values\");\n StringBuilder multiString = new StringBuilder();\n\n foreach (string s in values)\n {\n multiString.Append(s);\n multiString.Append('\\0');\n }\n return multiString.ToString();\n}\n" }, { "answer_id": 269441, "author": "k...m", "author_id": 35090, "author_profile": "https://Stackoverflow.com/users/35090", "pm_score": 2, "selected": false, "text": "[DllImport(\"winscard.dll\", CharSet = CharSet.Auto)]\nstatic extern int SCardListReaders(\n IntPtr context,\n string groups,\n char[] readers,\n ref uint readersLen\n );\n static string[] MultiStringToArray(\n char[] multistring\n )\n{\n List<string> stringList = new List<string>();\n int i = 0;\n while (i < multistring.Length)\n {\n int j = i;\n if (multistring[j++] == '\\0') break;\n while (j < multistring.Length)\n {\n if (multistring[j++] == '\\0')\n {\n stringList.Add(new string(multistring, i, j - i - 1));\n i = j;\n break;\n }\n }\n }\n\n return stringList.ToArray();\n}\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35090/" ]
268,902
<p>I have a few links that should all open in the same window or tab. To accomplish this I've given the window a name like in this example code:</p> <pre><code>&lt;a href="#" onClick='window.open("http://somesite.com", "mywindow", "");'&gt;link 1&lt;/a&gt; &lt;a href="#" onClick='window.open("http://someothersite.com", "mywindow", "");'&gt;link 2&lt;/a&gt; </code></pre> <p>This works OK in internet explorer, but firefox always opens a new tab/window. Any ideas? </p>
[ { "answer_id": 269039, "author": "Diodeus - James MacFarlane", "author_id": 12579, "author_profile": "https://Stackoverflow.com/users/12579", "pm_score": 3, "selected": false, "text": "<a href=\"#\" onClick='window.open(\"http://somesite.com\", \"mywindow\", \"width=700\", \"height=500\");'>link 1</a>\n" }, { "answer_id": 269731, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 4, "selected": false, "text": "var WindowObjectReference = window.open(strUrl, \n strWindowName [, strWindowFeatures]); \n <a href=\"http://google.com\" \n onclick=\"window.open( this.href, 'windowName' ); return false\" >\n Text\n </a>\n onclick FALSE <a href=\"google.com\" rel=\"external\" >Text</a>\n <script type=\"text/javascript\">\n jQuery(function($){ \n $(\"a[rel*=external]\").click(function(){ \n window.open(this.href, 'newWindowName' ); \n return false; \n });\n }); \n </script>\n" }, { "answer_id": 1080492, "author": "Spidey", "author_id": 131326, "author_profile": "https://Stackoverflow.com/users/131326", "pm_score": 2, "selected": false, "text": "<a href=\"http://www.google.com\" target=\"my_window_tab_frame_or_iframe\">Link</a>" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24046/" ]
268,920
<p>We have a decent sized object-oriented application. Whenever an object in the app is changed, the object changes are saved back to the DB. However, this has become less than ideal.</p> <p>Currently, transactions are stored as a transaction and a set of transactionLI's.</p> <p>The transaction table has fields for who, what, when, why, foreignKey, and foreignTable. The first four are self-explanatory. ForeignKey and foreignTable are used to determine which object changed.</p> <p>TransactionLI has timestamp, key, val, oldVal, and a transactionID. This is basically a key/value/oldValue storage system.</p> <p>The problem is that these two tables are used for every object in the application, so they're pretty big tables now. Using them for anything is slow. Indexes only help so much.</p> <p>So we're thinking about other ways to do something like this. Things we've considered so far: - Sharding these tables by something like the timestamp. - Denormalizing the two tables and merge them into one. - A combination of the two above. - Doing something along the lines of serializing each object after a change and storing it in subversion. - Probably something else, but I can't think of it right now.</p> <p>The whole problem is that we'd like to have some mechanism for properly storing and searching through transactional data. Yeah you can force feed that into a relational database, but really, it's transactional data and should be stored accordingly.</p> <p>What is everyone else doing?</p>
[ { "answer_id": 269008, "author": "JoshBerke", "author_id": 26160, "author_profile": "https://Stackoverflow.com/users/26160", "pm_score": 0, "selected": false, "text": "<objectDiff>\n<field name=\"firstName\" newValue=\"Josh\" oldValue=\"joshua\"/>\n<field name=\"lastName\" newValue=\"Box\" oldValue=\"boxer\"/>\n</objectDiff>\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35101/" ]
268,923
<p>I'm building an application using the Supervising Controller pattern (Model View Presenter) and I am facing a difficulty. In my page I have a repeater control that will display each item of a collection I am passing to it. The reapeater item contains 2 dropdown list that allow the user to select a particular value. When I click the next button, I want the controller to retrieve those values. </p> <p>How can I do that I a clean way? </p>
[ { "answer_id": 1152483, "author": "Berryl", "author_id": 95245, "author_profile": "https://Stackoverflow.com/users/95245", "pm_score": 3, "selected": true, "text": "public interface ITextWidget\n{\n event EventHandler TextChanged;\n string Text { get; set; }\n}\n\npublic abstract class TextWidget<T> : ITextWidget\n{\n\n protected T _wrappedWidget { get; set; }\n public event EventHandler TextChanged;\n\n protected void InvokeTextChanged(object sender, EventArgs e)\n {\n var textChanged = TextChanged;\n if (textChanged != null) textChanged(this, e);\n }\n\n public abstract string Text { get; set; }\n}\n public class TextBoxWidget : TextWidget<TextBox>\n{\n\n public TextBoxWidget(TextBox textBox)\n {\n textBox.TextChanged += InvokeTextChanged;\n _wrappedWidget = textBox;\n }\n\n public override string Text\n {\n get { return _wrappedWidget.Text; }\n set { _wrappedWidget.Text = value; }\n }\n}\n public partial class ProjectPickerForm : Form, IProjectPickerView\n{\n\n private IProjectPickerPresenter _presenter;\n public void InitializePresenter(IProjectPickerPresenter presenter) {\n _presenter = presenter;\n _presenter.InitializeWidgets(\n ...\n new TextBoxWidget(txtDescription));\n }\n ...\n}\n public class ProjectPickerPresenter : IProjectPickerPresenter\n{\n ...\n public void InitializeWidgets(ITextWidget descriptionFilter) {\n\n Check.RequireNotNull<ITextWidget>(descriptionFilter, \"descriptionFilter\");\n DescriptionFilter = descriptionFilter;\n DescriptionFilter.Text = string.Empty;\n DescriptionFilter.TextChanged += OnDescriptionTextChanged;\n\n }\n ...\n\n public void OnDescriptionTextChanged(object sender, EventArgs e) {\n FilterService.DescriptionFilterValue = DescriptionFilter.Text;\n }\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/201997/" ]
268,929
<p>I have two Java classes: B, which extends another class A, as follows :</p> <pre><code>class A { public void myMethod() { /* ... */ } } class B extends A { public void myMethod() { /* Another code */ } } </code></pre> <p>I would like to call the <code>A.myMethod()</code> from <code>B.myMethod()</code>. I am coming from the <a href="https://stackoverflow.com/questions/357307/how-to-call-a-parent-class-function-from-derived-class-function">C++ world</a>, and I don't know how to do this basic thing in Java.</p>
[ { "answer_id": 268939, "author": "unwind", "author_id": 28169, "author_profile": "https://Stackoverflow.com/users/28169", "pm_score": 8, "selected": true, "text": "super" }, { "answer_id": 268940, "author": "Robin", "author_id": 21925, "author_profile": "https://Stackoverflow.com/users/21925", "pm_score": 7, "selected": false, "text": "public void myMethod()\n{\n // B stuff\n super.myMethod();\n // B stuff\n}\n" }, { "answer_id": 268946, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": false, "text": "super.MyMethod() MyMethod() class B class A {\n public void myMethod() { /* ... */ }\n}\n\nclass B extends A {\n public void myMethod() { \n super.MyMethod();\n /* Another code */ \n }\n}\n" }, { "answer_id": 7427979, "author": "kinshuk4", "author_id": 3222727, "author_profile": "https://Stackoverflow.com/users/3222727", "pm_score": 2, "selected": false, "text": "super.baseMethod(params);\n" }, { "answer_id": 8134798, "author": "Yograj kingaonkar", "author_id": 1047310, "author_profile": "https://Stackoverflow.com/users/1047310", "pm_score": 4, "selected": false, "text": "super.Mymethod();\nsuper(); // calls base class Superclass constructor.\nsuper(parameter list); // calls base class parameterized constructor.\nsuper.method(); // calls base class method.\n" }, { "answer_id": 20717767, "author": "umanathan", "author_id": 3125035, "author_profile": "https://Stackoverflow.com/users/3125035", "pm_score": 2, "selected": false, "text": "// Using super keyword access parent class variable\nclass test {\n int is,xs;\n\n test(int i,int x) {\n is=i;\n xs=x;\n System.out.println(\"super class:\");\n }\n}\n\nclass demo extends test {\n int z;\n\n demo(int i,int x,int y) {\n super(i,x);\n z=y;\n System.out.println(\"re:\"+is);\n System.out.println(\"re:\"+xs);\n System.out.println(\"re:\"+z);\n }\n}\n\nclass free{\n public static void main(String ar[]){\n demo d=new demo(4,5,6);\n }\n}\n" }, { "answer_id": 20717843, "author": "umanathan", "author_id": 3125035, "author_profile": "https://Stackoverflow.com/users/3125035", "pm_score": 2, "selected": false, "text": "class test\n{\n void message()\n {\n System.out.println(\"super class\");\n }\n}\n\nclass demo extends test\n{\n int z;\n demo(int y)\n {\n super.message();\n z=y;\n System.out.println(\"re:\"+z);\n }\n}\nclass free{\n public static void main(String ar[]){\n demo d=new demo(6);\n }\n}\n" }, { "answer_id": 23112447, "author": "Gracjan Nawrot", "author_id": 3541651, "author_profile": "https://Stackoverflow.com/users/3541651", "pm_score": 3, "selected": false, "text": "class A\n{\n public void myMethod()\n { /* ... */ }\n}\n\nclass B extends A\n{\n public void myMethod()\n {\n super.myMethod(); // calling parent method\n }\n}\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268929", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26465/" ]
268,968
<p>Less than 10 client computers, each with their own installation have to upload data to a central server.</p> <p>The client database looks like:</p> <p>tblSales - rowGuid - randomNumber</p> <p>Central Server database:</p> <ul> <li>rowGuid</li> <li>randomNumber</li> <li>dateInserted</li> </ul> <p>I plan to use WCF to send the files to the central server.</p> <p><b>How can I verify the rows were inserted to the server? What kind of verification options do I have?</b></p> <p>I could return the # of rows inserted and compare that with the # that was sent, but is there any other more robust method?</p>
[ { "answer_id": 269011, "author": "GeekyMonkey", "author_id": 29900, "author_profile": "https://Stackoverflow.com/users/29900", "pm_score": 0, "selected": false, "text": "bool Success;\nSuccess = MyWCFService.InsertRecord(MyNewRecord);\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
268,982
<p>Please help!</p> <p><em>Background info</em></p> <p>I have a WPF application which accesses a SQL Server 2005 database. The database is running locally on the machine the application is running on.</p> <p>Everywhere I use the Linq DataContext I use a using { } statement, and pass in a result of a function which returns a SqlConnection object which has been opened and had an SqlCommand executed using it before returning to the DataContext constructor.. I.e.</p> <pre><code>// In the application code using (DataContext db = new DataContext(GetConnection())) { ... Code } </code></pre> <p>where getConnection looks like this (I've stripped out the 'fluff' from the function to make it more readable, but there is no additional functionality that is missing).</p> <pre><code>// Function which gets an opened connection which is given back to the DataContext constructor public static System.Data.SqlClient.SqlConnection GetConnection() { System.Data.SqlClient.SqlConnection Conn = new System.Data.SqlClient.SqlConnection(/* The connection string */); if ( Conn != null ) { try { Conn.Open(); } catch (System.Data.SqlClient.SqlException SDSCSEx) { /* Error Handling */ } using (System.Data.SqlClient.SqlCommand SetCmd = new System.Data.SqlClient.SqlCommand()) { SetCmd.Connection = Conn; SetCmd.CommandType = System.Data.CommandType.Text; string CurrentUserID = System.String.Empty; SetCmd.CommandText = "DECLARE @B VARBINARY(36); SET @B = CAST('" + CurrentUserID + "' AS VARBINARY(36)); SET CONTEXT_INFO @B"; try { SetCmd.ExecuteNonQuery(); } catch (System.Exception) { /* Error Handling */ } } return Conn; } </code></pre> <p><strong>I do not think that the application being a WPF one has any bearing on the issue I am having.</strong></p> <p><em>The issue I am having</em> </p> <p>Despite the SqlConnection being disposed along with the DataContext in Sql Server Management studio I can still see loads of open connections with :</p> <pre><code>status : 'Sleeping' command : 'AWAITING COMMAND' last SQL Transact Command Batch : DECLARE @B VARBINARY(36); SET @B = CAST('GUID' AS VARBINARY(36)); SET CONTEXT_INFO @B </code></pre> <p>Eventually the connection pool gets used up and the application can't continue. </p> <p>So I can only conclude that somehow running the SQLCommand to set the Context_Info is meaning that the connection doesn't get disposed of when the DataContext gets disposed. </p> <p>Can anyone spot anything obvious that would be stopping the connections from being closed and disposed of when the DataContext they are used by are disposed?</p>
[ { "answer_id": 268993, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 5, "selected": true, "text": "DataContext Constructor (IDbConnection) Dispose() protected override void Dispose(bool disposing)\n {\n if(disposing && this.Connection != null && this.Connection.State == ConnectionState.Open)\n {\n this.Connection.Close();\n this.Connection.Dispose();\n }\n base.Dispose(disposing);\n }\n using(var conn = GetConnection())\n{\n // snip: some stuff involving conn\n\n using(var ctx = new FooContext(conn))\n {\n // snip: some stuff involving ctx\n }\n\n // snip: some more stuff involving conn\n}\n" }, { "answer_id": 268995, "author": "Robert S.", "author_id": 7565, "author_profile": "https://Stackoverflow.com/users/7565", "pm_score": 0, "selected": false, "text": "Dispose GetContext()" }, { "answer_id": 268996, "author": "Bradley Grainger", "author_id": 23633, "author_profile": "https://Stackoverflow.com/users/23633", "pm_score": 3, "selected": false, "text": "SqlProvider DataContext SqlConnectionManager.DisposeConnection SqlConnection DataContext using (SqlConnection conn = GetConnection())\nusing (DataContext db = new DataContext(conn))\n{\n ... Code \n}\n" }, { "answer_id": 269139, "author": "Ash", "author_id": 31128, "author_profile": "https://Stackoverflow.com/users/31128", "pm_score": 1, "selected": false, "text": "// Variable for storing the connection passed to the constructor\nprivate System.Data.SqlClient.SqlConnection _Connection;\n\npublic DataContext(System.Data.SqlClient.SqlConnection Connection) : base(Connection)\n{\n // Only set the reference if the connection is Valid and Open during construction\n if (Connection != null)\n {\n if (Connection.State == System.Data.ConnectionState.Open)\n {\n _Connection = Connection; \n }\n } \n}\n\nprotected override void Dispose(bool disposing)\n{ \n // Only try closing the connection if it was opened during construction \n if (_Connection!= null)\n {\n _Connection.Close();\n _Connection.Dispose();\n }\n\n base.Dispose(disposing);\n}\n this.Connection" }, { "answer_id": 700316, "author": "Abhijeet Patel", "author_id": 84074, "author_profile": "https://Stackoverflow.com/users/84074", "pm_score": 2, "selected": false, "text": "ObjectContext using SaveChanges() using \"AWAITING COMMAND\" Open Close Open ClearAllPools ClearPool" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/268982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31128/" ]
269,005
<p>I'm trying to do a subselect in pgsql aka postgresql and the example I found doesn't work:</p> <pre><code>SELECT id FROM (SELECT * FROM table); </code></pre>
[ { "answer_id": 269033, "author": "cfeduke", "author_id": 5645, "author_profile": "https://Stackoverflow.com/users/5645", "pm_score": 1, "selected": false, "text": "SELECT * FROM table WHERE id IN (SELECT id FROM table2);\n SELECT id FROM table" }, { "answer_id": 269037, "author": "TravisO", "author_id": 35116, "author_profile": "https://Stackoverflow.com/users/35116", "pm_score": 3, "selected": true, "text": "SELECT id FROM (SELECT * FROM table) AS aliasname;\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35116/" ]
269,009
<p>I've been researching modules for Nginx (my preferred webserver) to serve a Lisp webapp, but I haven't been able to find anything.</p> <p>Is there modules for Nginx, or is there better ways to serve Lisp webapps? If so, what are they?</p>
[ { "answer_id": 21647266, "author": "sçuçu", "author_id": 2605049, "author_profile": "https://Stackoverflow.com/users/2605049", "pm_score": 0, "selected": false, "text": "upstream hunchentoot { server 127.0.0.1:5050; }\n location {} if (!-f $request_filename) {\n\nproxy_pass http://hunchentoot;\n}\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1555170/" ]
269,010
<p>I have created a proc that grabs all the user tables in a local DB on my machine. I want to be able to create a flat file of all my tables using BCP and SQL. Its a dummy database in SQL 2000 connecting through windows authentication. I have set my enviroment path variable in WinXP SP2. I have created new users to access the db, switched off my firewall, using trusted connection. I have tried dozens of forums, no luck. </p> <p>In dos command prompt I get the same error. </p> <p>SQLState = 37000, NativeError = 4060 Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database requested in login '[HelpDesk-EasyPay'. Login fails.</p> <p>Here is my SP: </p> <pre><code>@Path VARCHAR(100), @UserName VARCHAR(15), @PassWord VARCHAR(15), @ServerName VARCHAR(15) AS set quoted_identifier off set nocount on declare @n int declare @db varchar(40) set @db=DB_NAME() declare @TableName varchar(15) declare @bcp varchar(200) select identity(int,1,1) as tblNo,name tblname into #T from Sysobjects where xtype='u' select @n=COUNT(*) from #T WHILE (@n&gt;0) BEGIN SELECT @TableName=tblname FROM #T WHERE tblno=@n PRINT 'Now BCP out for table: ' + @TableName SET @bcp = "master..xp_cmdshell 'BCP " + "[" + @db + ".." + @TableName + "]" + " OUT" + @Path + "" + @TableName+".txt -c -U" + @UserName + " -P" + @PassWord + " -S" + @ServerName + " -T" + "'" EXEC(@bcp) SET @n=@n-1 END DROP TABLE #T </code></pre> <p>Can anyone advise. This seems to be a connection problem or BCP ? Not sure. </p> <p>edit: I am running this from query analyzer because I have 118 tables to output to flat file. I seem to agree that its an authentication issue because I tried connecting to master db with username sa password root. which is what its set to and I get the same error: SQLState = 37000, NativeError = 4060</p>
[ { "answer_id": 272094, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 1, "selected": false, "text": "bcp [HelpDesk-EasyPay].dbo.[customer] out d:\\MSSQL\\Data\\customer.bcp -N -Utest -Ptest -T\n SET @bcp = \"master..xp_cmdshell 'BCP \" + \"[\" + @db + \"]..[\" + @TableName + \"]\" + \" OUT\" + @Path + \"\" + @TableName+\".txt -c -U\" + @UserName + \" -P\" + @PassWord + \" -S\" + @ServerName + \" -T\" + \"'\" \n" }, { "answer_id": 1613510, "author": "podosta", "author_id": 103585, "author_profile": "https://Stackoverflow.com/users/103585", "pm_score": 0, "selected": false, "text": "SET @s = 'BCP \"SELECT * FROM [HelpDesk-EasyPay].dbo.customers\" QUERYOUT myfile.txt ...'\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35109/" ]
269,017
<p>So here is the simple code:</p> <pre><code> [System.ComponentModel.DefaultValue(true)] public bool AnyValue { get; set; } </code></pre> <p>I am sure I don't set AnyValue to false again (I just created it). This property is a property of a Page class of ASP.NET. And I am cheking the value in a button event handling function. But somehow it is still false. I wonder when actually it is set true? On compile time? When class is instantiated?</p> <p>What do you think about what I am doing wrong?</p>
[ { "answer_id": 269089, "author": "yusuf", "author_id": 35012, "author_profile": "https://Stackoverflow.com/users/35012", "pm_score": 0, "selected": false, "text": " private bool myVal = true;\n public bool MyVal\n {\n get { return myVal; } \n set { myVal = value; }\n }\n" }, { "answer_id": 270502, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 0, "selected": false, "text": "PropertyGrid [DefaultValue] XmlSerializer DataContractSerializer bool ShouldSerialize{Name}()" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35012/" ]
269,026
<p>How can I document a member inline in .Net? Let me explain. Most tools that extract documentation from comments support some kind of inline documentation where you can add a brief after the member declaration. Something like:</p> <pre><code>public static string MyField; /// &lt;summary&gt;Information about MyField.&lt;/summary&gt; </code></pre> <p>Is there a way to do this in C# or the .NET languages?</p>
[ { "answer_id": 269038, "author": "GeekyMonkey", "author_id": 29900, "author_profile": "https://Stackoverflow.com/users/29900", "pm_score": 1, "selected": false, "text": "/// <summary>Information about MyField.</summary>\npublic static string MyField; \n" }, { "answer_id": 269055, "author": "Robert S.", "author_id": 7565, "author_profile": "https://Stackoverflow.com/users/7565", "pm_score": 2, "selected": false, "text": "<summary />" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269026", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10688/" ]
269,042
<p>I´ve been looking for it yet in stackoverflow without success...</p> <p>Is it posible a connection pooling in asp.net? Is it worthwhile? How?</p>
[ { "answer_id": 269056, "author": "Dillie-O", "author_id": 71, "author_profile": "https://Stackoverflow.com/users/71", "pm_score": 3, "selected": true, "text": "Min Pool Size=5; Max Pool Size=60; Connect Timeout=300;\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269042", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34432/" ]
269,044
<p><strong>Background:</strong> I have an HTML page which lets you expand certain content. As only small portions of the page need to be loaded for such an expansion, it's done via JavaScript, and not by directing to a new URL/ HTML page. However, as a bonus the user is able to permalink to such expanded sections, i.e. send someone else a URL like</p> <p><em><a href="http://example.com/#foobar" rel="noreferrer">http://example.com/#foobar</a></em></p> <p>and have the "foobar" category be opened immediately for that other user. This works using parent.location.hash = 'foobar', so that part is fine.</p> <p><strong>Now the question:</strong> When the user closes such a category on the page, I want to empty the URL fragment again, i.e. turn <a href="http://example.com/#foobar" rel="noreferrer">http://example.com/#foobar</a> into <a href="http://example.com/" rel="noreferrer">http://example.com/</a> to update the permalink display. However, doing so using <code>parent.location.hash = ''</code> causes a reload of the whole page (in Firefox 3, for instance), which I'd like to avoid. Using <code>window.location.href = '/#'</code> won't trigger a page reload, but leaves the somewhat unpretty-looking "#" sign in the URL. So is there a way in popular browsers to JavaScript-remove a URL anchor including the "#" sign without triggering a page refresh?</p>
[ { "answer_id": 269118, "author": "Florin", "author_id": 34565, "author_profile": "https://Stackoverflow.com/users/34565", "pm_score": -1, "selected": false, "text": "$(document).ready(function() {\n $(\".lnk\").click(function(e) {\n e.preventDefault();\n $(this).attr(\"href\", \"stripped_url_via_desired_regex\");\n });\n });\n" }, { "answer_id": 1138931, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": -1, "selected": false, "text": "parent.location.hash = '' window.location.href=window.location.href.slice(0, -1);\n" }, { "answer_id": 4602517, "author": "jazkat", "author_id": 318380, "author_profile": "https://Stackoverflow.com/users/318380", "pm_score": 1, "selected": false, "text": "javascript: void(0); <a href=\"javascript:void(0);\" class=\"open_div\">Open Div</a>" }, { "answer_id": 4619108, "author": "Chris Boyle", "author_id": 6540, "author_profile": "https://Stackoverflow.com/users/6540", "pm_score": 2, "selected": false, "text": "window.history.pushState replaceState" }, { "answer_id": 13824103, "author": "Matmas", "author_id": 682025, "author_profile": "https://Stackoverflow.com/users/682025", "pm_score": 7, "selected": true, "text": "// remove fragment as much as it can go without adding an entry in browser history:\nwindow.location.replace(\"#\");\n\n// slice off the remaining '#' in HTML5: \nif (typeof window.history.replaceState == 'function') {\n history.replaceState({}, '', window.location.href.slice(0, -1));\n}\n" }, { "answer_id": 34660797, "author": "Manigandan Raamanathan", "author_id": 5758712, "author_profile": "https://Stackoverflow.com/users/5758712", "pm_score": 2, "selected": false, "text": "<script type=\"text/javascript\">\n var uri = window.location.toString();\n if (uri.indexOf(\"?\") > 0) {\n var clean_uri = uri.substring(0, uri.indexOf(\"?\"));\n window.history.replaceState({}, document.title, clean_uri);\n }\n</script>\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34170/" ]
269,046
<p>I have an MSI file that I have created using a Visual Studio Setup Project. The installed generates an .InstallState file in the application directory. Is there a way to have this file generated in a different location rather than the default location?</p>
[ { "answer_id": 1943145, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "private string GetInstallStatePath(string assemblyPath)\n{\n string str2 = base.Context.Parameters[\"InstallStateDir\"];\n assemblyPath = Path.ChangeExtension(assemblyPath, \".InstallState\");\n if (!string.IsNullOrEmpty(str2))\n {\n return Path.Combine(str2, Path.GetFileName(assemblyPath));\n }\n return assemblyPath;\n}\n Context[\"InstallStateDir\"] Uninstall AssemblyInstaller.GetInstallStatePath" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/324/" ]
269,050
<p>I'm writing code on the master page, and I need to know which child (content) page is being displayed. How can I do this programmatically? </p>
[ { "answer_id": 269091, "author": "spilliton", "author_id": 21367, "author_profile": "https://Stackoverflow.com/users/21367", "pm_score": 0, "selected": false, "text": "this.Request.Url.AbsolutePath\n" }, { "answer_id": 269167, "author": "Kon", "author_id": 22303, "author_profile": "https://Stackoverflow.com/users/22303", "pm_score": -1, "selected": false, "text": "// Assuming MyPage1, MyPage2, and MyPage3 are the class names in your aspx.cs files:\n\nif (this.Page is MyPage1)\n{\n // do MyPage1 specific stuff\n}\nelse if (this.Page is MyPage2)\n{\n // do MyPage2 specific stuff\n}\nelse if (this.Page is MyPage3)\n{\n // do MyPage3 specific stuff\n}\n" }, { "answer_id": 269329, "author": "Norbert B.", "author_id": 2605840, "author_profile": "https://Stackoverflow.com/users/2605840", "pm_score": 5, "selected": false, "text": "ContentPage MasterPage ContentPage Master MasterPage Child MasterPage Master ContentPage //Page_Load\nMyMaster m = (MyMaster)this.Master;\n\nm.TellMasterWhoIAm(this);\n" }, { "answer_id": 3215399, "author": "Todd H.", "author_id": 348126, "author_profile": "https://Stackoverflow.com/users/348126", "pm_score": 5, "selected": false, "text": "string pageName = this.ContentPlaceHolder1.Page.GetType().FullName;\n" }, { "answer_id": 3547532, "author": "WraithNath", "author_id": 428404, "author_profile": "https://Stackoverflow.com/users/428404", "pm_score": 3, "selected": false, "text": " //Only show the message if on the dashboard (first page after login)\n if (this.ContentPlaceHolder1.Page is Dashboard)\n {\n //Show modal message box\n mmb.Show(\"Warning Message\");\n }\n" }, { "answer_id": 15656628, "author": "Emad Mokhtar", "author_id": 373051, "author_profile": "https://Stackoverflow.com/users/373051", "pm_score": 0, "selected": false, "text": "string pageName = this.Request.Url.Segments.Last(); \n\nif (pageName.Contains(\"EmployeeTermination.aspx\"))\n{\n\n}\n" }, { "answer_id": 17525885, "author": "Sarim Shekhani", "author_id": 1178073, "author_profile": "https://Stackoverflow.com/users/1178073", "pm_score": 3, "selected": false, "text": "Page.ToString().Replace(\"ASP.\",\"\").Replace(\"_\",\".\")\n" }, { "answer_id": 19357664, "author": "sebprime", "author_id": 2878362, "author_profile": "https://Stackoverflow.com/users/2878362", "pm_score": 0, "selected": false, "text": "\n<%: this.ContentPlaceHolder1.Page.GetType().Name.Split('_')[0].ToUpper() %>\n title Site.Master" }, { "answer_id": 22629002, "author": "Challa Jyothi", "author_id": 3300256, "author_profile": "https://Stackoverflow.com/users/3300256", "pm_score": 1, "selected": false, "text": "Request.CurrentExecutionFilePath;\n Request.AppRelativeCurrentExecutionFilePath;\n" }, { "answer_id": 30168752, "author": "Shadi Alnamrouti", "author_id": 3380497, "author_profile": "https://Stackoverflow.com/users/3380497", "pm_score": 0, "selected": false, "text": "string s = Page.ToString().Replace(\"ASP.directory_name_\",\"\").Replace(\"_aspx\",\".aspx\").Replace(\"_\",\"-\");\n if (s == \"default.aspx\")\n { /* do something */ }\n" }, { "answer_id": 31717963, "author": "SHS", "author_id": 1270388, "author_profile": "https://Stackoverflow.com/users/1270388", "pm_score": 2, "selected": false, "text": "if (Page.TemplateControl.AppRelativeVirtualPath == \"~/YourPageName.aspx\")\n{\n // your code here\n}\n if (Page.TemplateControl.AppRelativeVirtualPath.Equals(\"~/YourPageName.aspx\", StringComparison.OrdinalIgnoreCase))\n{\n // your code here\n}\n" }, { "answer_id": 36744137, "author": "Vinez", "author_id": 4704261, "author_profile": "https://Stackoverflow.com/users/4704261", "pm_score": 0, "selected": false, "text": "<%if(this.MainContent.Page.Title != \"mypagetitle\") { %>\n<%}%>\n" }, { "answer_id": 47466970, "author": "sandip shaw", "author_id": 8989825, "author_profile": "https://Stackoverflow.com/users/8989825", "pm_score": 0, "selected": false, "text": "string PName = Request.UrlReferrer.Segments[Request.UrlReferrer.Segments.Length - 1];\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269050", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1316/" ]
269,053
<p>I have a program that runs osql.exe from microsoft sql server tools directory and runs a script. </p> <p>The problem is that on computers that don't have an installation of sql server, this tool is missing. So my question is whether or not is possible to run it as a standalone( along with any dll that may be required ) meaning that run them from Process.Start from a local directory of the application.</p>
[ { "answer_id": 269064, "author": "kͩeͣmͮpͥ ͩ", "author_id": 26479, "author_profile": "https://Stackoverflow.com/users/26479", "pm_score": 0, "selected": false, "text": "Server.ConnectionContext.ExecuteNonQuery GO" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17443/" ]
269,058
<p>Lets say I have an array like this:</p> <pre><code>string [] Filelist = ... </code></pre> <p>I want to create an Linq result where each entry has it's position in the array like this:</p> <pre><code>var list = from f in Filelist select new { Index = (something), Filename = f}; </code></pre> <p>Index to be 0 for the 1st item, 1 for the 2nd, etc.</p> <p>What should I use for the expression Index= ?</p>
[ { "answer_id": 269070, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 8, "selected": true, "text": "Select var list = FileList.Select((file, index) => new { Index=index, Filename=file });\n" }, { "answer_id": 269109, "author": "GeekyMonkey", "author_id": 29900, "author_profile": "https://Stackoverflow.com/users/29900", "pm_score": 2, "selected": false, "text": "string[] values = { \"a\", \"b\", \"c\" };\nint i = 0;\nvar t = (from v in values\nselect new { Index = i++, Value = v}).ToList();\n" }, { "answer_id": 50042465, "author": "Artemious", "author_id": 1830814, "author_profile": "https://Stackoverflow.com/users/1830814", "pm_score": 1, "selected": false, "text": "from.. where.. select.. .Select(item, index) var newestExistingFilesWithIndexes = \n (from f in Filelist\n // we love LINQ query expressions\n where f.Exists\n // and we use it anywhere possible\n orderby f.LastModified descending\n select f)\n // but sometimes we have to get out and use LINQ extension methods\n .Select((f, index) => new { Index = index, Filename = f.Fullname});\n var newestExistingFilesOnlyEvenIndexes = \n // use the Select method overload to get the index\n (from f in Filelist.Select((file, index) => new { file, index })\n // only take item with an even index\n where f.index % 2 == 0\n where f.file.Exists\n orderby f.file.LastModified descending\n select f.file);\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28260/" ]
269,060
<p>I'm writing some mail-processing software in Python that is encountering strange bytes in header fields. I suspect this is just malformed mail; the message itself claims to be us-ascii, so I don't think there is a true encoding, but I'd like to get out a unicode string approximating the original one without throwing a <code>UnicodeDecodeError</code>.</p> <p>So, I'm looking for a function that takes a <code>str</code> and optionally some hints and does its darndest to give me back a <code>unicode</code>. I could write one of course, but if such a function exists its author has probably thought a bit deeper about the best way to go about this.</p> <p>I also know that Python's design prefers explicit to implicit and that the standard library is designed to avoid implicit magic in decoding text. I just want to explicitly say "go ahead and guess".</p>
[ { "answer_id": 269276, "author": "jfs", "author_id": 4279, "author_profile": "https://Stackoverflow.com/users/4279", "pm_score": 5, "selected": false, "text": "@insin $ pip install chardet\n >>> import chardet\n>>> import urllib\n>>> detect = lambda url: chardet.detect(urllib.urlopen(url).read())\n>>> detect('http://stackoverflow.com')\n{'confidence': 0.85663169917190185, 'encoding': 'ISO-8859-2'} \n>>> detect('https://stackoverflow.com/questions/269060/is-there-a-python-lib')\n{'confidence': 0.98999999999999999, 'encoding': 'utf-8'}\n" }, { "answer_id": 273631, "author": "Nick", "author_id": 5222, "author_profile": "https://Stackoverflow.com/users/5222", "pm_score": 5, "selected": true, "text": "def decode(s, encodings=('ascii', 'utf8', 'latin1')):\n for encoding in encodings:\n try:\n return s.decode(encoding)\n except UnicodeDecodeError:\n pass\n return s.decode('ascii', 'ignore')\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5222/" ]
269,062
<p>I want to use LabVIEW's Call Library Function Node to access a DLL function, and have this function return a string to displayed on my VI. How would I go about doing this? I am quite happy returning numbers from my DLL, but am really struggling to find any examples of how to return a string.</p>
[ { "answer_id": 269608, "author": "Azim J", "author_id": 4612, "author_profile": "https://Stackoverflow.com/users/4612", "pm_score": 3, "selected": true, "text": "void returnString(char myString[])\n{\n const char *aString = \"test string\";\n memcpy(myString, aString, 12);\n}\n CStr returnString()\n{ ...\n }\n" }, { "answer_id": 271309, "author": "bk1e", "author_id": 8090, "author_profile": "https://Stackoverflow.com/users/8090", "pm_score": 2, "selected": false, "text": "examples/dll/regexpr/Regular Expression Solution/VIs/Get Error String.vi examples/dll/hostname/hostname.vi" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1555/" ]
269,063
<p>After moving a project from .NET 1.1 to .NET 2.0, MsBuild emits lots of warnings for some COM objects.</p> <p>Sample code for test (actual code doesn't matter, just used to create the warnings):</p> <pre><code>using System; using System.DirectoryServices; using ActiveDs; namespace Test { public class Class1 { public static void Main(string[] args) { string adsPath = String.Format("WinNT://{0}/{1}", args[0], args[1]); DirectoryEntry localuser = new DirectoryEntry(adsPath); IADsUser pUser = (IADsUser) localuser.NativeObject; Console.WriteLine("User = {0}", pUser.ADsPath); } } } </code></pre> <p>Warning messages look like</p> <p><em>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets : warning : At least one of the arguments for 'ITypeLib.RemoteGetLibAttr' cannot be marshaled by the runtime marshaler. Such arguments will therefore be passed as a pointer and may require unsafe code to manipulate.</em></p> <p>Observations:</p> <ul> <li>Happens for ActiveDs (11 warnings) and MSXML2 (54 warnings).</li> <li>Not seen for our own COM objects.</li> <li><code>&lt;Reference&gt;</code> entry in .csproj file contains attribute <code>WrapperTool = "tlbimp"</code></li> <li>Despite of all warnings, no problems have been observed in the running system.</li> </ul> <p>Any idea how to get rid of the warnings?</p>
[ { "answer_id": 1402834, "author": "Tony Lee", "author_id": 5819, "author_profile": "https://Stackoverflow.com/users/5819", "pm_score": 4, "selected": true, "text": " tlbimp c:\\WINNT\\system32\\activeds.tlb /out:interop.activeds.dll\n tlbimp c:\\WINNT\\system32\\activeds.tlb /silent /out:interop.activeds.dll\n \"$(DevEnvDir)\\..\\..\\SDK\\v2.0\\bin\\tlbimp\" c:\\WINNT\\system32\\activeds.tlb\n /namespace:ActiveDs /silent /out:\"$(ProjectDir)interop.activeds.dll\"\n" }, { "answer_id": 33213457, "author": "Hermann.Gruber", "author_id": 2792414, "author_profile": "https://Stackoverflow.com/users/2792414", "pm_score": 4, "selected": false, "text": "<ResolveComReferenceSilent>True</ResolveComReferenceSilent>\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23772/" ]
269,073
<p>Is there a collection (BCL or other) that has the following characteristics:</p> <p>Sends event if collection is changed AND sends event if any of the elements in the collection sends a <code>PropertyChanged</code> event. Sort of an <code>ObservableCollection&lt;T&gt;</code> where <code>T: INotifyPropertyChanged</code> and the collection is also monitoring the elements for changes. </p> <p>I could wrap an observable collection my self and do the event subscribe/unsubscribe when elements in the collection are added/removed but I was just wondering if any existing collections did this already?</p>
[ { "answer_id": 269113, "author": "soren.enemaerke", "author_id": 9222, "author_profile": "https://Stackoverflow.com/users/9222", "pm_score": 6, "selected": true, "text": "public class ObservableCollectionEx<T> : ObservableCollection<T> where T : INotifyPropertyChanged\n{\n protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)\n {\n Unsubscribe(e.OldItems);\n Subscribe(e.NewItems);\n base.OnCollectionChanged(e);\n }\n\n protected override void ClearItems()\n {\n foreach(T element in this)\n element.PropertyChanged -= ContainedElementChanged;\n\n base.ClearItems();\n }\n\n private void Subscribe(IList iList)\n {\n if (iList != null)\n {\n foreach (T element in iList)\n element.PropertyChanged += ContainedElementChanged;\n }\n }\n\n private void Unsubscribe(IList iList)\n {\n if (iList != null)\n {\n foreach (T element in iList)\n element.PropertyChanged -= ContainedElementChanged;\n }\n }\n\n private void ContainedElementChanged(object sender, PropertyChangedEventArgs e)\n {\n OnPropertyChanged(e);\n }\n}\n ObservableCollectionEx<Element> collection = new ObservableCollectionEx<Element>();\n((INotifyPropertyChanged)collection).PropertyChanged += (x,y) => ReactToChange();\n // work on original instance\n ObservableCollection<TestObject> col = new ObservableCollectionEx<TestObject>();\n ((INotifyPropertyChanged)col).PropertyChanged += (s, e) => { Trace.WriteLine(\"Changed \" + e.PropertyName); };\n\n var test = new TestObject();\n col.Add(test); // no event raised\n test.Info = \"NewValue\"; //Info property changed raised\n\n // working on explicit instance\n ObservableCollectionEx<TestObject> col = new ObservableCollectionEx<TestObject>();\n col.PropertyChanged += (s, e) => { Trace.WriteLine(\"Changed \" + e.PropertyName); };\n\n var test = new TestObject();\n col.Add(test); // Count and Item [] property changed raised\n test.Info = \"NewValue\"; //no event raised\n" }, { "answer_id": 269283, "author": "Todd White", "author_id": 30833, "author_profile": "https://Stackoverflow.com/users/30833", "pm_score": 2, "selected": false, "text": "public partial class Window1 : Window\n{\n public Window1()\n {\n InitializeComponent();\n\n FreezableCollection<SolidColorBrush> collection = new FreezableCollection<SolidColorBrush>();\n collection.Changed += collection_Changed;\n SolidColorBrush brush = new SolidColorBrush(Colors.Red);\n collection.Add(brush);\n brush.Color = Colors.Blue;\n }\n\n private void collection_Changed(object sender, EventArgs e)\n {\n }\n}\n" }, { "answer_id": 3316435, "author": "Mark Whitfeld", "author_id": 311292, "author_profile": "https://Stackoverflow.com/users/311292", "pm_score": 3, "selected": false, "text": "element.PropertyChanged += ContainedElementChanged;\n element.PropertyChanged -= ContainedElementChanged;\n private void ContainedElementChanged(object sender, PropertyChangedEventArgs e)\n" }, { "answer_id": 8024284, "author": "Lukas Cenovsky", "author_id": 138803, "author_profile": "https://Stackoverflow.com/users/138803", "pm_score": 1, "selected": false, "text": "ReactiveCollection reactiveCollection.Changed.Subscribe(_ => ...);\n" }, { "answer_id": 15169241, "author": "Ovi", "author_id": 7233, "author_profile": "https://Stackoverflow.com/users/7233", "pm_score": 0, "selected": false, "text": "PropertyChanged PropertyChanged col.PropertyChanged += (s, e) => { Trace.WriteLine(\"Changed \" + e.PropertyName)\n PropertyChangedEventArgsEx ContainedElementChanged public class PropertyChangedEventArgsEx : PropertyChangedEventArgs\n{\n public object Sender { get; private set; }\n\n public PropertyChangedEventArgsEx(string propertyName, object sender) \n : base(propertyName)\n {\n this.Sender = sender;\n }\n}\n private void ContainedElementChanged(object sender, PropertyChangedEventArgs e)\n {\n var ex = new PropertyChangedEventArgsEx(e.PropertyName, sender);\n OnPropertyChanged(ex);\n }\n Sender col.PropertyChanged += (s, e) e PropertyChangedEventArgsEx ((INotifyPropertyChanged)col).PropertyChanged += (s, e) =>\n {\n var argsEx = (PropertyChangedEventArgsEx)e;\n Trace.WriteLine(argsEx.Sender.ToString());\n };\n s Sender PropertyChangedEventArgsEx" }, { "answer_id": 25675556, "author": "Dave Sexton", "author_id": 3970148, "author_profile": "https://Stackoverflow.com/users/3970148", "pm_score": 0, "selected": false, "text": "ObservableCollection<T> ObservableCollection<MyClass> collection = ...;\n\nvar changes = collection.AsCollectionNotifications<MyClass>();\nvar itemChanges = changes.PropertyChanges();\nvar deepItemChanges = changes.PropertyChanges(\n item => item.ChildItems.AsCollectionNotifications<MyChildClass>());\n MyClass MyChildClass" }, { "answer_id": 48674119, "author": "Scott Chamberlain", "author_id": 80274, "author_profile": "https://Stackoverflow.com/users/80274", "pm_score": 0, "selected": false, "text": "using System.ComponentModel;\npublic class Example\n{\n BindingList<Foo> _collection;\n\n public Example()\n {\n _collection = new BindingList<Foo>();\n _collection.ListChanged += Collection_ListChanged;\n }\n\n void Collection_ListChanged(object sender, ListChangedEventArgs e)\n {\n MessageBox.Show(e.ListChangedType.ToString());\n }\n\n}\n ListChanged INotifyPropertyChanged" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9222/" ]
269,081
<pre><code>template &lt;class M, class A&gt; class C { std::list&lt;M&gt; m_List; ... } </code></pre> <p>Is the above code possible? I would like to be able to do something similar.</p> <p>Why I ask is that i get the following error:</p> <pre><code>Error 1 error C2079: 'std::_List_nod&lt;_Ty,_Alloc&gt;::_Node::_Myval' uses undefined class 'M' C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list 41 </code></pre>
[ { "answer_id": 269206, "author": "xtofl", "author_id": 6610, "author_profile": "https://Stackoverflow.com/users/6610", "pm_score": 3, "selected": true, "text": "// template definition file\n#include <list>\n\ntemplate< class aM, class aT >\nclass C {\n std::list<M> m_List;\n ...\n};\n // bad template usage file causing the aforementioned error\nclass M;\n...\nC<M,OtherClass> c; // this would result in your error\n\nclass M { double data; };\n // better template usage file\nclass M { double data; }; // or #include the class header\n...\n\nC<M,OtherClass> c; // this would have to compile\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23528/" ]
269,093
<p>I've a terrible memory. Whenever I do a CONNECT BY query in Oracle - and I do mean <em>every</em> time - I have to think hard and usually through trial and error work out on which argument the PRIOR should go.</p> <p>I don't know why I don't remember - but I don't.</p> <p>Does anyone have a handy memory mnemonic so I always remember ?</p> <p>For example:</p> <p>To go <strong>down</strong> a tree from a node - obviously I had to look this up :) - you do something like:</p> <pre><code>select * from node connect by prior node_id = parent_node_id start with node_id = 1 </code></pre> <p>So - I start with a <code>node_id</code> of 1 (the top of the branch) and the query looks for all nodes where the <code>parent_node_id</code> = 1 and then iterates down to the bottom of the tree.</p> <p>To go <strong>up</strong> the tree the prior goes on the parent:</p> <pre><code>select * from node connect by node_id = prior parent_node_id start with node_id = 10 </code></pre> <p>So starting somewhere down a branch (<code>node_id = 10</code> in this case) Oracle first gets all nodes where the <code>parent_node_id</code> is the same as the one for which <code>node_id</code> is 10.</p> <p><strong>EDIT</strong>: I <strong>still</strong> get this wrong so thought I'd add a clarifying edit to expand on the accepted answer - here's how I remember it now:</p> <pre><code>select * from node connect by prior node_id = parent_node_id start with node_id = 1 </code></pre> <p>The 'english language' version of this SQL I now read as...</p> <blockquote> <p>In NODE, starting with the row in which <code>node_id = 1</code>, the next row selected has its <code>parent_node_id</code> equal to <code>node_id</code> from the previous (prior) row.</p> </blockquote> <p><strong>EDIT</strong>: Quassnoi makes a great point - the order you write the SQL makes things a lot easier.</p> <pre><code>select * from node start with node_id = 1 connect by parent_node_id = prior node_id </code></pre> <p>This feels a lot clearer to me - the "start with" gives the first row selected and the "connect by" gives the next row(s) - in this case the children of node_id = 1.</p>
[ { "answer_id": 754290, "author": "Quassnoi", "author_id": 55159, "author_profile": "https://Stackoverflow.com/users/55159", "pm_score": 3, "selected": false, "text": "JOIN joined.column = leading.column\n SELECT t.value, d.name\nFROM transactions t\nJOIN\n dimensions d\nON d.id = t.dimension\n SELECT t.value, d.name\nFROM transactions t\nJOIN\n dimensions d\nON d.id = t.dimension\nWHERE t.id = :myid\n SELECT t.value, d.name\nFROM dimensions d\nJOIN\n transactions t\nON t.dimension = d.id\nWHERE d.id = :otherid\n (t.id) d.id (d.id) (t.dimension) JOIN CONNECT BY PRIOR PRIOR SELECT *\nFROM hierarchy\nSTART WITH\n id = :root\nCONNECT BY\n parent = PRIOR id\n parent id connect_by(row) {\n add_to_rowset(row);\n\n /* parent = PRIOR id */\n /* PRIOR id is an rvalue */\n index_on_parent.searchKey = row->id;\n\n foreach child_row in index_on_parent.search {\n connect_by(child_row);\n }\n}\n SELECT *\nFROM hierarchy\nSTART WITH\n id = :leaf\nCONNECT BY\n id = PRIOR parent\n id parent PRIOR PRIOR column" }, { "answer_id": 53173301, "author": "cartbeforehorse", "author_id": 1176987, "author_profile": "https://Stackoverflow.com/users/1176987", "pm_score": 0, "selected": false, "text": "id child_id id parent_id PRIOR PRIOR ID CHILD_ID PRIOR child_id = id parent_id id PRIOR id = parent_id" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4003/" ]
269,096
<p>I'm trying to create a WSTransfer implementation (I realise Roman Kiss has written one already for WCF - but it doesn't actually meet the specifications)</p> <p>I've ended up abandoning data contracts on the service contacts because WSTransfer is loosely coupled; so each the create message looks like Message Create(Message request).</p> <p>This works fine, and everything is lovely until it's time to fire back a response.</p> <p>The problem I have is in the way a WSTransfer response is constructed. Taking create as the example the response looks like</p> <pre><code>&lt;wxf:ResourceCreated&gt; &lt;wsa:Address&gt;....&lt;/wsa:Address&gt; &lt;wsa:ReferenceProperties&gt; &lt;xxx:MyID&gt;....&lt;/xxx:MyId&gt; &lt;/wsa:ReferenceProperties&gt; &lt;/wxf:ResourceCreated&gt; </code></pre> <p>As you can see there are 3 different XML namespaces within the response message.</p> <p>Now, it's easy enough when one is involved; you can (even if you're not exposing it), create a data contract and set the values and fire it back </p> <pre><code>Message response = Message.CreateMessage(request.Version, "http://schemas.xmlsoap.org/ws/2004/09/transfer/CreateResponse", resourceCreatedMessage); </code></pre> <p>However the problem arises in setting different namespaces for the child elements within the response; it appears WCF's datacontracts don't do this. Even using</p> <pre><code>[MessageBodyMember(Namespace="....")] </code></pre> <p>on the individual elements within the response class don't appear to make any changes, everything becomes part of the namespace specified for the contract class.</p> <p>So how do I apply different namespaces to individual elements in a WCF Message; either via a contract, or via some other jiggery pokery?</p>
[ { "answer_id": 754290, "author": "Quassnoi", "author_id": 55159, "author_profile": "https://Stackoverflow.com/users/55159", "pm_score": 3, "selected": false, "text": "JOIN joined.column = leading.column\n SELECT t.value, d.name\nFROM transactions t\nJOIN\n dimensions d\nON d.id = t.dimension\n SELECT t.value, d.name\nFROM transactions t\nJOIN\n dimensions d\nON d.id = t.dimension\nWHERE t.id = :myid\n SELECT t.value, d.name\nFROM dimensions d\nJOIN\n transactions t\nON t.dimension = d.id\nWHERE d.id = :otherid\n (t.id) d.id (d.id) (t.dimension) JOIN CONNECT BY PRIOR PRIOR SELECT *\nFROM hierarchy\nSTART WITH\n id = :root\nCONNECT BY\n parent = PRIOR id\n parent id connect_by(row) {\n add_to_rowset(row);\n\n /* parent = PRIOR id */\n /* PRIOR id is an rvalue */\n index_on_parent.searchKey = row->id;\n\n foreach child_row in index_on_parent.search {\n connect_by(child_row);\n }\n}\n SELECT *\nFROM hierarchy\nSTART WITH\n id = :leaf\nCONNECT BY\n id = PRIOR parent\n id parent PRIOR PRIOR column" }, { "answer_id": 53173301, "author": "cartbeforehorse", "author_id": 1176987, "author_profile": "https://Stackoverflow.com/users/1176987", "pm_score": 0, "selected": false, "text": "id child_id id parent_id PRIOR PRIOR ID CHILD_ID PRIOR child_id = id parent_id id PRIOR id = parent_id" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2525/" ]
269,101
<p>I'm using the code below to save a password to the registry, how do I convert it back? The code below isn't mine but it encrypts well.</p> <p>Thanks</p> <pre><code>using System.Security.Cryptography; public static string EncodePasswordToBase64(string password) { byte[] bytes = Encoding.Unicode.GetBytes(password); byte[] dst = new byte[bytes.Length]; byte[] inArray = HashAlgorithm.Create("SHA1").ComputeHash(dst); return Convert.ToBase64String(inArray); } </code></pre>
[ { "answer_id": 269218, "author": "Bradley Grainger", "author_id": 23633, "author_profile": "https://Stackoverflow.com/users/23633", "pm_score": 4, "selected": false, "text": "public static string ProtectPassword(string password)\n{\n byte[] bytes = Encoding.Unicode.GetBytes(password);\n byte[] protectedPassword = ProtectedData.Protect(bytes, null, DataProtectionScope.CurrentUser);\n return Convert.ToBase64String(protectedPassword);\n}\n\npublic static string UnprotectPassword(string protectedPassword)\n{\n byte[] bytes = Convert.FromBase64String(protectedPassword);\n byte[] password = ProtectedData.Unprotect(bytes, null, DataProtectionScope.CurrentUser);\n return Encoding.Unicode.GetString(password);\n}\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
269,106
<p>I am fairly new to WPF and I am having a problem with inheriting from a user control.</p> <p>I created a User Control and now I need to inherit from that control and add some more functionality.</p> <p>Has anyone does this sort of thing before? Any help would be greatly appreciated.</p> <p>Thank you</p>
[ { "answer_id": 269132, "author": "sirrocco", "author_id": 5246, "author_profile": "https://Stackoverflow.com/users/5246", "pm_score": 5, "selected": false, "text": "public abstract class BaseUserControl : UserControl{...}\n <Controls:BaseUserControl x:Class=\"Termo.Win.Controls.ChildControl\"\nxmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\nxmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"\nxmlns:Controls=\"clr-namespace:Namespace.Of.Your.BaseControl\">\n" }, { "answer_id": 1034172, "author": "Tomáš Kafka", "author_id": 38729, "author_profile": "https://Stackoverflow.com/users/38729", "pm_score": 2, "selected": false, "text": "<UserControl ... >\n\n <!-- My wrapping XAML -->\n <Common:DialogControl>\n <Common:DialogControl.Heading>\n <!-- Slot for a string -->\n </Common:DialogControl.Heading>\n <Common:DialogControl.Control>\n <!-- Concrete dialog's content goes here -->\n </Common:DialogControl.Control>\n <Common:DialogControl.Buttons>\n <!-- Concrete dialog's buttons go here -->\n </Common:DialogControl.Buttons>\n </Common:DialogControl>\n <!-- /My wrapping XAML -->\n\n</UserControl>\n" }, { "answer_id": 4843293, "author": "Maximiliano", "author_id": 595818, "author_profile": "https://Stackoverflow.com/users/595818", "pm_score": 1, "selected": false, "text": "delegate YourInterface IYourInterface Interface IYourInterface abstract class" }, { "answer_id": 7838196, "author": "user1005465", "author_id": 1005465, "author_profile": "https://Stackoverflow.com/users/1005465", "pm_score": 2, "selected": false, "text": "<Window \nx:Class=\"WPFSamples.Window1\"\nxmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\nxmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"\nHeight=\"auto\" Width=\"256\" Title=\"WPF Sameples\">\n <Grid>\n <Button x:Name=\"Button1\" VerticalAlignment=\"Center\" HorizontalAlignment=\"Center\" Content=\"Click Me\"/>\n </Grid>\n</Window>\n using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Windows;\nusing System.Windows.Controls;\nusing System.Windows.Data;\nusing System.Windows.Documents;\nusing System.Windows.Input;\nusing System.Windows.Media;\nusing System.Windows.Media.Imaging;\nusing System.Windows.Navigation;\nusing System.Windows.Shapes;\n\nnamespace WPFSamples\n{\n /// <summary>\n /// Interaction logic for Window1.xaml\n /// </summary>\n public abstract partial class Window1 : Window\n {\n public Window1()\n {\n InitializeComponent();\n }\n }\n}\n using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace WPFSamples\n{\n public sealed class DisabledButtonWindow : Window1\n {\n public DisabledButtonWindow()\n {\n Button1.IsEnabled = false;\n }\n }\n}\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269106", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35129/" ]
269,124
<p>I am reading a binary log file produced by a piece of equipment. </p> <p>I have the data in a byte[]. </p> <p>If I need to read two bytes to create a short I can do something like this:</p> <pre><code>short value = (short)(byte[1] &lt;&lt; 8); value += byte[2]; </code></pre> <p>Now I know the value is the correct for valid data. </p> <p>How would I know if the file was messed up and lets say the values FF FF were in those two places in the byte array?</p> <p>When I look at the resultant value of converting FF FF to a short, I get a -1.</p> <p>Is this a normal value for FF FF?, or did the computer just hit some kind of short bound and roll over with invalid data?</p> <p>For my purposes all of theses numbers are going to be positive. If FF FF is actually a short -1, then I just need to validate that all my results are postitive. </p> <p>Thank you,<br> Keith</p> <p><em>BTW, I am also reading other number data types. I'll show them here just because. The Read function is the basic part of reading from the byte[]. All the other data type reads use the basic Read() function.</em></p> <pre><code> public byte Read() { //advance position and then return byte at position byte returnValue; if (_CurrentPosition &lt; _count - 1) { returnValue= _array[_offset + ++_CurrentPosition]; return returnValue; } else throw new System.IO.EndOfStreamException ("Cannot Read Array, at end of stream."); } public float ReadFloat() { byte[] floatTemp = new byte[4]; for (int i = 3; i &gt;= 0; i--) { floatTemp[i] = Read(); } float returnValue = System.BitConverter.ToSingle (floatTemp, 0); if (float.IsNaN(returnValue)) { throw new Execption("Not a Number"); } return returnValue; } public short ReadInt16() { short returnValue = (short)(Read() &lt;&lt; 8); returnValue += Read(); return returnValue; } public int ReadInt32() { int returnValue = Read() &lt;&lt; 24; returnValue += Read() &lt;&lt; 16; returnValue += Read() &lt;&lt; 8; returnValue += Read(); return returnValue; } </code></pre>
[ { "answer_id": 269156, "author": "unwind", "author_id": 28169, "author_profile": "https://Stackoverflow.com/users/28169", "pm_score": 3, "selected": true, "text": "0xffff" }, { "answer_id": 269201, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 2, "selected": false, "text": "BitConverter MemoryStream mem = new MemoryStream(_array);\n\n\nfloat ReadFloat(Stream str)\n{\n byte[] bytes = str.Read(out bytes, 0, 4);\n return BitConverter.ToSingle(bytes, 0)\n}\n\npublic int ReadInt32(Stream str)\n{\n byte[] bytes = str.Read(out bytes, 0, 4);\n return BitConverter.ToInt32(bytes, 0)\n}\n" }, { "answer_id": 269398, "author": "Jacob Carpenter", "author_id": 26627, "author_profile": "https://Stackoverflow.com/users/26627", "pm_score": 1, "selected": false, "text": "BinaryReader" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1048/" ]
269,164
<p>I am looking for an elegant solution for removing content from an ASP.Net page if no data has been set. Let me explain this a little more.</p> <p>I have some blocks of data on a page that contain some sub-sections with individual values in them. If no data has been set for one of the values I need to hide it (so it does not take up space). Also, if none of the values within a sub-section have been set, it needs to be hidden as well. Finally if none of the sub-sections are visible within the block/panel, then I need to hide the entire thing.</p> <p>The layout is implemented using nested Panels/DIVs</p> <pre><code>&lt;Panel id="block"&gt; &lt;Panel id="sub1"&gt; &lt;Panel id="value1-1"&gt;blah&lt;/Panel&gt; &lt;Panel id="value1-2"&gt;blah&lt;/Panel&gt; &lt;/Panel&gt; &lt;Panel id="sub2"&gt; &lt;Panel id="value2-1"&gt;blah&lt;/Panel&gt; &lt;Panel id="value2-2"&gt;blah&lt;/Panel&gt; &lt;/Panel&gt; &lt;/panel&gt; </code></pre> <p>I am wondering if anyone has any decent ideas on implementing something like this without writing a bunch of nested <strong>If..Else</strong> statements, and without creating a bunch of custom controls. Whatever I implement needs to be robust enough to handle changes in the markup without constantly manipulating the codebehind.</p> <p>I am hoping there is a way to do this through some simple markup changes (custom attribute) and a recursive function call on PageLoad or PreRender.</p> <p>Any help is greatly appreciated.</p> <h2>EDIT:</h2> <p>Ok so what makes this tricky is that there might be other controls inside the sub-sections that do not factor into the hiding and showing of the controls. And each <em>value</em> panel could potentially have controls in it that do not factor into whether or not it is shown. Example:</p> <pre><code>&lt;Panel id="sub2"&gt; &lt;Image id="someImage" src="img.png" /&gt; &lt;Panel id="value2-1"&gt; &lt;Label&gt;blah&lt;/Label&gt; &lt;TextBox id="txtValue" /&gt; &lt;/Panel&gt; &lt;Panel id="value2-2"&gt;blah&lt;/Panel&gt; &lt;/Panel&gt; </code></pre> <p>This is an over simplified example, but not far off from what I have to worry about.</p>
[ { "answer_id": 269195, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 1, "selected": false, "text": "<Panel id=\"block\" runat=\"server\" visible=\"<%=IsBlockVisible%>\">\n <Panel id=\"sub1\" runat=\"server\" visible=\"<%=IsSubVisible(1)%>\">\n <Panel id=\"value1-1\">blah</Panel>\n <Panel id=\"value1-2\">blah</Panel>\n </Panel>\n <Panel id=\"sub2\" runat=\"server\" visible=\"<%=IsSubVisible(2)%>\">\n <Panel id=\"value2-1\">blah</Panel>\n <Panel id=\"value2-2\">blah</Panel>\n </Panel>\n</panel>\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269164", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11702/" ]
269,172
<p>It appear that SQL Server like most other products Random Function really is not that random. So we have this nice little function to generate a 10 char value. Is there a better way to accomplish what the following does. I am betting there is.</p> <pre><code>DECLARE @SaltCount INT; SELECT @SaltCount = COUNT(*) FROM tmp_NewLogin; PRINT 'Set Salt values for all records' + CAST(@SaltCount AS VARCHAR(10)) DECLARE @CharPool CHAR(83); DECLARE @Salt VARCHAR(10); SET @CharPool = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!"#$%&amp;()*+,-./:;&lt;=&gt;?@'; SET NOCOUNT ON; updateSaltValue: SET @Salt = '' SELECT @Salt = @Salt + SUBSTRING(@CharPool, number, 1) FROM ( SELECT TOP 10 number FROM MASTER..[spt_values] WHERE TYPE = 'p' AND Number BETWEEN 1 AND 83 ORDER BY NEWID() ) AS t UPDATE TOP(1) [table] SET [Salt] = @Salt WHERE [Salt] IS NULL IF (@@ROWCOUNT &gt; 0) GOTO updateSaltValue SET NOCOUNT OFF; PRINT 'Completed setting salts for all records'; </code></pre>
[ { "answer_id": 269222, "author": "Aleksandar", "author_id": 29511, "author_profile": "https://Stackoverflow.com/users/29511", "pm_score": 1, "selected": false, "text": "create view [dbo].[wrapped_rand_view]\nas\nselect rand( ) as random_value\n create function [dbo].[wrapped_rand]()\nreturns float\nas\nbegin\ndeclare @f float\nset @f = (select random_value from wrapped_rand_view)\nreturn @f\n" }, { "answer_id": 269445, "author": "Cristian Libardo", "author_id": 16526, "author_profile": "https://Stackoverflow.com/users/16526", "pm_score": 0, "selected": false, "text": "select substring(replace(newid(),'-',''),0,10)\n" }, { "answer_id": 8285307, "author": "gngolakia", "author_id": 1050111, "author_profile": "https://Stackoverflow.com/users/1050111", "pm_score": 0, "selected": false, "text": "> create proc [dbo].uspRandChars\n> @len int,\n> @min tinyint = 48,\n> @range tinyint = 74,\n> @exclude varchar(50) = '0:;<=>?@O[]`^\\/',\n> @output varchar(50) output as \n> declare @char char\n> set @output = ''\n> \n> while @len > 0 begin\n> select @char = char(round(rand() * @range + @min, 0))\n> if charindex(@char, @exclude) = 0 begin\n> set @output += @char\n> set @len = @len - 1\n> end\n> end\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24500/" ]
269,179
<p>I have a lot of spare intel linux servers laying around (hundreds) and want to use them for a distributed file system in a web hosting and file sharing environment. This isn't for a HPC application, so high performance isn't critical. The main requirement is high availability, if one server goes offline, the data stored on it's hard drives is still available from other nodes. It must run over TCP/IP and provide standard POSIX file permissions.</p> <p>I've looked at the following:</p> <ul> <li><p>Lustre (<a href="http://wiki.lustre.org/index.php?title=Main_Page" rel="noreferrer">http://wiki.lustre.org/index.php?title=Main_Page</a>): Comes <em>really</em> close, but it doesn't provide redundancy for data on a node. You must make the data HA using RAID or DRBD. Supported by Sun and Open Source, so it should be around for a while</p></li> <li><p>gfarm (<a href="http://datafarm.apgrid.org/" rel="noreferrer">http://datafarm.apgrid.org/</a>): Looks like it provides the redundancy but at the cost of complexity and maintainability. Not as well supported as Lustre.</p></li> </ul> <p>Does anyone have any experience with these or any other systems that might work?</p>
[ { "answer_id": 269187, "author": "Javier", "author_id": 11649, "author_profile": "https://Stackoverflow.com/users/11649", "pm_score": 5, "selected": true, "text": "librados" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34227/" ]
269,181
<p>When you link to an unmanaged library (say 'A.dll') which in turn links to another library ('B.dll'), and B.dll is missing, you will get a run-time error message about failing to load 'B.dll'.</p> <p>But when you P/Invoke into 'A.dll' from managed code, you'll get a general exception of this form:</p> <p>Unhandled Exception: System.DllNotFoundException: Unable to load DLL 'A.dll': The specified module could not be found.</p> <p>How can I get an error message that pinpoints the specific unmanaged dll file that failed to load, when p/invoking from managed code ?</p>
[ { "answer_id": 269197, "author": "Bradley Grainger", "author_id": 23633, "author_profile": "https://Stackoverflow.com/users/23633", "pm_score": 2, "selected": false, "text": "LoadLibrary" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
269,186
<p>We use Tomcat to host our WAR based applications. We are servlet container compliant J2EE applications with the exception of org.apache.catalina.authenticator.SingleSignOn.</p> <p>We are being asked to move to a commercial Java EE application server.</p> <ol> <li>The first downside to changing that I see is the cost. No matter what the charges for the application server, Tomcat is free.</li> <li>Second is the complexity. We don't use either EJB nor EAR features (of course not, we can't), and have not missed them.</li> </ol> <p>What then are the benefits I'm not seeing?</p> <p>What are the drawbacks that I haven't mentioned?</p> <hr> <p>Mentioned were...</p> <ol> <li>JTA - Java Transaction API - We control transaction via database stored procedures.</li> <li>JPA - Java Persistence API - We use JDBC and again stored procedures to persist.</li> <li>JMS - Java Message Service - We use XML over HTTP for messaging.</li> </ol> <p>This is good, please more!</p>
[ { "answer_id": 9199893, "author": "David Blevins", "author_id": 190816, "author_profile": "https://Stackoverflow.com/users/190816", "pm_score": 6, "selected": false, "text": "UserTransaction @Resource UserTransaction transaction; javax.transaction.UserTransaction javax.sql.DataSource javax.persistence.EntityManager javax.jms.ConnectionFactory javax.jms.QueueConnectionFactory javax.jms.TopicConnectionFactory javax.ejb.TimerService rollback() UserTransaction close() DataSource TransactionManager Synchronization Realm Realm @PersistenceUnit EntityManagerFactory @PersistenceContext EntityManager EntityManager EntityManager EntityManager EntityManager EntityManager EntityManager EntityManager EntityManager EntityManager EntityManager.getDelegate() EntityManager EntityManager EntityManager EntityManager EntityManager.getDelegate() EntityManager EntityManagerFactory HttpSession String HttpSession @SessionScoped @SessionScoped HttpSession @Inject FooObject EntitityManager getAttribute setAttribute HttpServletRequest @RequestScoped @ApplicationScoped getAttribute setAttribute ServletContext @PostConstruct @PreDestroy @DataSourceDefinition java:global java:app java:module @Resource MyEnum myEnum @Resource Class myPluggableClass @Resource(lookup=\"foo\") DataSource" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13930/" ]
269,193
<p>I've got two ListBox'es that are databound to the same BindingList.</p> <p>The issue is that when changing the selected item from the GUI it's changing the position in the BindingList and then the BindingList signals the other ListBox to change its selected item.</p> <p>So I've got the two ListBoxes Selected Item also synchronized which is not good for me.</p> <p>I'd like to maintain the list of items in sync. without the cursor position.</p> <p>How do I disable that cursor so it's not maintained?</p> <p>sample code (just add two ListBoxes to the Form at design time and register the SelectedIndexChanged events and register the button click event with a button):</p> <pre><code>public partial class Form1 : Form { BindingList&lt;string&gt; list = new BindingList&lt;string&gt;(); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { list.Add("bla1"); list.Add("bla2"); list.Add("bla3"); this.listBox1.DataSource = list; this.listBox2.DataSource = list; } private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { if (listBox1.SelectedIndex != -1) System.Diagnostics.Trace.WriteLine("ListBox1: " + listBox1.SelectedItem.ToString()); } private void listBox2_SelectedIndexChanged(object sender, EventArgs e) { if (listBox2.SelectedIndex != -1) System.Diagnostics.Trace.WriteLine("ListBox2: " + listBox2.SelectedItem.ToString()); } // Register this event to a button private void button1_Click(object sender, EventArgs e) { list.Add("Test"); } } </code></pre> <p>Thanks, --Ran.</p>
[ { "answer_id": 270622, "author": "tamberg", "author_id": 3588, "author_profile": "https://Stackoverflow.com/users/3588", "pm_score": 2, "selected": false, "text": "class MyListBox: ListBox {\n\n protected override void OnSelectedIndexChanged (EventArgs a) {\n if (DataManager != null) {\n DataManager.SuspendBinding();\n }\n }\n\n}\n" }, { "answer_id": 277850, "author": "jyoung", "author_id": 14841, "author_profile": "https://Stackoverflow.com/users/14841", "pm_score": 4, "selected": true, "text": "Form_Load this.listBox1.BindingContext = new BindingContext();\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35139/" ]
269,207
<p>I have implemented a SAX parser in Java by extending the default handler. The XML has a ñ in its content. When it hits this character it breaks. I print out the char array in the character method and it simply ends with the character before the ñ. The parser seems to stop after this as no other methods are called even though there is still much more content. ie the endElement method is never called again. Has anyone run into this problem before or have any suggestion on how to deal with it?</p>
[ { "answer_id": 269288, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 3, "selected": true, "text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" }, { "answer_id": 34519333, "author": "Amarnath Reddy Dornala", "author_id": 5728198, "author_profile": "https://Stackoverflow.com/users/5728198", "pm_score": 0, "selected": false, "text": "File F = new File(C://Location);\nBuffeReader Readfile = new BufferReader(F);\nInputSource Encode = new InputSource(Readfile);\nEncode.setEncoding(\"UTF-8\");\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35140/" ]
269,212
<p>We have an Java application running on Weblogic server that picks up XML messages from a JMS or MQ queue and writes it into another JMS queue. The application doesn't modify the XML content in any way. We use BEA's XMLObject to read and write the messages into queues.</p> <p>The XML messages contain the encoding type declarations as UTF-8.</p> <p>We have an issue when the XML contains characters that are out side the normal ASCII range (like £ symbol for example). When the message is read from the queue we can see that the £ symbol is intact, however once we write it to the destination queue, the £ symbol is lost and is replaced with £ instead.</p> <p>I have checked the OS level settings (locale settings) and everything seems to be fine. What else should I be checking to make sure that this doesn't happen?</p>
[ { "answer_id": 269891, "author": "Alan Moore", "author_id": 20938, "author_profile": "https://Stackoverflow.com/users/20938", "pm_score": 4, "selected": true, "text": "ÃX X" }, { "answer_id": 269949, "author": "erickson", "author_id": 3474, "author_profile": "https://Stackoverflow.com/users/3474", "pm_score": 2, "selected": false, "text": "InputStream OutputStream byte[] Reader Writer String BytesMessage TextMessage" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34026/" ]
269,213
<p>What are good ways of achieving this DB agnosticism without actually coding two DAL's? I've heard that the Data Access Application Block is suitable for this.</p>
[ { "answer_id": 331193, "author": "Patrick de Kleijn", "author_id": 33221, "author_profile": "https://Stackoverflow.com/users/33221", "pm_score": 0, "selected": false, "text": " private static DbProviderFactory _provider = DbProviderFactories.GetFactory(WebConfigurationManager.ConnectionStrings[\"database\"].ProviderName);\n private static string _connectionString = WebConfigurationManager.ConnectionStrings[\"database\"].ConnectionString;\n\n\n public static DbParameter CreateParameter(string name, object value)\n {\n DbParameter parameter = _provider.CreateParameter();\n parameter.ParameterName = name;\n parameter.Value = value;\n return parameter;\n }\n\n public static DataTable SelectAsTable(string query, DbParameter[] parameters)\n {\n using (DbConnection connection = _provider.CreateConnection())\n {\n connection.ConnectionString = _connectionString;\n using (DbDataAdapter adapter = _provider.CreateDataAdapter())\n {\n adapter.SelectCommand = connection.CreateCommand();\n adapter.SelectCommand.Parameters.AddRange(parameters);\n adapter.SelectCommand.CommandText = query;\n\n DataTable table = new DataTable();\n adapter.Fill(table);\n connection.Close();\n return table;\n }\n }\n }\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8741/" ]
269,223
<p>As I understand, the pimpl idiom is exists only because C++ forces you to place all the private class members in the header. If the header were to contain only the public interface, theoretically, any change in class implementation would not have necessitated a recompile for the rest of the program. </p> <p>What I want to know is why C++ is not designed to allow such a convenience. Why does it demand at all for the private parts of a class to be openly displayed in the header (no pun intended)?</p>
[ { "answer_id": 269251, "author": "Dan Hewett", "author_id": 17975, "author_profile": "https://Stackoverflow.com/users/17975", "pm_score": 4, "selected": true, "text": "class MyClass\n{\npublic:\n // public stuff\n\nprivate:\n#include \"MyClassPrivate.h\"\n};\n" }, { "answer_id": 269599, "author": "Matt Cruikshank", "author_id": 8643, "author_profile": "https://Stackoverflow.com/users/8643", "pm_score": 3, "selected": false, "text": "#pragma pimpl(MyClass_private.hpp)\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32688/" ]
269,228
<p>I am trying to write a tool that can compare a database’s schema to the SQL in an install script. Getting the information from the database is pretty straightforward but I am having a little trouble parsing the install scripts. </p> <p>I have played with a few of the parsers that show up on Google but they seemed somewhat incomplete. Ideally I would like to find an open source parser that is fairly stable and has half decent documentation. </p> <p>Also, I am not really concerned about types and syntax that specific to certain databases. The databases that need to be check are pretty simple.</p>
[ { "answer_id": 909531, "author": "Klathzazt", "author_id": 35223, "author_profile": "https://Stackoverflow.com/users/35223", "pm_score": 0, "selected": false, "text": "PRAGMA table_info(my_table)\nPRAGMA table_info(temporary_my_table)\n SELECT table_name, column_name, data_type\nFROM information_schema.columns\nWHERE table_schema = 'my_schema'\nAND (table_name LIKE '%my_table';\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13054/" ]
269,241
<p>I have a not-so-small class under development (that it changes often) and I need not to provide a public copy constructor and copy assignment. The class has objects with value semantics, so default copy and assignment work.</p> <p>the class is in a hierarchy, with virtual methods, so I provide a virtual Clone() to avoid slicing and to perform "polymorphic copy".</p> <p>I don't want to declare copy assignment and construction protected AND to define them (and to maintain in-sync with changes) unless I have some special thing to perform.</p> <p>Do someone knows if there's another way?</p> <p>thanks!</p> <p>UgaSofT</p>
[ { "answer_id": 6938247, "author": "小太郎", "author_id": 359653, "author_profile": "https://Stackoverflow.com/users/359653", "pm_score": 0, "selected": false, "text": "class A\n{\n protected:\n A(const A&) = default;\n};\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10120/" ]
269,243
<p>I have a multi-threaded Windows application that occasionally deadlocks. Inevitably this happens on a customer system and not when the software is in test. What is the easiest way of getting a Windows Minidump of the current state of the application? If it could also terminate the application so the user can restart it and continue using the system that would be great.</p>
[ { "answer_id": 269257, "author": "davefiddes", "author_id": 6353, "author_profile": "https://Stackoverflow.com/users/6353", "pm_score": 1, "selected": false, "text": "ntsd -pn MyApp.exe\n .dump c:\\my-deadlock.mdmp\n.kill\n ntsd -pn MyApp.exe -c \".dump c:\\my-deadlock.mdmp; .kill\" .detach" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6353/" ]
269,252
<p>Is there an event for when a document is edited? If not, does anyone know where I could find a list of the available VBA events?</p>
[ { "answer_id": 269323, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": 2, "selected": false, "text": "DocumentBeforeClose : Immediately before any open document closes. \nDocumentBeforePrint : Before any open document is printed. \nDocumentBeforeSave : Before any open document is saved. \nDocumentChange : A new document is created, when an existing document is opened, or when another document is made the active document. \nDocumentOpen : A document is opened. \nEPostageInsert : A user inserts electronic postage into a document. \nEPostagePropertyDialog : A user clicks the E-postage Properties (Labels and Envelopes dialog box) button or Print Electronic Postage toolbar button. This event allows a third-party software application to intercept and show their properties dialog box. \nMailMergeAfterMerge : After all records in a mail merge have merged successfully. \nMailMergeAfterRecordMerge : After each record in the data source successfully merges in a mail merge. \nMailMergeBeforeMerge : A merge is executed before any records merge. \nMailMergeBeforeRecordMerge : As a merge is executed for the individual records in a merge. \nMailMergeDataSourceLoad : The data source is loaded for a mail merge. \nMailMergeDataSourceValidate : A user performs address verification by clicking Validate in the Mail Merge Recipients dialog box. \nMailMergeWizardSendToCustom : The custom button is clicked on step six of the Mail Merge Wizard. \nMailMergeWizardStateChange : A user changes from a specified step to a specified step in the Mail Merge Wizard. \nNewDocument : A new document is created. \nQuit : The user quits Word. \nWindowActivate : Any document window is activated. \nWindowBeforeDoubleClick : The editing area of a document window is double-clicked, before the default double-click action. \nWindowBeforeRightClick : The editing area of a document window is right-clicked, before the default right-click action. \nWindowDeactivate : Any document window is deactivated. \nWindowSelectionChange : The selection changes in the active document window. \nWindowSize : The application window is resized or moved. \n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269252", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5653/" ]
269,253
<p>Is there a way to restrict a specific SQL 2005 login on a Microsoft SQL Server 2005, standard version (sql is in mixed mode) to specific IP addresses, while other logins, Windows authenticated ones, are unaffected?</p>
[ { "answer_id": 325936, "author": "Thuglife", "author_id": 41612, "author_profile": "https://Stackoverflow.com/users/41612", "pm_score": 3, "selected": false, "text": "CREATE TRIGGER [LOGIN_IP_RESTRICTION]\n ON ALL SERVER FOR LOGON\nAS\nBEGIN\n DECLARE @host NVARCHAR(255);\n\n SET @host = EVENTDATA().value('(/EVENT_INSTANCE/ClientHost)[1]', 'nvarchar(max)');\n\n IF(EXISTS(SELECT * FROM master.dbo.IP_RESTRICTION \n WHERE UserName = SYSTEM_USER))\n BEGIN\n IF(NOT EXISTS(SELECT * FROM master.dbo.IP_RESTRICTION \n WHERE UserName = SYSTEM_USER AND ValidIP = @host))\n BEGIN\n ROLLBACK;\n END\n END\nEND;\n CREATE TABLE [dbo].[IP_RESTRICTION](\n [UserName] [varchar](255) NOT NULL,\n [ValidIP] [varchar](15) NOT NULL,\n [Comment] [nvarchar](255) NULL,\n CONSTRAINT [PK_IP_RESTRICTION] PRIMARY KEY CLUSTERED \n([UserName] ASC, [ValidIP] ASC) ON [PRIMARY]\n) ON [PRIMARY]\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269253", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35150/" ]
269,263
<p>I have just been getting into low level programming (reading/writing to memory that sort of thing) and have run into an issue i cannot find an answer to.</p> <p>The piece of information i want to read from has an address that is relative to a DLL loaded in memory e,g, it is at mydll.dll + 0x01234567. the problem im having is that the dll moves around in memory but the offset stays the same. Is there anyway to find out the location of this dll in memory.</p> <p>I am currently trying to do this preferably in c# but i would be grateful for help in most highish level languages.</p>
[ { "answer_id": 280960, "author": "Paul Harris", "author_id": 35148, "author_profile": "https://Stackoverflow.com/users/35148", "pm_score": 3, "selected": true, "text": "String appToHookTo = \"applicationthatloadedthedll\";\nProcess[] foundProcesses = Process.GetProcessesByName(appToHookTo)\nProcessModuleCollection modules = foundProcesses[0].Modules;\nProcessModule dllBaseAdressIWant = null;\nforeach (ProcessModule i in modules) {\nif (i.ModuleName == \"nameofdlliwantbaseadressof\") {\n dllBaseAdressIWant = i;\n }\n }\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35148/" ]
269,267
<p>Excel has a Conditional Formatting... option under the Format menu that allows you to change the style/color/font/whatever of a cell depending upon its value. But it only allows three conditions.</p> <p>How do I get Excel to display say, six different background cell colors depending upon the value of the cell? (IE Make the cell red if the value is "Red", and blue if "Blue" etc.)</p>
[ { "answer_id": 269278, "author": "Galwegian", "author_id": 3201, "author_profile": "https://Stackoverflow.com/users/3201", "pm_score": 4, "selected": true, "text": "Private Sub Worksheet_Change(ByVal Target As Range)\n\nDim icolor As Integer\n\n If Not Intersect(Target, Range(\"A1:A10\")) is Nothing Then\n\n Select Case Target\n\n Case 1 To 5\n icolor = 6\n Case 6 To 10\n icolor = 12\n Case 11 To 15\n icolor = 7\n Case 16 To 20\n icolor = 53\n Case 21 To 25\n icolor = 15\n Case 26 To 30\n icolor = 42\n Case Else\n 'Whatever\n End Select\n\n Target.Interior.ColorIndex = icolor\n End If\nEnd Sub\n" }, { "answer_id": 273791, "author": "Russ Cam", "author_id": 1831, "author_profile": "https://Stackoverflow.com/users/1831", "pm_score": 2, "selected": false, "text": "Public Sub ColorCells()\n\nDim cell, rng As Range\nDim color As Integer\nDim sheet As Worksheet\n\nApplication.ScreenUpdating = False\nApplication.StatusBar = \"Coloring Cells\"\n\n Set rng = Application.Selection\n Set sheet = Application.ActiveSheet\n\nFor Each cell In rng.cells\n\n Select Case Trim(LCase(cell))\n\n Case \"blue\"\n\n color = 5\n\n Case \"red\"\n\n color = 3\n\n Case \"yellow\"\n\n color = 6\n\n Case \"green\"\n\n color = 4\n\n Case \"purple\"\n\n color = 7\n\n Case \"orange\"\n\n color = 46\n\n Case Else\n\n color = 0\n End Select\n\n sheet.Range(cell.Address).Interior.ColorIndex = color\n\nNext cell\n\nApplication.ScreenUpdating = True\nApplication.StatusBar = \"Ready\"\n\nEnd Sub\n Private Sub Worksheet_Change(ByVal Target As Range)\n\nIf Target.cells.Count > 1 Then Exit Sub\n\nDim color As Integer\n\n Select Case Trim(LCase(Target))\n\n Case \"blue\"\n\n color = 5\n\n Case \"red\"\n\n color = 3\n\n Case \"yellow\"\n\n color = 6\n\n Case \"green\"\n\n color = 4\n\n Case \"purple\"\n\n color = 7\n\n Case \"orange\"\n\n color = 46\n\n Case Else\n\n color = 0\n\n End Select\n\nTarget.Interior.ColorIndex = color\n\nEnd Sub\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35154/" ]
269,268
<p>I'd like to implement a big int class in C++ as a programming exercise&mdash;a class that can handle numbers bigger than a long int. I know that there are several open source implementations out there already, but I'd like to write my own. I'm trying to get a feel for what the right approach is.</p> <p>I understand that the general strategy is get the number as a string, and then break it up into smaller numbers (single digits for example), and place them in an array. At this point it should be relatively simple to implement the various comparison operators. My main concern is how I would implement things like addition and multiplication.</p> <p>I'm looking for a general approach and advice as opposed to actual working code.</p>
[ { "answer_id": 269302, "author": "hark", "author_id": 34826, "author_profile": "https://Stackoverflow.com/users/34826", "pm_score": 2, "selected": false, "text": "typedef struct {\n int high, low;\n} BiggerInt;\n BiggerInt add( const BiggerInt *lhs, const BiggerInt *rhs ) {\n BiggerInt ret;\n\n /* Ideally, you'd want a better way to check for overflow conditions */\n if ( rhs->high < INT_MAX - lhs->high ) {\n /* With a variable-length (a real) BigInt, you'd allocate some more room here */\n }\n\n ret.high = lhs->high + rhs->high;\n\n if ( rhs->low < INT_MAX - lhs->low ) {\n /* No overflow */\n ret.low = lhs->low + rhs->low;\n }\n else {\n /* Overflow */\n ret.high += 1;\n ret.low = lhs->low - ( INT_MAX - rhs->low ); /* Right? */\n }\n\n return ret;\n}\n" }, { "answer_id": 270258, "author": "mstrobl", "author_id": 25965, "author_profile": "https://Stackoverflow.com/users/25965", "pm_score": 6, "selected": false, "text": "template< class BaseType >\nclass BigInt\n{\ntypedef typename BaseType BT;\nprotected: std::vector< BaseType > value_;\n};\n template< class BaseType >\nBigInt< BaseType >& BigInt< BaseType >::operator += (BigInt< BaseType > const& operand)\n{\n BT count, carry = 0;\n for (count = 0; count < std::max(value_.size(), operand.value_.size(); count++)\n {\n BT op0 = count < value_.size() ? value_.at(count) : 0, \n op1 = count < operand.value_.size() ? operand.value_.at(count) : 0;\n BT digits_result = op0 + op1 + carry;\n if (digits_result-carry < std::max(op0, op1)\n {\n BT carry_old = carry;\n carry = digits_result;\n digits_result = (op0 + op1 + carry) >> sizeof(BT)*8; // NOTE [1]\n }\n else carry = 0;\n }\n\n return *this;\n}\n// NOTE 1: I did not test this code. And I am not sure if this will work; if it does\n// not, then you must restrict BaseType to be the second biggest type \n// available, i.e. a 32-bit int when you have a 64-bit long. Then use\n// a temporary or a cast to the mightier type and retrieve the upper bits. \n// Or you do it bitwise. ;-)\n operator<< value_.size()-1 operator< size() operator<<" }, { "answer_id": 12273233, "author": "Jeremy Trifilo", "author_id": 1625157, "author_profile": "https://Stackoverflow.com/users/1625157", "pm_score": 0, "selected": false, "text": "//Number = 100,000.00, Number Digits = 32, Decimal Digits = 2.\nBigDecimal *decimal = new BigDecimal(\"100000.00\", 32, 2);\ndecimal += \"1000.99\";\ncout << decimal->GetValue(0x1 | 0x2) << endl; //Format and show decimals.\n//Prints: 101,000.99\n" }, { "answer_id": 68690881, "author": "Nitin Verma", "author_id": 13949534, "author_profile": "https://Stackoverflow.com/users/13949534", "pm_score": 0, "selected": false, "text": "B B=2^{32} B=10 B B B" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9435/" ]
269,285
<p>I have this simple controller:</p> <pre><code>public class OneController : Controller { [AcceptVerbs(HttpVerbs.Get)] public ActionResult Create() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(IList&lt;TestModel&gt; m) { return View(m); } } </code></pre> <p>And a very simple view with two objects of type TestModel, properly indexed. When I submit the form with invalid data, I get the view with the errors highlighted. However, when I re-submit it (without changing anything), I get this error:</p> <blockquote> <p>[NullReferenceException: Object reference not set to an instance of an object.] System.Web.Mvc.DefaultModelBinder.UpdateCollection(ModelBindingContext bindingContext, Type itemType) +612 System.Web.Mvc.DefaultModelBinder.BindModelCore(ModelBindingContext bindingContext) +519 System.Web.Mvc.DefaultModelBinder.BindModel(ModelBindingContext bindingContext) +829 System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ParameterInfo parameterInfo) +313 System.Web.Mvc.ControllerActionInvoker.GetParameterValues(MethodInfo methodInfo) +399 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +232 System.Web.Mvc.Controller.ExecuteCore() +152 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +86 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +28 System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +332 System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) +55 System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext) +28 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +358 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +64</p> </blockquote> <p>Any idea on how can I debug this?</p>
[ { "answer_id": 426803, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<%= Html.Hidden(\"submitFormFields.index\", controlID) %>\n <input type=\"hidden\" id=\"submitFormFields.index\" name=\"submitFormFields.index\" value=\"<%=controlID %>\" />\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7277/" ]
269,298
<p>I have a list of items that I am displaying in a floated list, with each item in the list at a fixed width so that there's two per row. What is the best practice to prevent this horrible thing from happening:</p> <p><a href="http://x01.co.uk/floated_items.gif">alt text http://x01.co.uk/floated_items.gif</a></p> <p>Possibilites:</p> <ul> <li>Trim to a specified number of characters before displaying the data. Requires guesswork on how many characters will be "safe".</li> <li>Overflow: hidden. Hacky.</li> <li>Remove the background and just have a top border on each item.</li> </ul> <p>Possible but silly:</p> <ul> <li>Have a scrollbar in each item by doing overflow: auto, this will look horrendous.</li> <li>Add a background image to the container. It's not guaranteed that there's always an equal number of items so this option is out.</li> </ul> <p>Any help on this irritating issue appreciated!</p>
[ { "answer_id": 274983, "author": "Esteban Küber", "author_id": 34813, "author_profile": "https://Stackoverflow.com/users/34813", "pm_score": 0, "selected": false, "text": "ul li{\n display:block;\n float:left;\n width:6em;\n height:4em;\n background-color:black;\n color:white;\n margin-right:1em;\n}\nul{\n height:100%;\n overflow:hidden;\n}\ndiv{\n height:3em;\n overflow:hidden;\n background-color:blue;\n}\n <div>\n<ul>\n<li>asdf\n<li>asdf trey tyeu ereyuioquoi\n<li>fdas dasf erqwt ytwere r\n<li>dfsaklñd s jfañlsdjf ñkljdk ñlfas\n<li>ksdflñajñldsafjñlksdjfñalksdfjlkdhfc,v.mxzn\n</ul>\n</div>\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/192/" ]
269,303
<p>After using them a while I can't help but feel that the hoops you're forced to jump through when using anonymous classes are not worth it.</p> <p>You end up with <code>final</code> all over the place and no matter what the code is more difficult to read than if you'd used a well named inner class.</p> <p>So what are the advantages of using them? I must be missing something.</p>
[ { "answer_id": 269345, "author": "Vinze", "author_id": 26859, "author_profile": "https://Stackoverflow.com/users/26859", "pm_score": 2, "selected": false, "text": "this.addListener(new IListener(){\n public void listen() {...}\n});\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
269,314
<p>On Linux (or Solaris) is there a better way than hand parsing <code>/proc/self/maps</code> repeatedly to figure out whether or not you can read, write or execute whatever is stored at one or more addresses in memory?</p> <p>For instance, in Windows you have <code>VirtualQuery</code>. </p> <p>In Linux, I can <code>mprotect</code> to change those values, but I can't read them back.</p> <p>Furthermore, is there any way to know when those permissions change (e.g. when someone uses <code>mmap</code> on a file behind my back) other than doing something terribly invasive and using <code>ptrace</code> on all threads in the process and intercepting any attempt to make a <code>syscall</code> that could affect the memory map?</p> <p><strong>Update:</strong></p> <p>Unfortunately, I'm using this inside of a JIT that has very little information about the code it is executing to get an approximation of what is constant. Yes, I realize I could have a constant map of mutable data, like the vsyscall page used by Linux. I <em>can</em> safely fall back on an assumption that anything that isn't included in the initial parse is mutable and dangerous, but I'm not entirely happy with that option.</p> <p>Right now what I do is I read <code>/proc/self/maps</code> and build a structure I can binary search through for a given address's protection. Any time I need to know something about a page that isn't in my structure I reread /proc/self/maps assuming it has been added in the meantime or I'd be about to segfault anyways.</p> <p>It just seems that parsing text to get at this information and not knowing when it changes is awfully crufty. (<code>/dev/inotify</code> doesn't work on pretty much anything in <code>/proc</code>)</p>
[ { "answer_id": 269572, "author": "Pierre", "author_id": 24449, "author_profile": "https://Stackoverflow.com/users/24449", "pm_score": 4, "selected": true, "text": "VirtualQuery mprotect mprotect mprotect mprotect mprotect /dev/inotify /proc/self/maps" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34707/" ]
269,326
<p>I'm running Apache on Windows XP via Xampplite, and could use help configuring my virtual directory. Here's what I'm hoping to do on my dev box:</p> <ol> <li>I want my source files to live outside of the xampp htdocs dir</li> <li>on my local machine I can access the project at <a href="http://myproject" rel="noreferrer">http://myproject</a></li> <li>others on my local network can access the project at my.ip.address/myproject</li> <li>keep localhost pointing to the xampp's htdocs folder so I can easily add other projects.</li> </ol> <p>I've got 1 &amp; 2 working by editing the windows hosts file, and adding a virtual directory in xampp's apache\conf\extra\httpd-vhosts.conf file. I don't immediately see how to do 3 without messing up 4.</p>
[ { "answer_id": 269378, "author": "sprugman", "author_id": 24197, "author_profile": "https://Stackoverflow.com/users/24197", "pm_score": 6, "selected": true, "text": "Alias /myproject \"C:/path/to/my/project\"\n<Directory \"C:/path/to/my/project\">\n Options Indexes FollowSymLinks MultiViews ExecCGI\n AllowOverride All\n Order allow,deny\n Allow from all\n</Directory>\n" }, { "answer_id": 270018, "author": "jeremyasnyder", "author_id": 33143, "author_profile": "https://Stackoverflow.com/users/33143", "pm_score": 4, "selected": false, "text": " NameVirtualHost myproject:80\n\n <VirtualHost myproject:80>\n DocumentRoot c:/xampp/sites/myproject\n Options Indexes FollowSymLinks Includes ExecCGI\n AllowOverride All\n Order allow,deny\n Allow from all \n </Directory>\n Alias /myproject/ \"/xampp/sites/myproject/\"\n\n <Directory \"/xampp/sites/myproject\">\n AllowOverride None\n Options None\n Order allow,deny\n Allow from all\n </Directory>\n DocumentRoot \"/xampp/htdocs\"\n\n <Directory />\n Options FollowSymLinks\n AllowOverride None\n Order deny,allow\n Deny from all\n </Directory>\n\n <Directory \"/xampp/htdocs\">\n Options Indexes FollowSymLinks Includes ExecCGI\n AllowOverride All\n Order allow,deny\n Allow from all\n </Directory>\n" }, { "answer_id": 2879643, "author": "Nilanjan", "author_id": 346752, "author_profile": "https://Stackoverflow.com/users/346752", "pm_score": 0, "selected": false, "text": "NameVirtualHost myproject:80\n<VirtualHost myproject:80>\n DocumentRoot \"D:/Solution\"\n <Directory \"D:/Solution\">\n Options Indexes FollowSymLinks Includes ExecCGI\n AllowOverride All\n Order allow,deny\n Allow from all\n </Directory> \n</VirtualHost>\n" }, { "answer_id": 13417247, "author": "Stefan Michev", "author_id": 754571, "author_profile": "https://Stackoverflow.com/users/754571", "pm_score": 2, "selected": false, "text": "<IfModule alias_module>\n Alias /ddd \"D:/prj/customer/www\"\n\n <Directory \"D:/prj/customer/www\">\n Options Indexes FollowSymLinks Includes ExecCGI\n AllowOverride all\n Order allow,deny\n Allow from all\n </Directory>\n</IfModule>\n" }, { "answer_id": 21566403, "author": "4pi", "author_id": 2450246, "author_profile": "https://Stackoverflow.com/users/2450246", "pm_score": 1, "selected": false, "text": "<IfModule alias_module>\n Alias /angular-phonecat \"C:/DEV/git-workspace/angular-phonecat\"\n</IfModule>\n\n<Directory \"C:/DEV/git-workspace/angular-phonecat\">\n Options Indexes FollowSymLinks Includes ExecCGI\n AllowOverride all\n Order allow,deny\n Allow from all\n Require all granted\n</Directory>\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24197/" ]
269,363
<p>I have written a windows service using the Apache.NMS and Apcahe.NMS.ActiveMQ (version 1.0) libraries. The service consumes messages from ActiveMQ from a vendor server.</p> <p>The service spins up a connection and listens for messages (I handle the OnMessage event)</p> <p>The connection is a transacted connection so I call commit after each message.</p> <p>When the service starts up, everything works very well and does so for a while. However, after it has run for a while, it will no longer consume messages. Even if I reset the service. It usually takes a restart of my service AND the vendor server (tomcat) to get things going again. The vendor insists that nothing is wrong on their side.</p> <p>No exceptions are thrown on either side (client or server) - it's just 'stuck'.</p> <p>Should I consider using Spring.Messaging.Nms? </p>
[ { "answer_id": 302728, "author": "theGecko", "author_id": 39022, "author_profile": "https://Stackoverflow.com/users/39022", "pm_score": 0, "selected": false, "text": "ConnectionFactory connectionFactory = new ConnectionFactory(\"tcp://activemq:61616\");\n\nConnection connection = (Connection)connectionFactory.CreateConnection();\nconnection.Start();\n\nSession session = (Session)connection.CreateSession(AcknowledgementMode.AutoAcknowledge);\nIDestination queue = session.GetQueue(\"test.queue\");\n\nMessageConsumer consumer = (MessageConsumer)session.CreateConsumer(queue);\n\nfor (int i = 0; i < 1000; i++)\n{\n IMessage msg = consumer.Receive();\n if (msg != null)\n Console.WriteLine((msg as ITextMessage).Text);\n}\n" }, { "answer_id": 303710, "author": "HitLikeAHammer", "author_id": 35165, "author_profile": "https://Stackoverflow.com/users/35165", "pm_score": 1, "selected": false, "text": "factory = new Apache.NMS.ActiveMQ.ConnectionFactory(\"tcp://activemq:61616\");\n\nconnection = factory.QueueConnection(factory, \"MyQueue\", AcknowledgementMode.AutoAcknowledge)\n\nconsumer = connection.Session.CreateConsumer(connection.Queue, \"2 > 1\"); //Get every msg\n\nconsumer.Listener += new MessageListener(OnMessage);\n\n\nprivate void OnMessage(IMessage message)\n{\n //Process message here.;\n}\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35165/" ]
269,366
<p>Until this morning, I have had Apache 2.0 running as a service using a local account which was configured with appropriate permissions. Sometime yesterday, someone must have changed something, and now Apache 2.0 won't start as a service under this account.</p> <p>I made the account an Administrator temporarily, and Apache 2.0 starts fine.</p> <p>I tried following the access listed in the <a href="http://httpd.apache.org/docs/2.0/platform/windows.html" rel="nofollow noreferrer">official documentation</a>, but it seems to require more access. <strong>Does anyone know what access Apache 2.0 needs to start as a service?</strong></p> <p>I'm running Apache 2.0.63 with SVN 1.4.6 and mod_auth_sspi for windows domain authentication.</p> <p>I also checked the syntax of the configuration file from command-line using the <strong>-t</strong> parameter, but I received the message <strong>Syntax OK</strong>.</p> <p>Here's the error I get when starting as a service from command-line:</p> <pre> X:\>net start apache2 The Apache2 service is starting. The Apache2 service could not be started. A service specific error occurred: 1. More help is available by typing NET HELPMSG 3547. </pre>
[ { "answer_id": 302728, "author": "theGecko", "author_id": 39022, "author_profile": "https://Stackoverflow.com/users/39022", "pm_score": 0, "selected": false, "text": "ConnectionFactory connectionFactory = new ConnectionFactory(\"tcp://activemq:61616\");\n\nConnection connection = (Connection)connectionFactory.CreateConnection();\nconnection.Start();\n\nSession session = (Session)connection.CreateSession(AcknowledgementMode.AutoAcknowledge);\nIDestination queue = session.GetQueue(\"test.queue\");\n\nMessageConsumer consumer = (MessageConsumer)session.CreateConsumer(queue);\n\nfor (int i = 0; i < 1000; i++)\n{\n IMessage msg = consumer.Receive();\n if (msg != null)\n Console.WriteLine((msg as ITextMessage).Text);\n}\n" }, { "answer_id": 303710, "author": "HitLikeAHammer", "author_id": 35165, "author_profile": "https://Stackoverflow.com/users/35165", "pm_score": 1, "selected": false, "text": "factory = new Apache.NMS.ActiveMQ.ConnectionFactory(\"tcp://activemq:61616\");\n\nconnection = factory.QueueConnection(factory, \"MyQueue\", AcknowledgementMode.AutoAcknowledge)\n\nconsumer = connection.Session.CreateConsumer(connection.Queue, \"2 > 1\"); //Get every msg\n\nconsumer.Listener += new MessageListener(OnMessage);\n\n\nprivate void OnMessage(IMessage message)\n{\n //Process message here.;\n}\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2273/" ]
269,367
<p>I have a form which is used to <em>insert/display</em> and <em>update</em>. In the edit mode (<em>update</em>), when I pass my <code>BO</code> back to the Controller, what is the best possible way to check if any of the property values were changed, in order to execute the update to the datastore? </p> <pre><code>textbox1.text = CustomerController.GetCustomerInformation(id).Name </code></pre> <p>A customer object is returned from the controller. I need to check if the the object is dirty in order to execute an update. I would assume the object sent from the client has to be compared with the one sent from the controller when I do:</p> <pre><code>CustomerController.Save(customer) </code></pre> <p>How is this normally done?</p>
[ { "answer_id": 269371, "author": "vfilby", "author_id": 24279, "author_profile": "https://Stackoverflow.com/users/24279", "pm_score": 3, "selected": true, "text": "public string Name {\n get { return _name; }\n set {\n _name = value;\n _isDirty = true;\n }\n}\n Customer.IsDirty" }, { "answer_id": 269525, "author": "Panos", "author_id": 8049, "author_profile": "https://Stackoverflow.com/users/8049", "pm_score": 1, "selected": false, "text": "List<int> Address myCust.Address.City = \"...\" public bool IsDirty(object other)\n{\n if (other == null || this.GetType() != other.GetType())\n throw new ArgumentException(\"other\");\n\n foreach (PropertyInfo pi in this.GetType().GetProperties())\n {\n if (pi.GetValue(this, null) != pi.GetValue(other, null))\n return true;\n }\n return false;\n}\n Customer customer = new Customer();\n// ... set all properties\nif (customer.IsDirty(CustomerController.GetCustomerInformation(id)))\n CustomerController.Save(customer);\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23667/" ]
269,373
<p>I want to do something like this:</p> <pre><code>&lt;MyTemplate&gt; &lt;span&gt;&lt;%# Container.Title %&gt;&lt;/span&gt; &lt;MySubTemplate&gt; &lt;span&gt;&lt;%# Container.Username %&gt;&lt;/span&gt; &lt;/MySubTemplate&gt; &lt;/MyTemplate&gt; </code></pre> <p>Assuming I have a list of Titles that each have a list of Usernames.. If this is a correct approach how can I do this or what is a better way?</p>
[ { "answer_id": 273051, "author": "Max Schilling", "author_id": 29662, "author_profile": "https://Stackoverflow.com/users/29662", "pm_score": 2, "selected": true, "text": " <asp:Repeater ID=\"rptTitle\" runat=\"server\" >\n <ItemTemplate>\n <%# Eval(\"Title\") %>\n <asp:Repeater ID=\"rptUsers\" runat=\"server\" >\n <ItemTemplate>\n <%# Eval(\"UserName\") %>\n </ItemTemplate>\n </asp:Repeater>\n </ItemTemplate>\n </asp:Repeater>\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18926/" ]
269,390
<p>At the moment I have setup a custom ok cancel dialog with a drop down in c#. The ok and cancel buttons use the DialogResult property so no code behind it. What I now need to do is validate the drop down to check it isn't left empty before posting back a dialogresult.</p> <p>Is this possible?</p>
[ { "answer_id": 269396, "author": "Burkhard", "author_id": 12860, "author_profile": "https://Stackoverflow.com/users/12860", "pm_score": 3, "selected": true, "text": "private void Second_Closing(object sender, \n System.ComponentModel.CancelEventArgs e)\n{\n // When the user attempts to close the form, don't close it...\n e.Cancel = (dropdown.selecteditemindex >= 0);\n}\n" }, { "answer_id": 269415, "author": "Nathen Silver", "author_id": 6136, "author_profile": "https://Stackoverflow.com/users/6136", "pm_score": 1, "selected": false, "text": "private void OkButton_Clicked(object sender, EventArgs e)\n{\n this.DialogResult = ValueComboBox.SelectedIndex >= 0\n ? DialogResult.Ok\n : DialogResult.None;\n}\n" }, { "answer_id": 14145823, "author": "Anders Carstensen", "author_id": 1492977, "author_profile": "https://Stackoverflow.com/users/1492977", "pm_score": 1, "selected": false, "text": "private void OkButton_Clicked(object sender, EventArgs e)\n{\n if (!IsValid()) {\n this.DialogResult = System.Windows.Forms.DialogResult.None;\n }\n}\n IsValid()" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16989/" ]
269,402
<p>I've been asked to add Google e-commerce tracking into my site. This tracking involves inserting some javascript on your receipt page and then calling it's functions. From my asp.net receipt page, I need to call one function (_addTrans) for the transaction info and then another (_addItem) for each item on the order. An example of what they want is <a href="http://www.google.com/support/analytics/bin/answer.py?answer=55528" rel="nofollow noreferrer">here</a></p> <p>This is for a 1.1 site. Can anybody give me a jumpstart on calling these two functions from my c# code-behind? I can't imagine that I'm alone out there in needing to call Google e-commerce tracking, so I'm hopeful.</p>
[ { "answer_id": 269472, "author": "stevemegson", "author_id": 25028, "author_profile": "https://Stackoverflow.com/users/25028", "pm_score": 4, "selected": true, "text": "StringBuilder sb = new StringBuilder()\nsb.AppendLine( \"<script>\" );\nsb.AppendLine( \"var pageTracker = _gat._getTracker('UA-XXXXX-1');\" );\nsb.AppendLine( \"pageTracker._trackPageview();\" );\nsb.AppendFormat( \"pageTracker._addTrans('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}' );\\n\", orderId, affiliation, total, tax, shipping, city, state, country );\nsb.AppendFormat( \"pageTracker._addItem('{0}','{1}','{2}','{3}','{4}','{5}');\\n\", itemNumber, sku, productName, category, price, quantity );\nsb.AppendLine(\"pageTracker._trackTrans();\");\nsb.AppendLine( \"</script>\" );\n Page.RegisterStartupScript(\"someKey\", sb.ToString());\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3047/" ]
269,404
<p>I have been reading about the differences between Table Variables and Temp Tables and stumbled upon the following issue with the Table Variable. I did not see this issue mentioned in the articles I pursued. </p> <p>I pass in a series of PKs via a XML data type and successfully create the records in both temp table structures. When I attempt to update further fields in the temp tables the Table Variable fails but the Temp Table has no problem with the Update Statement. What do need to do different? I would like to take advantage of the speed boost that Table Variables promise…</p> <p>Here are the SP snippets and Results:</p> <pre><code>CREATE PROCEDURE ExpenseReport_AssignApprover ( @ExpenseReportIDs XML ) AS DECLARE @ERTableVariable TABLE ( ExpenseReportID INT, ExpenseReportProjectID INT, ApproverID INT) CREATE TABLE #ERTempTable ( ExpenseReportID INT, ExpenseReportProjectID INT, ApproverID INT ) INSERT INTO @ERTableVariable (ExpenseReportID) SELECT ParamValues.ID.value('.','VARCHAR(20)') FROM @ExpenseReportIDs.nodes('/Root/ExpenseReportID') as ParamValues(ID) INSERT INTO #ERTempTable (ExpenseReportID) SELECT ParamValues.ID.value('.','VARCHAR(20)') FROM @ExpenseReportIDs.nodes('/Root/ExpenseReportID') as ParamValues(ID) UPDATE #ERTempTable SET ExpenseReportProjectID = ( SELECT TOP 1 ExpenseReportProjectID FROM ExpenseReportItem WHERE(ExpenseReportID = #ERTempTable.ExpenseReportID)) UPDATE @ERTableVariable SET ExpenseReportProjectID = ( SELECT TOP 1 ExpenseReportProjectID FROM ExpenseReportItem WHERE(ExpenseReportID = @ERTableVariable.ExpenseReportID)) </code></pre> <p>Error when last update statement in there : Must declare the scalar variable "@ERTableVariable".</p> <p>ExpenseReportProjectID is updated in #ERTempTable when the last update is commented out:</p>
[ { "answer_id": 269418, "author": "TcKs", "author_id": 20382, "author_profile": "https://Stackoverflow.com/users/20382", "pm_score": 0, "selected": false, "text": "CREATE PROCEDURE ExpenseReport_AssignApprover\n(\n @ExpenseReportIDs XML\n)\nAS BEGIN\n\n\nDECLARE @ERTableVariable TABLE ( ExpenseReportID INT,\n ExpenseReportProjectID INT,\n ApproverID INT)\n\n\nCREATE TABLE #ERTempTable\n(\n ExpenseReportID INT,\n ExpenseReportProjectID INT,\n ApproverID INT\n)\n\nINSERT INTO @ERTableVariable (ExpenseReportID)\nSELECT ParamValues.ID.value('.','VARCHAR(20)')\nFROM @ExpenseReportIDs.nodes('/Root/ExpenseReportID') as ParamValues(ID)\n\nINSERT INTO #ERTempTable (ExpenseReportID)\nSELECT ParamValues.ID.value('.','VARCHAR(20)')\nFROM @ExpenseReportIDs.nodes('/Root/ExpenseReportID') as ParamValues(ID)\n\nUPDATE #ERTempTable\nSET ExpenseReportProjectID = ( SELECT TOP 1 ExpenseReportProjectID \n FROM ExpenseReportItem \n WHERE(ExpenseReportID = #ERTempTable.ExpenseReportID))\n\nUPDATE @ERTableVariable\nSET ExpenseReportProjectID = ( SELECT TOP 1 ExpenseReportProjectID \n FROM ExpenseReportItem \n WHERE(ExpenseReportID = @ERTableVariable.ExpenseReportID))\n\nEND\n" }, { "answer_id": 269994, "author": "Corbin March", "author_id": 7625, "author_profile": "https://Stackoverflow.com/users/7625", "pm_score": 5, "selected": true, "text": "UPDATE @ERTableVariable\n SET ExpenseReportProjectID = ( \n SELECT TOP 1 ExpenseReportProjectID\n FROM ExpenseReportItem \n WHERE ExpenseReportID = [@ERTableVariable].ExpenseReportID\n )\n UPDATE er SET \n ExpenseReportProjectID = ExpenseReportItem.ExpenseReportProjectID\nFROM @ERTableVariable er\nINNER JOIN ExpenseReportItem ON \n ExpenseReportItem.ExpenseReportID = er.ExpenseReportID\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30934/" ]
269,408
<p>We have Core2 machines (Dell T5400) with XP64.</p> <p>We observe that when running 32-bit processes, the performance of memcpy is on the order of 1.2GByte/s; however memcpy in a 64-bit process achieves about 2.2GByte/s (or 2.4GByte/s with the Intel compiler CRT's memcpy). While the initial reaction might be to just explain this away as due to the wider registers available in 64-bit code, we observe that our own memcpy-like SSE assembly code (which should be using 128-bit wide load-stores regardless of 32/64-bitness of the process) demonstrates similar upper limits on the copy bandwidth it achieves.</p> <p>My question is, what's this difference actually due to ? Do 32-bit processes have to jump through some extra WOW64 hoops to get at the RAM ? Is it something to do with TLBs or prefetchers or... what ?</p> <p>Thanks for any insight.</p> <p>Also raised on <a href="http://software.intel.com/en-us/forums/intel-avx-and-cpu-instructions/topic/63277/" rel="noreferrer">Intel forums</a>.</p>
[ { "answer_id": 269762, "author": "Mecki", "author_id": 15809, "author_profile": "https://Stackoverflow.com/users/15809", "pm_score": 3, "selected": false, "text": "mov eax, [address]\nmov [address2], eax\n mov rax, [address]\nmov [address2], rax\n mov reg, mem movdqa xmm1, [address]\nmovdqa [address2], xmm1\n movdqu xmm1, [address]\nmovdqu [address2], xmm1\n" }, { "answer_id": 536652, "author": "timday", "author_id": 24283, "author_profile": "https://Stackoverflow.com/users/24283", "pm_score": 3, "selected": false, "text": "memcpy(&dst[0],&src[0],dst.size()) memcpy(&dst[0],&src[0],N) const size_t N=512*(1<<20); __intel_fast_memcpy 000000014004ED80 lea rcx,[rcx+40h] \n 000000014004ED84 lea rdx,[rdx+40h] \n 000000014004ED88 lea r8,[r8-40h] \n 000000014004ED8C prefetchnta [rdx+180h] \n 000000014004ED93 movdqu xmm0,xmmword ptr [rdx-40h] \n 000000014004ED98 movdqu xmm1,xmmword ptr [rdx-30h] \n 000000014004ED9D cmp r8,40h \n 000000014004EDA1 movntdq xmmword ptr [rcx-40h],xmm0 \n 000000014004EDA6 movntdq xmmword ptr [rcx-30h],xmm1 \n 000000014004EDAB movdqu xmm2,xmmword ptr [rdx-20h] \n 000000014004EDB0 movdqu xmm3,xmmword ptr [rdx-10h] \n 000000014004EDB5 movntdq xmmword ptr [rcx-20h],xmm2 \n 000000014004EDBA movntdq xmmword ptr [rcx-10h],xmm3 \n 000000014004EDBF jge 000000014004ED80 \n memcpy(&dst[0],&src[0],dst.size()) __intel_fast_memcpy 004447A0 sub ecx,80h \n 004447A6 movdqa xmm0,xmmword ptr [esi] \n 004447AA movdqa xmm1,xmmword ptr [esi+10h] \n 004447AF movdqa xmmword ptr [edx],xmm0 \n 004447B3 movdqa xmmword ptr [edx+10h],xmm1 \n 004447B8 movdqa xmm2,xmmword ptr [esi+20h] \n 004447BD movdqa xmm3,xmmword ptr [esi+30h] \n 004447C2 movdqa xmmword ptr [edx+20h],xmm2 \n 004447C7 movdqa xmmword ptr [edx+30h],xmm3 \n 004447CC movdqa xmm4,xmmword ptr [esi+40h] \n 004447D1 movdqa xmm5,xmmword ptr [esi+50h] \n 004447D6 movdqa xmmword ptr [edx+40h],xmm4 \n 004447DB movdqa xmmword ptr [edx+50h],xmm5 \n 004447E0 movdqa xmm6,xmmword ptr [esi+60h] \n 004447E5 movdqa xmm7,xmmword ptr [esi+70h] \n 004447EA add esi,80h \n 004447F0 movdqa xmmword ptr [edx+60h],xmm6 \n 004447F5 movdqa xmmword ptr [edx+70h],xmm7 \n 004447FA add edx,80h \n 00444800 cmp ecx,80h \n 00444806 jge 004447A0\n memcpy(&dst[0],&src[0],N)\n const size_t N=512*(1<<20); __intel_VEC_memcpy\n 0043FF40 movdqa xmm0,xmmword ptr [esi] \n 0043FF44 movdqa xmm1,xmmword ptr [esi+10h] \n 0043FF49 movdqa xmm2,xmmword ptr [esi+20h] \n 0043FF4E movdqa xmm3,xmmword ptr [esi+30h] \n 0043FF53 movntdq xmmword ptr [edi],xmm0 \n 0043FF57 movntdq xmmword ptr [edi+10h],xmm1 \n 0043FF5C movntdq xmmword ptr [edi+20h],xmm2 \n 0043FF61 movntdq xmmword ptr [edi+30h],xmm3 \n 0043FF66 movdqa xmm4,xmmword ptr [esi+40h] \n 0043FF6B movdqa xmm5,xmmword ptr [esi+50h] \n 0043FF70 movdqa xmm6,xmmword ptr [esi+60h] \n 0043FF75 movdqa xmm7,xmmword ptr [esi+70h] \n 0043FF7A movntdq xmmword ptr [edi+40h],xmm4 \n 0043FF7F movntdq xmmword ptr [edi+50h],xmm5 \n 0043FF84 movntdq xmmword ptr [edi+60h],xmm6 \n 0043FF89 movntdq xmmword ptr [edi+70h],xmm7 \n 0043FF8E lea esi,[esi+80h] \n 0043FF94 lea edi,[edi+80h] \n 0043FF9A dec ecx \n 0043FF9B jne ___intel_VEC_memcpy+244h (43FF40h) \n _mm_stream_ps dst.size() movnt CPUID" }, { "answer_id": 4475715, "author": "GodLikeMOuse", "author_id": 546646, "author_profile": "https://Stackoverflow.com/users/546646", "pm_score": 0, "selected": false, "text": "void uint8copy(void *dest, void *src, size_t n){\n uint64_t * ss = (uint64_t)src;\n uint64_t * dd = (uint64_t)dest;\n n = n * sizeof(uint8_t)/sizeof(uint64_t); \n\n while(n--)\n *dd++ = *ss++;\n}//end uint8copy()\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269408", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24283/" ]
269,423
<p><strong>Is there a tool to generate WiX XML given a .reg file?</strong></p> <hr> <p>In 2.0, you were supposed to be able to run tallow to generate registry XML:</p> <pre><code>tallow -r my.reg </code></pre> <p>For what it's worth, the version of tallow I have is producing empty XML.</p> <p>In 3.0, tallow has been replaced with heat, but I can't figure out how to get it to produce output from a .reg file.</p> <p>Is there a way to do this in 3.0?</p>
[ { "answer_id": 270442, "author": "Adam Tegen", "author_id": 4066, "author_profile": "https://Stackoverflow.com/users/4066", "pm_score": 5, "selected": true, "text": "using System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.IO;\nusing System.Xml;\nusing System.Text.RegularExpressions;\n\nnamespace Reg2Wix\n{\n class Program\n {\n static void PrintUsage()\n {\n Console.WriteLine(\"reg2wix <input file> <output file>\");\n }\n\n /// <summary>\n /// Parse the hive out of a registry key\n /// </summary>\n /// <param name=\"keyWithHive\"></param>\n /// <param name=\"hive\"></param>\n /// <param name=\"key\"></param>\n static void ParseKey(string keyWithHive, out string hive, out string key)\n {\n if (keyWithHive == null)\n {\n throw new ArgumentNullException(\"keyWithHive\");\n }\n if (keyWithHive.StartsWith(\"HKEY_LOCAL_MACHINE\\\\\"))\n {\n hive = \"HKLM\";\n key = keyWithHive.Substring(19);\n }\n else if (keyWithHive.StartsWith(\"HKEY_CLASSES_ROOT\\\\\"))\n {\n hive = \"HKCR\";\n key = keyWithHive.Substring(18);\n }\n else if (keyWithHive.StartsWith(\"HKEY_USERS\\\\\"))\n {\n hive = \"HKU\";\n key = keyWithHive.Substring(11);\n }\n else if (keyWithHive.StartsWith(\"HKEY_CURRENT_USER\\\\\"))\n {\n hive = \"HKCU\";\n key = keyWithHive.Substring(18);\n }\n else\n {\n throw new ArgumentException();\n } \n }\n\n /// <summary>\n /// Write a WiX RegistryValue element for the specified key, name, and value\n /// </summary>\n /// <param name=\"writer\"></param>\n /// <param name=\"key\"></param>\n /// <param name=\"name\"></param>\n /// <param name=\"value\"></param>\n static void WriteRegistryValue(XmlWriter writer, string key, string name, string value)\n {\n if (writer == null)\n {\n throw new ArgumentNullException(\"writer\");\n }\n if (key == null)\n {\n throw new ArgumentNullException(\"key\");\n }\n if (value == null)\n {\n throw new ArgumentNullException(\"value\");\n }\n\n string hive;\n string keyPart;\n ParseKey(key, out hive, out keyPart);\n\n writer.WriteStartElement(\"RegistryValue\");\n\n writer.WriteAttributeString(\"Root\", hive);\n writer.WriteAttributeString(\"Key\", keyPart);\n if (!String.IsNullOrEmpty(name))\n {\n writer.WriteAttributeString(\"Name\", name);\n }\n writer.WriteAttributeString(\"Value\", value);\n writer.WriteAttributeString(\"Type\", \"string\");\n writer.WriteAttributeString(\"Action\", \"write\");\n\n writer.WriteEndElement();\n }\n\n /// <summary>\n /// Convert a .reg file into an XML document\n /// </summary>\n /// <param name=\"inputReader\"></param>\n /// <param name=\"xml\"></param>\n static void RegistryFileToWix(TextReader inputReader, XmlWriter xml)\n {\n Regex regexKey = new Regex(\"^\\\\[([^\\\\]]+)\\\\]$\");\n Regex regexValue = new Regex(\"^\\\"([^\\\"]+)\\\"=\\\"([^\\\"]*)\\\"$\");\n Regex regexDefaultValue = new Regex(\"@=\\\"([^\\\"]+)\\\"$\");\n\n string currentKey = null;\n\n string line;\n while ((line = inputReader.ReadLine()) != null)\n {\n line = line.Trim();\n Match match = regexKey.Match(line); \n if (match.Success)\n {\n //key track of the current key\n currentKey = match.Groups[1].Value;\n }\n else \n {\n //if we have a current key\n if (currentKey != null)\n {\n //see if this is an acceptable name=value pair\n match = regexValue.Match(line);\n if (match.Success)\n {\n WriteRegistryValue(xml, currentKey, match.Groups[1].Value, match.Groups[2].Value);\n }\n else\n {\n //see if this is an acceptable default value (starts with @)\n match = regexDefaultValue.Match(line);\n if (match.Success)\n {\n WriteRegistryValue(xml, currentKey, (string)null, match.Groups[1].Value);\n }\n }\n }\n }\n }\n }\n\n /// <summary>\n /// Convert a .reg file into a .wsx file\n /// </summary>\n /// <param name=\"inputPath\"></param>\n /// <param name=\"outputPath\"></param>\n static void RegistryFileToWix(string inputPath, string outputPath)\n {\n using (StreamReader reader = new StreamReader(inputPath))\n {\n using (XmlTextWriter writer = new XmlTextWriter(outputPath, Encoding.UTF8))\n {\n writer.Formatting = Formatting.Indented;\n writer.Indentation = 3;\n writer.IndentChar = ' ';\n writer.WriteStartDocument();\n writer.WriteStartElement(\"Component\");\n RegistryFileToWix(reader, writer);\n writer.WriteEndElement();\n writer.WriteEndDocument();\n }\n }\n }\n\n static void Main(string[] args)\n {\n if (args.Length != 2)\n {\n PrintUsage();\n return;\n }\n RegistryFileToWix(args[0], args[1]);\n }\n }\n}\n" }, { "answer_id": 739604, "author": "YONDERBOI", "author_id": 88919, "author_profile": "https://Stackoverflow.com/users/88919", "pm_score": 1, "selected": false, "text": "tallow -reg my.reg\n wixcop my.wxs -f\n" }, { "answer_id": 739612, "author": "YONDERBOI", "author_id": 88919, "author_profile": "https://Stackoverflow.com/users/88919", "pm_score": 3, "selected": false, "text": "using System;\nusing System.Globalization;\nusing System.IO;\nusing System.Reflection;\nusing System.Security.Cryptography;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Xml;\n\nnamespace AbsReg2Wix\n{\n public class Program\n {\n #region Constants\n\n private const string NS_URI = \"http://schemas.microsoft.com/wix/2006/wi\";\n private const string RegEditorVersionPattern = @\"Windows\\sRegistry\\sEditor\\sVersion\\s(?<RegEditorVersion>.*)\";\n private const string RegKeyPattern = @\"\\[(?<RegistryHive>[^\\\\]*)\\\\(?<RegistryKey>.*)\\]\";\n private const string RegNameValuePattern = \"\\\\\\\"(?<Name>.*)\\\\\\\"=(?<Value>\\\\\\\"?[^\\\\\\\\\\\\\\\"]*)(?<MultiLine>\\\\\\\\?)\";\n private const RegexOptions DefaultRegexOptions = RegexOptions.Multiline |\n RegexOptions.IgnorePatternWhitespace |\n RegexOptions.CultureInvariant;\n #endregion\n\n #region Methods\n\n /// <summary>\n /// Main applciation entry point\n /// </summary>\n /// <param name=\"args\">The args.</param>\n private static void Main(string[] args)\n {\n if (args.Length != 4)\n {\n PrintUsageInstructions();\n return;\n }\n\n if (File.Exists(args[1]))\n {\n ConvertRegistryFileToWix(args[1], args[3]);\n\n Console.WriteLine(\"Successfully completed conversion.\");\n Console.WriteLine(\"Press any key to continue...\");\n Console.ReadKey();\n }\n else\n {\n Console.WriteLine(@\"Input file {0} not found.\", args[1]);\n }\n }\n\n /// <summary>\n /// Prints the usage instructions.\n /// </summary>\n private static void PrintUsageInstructions()\n {\n Console.WriteLine(\"Syntax: AbsReg2Wix.exe /in <Input File (.reg)> /out <Output File>\");\n }\n\n /// <summary>\n /// Convert a .reg file into a .wsx file\n /// </summary>\n /// <param name=\"inputPath\">The input path.</param>\n /// <param name=\"outputPath\">The output path.</param>\n private static void ConvertRegistryFileToWix(string inputPath, string outputPath)\n {\n try\n {\n using (var reader = new StreamReader(inputPath))\n {\n string regEditorVersion = string.Empty;\n bool isRegEditorVersionFound = false;\n\n // Initialize Regex \n var regEditorVersionRegex = new Regex(RegEditorVersionPattern, DefaultRegexOptions);\n var regKeyRegex = new Regex(RegKeyPattern, DefaultRegexOptions);\n var regNameValueRegex = new Regex(RegNameValuePattern, DefaultRegexOptions);\n\n // Create xml document for output\n var xDoc = new XmlDocument();\n xDoc.AppendChild(xDoc.CreateProcessingInstruction(\"xml\", \"version=\\\"1.0\\\" encoding=\\\"utf-8\\\"\"));\n xDoc.AppendChild(xDoc.CreateComment(\n string.Format(\n \"{0}Following code was generated by AbsReg2Wix tool.{0}Tool Version: {1}{0}Date: {2}{0}Command Line: {3}\\n\",\n \"\\n\\t\", Assembly.GetExecutingAssembly().GetName().Version,\n DateTime.Now.ToString(\"F\"),\n Environment.CommandLine)));\n\n XmlElement includeElement = xDoc.CreateElement(\"Include\", NS_URI);\n XmlElement componentElement = null,\n regKeyElement = null,\n registryValueElement = null;\n\n bool multiLine = false;\n var rawValueBuilder = new StringBuilder();\n\n while (!reader.EndOfStream)\n {\n string regFileLine = reader.ReadLine().Trim();\n\n if (!isRegEditorVersionFound)\n {\n var regEditorVersionMatch = regEditorVersionRegex.Match(regFileLine);\n\n if (regEditorVersionMatch.Success)\n {\n regEditorVersion = regEditorVersionMatch.Groups[\"RegEditorVersion\"].Value;\n includeElement.AppendChild(\n xDoc.CreateComment(\"Registry Editor Version: \" + regEditorVersion));\n isRegEditorVersionFound = true;\n }\n }\n\n var regKeyMatch = regKeyRegex.Match(regFileLine);\n\n // Registry Key line found\n if (regKeyMatch.Success)\n {\n if (componentElement != null)\n {\n componentElement.AppendChild(regKeyElement);\n includeElement.AppendChild(componentElement);\n }\n\n componentElement = xDoc.CreateElement(\"Component\", NS_URI);\n\n var idAttr = xDoc.CreateAttribute(\"Id\");\n idAttr.Value = \"Comp_\" + GetMD5HashForString(regFileLine);\n componentElement.Attributes.Append(idAttr);\n\n var guidAttr = xDoc.CreateAttribute(\"Guid\");\n guidAttr.Value = Guid.NewGuid().ToString();\n componentElement.Attributes.Append(guidAttr);\n\n regKeyElement = xDoc.CreateElement(\"RegistryKey\", NS_URI);\n\n var hiveAttr = xDoc.CreateAttribute(\"Root\");\n hiveAttr.Value = GetShortHiveName(regKeyMatch.Groups[\"RegistryHive\"].Value);\n regKeyElement.Attributes.Append(hiveAttr);\n\n var keyAttr = xDoc.CreateAttribute(\"Key\");\n keyAttr.Value = regKeyMatch.Groups[\"RegistryKey\"].Value;\n regKeyElement.Attributes.Append(keyAttr);\n\n var actionAttr = xDoc.CreateAttribute(\"Action\");\n actionAttr.Value = \"createAndRemoveOnUninstall\";\n regKeyElement.Attributes.Append(actionAttr);\n }\n\n var regNameValueMatch = regNameValueRegex.Match(regFileLine);\n\n // Registry Name/Value pair line found\n if (regNameValueMatch.Success)\n {\n registryValueElement = xDoc.CreateElement(\"RegistryValue\", NS_URI);\n\n var nameAttr = xDoc.CreateAttribute(\"Name\");\n nameAttr.Value = regNameValueMatch.Groups[\"Name\"].Value;\n registryValueElement.Attributes.Append(nameAttr);\n\n var actionAttr = xDoc.CreateAttribute(\"Action\");\n actionAttr.Value = \"write\";\n registryValueElement.Attributes.Append(actionAttr);\n\n if (string.IsNullOrEmpty(regNameValueMatch.Groups[\"MultiLine\"].Value))\n {\n string valueType, actualValue;\n\n ParseRegistryValue(regNameValueMatch.Groups[\"Value\"].Value, out valueType,\n out actualValue);\n\n var typeAttr = xDoc.CreateAttribute(\"Type\");\n typeAttr.Value = valueType;\n registryValueElement.Attributes.Append(typeAttr);\n\n var valueAttr = xDoc.CreateAttribute(\"Value\");\n valueAttr.Value = actualValue;\n registryValueElement.Attributes.Append(valueAttr);\n regKeyElement.AppendChild(registryValueElement);\n }\n else\n {\n multiLine = true;\n rawValueBuilder.Append(regNameValueMatch.Groups[\"Value\"].Value\n .Replace(\"\\\\\", string.Empty));\n }\n }\n else if (multiLine)\n {\n if (regFileLine.IndexOf(\"\\\\\") != -1)\n {\n rawValueBuilder.Append(regFileLine.Replace(\"\\\\\", string.Empty));\n }\n else\n {\n rawValueBuilder.Append(regFileLine);\n\n string valueType, actualValue;\n ParseRegistryValue(rawValueBuilder.ToString(), out valueType, out actualValue);\n\n var typeAttr = xDoc.CreateAttribute(\"Type\");\n typeAttr.Value = valueType;\n registryValueElement.Attributes.Append(typeAttr);\n\n var valueAttr = xDoc.CreateAttribute(\"Value\");\n valueAttr.Value = actualValue;\n registryValueElement.Attributes.Append(valueAttr);\n regKeyElement.AppendChild(registryValueElement);\n\n rawValueBuilder.Remove(0, rawValueBuilder.Length);\n multiLine = false;\n }\n }\n }\n\n if (componentElement != null)\n {\n componentElement.AppendChild(regKeyElement);\n includeElement.AppendChild(componentElement);\n }\n\n xDoc.AppendChild(includeElement);\n xDoc.Save(outputPath);\n }\n }\n catch (Exception ex)\n {\n Console.WriteLine(ex.Message);\n }\n }\n\n /// <summary>\n /// Parses the registry value.\n /// </summary>\n /// <param name=\"rawValue\">The raw value.</param>\n /// <param name=\"valueType\">Type of the value.</param>\n /// <param name=\"actualValue\">The actual value.</param>\n private static void ParseRegistryValue(string rawValue, out string valueType, out string actualValue)\n {\n if (rawValue.IndexOf(\"\\\"\") != -1)\n {\n valueType = \"string\";\n actualValue = rawValue.Substring(1, rawValue.Length - 2);\n }\n else if (rawValue.IndexOf(\"dword:\") != -1)\n {\n valueType = \"integer\";\n actualValue = rawValue.Replace(\"dword:\", string.Empty);\n }\n else if (rawValue.IndexOf(\"hex:\") != -1)\n {\n valueType = \"binary\";\n actualValue = rawValue.Replace(\"hex:\", string.Empty)\n .Replace(\",\", string.Empty)\n .ToUpper();\n }\n else if (rawValue.IndexOf(\"hex(7):\") != -1)\n {\n valueType = \"multiString\";\n\n string[] hexStrings = rawValue.Replace(\"hex(7):\", string.Empty).Split(',');\n var bytes = new byte[hexStrings.Length];\n\n for (int i = 0; i < hexStrings.Length; i++)\n {\n bytes[i] = byte.Parse(hexStrings[i], NumberStyles.HexNumber);\n }\n\n actualValue = Encoding.Unicode.GetString(bytes).Replace(\"\\0\", \"[~]\");\n }\n else\n {\n valueType = \"string\";\n actualValue = rawValue;\n }\n }\n\n /// <summary>\n /// Gets the short name of the registry hive.\n /// </summary>\n /// <param name=\"fullHiveName\">Full name of the hive.</param>\n /// <returns></returns>\n private static string GetShortHiveName(string fullHiveName)\n {\n switch (fullHiveName)\n {\n case \"HKEY_LOCAL_MACHINE\":\n return \"HKLM\";\n case \"HKEY_CLASSES_ROOT\":\n return \"HKCR\";\n case \"HKEY_USERS\":\n return \"HKU\";\n case \"HKEY_CURRENT_USER\":\n return \"HKCU\";\n default:\n throw new ArgumentException(string.Format(\"Registry Hive unsupported by Wix: {0}.\",\n fullHiveName));\n }\n }\n\n /// <summary>\n /// Gets the MD5 hash for string.\n /// </summary>\n /// <param name=\"inputString\">The input string.</param>\n /// <returns></returns>\n private static string GetMD5HashForString(string inputString)\n {\n MD5 hashAlg = MD5.Create();\n byte[] originalInBytes = Encoding.ASCII.GetBytes(inputString);\n byte[] hashedOriginal = hashAlg.ComputeHash(originalInBytes);\n\n String outputString = Convert.ToBase64String(hashedOriginal)\n .Replace(\"/\", \"aa\")\n .Replace(\"+\", \"bb\")\n .Replace(\"=\", \"cc\");\n\n return outputString;\n }\n\n #endregion\n }\n}\n" }, { "answer_id": 970732, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": " if (rawValue.IndexOf(\"\\\"\") != -1)\n {\n valueType = \"string\";\n if (rawValue.Length > 1)\n {\n actualValue = rawValue.Substring(1, rawValue.Length - 2);\n }\n else\n {\n actualValue = \"\";\n }\n }\n" }, { "answer_id": 12844011, "author": "Ujjwal Singh", "author_id": 483588, "author_profile": "https://Stackoverflow.com/users/483588", "pm_score": 3, "selected": false, "text": "Heat.exe" }, { "answer_id": 50223070, "author": "Malcolm McCaffery", "author_id": 941548, "author_profile": "https://Stackoverflow.com/users/941548", "pm_score": 1, "selected": false, "text": "C:\\Program Files (x86)\\WiX Toolset v4.0\\bin>heat /? | find /i \"reg\"\n reg harvest a .reg file\n -sreg suppress registry harvesting\n heat reg regfile.reg -o fragment.xml\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4066/" ]
269,425
<p>When I right-click a solution in VS2008 and select Check In... I am presented with a list of changed files with check boxes and a comment area. (This is done against TFS.)</p> <p>Our check-in process requires that we enter this list of changed files into the bug tracking ticket. This requires typing in the name of each each file: time-consuming and error prone.</p> <p>Ideally I'd like to be able to select that list and copy it to the clipboard so that I can paste it into the bug tracking system.</p> <p>Does anybody have a way that I can easily get that list into the clipboard?</p>
[ { "answer_id": 269484, "author": "TcKs", "author_id": 20382, "author_profile": "https://Stackoverflow.com/users/20382", "pm_score": 2, "selected": false, "text": " string strServer = startInfo.Server;\n string strWorkspace = startInfo.Workspace;\n\n Microsoft.TeamFoundation.Client.TeamFoundationServer tfsServer = null;\n if ( false == string.IsNullOrEmpty( strServer ) ) {\n tfsServer = new Microsoft.TeamFoundation.Client.TeamFoundationServer( startInfo.Server );\n tfsServer.Authenticate();\n }\n\n Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer vcServer = null;\n if ( tfsServer != null ) {\n object obj = tfsServer.GetService( typeof( Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer ) );\n vcServer = obj as Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer;\n }\n\n Microsoft.TeamFoundation.VersionControl.Client.Workspace workspace = null;\n if ( tfsServer != null && vcServer != null && false == string.IsNullOrEmpty( strWorkspace ) ) {\n workspace = vcServer.GetWorkspace( strWorkspace, tfsServer.AuthenticatedUserName );\n }\n\n List<string> pendingItems = new List<string>();\n foreach ( Microsoft.TeamFoundation.VersionControl.Client.WorkingFolder folder in workspace.Folders ) {\n pendingItems.Add( folder.ServerItem );\n }\n\n List<string> localFilePaths = new List<string>();\n string userName = tfsServer.AuthenticatedUserIdentity.AccountName;\n Microsoft.TeamFoundation.VersionControl.Client.PendingSet[] pendingSets = workspace.QueryPendingSets( pendingItems.ToArray(), Microsoft.TeamFoundation.VersionControl.Client.RecursionType.Full, null, userName, false );\n foreach ( Microsoft.TeamFoundation.VersionControl.Client.PendingSet ps in pendingSets ) {\n foreach ( Microsoft.TeamFoundation.VersionControl.Client.PendingChange change in ps.PendingChanges ) {\n localFilePaths.Add( change.LocalItem );\n }\n }\n" }, { "answer_id": 32002067, "author": "Ramesh", "author_id": 30594, "author_profile": "https://Stackoverflow.com/users/30594", "pm_score": 1, "selected": false, "text": "CTRL+C" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
269,436
<p>I have set a canvas' background to an image of a company logo. I would like for this image to be aligned to the bottom right corner of the canvas.<br> Is it possible to do this, or would it require for the image to be added into the canvas as a child? That would not work with this program as all children of the canvas are handled differently.</p> <p>Thank You</p>
[ { "answer_id": 269514, "author": "Gishu", "author_id": 1695, "author_profile": "https://Stackoverflow.com/users/1695", "pm_score": 0, "selected": false, "text": "<Window x:Class=\"HelloWPF.Window1\" xmlns...\n Title=\"Window1\" Height=\"300\" Width=\"339\">\n <Canvas>\n <Image Canvas.Left=\"195\" Canvas.Top=\"175\" Height=\"87\" Name=\"image1\" Stretch=\"Fill\" Width=\"122\" Source=\"dilbert2666700071126ni1.gif\"/>\n </Canvas>\n</Window>\n" }, { "answer_id": 270871, "author": "Alan Le", "author_id": 1133, "author_profile": "https://Stackoverflow.com/users/1133", "pm_score": 0, "selected": false, "text": "<Window ...>\n <Grid>\n <Canvas/>\n <Image HorizontalAlignment=\"Right\" VerticalAlignment=\"Bottom\" .../>\n <Grid>\n</Window>\n" }, { "answer_id": 270883, "author": "Ryan Lundy", "author_id": 5486, "author_profile": "https://Stackoverflow.com/users/5486", "pm_score": 5, "selected": true, "text": " <Canvas>\n <Canvas.Background>\n <ImageBrush ImageSource=\"someimage.jpg\" AlignmentX=\"Right\" \n AlignmentY=\"Bottom\" Stretch=\"None\" />\n </Canvas.Background>\n </Canvas>\n" }, { "answer_id": 15619342, "author": "Enrique Marco", "author_id": 2208251, "author_profile": "https://Stackoverflow.com/users/2208251", "pm_score": 0, "selected": false, "text": "<Canvas x:Name=\"MiCanvas\" Height=\"250\" Width=\"500\" Background=\"Aqua\">\n <Border x:Name=\"MiBorderImage\" \n Width=\"{Binding ElementName=MiCanvas, Path=ActualWidth}\"\n Height=\"{Binding ElementName=MiCanvas, Path=ActualHeight}\"\n Background=\"Transparent\">\n <Image x:Name=\"MiImage\" Source=\"/GraphicsLibrary/Logos/MiLogo.png\"\n HorizontalAlignment=\"Right\" \n VerticalAlignment=\"Bottom\" \n Stretch=\"None\" />\n </Border>\n </Canvas>\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269436", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30838/" ]
269,440
<p>I have the following query:</p> <pre><code>UPDATE lessonstatus INNER JOIN user ON lessonstatus.user_id = user.user_id SET user_id = (SELECT user_id FROM user WHERE username = 'too_many_accounts') WHERE last_name = 'stupid' AND first_name = 'user' AND username != 'too_many_accounts' AND lessonstatus.lesson_id NOT IN (SELECT lesson_id FROM lessonstatus WHERE user_id = 1); </code></pre> <p>However, I get the following error when trying to execute it:</p> <pre><code>Error Code : 1093 You can't specify target table 'lessonstatus_rtab' for update in FROM clause </code></pre> <p>How would I fix this query so that it works?</p>
[ { "answer_id": 269471, "author": "Arvo", "author_id": 35777, "author_profile": "https://Stackoverflow.com/users/35777", "pm_score": 0, "selected": false, "text": "UPDATE lessonstatus\nSET user_id = (SELECT TOP 1 user_id FROM user WHERE username = 'too_many_accounts')\nFROM lessonstatus\n INNER JOIN user ON lessonstatus.user_id = user_rtab.user_id\nWHERE last_name = 'stupid' \n AND first_name = 'user'\n AND username != 'too_many_accounts'\n AND lessonstatus.lesson_id NOT IN (\n SELECT lesson_id FROM lessonstatus WHERE user_id = 1\n );\n" }, { "answer_id": 269546, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 3, "selected": true, "text": "SELECT user lessonstatus UPDATE NOT IN LEFT OUTER JOIN NOT IN UPDATE lessonstatus l1\n INNER JOIN user u1 ON (l1.user_id = u1.user_id)\n INNER JOIN user u2 ON (u2.username = 'too_many_accounts')\n LEFT OUTER JOIN lessonstatus l2 \n ON (l1.lesson_id = l2.lesson_id AND l2.user_id = 1)\nSET l1.user_id = u2.user_id\nWHERE u1.last_name = 'stupid' AND u1.first_name = 'user'\n AND u1.username != 'too_many_accounts'\n AND l2.lesson_id IS NULL; -- equivalent to \"l NOT IN l2\"\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20178/" ]
269,456
<p>We are rolling out a site for a client using IIS tomorrow. </p> <p>I am to take the site down to the general public (Sorry, we are updating message) and allow the client to test over the weekend after we perform the upgrade.</p> <p>If it is successful, I open it to everbody - if not, I rollback.</p> <p>What is the easiest way to put a "We're not open" sign for the general public, but leave the rest open to testers?</p>
[ { "answer_id": 269998, "author": "Tim Farley", "author_id": 4425, "author_profile": "https://Stackoverflow.com/users/4425", "pm_score": 3, "selected": false, "text": "app_offline.htm\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16794/" ]
269,458
<p>Ages ago when I was a java developer I could make separate ant scripts that I would call from my main ant script. I would put properties unique to each environment where my main script would run. I want to do the same thing in MSBuild but I can't find out how to chain MSBuild scripts together.</p>
[ { "answer_id": 269482, "author": "Scott Dorman", "author_id": 1559, "author_profile": "https://Stackoverflow.com/users/1559", "pm_score": 3, "selected": true, "text": " <Import Project=\"MyTargets\" Condition=\"Exists('MyTargets')\"/>\n" }, { "answer_id": 269498, "author": "Cristian Libardo", "author_id": 16526, "author_profile": "https://Stackoverflow.com/users/16526", "pm_score": 1, "selected": false, "text": "<MSBuild Projects=\"Other.proj\" Properties=\"SomeProp=$(MyProperty)\" />\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4491/" ]
269,462
<p>I'm doing some small changes to C++ MFC project. I'm .NET developer so Windows programming is new to me.</p> <p>I need to launch some method right after CDialog is completely shown (painted) for the first time, but only once.</p> <p>How can I do this? In .NET I would handle <strong>Form.Shown</strong> event.</p> <p>Do I need to handle some message? Which? Do I need to override some CDialog method? Or is there no easy way? I'm thinking of handling WM_ACTIVATE and then using a flag to ensure I call another method only once.</p>
[ { "answer_id": 269850, "author": "Sumrak", "author_id": 19124, "author_profile": "https://Stackoverflow.com/users/19124", "pm_score": 3, "selected": true, "text": "Short story:\nINT_PTR CALLBACK\nDlgProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)\n{\n switch (uiMsg) {\n\n case WM_INITDIALOG:\n return TRUE;\n\n case WM_WINDOWPOSCHANGED:\n if ((((WINDOWPOS*)lParam)->flags & SWP_SHOWWINDOW) &&\n !g_fShown) {\n g_fShown = TRUE;\n PostMessage(hwnd, WM_APP, 0, 0);\n }\n break;\n\n\n case WM_APP:\n MessageBox(hwnd,\n IsWindowVisible(hwnd) ? TEXT(\"Visible\")\n : TEXT(\"Not Visible\"),\n TEXT(\"Title\"), MB_OK);\n break;\n\n case WM_CLOSE:\n EndDialog(hwnd, 0);\n break;\n }\n\n return FALSE;\n}\n" }, { "answer_id": 60402071, "author": "SteveH", "author_id": 12962350, "author_profile": "https://Stackoverflow.com/users/12962350", "pm_score": 1, "selected": false, "text": " ON_WM_WINDOWPOSCHANGED()\n ON_MESSAGE(MyCDialog::MY_USER_MSG, OnDialogShown)\n\nvoid MyCDialog::OnWindowPosChanged(WINDOWPOS *wndpos)\n{\n __super::OnWindowPosChanged(wndpos);\n\n if (!mDialogShown && (wndpos->flags & SWP_SHOWWINDOW)) {\n PostMessage(MY_USER_MSG);\n mDialogShown = true;\n }\n}\n\nLRESULT MyCDialog::OnDialogShown(WPARAM, LPARAM)\n{\n ...\n}\n\n" } ]
2008/11/06
[ "https://Stackoverflow.com/questions/269462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19124/" ]