qid
int64 4
19.1M
| question
stringlengths 18
48.3k
| answers
list | date
stringlengths 10
10
| metadata
list |
|---|---|---|---|---|
220,188
|
<p><a href="http://www.w3.org/TR/REC-html40/interact/scripts.html" rel="noreferrer"><strong>According to spec</strong></a>, only the <code>BODY</code> and <code>FRAMESET</code> elements provide an "onload" event to attach to, but I would like to know when a dynamically-created DOM element has been added to the DOM in JavaScript.</p>
<p>The super-naive heuristics I am currently using, which work, are as follows:</p>
<ul>
<li>Traverse the <strong>parentNode</strong> property of the element back until I find the ultimate ancestor (i.e. parentNode.parentNode.parentNode.etc until parentNode is null)<br /><br /></li>
<li>If the ultimate ancestor has a defined, non-null <strong>body</strong> property<br /><br />
<ul>
<li>assume the element in question is part of the dom</li>
</ul></li>
<li>else<br /><br />
<ul>
<li>repeat these steps again in 100 milliseconds</li>
</ul></li>
</ul>
<p>What I am after is either confirmation that what I am doing is sufficient (again, it is working in both IE7 and FF3) or a better solution that, for whatever reason, I have been completely oblivious to; perhaps other properties I should be checking, etc.</p>
<hr>
<p>EDIT: I want a browser-agnostic way of doing this, I don't live in a one-browser world, unfortunately; that said, browser-specific information is appreciated, but please note which browser you know that it <em>does</em> work in. Thanks!</p>
|
[
{
"answer_id": 220192,
"author": "eyelidlessness",
"author_id": 17964,
"author_profile": "https://Stackoverflow.com/users/17964",
"pm_score": 1,
"selected": false,
"text": "DOMNodeInserted DOMNodeInsertedIntoDocument"
},
{
"answer_id": 220224,
"author": "Darryl Hein",
"author_id": 5441,
"author_profile": "https://Stackoverflow.com/users/5441",
"pm_score": 3,
"selected": false,
"text": "document.getElementById('newElementId');"
},
{
"answer_id": 220893,
"author": "Leo",
"author_id": 20689,
"author_profile": "https://Stackoverflow.com/users/20689",
"pm_score": 2,
"selected": false,
"text": "var append = function(parent, child, onAppend) {\n parent.appendChild(child);\n if (onAppend) onAppend(child);\n}\n\n//inserts a div into body and adds the class \"created\" upon insertion\nappend(document.body, document.createElement(\"div\"), function(el) {\n el.className = \"created\";\n});\n"
},
{
"answer_id": 222441,
"author": "Borgar",
"author_id": 27388,
"author_profile": "https://Stackoverflow.com/users/27388",
"pm_score": 2,
"selected": false,
"text": "document.body.innerHTML .innerHTML .offsetParent .parentNode compareDocumentIndex() .sourceIndex"
},
{
"answer_id": 850995,
"author": "Jason Bunting",
"author_id": 1790,
"author_profile": "https://Stackoverflow.com/users/1790",
"pm_score": 6,
"selected": true,
"text": "function isInDOMTree(node) {\n // If the farthest-back ancestor of our node has a \"body\"\n // property (that node would be the document itself), \n // we assume it is in the page's DOM tree.\n return !!(findUltimateAncestor(node).body);\n}\nfunction findUltimateAncestor(node) {\n // Walk up the DOM tree until we are at the top (parentNode \n // will return null at that point).\n // NOTE: this will return the same node that was passed in \n // if it has no ancestors.\n var ancestor = node;\n while(ancestor.parentNode) {\n ancestor = ancestor.parentNode;\n }\n return ancestor;\n}\n onload function executeOnLoad(node, func) {\n // This function will check, every tenth of a second, to see if \n // our element is a part of the DOM tree - as soon as we know \n // that it is, we execute the provided function.\n if(isInDOMTree(node)) {\n func();\n } else {\n setTimeout(function() { executeOnLoad(node, func); }, 100);\n }\n}\n var mySpan = document.createElement(\"span\");\nmySpan.innerHTML = \"Hello world!\";\nexecuteOnLoad(mySpan, function(node) { \n alert('Added to DOM tree. ' + node.innerHTML);\n});\n\n// now, at some point later in code, this\n// node would be appended to the document\ndocument.body.appendChild(mySpan);\n\n// sometime after this is executed, but no more than 100 ms after,\n// the anonymous function I passed to executeOnLoad() would execute\n"
},
{
"answer_id": 13725984,
"author": "Chris Calo",
"author_id": 101869,
"author_profile": "https://Stackoverflow.com/users/101869",
"pm_score": 4,
"selected": false,
"text": "Node.contains var el = document.createElement(\"div\");\nconsole.log(document.body.contains(el)); // false\ndocument.body.appendChild(el);\nconsole.log(document.body.contains(el)); // true\ndocument.body.removeChild(el);\nconsole.log(document.body.contains(el)); // false\n document.contains(el) document.body.contains(el) setTimeout(function test() {\n if (document.body.contains(node)) {\n func();\n } else {\n setTimeout(test, 50);\n }\n}, 50);\n"
},
{
"answer_id": 15845595,
"author": "ydaniv",
"author_id": 531132,
"author_profile": "https://Stackoverflow.com/users/531132",
"pm_score": 3,
"selected": false,
"text": "element.ownerDocument element.ownerDocument.body.contains(element)\n"
},
{
"answer_id": 15938845,
"author": "user1403517",
"author_id": 1403517,
"author_profile": "https://Stackoverflow.com/users/1403517",
"pm_score": 0,
"selected": false,
"text": "var finalElement=null; \n lastDomObject finalElement=lastDomObject; \n while (!finalElement) { } //this is the delay... \n"
},
{
"answer_id": 48514909,
"author": "Elliot B.",
"author_id": 1215133,
"author_profile": "https://Stackoverflow.com/users/1215133",
"pm_score": 2,
"selected": false,
"text": "MutationObserver var myElement = $(\"<div>hello world</div>\")[0];\n\nvar observer = new MutationObserver(function(mutations) {\n if (document.contains(myElement)) {\n console.log(\"It's in the DOM!\");\n observer.disconnect();\n }\n});\n\nobserver.observe(document, {attributes: false, childList: true, characterData: false, subtree:true});\n\n$(\"body\").append(myElement); // console.log: It's in the DOM!\n observer document contains myElement document mutations document.contains myElement document myElement"
}
] |
2008/10/20
|
[
"https://Stackoverflow.com/questions/220188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1790/"
] |
220,202
|
<p>The subject doesn't say much cause it is not easy to question in one line.
I have to execute a few programs which I read from the registry. I have to read from a field where somebody saves the whole paths and arguments.<br>
I've been using System.Diagnostics.ProcessStartInfo setting the name of the program and its arguments but I've found a wide variety of arguments which I have to parse to save the process executable file in one field and its arguments in the other. </p>
<p>Is there a way to just execute the whole string as is?</p>
|
[
{
"answer_id": 220553,
"author": "Danny Frencham",
"author_id": 29830,
"author_profile": "https://Stackoverflow.com/users/29830",
"pm_score": 4,
"selected": true,
"text": "Process myProcess = New Process;\nmyProcess.StartInfo.FileName = \"cmd.exe\";\nmyProcess.StartInfo.Arguments = \"/C \" + cmd;\nmyProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;\nmyProcess.StartInfo.CreateNoWindow = True;\nmyProcess.Start();\nmyProcess.WaitForExit();\nmyProcess.Close();\n"
},
{
"answer_id": 800680,
"author": "Luke Quinane",
"author_id": 18437,
"author_profile": "https://Stackoverflow.com/users/18437",
"pm_score": 0,
"selected": false,
"text": "var processStartInfo = new ProcessStartInfo()\n{\n UseShellExecute = false,\n Arguments = cmd\n};\nProcess.Start(processStartInfo);\n"
}
] |
2008/10/20
|
[
"https://Stackoverflow.com/questions/220202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23893/"
] |
220,203
|
<p>Or if any body knows of an alternative control that does?</p>
<p>It would be handy to serve up content to the WebBrowser control that has embedded images & other resources from a database without having a dependency on these resources being hosted on a webserver or to create temporary files on the local file system.</p>
<p>Mhtml supports this but doesn't seem to work in a WebBrowser control when using the DocumentText property?</p>
|
[
{
"answer_id": 220239,
"author": "sbeskur",
"author_id": 10446,
"author_profile": "https://Stackoverflow.com/users/10446",
"pm_score": 1,
"selected": false,
"text": "this.webBrowser1.Url = new System.Uri(@\"C:\\TempFiles\\MyTest.mht\");\n"
}
] |
2008/10/20
|
[
"https://Stackoverflow.com/questions/220203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29799/"
] |
220,211
|
<p>I'm creating a web application for work where the user has to enter the name of the person that requested the job. I'd like to create a simple AJAX auto-suggest dropdown so they don't need to type the entire name. On the backend, the database will provide suggestions based on previous entries. The website is built using CakePHP 1.1.</p>
<p>I know there are a lot of libraries out there, some better than others. Which do you think is the fastest and easiest to implement?</p>
|
[
{
"answer_id": 220264,
"author": "Paolo Bergantino",
"author_id": 16417,
"author_profile": "https://Stackoverflow.com/users/16417",
"pm_score": 4,
"selected": true,
"text": "function autocomplete () {\n $this->set('people',\n $this->Person->findAll(\"name LIKE '%{$this->data['Person']['name']}%'\")\n );\n $this->layout = \"ajax\";\n}\n autocomplete.thtml <ul>\n<?php foreach($people as $person): ?>\n<li><?php echo $person['Person']['name']; ?></li>\n<?php endforeach; ?>\n</ul>\n <form action=\"/people/index\" method=\"POST\">\n<?php echo $ajax->autoComplete('Person/name', '/people/autocomplete/')?>\n<?php echo $html->submit('View Person')?>\n</form>\n helpers"
}
] |
2008/10/20
|
[
"https://Stackoverflow.com/questions/220211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5982/"
] |
220,229
|
<p>I'm looking for Ruby's Active record for PHP. Something that is so simple that I just define my fields, extend the base ORM class, and I get ACID operations for free. I should get default getters and setters without writing any code, but overriding a default getter or setter is as easy as declaring get$fieldName or set$fieldName functions with the behavior I want. Symphony makes you create about 5 files per object, and all defined objects always load as far as I can tell. What is a better alternative? Why is it better? Can you put simple examples in your answers please?</p>
<p>Doctrine is another ORM I've looked at besides symphony . There also you need to create yaml files that describe your data structures. The database already defines this stuff. What will just read my table defs without having to generate and store config files everywhere?</p>
|
[
{
"answer_id": 223836,
"author": "dcousineau",
"author_id": 20265,
"author_profile": "https://Stackoverflow.com/users/20265",
"pm_score": 4,
"selected": false,
"text": "./doctrine build-all-reload ./doctrine generate-models-db ./doctrine generate-yaml-db $object->save()"
}
] |
2008/10/20
|
[
"https://Stackoverflow.com/questions/220229",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2112692/"
] |
220,231
|
<p>How do I access a page's HTTP response headers via JavaScript?</p>
<p>Related to <a href="https://stackoverflow.com/questions/220149/how-do-i-access-the-http-request-header-fields-via-javascript"><strong>this question</strong></a>, which was modified to ask about accessing two specific HTTP headers.</p>
<blockquote>
<p><strong>Related:</strong><br>
<a href="https://stackoverflow.com/questions/220149/how-do-i-access-the-http-request-header-fields-via-javascript">How do I access the HTTP request header fields via JavaScript?</a></p>
</blockquote>
|
[
{
"answer_id": 220233,
"author": "keparo",
"author_id": 19468,
"author_profile": "https://Stackoverflow.com/users/19468",
"pm_score": 9,
"selected": true,
"text": "getAllResponseHeaders() fetchSimilarHeaders() myXMLHttpRequest.getAllResponseHeaders();\n getAllResponseHeaders() XMLHttpRequest getallresponseheaders() XMLHttpRequest function fetchSimilarHeaders (callback) {\n var request = new XMLHttpRequest();\n request.onreadystatechange = function () {\n if (request.readyState === XMLHttpRequest.DONE) {\n //\n // The following headers may often be similar\n // to those of the original page request...\n //\n if (callback && typeof callback === 'function') {\n callback(request.getAllResponseHeaders());\n }\n }\n };\n\n //\n // Re-request the same page (document.location)\n // We hope to get the same or similar response headers to those which \n // came with the current page, but we have no guarantee.\n // Since we are only after the headers, a HEAD request may be sufficient.\n //\n request.open('HEAD', document.location, true);\n request.send(null);\n}\n navigator.userAgent User-Agent"
},
{
"answer_id": 220312,
"author": "savetheclocktower",
"author_id": 25720,
"author_profile": "https://Stackoverflow.com/users/25720",
"pm_score": 4,
"selected": false,
"text": "Set-Cookie"
},
{
"answer_id": 220883,
"author": "Leo",
"author_id": 20689,
"author_profile": "https://Stackoverflow.com/users/20689",
"pm_score": 3,
"selected": false,
"text": "var request = new XMLHttpRequest();\nrequest.setRequestHeader(\"X-Requested-With\", \"XMLHttpRequest\");\nrequest.open(\"GET\", path, true);\nrequest.send(null);\n"
},
{
"answer_id": 260117,
"author": "Allain Lalonde",
"author_id": 2443,
"author_profile": "https://Stackoverflow.com/users/2443",
"pm_score": 5,
"selected": false,
"text": "XmlHttpRequest HEAD"
},
{
"answer_id": 277761,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "this.xhr.getAllResponseHeaders()"
},
{
"answer_id": 4847090,
"author": "dlo",
"author_id": 580394,
"author_profile": "https://Stackoverflow.com/users/580394",
"pm_score": -1,
"selected": false,
"text": "getAllResponseHeaders() getResponseHeader()"
},
{
"answer_id": 4881836,
"author": "Raja",
"author_id": 600903,
"author_profile": "https://Stackoverflow.com/users/600903",
"pm_score": 9,
"selected": false,
"text": "get var req = new XMLHttpRequest();\nreq.open('GET', document.location, false);\nreq.send(null);\nvar headers = req.getAllResponseHeaders().toLowerCase();\nalert(headers);\n"
},
{
"answer_id": 18278054,
"author": "rushmore",
"author_id": 2690114,
"author_profile": "https://Stackoverflow.com/users/2690114",
"pm_score": 2,
"selected": false,
"text": "var xhr = new XMLHttpRequest(); \nxhr.open('POST', url, true); \nxhr.responseType = \"blob\";\nxhr.onreadystatechange = function () { \n if (xhr.readyState == 4) {\n success(xhr.response); // the function to proccess the response\n\n console.log(\"++++++ reading headers ++++++++\");\n var headers = xhr.getAllResponseHeaders();\n console.log(headers);\n console.log(\"++++++ reading headers end ++++++++\");\n\n }\n};\n Date: Fri, 16 Aug 2013 16:21:33 GMT\nContent-Disposition: attachment;filename=testFileName.doc\nContent-Length: 20\nServer: Apache-Coyote/1.1\nContent-Type: application/octet-stream\n"
},
{
"answer_id": 26381576,
"author": "Fulup",
"author_id": 3986849,
"author_profile": "https://Stackoverflow.com/users/3986849",
"pm_score": 3,
"selected": false,
"text": " case \".html\":\n response.setHeader(\"Content-Type\", \"text/html\");\n response.write (\"<script>location['GPSD_HTTP_AJAX']=true</script>\")\n // process the real contend of my page\n // Select direct Ajax/Json profile if using GpsdTracking/HttpAjax server otherwise use JsonP\n var corsbypass = true; \n if (location['GPSD_HTTP_AJAX']) corsbypass = false;\n\n if (corsbypass) { // Json & html served from two different web servers\n var gpsdApi = \"http://localhost:4080/geojson.rest?jsoncallback=?\";\n } else { // Json & html served from same web server [no ?jsoncallback=]\n var gpsdApi = \"geojson.rest?\";\n }\n var gpsdRqt = \n {key :123456789 // user authentication key\n ,cmd :'list' // rest command\n ,group :'all' // group to retreive\n ,round : true // ask server to round numbers\n };\n $.getJSON(gpsdApi,gpsdRqt, DevListCB);\n"
},
{
"answer_id": 37762564,
"author": "Gaël Métais",
"author_id": 4716391,
"author_profile": "https://Stackoverflow.com/users/4716391",
"pm_score": 5,
"selected": false,
"text": "fetch respondWith postMessage"
},
{
"answer_id": 47724317,
"author": "Diego",
"author_id": 498609,
"author_profile": "https://Stackoverflow.com/users/498609",
"pm_score": 4,
"selected": false,
"text": "headers[\"content-type\"] parseHttpHeaders function parseHttpHeaders(httpHeaders) {\n return httpHeaders.split(\"\\n\")\n .map(x=>x.split(/: */,2))\n .filter(x=>x[0])\n .reduce((ac, x)=>{ac[x[0]] = x[1];return ac;}, {});\n}\n\nvar req = new XMLHttpRequest();\nreq.open('GET', document.location, false);\nreq.send(null);\nvar headers = parseHttpHeaders(req.getAllResponseHeaders());\n// Now we can do: headers[\"content-type\"]\n"
},
{
"answer_id": 47782657,
"author": "Jorgesys",
"author_id": 250260,
"author_profile": "https://Stackoverflow.com/users/250260",
"pm_score": 2,
"selected": false,
"text": "var url = \"< URL >\";\n\nvar req = new XMLHttpRequest();\nreq.open('HEAD', url, false);\nreq.send(null);\nvar headers = req.getAllResponseHeaders();\n\n//Show alert with response headers.\nalert(headers);\n"
},
{
"answer_id": 49471801,
"author": "Ollie Williams",
"author_id": 6854859,
"author_profile": "https://Stackoverflow.com/users/6854859",
"pm_score": -1,
"selected": false,
"text": "app.get('/somepage', (req, res) => {\n res.render('somepage.hbs', {headers: req.headers});\n})\n"
},
{
"answer_id": 51842418,
"author": "shaedrich",
"author_id": 7451109,
"author_profile": "https://Stackoverflow.com/users/7451109",
"pm_score": 3,
"selected": false,
"text": "var req = new XMLHttpRequest();\nreq.open('GET', document.location, false);\nreq.send(null);\nvar headers = req.getAllResponseHeaders().toLowerCase();\nheaders = headers.split(/\\n|\\r|\\r\\n/g).reduce(function(a, b) {\n if (b.length) {\n var [ key, value ] = b.split(': ');\n a[key] = value;\n }\n return a;\n}, {});\n"
},
{
"answer_id": 58791949,
"author": "j.j.",
"author_id": 5807141,
"author_profile": "https://Stackoverflow.com/users/5807141",
"pm_score": 3,
"selected": false,
"text": "<!DOCTYPE html>\n<title>(XHR) Show all response headers</title>\n\n<h1>All Response Headers with XHR</h1>\n<script>\n var X= new XMLHttpRequest();\n X.open(\"HEAD\", location);\n X.send();\n X.onload= function() { \n document.body.appendChild(document.createElement(\"pre\")).textContent= X.getAllResponseHeaders();\n }\n</script>\n fetch() <!DOCTYPE html>\n<title>fetch() all Response Headers</title>\n\n<h1>All Response Headers with fetch()</h1>\n<script>\n var x= \"\";\n if(window.fetch)\n fetch(location, {method:'HEAD'})\n .then(function(r) {\n r.headers.forEach(\n function(Value, Header) { x= x + Header + \"\\n\" + Value + \"\\n\\n\"; }\n );\n })\n .then(function() {\n document.body.appendChild(document.createElement(\"pre\")).textContent= x;\n });\n else\n document.write(\"This does not work in your browser - no support for fetch API\");\n</script>\n"
},
{
"answer_id": 66211531,
"author": "jakub.g",
"author_id": 245966,
"author_profile": "https://Stackoverflow.com/users/245966",
"pm_score": 5,
"selected": false,
"text": "Server-Timing server-timing: key;desc=\"value\"\n server-timing: key1;desc=\"value1\"\nserver-timing: key2;desc=\"value2\"\n server-timing: key1;desc=\"value1\", key2;desc=\"value2\"\n if (window.performance && performance.getEntriesByType) { // avoid error in Safari 10, IE9- and other old browsers\n let navTiming = performance.getEntriesByType('navigation')\n if (navTiming.length > 0) { // still not supported as of Safari 14...\n let serverTiming = navTiming[0].serverTiming\n if (serverTiming && serverTiming.length > 0) {\n for (let i=0; i<serverTiming.length; i++) {\n console.log(`${serverTiming[i].name} = ${serverTiming[i].description}`)\n }\n }\n }\n}\n cache = hit-front Timing-Allow-Origin: * Timing-Allow-Origin: https://www.example.com Server-Timing dur duration 0 PerformanceObserver"
}
] |
2008/10/20
|
[
"https://Stackoverflow.com/questions/220231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19468/"
] |
220,234
|
<p>In the <code>IDisposable.Dispose</code> method is there a way to figure out if an exception is being thrown?</p>
<pre><code>using (MyWrapper wrapper = new MyWrapper())
{
throw new Exception("Bad error.");
}
</code></pre>
<p>If an exception is thrown in the <code>using</code> statement I want to know about it when the <code>IDisposable</code> object is disposed.</p>
|
[
{
"answer_id": 220249,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 1,
"selected": false,
"text": "try\n{\n MyWrapper wrapper = new MyWrapper();\n\n}\ncatch (Exception e)\n{\n wrapper.CaughtException = true;\n}\nfinally\n{\n if (wrapper != null)\n {\n wrapper.Dispose();\n }\n}\n"
},
{
"answer_id": 223435,
"author": "Robert Paulson",
"author_id": 14033,
"author_profile": "https://Stackoverflow.com/users/14033",
"pm_score": 2,
"selected": false,
"text": "wrapper wrapper wrapper try\n{\n // code that may cause exceptions.\n}\ncatch( Exception ex )\n{\n LogExceptionSomewhere(ex);\n throw;\n}\nfinally\n{\n // CLR always tries to execute finally blocks\n}\n"
},
{
"answer_id": 223469,
"author": "Keith",
"author_id": 905,
"author_profile": "https://Stackoverflow.com/users/905",
"pm_score": 0,
"selected": false,
"text": "try\n{\n using (MyWrapper wrapper = new MyWrapper())\n {\n throw new MyException(\"Bad error.\");\n }\n}\ncatch ( MyException myex ) {\n //deal with your exception\n}\ncatch ( Exception ex ) {\n //any other exception thrown by either\n //MyWrapper..ctor() or MyWrapper.Dispose()\n}\n MyWrapper wrapper;\ntry\n{\n wrapper = new MyWrapper();\n}\nfinally {\n if( wrapper != null )\n wrapper.Dispose();\n}\n MyWrapper wrapper;\ntry\n{\n wrapper = new MyWrapper();\n}\nfinally {\n try{\n if( wrapper != null )\n wrapper.Dispose();\n }\n catch {\n //only errors thrown by disposal\n }\n}\n Close()"
},
{
"answer_id": 9730775,
"author": "sammyboy",
"author_id": 569208,
"author_profile": "https://Stackoverflow.com/users/569208",
"pm_score": 2,
"selected": false,
"text": "public void Dispose()\n{\n bool ExceptionOccurred = Marshal.GetExceptionPointers() != IntPtr.Zero\n || Marshal.GetExceptionCode() != 0;\n if(ExceptionOccurred)\n {\n System.Diagnostics.Debug.WriteLine(\"We had an exception\");\n }\n}\n"
},
{
"answer_id": 10236572,
"author": "Jo VdB",
"author_id": 861358,
"author_profile": "https://Stackoverflow.com/users/861358",
"pm_score": 3,
"selected": false,
"text": "Dispose() Marshal.GetExceptionCode() HandleException(() => {\n throw new Exception(\"Bad error.\");\n});\n\npublic static void HandleException(Action code)\n{\n try\n {\n if (code != null)\n code.Invoke();\n }\n catch\n {\n Console.WriteLine(\"Error handling\");\n throw;\n }\n}\n public static int? GetFerrariId()\n{\n using (var connection = new SqlConnection(\"...\"))\n {\n connection.Open();\n using (var transaction = connection.BeginTransaction())\n {\n return HandleTranaction(transaction, () =>\n {\n using (var command = connection.CreateCommand())\n {\n command.Transaction = transaction;\n command.CommandText = \"SELECT CarID FROM Cars WHERE Brand = 'Ferrari'\";\n return (int?)command.ExecuteScalar();\n }\n });\n }\n }\n}\n\npublic static T HandleTranaction<T>(IDbTransaction transaction, Func<T> code)\n{\n try\n {\n var result = code != null ? code.Invoke() : default(T);\n transaction.Commit();\n return result;\n }\n catch\n {\n transaction.Rollback();\n throw;\n }\n}\n"
},
{
"answer_id": 14321555,
"author": "Kelqualyn",
"author_id": 682696,
"author_profile": "https://Stackoverflow.com/users/682696",
"pm_score": 5,
"selected": false,
"text": "IDisposable Complete using (MyWrapper wrapper = new MyWrapper())\n{\n throw new Exception(\"Bad error.\");\n wrapper.Complete();\n}\n using Complete Dispose AppDomain.CurrentDomain.FirstChanceException ThreadLocal<Exception> TransactionScope"
},
{
"answer_id": 33004568,
"author": "Chad Hedgcock",
"author_id": 591097,
"author_profile": "https://Stackoverflow.com/users/591097",
"pm_score": 1,
"selected": false,
"text": "using Dispose() public void Start(Action<string, string, string> behavior)\n try{\n var string1 = \"my queue message\";\n var string2 = \"some string message\";\n var string3 = \"some other string yet;\"\n behaviour(string1, string2, string3);\n }\n catch(Exception e){\n Console.WriteLine(string.Format(\"Oops: {0}\", e.Message))\n }\n }\n using (var wrapper = new MyWrapper())\n {\n wrapper.Start((string1, string2, string3) => \n {\n Console.WriteLine(string1);\n Console.WriteLine(string2);\n Console.WriteLine(string3);\n }\n }\n"
},
{
"answer_id": 49680507,
"author": "mattias",
"author_id": 1766380,
"author_profile": "https://Stackoverflow.com/users/1766380",
"pm_score": 1,
"selected": false,
"text": " public static T WithinTransaction<T>(this IDbConnection cnn, Func<IDbTransaction, T> fn)\n {\n cnn.Open();\n using (var transaction = cnn.BeginTransaction())\n {\n try\n {\n T res = fn(transaction);\n transaction.Commit();\n return res;\n }\n catch (Exception)\n {\n transaction.Rollback();\n throw;\n }\n finally\n {\n cnn.Close();\n }\n }\n }\n cnn.WithinTransaction(\n transaction =>\n {\n var affected = ..sqlcalls..(cnn, ..., transaction);\n return affected;\n });\n"
}
] |
2008/10/20
|
[
"https://Stackoverflow.com/questions/220234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11829/"
] |
220,236
|
<p>I'm trying to figure out a decent solution (especially from the SEO side) for embedding fonts in web pages. So far I have seen <a href="http://web.archive.org/web/20100208164146/http://www.spoono.com/html/tutorials/tutorial.php?id=19" rel="noreferrer">the W3C solution</a>, which doesn't even work on Firefox, and <a href="http://web.archive.org/web/20130127125919/http://wiki.novemberborn.net/sifr/How+to+use" rel="noreferrer">this pretty cool solution</a>. The second solution is for titles only. Is there a solution available for full text? I'm tired of the standard fonts for web pages.</p>
<p>Thanks!</p>
|
[
{
"answer_id": 220277,
"author": "savetheclocktower",
"author_id": 25720,
"author_profile": "https://Stackoverflow.com/users/25720",
"pm_score": 3,
"selected": false,
"text": "font-family: \"Lucida Grande\", \"Verdana\", sans-serif"
},
{
"answer_id": 1967226,
"author": "fencepost",
"author_id": 221818,
"author_profile": "https://Stackoverflow.com/users/221818",
"pm_score": 8,
"selected": true,
"text": "@font-face {\n font-family: 'Graublau Web';\n src: url('GraublauWeb.eot');\n src: local('Graublau Web Regular'), local('Graublau Web'),\n url(\"GraublauWeb.woff\") format(\"woff\"),\n url(\"GraublauWeb.otf\") format(\"opentype\"),\n url(\"GraublauWeb.svg#grablau\") format(\"svg\");\n}\n"
},
{
"answer_id": 1967232,
"author": "philfreo",
"author_id": 137067,
"author_profile": "https://Stackoverflow.com/users/137067",
"pm_score": 2,
"selected": false,
"text": "@font-face EOT"
}
] |
2008/10/20
|
[
"https://Stackoverflow.com/questions/220236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8047/"
] |
220,243
|
<p>How can I comment a JSP expression like: <code><%= map.size() %></code></p>
<p>Is there something like <code><%= // map.size() %>?</code></p>
|
[
{
"answer_id": 220251,
"author": "jim",
"author_id": 27628,
"author_profile": "https://Stackoverflow.com/users/27628",
"pm_score": -1,
"selected": false,
"text": "<!-- map.size here because --> \n<%= map.size() %>\n <%= map.size() // map.size here because %>\n"
},
{
"answer_id": 220275,
"author": "Jonny Buchanan",
"author_id": 6760,
"author_profile": "https://Stackoverflow.com/users/6760",
"pm_score": 9,
"selected": true,
"text": "<%-- Comment --%>\n = <%--= map.size() --%>\n <%= <% /*= map.size()*/ %>\n"
},
{
"answer_id": 220304,
"author": "lock",
"author_id": 24744,
"author_profile": "https://Stackoverflow.com/users/24744",
"pm_score": 2,
"selected": false,
"text": "<%= //map.size() %> <% //= map.size() %>\n"
},
{
"answer_id": 21775583,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": " <%--your comment --%>\n single line comment\n <% your code //your comment%>\n\nmultiple line comment \n\n<% your code \n/**\nyour another comment\n**/\n\n%>\n <!-- your commment -->\n"
},
{
"answer_id": 27956938,
"author": "Jflywheel",
"author_id": 1301982,
"author_profile": "https://Stackoverflow.com/users/1301982",
"pm_score": 3,
"selected": false,
"text": "<%-- comment --%>\n <!-- comment -->\n"
},
{
"answer_id": 30295023,
"author": "kavi temre",
"author_id": 4062987,
"author_profile": "https://Stackoverflow.com/users/4062987",
"pm_score": 6,
"selected": false,
"text": "1. <%-- comment --%>\n 2. <!-- comment -->\n 3. <% my code //my comment %>\n 4. <% my code /**\n my comment **/ \n %>\n"
},
{
"answer_id": 44278752,
"author": "Mani Kasi",
"author_id": 2175165,
"author_profile": "https://Stackoverflow.com/users/2175165",
"pm_score": 2,
"selected": false,
"text": "<%-- Comment --%>"
}
] |
2008/10/20
|
[
"https://Stackoverflow.com/questions/220243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14015/"
] |
220,250
|
<p>I am curious as to why an implicit cast fails in...</p>
<pre><code>int? someValue = SomeCondition ? ResultOfSomeCalc() : null;
</code></pre>
<p>and why I have to perform an explicit cast instead</p>
<pre><code>int? someValue = SomeCondition ? ResultofSomeCalc() : (int?)null;
</code></pre>
<p>It seems to me that the compiler has all the information it need to make an implicit casting decision, no?</p>
|
[
{
"answer_id": 220269,
"author": "TheSoftwareJedi",
"author_id": 18941,
"author_profile": "https://Stackoverflow.com/users/18941",
"pm_score": 4,
"selected": false,
"text": "object someValue = true ? new Nullable<int>(ResultOfSomeCalc()) : null;\n\nobject someValue = true ? (int?)ResultOfSomeCalc() : null;\n"
},
{
"answer_id": 522404,
"author": "Mr. Putty",
"author_id": 63513,
"author_profile": "https://Stackoverflow.com/users/63513",
"pm_score": 3,
"selected": false,
"text": "int? someValue = SomeCondition ? ResultofSomeCalc() : default(int?);\n"
}
] |
2008/10/20
|
[
"https://Stackoverflow.com/questions/220250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10387/"
] |
220,254
|
<p>I have been using code similar to this</p>
<pre><code>MessageDlg('', mtWarning, [mbOK], 0);
</code></pre>
<p>throughout my project, (thanks to the GExperts Message Dialog tool :) ) and i was wondering if anyone knows of a way do override the call and show my own custom Form.</p>
<p>The only way i can think to do it its make a New Form with something like</p>
<pre><code>function MessageDlg(const Msg: string; DlgType: TMsgDlgType;
Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer;
begin
//show my own code here
end;
</code></pre>
<p>and put it each of my uses lists before the Dialogs unit but is there a guaranteed way to make sure it uses my code not the Dialogs unit Code.<br>
I don't like the idea of copying the dialogs unit to a local dir and making changes to it.</p>
<p>Or is this all to much work and should i just use my own function call and replace all the MessageDlg with my own. (which would not be fun, ive prob used MessageDlg too much) </p>
|
[
{
"answer_id": 222330,
"author": "X-Ray",
"author_id": 14031,
"author_profile": "https://Stackoverflow.com/users/14031",
"pm_score": 0,
"selected": false,
"text": "function MessageDlgEx(Caption, Msg: string; AType: TMsgDlgType;\n AButtons: array of string;\n DefBtn, CanBtn: Integer; iWidth:integer=450;bCourier:boolean=false): Word;\nconst\n icMin=50;\n icButtonHeight=25;\n icInterspace=10;\n icButtonResultStart=100;\n icFirstButtonReturnValue=1;\nvar\n I, iButtonWidth, iAllButtonsWidth,\n iIconWidth,iIconHeight:Integer;\n LabelText:String;\n Frm: TForm;\n Lbl: TLabel;\n Btn: TBitBtn;\n Glyph: TImage;\n FIcon: TIcon;\n Rect:TRect;\n Caption_ca:Array[0..2000] of Char;\nbegin\n { Create the form.}\n Frm := TForm.Create(Application);\n Frm.BorderStyle := bsDialog;\n Frm.BorderIcons := [biSystemMenu];\n Frm.FormStyle := fsStayOnTop;\n Frm.Height := 185;\n Frm.Width := iWidth;\n Frm.Position := poScreenCenter;\n Frm.Caption := Caption;\n Frm.Font.Name:='MS Sans Serif';\n Frm.Font.Style:=[];\n Frm.Scaled:=false;\n\n if ResIDs[AType] <> nil then\n begin\n Glyph := TImage.Create(Frm);\n Glyph.Name := 'Image';\n Glyph.Parent := Frm;\n\n FIcon := TIcon.Create;\n try\n FIcon.Handle := LoadIcon(HInstance, ResIDs[AType]);\n iIconWidth:=FIcon.Width;\n iIconHeight:=FIcon.Height;\n Glyph.Picture.Graphic := FIcon;\n Glyph.BoundsRect := Bounds(icInterspace, icInterspace, FIcon.Width, FIcon.Height);\n finally\n FIcon.Free;\n end;\n end\n else\n begin\n iIconWidth:=0;\n iIconHeight:=0;\n end;\n\n { Loop through buttons to determine the longest caption. }\n iButtonWidth := 0;\n for I := 0 to High(AButtons) do\n iButtonWidth := Max(iButtonWidth, frm.Canvas.TextWidth(AButtons[I]));\n\n { Add padding for the button's caption}\n iButtonWidth := iButtonWidth + 18;\n\n {assert a minimum button width}\n If iButtonWidth<icMin Then\n iButtonWidth:=icMin;\n\n { Determine space required for all buttons}\n iAllButtonsWidth := iButtonWidth * (High(AButtons) + 1);\n\n { Each button has padding on each side}\n iAllButtonsWidth := iAllButtonsWidth +icInterspace*High(AButtons);\n\n { The form has to be at least as wide as the buttons with space on each side}\n if iAllButtonsWidth+icInterspace*2 > Frm.Width then\n Frm.Width := iAllButtonsWidth+icInterspace*2;\n\n if Length(Msg)>sizeof(Caption_ca) then\n SetLength(Msg,sizeof(Caption_ca));\n\n { Create the message control}\n Lbl := TLabel.Create(Frm);\n Lbl.AutoSize := False;\n Lbl.Left := icInterspace*2+iIconWidth;\n Lbl.Top := icInterspace;\n Lbl.Height := 200;\n Lbl.Width := Frm.ClientWidth - icInterspace*3-iIconWidth;\n Lbl.WordWrap := True;\n Lbl.Caption := Msg;\n Lbl.Parent := Frm;\n\n if bCourier then\n lbl.Font.Name:='Courier New';\n\n Rect := Lbl.ClientRect;\n LabelText:=Lbl.Caption;\n StrPCopy(Caption_ca, LabelText);\n\n Lbl.Height:=DrawText(Lbl.Canvas.Handle,\n Caption_ca,\n Length(LabelText),\n Rect,\n DT_CalcRect or DT_ExpandTabs or DT_WordBreak Or DT_Left);\n\n\n If Lbl.Height<iIconHeight Then\n Lbl.Height:=iIconHeight;\n\n { Adjust the form's height accomodating the message, padding and the buttons}\n Frm.ClientHeight := Lbl.Height + 3*icInterspace + icButtonHeight;\n\n { Create the pusbuttons}\n for I := 0 to High(AButtons) do\n begin\n Btn := TBitBtn.Create(Frm);\n Btn.Height := icButtonHeight;\n Btn.Width := iButtonWidth;\n Btn.Left:=((Frm.Width-iAllButtonsWidth) Div 2)+I*(iButtonWidth+icInterspace);\n Btn.Top := Frm.ClientHeight - Btn.height-icInterspace;\n Btn.Caption := AButtons[I];\n Btn.ModalResult := I + icButtonResultStart + icFirstButtonReturnValue;\n Btn.Parent := Frm;\n\n If I=DefBtn-1 Then\n Begin\n Frm.ActiveControl:=Btn;\n Btn.Default:=True;\n End\n Else\n Btn.Default:=False;\n\n If I=CanBtn-1 Then\n Btn.Cancel:=True\n Else\n Btn.Cancel:=False;\n end;\n\n Application.BringToFront;\n\n Result := Frm.ShowModal;\n\n {trap and convert user Close into mrNone}\n If Result=mrCancel Then\n Result:=mrNone\n Else\n If Result>icButtonResultStart Then\n Result:=Result - icButtonResultStart\n Else\n Exception.Create('Unknown MessageDlgEx result');\n\n Frm.Free;\nend;\n"
}
] |
2008/10/20
|
[
"https://Stackoverflow.com/questions/220254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11016/"
] |
220,266
|
<p>So after installing NUnit, the assemblies (<code>nunit.framework</code>, etc.) now appear in the <code>References > Add Reference</code> dialog, but they're not in the <code>%WINDIR%\Microsoft.NET\Framework\v2.0.50727</code> dir and there is no <code>NUnit</code> registry entry for the Assembly Path <code>(i.e. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramewokr\AssemblyFolder)</code>.</p>
<p>There's also no automatic entries created in the project properties Reference Paths for the <code>NUnit</code> install directory. How the heck are they appearing in the "Add Dialog"?!?! I thought the mentioned way were the only ways assemblies could appear in "Add Reference".</p>
|
[
{
"answer_id": 220285,
"author": "TheSoftwareJedi",
"author_id": 18941,
"author_profile": "https://Stackoverflow.com/users/18941",
"pm_score": 0,
"selected": false,
"text": "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\.NETFramework\\AssemblyFolders\\v3.0\n HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\.NETFramework\\AssemblyFolders\\v3.5\n"
},
{
"answer_id": 220448,
"author": "Brody",
"author_id": 17131,
"author_profile": "https://Stackoverflow.com/users/17131",
"pm_score": 0,
"selected": false,
"text": "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\.NETFramework\\AssemblyFolders\\NUnit 2.4.3\n"
}
] |
2008/10/20
|
[
"https://Stackoverflow.com/questions/220266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
220,273
|
<p>Given a template where the HTML cannot be modified because of other requirements, how is it possible to display (rearrange) a <code>div</code> above another <code>div</code> when they are not in that order in the HTML? Both <code>div</code>s contain data that varies in height and width.</p>
<pre><code><div id="wrapper">
<div id="firstDiv">
Content to be below in this situation
</div>
<div id="secondDiv">
Content to be above in this situation
</div>
</div>
Other elements
</code></pre>
<p>Hopefully it is obvious that the desired result is:</p>
<pre class="lang-none prettyprint-override"><code>Content to be above in this situation
Content to be below in this situation
Other elements
</code></pre>
<p>When the dimensions are fixed it easy to position them where needed, but I need some ideas for when the content is variable. For the sake of this scenario, please just consider the width to be 100% on both.</p>
<p>I am specifically looking for a CSS-only solution (and it will probably have to be met with other solutions if that doesn't pan out). </p>
<p>There are other elements following this. A good suggestion was mentioned given the limited scenario I demonstrated—given that it might be the best answer, but I am looking to also make sure elements following this aren't impacted.</p>
|
[
{
"answer_id": 220321,
"author": "Bobby Jack",
"author_id": 5058,
"author_profile": "https://Stackoverflow.com/users/5058",
"pm_score": 2,
"selected": false,
"text": "#wrapper { position: relative; margin-top: 4em; }\n#firstDiv { position: absolute; top: 0; width: 100%; }\n#secondDiv { position: absolute; bottom: 0; width: 100%; }\n"
},
{
"answer_id": 220326,
"author": "Kris",
"author_id": 18565,
"author_profile": "https://Stackoverflow.com/users/18565",
"pm_score": 3,
"selected": false,
"text": "position : absolute;\n fd = document.getElementById( 'firstDiv' );\nsd = document.getElementById( 'secondDiv' );\nfd.parentNode.removeChild( fd );\nsd.parentNode.insertAfter( fd, sd );\n"
},
{
"answer_id": 220335,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 6,
"selected": false,
"text": "$('#secondDiv').insertBefore('#firstDiv');\n $('.swapMe').each(function(i, el) {\n $(el).insertBefore($(el).prev());\n});\n"
},
{
"answer_id": 220336,
"author": "buti-oxa",
"author_id": 2515,
"author_profile": "https://Stackoverflow.com/users/2515",
"pm_score": 4,
"selected": false,
"text": "<style>\n#firstDiv {\n position:absolute; top:100%;\n}\n#wrapper {\n position:relative; \n}\n"
},
{
"answer_id": 224224,
"author": "Carl Camera",
"author_id": 12804,
"author_profile": "https://Stackoverflow.com/users/12804",
"pm_score": 3,
"selected": false,
"text": "<div class=\"product\">\n<h2>Greatest Product Ever</h2>\n<p class=\"desc\">This paragraph appears in the source code directly after the heading and will appear in the search results.</p>\n<p class=\"sidenote\">Note: This information appears in HTML after the product description appearing below.</p>\n</div>\n .product { width: 400px; }\n.desc { margin-top: 5em; }\n.sidenote { margin-top: -7em; }\n"
},
{
"answer_id": 549760,
"author": "user65952",
"author_id": 65952,
"author_profile": "https://Stackoverflow.com/users/65952",
"pm_score": -1,
"selected": false,
"text": "#firstDiv { position: relative; top: YYYpx; height: XXXpx; }\n#secondDiv { position: relative; top: -XXXpx; height: YYYpx; }\n"
},
{
"answer_id": 549921,
"author": "Matt Howell",
"author_id": 2321,
"author_profile": "https://Stackoverflow.com/users/2321",
"pm_score": 5,
"selected": false,
"text": "#wrapper { position: relative; }\n#firstDiv { position: absolute; height: 100px; top: 110px; }\n#secondDiv { position: absolute; height: 100px; top: 0; }\n"
},
{
"answer_id": 4984052,
"author": "Reza Amya",
"author_id": 615014,
"author_profile": "https://Stackoverflow.com/users/615014",
"pm_score": 2,
"selected": false,
"text": "clear: left right #firstDiv {\n float: left;\n}\n\n#secondDiv {\n float: left;\n clear: left;\n}\n"
},
{
"answer_id": 7514803,
"author": "z666zz666z",
"author_id": 608040,
"author_profile": "https://Stackoverflow.com/users/608040",
"pm_score": -1,
"selected": false,
"text": "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n<meta http-equiv=\"Content-Language\" content=\"en\" />\n<meta name=\"language\" content=\"en\" />\n<title>Vertical Centering in CSS2 - Example (IE, FF & Chrome tested) - This is so tricky!!!</title>\n<style type=\"text/css\">\n html,body{\n margin:0px;\n padding:0px;\n width:100%;\n height:100%;\n }\n div.BloqueTipoTabla{\n display:table;margin:0px;border:0px;padding:0px;width:100%;height:100%;\n }\n div.BloqueTipoFila_AltoAjustadoAlContenido{\n display:table-row;margin:0px;border:0px;padding:0px;width:100%;height:auto;\n }\n div.BloqueTipoFila_AltoRestante{\n display:table-row;margin:0px;border:0px;padding:0px;width:100%;height:100%;\n }\n div.BloqueTipoCelda_AjustadoAlContenido{\n display:table-cell;margin:0px;border:0px;padding:0px;width:auto;height:auto;\n }\n div.BloqueTipoCelda_RestanteAncho{\n display:table-cell;margin:0px;border:0px;padding:0px;width:100%;height:auto;\n }\n div.BloqueTipoCelda_RestanteAlto{\n display:table-cell;margin:0px;border:0px;padding:0px;width:auto;height:100%;\n }\n div.BloqueTipoCelda_RestanteAnchoAlto{\n display:table-cell;margin:0px;border:0px;padding:0px;width:100%;height:100%;\n }\n div.BloqueTipoContenedor{\n display:block;margin:0px;border:0px;padding:0px;width:100%;height:100%;position:relative;\n }\n div.BloqueTipoContenedor_VerticalmenteCentrado{\n display:block;margin:0px;border:0px;padding:0px;width:100%;height:auto;position:relative;top:50%;\n }\n div.BloqueTipoContenido_VerticalmenteCentrado_Oculto{\n display:block;margin:0px;border:0px;padding:0px;width:100%;height:auto;visibility:hidden;position:relative;top:50%;\n }\n div.BloqueTipoContenido_VerticalmenteCentrado_Visible{\n display:block;margin:0px;border:0px;padding:0px;width:100%;height:auto;visibility:visible;position:absolute;top:-50%;\n }\n</style>\n</head>\n<body>\n<h1>Vertical Centering in CSS2 - Example<br />(IE, FF & Chrome tested)<br />This is so tricky!!!</h1>\n<div class=\"BloqueTipoTabla\" style=\"margin:0px 0px 0px 25px;width:75%;height:66%;border:1px solid blue;\">\n <div class=\"BloqueTipoFila_AltoAjustadoAlContenido\">\n <div class=\"BloqueTipoCelda_AjustadoAlContenido\">\n [1,1]\n </div>\n <div class=\"BloqueTipoCelda_AjustadoAlContenido\">\n [1,2]\n </div>\n <div class=\"BloqueTipoCelda_RestanteAncho\">\n [1,3]\n </div>\n <div class=\"BloqueTipoCelda_AjustadoAlContenido\">\n [1,4]\n </div>\n </div>\n <div class=\"BloqueTipoFila_AltoAjustadoAlContenido\">\n <div class=\"BloqueTipoCelda_AjustadoAlContenido\">\n [2,1]\n </div>\n <div class=\"BloqueTipoCelda_AjustadoAlContenido\">\n [2,2]\n </div>\n <div class=\"BloqueTipoCelda_RestanteAncho\">\n [2,3]\n </div>\n <div class=\"BloqueTipoCelda_AjustadoAlContenido\">\n [2,4]\n </div>\n</div>\n <div class=\"BloqueTipoFila_AltoRestante\">\n <div class=\"BloqueTipoCelda_RestanteAlto\">\n <div class=\"BloqueTipoContenedor\" style=\"border:1px solid lime;\">\n <div class=\"BloqueTipoContenedor_VerticalmenteCentrado\" style=\"border:1px dotted red;\">\n <div class=\"BloqueTipoContenido_VerticalmenteCentrado_Oculto\">\n The cell [3,1]\n <br />\n * * * *\n <br />\n * * * *\n <br />\n * * * *\n <br />\n Now is the highest one\n </div>\n <div class=\"BloqueTipoContenido_VerticalmenteCentrado_Visible\" style=\"border:1px dotted blue;\">\n The cell [3,1]\n <br />\n * * * *\n <br />\n * * * *\n <br />\n * * * *\n <br />\n Now is the highest one\n </div>\n </div>\n </div>\n </div>\n <div class=\"BloqueTipoCelda_RestanteAlto\">\n <div class=\"BloqueTipoContenedor\" style=\"border:1px solid lime;\">\n <div class=\"BloqueTipoContenedor_VerticalmenteCentrado\" style=\"border:1px dotted red;\">\n <div class=\"BloqueTipoContenido_VerticalmenteCentrado_Oculto\">\n This is<br />cell [3,2]\n </div>\n <div class=\"BloqueTipoContenido_VerticalmenteCentrado_Visible\" style=\"border:1px dotted blue;\">\n This is<br />cell [3,2]\n </div>\n </div>\n </div>\n </div>\n <div class=\"BloqueTipoCelda_RestanteAnchoAlto\">\n <div class=\"BloqueTipoContenedor\" style=\"border:1px solid lime;\">\n <div class=\"BloqueTipoContenedor_VerticalmenteCentrado\" style=\"border:1px dotted red;\">\n <div class=\"BloqueTipoContenido_VerticalmenteCentrado_Oculto\">\n This is cell [3,3]\n <br/>\n It is duplicated on source to make the trick to know its variable height\n <br />\n First copy is hidden and second copy is visible\n <br/>\n Other cells of this row are not correctly aligned only on IE!!!\n </div>\n <div class=\"BloqueTipoContenido_VerticalmenteCentrado_Visible\" style=\"border:1px dotted blue;\">\n This is cell [3,3]\n <br/>\n It is duplicated on source to make the trick to know its variable height\n <br />\n First copy is hidden and second copy is visible\n <br/>\n Other cells of this row are not correctly aligned only on IE!!!\n </div>\n </div>\n </div>\n </div>\n <div class=\"BloqueTipoCelda_RestanteAlto\">\n <div class=\"BloqueTipoContenedor\" style=\"border:1px solid lime;\">\n <div class=\"BloqueTipoContenedor_VerticalmenteCentrado\" style=\"border:1px dotted red;\">\n <div class=\"BloqueTipoContenido_VerticalmenteCentrado_Oculto\">\n This other is<br />the cell [3,4]\n </div>\n <div class=\"BloqueTipoContenido_VerticalmenteCentrado_Visible\" style=\"border:1px dotted blue;\">\n This other is<br />the cell [3,4]\n </div>\n </div>\n </div>\n </div>\n </div>\n <div class=\"BloqueTipoFila_AltoAjustadoAlContenido\">\n <div class=\"BloqueTipoCelda_AjustadoAlContenido\">\n [4,1]\n </div>\n <div class=\"BloqueTipoCelda_AjustadoAlContenido\">\n [4,2]\n </div>\n <div class=\"BloqueTipoCelda_RestanteAncho\">\n [4,3]\n </div>\n <div class=\"BloqueTipoCelda_AjustadoAlContenido\">\n [4,4]\n </div>\n </div>\n</div>\n</body>\n</html>\n"
},
{
"answer_id": 12069537,
"author": "Jordi",
"author_id": 1134242,
"author_profile": "https://Stackoverflow.com/users/1134242",
"pm_score": 8,
"selected": false,
"text": "#wrapper { display: table; }\n#firstDiv { display: table-footer-group; }\n#secondDiv { display: table-header-group; }\n"
},
{
"answer_id": 13332006,
"author": "Pmillan",
"author_id": 920123,
"author_profile": "https://Stackoverflow.com/users/920123",
"pm_score": -1,
"selected": false,
"text": "display:block z-index <body>\n <div class=\"wrapper\">\n\n <div class=\"header\">\n header\n </div>\n\n <div class=\"content\">\n content\n </div>\n </div>\n</body>\n .wrapper\n{\n [...]\n}\n\n.header\n{\n [...]\n z-index:9001;\n display:block;\n [...]\n}\n\n.content\n{\n [...]\n z-index:9000;\n [...]\n}\n background-color div-s"
},
{
"answer_id": 17364200,
"author": "Jose Paitamala",
"author_id": 2531748,
"author_profile": "https://Stackoverflow.com/users/2531748",
"pm_score": 2,
"selected": false,
"text": "// changing the order of the sidebar so it goes after the content for mobile versions\njQuery(window).resize(function(){\n if ( jQuery(window).width() < 480 )\n {\n jQuery('#main-content').insertBefore('#sidebar');\n }\n if ( jQuery(window).width() > 480 )\n {\n jQuery('#sidebar').insertBefore('#main-content');\n }\n jQuery(window).height(); // New height\n jQuery(window).width(); // New width\n});\n"
},
{
"answer_id": 24214855,
"author": "BlakePetersen",
"author_id": 2510949,
"author_profile": "https://Stackoverflow.com/users/2510949",
"pm_score": 5,
"selected": false,
"text": "/* -- Where the Magic Happens -- */\n\n.container {\n \n /* Setup Flexbox */\n display: -webkit-box;\n display: -moz-box;\n display: -ms-flexbox;\n display: -webkit-flex;\n display: flex;\n\n /* Reverse Column Order */\n -webkit-flex-flow: column-reverse;\n flex-flow: column-reverse;\n\n}\n\n\n/* -- Styling Only -- */\n\n.container > div {\n background: red;\n color: white;\n padding: 10px;\n}\n\n.container > div:last-of-type {\n background: blue;\n} <div class=\"container\">\n \n <div class=\"first\">\n\n first\n\n </div>\n \n <div class=\"second\">\n\n second\n\n </div>\n \n</div>"
},
{
"answer_id": 27861762,
"author": "K.Kutschera",
"author_id": 4437027,
"author_profile": "https://Stackoverflow.com/users/4437027",
"pm_score": -1,
"selected": false,
"text": ".move-wrap {\n display: table;\n table-layout: fixed; // prevent some responsive bugs\n width: 100%; // set a width if u like\n /* TODO: js-fallback IE7 if u like ms */\n}\n\n.move-down {\n display: table-footer-group;\n}\n\n.move-up {\n display: table-header-group;\n}\n"
},
{
"answer_id": 28159766,
"author": "Justin",
"author_id": 922522,
"author_profile": "https://Stackoverflow.com/users/922522",
"pm_score": 8,
"selected": false,
"text": "order #flex { display: flex; flex-direction: column; }\n#a { order: 2; }\n#b { order: 1; }\n#c { order: 3; } <div id=\"flex\">\n <div id=\"a\">A</div>\n <div id=\"b\">B</div>\n <div id=\"c\">C</div>\n</div>"
},
{
"answer_id": 28207196,
"author": "Gian Miller",
"author_id": 4505835,
"author_profile": "https://Stackoverflow.com/users/4505835",
"pm_score": -1,
"selected": false,
"text": "<!-- HTML -->\n\n<div class=\"wrapper\">\n\n <div class=\"sm-hide\">This content hides when at your layouts chosen breaking point.</div>\n\n <div>Content that stays in place</div>\n\n <div class=\"sm-show\">This content is set to show at your layouts chosen breaking point.</div>\n\n</div>\n\n<!-- CSS -->\n\n .sm-hide {display:block;}\n .sm-show {display:none;}\n\n@media (max-width:598px) {\n .sm-hide {display:none;}\n .sm-show {display:block;}\n}\n"
},
{
"answer_id": 30380136,
"author": "jansmolders86",
"author_id": 1077230,
"author_profile": "https://Stackoverflow.com/users/1077230",
"pm_score": 2,
"selected": false,
"text": "#main {\n display: -webkit-box;\n display: -webkit-flex;\n display: flex;\n -webkit-box-orient: vertical;\n -webkit-flex-direction: column;\n flex-direction: column;\n -webkit-box-align: start;\n -webkit-align-items: flex-start;\n align-items: flex-start;\n}\n #main > div#one{\n -webkit-box-ordinal-group: 2;\n -moz-box-ordinal-group: 2;\n -ms-flex-order: 2;\n -webkit-order: 2;\n order: 2;\n overflow:visible;\n}\n\n#main > div#two{\n -webkit-box-ordinal-group: 1;\n -moz-box-ordinal-group: 1;\n -ms-flex-order: 1;\n -webkit-order: 1;\n order: 1;\n}\n"
},
{
"answer_id": 33255407,
"author": "Arun Kumar M",
"author_id": 5173098,
"author_profile": "https://Stackoverflow.com/users/5173098",
"pm_score": 4,
"selected": false,
"text": "#wrapper {\n display: flex;\n flex-direction: column;\n}\n#firstDiv {\n order: 2;\n}\n\n<div id=\"wrapper\">\n <div id=\"firstDiv\">\n Content1\n </div>\n <div id=\"secondDiv\">\n Content2\n </div>\n</div>\n"
},
{
"answer_id": 39004402,
"author": "MUSTAPHA ABDULRASHEED",
"author_id": 6589406,
"author_profile": "https://Stackoverflow.com/users/6589406",
"pm_score": 0,
"selected": false,
"text": "display: flex flex-direction : column"
},
{
"answer_id": 39628823,
"author": "Finesse",
"author_id": 1118709,
"author_profile": "https://Stackoverflow.com/users/1118709",
"pm_score": 2,
"selected": false,
"text": "#wrapper {\n -webkit-transform: scaleY(-1);\n -ms-transform: scaleY(-1);\n transform: scaleY(-1);\n}\n#wrapper > * {\n -webkit-transform: scaleY(-1);\n -ms-transform: scaleY(-1);\n transform: scaleY(-1);\n} <div id=\"wrapper\">\n <div id=\"firstDiv\">\n Content to be below in this situation\n </div>\n <div id=\"secondDiv\">\n Content to be above in this situation\n </div>\n</div>\nOther elements display: table; .wrapper"
},
{
"answer_id": 42706942,
"author": "lsrom",
"author_id": 4751720,
"author_profile": "https://Stackoverflow.com/users/4751720",
"pm_score": -1,
"selected": false,
"text": "<div style=\"height: 500px; width: 500px;\">\n\n<div class=\"bottom\" style=\"height: 250px; width: 500px; background: red; margin-top: 250px;\"></div>\n\n<div class=\"top\" style=\"height: 250px; width: 500px; background: blue; margin-top: -500px;\"></div>\n"
},
{
"answer_id": 59388711,
"author": "al-bulat",
"author_id": 9056683,
"author_profile": "https://Stackoverflow.com/users/9056683",
"pm_score": 3,
"selected": false,
"text": ".price {\n display: flex;\n align-items: center;\n justify-content: center;\n\n flex-direction: row-reverse; //revert horizontally\n //flex-direction: column-reverse; revert vertically\n} <div class=\"price\">\n <div>first block</div>\n <div>second block</div>\n</div>"
},
{
"answer_id": 65441414,
"author": "Alan",
"author_id": 5449450,
"author_profile": "https://Stackoverflow.com/users/5449450",
"pm_score": 3,
"selected": false,
"text": "<div>\n <div class=\"gridInverseMobile1\">First</div>\n <div class=\"gridInverseMobile1\">Second</div>\n</div>\n @media only screen and (max-width: 960px) {\n .gridInverseMobile1 {\n order: 2;\n -webkit-order: 2;\n }\n .gridInverseMobile2 {\n order: 1;\n -webkit-order: 1;\n }\n}\n Desktop: First | Second\nMobile: Second | First\n"
},
{
"answer_id": 69852350,
"author": "Aleandro Coppola",
"author_id": 4083794,
"author_profile": "https://Stackoverflow.com/users/4083794",
"pm_score": 3,
"selected": false,
"text": "#wrapper {\n display: flex;\n flex-direction: column;\n}\n\n#firstDiv {\n order: 1;\n}\n\n#secondDiv {\n order: 0;\n} <div id=\"wrapper\">\n <div id=\"firstDiv\">\n Content to be below in this situation\n </div>\n <div id=\"secondDiv\">\n Content to be above in this situation\n </div>\n</div>"
},
{
"answer_id": 69880977,
"author": "Chuong Tran",
"author_id": 8568835,
"author_profile": "https://Stackoverflow.com/users/8568835",
"pm_score": 0,
"selected": false,
"text": "direction: rtl;"
}
] |
2008/10/20
|
[
"https://Stackoverflow.com/questions/220273",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12368/"
] |
220,274
|
<p>I remember when MS was developing Cassini - I believe they rolled it into VS 05/08, so I think this is a Cassini web server question. </p>
<p>I am using Windows XP with Visual Studio 2008, and find it quite inconvenient when I want to test a web page/styling with multiple browsers and multiple OSes. Right now I have to deploy the code on our server, and if there are any updates that need to happen, the process turns into quite a time drain. Since I am using XP/IIS 5, the option of using IIS is not an option. The use of IIS on XP requires an extra prefix for a project, which breaks all links, css etc. This was also a really quick development project so things like root dir that should be pulled out to config aren't, I am quite on board with this type of solution but it wasn't implemented in this project. It also seems really sketchy that MS wouldn't allow a simple flag somewhere to allow remote connections - its quite simple (<a href="http://www.devx.com/dotnet/Article/11711" rel="noreferrer">http://www.devx.com/dotnet/Article/11711</a>) but I don't want to recompile Cassini.</p>
<p>Does anyone know how to allow the integrated development web server in Visual Studio 2008 to be seen by other computers? This would save loads of time.</p>
|
[
{
"answer_id": 220279,
"author": "TheSoftwareJedi",
"author_id": 18941,
"author_profile": "https://Stackoverflow.com/users/18941",
"pm_score": 2,
"selected": false,
"text": "C:\\Windows\\system32\\drivers\\etc\n"
},
{
"answer_id": 1732123,
"author": "ronsky",
"author_id": 210760,
"author_profile": "https://Stackoverflow.com/users/210760",
"pm_score": 6,
"selected": true,
"text": "http://localhost.:[insert your dev port # here"
}
] |
2008/10/20
|
[
"https://Stackoverflow.com/questions/220274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8426/"
] |
220,298
|
<p>I would like to have my warnings set to the highest level using Microsoft Visual C++ compiler. Similar to using -pedantic on gcc. What compiler switches do you use to have the most warnings enabled?</p>
|
[
{
"answer_id": 220314,
"author": "Menkboy",
"author_id": 29539,
"author_profile": "https://Stackoverflow.com/users/29539",
"pm_score": 1,
"selected": false,
"text": "/W4 /Wall"
},
{
"answer_id": 63542701,
"author": "boqpoq",
"author_id": 14150291,
"author_profile": "https://Stackoverflow.com/users/14150291",
"pm_score": 2,
"selected": false,
"text": "/permissive- /permissive- /permissive- /Za"
}
] |
2008/10/20
|
[
"https://Stackoverflow.com/questions/220298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13676/"
] |
220,323
|
<p>I have a class with the following member functions:</p>
<pre><code>
/// caller pid
virtual pid_t Pid() const = 0;
/// physical memory size in KB
virtual uint64_t Size() const = 0;
/// resident memory for this process
virtual uint64_t Rss() const = 0;
/// cpu used by this process
virtual double PercentCpu() const = 0;
/// memory used by this process
virtual double PercentMemory() const = 0;
/// number of threads in this process
virtual int32_t Lwps() const = 0;
</code>
</pre>
<p>This class' duty is to return process information about caller. Physical memory size can easily determined by a sysctl call, and pid is trivial, but the remaining calls have eluded me, aside from invoking a popen on ps or top and parsing the output - which isn't acceptable. Any help would be greatly appreciated.</p>
<p>Requirements:<br/>
Compiles on g++ 4.0<br/>
No obj-c<br/>
OSX 10.5<br/></p>
|
[
{
"answer_id": 220546,
"author": "DGentry",
"author_id": 4761,
"author_profile": "https://Stackoverflow.com/users/4761",
"pm_score": 3,
"selected": false,
"text": "#include <sys/resource.h>\n\nstruct rusage r_usage;\n\nif (getrusage(RUSAGE_SELF, &r_usage)) {\n /* ... error handling ... */\n}\n\nprintf(\"Total User CPU = %ld.%ld\\n\",\n r_usage.ru_utime.tv_sec,\n r_usage.ru_utime.tv_usec);\nprintf(\"Total System CPU = %ld.%ld\\n\",\n r_usage.ru_stime.tv_sec,\n r_usage.ru_stime.tv_usec);\n"
},
{
"answer_id": 220908,
"author": "diciu",
"author_id": 2811,
"author_profile": "https://Stackoverflow.com/users/2811",
"pm_score": 5,
"selected": true,
"text": "pidinfo cristi:~ diciu$ grep proc_pidinfo /usr/include/libproc.h\n\nint proc_pidinfo(int pid, int flavor, uint64_t arg, void *buffer, int buffersize);\n host_statistics cristi:~ diciu$ grep -r host_statistics /usr/include/\n\n/usr/include/mach/host_info.h:/* host_statistics() */\n\n/usr/include/mach/mach_host.defs:routine host_statistics(\n\n/usr/include/mach/mach_host.h:/* Routine host_statistics */\n\n/usr/include/mach/mach_host.h:kern_return_t host_statistics\n top lsof /*\n * This header file contains private interfaces to obtain process information.\n * These interfaces are subject to change in future releases.\n */\n"
},
{
"answer_id": 16522537,
"author": "hamed",
"author_id": 1859571,
"author_profile": "https://Stackoverflow.com/users/1859571",
"pm_score": 2,
"selected": false,
"text": "void IsInBSDProcessList(char *name) { \n assert( name != NULL); \n kinfo_proc *result; \n size_t count = 0; \n result = (kinfo_proc *)malloc(sizeof(kinfo_proc)); \n if(GetBSDProcessList(&result,&count) == 0) { \n for (int i = 0; i < count; i++) { \n kinfo_proc *proc = NULL; \n proc = &result[i]; \n }\n } \n free(result);\n}\n"
}
] |
2008/10/20
|
[
"https://Stackoverflow.com/questions/220323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29810/"
] |
220,340
|
<p>I want to be able to check the status of a publication and subscription in SQL Server 2008 T-SQL. I want to be able to determine if its okay, when was the last successful, sync, etc.. Is this possible?</p>
|
[
{
"answer_id": 4036445,
"author": "Denaem",
"author_id": 331461,
"author_profile": "https://Stackoverflow.com/users/331461",
"pm_score": 5,
"selected": false,
"text": "SELECT \n(CASE \n WHEN mdh.runstatus = '1' THEN 'Start - '+cast(mdh.runstatus as varchar)\n WHEN mdh.runstatus = '2' THEN 'Succeed - '+cast(mdh.runstatus as varchar)\n WHEN mdh.runstatus = '3' THEN 'InProgress - '+cast(mdh.runstatus as varchar)\n WHEN mdh.runstatus = '4' THEN 'Idle - '+cast(mdh.runstatus as varchar)\n WHEN mdh.runstatus = '5' THEN 'Retry - '+cast(mdh.runstatus as varchar)\n WHEN mdh.runstatus = '6' THEN 'Fail - '+cast(mdh.runstatus as varchar)\n ELSE CAST(mdh.runstatus AS VARCHAR)\nEND) [Run Status], \nmda.subscriber_db [Subscriber DB], \nmda.publication [PUB Name],\nright(left(mda.name,LEN(mda.name)-(len(mda.id)+1)), LEN(left(mda.name,LEN(mda.name)-(len(mda.id)+1)))-(10+len(mda.publisher_db)+(case when mda.publisher_db='ALL' then 1 else LEN(mda.publication)+2 end))) [SUBSCRIBER],\nCONVERT(VARCHAR(25),mdh.[time]) [LastSynchronized],\nund.UndelivCmdsInDistDB [UndistCom], \nmdh.comments [Comments], \n'select * from distribution.dbo.msrepl_errors (nolock) where id = ' + CAST(mdh.error_id AS VARCHAR(8)) [Query More Info],\nmdh.xact_seqno [SEQ_NO],\n(CASE \n WHEN mda.subscription_type = '0' THEN 'Push' \n WHEN mda.subscription_type = '1' THEN 'Pull' \n WHEN mda.subscription_type = '2' THEN 'Anonymous' \n ELSE CAST(mda.subscription_type AS VARCHAR)\nEND) [SUB Type],\n\nmda.publisher_db+' - '+CAST(mda.publisher_database_id as varchar) [Publisher DB],\nmda.name [Pub - DB - Publication - SUB - AgentID]\nFROM distribution.dbo.MSdistribution_agents mda \nLEFT JOIN distribution.dbo.MSdistribution_history mdh ON mdh.agent_id = mda.id \nJOIN \n (SELECT s.agent_id, MaxAgentValue.[time], SUM(CASE WHEN xact_seqno > MaxAgentValue.maxseq THEN 1 ELSE 0 END) AS UndelivCmdsInDistDB \n FROM distribution.dbo.MSrepl_commands t (NOLOCK) \n JOIN distribution.dbo.MSsubscriptions AS s (NOLOCK) ON (t.article_id = s.article_id AND t.publisher_database_id=s.publisher_database_id ) \n JOIN \n (SELECT hist.agent_id, MAX(hist.[time]) AS [time], h.maxseq \n FROM distribution.dbo.MSdistribution_history hist (NOLOCK) \n JOIN (SELECT agent_id,ISNULL(MAX(xact_seqno),0x0) AS maxseq \n FROM distribution.dbo.MSdistribution_history (NOLOCK) \n GROUP BY agent_id) AS h \n ON (hist.agent_id=h.agent_id AND h.maxseq=hist.xact_seqno) \n GROUP BY hist.agent_id, h.maxseq \n ) AS MaxAgentValue \n ON MaxAgentValue.agent_id = s.agent_id \n GROUP BY s.agent_id, MaxAgentValue.[time] \n ) und \nON mda.id = und.agent_id AND und.[time] = mdh.[time] \nwhere mda.subscriber_db<>'virtual' -- created when your publication has the immediate_sync property set to true. This property dictates whether snapshot is available all the time for new subscriptions to be initialized. This affects the cleanup behavior of transactional replication. If this property is set to true, the transactions will be retained for max retention period instead of it getting cleaned up as soon as all the subscriptions got the change.\n--and mdh.runstatus='6' --Fail\n--and mdh.runstatus<>'2' --Succeed\norder by mdh.[time]\n"
},
{
"answer_id": 70593923,
"author": "JM1",
"author_id": 3729714,
"author_profile": "https://Stackoverflow.com/users/3729714",
"pm_score": 0,
"selected": false,
"text": "-------------------------------------------------------------------------------------------------------------------------\n-- PUBLISHER SCRIPT\n-------------------------------------------------------------------------------------------------------------------------\n\nIF OBJECT_ID ('tempdb..#tmp_replicationPub_monitordata') IS NOT NULL DROP TABLE #tmp_replicationPub_monitordata;\n\nCREATE TABLE #tmp_replicationPub_monitordata (\n publisher_db sysname\n , publication sysname\n , publication_id INT\n , publication_type INT\n , status INT -- publication status defined as max(status) among all agents\n , warning INT -- publication warning defined as max(isnull(warning,0)) among all agents\n , worst_latency INT\n , best_latency INT\n , average_latency INT\n , last_distsync DATETIME -- last sync time\n , retention INT -- retention period \n , latencythreshold INT\n , expirationthreshold INT\n , agentnotrunningthreshold INT\n , subscriptioncount INT -- # of subscription\n , runningdistagentcount INT -- # of running agents\n , snapshot_agentname sysname NULL\n , logreader_agentname sysname NULL\n , qreader_agentname sysname NULL\n , worst_runspeedPerf INT\n , best_runspeedPerf INT\n , average_runspeedPerf INT\n , retention_period_unit TINYINT\n , publisher sysname NULL\n);\n\nINSERT INTO #tmp_replicationPub_monitordata\nEXEC sp_replmonitorhelppublication;\n\nSELECT (CASE WHEN status = '1' THEN 'Start - ' + CAST(status AS VARCHAR)\n WHEN status = '2' THEN 'Succeed - ' + CAST(status AS VARCHAR)\n WHEN status = '3' THEN 'InProgress - ' + CAST(status AS VARCHAR)\n WHEN status = '4' THEN 'Idle - ' + CAST(status AS VARCHAR)\n WHEN status = '5' THEN 'Retry - ' + CAST(status AS VARCHAR)\n WHEN status = '6' THEN 'Fail - ' + CAST(status AS VARCHAR)ELSE CAST(status AS VARCHAR)END) [Run Status]\n , publisher_db\n , publication\n , publication_id\n , (CASE WHEN publication_type = '0' THEN 'Transactional - ' + CAST(publication_type AS VARCHAR)\n WHEN publication_type = '1' THEN 'Snapshot - ' + CAST(publication_type AS VARCHAR)\n WHEN publication_type = '2' THEN 'Merge - ' + CAST(publication_type AS VARCHAR)ELSE '' END) AS [Publication Type]\n , (CASE WHEN warning = '1' THEN 'Expiration' + CAST(warning AS VARCHAR)\n WHEN warning = '2' THEN 'Latency' + CAST(warning AS VARCHAR)\n WHEN warning = '4' THEN 'Mergeexpiration' + CAST(warning AS VARCHAR)\n WHEN warning = '16' THEN 'Mergeslowrunduration' + CAST(warning AS VARCHAR)\n WHEN warning = '32' THEN 'Mergefastrunspeed' + CAST(warning AS VARCHAR)\n WHEN warning = '64' THEN 'Mergeslowrunspeed' + CAST(warning AS VARCHAR)END) warning\n , worst_latency\n , best_latency\n , average_latency\n , last_distsync\n , retention\n , latencythreshold\n , expirationthreshold\n , agentnotrunningthreshold\n , subscriptioncount\n , runningdistagentcount\n , snapshot_agentname\n , logreader_agentname\n , qreader_agentname\n , worst_runspeedPerf\n , best_runspeedPerf\n , average_runspeedPerf\n , retention_period_unit\n , publisher\nFROM #tmp_replicationPub_monitordata\nORDER BY publication;\n\n-------------------------------------------------------------------------------------------------------------------------\n-- SUBSCRIBER SCRIPT\n-------------------------------------------------------------------------------------------------------------------------\nIF OBJECT_ID ('tempdb..#tmp_rep_monitordata ') IS NOT NULL DROP TABLE #tmp_rep_monitordata;\n\nCREATE TABLE #tmp_rep_monitordata (\n status INT NULL\n , warning INT NULL\n , subscriber sysname NULL\n , subscriber_db sysname NULL\n , publisher_db sysname NULL\n , publication sysname NULL\n , publication_type INT NULL\n , subtype INT NULL\n , latency INT NULL\n , latencythreshold INT NULL\n , agentnotrunning INT NULL\n , agentnotrunningthreshold INT NULL\n , timetoexpiration INT NULL\n , expirationthreshold INT NULL\n , last_distsync DATETIME NULL\n , distribution_agentname sysname NULL\n , mergeagentname sysname NULL\n , mergesubscriptionfriendlyname sysname NULL\n , mergeagentlocation sysname NULL\n , mergeconnectiontype INT NULL\n , mergePerformance INT NULL\n , mergerunspeed FLOAT NULL\n , mergerunduration INT NULL\n , monitorranking INT NULL\n , distributionagentjobid BINARY(16) NULL\n , mergeagentjobid BINARY(16) NULL\n , distributionagentid INT NULL\n , distributionagentprofileid INT NULL\n , mergeagentid INT NULL\n , mergeagentprofileid INT NULL\n , logreaderagentname sysname NULL\n , publisher sysname NULL\n);\n\nINSERT INTO #tmp_rep_monitordata\nEXEC sp_replmonitorhelpsubscription @publication_type = 0;\n\nINSERT INTO #tmp_rep_monitordata\nEXEC sp_replmonitorhelpsubscription @publication_type = 1;\n\nSELECT (CASE WHEN status = '1' THEN 'Start - ' + CAST(status AS VARCHAR)\n WHEN status = '2' THEN 'Succeed - ' + CAST(status AS VARCHAR)\n WHEN status = '3' THEN 'InProgress - ' + CAST(status AS VARCHAR)\n WHEN status = '4' THEN 'Idle - ' + CAST(status AS VARCHAR)\n WHEN status = '5' THEN 'Retry - ' + CAST(status AS VARCHAR)\n WHEN status = '6' THEN 'Fail - ' + CAST(status AS VARCHAR)ELSE CAST(status AS VARCHAR)END) [Run Status]\n , publisher_db\n , publication\n , (CASE WHEN warning = '1' THEN 'Expiration' + CAST(warning AS VARCHAR)\n WHEN warning = '2' THEN 'Latency' + CAST(warning AS VARCHAR)\n WHEN warning = '4' THEN 'Mergeexpiration' + CAST(warning AS VARCHAR)\n WHEN warning = '16' THEN 'Mergeslowrunduration' + CAST(warning AS VARCHAR)\n WHEN warning = '32' THEN 'Mergefastrunspeed' + CAST(warning AS VARCHAR)\n WHEN warning = '64' THEN 'Mergeslowrunspeed' + CAST(warning AS VARCHAR)END) warning\n , subscriber\n , subscriber_db\n , (CASE WHEN publication_type = '0' THEN 'Transactional - ' + CAST(publication_type AS VARCHAR)\n WHEN publication_type = '1' THEN 'Snapshot - ' + CAST(publication_type AS VARCHAR)\n WHEN publication_type = '2' THEN 'Merge - ' + CAST(publication_type AS VARCHAR)ELSE '' END) AS [Publication Type]\n , (CASE WHEN subtype = '0' THEN 'Push - ' + CAST(subtype AS VARCHAR)\n WHEN subtype = '1' THEN 'Pull - ' + CAST(subtype AS VARCHAR)\n WHEN subtype = '2' THEN 'Anonymous - ' + CAST(subtype AS VARCHAR)ELSE '' END) AS SubscriptionType\n , latency\n , latencythreshold\n , agentnotrunning\n , agentnotrunningthreshold\n , last_distsync\n , timetoexpiration\n , expirationthreshold\n , distribution_agentname\n , monitorranking\n , distributionagentjobid\n , mergeagentjobid\n , distributionagentid\n , distributionagentprofileid\n , mergeagentid\n , mergeagentprofileid\n , logreaderagentname\n , publisher\nFROM #tmp_rep_monitordata\nORDER BY publication ASC;\n"
}
] |
2008/10/20
|
[
"https://Stackoverflow.com/questions/220340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17222/"
] |
220,342
|
<p>In MonoRail you can just CancelLayout() to not render the layout. In ASP.NET MVC, the only way to affect the layout seems to be to pass the layout name into the View() method like View("myview", "mylayout"); only it seems that passing null or an empty string doesn't do what I'd want. </p>
<p>I ended up creating an empty layout that just rendered the content, but that seems silly.</p>
<p>"Not Render the layout" means exactly that. In the web forms view engine they call layouts "master pages". I want to render <em>just</em> my action's view and not surround it with the master page.</p>
|
[
{
"answer_id": 4730049,
"author": "expdiant",
"author_id": 108260,
"author_profile": "https://Stackoverflow.com/users/108260",
"pm_score": 7,
"selected": false,
"text": " @{\n Layout = \"\"; \n }\n"
},
{
"answer_id": 10137056,
"author": "berzinsu",
"author_id": 1330998,
"author_profile": "https://Stackoverflow.com/users/1330998",
"pm_score": 6,
"selected": false,
"text": "@{\n Layout = null;\n}\n"
},
{
"answer_id": 26795768,
"author": "TomCat",
"author_id": 2039603,
"author_profile": "https://Stackoverflow.com/users/2039603",
"pm_score": 4,
"selected": false,
"text": "return View(\"Index\", \"_LAYOUT_NAME\", model);\n"
},
{
"answer_id": 35004830,
"author": "Chris Halcrow",
"author_id": 1549918,
"author_profile": "https://Stackoverflow.com/users/1549918",
"pm_score": 4,
"selected": false,
"text": "@{\n Layout = null;\n}\n @{\n Layout = \"~/Views/Shared/_Layout.cshtml\";\n}\n"
},
{
"answer_id": 39312337,
"author": "Simon Weaver",
"author_id": 5286812,
"author_profile": "https://Stackoverflow.com/users/5286812",
"pm_score": 2,
"selected": false,
"text": "masterPage \"\" null View PartialView public ActionResult Article(string id)\n {\n return PartialView(\"~/Areas/Store/Views/CustomerService/\" + id);\n }\n"
},
{
"answer_id": 48833695,
"author": "lat94",
"author_id": 7004017,
"author_profile": "https://Stackoverflow.com/users/7004017",
"pm_score": 3,
"selected": false,
"text": "@{\n Layout = null;\n}\n public ActionResult Index()\n{\n SampleModel model = new SampleModel();\n //Any Logic\n return View(\"Index\", \"_WebmasterLayout\", model);\n}\n"
}
] |
2008/10/20
|
[
"https://Stackoverflow.com/questions/220342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11229/"
] |
220,374
|
<p>I have just started migrating my homegrown persistence framework to JPA.</p>
<p>Given that the persistence frameworks hide a lot of the plumbing, I'm interested in knowing if NOT closing EntityManagers will create a resource leak, or if the frameworks will collect and close them for me.</p>
<p>I intend in all places to close them, but do I HAVE to?</p>
<p>At the moment using TopLink, just because it works with NetBeans easily, but am happy to investigate other JPA providers.</p>
|
[
{
"answer_id": 12474357,
"author": "Puneet",
"author_id": 1366477,
"author_profile": "https://Stackoverflow.com/users/1366477",
"pm_score": 3,
"selected": false,
"text": "EntityManager @PersistenceContext maxPoolSize EntityManager EntityManagerFactory entitymanager.close() c3p0"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20150/"
] |
220,382
|
<p>I need to write robust code in .NET to enable a windows service (server 2003) to restart itself. What is the best way to so this? Is there some .NET API to do it?</p>
|
[
{
"answer_id": 220451,
"author": "TheSoftwareJedi",
"author_id": 18941,
"author_profile": "https://Stackoverflow.com/users/18941",
"pm_score": 9,
"selected": true,
"text": "Environment.Exit(1)"
},
{
"answer_id": 538825,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "cmd.exe Process process = new Process();\n process.StartInfo.FileName = \"cmd\";\n process.StartInfo.Arguments = \"/c net stop \\\"servicename\\\" & net start \\\"servicename\\\"\";\n process.Start();\n"
},
{
"answer_id": 3916431,
"author": "Lee Smith",
"author_id": 180329,
"author_profile": "https://Stackoverflow.com/users/180329",
"pm_score": -1,
"selected": false,
"text": "private static void RestartService(string serviceName)\n {\n using (var controller = new ServiceController(serviceName))\n {\n controller.Stop();\n int counter = 0;\n while (controller.Status != ServiceControllerStatus.Stopped)\n {\n Thread.Sleep(100);\n controller.Refresh();\n counter++;\n if (counter > 1000)\n {\n throw new System.TimeoutException(string.Format(\"Could not stop service: {0}\", Constants.Series6Service.WindowsServiceName));\n }\n }\n\n controller.Start();\n }\n }\n"
},
{
"answer_id": 6183346,
"author": "Khalid Rahaman",
"author_id": 55688,
"author_profile": "https://Stackoverflow.com/users/55688",
"pm_score": 5,
"selected": false,
"text": "Dim proc As New Process()\nDim psi As New ProcessStartInfo()\n\npsi.CreateNoWindow = True\npsi.FileName = \"cmd.exe\"\npsi.Arguments = \"/C net stop YOURSERVICENAMEHERE && net start YOURSERVICENAMEHERE\"\npsi.LoadUserProfile = False\npsi.UseShellExecute = False\npsi.WindowStyle = ProcessWindowStyle.Hidden\nproc.StartInfo = psi\nproc.Start()\n"
},
{
"answer_id": 15973556,
"author": "Filip",
"author_id": 1430750,
"author_profile": "https://Stackoverflow.com/users/1430750",
"pm_score": 4,
"selected": false,
"text": "const string strCmdText = \"/C net stop \\\"SERVICENAME\\\"&net start \\\"SERVICENAME\\\"\";\nProcess.Start(\"CMD.exe\", strCmdText);\n SERVICENAME"
},
{
"answer_id": 25304115,
"author": "Erik Martino",
"author_id": 679892,
"author_profile": "https://Stackoverflow.com/users/679892",
"pm_score": 0,
"selected": false,
"text": "@echo on\nset once=\"C:\\Program Files\\MyService\\once.bat\"\nset taskname=Restart_MyService\nset service=MyService\necho rem %time% >%once%\necho net stop %service% >>%once%\necho net start %service% >>%once%\necho del %once% >>%once%\n\nschtasks /create /ru \"System\" /tn %taskname% /tr '%once%' /sc onstart /F /V1 /Z\nschtasks /run /tn %taskname%\n"
},
{
"answer_id": 36894173,
"author": "buzzard51",
"author_id": 3235770,
"author_profile": "https://Stackoverflow.com/users/3235770",
"pm_score": 2,
"selected": false,
"text": "...\n\nbool ABORT;\n\nprotected override void OnStop()\n{\n Logger.log(\"Stopping service\");\n WorkThreadRun = false;\n WorkThread.Join();\n Logger.stop();\n // if there was a problem, set an exit error code\n // so the service manager will restart this\n if(ABORT)Environment.Exit(1);\n}\n ...\n\nif(NeedToRestart)\n{\n ABORT = true;\n new Thread(RestartThread).Start();\n}\n\nvoid RestartThread()\n{\n ServiceController sc = new ServiceController(ServiceName);\n try\n {\n sc.Stop();\n }\n catch (Exception) { }\n}\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1363/"
] |
220,387
|
<p>What's the simplest way to join one or more arrays (or ArrayLists) in Visual Basic?</p>
<p>I'm using .NET 3.5, if that matters much.</p>
|
[
{
"answer_id": 220481,
"author": "TheSoftwareJedi",
"author_id": 18941,
"author_profile": "https://Stackoverflow.com/users/18941",
"pm_score": 4,
"selected": false,
"text": "int[] a = new int[] { 1, 2, 3, 4, 5 };\nint[] b = new int[] { 6, 7, 8, 9, 10 };\nint[] c = a.Union(b).ToArray();\n int[] a = new int[] { 1, 2, 3, 4, 5 };\nint[] b = new int[] { 6, 7, 8, 9, 10 };\nIEnumerable<int> c = a.Union(b);\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13563/"
] |
220,392
|
<p>This is the exception that I'm getting when I'm trying to bind to a System.Type.Name.</p>
<p>Here is what I'm doing:</p>
<pre><code>this.propertyTypeBindingSource.DataSource = typeof(System.Type);
/* snip */
this.nameTextBox1.DataBindings.Add(
new System.Windows.Forms.Binding(
"Text",
this.propertyTypeBindingSource,
"Name", true));
</code></pre>
<p>Is there some trick with binding to System.Type, is it not allowed or is there any workaround? Have no problems with binding to other types.</p>
|
[
{
"answer_id": 220425,
"author": "Evgeny",
"author_id": 26447,
"author_profile": "https://Stackoverflow.com/users/26447",
"pm_score": 3,
"selected": true,
"text": "public class StubPropertyType\n{\n public StubPropertyType(Type type)\n {\n this.StubPropertyTypeName = type.Name;\n }\n\n public string StubPropertyTypeName = string.Empty;\n}\n this.propertyStubBindingSource.DataSource = typeof(StubPropertyType);\n this.nameTextBox.DataBindings.Add(\n new System.Windows.Forms.Binding(\n \"Text\", \n this.propertyStubBindingSource, \n \"StubPropertyTypeName\", \n true));\n"
},
{
"answer_id": 220901,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": false,
"text": "bindingSource1.DataSource = typeof(MyObject);\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26447/"
] |
220,393
|
<p>This seems like a pretty stupid question, but I'm trying to figure out the best way to do this. Would you simply redirect to a /Logout page and have the controller call the FormsAuthentication.SignOut function?</p>
<p>That was my first thought, but then I wondered if it could be abused by third party websites. Let's say someone just decides to post a link to your /Logout page. The user would get signed out of your application. Is there a good way to prevent that?</p>
|
[
{
"answer_id": 220403,
"author": "Schotime",
"author_id": 29376,
"author_profile": "https://Stackoverflow.com/users/29376",
"pm_score": 2,
"selected": false,
"text": "public ActionResult Logout()\n{\n FormsAuthentication.SignOut();\n return RedirectToAction(\"Index\", \"Home\");\n}\n"
},
{
"answer_id": 220676,
"author": "Matt Hinze",
"author_id": 2676,
"author_profile": "https://Stackoverflow.com/users/2676",
"pm_score": 1,
"selected": false,
"text": "public class LogoutResult : ActionResult\n{\n private readonly IAuthenticationService _authenticationService;\n private readonly IWebContext _context;\n\n public LogoutResult(IAuthenticationService authenticationService, IWebContext context)\n {\n _authenticationService = authenticationService;\n _context = context;\n }\n\n public override void ExecuteResult(ControllerContext context)\n {\n _authenticationService.Logout();\n _context.Abandon();\n _context.Redirect(\"~/\");\n }\n}\n"
},
{
"answer_id": 23624831,
"author": "rhughes",
"author_id": 1213006,
"author_profile": "https://Stackoverflow.com/users/1213006",
"pm_score": 2,
"selected": false,
"text": "[Authorize]\npublic RedirectResult Logout()\n{\n FormsAuthentication.SignOut();\n\n return this.Redirect(\"/\");\n}\n Logout Authorize"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220393",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1574/"
] |
220,405
|
<p>I have a web application that I'm writing (C#, MSSQL) and I need to store the timestamp when a record is stored in the system. Normally, I would just do this with SQL and the DATETIME function. However, the server is located in a different time zone than our company is located... AND we may change to another server in completely different time zone. The hosting company will not change the server time to match our local time zone. (Not that I blame them, but it was one thing I tried.)</p>
<p>So, my question is, what is the best way to store the date/time of the record update and what is the best way to present that date/time back to the user in our local time zone?</p>
<p>I want the least messy way of doing this, so a combo of C# and SQL would be fine as long as the solution is easy to implement. (My normal style is to do more work in stored procedures and less in C#, if that matters.)</p>
<p>Can you show me some sample code? Thanks!</p>
|
[
{
"answer_id": 220706,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 5,
"selected": true,
"text": "-- convert UTC to local time\ncreate FUNCTION [dbo].[udfUtcToLocalTime]\n(\n @gmt datetime\n)\nRETURNS datetime\nAS\nBEGIN\n DECLARE @dt datetime\n SELECT \n @dt = dateadd(millisecond,datediff(millisecond,getutcdate(), getdate()),@gmt)\n RETURN @dt\nEND\n SELECT dbo.udfUtcToLocalTime(someDateTimeField)\nFROM someTable\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20848/"
] |
220,423
|
<p>From time to time, I run into communications issue with other programmers, when we talk about NULL. Now NULL could be
<BR>
<BR> a NULL pointer
<BR> the NUL character
<BR> an empty data element in some sort of database.</p>
<p><BR> NUL seems to be the most confusing. It is the ASCII character 0x00.
<BR> I tend to use '\0' in my code to represent it. Some developers in my group
<BR> tend to prefer to simply use 0, and let the compiler implicitly cast it to a char.</p>
<p><BR> What do you prefer to use for NUL? and why?</p>
|
[
{
"answer_id": 220434,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 4,
"selected": true,
"text": "'\\0' NULL 0 '\\0' int char char"
},
{
"answer_id": 220530,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 0,
"selected": false,
"text": "const char END_OF_STRING = '\\0';\n str[i] = END_OF_STRING;\n if (*ptr == END_OF_STRING)\n"
},
{
"answer_id": 221408,
"author": "Steve Jessop",
"author_id": 13005,
"author_profile": "https://Stackoverflow.com/users/13005",
"pm_score": 1,
"selected": false,
"text": "#define ASCII_NUL ('\\0')\n"
},
{
"answer_id": 221437,
"author": "Graeme Perrow",
"author_id": 1821,
"author_profile": "https://Stackoverflow.com/users/1821",
"pm_score": 0,
"selected": false,
"text": "#define NULLCHAR '\\0'\n"
},
{
"answer_id": 221458,
"author": "Gorpik",
"author_id": 25824,
"author_profile": "https://Stackoverflow.com/users/25824",
"pm_score": 1,
"selected": false,
"text": "#define NULL 0\n#define END_OF_STRING '\\0'\n #define SEVEN 7\n"
},
{
"answer_id": 224795,
"author": "orj",
"author_id": 20480,
"author_profile": "https://Stackoverflow.com/users/20480",
"pm_score": 2,
"selected": false,
"text": "#define NULL ((void*)0)\n // Example taken from wikibooks.org\nstd::string * str = NULL; // Can't automatically cast void * to std::string *\nvoid (C::*pmf) () = &C::func;\nif (pmf == NULL) {} // Can't automatically cast from void * to pointer to member function.\n #ifdef __cplusplus\n#define NULL (0)\n#else\n#define NULL ((void*)0)\n#endif\n nullptr"
},
{
"answer_id": 413256,
"author": "EvilTeach",
"author_id": 7734,
"author_profile": "https://Stackoverflow.com/users/7734",
"pm_score": 2,
"selected": false,
"text": "A one-L NUL, it ends a string. \nA two-L NULL points to no thing. \nAnd I will bet a golden bull \nThat there is no three-L NULLL. \n\n\n\n(The name of the original author is, alas, lost to the sands of time.)\n"
},
{
"answer_id": 1170523,
"author": "Martin Geisler",
"author_id": 110204,
"author_profile": "https://Stackoverflow.com/users/110204",
"pm_score": 0,
"selected": false,
"text": "comp.lang.c"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7734/"
] |
220,432
|
<p>Say I have an array of strings in a php array called $foo with a few hundred entries, and I have a MySQL table 'people' that has a field named 'name' with a few thousand entries. What is an efficient way to find out which strings in $foo aren't a 'name' in an entry in 'people' without submitting a query for every string in $foo? </p>
<p>So I want to find out what strings in $foo have not already been entered in 'people.'</p>
<p>Note that it is clear that all of the data will have to be on one box at one point. The goal would be doing this at the same time minimizing the number of queries and the amount of php processing.</p>
|
[
{
"answer_id": 220497,
"author": "jakber",
"author_id": 29812,
"author_profile": "https://Stackoverflow.com/users/29812",
"pm_score": 1,
"selected": false,
"text": " $list = join(\",\", $foo);\n\n// fetch all rows of the result of \n// \"SELECT name FROM people WHERE name IN($list)\" \n// into an array $result\n\n$missing_names = array_diff($foo, $result);\n"
},
{
"answer_id": 220509,
"author": "cole",
"author_id": 910,
"author_profile": "https://Stackoverflow.com/users/910",
"pm_score": 0,
"selected": false,
"text": "$query = 'SELECT name FROM table WHERE name != '.implode(' OR name != '. $foo);\n"
},
{
"answer_id": 220599,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 1,
"selected": true,
"text": "CREATE TEMPORARY TABLE PhpArray (name varchar(50));\n\n-- you can probably do this more efficiently\nINSERT INTO PhpArray VALUES ($foo[0]), ($foo[1]), ...;\n\nSELECT People.*\nFROM People\n LEFT OUTER JOIN PhpArray USING (name)\nWHERE PhpArray.name IS NULL;\n"
},
{
"answer_id": 221007,
"author": "Darryl Hein",
"author_id": 5441,
"author_profile": "https://Stackoverflow.com/users/5441",
"pm_score": 1,
"selected": false,
"text": "SELECT name FROM people WHERE name IN (imploded list of names) array_diff() INSERT ... SELECT"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10393/"
] |
220,437
|
<p>According to the <a href="http://ca3.php.net/manual/en/function.get-magic-quotes-gpc.php" rel="noreferrer">PHP manual</a>, in order to make code more portable, they recommend using something like the following for escaping data:</p>
<pre><code>if (!get_magic_quotes_gpc()) {
$lastname = addslashes($_POST['lastname']);
} else {
$lastname = $_POST['lastname'];
}
</code></pre>
<p>I have other validation checks that I will be performing, but how secure is the above strictly in terms of escaping data? I also saw that magic quotes will be deprecated in PHP 6. How will that affect the above code? I would prefer not to have to rely on a database-specific escaping function like mysql_real_escape_string().</p>
|
[
{
"answer_id": 220490,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 3,
"selected": false,
"text": "<?php\n\n// Strips slashes recursively only up to 3 levels to prevent attackers from\n// causing a stack overflow error.\nfunction stripslashes_array(&$array, $iterations=0) {\n if ($iterations < 3) {\n foreach ($array as $key => $value) {\n if (is_array($value)) {\n stripslashes_array($array[$key], $iterations + 1);\n } else {\n $array[$key] = stripslashes($array[$key]);\n }\n }\n }\n}\n\nif (get_magic_quotes_gpc()) {\n stripslashes_array($_GET);\n stripslashes_array($_POST);\n stripslashes_array($_COOKIE);\n}\n\n?>\n"
},
{
"answer_id": 220993,
"author": "Darryl Hein",
"author_id": 5441,
"author_profile": "https://Stackoverflow.com/users/5441",
"pm_score": 0,
"selected": false,
"text": "addslashes()"
},
{
"answer_id": 221180,
"author": "MarkR",
"author_id": 13724,
"author_profile": "https://Stackoverflow.com/users/13724",
"pm_score": 4,
"selected": false,
"text": "if (get_magic_quotes_gpc()) {\n throw new Exception(\"Turn magic quotes off now!\");\n}\n"
},
{
"answer_id": 325534,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "if (get_magic_quotes_gpc()) { \n $_REQUEST = array_map('stripslashes', $_REQUEST); \n $_GET = array_map('stripslashes', $_GET);\n $_POST = array_map('stripslashes', $_POST);\n $_GET = array_map('stripslashes', $_COOKIES);\n\n }\n"
},
{
"answer_id": 441790,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "filter_* $_POST magic_quotes_gpc if (!get_magic_quotes_gpc()) {\n $lastname = addslashes($_POST['lastname']);\n} else {\n $lastname = $_POST['lastname'];\n}\n $lastname = filter_input(INPUT_POST, 'lastname');\n"
},
{
"answer_id": 441832,
"author": "too much php",
"author_id": 28835,
"author_profile": "https://Stackoverflow.com/users/28835",
"pm_score": 0,
"selected": false,
"text": "if (get_magic_quotes_gpc()) {\n $lastname = stripslashes($_POST['lastname']);\n} else {\n $lastname = $_POST['lastname'];\n}\n echo htmlentities() mysql_real_escape_string() echo json_encode()"
},
{
"answer_id": 2688559,
"author": "gnarf",
"author_id": 91914,
"author_profile": "https://Stackoverflow.com/users/91914",
"pm_score": 0,
"selected": false,
"text": "if (get_magic_quotes_gpc())\n{\n $_GET = json_decode(stripslashes(json_encode($_GET, JSON_HEX_APOS)), true);\n $_POST = json_decode(stripslashes(json_encode($_POST, JSON_HEX_APOS)), true);\n $_COOKIE = json_decode(stripslashes(json_encode($_COOKIE, JSON_HEX_APOS)), true);\n $_REQUEST = json_decode(stripslashes(json_encode($_REQUEST, JSON_HEX_APOS)), true);\n ini_set('magic_quotes_gpc', 0);\n}\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13281/"
] |
220,439
|
<p>I'm trying to make a triangle (isosceles triangle) to move around the screen and at the same time slightly rotate it when a user presses a directional key (like right or left).</p>
<p>I would like the nose (top point) of the triangle to lead the triangle at all times. (Like that old asteroids game).</p>
<p>My problem is with the maths behind this. At every X time interval, I want the triangle to move in "some direction", I need help finding this direction (x and y increments/decrements).</p>
<p>I can find the center point (Centroid) of the triangle, and I have the top most x an y points, so I have a line vector to work with, but not a clue as to "how" to work with it.</p>
<p>I think it has something to do with the old Sin and Cos methods and the amount (angle) that the triangle has been rotated, but I'm a bit rusty on that stuff.</p>
<p>Any help is greatly appreciated.</p>
|
[
{
"answer_id": 220468,
"author": "Loren Pechtel",
"author_id": 10659,
"author_profile": "https://Stackoverflow.com/users/10659",
"pm_score": 2,
"selected": false,
"text": "x' = x + speed * cos(angle)\ny' = y + speed * sin(angle)\n"
},
{
"answer_id": 220471,
"author": "jakber",
"author_id": 29812,
"author_profile": "https://Stackoverflow.com/users/29812",
"pm_score": 0,
"selected": false,
"text": "double v; // velocity\ndouble theta; // direction of travel (angle)\ndouble dt; // time elapsed\n\n// To compute increments\ndouble dx = v*dt*cos(theta);\ndouble dy = v*dt*sin(theta);\n\n// To compute position of the top of the triangle\ndouble size; // distance between centroid and top\ndouble top_x = x + size*cos(theta);\ndouble top_y = y + size*sin(theta);\n"
},
{
"answer_id": 249337,
"author": "Loren Pechtel",
"author_id": 10659,
"author_profile": "https://Stackoverflow.com/users/10659",
"pm_score": 0,
"selected": false,
"text": "double tip_x = 10;\ndouble tip_y = 10;\n\nshould be\n\ndouble center_x = 10;\ndouble center_y = 10;\n int width = 6; //base\nint height = 9;\n angle = rotation_angle + vertex[1].angle;\ndist = vertex[1].distance; \np1_x = center_x + math.cos(angle) * dist;\np1_y = center_y - math.sin(angle) * dist;\n// and the same for the other two points\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26310/"
] |
220,445
|
<p>How would I be able to programmatically search and replace some text in a large number of PDF files? I would like to remove a URL that has been added to a set of files. I have been able to remove the link using javascript under Batch Processing in Adobe Pro, but the link text remains. I have seen recommendations to use text touchup, which works manually, but I don't want to modify 1300 files manually.</p>
|
[
{
"answer_id": 220791,
"author": "Chris Dolan",
"author_id": 14783,
"author_profile": "https://Stackoverflow.com/users/14783",
"pm_score": 5,
"selected": true,
"text": " $ cpan install CAM::PDF\n # start a new terminal if this is your first cpan module\n $ changepagestring.pl input.pdf oldtext newtext output.pdf\n"
},
{
"answer_id": 67439448,
"author": "Tilal Ahmad",
"author_id": 1368028,
"author_profile": "https://Stackoverflow.com/users/1368028",
"pm_score": -1,
"selected": false,
"text": "\nconst { PdfApi } = require(\"asposepdfcloud\");\nconst { TextReplaceListRequest }= require(\"asposepdfcloud/src/models/textReplaceListRequest\");\nconst { TextReplace }= require(\"asposepdfcloud/src/models/textReplace\");\n\n// Get Client ID and Client Secret from https://dashboard.aspose.cloud/\npdfApi = new PdfApi(\"xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx\", \"xxxxxxxxxxxxxxxxxxxxxx\");\nvar fs = require('fs');\n\nconst name = \"02_pages.pdf\";\nconst remoteTempFolder = \"Temp\";\n//const localTestDataFolder = \"C:\\\\Temp\";\n//const path = remoteTempFolder + \"\\\\\" + name;\n//const outputFile= \"Replace_output.pdf\";\n\n\n// Upload File\n//pdfApi.uploadFile(path, fs.readFileSync(localTestDataFolder + \"\\\\\" + name)).then((result) => { \n// console.log(\"Uploaded File\"); \n// }).catch(function(err) {\n // Deal with an error\n// console.log(err);\n//});\n \nconst textReplace= new TextReplace();\n textReplace.oldValue= \"origami\"; \n textReplace.newValue= \"aspose\";\n textReplace.regex= false;\n\nconst textReplace1= new TextReplace();\n textReplace1.oldValue= \"candy\"; \n textReplace1.newValue= \"biscuit\";\n textReplace1.regex= false;\n \nconst trr = new TextReplaceListRequest();\n trr.textReplaces = [textReplace,textReplace1];\n\n\n// Replace text\npdfApi.postDocumentTextReplace(name, trr, null, remoteTempFolder).then((result) => { \n console.log(result.body.code); \n}).catch(function(err) {\n // Deal with an error\n console.log(err);\n});\n\n//Download file\n//const outputPath = \"C:/Temp/\" + outputFile;\n\n//pdfApi.downloadFile(path).then((result) => { \n// fs.writeFileSync(outputPath, result.body);\n// console.log(\"File Downloaded\"); \n//}).catch(function(err) {\n // Deal with an error\n// console.log(err);\n//});\n"
},
{
"answer_id": 67932076,
"author": "rogerdpack",
"author_id": 32453,
"author_profile": "https://Stackoverflow.com/users/32453",
"pm_score": 0,
"selected": false,
"text": "sed [(O)-16(ther i)-20(nformati)-11(on )]TJ\n $ crystal replaceinpdf.cr input_filename.pdf \"something you want replaced\" \"what you want it replaced with\" output.pdf\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/363015/"
] |
220,465
|
<p>I have an application which I have made a 256 x 256 Windows Vista icon for.</p>
<p>I was wondering how I would be able to use a 256x256 PNG file in the ico file used as the application icon and show it in a picture box on a form.</p>
<p>I am using VB.NET, but answers in C# are fine. I'm thinking I may have to use reflection.</p>
<p>I am not sure if this is even possible in Windows XP and may need Windows Vista APIs</p>
|
[
{
"answer_id": 220474,
"author": "TheSoftwareJedi",
"author_id": 18941,
"author_profile": "https://Stackoverflow.com/users/18941",
"pm_score": 2,
"selected": false,
"text": "using System.Runtime.InteropServices;\n // Constants that we need in the function call\nprivate const int SHGFI_ICON = 0x100;\nprivate const int SHGFI_SMALLICON = 0x1;\nprivate const int SHGFI_LARGEICON = 0x0;\n // This structure will contain information about the file\npublic struct SHFILEINFO\n{\n // Handle to the icon representing the file\n public IntPtr hIcon;\n // Index of the icon within the image list\n public int iIcon;\n // Various attributes of the file\n public uint dwAttributes;\n // Path to the file\n [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]\n public string szDisplayName;\n // File type\n [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]\n public string szTypeName;\n};\n // The signature of SHGetFileInfo (located in Shell32.dll)\n[DllImport(\"Shell32.dll\")]\npublic static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, int cbFileInfo, uint uFlags);\n private void btnExtract_Click(object sender, EventArgs e)\n{\n // Will store a handle to the small icon\n IntPtr hImgSmall;\n // Will store a handle to the large icon\n IntPtr hImgLarge;\n\n SHFILEINFO shinfo = new SHFILEINFO();\n\n // Open the file that we wish to extract the icon from\n if(openFile.ShowDialog() == DialogResult.OK)\n {\n // Store the file name\n string FileName = openFile.FileName;\n // Sore the icon in this myIcon object\n System.Drawing.Icon myIcon;\n\n // Get a handle to the small icon\n hImgSmall = SHGetFileInfo(FileName, 0, ref shinfo, Marshal.SizeOf(shinfo), SHGFI_ICON | SHGFI_SMALLICON);\n // Get the small icon from the handle\n myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon);\n // Display the small icon\n picIconSmall.Image = myIcon.ToBitmap();\n\n // Get a handle to the large icon\n hImgLarge = SHGetFileInfo(FileName, 0, ref shinfo, Marshal.SizeOf(shinfo), SHGFI_ICON | SHGFI_LARGEICON);\n // Get the large icon from the handle\n myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon);\n // Display the large icon\n picIconLarge.Image = myIcon.ToBitmap();\n\n }\n}\n"
},
{
"answer_id": 1945764,
"author": "SLA80",
"author_id": 228365,
"author_profile": "https://Stackoverflow.com/users/228365",
"pm_score": 4,
"selected": true,
"text": "picboxAppLogo.Image = ExtractVistaIcon(myIcon);\n // Based on: http://www.codeproject.com/KB/cs/IconExtractor.aspx\n// And a hint from: http://www.codeproject.com/KB/cs/IconLib.aspx\n\nBitmap ExtractVistaIcon(Icon icoIcon)\n{\n Bitmap bmpPngExtracted = null;\n try\n {\n byte[] srcBuf = null;\n using (System.IO.MemoryStream stream = new System.IO.MemoryStream())\n { icoIcon.Save(stream); srcBuf = stream.ToArray(); }\n const int SizeICONDIR = 6;\n const int SizeICONDIRENTRY = 16;\n int iCount = BitConverter.ToInt16(srcBuf, 4);\n for (int iIndex=0; iIndex<iCount; iIndex++)\n {\n int iWidth = srcBuf[SizeICONDIR + SizeICONDIRENTRY * iIndex];\n int iHeight = srcBuf[SizeICONDIR + SizeICONDIRENTRY * iIndex + 1];\n int iBitCount = BitConverter.ToInt16(srcBuf, SizeICONDIR + SizeICONDIRENTRY * iIndex + 6);\n if (iWidth == 0 && iHeight == 0 && iBitCount == 32)\n {\n int iImageSize = BitConverter.ToInt32(srcBuf, SizeICONDIR + SizeICONDIRENTRY * iIndex + 8);\n int iImageOffset = BitConverter.ToInt32(srcBuf, SizeICONDIR + SizeICONDIRENTRY * iIndex + 12);\n System.IO.MemoryStream destStream = new System.IO.MemoryStream();\n System.IO.BinaryWriter writer = new System.IO.BinaryWriter(destStream);\n writer.Write(srcBuf, iImageOffset, iImageSize);\n destStream.Seek(0, System.IO.SeekOrigin.Begin);\n bmpPngExtracted = new Bitmap(destStream); // This is PNG! :)\n break;\n }\n }\n }\n catch { return null; }\n return bmpPngExtracted;\n}\n // Getting FILL icon set from EXE, and extracting 256x256 version for logo...\nusing (TKageyu.Utils.IconExtractor IconEx = new TKageyu.Utils.IconExtractor(Application.ExecutablePath))\n{\n Icon icoAppIcon = IconEx.GetIcon(0); // Because standard System.Drawing.Icon.ExtractAssociatedIcon() returns ONLY 32x32.\n picboxAppLogo.Image = ExtractVistaIcon(icoAppIcon);\n}\n"
},
{
"answer_id": 9098914,
"author": "Jean-Philippe",
"author_id": 1183099,
"author_profile": "https://Stackoverflow.com/users/1183099",
"pm_score": 2,
"selected": false,
"text": " /// <summary>\n /// Extracts the large Vista icon from a ICO file \n /// </summary>\n /// <param name=\"srcBuf\">Bytes of the ICO file</param>\n /// <returns>The large icon or null if not found</returns>\n private static Bitmap ExtractVistaIcon(byte[] srcBuf)\n {\n const int SizeIcondir = 6;\n const int SizeIcondirentry = 16;\n\n // Read image count from ICO header\n int iCount = BitConverter.ToInt16(srcBuf, 4);\n\n // Search for a large icon\n for (int iIndex = 0; iIndex < iCount; iIndex++)\n {\n // Read image information from image directory entry\n int iWidth = srcBuf[SizeIcondir + SizeIcondirentry * iIndex];\n int iHeight = srcBuf[SizeIcondir + SizeIcondirentry * iIndex + 1];\n int iBitCount = BitConverter.ToInt16(srcBuf, SizeIcondir + SizeIcondirentry * iIndex + 6);\n\n // If Vista icon\n if (iWidth == 0 && iHeight == 0 && iBitCount == 32)\n {\n // Get image data position and length from directory\n int iImageSize = BitConverter.ToInt32(srcBuf, SizeIcondir + SizeIcondirentry * iIndex + 8);\n int iImageOffset = BitConverter.ToInt32(srcBuf, SizeIcondir + SizeIcondirentry * iIndex + 12);\n\n // Check if the image has a PNG signature\n if (srcBuf[iImageOffset] == 0x89 && srcBuf[iImageOffset+1] == 0x50 && srcBuf[iImageOffset+2] == 0x4E && srcBuf[iImageOffset+3] == 0x47)\n {\n // the PNG data is stored directly in the file\n var x = new MemoryStream(srcBuf, iImageOffset, iImageSize, false, false);\n return new Bitmap(x); \n }\n\n // Else it's bitmap data with a partial bitmap header\n // Read size from partial header\n int w = BitConverter.ToInt32(srcBuf, iImageOffset + 4);\n // Create a full header\n var b = new Bitmap(w, w, PixelFormat.Format32bppArgb);\n // Copy bits into bitmap\n BitmapData bmpData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.WriteOnly, b.PixelFormat);\n Marshal.Copy(srcBuf, iImageOffset + Marshal.SizeOf(typeof(Bitmapinfoheader)), bmpData.Scan0, b.Width*b.Height*4);\n b.UnlockBits(bmpData);\n return b;\n }\n }\n\n return null;\n }\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6335/"
] |
220,470
|
<p>This works, but is it the proper way to do it???</p>
<p>I have a custom server control that has an [input] box on it. I want it to kinda mimic the ASP.NET TextBox, but not completely. When the textbox is rendered i have a javascript that allows users to select values that are then placed in that input box.</p>
<p>I have a public text property on the control. In the get/set i get/set the viewstate for the control - that part is easy, but when the control is populated via the javascript, the Text get is not actually called, what is the proper way to set this exposed property using JavaScript (or even if the user just types in the box) ?</p>
<p>Edit:
In the OnInit i ensure the state is maintained by reaching into the form values.</p>
<pre><code> protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (HttpContext.Current.Request.Form["MyInputBoxValue"] != "")
{
ViewState["MyInputBoxValue"]
= HttpContext.Current.Request.Form["MyInputBoxValue"];
}
}
</code></pre>
<p>Then to get the value actually back in place in the HtmlTextWrite, i do this:</p>
<pre><code>protected override void RenderContents(HtmlTextWriter output)
{
// There is an input control here and i set its value property
// like this using the Text internal defined.
output.Write("<input value=" + Text + ">.....
}
</code></pre>
<p>thanks</p>
|
[
{
"answer_id": 220586,
"author": "gregmac",
"author_id": 7913,
"author_profile": "https://Stackoverflow.com/users/7913",
"pm_score": 2,
"selected": true,
"text": "partial class MyControl : System.Web.UI.UserControl, IStateManager\n{\n [Serializable()]\n protected struct MyControlState\n {\n public bool someValue;\n public string name;\n }\n\n protected MyControlState state;\n\n public bool someValue {\n get { return state.someValue; }\n set { state.someValue = value; }\n }\n\n public bool IsTrackingViewState {\n get { return true; }\n }\n\n protected override void LoadViewState(object state)\n {\n if ((state != null) && state is MyControlState) {\n this.state = state;\n }\n }\n\n protected override object SaveViewState()\n {\n return state;\n }\n\n protected override void TrackViewState()\n {\n base.TrackViewState();\n }\n}\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26685/"
] |
220,488
|
<p>I have an input which at some points happens to have the focus. If the user click in the "background" of the page, the input loses its focus. I was trying to simulate the click on the background with the following code, but this doesn't work (you will notice that the input still has the focus). Any suggestion on how to write code that simulates a click on the "background" of the page?</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="http://yui.yahooapis.com/2.6.0/build/yahoo/yahoo-min.js" ></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.6.0/build/event/event-min.js" ></script>
<script type="text/javascript">
YAHOO.util.Event.onDOMReady(function() {
document.getElementById("input").focus();
document.getElementById("main").focus();
});
</script>
</head>
<body>
<div id="main">
<form action="/">
<p>
<input type="text" id="input"/>
</p>
</form>
</div>
</body>
</html>
</code></pre>
|
[
{
"answer_id": 220491,
"author": "Paolo Bergantino",
"author_id": 16417,
"author_profile": "https://Stackoverflow.com/users/16417",
"pm_score": 5,
"selected": true,
"text": "blur() <script type=\"text/javascript\">\n YAHOO.util.Event.onDOMReady(function() {\n document.getElementById(\"input\").focus(); \n document.getElementById(\"input\").blur(); \n });\n</script>\n"
},
{
"answer_id": 220494,
"author": "Dan Herbert",
"author_id": 392,
"author_profile": "https://Stackoverflow.com/users/392",
"pm_score": 2,
"selected": false,
"text": "blur blur()"
},
{
"answer_id": 64925509,
"author": "Regis Emiel",
"author_id": 9096719,
"author_profile": "https://Stackoverflow.com/users/9096719",
"pm_score": 0,
"selected": false,
"text": "document.getElementById(\"main\").focus();\n\n<div id=\"main\">\n blur()"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5295/"
] |
220,507
|
<p>I write a large static method that takes a generic as a parameter argument. I call this method, and the framework throws a System.InvalidProgramException. This exception is thrown even before the first line of the method is executed.</p>
<p>I can create a static class which takes the generic argument, and then make this a method of the static class, and everything works fine.</p>
<p>Is this a .NET defect, or is there some obscure generic rule I'm breaking here?</p>
<p>For the sake of completeness, I've included the method which fails, and the method which passes. Note that this uses a number of other classes from my own library (eg GridUtils), and these classes are not explained here. I don't think the actual meaning matters: the question is why the runtime crashes before the method even starts.</p>
<p>(I'm programming with Visual Studio 2005, so maybe this has gone away in Visual Studio 2008.)</p>
<p><b>This throws an exception before the first line is invoked:</b></p>
<pre><code> private delegate void PROG_Delegate<TGridLine>(DataGridView dgv, IEnumerable<TGridLine> gridLines, string[] columns);
public static void PopulateReadOnlyGrid<TGridLine>(DataGridView dgv, IEnumerable<TGridLine> gridLines, string[] columns)
{
if (dgv.InvokeRequired)
{
dgv.BeginInvoke
(
new PROG_Delegate<TGridLine>(PopulateReadOnlyGrid<TGridLine>),
new object[] { dgv, gridLines, columns }
);
return;
}
GridUtils.StatePreserver statePreserver = new GridUtils.StatePreserver(dgv);
System.Data.DataTable dt = CollectionHelper.ConvertToDataTable<TGridLine>((gridLines));
dgv.DataSource = dt;
dgv.DataMember = "";
dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
GridUtils.OrderColumns<TGridLine>(dgv, columns);
statePreserver.RestoreState();
dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
}
</code></pre>
<p><b>This works fine:</b></p>
<pre><code> public static class Populator<TGridLine>
{
private delegate void PROG_Delegate(DataGridView dgv, IEnumerable<TGridLine> gridLines, string[] columns);
public static void PopulateReadOnlyGrid(DataGridView dgv, IEnumerable<TGridLine> gridLines, string[] columns)
{
if (dgv.InvokeRequired)
{
dgv.BeginInvoke
(
new PROG_Delegate(PopulateReadOnlyGrid),
new object[] { dgv, gridLines, columns }
);
return;
}
GridUtils.StatePreserver statePreserver = new GridUtils.StatePreserver(dgv);
System.Data.DataTable dt = CollectionHelper.ConvertToDataTable<TGridLine>((gridLines));
dgv.DataSource = dt;
dgv.DataMember = "";
dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
GridUtils.OrderColumns<TGridLine>(dgv, columns);
statePreserver.RestoreState();
dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
}
}
</code></pre>
|
[
{
"answer_id": 220491,
"author": "Paolo Bergantino",
"author_id": 16417,
"author_profile": "https://Stackoverflow.com/users/16417",
"pm_score": 5,
"selected": true,
"text": "blur() <script type=\"text/javascript\">\n YAHOO.util.Event.onDOMReady(function() {\n document.getElementById(\"input\").focus(); \n document.getElementById(\"input\").blur(); \n });\n</script>\n"
},
{
"answer_id": 220494,
"author": "Dan Herbert",
"author_id": 392,
"author_profile": "https://Stackoverflow.com/users/392",
"pm_score": 2,
"selected": false,
"text": "blur blur()"
},
{
"answer_id": 64925509,
"author": "Regis Emiel",
"author_id": 9096719,
"author_profile": "https://Stackoverflow.com/users/9096719",
"pm_score": 0,
"selected": false,
"text": "document.getElementById(\"main\").focus();\n\n<div id=\"main\">\n blur()"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28506/"
] |
220,525
|
<p>I'm working on a GUI application in WxPython, and I am not sure how I can ensure that only one copy of my application is running at any given time on the machine. Due to the nature of the application, running more than once doesn't make any sense, and will fail quickly. Under Win32, I can simply make a named mutex and check that at startup. Unfortunately, I don't know of any facilities in Linux that can do this. </p>
<p>I'm looking for something that will automatically be released should the application crash unexpectedly. I don't want to have to burden my users with having to manually delete lock files because I crashed.</p>
|
[
{
"answer_id": 220539,
"author": "Adam Liss",
"author_id": 29157,
"author_profile": "https://Stackoverflow.com/users/29157",
"pm_score": 0,
"selected": false,
"text": "linux# pidof myapp\n8947\nlinux# pidof nonexistent_app\n\nlinux#\n"
},
{
"answer_id": 220542,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 6,
"selected": true,
"text": ".pid"
},
{
"answer_id": 220544,
"author": "Menkboy",
"author_id": 29539,
"author_profile": "https://Stackoverflow.com/users/29539",
"pm_score": 1,
"selected": false,
"text": "semaphore.h sem_open() sem_trywait()"
},
{
"answer_id": 220590,
"author": "Matthew Smith",
"author_id": 20889,
"author_profile": "https://Stackoverflow.com/users/20889",
"pm_score": 1,
"selected": false,
"text": "import os\nos.getpid()\n cmd = \"ps -p %s -o comm=\" % var_run_pid\napp_name = os.popen(cmd).read().strip()\nif len(app_name) > 0:\n Already running\n"
},
{
"answer_id": 220709,
"author": "Charles Duffy",
"author_id": 14122,
"author_profile": "https://Stackoverflow.com/users/14122",
"pm_score": 6,
"selected": false,
"text": "flock(LOCK_EX) fcntl"
},
{
"answer_id": 221159,
"author": "zgoda",
"author_id": 12138,
"author_profile": "https://Stackoverflow.com/users/12138",
"pm_score": 5,
"selected": false,
"text": "fcntl import fcntl\npid_file = 'program.pid'\nfp = open(pid_file, 'w')\ntry:\n fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB)\nexcept IOError:\n # another instance is running\n sys.exit(1)\n"
},
{
"answer_id": 476133,
"author": "Brian Victor",
"author_id": 58603,
"author_profile": "https://Stackoverflow.com/users/58603",
"pm_score": 3,
"selected": false,
"text": " name = \"MyApp-%s\" % wx.GetUserId()\n checker = wx.SingleInstanceChecker(name)\n if checker.IsAnotherRunning():\n return False\n"
},
{
"answer_id": 15016759,
"author": "Asclepius",
"author_id": 832230,
"author_profile": "https://Stackoverflow.com/users/832230",
"pm_score": 3,
"selected": false,
"text": "root foo foo root import fcntl, os, stat, tempfile\n\napp_name = 'myapp' # <-- Customize this value\n\n# Establish lock file settings\nlf_name = '.{}.lock'.format(app_name)\nlf_path = os.path.join(tempfile.gettempdir(), lf_name)\nlf_flags = os.O_WRONLY | os.O_CREAT\nlf_mode = stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH # This is 0o222, i.e. 146\n\n# Create lock file\n# Regarding umask, see https://stackoverflow.com/a/15015748/832230\numask_original = os.umask(0)\ntry:\n lf_fd = os.open(lf_path, lf_flags, lf_mode)\nfinally:\n os.umask(umask_original)\n\n# Try locking the file\ntry:\n fcntl.lockf(lf_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)\nexcept IOError:\n msg = ('Error: {} may already be running. Only one instance of it '\n 'can run at a time.'\n ).format('appname')\n exit(msg)\n /var/run/<appname>/ root"
},
{
"answer_id": 34659754,
"author": "shuckc",
"author_id": 148439,
"author_profile": "https://Stackoverflow.com/users/148439",
"pm_score": 2,
"selected": false,
"text": "# Use a listening socket as a mutex against multiple invocations\nimport socket\ns = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\ns.bind(('127.0.0.1', 5080))\ns.listen(1)\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29825/"
] |
220,547
|
<p>Does anyone knows how to detect printable characters in java?</p>
<p>After a while ( trial/error ) I get to this method:</p>
<pre><code> public boolean isPrintableChar( char c ) {
Character.UnicodeBlock block = Character.UnicodeBlock.of( c );
return (!Character.isISOControl(c)) &&
c != KeyEvent.CHAR_UNDEFINED &&
block != null &&
block != Character.UnicodeBlock.SPECIALS;
}
</code></pre>
<p>I'm getting the input via KeyListener and come Ctr-'key' printed an square. With this function seems fairly enough. </p>
<p>Am I missing some char here?</p>
|
[
{
"answer_id": 221115,
"author": "jb.",
"author_id": 7918,
"author_profile": "https://Stackoverflow.com/users/7918",
"pm_score": 4,
"selected": false,
"text": "Font.canDisplay(int)\n"
},
{
"answer_id": 418560,
"author": "OscarRyz",
"author_id": 20654,
"author_profile": "https://Stackoverflow.com/users/20654",
"pm_score": 7,
"selected": true,
"text": "public boolean isPrintableChar( char c ) {\n Character.UnicodeBlock block = Character.UnicodeBlock.of( c );\n return (!Character.isISOControl(c)) &&\n c != KeyEvent.CHAR_UNDEFINED &&\n block != null &&\n block != Character.UnicodeBlock.SPECIALS;\n}\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20654/"
] |
220,560
|
<p>I am changing document template macros. The one thing I can't find out how to do is to customize error messages. For example an error message in a document is</p>
<p>"Error! No table of figures entries found"</p>
<p>I would like to change this to display something else. Is it possible to do this with Word VBA or VBScript?</p>
|
[
{
"answer_id": 220573,
"author": "CtrlDot",
"author_id": 19487,
"author_profile": "https://Stackoverflow.com/users/19487",
"pm_score": 0,
"selected": false,
"text": "On Error Resume Next\n' try action\nIf Err.Number <> 0 Then\n ' handle w/ custom message\n Err.Clear\nEnd If\n If Err.Number = N Then"
},
{
"answer_id": 220579,
"author": "Michael Galos",
"author_id": 29820,
"author_profile": "https://Stackoverflow.com/users/29820",
"pm_score": 0,
"selected": false,
"text": "Msgbox(\"Error! No table of figures entries found\",16,\"Error\")\n On Error Resume Next\nn = 1 / 0 ' this causes an error\nIf Err.Number <> 0 Then \n n = 1\n if Err.Number = 1 Then MsgBox Err.Description\nEnd If\n"
},
{
"answer_id": 221239,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 1,
"selected": false,
"text": "Sub HandleErr(ErrNo As Long)\n Select Case ErrNo\n Case vbObjectError + 1024\n MsgBox \"No table of figures entries found.\", vbOKOnly + vbCritical\n\n Case vbObjectError + 1034 To vbObjectError + 4999\n MsgBox \"Still no table of figures entries found.\", vbOKOnly + vbCritical\n\n Case Else\n MsgBox \"I give up.\", vbOKOnly + vbCritical, _\n \"Application Error\"\n End Select\nEnd Sub\n Sub ShowError()\nDim i As Integer\n\nOn Error GoTo Proc_Err\n\n 'VBA Error\n i = \"a\"\n\n 'Custom error\n If Dir(\"C:\\Docs\\TableFigs.txt\") = \"\" Then\n Err.Raise vbObjectError + 1024\n End If\n\nExit_Here:\n Exit Sub\n\nProc_Err:\n If Err.Number > vbObjectError And Err.Number < vbObjectError + 9999 Then\n HandleErr Err.Number\n Else\n MsgBox Err.Description\n End If\nEnd Sub\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27294/"
] |
220,585
|
<p>I am having a real problem at work with a highly ingrained developer obsessed with ms access. Users moan about random crashes, locking errors, freeze's, the application slowing down (especially in 2007) but seem to be very resistant to moving it. Most of the time they blame the computer and can't be convinced it's the fact its a mdb sat on a network drive and nothing to do with the hardware sat in front of them which is brand new.</p>
<p>There is a front end vb program hanging off it but I don't think it would take more than a couple of weeks to adjust, infact I would probably re-write it as it has year on year messy code from a previous developer.</p>
<p>What are my best arguments to convince them we need to move it?</p>
<p>Does anyone else have similar problems with developers stuck in their ways?</p>
|
[
{
"answer_id": 220986,
"author": "Philippe Grondier",
"author_id": 11436,
"author_profile": "https://Stackoverflow.com/users/11436",
"pm_score": 1,
"selected": false,
"text": "type_Of_TheConnexion"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16989/"
] |
220,603
|
<p>I'm calling a web service that returns an array of objects in JSON. I want to take those objects and populate a div with HTML. Let's say each object contains a url and a name.</p>
<p>If I wanted to generate the following HTML for each object:</p>
<pre><code><div><img src="the url" />the name</div>
</code></pre>
<p>Is there a best practice for this? I can see a few ways of doing it:</p>
<ol>
<li>Concatenate strings</li>
<li>Create elements</li>
<li>Use a templating plugin</li>
<li>Generate the html on the server, then serve up via JSON.</li>
</ol>
|
[
{
"answer_id": 220619,
"author": "savetheclocktower",
"author_id": 25720,
"author_profile": "https://Stackoverflow.com/users/25720",
"pm_score": 3,
"selected": false,
"text": "// assuming JSON looks like this:\n// { 'src': 'foo/bar.jpg', 'name': 'Lorem ipsum' }\n var html = \"<div><img src='#{src}' /> #{name}</div>\".interpolate(json);\n$('container').insert(html); // inserts at bottom\n var div = new Element('div');\ndiv.insert( new Element('img', { src: json.src }) );\ndiv.insert(\" \" + json.name);\n$('container').insert(div); // inserts at bottom\n"
},
{
"answer_id": 220632,
"author": "Jim Fiorato",
"author_id": 650,
"author_profile": "https://Stackoverflow.com/users/650",
"pm_score": 7,
"selected": true,
"text": "var t = $.template('<div><img src=\"${url}\" />${name}</div>');\n\n$(selector).append( t , {\n url: jsonObj.url,\n name: jsonObj.name\n});\n"
},
{
"answer_id": 220696,
"author": "Andrew Hedges",
"author_id": 11577,
"author_profile": "https://Stackoverflow.com/users/11577",
"pm_score": 3,
"selected": false,
"text": "var tmpl = '<div class=\"#{classname}\">#{content}</div>';\nvar vals = {\n classname : 'my-class',\n content : 'This is my content.'\n};\nvar html = $.tmpl(tmpl, vals);\n"
},
{
"answer_id": 223790,
"author": "Leo",
"author_id": 20689,
"author_profile": "https://Stackoverflow.com/users/20689",
"pm_score": 3,
"selected": false,
"text": "/* CSS */\n.template {display:none;}\n\n<!--HTML-->\n<div class=\"template\">\n <div class=\"container\">\n <h1></h1>\n <img src=\"\" alt=\"\" />\n </div>\n</div>\n\n/*Javascript (using Prototype)*/\nvar copy = $$(\".template .container\")[0].cloneNode(true);\nmyElement.appendChild(copy);\n$(copy).select(\"h1\").each(function(e) {/*do stuff to h1*/})\n$(copy).select(\"img\").each(function(e) {/*do stuff to img*/})\n"
},
{
"answer_id": 304798,
"author": "some",
"author_id": 36866,
"author_profile": "https://Stackoverflow.com/users/36866",
"pm_score": 4,
"selected": false,
"text": "var s=\"\";\nfor (var i=0; i < 200; ++i) {s += \"testing\"; }\n var s=[];\nfor (var i=0; i < 200; ++i) { s.push(\"testing\"); }\ns = s.join(\"\");\n"
},
{
"answer_id": 23670731,
"author": "Tzach",
"author_id": 1795244,
"author_profile": "https://Stackoverflow.com/users/1795244",
"pm_score": 3,
"selected": false,
"text": "var view = {\n url: \"/hello\",\n name: function () {\n return 'Jo' + 'hn';\n }\n};\n\nvar output = Mustache.render('<div><img src=\"{{url}}\" />{{name}}</div>', view);\n"
},
{
"answer_id": 29434325,
"author": "Automatico",
"author_id": 741850,
"author_profile": "https://Stackoverflow.com/users/741850",
"pm_score": 2,
"selected": false,
"text": "<div><img src=\"the url\" />the name</div>\n new BOB(\"div\").insert(\"img\",{\"src\":\"the url\"}).up().content(\"the name\").toString()\n//=> \"<div><img src=\"the url\" />the name</div>\"\n new BOB(\"div\").i(\"img\",{\"src\":\"the url\"}).up().co(\"the name\").s()\n//=> \"<div><img src=\"the url\" />the name</div>\"\n data = [1,2,3,4,5,6,7]\nnew BOB(\"div\").i(\"ul#count\").do(data).i(\"li.number\").co(BOB.d).up().up().a(\"a\",{\"href\": \"www.google.com\"}).s()\n//=> \"<div><ul id=\"count\"><li class=\"number\">1</li><li class=\"number\">2</li><li class=\"number\">3</li><li class=\"number\">4</li><li class=\"number\">5</li><li class=\"number\">6</li><li class=\"number\">7</li></ul></div><a href=\"www.google.com\"></a>\"\n document.getElementById(\"parent\").innerHTML = new BOB(\"div\").insert(\"img\",{\"src\":\"the url\"}).up().content(\"the name\").s();\n//Or jquery:\n$(\"#parent\").append(new BOB(\"div\").insert(\"img\",{\"src\":\"the url\"}).up().content(\"the name\").s());\n bower install BOB"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67719/"
] |
220,613
|
<p>I have a coworker who is planning a database for a new app that will have several tables with over 30 fields each. Is this excessive? Maybe I'm just not enterprisey enough to understand. </p>
<p>Edit: Also, a lot of the fields are option-type sort of things (like on a request form, would you like your widget to be yellow or green, he has a field for 'colour' with an enum). It's quite likely that these will be added to or removed over time. I haven't really done database design and try to stay away from it myself, so maybe I'm being completely stupid, but surely there's a better way of doing this??</p>
|
[
{
"answer_id": 220689,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 3,
"selected": false,
"text": "BaseTable:\n Id\n NonOptionFields\nOptionTable:\n Id\n OptionName\n OptionValue\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29840/"
] |
220,624
|
<p>How do I write the getDB() function and use it properly?</p>
<p>Here is a code snippet of my App Object:</p>
<pre><code>public class MyApp extends UiApplication {
private static PersistentObject m_oStore;
private static MyBigObjectOfStorage m_oDB;
static {
store = PersistentStore.getPersistentObject(0xa1a569278238dad2L);
}
public static void main(String[] args) {
MyApp theApp = new MyApp();
theApp.enterEventDispatcher();
}
public MyApp() {
pushScreen(new MyMainScreen());
}
// Is this correct? Will it return a copy of m_oDB or a reference of m_oDB?
public MyBigObjectOfStorage getDB() {
return m_oDB; // returns a reference
}
}
</code></pre>
|
[
{
"answer_id": 220724,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "public MyBigObjectOfStorage getDB() {\n Object o = store.getContents();\n if ( o instanceof MyBigObjectOfStorage ) {\n return (MyBigObjectOfStorage) o;\n } else {\n return null;\n }\n}\n"
},
{
"answer_id": 220726,
"author": "madlep",
"author_id": 14160,
"author_profile": "https://Stackoverflow.com/users/14160",
"pm_score": 2,
"selected": true,
"text": "public MyBigObjectOfStorage getDB() {\n return m_oDB;\n}\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22917/"
] |
220,630
|
<p>If I make two iPhone applications, how can/should I share custom data (not contacts and stuff like that) among them?</p>
<p>Thanks!</p>
|
[
{
"answer_id": 1522707,
"author": "livingtech",
"author_id": 18961,
"author_profile": "https://Stackoverflow.com/users/18961",
"pm_score": 2,
"selected": false,
"text": "NSUserDefaults"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15124/"
] |
220,638
|
<p>How can I best set up my PHP (LAMP) development environment so that I have development, staging and production servers. One-"click" deployment to any of those, as well as one-click rollback to any revision. Rollback should also rollback the database schema and data to how it was when that source code was current.</p>
<p>Right now I've done all of this (except the DB rollback ability) for one application using shell scripts. I'm curious to know how others' environments are setup, and also if there are any generic tools or best-practices out there to follow as far as layout is concerned.</p>
<p>So, how do you do this? What existing tools do you make use of?</p>
<p>Thanks!</p>
<p>UPDATE: Just to clarify as there is some confusion about what I'm interested in.</p>
<p>I really want people to chime in with how their environment is set up.</p>
<p>If you run a PHP project and you have your DB schema in version control, how do you do it? What tools do you use? Are they in-house or can we all find them on the web somewhere?</p>
<p>If you run a PHP project and you do automated testing on commit (and/or nightly), how do you do it? What source versioning system do you use? Do you use SVN and run your tests in post-commit hooks?</p>
<p>If you run a PHP project with multiple dev servers, a staging server and production server(s), how do you organize them and how do you deploy?</p>
<p>What I hope to get out of this is a good idea of how others glue everything together.</p>
|
[
{
"answer_id": 225524,
"author": "Till",
"author_id": 2859,
"author_profile": "https://Stackoverflow.com/users/2859",
"pm_score": 5,
"selected": true,
"text": "capfile role :www, \"web01\", \"web02\", \"web03\"\nrole :web, \"web01\", \"web02\", \"web03\", \"web04\"\nrole :db, \"db01\", \"db02\"\n\ndesc \"Deploy sites\"\ntask :deploy, :roles => :www do\n run \"cd /usr/www/website && sudo svn --username=deploy --password=foo update\"\nend\n cap invoke COMMAND=\"uptime\" ROLES=web\n"
},
{
"answer_id": 1171129,
"author": "K. Norbert",
"author_id": 80761,
"author_profile": "https://Stackoverflow.com/users/80761",
"pm_score": 1,
"selected": false,
"text": "+ dbchanges\n|_ 01_database\n|_ 02_table\n|_ 03_data\n|_ 04_constraints\n|_ 05_functions\n|_ 06_triggers\n|_ 07_indexes\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29838/"
] |
220,642
|
<p>I need a Linux text editor to replace Textpad 4.7.3 (a Windows nagware app), but all the alternatives I've tried are either bloated or incomplete. Here are the features I find most important, in descending order:</p>
<ul>
<li>Regex search, mark, and replace (across all open files, even), regex search in directory trees</li>
<li>Tabbed editor with <strong>proper</strong> keyboard shortcuts ([ctrl]+[tab] should work on the <em>exact same model</em> as [alt]+[tab])</li>
<li>Auto-indent, indent preservation, and indent manipulation (tab, shift-tab)</li>
<li>Smart navigation keys: [home] toggles between start of line and start of non-whitespace, [F2] seeks to next bookmark, <em>hitting the up and down arrow keys take you to the column where you last navigated, not where you last typed</em> (I think Textpad's the only place I've seen this)</li>
<li>Syntax highlighting (bonus: mixed-language highlighting, which TextPad lacked)</li>
<li>Block select mode</li>
<li>Run user-defined commands from program (such as compilers), have interactive command results (Textpad would let you define regexes to match filenames and line numbers so you could double-click on an error and be taken to that line in that file.)</li>
<li>Workspaces (collections of files to be open at the same time)</li>
</ul>
<p>Here's what I've found distasteful in the editors I've tried:</p>
<ul>
<li>Vim and emacs <s>do not take full advantage of my screen, mouse, and keyboard. Also, there's</s> have quite a learning curve -- you have to learn an <em>entirely new</em> way of interacting with the keyboard. (Of course, if they had everything I wanted, I would learn them.)</li>
<li>Gedit is almost perfect, but it (like most of them) has crappy tabbing, which is <em>intolerable</em></li>
<li>Eclipse is a monstrosity, and I won't touch it unless I'm doing Java</li>
<li><strong>Regex capability</strong> is frighteningly rare</li>
<li>Almost nothing has <strong>last-seen</strong> tab traversal</li>
<li>I've not seen anything with last-navigation-column cursor traversal. (Once I started using it I found I couldn't do without.)</li>
</ul>
<p>I don't have the time or the specific knowledge required to build my "ideal editor", so I'm hoping someone out there with the same taste in editors might have stumbled across a gem.</p>
<p>ETA: Please <strong>don't recommend</strong> an editor you haven't <strong>personally used</strong>. I've heard of SciTE, Eclipse, gedit, medit, nedit, GVim, Gemacs, Kate, Geany, Gnotepad, ozeditor, etc. I'm sure that most of them have some of the features I mentioned. If you're not sure if it has an essential feature (e.g. ctrl-tab works just like alt-tab), then you're not really helping, are you?</p>
|
[
{
"answer_id": 220753,
"author": "Mark Porter",
"author_id": 29462,
"author_profile": "https://Stackoverflow.com/users/29462",
"pm_score": 3,
"selected": false,
"text": "* Regex search mark, and replace (across all open files, even), regex\n * Tabbed editor with proper keyboard shortcuts ([ctrl]+[tab]\n * Auto-indent, indent preservation, and indent manipulation\n * Smart navigation keys: [home] toggles between start of line and\n * Block select mode\n * Run user-defined commands from program (such as compilers), have\n * Workspaces (collections of files to be open at the same time)\n * Vim and emacs do not take full advantage of my screen, mouse, and\n * Regex capability is frighteningly rare\n * Almost nothing has last-seen tab traversal\n * I've not seen anything with last-navigation-column cursor\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20772/"
] |
220,643
|
<p>In my app I've got a thread which displays for some time "please wait" dialog window, sometimes it is a very tiny amout of time and there is some glitch while drawing UI (I guess).</p>
<p>I get the exception "Thread was being aborted" and completly have no idea how get rid of it. I mean Catch that exception in some way, or in some other way hide it from user. This exception has got nothing to do with rest of my app and that error in any way doesn't affect it. Appears randomly and it is hard to recreate on a call.</p>
<p>I tried in various ways to catch that exception by side of code which starts and stops thread with dialog window but it seems that error apparently is by side some other thread which dispalys window in my newly created thread.</p>
<p>Here is a code sample, part of static class with useful stuff, of course I don't say that is good way to solve this kind of "busy" situation but I want to solve this problem. Thread.Sleep(500); or other try/catch improvments doesn't help me to avoid that thread exception.</p>
<pre><code> public static bool alreadyBusy = false;
public static BusyIndicator bi = new BusyIndicator("");
public static Thread backgroundOpertionThread;
public static void showBusy(bool isBusy, System.Windows.Forms.Form hostform, string message)
{
Common.busyMessage = message;
if (isBusy)
{
Common.alreadyBusy = true;
backgroundOpertionThread = new Thread(new ThreadStart(showBusy));
Thread.Sleep(500);
if (hostform != null)
{
hostform.Enabled = false;
hostform.SuspendLayout();
}
backgroundOpertionThread.Start();
}
else
{
backgroundOpertionThread.Abort();
Thread.Sleep(500);
Common.alreadyBusy = false;
if (hostform != null)
{
hostform.Enabled = true;
hostform.ResumeLayout();
}
}
}
public static void showBusy()
{
BusyIndicator bir = new BusyIndicator(Common.busyMessage);
bir.ShowDialog();
}
</code></pre>
<p>Any ideas?</p>
|
[
{
"answer_id": 220948,
"author": "Veldmuis",
"author_id": 18826,
"author_profile": "https://Stackoverflow.com/users/18826",
"pm_score": -1,
"selected": false,
"text": "Thread.Sleep(500);\n backgroundOpertionThread.Start();\n backgroundOpertionThread.Abort();\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24824/"
] |
220,658
|
<p>Could someone explain? I understand the basic concepts behind them but I often see them used interchangeably and I get confused. </p>
<p>And now that we're here, how do they differ from a regular function?</p>
|
[
{
"answer_id": 220715,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 8,
"selected": false,
"text": "function foo() { return \"This string is returned from the 'foo' function\"; }\n foo(); //returns the string above\n @foo = lambda() {return \"This is returned from a function without a name\";}\n foo();\n function filter(list, predicate) \n { @filteredList = [];\n for-each (@x in list) if (predicate(x)) filteredList.add(x);\n return filteredList;\n }\n\n//filter for even numbers\nfilter([0,1,2,3,4,5,6], lambda(x) {return (x mod 2 == 0)}); \n @x = 0;\n\nfunction incrementX() { x = x + 1;}\n\nincrementX(); // x now equals 1\n incrementX function foo()\n { @x = 0;\n\n function incrementX() \n { x = x + 1;\n return x;\n }\n\n return incrementX;\n }\n\n@y = foo(); // y = closure of incrementX over foo.x\ny(); //returns 1 (y.x == 0 + 1)\ny(); //returns 2 (y.x == 1 + 1)\n function foo()\n { @x = 0;\n\n return lambda() \n { x = x + 1;\n return x;\n };\n }\n"
},
{
"answer_id": 220728,
"author": "Claudiu",
"author_id": 15055,
"author_profile": "https://Stackoverflow.com/users/15055",
"pm_score": 11,
"selected": true,
"text": "def func(): return h\ndef anotherfunc(h):\n return func()\n func anotherfunc h func def anotherfunc(h):\n def func(): return h\n return func()\n func anotherfunc anotherfunc nonlocal func anotherfunc anotherfunc def anotherfunc(h):\n def func(): return h\n return func\n\nprint anotherfunc(10)()\n"
},
{
"answer_id": 22493714,
"author": "Wei Qiu",
"author_id": 1854834,
"author_profile": "https://Stackoverflow.com/users/1854834",
"pm_score": 4,
"selected": false,
"text": "(lambda (x y) (+ x y))\n ((lambda (x y) (+ x y)) 2 3)\n (lambda (x y) (+ x y z))\n ((lambda (z) (lambda (x y) (+ x y z))) 1)\n"
},
{
"answer_id": 25053337,
"author": "Developer",
"author_id": 376702,
"author_profile": "https://Stackoverflow.com/users/376702",
"pm_score": 4,
"selected": false,
"text": "$input = array(1, 2, 3, 4, 5);\n$output = array_filter($input, function ($v) { return $v > 2; });\n $max = function ($v) { return $v > 2; };\n\n$input = array(1, 2, 3, 4, 5);\n$output = array_filter($input, $max);\n $max_comp = function ($max) {\n return function ($v) use ($max) { return $v > $max; };\n};\n\n$input = array(1, 2, 3, 4, 5);\n$output = array_filter($input, $max_comp(2));\n $string = \"Hello World!\";\n$closure = function() use ($string) { echo $string; };\n\n$closure();\n"
},
{
"answer_id": 36878651,
"author": "SasQ",
"author_id": 434562,
"author_profile": "https://Stackoverflow.com/users/434562",
"pm_score": 9,
"selected": false,
"text": "f x f x λ x . λx.x+2 x+2 x (λx.x+2) 7 7 x x+2 7+2 9 λx.x+2 function(x) { return x+2; }\n (function(x) { return x+2; })(7)\n var f = function(x) { return x+2; }\n f alert( f(7) + f(10) ); // should print 21 in the message box\n alert( function(x) { return x+2; } (7) ); // should print 9 in the message box\n (lambda (x) (+ x 2))\n ( (lambda (x) (+ x 2)) 7 )\n λx.x/y+2 x λx. y y 2 + λx.x/y+2 x y open y + 2 { y: 3,\n+: [built-in addition],\n2: [built-in number],\nq: 42,\nw: 5 }\n y + 2 q w { y: 3,\n+: [built-in addition],\n2: [built-in number] }\n Closure {\n [pointer to the lambda function's machine code],\n [pointer to the lambda function's environment]\n}\n"
},
{
"answer_id": 52476401,
"author": "DIPANSHU GOYAL",
"author_id": 4853061,
"author_profile": "https://Stackoverflow.com/users/4853061",
"pm_score": 2,
"selected": false,
"text": "Function<Integer,Integer> lambda = t -> {\n int n = 2\n return t * n \n}\n int n = 2\n\nFunction<Integer,Integer> closure = t -> {\n return t * n \n}\n"
},
{
"answer_id": 55680389,
"author": "j2emanue",
"author_id": 835883,
"author_profile": "https://Stackoverflow.com/users/835883",
"pm_score": 3,
"selected": false,
"text": "Function<Person, Job> mapPersonToJob = new Function<Person, Job>() {\n public Job apply(Person person) {\n Job job = new Job(person.getPersonId(), person.getJobDescription());\n return job;\n }\n};\n mapPersonToJob.apply(person)"
},
{
"answer_id": 66426148,
"author": "ap-osd",
"author_id": 3209308,
"author_profile": "https://Stackoverflow.com/users/3209308",
"pm_score": 0,
"selected": false,
"text": "[] void register_func(void(*f)(int val)) // Works only with an EMPTY capture list\n{\n int val = 3;\n f(val);\n}\n \nint main() \n{\n int env = 5;\n register_func( [](int val){ /* lambda body can access only val variable*/ } );\n}\n [env] register_func( [env](int val){ /* lambda body can access val and env variables*/ } );\n no suitable conversion function from \"lambda []void (int val)->void\" to \"void (*)(int val)\" exists std::function void register_func(std::function<void(int val)> f)\n"
},
{
"answer_id": 66663532,
"author": "yoAlex5",
"author_id": 4770877,
"author_profile": "https://Stackoverflow.com/users/4770877",
"pm_score": 3,
"selected": false,
"text": "Lambda Closure interface Runnable {\n void run();\n}\n\nclass MyClass {\n void foo(Runnable r) {\n\n }\n\n //Lambda\n void lambdaExample() {\n foo(() -> {});\n }\n\n //Closure\n String s = \"hello\";\n void closureExample() {\n foo(() -> { s = \"world\";});\n }\n}\n class MyClass {\n func foo(r:() -> Void) {}\n \n func lambdaExample() {\n foo(r: {})\n }\n \n var s = \"hello\"\n func closureExample() {\n foo(r: {s = \"world\"})\n }\n}\n"
},
{
"answer_id": 70879701,
"author": "FrankHB",
"author_id": 2307646,
"author_profile": "https://Stackoverflow.com/users/2307646",
"pm_score": 2,
"selected": false,
"text": "LAMBDA LAMBDA LAMBDA FUNARG make-parameter parameterize lambda move let rec sizeof(a_plain_cxx_function) QUOTE"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9776/"
] |
220,668
|
<p>I've been searching around for a Continuous Integration solution for Ruby on Rails, but haven't been too pleased with the results. I came from a .NET shop that used CruiseControl.NET and was really spoiled with its ease of use and rich status/reporting.</p>
<p>Ideally I'm looking for:</p>
<ul>
<li><p>The obvious Git/SVN and Test::Unit
integration</p></li>
<li><p>Integration with Rake and/or
Capistrano</p></li>
<li><p>A web interface showing the status
of the build</p></li>
<li><p>Email notification of failed builds.</p></li>
<li><p>Desktop notification (potentially
through Growl)</p></li>
<li><p>REST API for build statuses</p></li>
<li><p>Plugin framework for running other code analysis tools and reporting results in the UI</p></li>
</ul>
|
[
{
"answer_id": 220692,
"author": "craigb",
"author_id": 18590,
"author_profile": "https://Stackoverflow.com/users/18590",
"pm_score": 5,
"selected": false,
"text": "CruiseControl Ruby Rake"
},
{
"answer_id": 8055423,
"author": "TALlama",
"author_id": 5657,
"author_profile": "https://Stackoverflow.com/users/5657",
"pm_score": 7,
"selected": true,
"text": "routes.rb resources :projects /Users/Shared/Jenkins/Home chown daemon jenkins"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/650/"
] |
220,672
|
<p>I have an excel sheet full of times.</p>
<p>They are formatted so that they look like: 1:00:15</p>
<p>However if I change the format on the cells to text, they change to the underlying numeric representation of the time: 0.041840278</p>
<p>How can I convert the cells to be text cells but still have the time in them ?</p>
|
[
{
"answer_id": 220734,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 6,
"selected": false,
"text": "=TEXT(A1,\"hh:mm:ss AM/PM\")"
},
{
"answer_id": 32119433,
"author": "LukStorms",
"author_id": 4003419,
"author_profile": "https://Stackoverflow.com/users/4003419",
"pm_score": 4,
"selected": false,
"text": "=TEXT(A1,\"hh:mm:ss\")\n"
},
{
"answer_id": 44608508,
"author": "Makah",
"author_id": 205034,
"author_profile": "https://Stackoverflow.com/users/205034",
"pm_score": 0,
"selected": false,
"text": "format() Function GetMyTimeField()\n Dim myTime As Date, myStrTime As String\n\n myTime = [A1]\n myStrTime = Format(myTime, \"hh:mm\")\n Debug.Print myStrTime & \" Nice!\"\n\nEnd Function\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/147/"
] |
220,717
|
<p>What would be the most efficient data type to store a UUID/GUID in databases that do not have a native UUID/GUID data type? 2 BIGINTs?</p>
<p>And what would be the most efficient code (C# preferred) to convert to and from a GUID to that type?</p>
<p>Thanks.</p>
|
[
{
"answer_id": 221016,
"author": "Brannon",
"author_id": 5745,
"author_profile": "https://Stackoverflow.com/users/5745",
"pm_score": 4,
"selected": true,
"text": "binary(16) System.Guid byte[] ToByteArray()"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8280/"
] |
220,718
|
<p>I am trying to use <code>set.insert (key)</code> as a conditional, where if the key is inserted correctly (meaning that the key does NOT already exist in the set ) then it should go on and perform some kind of code. For example, something like:</p>
<pre><code>if (set.insert( key )) {
// some kind of code
}
</code></pre>
<p>Is this allowed? Because the compiler is throwing this error: </p>
<pre><code>conditional expression of type 'std::_Tree<_Traits>::iterator' is illegal
</code></pre>
|
[
{
"answer_id": 220721,
"author": "Don Neufeld",
"author_id": 13097,
"author_profile": "https://Stackoverflow.com/users/13097",
"pm_score": 2,
"selected": false,
"text": "if( set.insert( key ).second ) {\n // some kind of code\n}\n"
},
{
"answer_id": 220722,
"author": "Charlie",
"author_id": 18529,
"author_profile": "https://Stackoverflow.com/users/18529",
"pm_score": 5,
"selected": true,
"text": "std::pair<iterator,bool> if( set.insert( key ).second ) {\n // code\n}\n"
},
{
"answer_id": 222894,
"author": "Richard Corden",
"author_id": 11698,
"author_profile": "https://Stackoverflow.com/users/11698",
"pm_score": 1,
"selected": false,
"text": "std::pair<std::set<key>::iterator, bool> iResult = set.insert (key);\nif (iResult.second) {\n // some kind of code - insert took place\n}\nelse {\n // some kind of code using iResult.first, which\n // is an iterator to the previous entry in the set.\n}\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29326/"
] |
220,719
|
<p>I have an application that detects if there is another instance of the app running and exits if one is found. This part seems to work reliably. My app takes a command-line argument that I would like to pass to the already running instance. I have the following code so far:</p>
<h2>Project1.dpr</h2>
<pre><code>program Project1;
uses
...
AppInstanceControl in 'AppInstanceControl.pas';
if not AppInstanceControl.RestoreIfRunning(Application.Handle) then
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TFormMain, FormMain);
Application.Run;
end;
end.
</code></pre>
<h2>AppInstanceControl.pas</h2>
<p>{ Based on code by Zarko Gajic found at <a href="http://delphi.about.com/library/code/ncaa100703a.htm" rel="noreferrer">http://delphi.about.com/library/code/ncaa100703a.htm</a>}</p>
<pre><code>unit AppInstanceControl;
interface
uses
Windows,
SysUtils;
function RestoreIfRunning(const AAppHandle: THandle; const AMaxInstances: integer = 1): boolean;
implementation
uses
Messages;
type
PInstanceInfo = ^TInstanceInfo;
TInstanceInfo = packed record
PreviousHandle: THandle;
RunCounter: integer;
end;
var
UMappingHandle: THandle;
UInstanceInfo: PInstanceInfo;
UMappingName: string;
URemoveMe: boolean = True;
function RestoreIfRunning(const AAppHandle: THandle; const AMaxInstances: integer = 1): boolean;
var
LCopyDataStruct : TCopyDataStruct;
begin
Result := True;
UMappingName := StringReplace(
ParamStr(0),
'\',
'',
[rfReplaceAll, rfIgnoreCase]);
UMappingHandle := CreateFileMapping($FFFFFFFF,
nil,
PAGE_READWRITE,
0,
SizeOf(TInstanceInfo),
PChar(UMappingName));
if UMappingHandle = 0 then
RaiseLastOSError
else
begin
if GetLastError <> ERROR_ALREADY_EXISTS then
begin
UInstanceInfo := MapViewOfFile(UMappingHandle,
FILE_MAP_ALL_ACCESS,
0,
0,
SizeOf(TInstanceInfo));
UInstanceInfo^.PreviousHandle := AAppHandle;
UInstanceInfo^.RunCounter := 1;
Result := False;
end
else //already runing
begin
UMappingHandle := OpenFileMapping(
FILE_MAP_ALL_ACCESS,
False,
PChar(UMappingName));
if UMappingHandle <> 0 then
begin
UInstanceInfo := MapViewOfFile(UMappingHandle,
FILE_MAP_ALL_ACCESS,
0,
0,
SizeOf(TInstanceInfo));
if UInstanceInfo^.RunCounter >= AMaxInstances then
begin
URemoveMe := False;
if IsIconic(UInstanceInfo^.PreviousHandle) then
ShowWindow(UInstanceInfo^.PreviousHandle, SW_RESTORE);
SetForegroundWindow(UInstanceInfo^.PreviousHandle);
end
else
begin
UInstanceInfo^.PreviousHandle := AAppHandle;
UInstanceInfo^.RunCounter := 1 + UInstanceInfo^.RunCounter;
Result := False;
end
end;
end;
end;
if (Result) and (CommandLineParam <> '') then
begin
LCopyDataStruct.dwData := 0; //string
LCopyDataStruct.cbData := 1 + Length(CommandLineParam);
LCopyDataStruct.lpData := PChar(CommandLineParam);
SendMessage(UInstanceInfo^.PreviousHandle, WM_COPYDATA, Integer(AAppHandle), Integer(@LCopyDataStruct));
end;
end; (*RestoreIfRunning*)
initialization
finalization
//remove this instance
if URemoveMe then
begin
UMappingHandle := OpenFileMapping(
FILE_MAP_ALL_ACCESS,
False,
PChar(UMappingName));
if UMappingHandle <> 0 then
begin
UInstanceInfo := MapViewOfFile(UMappingHandle,
FILE_MAP_ALL_ACCESS,
0,
0,
SizeOf(TInstanceInfo));
UInstanceInfo^.RunCounter := -1 + UInstanceInfo^.RunCounter;
end
else
RaiseLastOSError;
end;
if Assigned(UInstanceInfo) then UnmapViewOfFile(UInstanceInfo);
if UMappingHandle <> 0 then CloseHandle(UMappingHandle);
end.
</code></pre>
<h2>and in the main form unit:</h2>
<pre><code>procedure TFormMain.WMCopyData(var Msg: TWMCopyData);
var
LMsgString: string;
begin
Assert(Msg.CopyDataStruct.dwData = 0);
LMsgString := PChar(Msg.CopyDataStruct.lpData);
//do stuff with the received string
end;
</code></pre>
<p>I'm pretty sure the problem is that I'm trying to send the message to the handle of the running app instance but trying to process the message on the main form. I'm thinking I have two options here:</p>
<p>A) From the application's handle somehow get the handle of its main form and send the message there.</p>
<p>B) Handle receiving the message at the application rather than the main form level.</p>
<p>I'm not really sure how to go about either. Is there a better approach?</p>
<p>Thanks.</p>
|
[
{
"answer_id": 220852,
"author": "Tim Knipe",
"author_id": 10493,
"author_profile": "https://Stackoverflow.com/users/10493",
"pm_score": 4,
"selected": false,
"text": "procedure IPCSendMessage(target: HWND; const message: string);\nvar\n cds: TCopyDataStruct;\nbegin\n cds.dwData := 0;\n cds.cbData := Length(message) * SizeOf(Char);\n cds.lpData := Pointer(@message[1]);\n\n SendMessage(target, WM_COPYDATA, 0, LPARAM(@cds));\nend;\n procedure TForm1.WMCopyData(var msg: TWMCopyData);\nvar\n message: string;\nbegin\n SetLength(message, msg.CopyDataStruct.cbData div SizeOf(Char));\n Move(msg.CopyDataStruct.lpData^, message[1], msg.CopyDataStruct.cbData);\n\n // do something with the message e.g.\n Edit1.Text := message;\nend;\n"
},
{
"answer_id": 221263,
"author": "gabr",
"author_id": 4997,
"author_profile": "https://Stackoverflow.com/users/4997",
"pm_score": 3,
"selected": false,
"text": "program ReActivate;\n\nuses\n Forms,\n GpReActivator, \n raMain in 'raMain.pas' {frmReActivate};\n\n{$R *.res}\n\nbegin\n if ReactivateApplication(TfrmReActivate, WM_REACTIVATE) then\n Exit;\n\n Application.Initialize;\n Application.MainFormOnTaskbar := True;\n// Application.MainFormOnTaskbar := False;\n Application.CreateForm(TfrmReActivate, frmReActivate);\n Application.Run;\nend.\n unit raMain;\n\ninterface\n\nuses\n Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,\n Dialogs;\n\nconst\n WM_REACTIVATE = WM_APP;\n\ntype\n TfrmReActivate = class(TForm)\n private\n public\n procedure ReActivate(var msg: TMessage); message WM_REACTIVATE;\n end;\n\nvar\n frmReActivate: TfrmReActivate;\n\nimplementation\n\n{$R *.dfm}\n\nuses\n GpReactivator;\n\n{ TfrmReActivate }\n\nprocedure TfrmReActivate.ReActivate(var msg: TMessage);\nbegin\n GpReactivator.Activate;\nend; \n\nend.\n unit GpReActivator;\n\ninterface\n\nuses\n Classes;\n\nprocedure Activate;\nfunction ReActivateApplication(mainFormClass: TComponentClass; reactivateMsg: cardinal):\n boolean;\n\nimplementation\n\nuses\n Windows,\n Messages,\n SysUtils,\n Forms;\n\ntype\n TProcWndInfo = record\n ThreadID : DWORD;\n MainFormClass: TComponentClass;\n FoundWindow : HWND;\n end; { TProcWndInfo }\n PProcWndInfo = ^TProcWndInfo;\n\nvar\n fileMapping : THandle;\n fileMappingResult: integer;\n\nfunction ForceForegroundWindow(hwnd: THandle): boolean;\nvar\n foregroundThreadID: DWORD;\n thisThreadID : DWORD;\n timeout : DWORD;\nbegin\n if GetForegroundWindow = hwnd then\n Result := true\n else begin\n\n // Windows 98/2000 doesn't want to foreground a window when some other\n // window has keyboard focus\n\n if ((Win32Platform = VER_PLATFORM_WIN32_NT) and (Win32MajorVersion > 4)) or\n ((Win32Platform = VER_PLATFORM_WIN32_WINDOWS) and\n ((Win32MajorVersion > 4) or ((Win32MajorVersion = 4) and (Win32MinorVersion > 0)))) then\n begin\n\n // Code from Karl E. Peterson, www.mvps.org/vb/sample.htm\n // Converted to Delphi by Ray Lischner\n // Published in The Delphi Magazine 55, page 16\n\n Result := false;\n foregroundThreadID := GetWindowThreadProcessID(GetForegroundWindow,nil);\n thisThreadID := GetWindowThreadPRocessId(hwnd,nil);\n if AttachThreadInput(thisThreadID, foregroundThreadID, true) then begin\n BringWindowToTop(hwnd); //IE 5.5 - related hack\n SetForegroundWindow(hwnd);\n AttachThreadInput(thisThreadID, foregroundThreadID, false);\n Result := (GetForegroundWindow = hwnd);\n end;\n if not Result then begin\n\n // Code by Daniel P. Stasinski <dannys@karemor.com>\n\n SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, @timeout, 0);\n SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, TObject(0), SPIF_SENDCHANGE);\n BringWindowToTop(hwnd); //IE 5.5 - related hack\n SetForegroundWindow(hWnd);\n SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, TObject(timeout), SPIF_SENDCHANGE);\n end;\n end\n else begin\n BringWindowToTop(hwnd); //IE 5.5 - related hack\n SetForegroundWindow(hwnd);\n end;\n\n Result := (GetForegroundWindow = hwnd);\n end;\nend; { ForceForegroundWindow }\n\nprocedure Activate;\nbegin\n if (Application.MainFormOnTaskBar and (Application.MainForm.WindowState = wsMinimized))\n or\n ((not Application.MainFormOnTaskBar) and (not IsWindowVisible(Application.MainForm.Handle)))\n then\n Application.Restore\n else\n Application.BringToFront;\n ForceForegroundWindow(Application.MainForm.Handle);\nend; { Activate }\n\nfunction IsTopDelphiWindow(wnd: HWND): boolean;\nvar\n parentWnd: HWND;\n winClass : array [0..1024] of char;\nbegin\n parentWnd := GetWindowLong(wnd, GWL_HWNDPARENT);\n Result :=\n (parentWnd = 0)\n or\n (GetWindowLong(parentWnd, GWL_HWNDPARENT) = 0) and\n (GetClassName(parentWnd, winClass, SizeOf(winClass)) <> 0) and\n (winClass = 'TApplication');\nend; { IsTopDelphiWindow }\n\nfunction EnumGetProcessWindow(wnd: HWND; userParam: LPARAM): BOOL; stdcall;\nvar\n procWndInfo: PProcWndInfo;\n winClass : array [0..1024] of char;\nbegin\n procWndInfo := PProcWndInfo(userParam);\n if (GetWindowThreadProcessId(wnd, nil) = procWndInfo.ThreadID) and\n (GetClassName(wnd, winClass, SizeOf(winClass)) <> 0) and\n IsTopDelphiWindow(wnd) and\n (string(winClass) = procWndInfo.MainFormClass.ClassName) then\n begin\n procWndInfo.FoundWindow := Wnd;\n Result := false;\n end\n else\n Result := true;\nend; { EnumGetProcessWindow }\n\nfunction GetThreadWindow(threadID: cardinal; mainFormClass: TComponentClass): HWND;\nvar\n procWndInfo: TProcWndInfo;\nbegin\n procWndInfo.ThreadID := threadID;\n procWndInfo.MainFormClass := mainFormClass;\n procWndInfo.FoundWindow := 0;\n EnumWindows(@EnumGetProcessWindow, LPARAM(@procWndInfo));\n Result := procWndInfo.FoundWindow;\nend; { GetThreadWindow }\n\nfunction ReActivateApplication(mainFormClass: TComponentClass; reactivateMsg: cardinal):\n boolean;\nvar\n mappingData: PDWORD;\nbegin\n Result := false;\n if fileMappingResult = NO_ERROR then begin // first owner\n mappingData := MapViewOfFile(fileMapping, FILE_MAP_WRITE, 0, 0, SizeOf(DWORD));\n Win32Check(assigned(mappingData));\n mappingData^ := GetCurrentThreadID;\n UnmapViewOfFile(mappingData);\n end\n else if fileMappingResult = ERROR_ALREADY_EXISTS then begin // app already started\n mappingData := MapViewOfFile(fileMapping, FILE_MAP_READ, 0, 0, SizeOf(DWORD));\n if mappingData^ <> 0 then begin // 0 = race condition\n PostMessage(GetThreadWindow(mappingData^, mainFormClass), reactivateMsg, 0, 0);\n Result := true;\n end;\n UnmapViewOfFile(mappingData);\n Exit;\n end\n else\n RaiseLastWin32Error;\nend; { ReActivateApplication }\n\ninitialization\n fileMapping := CreateFileMapping(INVALID_HANDLE_VALUE, nil, PAGE_READWRITE, 0,\n SizeOf(DWORD), PChar(StringReplace(ParamStr(0), '\\', '', [rfReplaceAll, rfIgnoreCase])));\n Win32Check(fileMapping <> 0);\n fileMappingResult := GetLastError;\nfinalization\n if fileMapping <> 0 then\n CloseHandle(fileMapping);\nend.\n"
},
{
"answer_id": 224549,
"author": "lukeck",
"author_id": 2189521,
"author_profile": "https://Stackoverflow.com/users/2189521",
"pm_score": 2,
"selected": false,
"text": " if not AppInstanceControl.RestoreIfRunning(Application.Handle) then\n begin\n Application.Initialize;\n Application.MainFormOnTaskbar := True;\n Application.CreateForm(TFormMain, FormMain);\n SetRunningInstanceMainFormHandle(FormMain.Handle);\n Application.Run;\n end else\n SendMsgToRunningInstanceMainForm('Message string goes here');\n type\n PInstanceInfo = ^TInstanceInfo;\n TInstanceInfo = packed record\n PreviousHandle: THandle;\n PreviousMainFormHandle: THandle;\n RunCounter: integer;\n end;\n\nprocedure SetRunningInstanceMainFormHandle(const AMainFormHandle: THandle);\nbegin\n UMappingHandle := OpenFileMapping(\n FILE_MAP_ALL_ACCESS,\n False,\n PChar(UMappingName));\n if UMappingHandle <> 0 then\n begin\n UInstanceInfo := MapViewOfFile(UMappingHandle,\n FILE_MAP_ALL_ACCESS,\n 0,\n 0,\n SizeOf(TInstanceInfo));\n\n UInstanceInfo^.PreviousMainFormHandle := AMainFormHandle;\n end;\nend;\n\nprocedure SendMsgToRunningInstanceMainForm(const AMsg: string);\nvar\n LCopyDataStruct : TCopyDataStruct;\nbegin\n UMappingHandle := OpenFileMapping(\n FILE_MAP_ALL_ACCESS,\n False,\n PChar(UMappingName));\n if UMappingHandle <> 0 then\n begin\n UInstanceInfo := MapViewOfFile(UMappingHandle,\n FILE_MAP_ALL_ACCESS,\n 0,\n 0,\n SizeOf(TInstanceInfo));\n\n\n LCopyDataStruct.dwData := 0; //string\n LCopyDataStruct.cbData := 1 + Length(AMsg);\n LCopyDataStruct.lpData := PChar(AMsg);\n\n SendMessage(UInstanceInfo^.PreviousMainFormHandle, WM_COPYDATA, Integer(Application.Handle), Integer(@LCopyDataStruct));\n end;\nend;\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220719",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2189521/"
] |
220,742
|
<p>I need a serviceable shell for MSYS. This is my current dilemma: </p>
<p>The default rxvt.exe has a scroll bar and copy and paste, but doesn't send control characters or arrow keys to a running program in the shell (like interpreters/debuggers). This is a real thorn when using the Haskell interpreter ghci.</p>
<p>The other shell sh.exe handles control characters (or at least some of them), but has no scroll bar or copy and paste.</p>
<p>rxvt also has (relatively) more issues with output buffering</p>
<p>What are my options? Does the replacement shell need to be msys aware? All I want is a sane environment to work with Haskell (ghc), C++ (gcc), and the basic tool chain (make and what not). I'm willing to compile a shell if it doesn't involve crazy shenanigans.</p>
|
[
{
"answer_id": 220759,
"author": "Hugh Allen",
"author_id": 15069,
"author_profile": "https://Stackoverflow.com/users/15069",
"pm_score": 2,
"selected": false,
"text": "sh.exe"
},
{
"answer_id": 9124305,
"author": "Doug",
"author_id": 353820,
"author_profile": "https://Stackoverflow.com/users/353820",
"pm_score": 3,
"selected": false,
"text": "mingw-get install mintty\nmintty\n"
},
{
"answer_id": 26303925,
"author": "MichalAntkiew",
"author_id": 3642157,
"author_profile": "https://Stackoverflow.com/users/3642157",
"pm_score": 1,
"selected": false,
"text": "C:\\msys64\\usr\\bin\\sh.exe --login -i\n"
},
{
"answer_id": 30760675,
"author": "Theodore Lief Gannon",
"author_id": 3955068,
"author_profile": "https://Stackoverflow.com/users/3955068",
"pm_score": 1,
"selected": false,
"text": "mintty \\ESC mintty pacman -R mintty"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14903/"
] |
220,747
|
<p>I have three related tables "A(id, val)", "B(id, val)", and a link table with a value "AB(aid, bid, val)"</p>
<p>I am querying against B to bring back A values, for example:</p>
<pre><code>SELECT A.*
FROM A INNER JOIN AB ON A.id = AB.aid INNER JOIN B ON AB.bid = B.id
WHERE B.val = 'foo';
</code></pre>
<p>Every A has many B's and every B has many A's.</p>
<p>And the catch that I'm falling apart on is the need to filter the set so that the query returns rows only when AB.val is a max for any given A/B pair</p>
<p>E.g. if I have the data:</p>
<h2>A</h2>
<pre><code>id val
1 something
2 somethingelse
</code></pre>
<h2>B</h2>
<pre><code>id val
1 foo
2 bar
</code></pre>
<h2>AB</h2>
<pre><code>aid bid val
1 1 3
1 2 2
2 1 1
2 2 4
</code></pre>
<p>I would want to select only the first and last rows of AB since they are the max values for each of the A's and then be able to query against B.val = 'foo' to return only the first row. I don't have a clue on how I can constrain against only the max val row in the AB table.</p>
<p>The best I've been able to get is</p>
<pre><code>SELECT *
FROM A
INNER JOIN
(SELECT aid, bid, MAX(val) AS val FROM AB GROUP BY aid) as AB
ON A.id = AB.aid
INNER JOIN B ON AB.id = B.id
WHERE B.val = 'foo'
</code></pre>
<p>but this doesn't quite work. First, it just feels to be the wrong approach, second, it returns bad bid values. That is, the bid returned from the subquery is not necessarily from the same row as the max(val). I believe this is a known group by issue where selection of values to return when the column is not specified for either collation or grouping is undefined.</p>
<p>I hope that some of the above makes sense, I've been banging my head against a wall for the past few hours over this and any help at all would be hugely appreciated. Thanks.</p>
<p>(For those wondering, the actual use of this is for a Dictionary backend where A is the Word Table and B is the Phoneme Table. AB is the WordPhoneme table with a 'position' column. The query is to find all words that end with a specified phoneme. (a phoneme is a word sound, similar in usage to the international phonetic alphabet )</p>
|
[
{
"answer_id": 220798,
"author": "Blorgbeard",
"author_id": 369,
"author_profile": "https://Stackoverflow.com/users/369",
"pm_score": 2,
"selected": false,
"text": "select a.*\nfrom a\nleft join (\n select aid, max(val) as val \n from ab \n group by aid\n) abmax on abmax.aid=a.id\ninner join ab on ab.aid=abmax.aid and ab.val=abmax.val\ninner join b on b.id=ab.bid\nwhere b.val='foo'\n"
},
{
"answer_id": 220829,
"author": "patmortech",
"author_id": 19090,
"author_profile": "https://Stackoverflow.com/users/19090",
"pm_score": 1,
"selected": false,
"text": "select a.*\nfrom ab\n inner join b on(ab.bid=b.id)\n inner join a on (ab.aid=a.id)\nwhere ab.val = (select max(val) from ab AS ab2 where ab2.aid = ab.aid)\n and b.val='foo'\n"
},
{
"answer_id": 220938,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 1,
"selected": false,
"text": "SELECT a.*\nFROM ab AS ab1\n LEFT OUTER JOIN ab AS ab2 ON (ab1.aid = ab2.aid AND ab1.val < ab2.val)\n JOIN a ON (ab1.aid = a.id)\n JOIN b ON (ab1.bid = b.id)\nWHERE ab2.aid IS NULL\n AND b.val = 'foo';\n"
},
{
"answer_id": 222057,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 0,
"selected": false,
"text": "SELECT *\nFROM\n(\n SELECT\n A.*,\n (SELECT top 1 AB.BID FROM AB WHERE A.AID = AB.AID ORDER BY AB.val desc) as BID\n FROM A\n) as Aplus\nJOIN B ON Aplus.BID = B.BID\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
220,751
|
<p>I have a DataTable that has a boolean column called [Invalid]. I need to divide this data up by this Invalid column - valid rows can be edited, invalid rows cannot. My original plan was to use two BindingSources and set the Filter property ([Invalid] = 'false', for instance), which plays right into my hands because I have two DataGridViews and so I need two BindingSources anyway.</p>
<p>This doesn't work: the BindingSources set the Filter property associated with the DataTable, so both BindingSources hold the same data. Am I going to have to do two fetches from the database, or can I do what I want with the objects I have?</p>
|
[
{
"answer_id": 220798,
"author": "Blorgbeard",
"author_id": 369,
"author_profile": "https://Stackoverflow.com/users/369",
"pm_score": 2,
"selected": false,
"text": "select a.*\nfrom a\nleft join (\n select aid, max(val) as val \n from ab \n group by aid\n) abmax on abmax.aid=a.id\ninner join ab on ab.aid=abmax.aid and ab.val=abmax.val\ninner join b on b.id=ab.bid\nwhere b.val='foo'\n"
},
{
"answer_id": 220829,
"author": "patmortech",
"author_id": 19090,
"author_profile": "https://Stackoverflow.com/users/19090",
"pm_score": 1,
"selected": false,
"text": "select a.*\nfrom ab\n inner join b on(ab.bid=b.id)\n inner join a on (ab.aid=a.id)\nwhere ab.val = (select max(val) from ab AS ab2 where ab2.aid = ab.aid)\n and b.val='foo'\n"
},
{
"answer_id": 220938,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 1,
"selected": false,
"text": "SELECT a.*\nFROM ab AS ab1\n LEFT OUTER JOIN ab AS ab2 ON (ab1.aid = ab2.aid AND ab1.val < ab2.val)\n JOIN a ON (ab1.aid = a.id)\n JOIN b ON (ab1.bid = b.id)\nWHERE ab2.aid IS NULL\n AND b.val = 'foo';\n"
},
{
"answer_id": 222057,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 0,
"selected": false,
"text": "SELECT *\nFROM\n(\n SELECT\n A.*,\n (SELECT top 1 AB.BID FROM AB WHERE A.AID = AB.AID ORDER BY AB.val desc) as BID\n FROM A\n) as Aplus\nJOIN B ON Aplus.BID = B.BID\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5133/"
] |
220,758
|
<p>I was fortunate enough to be able to start fresh with Grails. However, many people have asked me how to add Groovy and/or Grails to a legacy Java/JSP web app. Do people have experience or recommendations on how to best include Groovy and Grails into a large legacy application?</p>
|
[
{
"answer_id": 262203,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "http://www.ibm.com/developerworks/java/library/j-pg03155\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220758",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
220,767
|
<p>How exactly do you make an auto-refreshing <code>div</code> with JavaScript (specifically, jQuery)?</p>
<p>I know about the <code>setTimeout</code> method, but is it really a good practice ? Is there a better method?</p>
<pre><code>function update() {
$.get("response.php", function(data) {
$("#some_div").html(data);
});
window.setTimeout("update();", 10000);
}
</code></pre>
|
[
{
"answer_id": 220800,
"author": "gregmac",
"author_id": 7913,
"author_profile": "https://Stackoverflow.com/users/7913",
"pm_score": 6,
"selected": true,
"text": "function update() {\n $.get(\"response.php\", function(data) {\n $(\"#some_div\").html(data);\n window.setTimeout(update, 10000);\n });\n}\n function update() {\n $(\"#notice_div\").html('Loading..'); \n $.ajax({\n type: 'GET',\n url: 'response.php',\n timeout: 2000,\n success: function(data) {\n $(\"#some_div\").html(data);\n $(\"#notice_div\").html(''); \n window.setTimeout(update, 10000);\n },\n error: function (XMLHttpRequest, textStatus, errorThrown) {\n $(\"#notice_div\").html('Timeout contacting server..');\n window.setTimeout(update, 60000);\n }\n}\n"
},
{
"answer_id": 5692861,
"author": "Faghani",
"author_id": 712021,
"author_profile": "https://Stackoverflow.com/users/712021",
"pm_score": 2,
"selected": false,
"text": "function update() {\n $(\"#notice_div\").html('Loading..'); \n $.ajax({\n type: 'GET',\n url: 'jbede.php',\n timeout: 2000,\n success: function(data) {\n $(\"#some_div\").html(data);\n $(\"#notice_div\").html(''); \n window.setTimeout(update, 10000);\n },\n error: function (XMLHttpRequest, textStatus, errorThrown) {\n $(\"#notice_div\").html('Timeout contacting server..');\n window.setTimeout(update, 60000);\n }\n});\n}\n$(document).ready(function() {\n update();\n});\n"
},
{
"answer_id": 9261806,
"author": "Viktor Trón",
"author_id": 641672,
"author_profile": "https://Stackoverflow.com/users/641672",
"pm_score": 3,
"selected": false,
"text": "$(document).ready(function() {\n $.ajaxSetup({ cache: false }); // This part addresses an IE bug. without it, IE will only load the first number and will never refresh\n setInterval(function() {\n $('#notice_div').load('response.php');\n }, 3000); // the \"3000\" \n});\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26721/"
] |
220,772
|
<p>Before I explain what I'm trying to do, note that I have the good fortune of only having to target Webkit (meaning, I can use lots of neat CSS).</p>
<p>So, basically, I want to have a block with a flexible height, position fixed, maximum height being that of the available window height, with some elements at the top and bottom of the block that are always visible, and in the middle an area with overflow auto. Basically it'd look like this:</p>
<pre>
----------------------
| Top item | |
| | |
| stuff | |
| | |
| | |
| Last item | |
|------------ |
| |
| |
----------------------
----------------------
| Top item | |
|-----------| |
| lots |^| |
| of |_| |
| stuff |_| |
| | | |
| | | |
|-----------| |
| Last item | |
----------------------</pre>
<p>Can it be done with CSS? Or will I have to hack it with Javascript? I'd be willing to accept a little div-itis if that's what it takes to make this work—better div-itis than trying to account for every stupid little thing like reflow and window resize and all of that nonsense.</p>
<p>I'm prepared for the bad news that this isn't something CSS can do, but I've been pleasantly surprised by the magic some folks on SO can work before.</p>
|
[
{
"answer_id": 220800,
"author": "gregmac",
"author_id": 7913,
"author_profile": "https://Stackoverflow.com/users/7913",
"pm_score": 6,
"selected": true,
"text": "function update() {\n $.get(\"response.php\", function(data) {\n $(\"#some_div\").html(data);\n window.setTimeout(update, 10000);\n });\n}\n function update() {\n $(\"#notice_div\").html('Loading..'); \n $.ajax({\n type: 'GET',\n url: 'response.php',\n timeout: 2000,\n success: function(data) {\n $(\"#some_div\").html(data);\n $(\"#notice_div\").html(''); \n window.setTimeout(update, 10000);\n },\n error: function (XMLHttpRequest, textStatus, errorThrown) {\n $(\"#notice_div\").html('Timeout contacting server..');\n window.setTimeout(update, 60000);\n }\n}\n"
},
{
"answer_id": 5692861,
"author": "Faghani",
"author_id": 712021,
"author_profile": "https://Stackoverflow.com/users/712021",
"pm_score": 2,
"selected": false,
"text": "function update() {\n $(\"#notice_div\").html('Loading..'); \n $.ajax({\n type: 'GET',\n url: 'jbede.php',\n timeout: 2000,\n success: function(data) {\n $(\"#some_div\").html(data);\n $(\"#notice_div\").html(''); \n window.setTimeout(update, 10000);\n },\n error: function (XMLHttpRequest, textStatus, errorThrown) {\n $(\"#notice_div\").html('Timeout contacting server..');\n window.setTimeout(update, 60000);\n }\n});\n}\n$(document).ready(function() {\n update();\n});\n"
},
{
"answer_id": 9261806,
"author": "Viktor Trón",
"author_id": 641672,
"author_profile": "https://Stackoverflow.com/users/641672",
"pm_score": 3,
"selected": false,
"text": "$(document).ready(function() {\n $.ajaxSetup({ cache: false }); // This part addresses an IE bug. without it, IE will only load the first number and will never refresh\n setInterval(function() {\n $('#notice_div').load('response.php');\n }, 3000); // the \"3000\" \n});\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17964/"
] |
220,773
|
<p>I wrote a simple javascript image rotator which picks a random image on each page load. The issue is that if i use a default image, that default image will show up for a second before the javascript loads and replaces it. Obviously if someone has javascript disabled i want them to see an image. How can i have a default image without a flickering of the default image.</p>
|
[
{
"answer_id": 220789,
"author": "Ates Goral",
"author_id": 23501,
"author_profile": "https://Stackoverflow.com/users/23501",
"pm_score": 0,
"selected": false,
"text": "window.onload = function () {\n var img = document.getElementById(\"rotating_image\");\n\n // Hide the default image that's shown to people with no JS\n img.style.visibility = \"hidden\";\n\n // We'll unhide it when our new image loads\n img.onload = function () {\n img.style.visibility = \"visible\";\n };\n\n // Load a random image\n img.src = \"http://example.com/random\" + Math.floor(Math.random() * 5) + \".jpg\";\n\n};\n"
},
{
"answer_id": 220806,
"author": "Darryl Hein",
"author_id": 5441,
"author_profile": "https://Stackoverflow.com/users/5441",
"pm_score": 0,
"selected": false,
"text": "<img src=\"/not/rotated/image.jpg\" />\n<script type=\"text/javascript\">\n// change image\n</script>\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7894/"
] |
220,775
|
<p>Should you always check parameters and throw exceptions in .NET when the parameters are not what you expected? E.g. null objects or empty strings?</p>
<p>I started doing this, but then thought that this will bloat my code a lot if it’s done on every single method. Should I check parameters for both private and public methods?</p>
<p>I end up throwing a lot of ArgumentNullException("name") exceptions even though the code handling the exception can’t really do anything different programmatically since there is not guarantee that "name" will not change in the future.</p>
<p>I assume this info is just helpful when viewing a log full of exception information?</p>
<p>Is it best practice to always “plain for the worst”.</p>
|
[
{
"answer_id": 220782,
"author": "Robert Gould",
"author_id": 15124,
"author_profile": "https://Stackoverflow.com/users/15124",
"pm_score": 1,
"selected": false,
"text": "if value == not_valid then\n#if DEBUG\n log failure\n value = a_safe_default_value\n#elsif RELASE\n throw\n#endif\nend\n"
},
{
"answer_id": 221103,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": false,
"text": "[NullArgumentAspect(\"text\")]\npublic static IEnumerable<char> GetAspectEnhancedEnumerable(string text)\n{ /* text is automatically checked for null, and an ArgumentNullException thrown */ }\n static void ThrowIfNull<T>(this T value, string name) where T : class\n{\n if (value == null) throw new ArgumentNullException(name);\n}\n// ...\nstream.ThrowIfNull(\"stream\");\n"
},
{
"answer_id": 221141,
"author": "Greg Beech",
"author_id": 13552,
"author_profile": "https://Stackoverflow.com/users/13552",
"pm_score": 1,
"selected": false,
"text": "public protected protected internal public internal private Debug.Assert"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
220,777
|
<p>One of the modules for my app uses functions from a .pyd file. There's an option to exclude dlls (exclude_dlls) but is there one for including them? The build process doesn't seem to be copying the .pyd in my module despite copying the rest of the files (.py). I also need to include a .dll. How do I get py2exe to include both .pyd and .dll files?</p>
|
[
{
"answer_id": 220892,
"author": "Claudiu",
"author_id": 15055,
"author_profile": "https://Stackoverflow.com/users/15055",
"pm_score": 2,
"selected": false,
"text": "script = \"PyInvaders.py\" #name of starting .PY\nproject_name = os.path.splitext(os.path.split(script)[1])[0]\nsetup(name=project_name, scripts=[script]) #this installs the program\n\n#also need to hand copy the extra files here\ndef installfile(name):\n dst = os.path.join('dist', project_name)\n print 'copying', name, '->', dst\n if os.path.isdir(name):\n dst = os.path.join(dst, name)\n if os.path.isdir(dst):\n shutil.rmtree(dst)\n shutil.copytree(name, dst)\n elif os.path.isfile(name):\n shutil.copy(name, dst)\n else:\n print 'Warning, %s not found' % name\n\npygamedir = os.path.split(pygame.base.__file__)[0]\ninstallfile(os.path.join(pygamedir, pygame.font.get_default_font()))\ninstallfile(os.path.join(pygamedir, 'pygame_icon.bmp'))\nfor data in extra_data:\n installfile(data)\n"
},
{
"answer_id": 224154,
"author": "John Fouhy",
"author_id": 15154,
"author_profile": "https://Stackoverflow.com/users/15154",
"pm_score": 2,
"selected": false,
"text": "import glob\nsetup(name='MyApp',\n # other options,\n data_files=[('.', glob.glob('*.dll')),\n ('.', glob.glob('*.pyd'))],\n )\n"
},
{
"answer_id": 224274,
"author": "Tony Meyer",
"author_id": 4966,
"author_profile": "https://Stackoverflow.com/users/4966",
"pm_score": 4,
"selected": false,
"text": "setup(name='App',\n # other options,\n data_files=[('.', 'foo.dll'), ('.', 'bar.dll')],\n options = {\"py2exe\" : {\"includes\" : \"module1,module2,module3\"}}\n )\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220777",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20879/"
] |
220,796
|
<p>I have all the web pages of a website. My task is to change all HTML files to <code>.asp</code> files and change the links. I have about 280 HTML files.<br>
Is there any software or web service which can read a website and show me the link structure of the site (to make my job easier) similar to a site map?</p>
|
[
{
"answer_id": 220843,
"author": "Julien Grenier",
"author_id": 23051,
"author_profile": "https://Stackoverflow.com/users/23051",
"pm_score": 2,
"selected": false,
"text": "find . -type f -name '*html' | awk '{ print \"mv \" $0 \" \" substr($0,0,length($0)-4)} | sh' find . type f -name '*asp' | xargs perl -PI -e 's/\\.html/\\.asp/g;"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12178/"
] |
220,813
|
<p>I have several branches in TFS (dev, test, stage) and when I merge changes into the test branch I want the automated build and deploy script to find all the updated SQL files and deploy them to the test database.</p>
<p>I thought I could do this by finding all the changesets associated with the build since the last good build, finding all the sql files in the changesets and deploying them. However I don't seem to be having the changeset associated with the build for some reason so my question is twofold:</p>
<p>1) How do I ensure that a changeset is associated with a particular build?</p>
<p>2) How can I get a list of files that have changed in the branch since the last good build? I have the last successfully built build but I'm unsure how to get the files without checking the changesets (which as mentioned above are not associated with the build!)</p>
|
[
{
"answer_id": 252916,
"author": "mjallday",
"author_id": 6084,
"author_profile": "https://Stackoverflow.com/users/6084",
"pm_score": 4,
"selected": true,
"text": "TeamFoundationServer tfs = new TeamFoundationServer(TfsServerUrl);\nVersionControlServer vcs = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));\n\nvar buildServer = (IBuildServer)tfs.GetService(typeof(IBuildServer));\n\n\nIBuildDetail build = buildServer.GetBuild(\n new Uri(BuildUri)\n , null\n , QueryOptions.All\n);\n\nbuild.RefreshAllDetails();\n\nvar changesets = InformationNodeConverters.GetAssociatedChangesets(build);\n\nforeach (var changesetSummary in changesets)\n{\n Changeset changeSet = vcs.GetChangeset(changesetSummary.ChangesetId);\n\n sqlFilePaths.AddRange(\n ProcessChangeSet(changeSet)\n );\n\n}\n List<string> sqlFilePaths = new List<string>();\nforeach (Change change in changeSet.Changes)\n{\n\n if ((change.Item.ItemType == ItemType.File)\n && (change.Item.ServerItem.EndsWith(\".sql\", StringComparison.OrdinalIgnoreCase))\n )\n {\n sqlFilePaths.Add(\n sqlPath\n );\n\n }\n}\nreturn sqlFilePathes;\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6084/"
] |
220,818
|
<p>How can I detect keyboard event in C language without using third party libraries? Should I use signal handling?</p>
|
[
{
"answer_id": 220876,
"author": "Mark Harrison",
"author_id": 116,
"author_profile": "https://Stackoverflow.com/users/116",
"pm_score": 4,
"selected": true,
"text": "getch();\n static struct termios save_termios;\nstatic int term_saved;\n\nint tty_raw(int fd) { /* RAW! mode */\n struct termios buf;\n\n if (tcgetattr(fd, &save_termios) < 0) /* get the original state */\n return -1;\n\n buf = save_termios;\n\n buf.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);\n /* echo off, canonical mode off, extended input\n processing off, signal chars off */\n\n buf.c_iflag &= ~(BRKINT | ICRNL | ISTRIP | IXON);\n /* no SIGINT on BREAK, CR-toNL off, input parity\n check off, don't strip the 8th bit on input,\n ouput flow control off */\n\n buf.c_cflag &= ~(CSIZE | PARENB);\n /* clear size bits, parity checking off */\n\n buf.c_cflag |= CS8;\n /* set 8 bits/char */\n\n buf.c_oflag &= ~(OPOST);\n /* output processing off */\n\n buf.c_cc[VMIN] = 1; /* 1 byte at a time */\n buf.c_cc[VTIME] = 0; /* no timer on input */\n\n if (tcsetattr(fd, TCSAFLUSH, &buf) < 0)\n return -1;\n\n term_saved = 1;\n\n return 0;\n}\n\n\nint tty_reset(int fd) { /* set it to normal! */\n if (term_saved)\n if (tcsetattr(fd, TCSAFLUSH, &save_termios) < 0)\n return -1;\n\n return 0;\n}\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/130278/"
] |
220,822
|
<p>Strange performance outcome, I have a LINQ to SQL query which uses several let statements to get various info it looks like this</p>
<pre><code> public IQueryable<SystemNews> GetSystemNews()
{
using (var t = new TransactionScope(TransactionScopeOption.Required,
new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted }))
{
var results = from s in _datacontext.SystemNews
let member = GetMemberInfo(s.MemberID)
let determination = GetDetermination(s.DeterminationID.Value)
let daimoku = GetDaimoku(s.DaimokuID.Value)
let entry = GetEntry(s.EntryID.Value)
let encouragment = GetEncouragement(s.EncouragementID.Value)
select new SystemNews
{
NewsDate = s.NewsDate,
MemberID = s.MemberID,
PhotoID = s.PhotoID.Value,
DeterminationID = s.DeterminationID.Value,
DaimokuID = s.DaimokuID.Value,
EntryID = s.EntryID.Value,
EncouragementID = s.EncouragementID.Value,
Member = new LazyList<Members>(member),
Determination = new LazyList<Determinations>(determination),
Daimoku = new LazyList<MemberDaimoku>(daimoku),
Entry = new LazyList<MemberEntries>(entry),
Encouragement = new LazyList<MemberEncouragements>(encouragment),
IsDeterminationComplete = s.IsDeterminationComplete.Value
};
return results;
}
}
</code></pre>
<p>I created the same thing (basically at least the various info that is obtained in this) into a SQL View, and the LINQ to SQL returned results in under 90 miliseconds where as the view returned the same data actually less info in over 700 milliseconds. Can anyone explain this?</p>
|
[
{
"answer_id": 221090,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": true,
"text": "_datacontext.Log = Console.Out;\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22093/"
] |
220,828
|
<p>I have an application running on multiple IIS servers that need to parse a CSV file that is placed on a common network drive. If I use the <a href="http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.created.aspx" rel="nofollow noreferrer">System.IO.FileSystemWatcher Created event</a> to be notified of the event when the file is available, how can I ensure only one server parses the file? If all servers are notified of this change, all will try to parse it. Should the first server copy this locally and then parse it? Would this cause errors on the other servers? Should I set the remote directory access to only allow one server read access?</p>
<p>The file contains records that needs to be inserted into a shared database, but there is no unique key for the records. Therefore, if more than one server grabs the file at the same time and inserts the records, there will be duplicates in the database.</p>
|
[
{
"answer_id": 220957,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 3,
"selected": true,
"text": "FileStream fs = new FileStream(\n FilePath, \n FileMode.Open,\n FileAccess.ReadWrite, \n FileShare.None\n);\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4555/"
] |
220,832
|
<p>If I have the string <code>.....ZZ..ZZ.....</code> or <code>.Z.1.Z.23Z.4.Z55</code>,</p>
<p>Is there an easy way of shifting all <code>Z</code>characters in the string one space right of the current position?</p>
<p>Some additional test strings are:</p>
<ul>
<li><code>.Z</code></li>
<li><code>Z.</code></li>
<li><code>ZZ.</code></li>
<li><code>.ZZ</code></li>
<li><code>Z</code></li>
<li><code>ZZ</code></li>
<li><code>ZZZ</code></li>
</ul>
<p>I think a few of the higher voted answers to this question (including the currently accepted one) do not work on these tests.</p>
|
[
{
"answer_id": 220837,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 4,
"selected": true,
"text": "int main ()\n{\n char text[] = \"...Z.Z.Z...\", temp;\n int text_len = strlen (text), i;\n for (i = text_len - 1; i >= 0; i--)\n {\n if (text[i] == 'Z')\n {\n temp = text[i+1];\n text[i+1] = text[i];\n text[i] = temp;\n }\n }\n printf (\"%s\\n\", text);\n return 0;\n}\n [~]$ gcc zshift.c && ./a.out\n....Z.Z.Z..\n zshift \"Z.\" -> \".Z\"\nzshift \".Z\" -> \".\"\nzshift \"Z\" -> \"\"\n temp = text[i+1];\nif (temp == 0) continue;\ntext[i+1] = text[i];\ntext[i] = temp;\n"
},
{
"answer_id": 220850,
"author": "Steve Lacey",
"author_id": 11077,
"author_profile": "https://Stackoverflow.com/users/11077",
"pm_score": 0,
"selected": false,
"text": " char text[] = \"...Z.Z.Z...\";\n\n for (int i = strlen(text) - 2); i > 0; --i) {\n if (text[i] == 'Z' && text[i + 1] == '.') {\n text[i] = '.';\n text[i + 1] = 'Z';\n }\n }\n"
},
{
"answer_id": 220880,
"author": "ypnos",
"author_id": 21974,
"author_profile": "https://Stackoverflow.com/users/21974",
"pm_score": 2,
"selected": false,
"text": "void move_z_right (char* str, int strlen) {\n for (unsigned int i = 0; i < strlen - 1; ++i)\n {\n if (str[i] == 'Z')\n {\n unsigned int j = i+1;\n while (str[j] == 'Z' && j < strlen - 1) ++j;\n if (j == strlen) break; // we are at the end, done\n char tmp = str[j];\n str[j] = str[i];\n str[i] = tmp;\n i = j; // continue after new Z next run\n }\n }\n}\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29326/"
] |
220,846
|
<p>Our groups legacy ASP 3.0 web apps were able to take advantage of a global error file by setting up a custom error file within IIS's Custom Error's tab. I'm unable to find a similar solution for ASP.NET apps. </p>
<p>Does anyone know if there is a way to have a centralized "Error.aspx" page (for example) that will trap errors for an entire application pool? The objective is to avoid adding custom code to each app's Global error handler ....</p>
<p>Any guidance is greatly appreciated!</p>
|
[
{
"answer_id": 220875,
"author": "SaaS Developer",
"author_id": 7215,
"author_profile": "https://Stackoverflow.com/users/7215",
"pm_score": 1,
"selected": false,
"text": "<customErrors defaultRedirect=\"[url]\"></customErrors>"
},
{
"answer_id": 221340,
"author": "Ben R",
"author_id": 27705,
"author_profile": "https://Stackoverflow.com/users/27705",
"pm_score": 1,
"selected": false,
"text": "Exception myError = Server.GetLastError();\nException baseException = myError.GetBaseException();\n"
},
{
"answer_id": 221734,
"author": "Maxime Rouiller",
"author_id": 24975,
"author_profile": "https://Stackoverflow.com/users/24975",
"pm_score": 0,
"selected": false,
"text": "public class ErrorHandlingModule : IHttpModule\n{\n public void Init(HttpApplication application)\n {\n application.Error += new System.EventHandler(OnError);\n }\n\n public void OnError(object obj, EventArgs args)\n {\n Exception ex = HttpContext.Current.Server.GetLastError();\n //Log your error here or pick a funny message to display\n HttpContext.Current.Server.ClearError();\n HttpContext.Current.Response.Redirect(\"/Error.aspx\", false);\n }\n}\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4646/"
] |
220,847
|
<p>in the multi-threaded app I am porting to Symbian using Open C, I have an object that uses an RFile to read/write data to file. This object is supposed to be accessed from different threads (it is threadsafe), however there is the issue that apparently RFile objects can only be accessed within one thread only. As soon as another thread uses the RFile object, I am getting a KERN-EXEC 0. </p>
<p>Is there any way to share the RFile object between different threads? I can't use Active Objects. </p>
|
[
{
"answer_id": 2049095,
"author": "Dynite",
"author_id": 16177,
"author_profile": "https://Stackoverflow.com/users/16177",
"pm_score": 0,
"selected": false,
"text": "RFile::TransferToClient(const RMessage2 &,TInt)const\n RFile::TransferToProcess(RProcess &,TInt,TInt)const\n RFile::TransferToServer(TIpcArgs &,TInt,TInt)const\n RFile::AdoptFromClient(const RMessage2 &,TInt,TInt)\n RFile::AdoptFromCreator(TInt,TInt)\n RFile::AdoptFromServer(TInt,TInt)\n RFile::Duplicate(const RFile &,TOwnerType)\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27101/"
] |
220,855
|
<p>By default gcc/g++ prints a warning message with the line number only. I am looking for the option by which g++ or gcc associates the build warning messages with the warning ids, so that the warning messages can be identified easily (without parsing). Also can there be any more option to get a more detailed warning message ? (Though I think each of the warning message is pretty much explanatory by itself, but just curious)</p>
<p>Thanks.</p>
|
[
{
"answer_id": 220912,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 1,
"selected": false,
"text": "-Wno-pragmas -Wno-oveflow"
},
{
"answer_id": 221132,
"author": "JesperE",
"author_id": 13051,
"author_profile": "https://Stackoverflow.com/users/13051",
"pm_score": 3,
"selected": false,
"text": "$ gcc -fdiagnostics-show-option foo.c -Wall -o foo\nfoo.c: In function ‘main’:\nfoo.c:3: warning: unused variable ‘x’ [-Wunused-variable]\nfoo.c:4: warning: control reaches end of non-void function\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220855",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29857/"
] |
220,867
|
<p>What is the best way to deal with XML documents, XSD etc in C# 2.0? </p>
<p>Which classes to use etc. What are the best practices of parsing and making XML documents etc. </p>
<p>EDIT: .Net 3.5 suggestions are also welcome.</p>
|
[
{
"answer_id": 220981,
"author": "nyxtom",
"author_id": 19753,
"author_profile": "https://Stackoverflow.com/users/19753",
"pm_score": 9,
"selected": true,
"text": "XmlDocument document = new XmlDocument();\ndocument.LoadXml(\"<People><Person Name='Nick' /><Person Name='Joe' /></People>\");\n XmlDocument document = new XmlDocument();\ndocument.Load(@\"C:\\Path\\To\\xmldoc.xml\");\n// Or using an XmlReader/XmlTextReader\nXmlReader reader = XmlReader.Create(@\"C:\\Path\\To\\xmldoc.xml\");\ndocument.Load(reader);\n XmlDocument document = new XmlDocument();\ndocument.LoadXml(\"<People><Person Name='Nick' /><Person Name='Joe' /></People>\");\n\n// Select a single node\nXmlNode node = document.SelectSingleNode(\"/People/Person[@Name = 'Nick']\");\n\n// Select a list of nodes\nXmlNodeList nodes = document.SelectNodes(\"/People/Person\");\n XmlReaderSettings settings = new XmlReaderSettings();\nsettings.ValidateType = ValidationType.Schema;\nsettings.Schemas.Add(\"\", pathToXsd); // targetNamespace, pathToXsd\n\nXmlReader reader = XmlReader.Create(pathToXml, settings);\nXmlDocument document = new XmlDocument();\n\ntry {\n document.Load(reader);\n} catch (XmlSchemaValidationException ex) { Trace.WriteLine(ex.Message); }\n XmlReaderSettings settings = new XmlReaderSettings();\nsettings.ValidateType = ValidationType.Schema;\nsettings.Schemas.Add(\"\", pathToXsd); // targetNamespace, pathToXsd\nsettings.ValidationEventHandler += new ValidationEventHandler(settings_ValidationEventHandler);\n\nXmlReader reader = XmlReader.Create(pathToXml, settings);\nwhile (reader.Read()) { }\n\nprivate void settings_ValidationEventHandler(object sender, ValidationEventArgs args)\n{\n // e.Message, e.Severity (warning, error), e.Error\n // or you can access the reader if you have access to it\n // reader.LineNumber, reader.LinePosition.. etc\n}\n XmlWriter writer = XmlWriter.Create(pathToOutput);\nwriter.WriteStartDocument();\nwriter.WriteStartElement(\"People\");\n\nwriter.WriteStartElement(\"Person\");\nwriter.WriteAttributeString(\"Name\", \"Nick\");\nwriter.WriteEndElement();\n\nwriter.WriteStartElement(\"Person\");\nwriter.WriteStartAttribute(\"Name\");\nwriter.WriteValue(\"Nick\");\nwriter.WriteEndAttribute();\nwriter.WriteEndElement();\n\nwriter.WriteEndElement();\nwriter.WriteEndDocument();\n\nwriter.Flush();\n XDocument doc = XDocument.Load(pathToXml);\n List<Person> people = (from xnode in doc.Element(\"People\").Elements(\"Person\")\n select new Person\n {\n Name = xnode.Attribute(\"Name\").Value\n }).ToList();\n XDocument doc =\n new XDocument(\n new XDeclaration(\"1.0\", Encoding.UTF8.HeaderName, String.Empty),\n new XComment(\"Xml Document\"),\n new XElement(\"catalog\",\n new XElement(\"book\", new XAttribute(\"id\", \"bk001\"),\n new XElement(\"title\", \"Book Title\")\n )\n )\n );\n <!--Xml Document-->\n<catalog>\n <book id=\"bk001\">\n <title>Book Title</title>\n </book>\n</catalog>\n"
},
{
"answer_id": 223014,
"author": "Robert Rossney",
"author_id": 19403,
"author_profile": "https://Stackoverflow.com/users/19403",
"pm_score": 4,
"selected": false,
"text": "XPathDocument XmlDocument XPathDocument SelectNodes SelectSingleNode XmlNode IXPathNavigable CreateNavigator XPathNavigator XPathNavigator XPathNodeIterator XmlDocument XmlDocument XmlNode IXPathNavigable XPathDocument XmlDocument IXPathNavigable XmlNode XmlDocument XDocument XElement XNode XObject IXPathNavigable XmlReader XmlReader XmlReader XmlReader XmlReader XmlReader"
},
{
"answer_id": 4837444,
"author": "mokumaxCraig",
"author_id": 572807,
"author_profile": "https://Stackoverflow.com/users/572807",
"pm_score": 0,
"selected": false,
"text": "XDocument **doc** = XDocument.Load(pathToXml);\nList<Person> people = (from xnode in **xdoc**.Element(\"People\").Elements(\"Person\")\n select new Person\n {\n Name = xnode.Attribute(\"Name\").Value\n }).ToList();\n"
},
{
"answer_id": 35289396,
"author": "Anil Rathod",
"author_id": 1078684,
"author_profile": "https://Stackoverflow.com/users/1078684",
"pm_score": 2,
"selected": false,
"text": "//itemValues is collection of items in Key value pair format\n//fileName i name of XML file which to creatd or modified with content\n private void WriteInXMLFile(System.Collections.Generic.Dictionary<string, object> itemValues, string fileName)\n {\n string filePath = \"C:\\\\\\\\tempXML\\\\\" + fileName + \".xml\";\n try\n {\n\n if (System.IO.File.Exists(filePath))\n {\n XmlDocument doc = new XmlDocument();\n doc.Load(filePath); \n\n XmlNode rootNode = doc.SelectSingleNode(\"Documents\");\n\n XmlNode pageNode = doc.CreateElement(\"Document\");\n rootNode.AppendChild(pageNode);\n\n\n foreach (string key in itemValues.Keys)\n {\n\n XmlNode attrNode = doc.CreateElement(key);\n attrNode.InnerText = Convert.ToString(itemValues[key]);\n pageNode.AppendChild(attrNode);\n //doc.DocumentElement.AppendChild(attrNode);\n\n }\n doc.DocumentElement.AppendChild(pageNode);\n doc.Save(filePath);\n }\n else\n {\n XmlDocument doc = new XmlDocument();\n using(System.IO.FileStream fs = System.IO.File.Create(filePath))\n {\n //Do nothing\n }\n\n XmlNode rootNode = doc.CreateElement(\"Documents\");\n doc.AppendChild(rootNode);\n doc.Save(filePath);\n\n doc.Load(filePath);\n\n XmlNode pageNode = doc.CreateElement(\"Document\");\n rootNode.AppendChild(pageNode);\n\n foreach (string key in itemValues.Keys)\n { \n XmlNode attrNode = doc.CreateElement(key); \n attrNode.InnerText = Convert.ToString(itemValues[key]);\n pageNode.AppendChild(attrNode);\n //doc.DocumentElement.AppendChild(attrNode);\n\n }\n doc.DocumentElement.AppendChild(pageNode);\n\n doc.Save(filePath);\n\n }\n }\n catch (Exception ex)\n {\n\n }\n\n }\n\nOutPut look like below\n<Dcouments>\n <Document>\n <DocID>01<DocID>\n <PageName>121<PageName>\n <Author>Mr. ABC<Author>\n <Dcoument>\n <Document>\n <DocID>02<DocID>\n <PageName>122<PageName>\n <Author>Mr. PQR<Author>\n <Dcoument>\n</Dcouments>\n"
},
{
"answer_id": 52056636,
"author": "Michael Hutter",
"author_id": 9134997,
"author_profile": "https://Stackoverflow.com/users/9134997",
"pm_score": 0,
"selected": false,
"text": "XmlNode XNode XElement public static class MyExtensions\n{\n public static XNode GetXNode(this XmlNode node)\n {\n return GetXElement(node);\n }\n\n public static XElement GetXElement(this XmlNode node)\n {\n XDocument xDoc = new XDocument();\n using (XmlWriter xmlWriter = xDoc.CreateWriter())\n node.WriteTo(xmlWriter);\n return xDoc.Root;\n }\n\n public static XmlNode GetXmlNode(this XElement element)\n {\n using (XmlReader xmlReader = element.CreateReader())\n {\n XmlDocument xmlDoc = new XmlDocument();\n xmlDoc.Load(xmlReader);\n return xmlDoc;\n }\n }\n\n public static XmlNode GetXmlNode(this XNode node)\n {\n return GetXmlNode(node);\n }\n}\n XmlDocument MyXmlDocument = new XmlDocument();\nMyXmlDocument.Load(\"MyXml.xml\");\nXElement MyXElement = MyXmlDocument.GetXElement(); // Convert XmlNode to XElement\nList<XElement> List = MyXElement.Document\n .Descendants()\n .ToList(); // Now you can use LINQ\n...\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1688440/"
] |
220,872
|
<p>Just wondering if anyone has seen any usable progress bar for C# .net apps. My app takes about 20-60 secs to load and I would love to show users a progress bar while they wait. I saw <a href="http://www.codeproject.com/KB/aspnet/ASPNETAJAXPageLoader.aspx" rel="nofollow noreferrer">this one</a> but the sample site doesn't seem to work which doesn't inspire confidence.</p>
|
[
{
"answer_id": 223796,
"author": "Dhaust",
"author_id": 242,
"author_profile": "https://Stackoverflow.com/users/242",
"pm_score": 3,
"selected": true,
"text": "<asp:ScriptManager ID=\"ScriptManager1\" runat=\"server\" />\n <asp:UpdateProgress runat=\"server\" id=\"PageUpdateProgress\">\n <ProgressTemplate>\n Loading...\n </ProgressTemplate>\n </asp:UpdateProgress>\n <asp:UpdatePanel runat=\"server\" id=\"Panel\">\n <ContentTemplate>\n <asp:Button runat=\"server\" id=\"UpdateButton\" onclick=\"UpdateButton_Click\" text=\"Update\" />\n </ContentTemplate>\n </asp:UpdatePanel>\n"
},
{
"answer_id": 12418314,
"author": "nikinup",
"author_id": 1256450,
"author_profile": "https://Stackoverflow.com/users/1256450",
"pm_score": 1,
"selected": false,
"text": "<asp:Panel ID=\"ProgressIndicatorPanel\" runat=\"server\" Style=\"display: none\" CssClass=\"modalPopup\">\n <div id=\"ProgressDiv\" class=\"progressStyle\">\n <ul class=\"ProgressStyleTable\" style=\"list-style:none;height:60px\">\n <li style=\"position:static;float:left;margin-top:0.5em;margin-left:0.5em\">\n <asp:Image ID=\"ProgressImage\" runat=\"server\" SkinID=\"ProgressImage\" />\n </li>\n <li style=\"position:static;float:left;margin-top:0.5em;margin-left:0.5em;margin-right:0.5em\">\n <span id=\"ProgressTextTableCell\"> Loading, please wait... </span>\n </li>\n </ul>\n </div>\n </asp:Panel>\n var ProgressIndicator = function (progPrefix) {\n var divId = 'ProgressDiv';\n var textId = 'ProgressTextTableCell';\n var progressCss = \"progressStyle\";\n\n if (progPrefix != null) {\n divId = progPrefix + divId;\n textId = progPrefix + textId;\n }\n\n this.Start = function (textString) {\n if (textString) {\n $('#' + textId).text(textString);\n }\n else {\n $('#' + textId).text('Loading, please wait...');\n }\n this.Center();\n //$('#' + divId).show();\n var modalPopupBehavior = $find('ProgressModalPopupBehaviour');\n if (modalPopupBehavior != null) modalPopupBehavior.show();\n }\n\n this.Center = function () {\n var viewportWidth = jQuery(window).width();\n var viewportHeight = jQuery(window).height();\n var progressDiv = $(\"#\" + divId);\n var elWidth = progressDiv.width();\n var elHeight = progressDiv.height();\n progressDiv.css({ top: ((viewportHeight / 2) - (elHeight / 2)) + $(window).scrollTop(),\n left: ((viewportWidth / 2) - (elWidth / 2)) + $(window).scrollLeft(), visibility: 'visible'\n });\n }\n\n this.Stop = function () {\n //$(\"#\" + divId).hide();\n var modalPopupBehavior = $find('ProgressModalPopupBehaviour');\n if (modalPopupBehavior != null) modalPopupBehavior.hide();\n }\n};\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5234/"
] |
220,878
|
<p>Slashdot's RSS feed is <a href="http://rss.slashdot.org/Slashdot/slashdot" rel="nofollow noreferrer">http://rss.slashdot.org/Slashdot/slashdot</a>. If I download the XML file directly, I only get a few of the posts from today. However, if I subscribe to the feed in Google Reader, and keep scrolling down in their "infinite scroll" interface, it seems like I can get an arbitrary number of Slashdot posts from the past - maybe I can get every Slashdot post ever?</p>
<ol>
<li>How does Google Reader retrieve an unlimited number of posts from an RSS feed?</li>
<li>How can I do the same?</li>
</ol>
|
[
{
"answer_id": 43125793,
"author": "wle8300",
"author_id": 1775026,
"author_profile": "https://Stackoverflow.com/users/1775026",
"pm_score": 1,
"selected": false,
"text": "https://pub.center/feed/02702624d8a4c825dde21af94e9169773454e0c3/articles?limit=10&page=1 https://pub.center/feed/02702624d8a4c825dde21af94e9169773454e0c3/articles?limit=10&page=2"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25068/"
] |
220,879
|
<p>I don't need this, obviously; I'm just curious about what's going on here. Am I missing
something simple? Can I rely on this behaviour in all versions of Perl?)</p>
<p>Perl v5.8.8:</p>
<pre><code>%h = ( 0=>'zero', 1=>'one', 2=>'two' );
while ($k = each %h) {
$v = delete $h{$k};
print "deleted $v; remaining: @h{0..2}\n";
}
</code></pre>
<p>outputs</p>
<pre><code>deleted one; remaining: zero two
deleted zero; remaining: two
deleted two; remaining:
</code></pre>
<p><code>man perlfunc</code> (each) does not explain why the
while loop continues when <code>$k</code> is assigned 0.
The code behaves as if the condition on the <code>while</code> loop
were <code>($k = each %h, defined $k)</code>.</p>
<p>If the loop condition is actually changed to
<code>($k = each %h, $k)</code> then it does indeed
stop at <code>$k = 0</code> as expected.</p>
<p>It also stops at <code>$k = 0</code> for the following
reimplementation of <code>each</code>:</p>
<pre><code>%h = ( 0=>'zero', 1=>'one', 2=>'two' );
sub each2 {
return each %{$_[0]};
}
while ($k = each2 \%h) {
$v = delete $h{$k};
print "deleted $v; remaining: @h{0..2}\n";
}
</code></pre>
<p>outputs just:</p>
<pre><code>deleted one; remaining: zero two
</code></pre>
|
[
{
"answer_id": 220999,
"author": "cjm",
"author_id": 8355,
"author_profile": "https://Stackoverflow.com/users/8355",
"pm_score": 5,
"selected": false,
"text": "each while ($line = <FILE>)\n defined while ($key = each %hash)\n case OP_SASSIGN:\n if (k1->op_type == OP_READDIR\n || k1->op_type == OP_GLOB\n || (k1->op_type == OP_NULL && k1->op_targ == OP_GLOB)\n || k1->op_type == OP_EACH)\n expr = newUNOP(OP_DEFINED, 0, expr);\n break;\n <FILE> each"
},
{
"answer_id": 222764,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "defined"
},
{
"answer_id": 223337,
"author": "Schwern",
"author_id": 14660,
"author_profile": "https://Stackoverflow.com/users/14660",
"pm_score": 3,
"selected": false,
"text": "$ perl -MO=Deparse,p your_example.plx\n(%h) = (0, 'zero', 1, 'one', 2, 'two');\nwhile (defined($k = each %h)) {\n $v = delete $h{$k};\n print \"deleted $v; remaining: @h{0..2}\\n\";\n}\nyour_example.plx syntax OK\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
220,887
|
<p>In Ruby I have often written a number of small classes, and had a main class organize the little guys to get work done. I do this by writing </p>
<pre><code>require "converter.rb"
require "screenFixer.rb"
.
.
.
</code></pre>
<p>at the top of the main class. How do I do this in Java? Is it "import?"</p>
<p>Also, could someone please come up with a better title for this question?</p>
|
[
{
"answer_id": 220904,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "\npublic class Example {\n public Example(IConverter converter, IScreenFixer screenFixer) {\n\n }\n}\n\n"
},
{
"answer_id": 220921,
"author": "Feet",
"author_id": 18340,
"author_profile": "https://Stackoverflow.com/users/18340",
"pm_score": 4,
"selected": true,
"text": "package com.boo;\n\nimport com.foo.Bar;\n\npublic class StackOverflow {\n\nprivate Bar myBar;\n\n}\n"
},
{
"answer_id": 220925,
"author": "Alexander K",
"author_id": 17592,
"author_profile": "https://Stackoverflow.com/users/17592",
"pm_score": 1,
"selected": false,
"text": "javac file1.java file2.java file3.java\njava file1\n"
},
{
"answer_id": 221167,
"author": "miceuz",
"author_id": 24443,
"author_profile": "https://Stackoverflow.com/users/24443",
"pm_score": 1,
"selected": false,
"text": "package com.foo;\nimport com.foo.Bar;\n\npublic class StackOverflow {\n\nprivate Bar myBar;\n public StackOverflow() { //this is a constructor of StackOverflow class\n myBar = new Bar(); //i'm invoking constructor of Bar class\n }\n}\n"
},
{
"answer_id": 221312,
"author": "Vincent Ramdhanie",
"author_id": 27439,
"author_profile": "https://Stackoverflow.com/users/27439",
"pm_score": 1,
"selected": false,
"text": "import package.ClasName;\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29182/"
] |
220,891
|
<p>I have a COM SDK written in C++ and I'd like to create documentation for my product. I understand that most people will probably not use C++ for integration with this COM component, but many will. </p>
<p>Which method is best to describe the API, without losing details that a C++ developer would need to know. </p>
|
[
{
"answer_id": 220904,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "\npublic class Example {\n public Example(IConverter converter, IScreenFixer screenFixer) {\n\n }\n}\n\n"
},
{
"answer_id": 220921,
"author": "Feet",
"author_id": 18340,
"author_profile": "https://Stackoverflow.com/users/18340",
"pm_score": 4,
"selected": true,
"text": "package com.boo;\n\nimport com.foo.Bar;\n\npublic class StackOverflow {\n\nprivate Bar myBar;\n\n}\n"
},
{
"answer_id": 220925,
"author": "Alexander K",
"author_id": 17592,
"author_profile": "https://Stackoverflow.com/users/17592",
"pm_score": 1,
"selected": false,
"text": "javac file1.java file2.java file3.java\njava file1\n"
},
{
"answer_id": 221167,
"author": "miceuz",
"author_id": 24443,
"author_profile": "https://Stackoverflow.com/users/24443",
"pm_score": 1,
"selected": false,
"text": "package com.foo;\nimport com.foo.Bar;\n\npublic class StackOverflow {\n\nprivate Bar myBar;\n public StackOverflow() { //this is a constructor of StackOverflow class\n myBar = new Bar(); //i'm invoking constructor of Bar class\n }\n}\n"
},
{
"answer_id": 221312,
"author": "Vincent Ramdhanie",
"author_id": 27439,
"author_profile": "https://Stackoverflow.com/users/27439",
"pm_score": 1,
"selected": false,
"text": "import package.ClasName;\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3153/"
] |
220,902
|
<p>I'm building a python application from some source code I've found <a href="http://code.google.com/p/enso" rel="nofollow noreferrer">Here</a></p>
<p>I've managed to compile and fix some problems by searching the web, but I'm stuck at this point:</p>
<p>When running the application this message appears.</p>
<p><a href="http://img511.imageshack.us/img511/4481/loadfr0.png" rel="nofollow noreferrer">alt text http://img511.imageshack.us/img511/4481/loadfr0.png</a></p>
<p>This python app, usues swig to link to c/c++ code.</p>
<p>I have VC++2005 express edition which I used to compile along with scons
and Python 2.5 ( and tried 2.4 too ) </p>
<p>The dlls that are attempting to load is "msvcr80.dll" because before the message was "msvcr80.dll" cannot be found or something like that, so I got it and drop it in window32 folder.</p>
<p>For what I've read in here:
<a href="http://msdn.microsoft.com/en-us/library/ms235591(VS.80).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms235591(VS.80).aspx</a></p>
<p>The solution is to run MT with the manifest and the dll file. I did it already and doesn't work either.</p>
<p>Could anyone point me to the correct direction?</p>
<p>This is the content of the manifest fie:</p>
<pre><code><?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
</dependentAssembly>
</dependency>
</assembly>
</code></pre>
<p>I'm going to try Python 2.6 now, I'm not quite sure of understanding the problem, but Python 2.5 and Python 2.5 .exe had the string "MSVCR71.dll" inside the .exe file. But probably this has nothing to do.</p>
<p>ps. if only everything was as easy as jar files :( </p>
<p>This is the stack trace for completeness</p>
<pre><code>None
INFO:root:Skipping provider enso.platform.osx.
INFO:root:Skipping provider enso.platform.linux.
INFO:root:Added provider enso.platform.win32.
Traceback (most recent call last):
File "scripts\run_enso.py", line 24, in <module>
enso.run()
File "C:\oreyes\apps\enso\enso-read-only\enso\__init__.py", line 40, in run
from enso.events import EventManager
File "C:\oreyes\apps\enso\enso-read-only\enso\events.py", line 60, in <module>
from enso import input
File "C:\oreyes\apps\enso\enso-read-only\enso\input\__init__.py", line 3, in <module>
_input = enso.providers.getInterface( "input" )
File "C:\oreyes\apps\enso\enso-read-only\enso\providers.py", line 137, in getInterface
interface = provider.provideInterface( name )
File "C:\oreyes\apps\enso\enso-read-only\enso\platform\win32\__init__.py", line 48, in provideInterface
import enso.platform.win32.input
File "C:\oreyes\apps\enso\enso-read-only\enso\platform\win32\input\__init__.py", line 3, in <module>
from InputManager import *
File "C:\oreyes\apps\enso\enso-read-only\enso\platform\win32\input\InputManager.py", line 7, in <module>
import _InputManager
ImportError: DLL load failed: Error en una rutina de inicializaci¾n de biblioteca de vÝnculos dinßmicos (DLL).
</code></pre>
|
[
{
"answer_id": 221200,
"author": "OscarRyz",
"author_id": 20654,
"author_profile": "https://Stackoverflow.com/users/20654",
"pm_score": 0,
"selected": false,
"text": "INFO:root:Skipping provider enso.platform.osx.\nINFO:root:Skipping provider enso.platform.linux.\nINFO:root:Added provider enso.platform.win32.\nINFO:root:Obtained interface 'input' from provider 'enso.platform.win32'.\nTraceback (most recent call last):\n File \"scripts\\run_enso.py\", line 23, in <module>\n enso.run()\n File \"C:\\oreyes\\apps\\enso\\enso-comunity\\enso\\__init__.py\", line 41, in run\n from enso.quasimode import Quasimode\n File \"C:\\oreyes\\apps\\enso\\enso-comunity\\enso\\quasimode\\__init__.py\", line 62, in <module>\n from enso.quasimode.window import TheQuasimodeWindow\n File \"C:\\oreyes\\apps\\enso\\enso-comunity\\enso\\quasimode\\window.py\", line 65, in <module>\n from enso.quasimode.linewindows import TextWindow\n File \"C:\\oreyes\\apps\\enso\\enso-comunity\\enso\\quasimode\\linewindows.py\", line 44, in <module>\n from enso import cairo\n File \"C:\\oreyes\\apps\\enso\\enso-comunity\\enso\\cairo.py\", line 3, in <module>\n __cairoImpl = enso.providers.getInterface( \"cairo\" )\n File \"C:\\oreyes\\apps\\enso\\enso-comunity\\enso\\providers.py\", line 137, in getInterface\n interface = provider.provideInterface( name )\n File \"C:\\oreyes\\apps\\enso\\enso-comunity\\enso\\platform\\win32\\__init__.py\", line 61, in provideInterface\n import enso.platform.win32.cairo\n File \"C:\\oreyes\\apps\\enso\\enso-comunity\\enso\\platform\\win32\\cairo\\__init__.py\", line 1, in <module>\n from _cairo import *\nImportError: No module named _cairo\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220902",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20654/"
] |
220,906
|
<p>I am writing one web chat program using AJAX (a little bit). It is working when both users open a chat page, but I want to open a window when one user send data to others.</p>
|
[
{
"answer_id": 221119,
"author": "jeff porter",
"author_id": 26778,
"author_profile": "https://Stackoverflow.com/users/26778",
"pm_score": 0,
"selected": false,
"text": "winRef = window.open( URL, name [ , features [, replace ] ] )\n"
},
{
"answer_id": 13311866,
"author": "Joshua",
"author_id": 1539065,
"author_profile": "https://Stackoverflow.com/users/1539065",
"pm_score": 1,
"selected": false,
"text": "window.open(url)"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
220,907
|
<p>How does reverse proxy server work? Is it used to secure the main server? Is it used as a firewall? What are the reasons for using a proxy server? Could someone give a real world example?</p>
|
[
{
"answer_id": 220991,
"author": "splattne",
"author_id": 6461,
"author_profile": "https://Stackoverflow.com/users/6461",
"pm_score": 2,
"selected": false,
"text": "RewriteRule ^(.*) http://www.testsiteXY.com$1 [P]\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220907",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
220,966
|
<p>I have a 2 variable 100x100 data table in excel.</p>
<p>I need to have a function that returns all the possible sets of variables that yield a given target value.
What I am looking at is some kind of a reursive 2 dimensional lookup function. Can someone point me in the right direction?</p>
|
[
{
"answer_id": 221395,
"author": "Vaibhav Garg",
"author_id": 27795,
"author_profile": "https://Stackoverflow.com/users/27795",
"pm_score": 0,
"selected": false,
"text": "Dim arr As Range\nDim tempval As Range\nDim op As Integer\n\nSet arr = Worksheets(\"sheet1\").Range(\"b2:ao41\")\nop = 1\nRange(\"B53:D153\").ClearContents\n\n\n\n\n\nFor Each tempval In arr\nIf Round(tempval.Value, 0) = Round(Range(\"b50\").Value, 0) Then\n\nRange(\"b52\").Offset(op, 0).Value = Range(\"a\" & tempval.Row).Value\nRange(\"b52\").Offset(op, 1).Value = Cells(tempval.Column, 1).Value\nRange(\"b52\").Offset(op, 2).Value = tempval.Value\nop = op + 1\n\nEnd If\n\nNext\nRange(\"b50\").Select\n"
},
{
"answer_id": 221812,
"author": "dbb",
"author_id": 25675,
"author_profile": "https://Stackoverflow.com/users/25675",
"pm_score": 2,
"selected": true,
"text": " B104=MAX(($A$2:$A$101*100+$B$1:$CW$1<B103)*($B$2:$CW$101=TargetValue)*($A$2:$A$101*100+$B$1:$CW$1))\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27795/"
] |
220,975
|
<p>How to put underline for first letter for access key for ?</p>
|
[
{
"answer_id": 220985,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 0,
"selected": false,
"text": "<asp:button id=\"Button1\" runat=\"server\" Text=\"Print\" AccessKey=\"P\" />\n"
},
{
"answer_id": 221022,
"author": "Rob Bell",
"author_id": 2179408,
"author_profile": "https://Stackoverflow.com/users/2179408",
"pm_score": 2,
"selected": false,
"text": "<button id=\"mybutton\" runat=\"server\" onserverclick=\"myfunction\">\n<span style=\"text-decoration:underline;\">P</span>rint</button>\n protected void myfunction(object sender, EventArgs e)\n{\n Response.Write(\"clicked\");\n}\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/220975",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29867/"
] |
221,001
|
<p>I want to convert from char representing a hexadecimal value (in upper or lower case) to byte, like</p>
<pre><code>'0'->0, '1' -> 1, 'A' -> 10, 'a' -> 10, 'f' -> 15 etc...
</code></pre>
<p>I will be calling this method extremely often, so performance is important. Is there a faster way than to use a pre-initialized <code>HashMap<Character,Byte></code> to get the value from?</p>
<p><strong>Answer</strong></p>
<p>It seems like <s>it's a tossup between using a switch-case and Jon Skeet's direct computing solution - the switch-case solution seems to edge out ever so slightly, though.</s> Greg's array method wins out. Here are the performance results (in ms) for 200,000,000 runs of the various methods:</p>
<pre><code>Character.getNumericValue:
8360
Character.digit:
8453
HashMap<Character,Byte>:
15109
Greg's Array Method:
6656
JonSkeet's Direct Method:
7344
Switch:
7281
</code></pre>
<p>Thanks guys!</p>
<p><strong>Benchmark method code</strong></p>
<p>Here ya go, JonSkeet, you old competitor. ;-)</p>
<pre><code>public class ScratchPad {
private static final int NUMBER_OF_RUNS = 200000000;
static byte res;
static HashMap<Character, Byte> map = new HashMap<Character, Byte>() {{
put( Character.valueOf( '0' ), Byte.valueOf( (byte )0 ));
put( Character.valueOf( '1' ), Byte.valueOf( (byte )1 ));
put( Character.valueOf( '2' ), Byte.valueOf( (byte )2 ));
put( Character.valueOf( '3' ), Byte.valueOf( (byte )3 ));
put( Character.valueOf( '4' ), Byte.valueOf( (byte )4 ));
put( Character.valueOf( '5' ), Byte.valueOf( (byte )5 ));
put( Character.valueOf( '6' ), Byte.valueOf( (byte )6 ));
put( Character.valueOf( '7' ), Byte.valueOf( (byte )7 ));
put( Character.valueOf( '8' ), Byte.valueOf( (byte )8 ));
put( Character.valueOf( '9' ), Byte.valueOf( (byte )9 ));
put( Character.valueOf( 'a' ), Byte.valueOf( (byte )10 ));
put( Character.valueOf( 'b' ), Byte.valueOf( (byte )11 ));
put( Character.valueOf( 'c' ), Byte.valueOf( (byte )12 ));
put( Character.valueOf( 'd' ), Byte.valueOf( (byte )13 ));
put( Character.valueOf( 'e' ), Byte.valueOf( (byte )14 ));
put( Character.valueOf( 'f' ), Byte.valueOf( (byte )15 ));
put( Character.valueOf( 'A' ), Byte.valueOf( (byte )10 ));
put( Character.valueOf( 'B' ), Byte.valueOf( (byte )11 ));
put( Character.valueOf( 'C' ), Byte.valueOf( (byte )12 ));
put( Character.valueOf( 'D' ), Byte.valueOf( (byte )13 ));
put( Character.valueOf( 'E' ), Byte.valueOf( (byte )14 ));
put( Character.valueOf( 'F' ), Byte.valueOf( (byte )15 ));
}};
static int[] charValues = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10, 11, 12, 13,14,15};
static char[] cs = new char[]{'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','A','B','C','D','E','F'};
public static void main(String args[]) throws Exception {
long time = System.currentTimeMillis();
for( int i = 0; i < NUMBER_OF_RUNS; i++ ) {
res = getNumericValue( i );
}
System.out.println( "Character.getNumericValue:" );
System.out.println( System.currentTimeMillis()-time );
time = System.currentTimeMillis();
for( int i = 0; i < NUMBER_OF_RUNS; i++ ) {
res = getDigit( i );
}
System.out.println( "Character.digit:" );
System.out.println( System.currentTimeMillis()-time );
time = System.currentTimeMillis();
for( int i = 0; i < NUMBER_OF_RUNS; i++ ) {
try {
res = getValueFromArray( i );
} catch (IllegalArgumentException e) {
}
}
System.out.println( "Array:" );
System.out.println( System.currentTimeMillis()-time );
time = System.currentTimeMillis();
for( int i = 0; i < NUMBER_OF_RUNS; i++ ) {
res = getValueFromHashMap( i );
}
System.out.println( "HashMap<Character,Byte>:" );
System.out.println( System.currentTimeMillis()-time );
time = System.currentTimeMillis();
for( int i = 0; i < NUMBER_OF_RUNS; i++ ) {
char c = cs[i%cs.length];
res = getValueFromComputeMethod( c );
}
System.out.println( "JonSkeet's Direct Method:" );
System.out.println( System.currentTimeMillis()-time );
time = System.currentTimeMillis();
for( int i = 0; i < NUMBER_OF_RUNS; i++ ) {
res = getValueFromSwitch( i );
}
System.out.println( "Switch:" );
System.out.println( System.currentTimeMillis()-time );
}
private static byte getValueFromSwitch( int i ) {
byte res;
char ch = cs[i%cs.length];
switch( ch ) {
case '0':
res = 0;
break;
case '1':
res = 1;
break;
case '2':
res = 2;
break;
case '3':
res = 3;
break;
case '4':
res = 4;
break;
case '5':
res = 5;
break;
case '6':
res = 6;
break;
case '7':
res = 7;
break;
case '8':
res = 8;
break;
case '9':
res = 9;
break;
case 'a':
case 'A':
res = 10;
break;
case 'b':
case 'B':
res = 11;
break;
case 'c':
case 'C':
res = 12;
break;
case 'd':
case 'D':
res = 13;
break;
case 'e':
case 'E':
res = 14;
break;
case 'f':
case 'F':
res = 15;
break;
default:
throw new RuntimeException("unknown hex character: " + ch );
}
return res;
}
private static byte getValueFromComputeMethod( char c ) {
byte result = 0;
if (c >= '0' && c <= '9')
{
result = (byte)(c - '0');
}
if (c >= 'a' && c <= 'f')
{
result = (byte)(c - 'a' + 10);
}
if (c >= 'A' && c <= 'F')
{
result = (byte)(c - 'A' + 10);
}
return result;
}
private static byte getValueFromHashMap( int i ) {
return map.get( Character.valueOf( cs[i%cs.length] ) ).byteValue();
}
private static byte getValueFromArray( int i ) {
char c = cs[i%cs.length];
if (c < '0' || c > 'f') {
throw new IllegalArgumentException();
}
byte result = (byte)charValues[c-'0'];
if (res < 0) {
throw new IllegalArgumentException();
}
return result;
}
private static byte getDigit( int i ) {
return (byte)Character.digit( cs[i%cs.length], 16 );
}
private static byte getNumericValue( int i ) {
return (byte)Character.getNumericValue( cs[i%cs.length] );
}
}
</code></pre>
|
[
{
"answer_id": 221012,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": false,
"text": "if (c >= '0' && c <= '9')\n{\n return c - '0';\n}\nif (c >= 'a' && c <= 'f')\n{\n return c - 'a' + 10;\n}\nif (c >= 'A' && c <= 'F')\n{\n return c - 'A' + 10;\n}\nthrow new IllegalArgumentException();\n"
},
{
"answer_id": 221020,
"author": "Keeg",
"author_id": 21059,
"author_profile": "https://Stackoverflow.com/users/21059",
"pm_score": 2,
"selected": false,
"text": "char c = 'a';\nSystem.out.println(c + \"->\" + Character.getNumericValue(c));\n"
},
{
"answer_id": 221024,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 5,
"selected": true,
"text": "int CharValues['f'-'0'+1] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, ... -1, 10, 11, 12, ...};\n\nif (c < '0' || c > 'f') {\n throw new IllegalArgumentException();\n}\nint n = CharValues[c-'0'];\nif (n < 0) {\n throw new IllegalArgumentException();\n}\n// n contains the digit value\n"
},
{
"answer_id": 221071,
"author": "Arne Burmeister",
"author_id": 12890,
"author_profile": "https://Stackoverflow.com/users/12890",
"pm_score": 2,
"selected": false,
"text": "int i = Integer.parseInt(String.ValueOf(c), 16);\n int i = Character.digit(c, 16);\n"
},
{
"answer_id": 221111,
"author": "Staale",
"author_id": 3355,
"author_profile": "https://Stackoverflow.com/users/3355",
"pm_score": 2,
"selected": false,
"text": "static final int[] precalc = new int['f'+1];\nstatic {\n for (char c='0'; c<='9'; c++) precalc[c] = c-'0';\n for (char c='A'; c<='F'; c++) precalc[c] = c-'A';\n for (char c='a'; c<='f'; c++) precalc[c] = c-'a';\n}\n\nSystem.out.println(precalc['f']);\n"
},
{
"answer_id": 221134,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "public class HexParser\n{\n private static final byte VALUES = new int['f'];\n\n // Easier to get right for bozos like me (Jon) than\n // a hard-coded array :)\n static\n {\n for (int i=0; i < VALUES.length; i++)\n {\n VALUES[i] = (byte) -1;\n }\n for (int i='0'; i <= '9'; i++)\n {\n VALUES[i] = (byte) i-'0';\n }\n for (int i='A'; i <= 'F'; i++)\n {\n VALUES[i] = (byte) (i-'A'+10);\n }\n for (int i='a'; i <= 'f'; i++)\n {\n VALUES[i] = (byte) (i-'a'+10);\n }\n }\n\n public static byte parseHexChar(char c)\n {\n if (c > 'f')\n {\n throw new IllegalArgumentException();\n }\n byte ret = VALUES[c];\n if (ret == -1)\n {\n throw new IllegalArgumentException();\n }\n return ret;\n }\n}\n"
},
{
"answer_id": 379653,
"author": "pro",
"author_id": 352728,
"author_profile": "https://Stackoverflow.com/users/352728",
"pm_score": 2,
"selected": false,
"text": "int CharValues[256] = \n{\n16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,\n16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,0,1,2,3,4,5,6,7,8,9,16,16,16,16,16,16,16,\n16,10,11,12,13,14,15,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,\n16,10,11,12,13,14,15,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,\n16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,\n16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,\n16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,\n16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16\n}\n\nint n = CharValues[c];\n\nif (n == 16)\n throw new IllegalArgumentException();\n\n// n contains the digit value\n"
},
{
"answer_id": 798803,
"author": "Adam Davis",
"author_id": 2915,
"author_profile": "https://Stackoverflow.com/users/2915",
"pm_score": 3,
"selected": false,
"text": "(char | 32) % 39 - 9\n"
},
{
"answer_id": 799734,
"author": "Peter Lawrey",
"author_id": 57695,
"author_profile": "https://Stackoverflow.com/users/57695",
"pm_score": 2,
"selected": false,
"text": "private static byte lookUpTest(int i) {\n return (byte) cs[i%cs.length];\n}\n"
},
{
"answer_id": 17894129,
"author": "mauricio_martins",
"author_id": 2517201,
"author_profile": "https://Stackoverflow.com/users/2517201",
"pm_score": 2,
"selected": false,
"text": "c|=0x20;\nreturn c<='9'? c+0xD0 : c+0xA9;\n"
},
{
"answer_id": 17894227,
"author": "user207421",
"author_id": 207421,
"author_profile": "https://Stackoverflow.com/users/207421",
"pm_score": 1,
"selected": false,
"text": "x[Integer.toHexString(i).charAt[0]] = i 0 <= i < 256 x[c] c"
},
{
"answer_id": 56837705,
"author": "Florian F",
"author_id": 3450840,
"author_profile": "https://Stackoverflow.com/users/3450840",
"pm_score": 1,
"selected": false,
"text": "public static int hex2Dig2(char c) {\n if (c < 'A') {\n if (c >= '0' && c <= '9')\n return c - '0';\n } else if (c > 'F') {\n if (c >= 'a' && c <= 'f')\n return c - 'a' + 10;\n } else {\n return c - 'A' + 10;\n }\n return -1; // or throw exception\n}\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/221001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6583/"
] |
221,002
|
<p>I'm implementing an audit log on a database, so everything has a CreatedAt and a RemovedAt column. Now I want to be able to list all revisions of an object graph but the best way I can think of for this is to use unions. I need to get every unique CreatedAt and RemovedAt id.</p>
<p>If I'm getting a list of countries with provinces the union looks like this:</p>
<pre><code>SELECT c.CreatedAt AS RevisionId from Countries as c where localId=@Country
UNION
SELECT p.CreatedAt AS RevisionId from Provinces as p
INNER JOIN Countries as c ON p.CountryId=c.LocalId AND c.LocalId = @Country
UNION
SELECT c.RemovedAt AS RevisionId from Countries as c where localId=@Country
UNION
SELECT p.RemovedAt AS RevisionId from Provinces as p
INNER JOIN Countries as c ON p.CountryId=c.LocalId AND c.LocalId = @Country
</code></pre>
<p>For more complicated queries this could get quite complicated and possibly perform very poorly so I wanted to see if anyone could think of a better approach. This is in MSSQL Server.</p>
<p>I need them all in a single list because this is being used in a from clause and the real data comes from joining on this.</p>
|
[
{
"answer_id": 221114,
"author": "Aleris",
"author_id": 20417,
"author_profile": "https://Stackoverflow.com/users/20417",
"pm_score": 1,
"selected": false,
"text": "AuditLog table\n EntityName varchar(2000),\n Action varchar(255),\n EntityId int,\n OccuranceDate datetime\n select *\nfrom \n Contries C \n join AuditLog L on C.Id = L.EntityId and EntityName = 'Contries'\n"
},
{
"answer_id": 222340,
"author": "Tom H",
"author_id": 5696608,
"author_profile": "https://Stackoverflow.com/users/5696608",
"pm_score": 0,
"selected": false,
"text": "SELECT\n COALESCE(C.CreatedAt, P.CreatedAt)\nFROM\n dbo.Countries C\nFULL OUTER JOIN dbo.Provinces P ON\n 1 = 0\nWHERE\n C.LocalID = @Country OR\n P.LocalID = @Country\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/221002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/407256/"
] |
221,006
|
<p>So from what little I understand about packaging for Macs, I see that the actual program that launches is the one defined under the CFBundleExecutable key in Info.plist.</p>
<pre><code><key>CFBundleExecutable</key>
<string>JavaApplicationStub</string>
</code></pre>
<p>Now, my app doesnt work if /APP/Content/MacOS/JavaApplicationStub is not chmodded +x (It just fails silently without doing anything, which is a pain!).
Fair enough, its not executable I guess. But its a big problem if you are copying the app from somewhere that dosent support +x properties on files; such as windows, fat32 USB keys, CDROMs, websites, zip files, etc...</p>
<p>What can I do in these instances to make the app able to run? Manually setting the execute bit is not an option.</p>
<p>There's got to be people who run Mac apps off CD, at the very least!</p>
|
[
{
"answer_id": 221114,
"author": "Aleris",
"author_id": 20417,
"author_profile": "https://Stackoverflow.com/users/20417",
"pm_score": 1,
"selected": false,
"text": "AuditLog table\n EntityName varchar(2000),\n Action varchar(255),\n EntityId int,\n OccuranceDate datetime\n select *\nfrom \n Contries C \n join AuditLog L on C.Id = L.EntityId and EntityName = 'Contries'\n"
},
{
"answer_id": 222340,
"author": "Tom H",
"author_id": 5696608,
"author_profile": "https://Stackoverflow.com/users/5696608",
"pm_score": 0,
"selected": false,
"text": "SELECT\n COALESCE(C.CreatedAt, P.CreatedAt)\nFROM\n dbo.Countries C\nFULL OUTER JOIN dbo.Provinces P ON\n 1 = 0\nWHERE\n C.LocalID = @Country OR\n P.LocalID = @Country\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/221006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16925/"
] |
221,025
|
<p>In this sentence:</p>
<pre><code>myCommand.ExecuteReader(CommandBehavior.CloseConnection)
</code></pre>
<p>does it close connection in case of exception?</p>
|
[
{
"answer_id": 221034,
"author": "Danny Frencham",
"author_id": 29830,
"author_profile": "https://Stackoverflow.com/users/29830",
"pm_score": -1,
"selected": false,
"text": "SqlCommand myCommand = new SqlCommand();\n\ntry\n{\n myCommand.dostuff();\n}\ncatch(Exception ex)\n{\n // display error message\n}\nfinally\n{\n myCommand.ExecuteReader(CommandBehavior.CloseConnection);\n}\n"
},
{
"answer_id": 221045,
"author": "Stefan Schultze",
"author_id": 6358,
"author_profile": "https://Stackoverflow.com/users/6358",
"pm_score": 3,
"selected": false,
"text": "using (var conn = new SqlConnection(\"...\"))\n{\n conn.Open();\n using (var cmd = conn.CreateCommand())\n {\n cmd.CommandText = \"...\";\n using (var reader = cmd.ExecuteReader())\n {\n while (reader.Read())\n {\n // ...\n }\n }\n }\n}\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/221025",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29600/"
] |
221,031
|
<p>I have a Java service which now will execute in a batch mode. Multi threaded support is added to the service so for every batch request a thread pool will be dedicated to execute the batch. The question is how do I test this? I have functional tests that pass under the threaded version of the service but, somehow, I feel there must be an idiom for testing this. </p>
|
[
{
"answer_id": 221057,
"author": "Daniel Spiewak",
"author_id": 9815,
"author_profile": "https://Stackoverflow.com/users/9815",
"pm_score": 3,
"selected": false,
"text": "@Test(invocationCount=10, threadPool=10)\npublic void testSomethingConcurrently() {\n ...\n}\n testSomethingConcurrently"
},
{
"answer_id": 15952591,
"author": "Vinod",
"author_id": 2270969,
"author_profile": "https://Stackoverflow.com/users/2270969",
"pm_score": 1,
"selected": false,
"text": " @Test(threadPoolSize = 100, invocationCount = 100)\n @DataProvider(parallel = true)\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/221031",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28501/"
] |
221,052
|
<p>Could anyone provide any example of NAnt script for C++ project build automation?</p>
<p>Thanks!</p>
|
[
{
"answer_id": 221107,
"author": "endian",
"author_id": 25462,
"author_profile": "https://Stackoverflow.com/users/25462",
"pm_score": 0,
"selected": false,
"text": "<Solution>"
},
{
"answer_id": 222560,
"author": "Mike Marshall",
"author_id": 29798,
"author_profile": "https://Stackoverflow.com/users/29798",
"pm_score": 3,
"selected": true,
"text": "<property name=\"msbuild.dir\" value=\"C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\" />\n\n...\n\n<exec program=\"${msbuild.dir}\\MSBuild.exe\"\n commandline=\"/p:Configuration=Release .\\MySolution.sln\" \n/>\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/221052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22996/"
] |
221,063
|
<p>How can i find out this information?</p>
<hr>
<p>Ie, </p>
<p>I can install boost 1.35 with a command like</p>
<pre><code>sudo port install boost
</code></pre>
<p>only to get boost 1.36 via port i would do something like this? </p>
<pre><code>sudo port install boost-1.36
</code></pre>
<p>Hope that clears up my question</p>
|
[
{
"answer_id": 221107,
"author": "endian",
"author_id": 25462,
"author_profile": "https://Stackoverflow.com/users/25462",
"pm_score": 0,
"selected": false,
"text": "<Solution>"
},
{
"answer_id": 222560,
"author": "Mike Marshall",
"author_id": 29798,
"author_profile": "https://Stackoverflow.com/users/29798",
"pm_score": 3,
"selected": true,
"text": "<property name=\"msbuild.dir\" value=\"C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\" />\n\n...\n\n<exec program=\"${msbuild.dir}\\MSBuild.exe\"\n commandline=\"/p:Configuration=Release .\\MySolution.sln\" \n/>\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/221063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21537/"
] |
221,079
|
<p>I'm trying to add a pojo to a collection in another pojo. I'm sure I'm making a really stupid mistake somewhere along the lines but I can't figure out how to solve it.</p>
<p>I have a pojo LookupTable which contains a list of Columns:</p>
<pre><code>public class LookupTable {
private long id;
// More properties go here...
private List<Column> columns;
public void addColumn(Column column) {
this.columns.add(column);
}
// More methods go here...
}
</code></pre>
<p>In my hibernate configuration I have:</p>
<pre><code><class name="LookupTable" table="ARR_LOOKUP_TABLE">
<id name="id" column="ID">
<generator class="native"/>
</id>
<!-- Some properties here -->
<bag name="columns" cascade="all,delete-orphan" access="field">
<key column="LOOKUP_TABLE" not-null="true"/>
<one-to-many class="Column"/>
</bag>
</class>
<class name="Column" table="ARR_LOOKUP_COLUMN">
<id name="id" column="ID">
<generator class="native"/>
</id>
<!-- Some properties here -->
</class>
</code></pre>
<p>In my Spring config file I have:</p>
<pre><code><tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="managers" expression="execution(public * com.foo.*Manager.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="managers"/>
</aop:config>
</code></pre>
<p>And finally the code where it all fails within my manager class (com.foo.LookupTableManager):</p>
<pre><code>public void addColumnToTable(Column column, long tableId) {
LookupTable lookupTable = this.lookupTableDao.findById(tableId);
lookupTable.addColumn(column);
this.lookupTableDao.saveOrUpdate(lookupTable);
}
</code></pre>
<p>The variable lookupTableDao here refers to a simple DAO class which extends HibernateDaoSupport.</p>
<p>The error I get is:</p>
<pre><code>org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
at org.hibernate.collection.AbstractPersistentCollection.setCurrentSession(AbstractPersistentCollection.java:410)
at org.hibernate.event.def.OnUpdateVisitor.processCollection(OnUpdateVisitor.java:43)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:101)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:61)
at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:55)
at org.hibernate.event.def.AbstractVisitor.process(AbstractVisitor.java:123)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:293)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:223)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:89)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:495)
at com.foo.AbstractDao.saveOrUpdate(AbstractDao.java:29)
at com.foo.LookupTableManager.addColumnToTable(LookupTableManager.java:338)
... etc ...
</code></pre>
<p>OK, I understand the basic message I'm getting. But what I don't understand is where I get the second session.... Can anyone help me with this?</p>
<p>I'm using Hibernate 3.2.6.ga, Spring 2.5.5 and Tomcat 6.0</p>
|
[
{
"answer_id": 221110,
"author": "Chris Kimpton",
"author_id": 48310,
"author_profile": "https://Stackoverflow.com/users/48310",
"pm_score": 2,
"selected": false,
"text": "lookupTableDao.findById lookupTableDao.saveOrUpdate Session Column"
},
{
"answer_id": 7704473,
"author": "Mark Bakker",
"author_id": 626698,
"author_profile": "https://Stackoverflow.com/users/626698",
"pm_score": 2,
"selected": false,
"text": "myInstance = (myInstanceClass) Session.merge(myInstance);\n"
},
{
"answer_id": 8086160,
"author": "Claes Mogren",
"author_id": 4992,
"author_profile": "https://Stackoverflow.com/users/4992",
"pm_score": 0,
"selected": false,
"text": "import org.hibernate.Session;\nimport org.hibernate.SessionFactory;\nimport org.hibernate.Transaction;\n @Autowired private SessionFactory sessionFactory;\n Session session = sessionFactory.openSession();\nTransaction tx = session.beginTransaction();\n\nStuff stuff = getStuff();\nmanipulate(stuff);\nsend(stuff);\nsave(stuff);\n\ntx.commit();\n"
},
{
"answer_id": 10071182,
"author": "Raul Rene",
"author_id": 1300817,
"author_profile": "https://Stackoverflow.com/users/1300817",
"pm_score": 2,
"selected": false,
"text": "@Override\npublic Store getStoreByStoreId(final long storeId) {\n getHibernateTemplate().execute(new HibernateCallback<Store>() {\n @Override\n public StoredoInHibernate(Session session) throws HibernateException, SQLException {\n return (Store) session.createCriteria(Store.class)\n .add(Restrictions.eq(Store.PROP_ID, storeId))\n .uniqueResult();\n }\n });\n}\n @Override\npublic void updateStoreByStoreId(final long storeId) {\n getHibernateTemplate().execute(new HibernateCallback<Void>() {\n @Override\n public Void doInHibernate(Session session) throws HibernateException, SQLException {\n Store toBeUpdated = getStoreByStoreId(storeId);\n\n if (toBeUpdated != null){\n // ..change values for certain fields\n session.update(toBeUpdated);\n }\n return null;\n }\n });\n} \n @Override\npublic void updateStoreByStoreId(final long storeId) {\n getHibernateTemplate().execute(new HibernateCallback<Void>() {\n @Override\n public Void doInHibernate(Session session) throws HibernateException, SQLException {\n Store toBeUpdated = (Store) session.createCriteria(Store.class)\n .add(Restrictions.eq(Store.PROP_ID, storeId))\n .uniqueResult();\n\n if (toBeUpdated != null){\n // ..change values for certain fields\n session.update(toBeUpdated );\n }\n return null;\n }\n });\n} \n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/221079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26066/"
] |
221,091
|
<p>How can I extract information from a website (<a href="http://tv.yahoo.com/listings" rel="nofollow noreferrer">http://tv.yahoo.com/listings</a>) and then create an XML file out of it? I want to save it so to parse later and display information using JavaScript?</p>
<p>I am quite new to Perl and I have no idea about how to do it.</p>
|
[
{
"answer_id": 222621,
"author": "cjm",
"author_id": 8355,
"author_profile": "https://Stackoverflow.com/users/8355",
"pm_score": 2,
"selected": false,
"text": "use XMLTV;"
},
{
"answer_id": 223662,
"author": "draegtun",
"author_id": 12195,
"author_profile": "https://Stackoverflow.com/users/12195",
"pm_score": 1,
"selected": false,
"text": "use pQuery;\npQuery( 'http://tv.yahoo.com/listings' )\n ->find( '.show' )->each(\n sub {\n my $n = shift;\n my $pQ = pQuery( $_ ); \n say $pQ->text;\n }\n );\n\n # => 4:00pm - 6:30pm Local Programming\n use pQuery;\nmy @tv_progs;\npQuery( 'http://tv.yahoo.com/listings' )\n ->find( 'li div strong' )->each(\n sub {\n my $n = shift;\n my $pQ = pQuery( $_ ); \n $tv_progs[ $n ]->{ time } = $pQ->text;\n }\n )\n ->end\n ->find( '.showTitle' )->each( \n sub {\n my $n = shift;\n my $pQ = pQuery( $_ ); \n $tv_progs[ $n ]->{ name } = $pQ->text;\n }\n );\n\nfor my $prog ( @tv_progs ) {\n say $prog->{name} . \" @ \" . $prog->{time};\n}\n\n # => Local Programming @ 4:00pm - 6:30pm\n use pQuery;\npQuery( 'http://tv.yahoo.com/listings' )\n->find( '.chhdr a' )->each(\n sub {\n my $n = shift;\n my $pQ = pQuery( $_ ); \n say $pQ->text;\n }\n);\n\n # => ABC\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/221091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
221,154
|
<p>The number is bigger than <code>int</code> & <code>long</code> but can be accomodated in <code>Decimal</code>. But the normal <code>ToString</code> or <code>Convert</code> methods don't work on <code>Decimal</code>.</p>
|
[
{
"answer_id": 221174,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 1,
"selected": false,
"text": " decimal d = 588063595292424954445828M;\n int[] bits = decimal.GetBits(d);\n if (bits[3] != 0) throw new InvalidOperationException(\"Only +ve integers supported!\");\n string s = Convert.ToString(bits[2], 16).PadLeft(8,'0') // high\n + Convert.ToString(bits[1], 16).PadLeft(8, '0') // middle\n + Convert.ToString(bits[0], 16).PadLeft(8, '0'); // low\n Console.WriteLine(s);\n\n /* or Jon's much tidier: string.Format(\"{0:x8}{1:x8}{2:x8}\",\n (uint)bits[2], (uint)bits[1], (uint)bits[0]); */\n\n const decimal chunk = (decimal)(1 << 16);\n StringBuilder sb = new StringBuilder();\n while (d > 0)\n {\n int fragment = (int) (d % chunk);\n sb.Insert(0, Convert.ToString(fragment, 16).PadLeft(4, '0'));\n d -= fragment;\n d /= chunk;\n }\n Console.WriteLine(sb);\n"
},
{
"answer_id": 221209,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": true,
"text": "static string ConvertToHex(decimal d)\n{\n int[] bits = decimal.GetBits(d);\n if (bits[3] != 0) // Sign and exponent\n {\n throw new ArgumentException();\n }\n return string.Format(\"{0:x8}{1:x8}{2:x8}\",\n (uint)bits[2], (uint)bits[1], (uint)bits[0]);\n}\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/221154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
221,160
|
<p><code>termios.h</code> defines:</p>
<pre><code>#define TIOCM_OUT1 0x2000
#define TIOCM_OUT2 0x4000
</code></pre>
<p>But what are the flags good for?</p>
|
[
{
"answer_id": 221174,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 1,
"selected": false,
"text": " decimal d = 588063595292424954445828M;\n int[] bits = decimal.GetBits(d);\n if (bits[3] != 0) throw new InvalidOperationException(\"Only +ve integers supported!\");\n string s = Convert.ToString(bits[2], 16).PadLeft(8,'0') // high\n + Convert.ToString(bits[1], 16).PadLeft(8, '0') // middle\n + Convert.ToString(bits[0], 16).PadLeft(8, '0'); // low\n Console.WriteLine(s);\n\n /* or Jon's much tidier: string.Format(\"{0:x8}{1:x8}{2:x8}\",\n (uint)bits[2], (uint)bits[1], (uint)bits[0]); */\n\n const decimal chunk = (decimal)(1 << 16);\n StringBuilder sb = new StringBuilder();\n while (d > 0)\n {\n int fragment = (int) (d % chunk);\n sb.Insert(0, Convert.ToString(fragment, 16).PadLeft(4, '0'));\n d -= fragment;\n d /= chunk;\n }\n Console.WriteLine(sb);\n"
},
{
"answer_id": 221209,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": true,
"text": "static string ConvertToHex(decimal d)\n{\n int[] bits = decimal.GetBits(d);\n if (bits[3] != 0) // Sign and exponent\n {\n throw new ArgumentException();\n }\n return string.Format(\"{0:x8}{1:x8}{2:x8}\",\n (uint)bits[2], (uint)bits[1], (uint)bits[0]);\n}\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/221160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
221,165
|
<p>I'm building a database that will store information on a range of objects (such as scientific papers, specimens, DNA sequences, etc.) that all have a presence online and can be identified by a URL, or an identifier such as a <a href="http://www.doi.org/" rel="noreferrer" title="DOI">DOI</a>. Using these GUIDs as the primary key for the object seems a reasonable idea, and I've followed <a href="http://delicious.com/" rel="noreferrer" title="delicious">delicious</a> and <a href="http://www.connotea.org" rel="noreferrer" title="Connotea">Connotea</a> in using the md5 hash of the GUID. You'll see the md5 hash in your browser status bar if you mouse over the edit or delete buttons in a delicious or Connotea book mark. For example, the bookmark for <a href="http://stackoverflow/" rel="noreferrer">http://stackoverflow/</a> is </p>
<pre><code>http://delicious.com/url/e4a42d992025b928a586b8bdc36ad38d
</code></pre>
<p>where e4a42d992025b928a586b8bdc36ad38d ais the md5 hash of <a href="http://stackoverflow/" rel="noreferrer">http://stackoverflow/</a>.</p>
<p>Does anybody have views on the pros and cons of this approach?</p>
<p>For me an advantage of this approach (as opposed to using an auto incrementing primary key generated by the database itself) is that I have to do a lot of links between objects, and by using md5 hashes I can store these links externally in a file (say, as the result of data mining/scraping), then import them in bulk into the database. In the same way, if the database has to be rebuilt from scratch, the URLs to the objects won't change because they use the md5 hash.</p>
<p>I'd welcome any thoughts on whether this sounds sensible, or whether there other (better?) ways of doing this.</p>
|
[
{
"answer_id": 221249,
"author": "Steve McLeod",
"author_id": 2959,
"author_profile": "https://Stackoverflow.com/users/2959",
"pm_score": 1,
"selected": false,
"text": "http://example.com/view?id=1ccb9467-e326-4fed-b9a7-7edcba52be84\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/221165",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9684/"
] |
221,169
|
<p>I'm new to Flex, although not new to programming. I want to write a generic event handler that will be called by all my textinput boxes when they receive focus. When they have focus, I want to change the colour of the textinput box. When they lose focus, I want to restore the "inactive" color profile. I could write an ActionScript event handler for each textinput box, but we all know that's lame. :o) What I need, then, is a way to access the object which is calling the event handler.</p>
<p>In Delphi, I'd have written a function which passes in the Sender object, allowing me to access the calling object's properties. I'm guessing ActionScript/Flex has a completely different architecture, which is why I'm having difficulty doing this.</p>
<p>Thanks in anticipation!</p>
|
[
{
"answer_id": 221182,
"author": "eyelidlessness",
"author_id": 17964,
"author_profile": "https://Stackoverflow.com/users/17964",
"pm_score": 1,
"selected": false,
"text": "// 'focusOut' for blur\nstage.addEventListener('focusIn', function(e:Event):void {\n // The focused control is e.target\n});\n"
},
{
"answer_id": 400611,
"author": "Niko Nyman",
"author_id": 36817,
"author_profile": "https://Stackoverflow.com/users/36817",
"pm_score": 0,
"selected": false,
"text": "focusSkin mx.skins.halo.HaloFocusRect TextInput {\n focusSkin: Embed(source=\"focus.png\");\n}\n focusAlpha"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/221169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7703/"
] |
221,170
|
<p>How do I declare a private function in Fortran?</p>
|
[
{
"answer_id": 222003,
"author": "SumoRunner",
"author_id": 18975,
"author_profile": "https://Stackoverflow.com/users/18975",
"pm_score": 1,
"selected": false,
"text": "Private xxx, yyy, zzz\n\nreal function xxx (v)\n ...\nend function xxx\n\ninteger function yyy()\n ...\nend function yyy\n\nsubroutine zzz ( a,b,c )\n ...\nend subroutine zzz\n\n... \nother stuff that calls them\n...\n"
},
{
"answer_id": 222289,
"author": "Tim Whitcomb",
"author_id": 24895,
"author_profile": "https://Stackoverflow.com/users/24895",
"pm_score": 6,
"selected": true,
"text": "module so_example\n implicit none\n\n private\n\n public :: subroutine_1\n public :: function_1\n\ncontains\n\n ! Implementation of subroutines and functions goes here \n\nend module so_example\n"
},
{
"answer_id": 30926570,
"author": "Zeus",
"author_id": 4167161,
"author_profile": "https://Stackoverflow.com/users/4167161",
"pm_score": 2,
"selected": false,
"text": "PUBLIC :: subname-1, funname-2, ...\n\nPRIVATE :: subname-1, funname-2, ...\n MODULE Field\n IMPLICIT NONE\n\n Integer :: Dimen\n\n PUBLIC :: Gravity\n PRIVATE :: Electric, Magnetic\n\nCONTAINS\n\n INTEGER FUNCTION Gravity()\n ..........\n END FUNCTION Gravity\n\n\n REAL FUNCTION Electric()\n ..........\n END FUNCTION\n\n\n REAL FUNCTION Magnetic()\n ..........\n END FUNCTION\n\n ..........\n\nEND MODULE Field\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/221170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] |
221,178
|
<p>In my Spring MVC based applications i use Freemarker and i like it very much, but it's lacking advantages provided by Composite View pattern. </p>
<p>I'm thinking of trying to use Tiles2 together with Freemarker - does anyone know where do i find a simple example of SpringMVC together with Tiles2+Freemarker?</p>
|
[
{
"answer_id": 224746,
"author": "miceuz",
"author_id": 24443,
"author_profile": "https://Stackoverflow.com/users/24443",
"pm_score": 2,
"selected": false,
"text": "<definition name=\"template\" template=\"/WEB-INF/ftl/main.ftl\">\n <servlet>\n <servlet-name>freemarker</servlet-name>\n <servlet-class>freemarker.ext.servlet.FreemarkerServlet</servlet-class>\n\n <!-- FreemarkerServlet settings: -->\n <init-param>\n <param-name>TemplatePath</param-name>\n <param-value>/</param-value>\n </init-param>\n <init-param>\n <param-name>NoCache</param-name>\n <param-value>true</param-value>\n </init-param>\n <init-param>\n <param-name>ContentType</param-name>\n <param-value>text/html</param-value>\n </init-param>\n\n <!-- FreeMarker settings: -->\n <init-param>\n <param-name>template_update_delay</param-name>\n <param-value>0</param-value> <!-- 0 is for development only! Use higher value otherwise. -->\n </init-param>\n <init-param>\n <param-name>default_encoding</param-name>\n <param-value>ISO-8859-1</param-value>\n </init-param>\n <init-param>\n <param-name>number_format</param-name>\n <param-value>0.##########</param-value>\n </init-param>\n\n <load-on-startup>5</load-on-startup>\n</servlet> \n\n <servlet-mapping>\n <servlet-name>freemarker</servlet-name>\n <url-pattern>*.ftl</url-pattern>\n </servlet-mapping>\n <bean id=\"tilesConfigurer\" class=\"org.springframework.web.servlet.view.tiles2.TilesConfigurer\">\n <property name=\"definitions\">\n <list>\n <value>/WEB-INF/defs/definitions.xml</value>\n </list>\n </property>\n</bean>\n<bean id=\"viewResolver\" class=\"org.springframework.web.servlet.view.UrlBasedViewResolver\">\n <property name=\"viewClass\" value=\"org.springframework.web.servlet.view.tiles2.TilesView\"/>\n</bean>\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/221178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24443/"
] |
221,181
|
<p>How can I access Ethernet statistics from C/C++ code like <strong>netstat -e</strong>?</p>
<pre><code>Interface Statistics
Received Sent
Bytes 21010071 15425579
Unicast packets 95512 94166
Non-unicast packets 12510 7
Discards 0 0
Errors 0 3
Unknown protocols 0
</code></pre>
|
[
{
"answer_id": 221237,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 3,
"selected": false,
"text": "SELECT * FROM Win32_PerfFormattedData_Tcpip_IP\nSELECT * FROM Win32_PerfFormattedData_Tcpip_TCP\nSELECT * FROM Win32_PerfFormattedData_Tcpip_UDP\nSELECT * FROM Win32_PerfFormattedData_Tcpip_ICMP\nSELECT * FROM Win32_PerfFormattedData_Tcpip_Networkinterface\n"
},
{
"answer_id": 222530,
"author": "Denes Tarjan",
"author_id": 17617,
"author_profile": "https://Stackoverflow.com/users/17617",
"pm_score": 2,
"selected": false,
"text": "#include <winsock2.h>\n#include <iphlpapi.h>\n\nint main(int argc, char *argv[])\n{\n\nPMIB_IFTABLE pIfTable;\nMIB_IFROW ifRow;\nPMIB_IFROW pIfRow = &ifRow;\nDWORD dwSize = 0;\n\n// first call returns the buffer size needed\nDWORD retv = GetIfTable(pIfTable, &dwSize, true);\nif (retv != ERROR_INSUFFICIENT_BUFFER)\n WriteErrorAndExit(retv);\npIfTable = (MIB_IFTABLE*)malloc(dwSize);\n\nretv = GetIfTable(pIfTable, &dwSize, true);\nif (retv != NO_ERROR)\n WriteErrorAndExit(retv);\n\n// Get index\n int i,j;\n printf(\"\\tNum Entries: %ld\\n\\n\", pIfTable->dwNumEntries);\n for (i = 0; i < (int) pIfTable->dwNumEntries; i++)\n {\n pIfRow = (MIB_IFROW *) & pIfTable->table[i];\n printf(\"\\tIndex[%d]:\\t %ld\\n\", i, pIfRow->dwIndex);\n printf(\"\\tInterfaceName[%d]:\\t %ws\", i, pIfRow->wszName);\n printf(\"\\n\");\n printf(\"\\tDescription[%d]:\\t \", i);\n for (j = 0; j < (int) pIfRow->dwDescrLen; j++)\n printf(\"%c\", pIfRow->bDescr[j]);\n printf(\"\\n\");\n ...\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/221181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17617/"
] |
221,185
|
<p>How can I compile/run C or C++ code in a Unix console or a Mac terminal?</p>
|
[
{
"answer_id": 221189,
"author": "P-A",
"author_id": 4975,
"author_profile": "https://Stackoverflow.com/users/4975",
"pm_score": 3,
"selected": false,
"text": "./[name of the program] ./a.out"
},
{
"answer_id": 221193,
"author": "Andrey Neverov",
"author_id": 6698,
"author_profile": "https://Stackoverflow.com/users/6698",
"pm_score": 7,
"selected": false,
"text": "gcc main.cpp -o main.out\n./main.out\n"
},
{
"answer_id": 221204,
"author": "Nazgob",
"author_id": 3579,
"author_profile": "https://Stackoverflow.com/users/3579",
"pm_score": 3,
"selected": false,
"text": "- Wall -pedantic -Weffc++ -Werror\n"
},
{
"answer_id": 221222,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 2,
"selected": false,
"text": "makefile make"
},
{
"answer_id": 221257,
"author": "camh",
"author_id": 23744,
"author_profile": "https://Stackoverflow.com/users/23744",
"pm_score": 9,
"selected": true,
"text": "make foo\n $PATH . foo ./foo\n"
},
{
"answer_id": 224784,
"author": "orj",
"author_id": 20480,
"author_profile": "https://Stackoverflow.com/users/20480",
"pm_score": 4,
"selected": false,
"text": "/bin/cat MyProgram /Users/oliver/MyProject /Users/oliver/MyProject2 /Users/oliver/MyProject/MyProgram MyProgram pwd .bash_profile #!/bin/sh\nexport PATH=$PATH:~/bin\n ~/bin export PATH=~/bin:$PATH\n"
},
{
"answer_id": 5108608,
"author": "Komengem",
"author_id": 619010,
"author_profile": "https://Stackoverflow.com/users/619010",
"pm_score": 6,
"selected": false,
"text": "g++ -o lab21 iterative.cpp\n -o lab21 iterative.cpp ./lab21\n"
},
{
"answer_id": 8608367,
"author": "Srini Kadamati",
"author_id": 963203,
"author_profile": "https://Stackoverflow.com/users/963203",
"pm_score": 2,
"selected": false,
"text": "gcc hello.c\n./a.out (or with the output file of the first command)\n"
},
{
"answer_id": 13714437,
"author": "nerdwaller",
"author_id": 1584762,
"author_profile": "https://Stackoverflow.com/users/1584762",
"pm_score": 4,
"selected": false,
"text": "cd ~/programs/myprograms/ g++ input.cpp -o output.bin ls ./outbut.bin"
},
{
"answer_id": 24994658,
"author": "Victor Augusto",
"author_id": 1214729,
"author_profile": "https://Stackoverflow.com/users/1214729",
"pm_score": 5,
"selected": false,
"text": "make foo\n ./foo\n"
},
{
"answer_id": 27935706,
"author": "markthethomas",
"author_id": 3314701,
"author_profile": "https://Stackoverflow.com/users/3314701",
"pm_score": 3,
"selected": false,
"text": "make foo && ./$_\n"
},
{
"answer_id": 39094485,
"author": "Himanshu Mahajan",
"author_id": 1624283,
"author_profile": "https://Stackoverflow.com/users/1624283",
"pm_score": 0,
"selected": false,
"text": "gcc /Desktop/test.c\n ~/a.out\n"
},
{
"answer_id": 49772790,
"author": "Yogesh Nogia",
"author_id": 5954881,
"author_profile": "https://Stackoverflow.com/users/5954881",
"pm_score": 3,
"selected": false,
"text": "make filename ./filename gcc g++ gcc filename.c\n\n./a.out\n g++ filename.cpp\n\n./a.out\n"
},
{
"answer_id": 52665020,
"author": "Shiv Prakash",
"author_id": 7514765,
"author_profile": "https://Stackoverflow.com/users/7514765",
"pm_score": 2,
"selected": false,
"text": "gcc filename.c\n./a.out filename.c\n g++ filename.cpp\n./a.out filename.cpp\n"
},
{
"answer_id": 56603676,
"author": "Alper",
"author_id": 8054623,
"author_profile": "https://Stackoverflow.com/users/8054623",
"pm_score": 2,
"selected": false,
"text": "c++ fileName.cpp -o fileName ./fileName"
},
{
"answer_id": 62215466,
"author": "Teena nath Paul",
"author_id": 1676585,
"author_profile": "https://Stackoverflow.com/users/1676585",
"pm_score": 0,
"selected": false,
"text": "g++ -c main.cpp -o main.o\n #include <conio.h> #include <curses.h> -lcurses g++ -o main main.o -lcurses\n ./main\n"
},
{
"answer_id": 65272226,
"author": "Shubham Saurav",
"author_id": 7688676,
"author_profile": "https://Stackoverflow.com/users/7688676",
"pm_score": 0,
"selected": false,
"text": "gcc fileName g++ fileName"
},
{
"answer_id": 67008542,
"author": "Ashish Kumar",
"author_id": 10830020,
"author_profile": "https://Stackoverflow.com/users/10830020",
"pm_score": 3,
"selected": false,
"text": "touch test.cpp\n g++ test.cpp\n ./a.out\n"
},
{
"answer_id": 71043011,
"author": "Raj BigData",
"author_id": 7222806,
"author_profile": "https://Stackoverflow.com/users/7222806",
"pm_score": 2,
"selected": false,
"text": "g++ one.cpp -o one\n\n./one\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/221185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4975/"
] |
221,192
|
<p>I have a page, with some code in js and jQuery and it works very well. But unfortunately, all my site is very very old, and uses frames. So when I loaded my page inside a frame, <code>$(document).ready()</code> doesn't fire up.</p>
<p>My frameset looks like:</p>
<pre><code><frameset rows="79,*" frameBorder="1" frameSpacing="1" bordercolor="#5996BF" noresize>
<frame name="header" src="Operations.aspx?main='Info.aspx'" marginwidth="0" marginheight="0" scrolling="no" noresize frameborder="0">
<frame name="main" src="Info.aspx" marginwidth="0" marginheight="0" scrolling="auto" noresize frameborder="0">
</frameset>
</code></pre>
<p>My page is loaded into the <code>main</code> frame. What should I do?</p>
|
[
{
"answer_id": 221234,
"author": "Aleris",
"author_id": 20417,
"author_profile": "https://Stackoverflow.com/users/20417",
"pm_score": -1,
"selected": false,
"text": "$(document).ready() jquery.js"
},
{
"answer_id": 221441,
"author": "matma",
"author_id": 29880,
"author_profile": "https://Stackoverflow.com/users/29880",
"pm_score": 0,
"selected": false,
"text": "$(document).ready()"
},
{
"answer_id": 323141,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "onload id name <frame> id name onload $(\"frameName\").ready(function() { \n // Write your frame onload code here\n}\n"
},
{
"answer_id": 3064350,
"author": "jenming",
"author_id": 369654,
"author_profile": "https://Stackoverflow.com/users/369654",
"pm_score": 3,
"selected": false,
"text": "$(\"#frameName\").ready(function() {\n // Write you frame on load javascript code here\n} );\n $(\"#frameName\").load( function() {\n //code goes here\n} );\n"
},
{
"answer_id": 9082075,
"author": "brobert7",
"author_id": 1075723,
"author_profile": "https://Stackoverflow.com/users/1075723",
"pm_score": 2,
"selected": false,
"text": "<script src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js\"></script>\n<script>\n$(window.parent.frames[0].document).ready(function() {\n // Do stuff\n});\n</script>\n"
},
{
"answer_id": 10943864,
"author": "Jochen",
"author_id": 1443796,
"author_profile": "https://Stackoverflow.com/users/1443796",
"pm_score": 1,
"selected": false,
"text": "<!DOCTYPE HTML>\n<html>\n<head>\n <script src=\"http://code.jquery.com/jquery-latest.js\"></script>\n\n <script> \n document.write('<frameset><frame name=\"frame_content\" id=\"frame_content\"></frame></frameset>');\n\n $('#frame_content').attr('src', 'test2.html');\n $('#frame_content').load(function()\n {\n if('${\"#header\"}' != '') {\n $(\"#header\", frame_content.document).remove();\n }\n });\n if($('#frame_content').complete) $('#frame_content').trigger(\"load\");\n </script>\n\n</head>\n</html>\n <!DOCTYPE HTML>\n<html>\n\n <head>\n </head>\n\n <body>\n <div id=\"header\">You will never see me, cause I have been removed!</div>\n </body>\n</html>\n"
},
{
"answer_id": 11322965,
"author": "elfan",
"author_id": 1500595,
"author_profile": "https://Stackoverflow.com/users/1500595",
"pm_score": 2,
"selected": false,
"text": "$($(\"#frameName\")[0].contentWindow.document).ready(function() {\n // Write you frame onready code here\n});\n"
},
{
"answer_id": 27140768,
"author": "Edward Olamisan",
"author_id": 556649,
"author_profile": "https://Stackoverflow.com/users/556649",
"pm_score": 0,
"selected": false,
"text": "$(\"frame[name='main']\").ready(function(){..}); \n $(\"#frameName\").ready(function(){..}); \n"
},
{
"answer_id": 35680918,
"author": "newstockie",
"author_id": 4890961,
"author_profile": "https://Stackoverflow.com/users/4890961",
"pm_score": 0,
"selected": false,
"text": "ifrm2 = var ifrm2 = document.getElementById('frm2');\nif (ifrm2.contentDocument.readyState == 'complete') {\n //here goes the code after frame fully loaded\n}\n\n //id = frm2 is the id of iframe in my page\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/221192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29880/"
] |
221,194
|
<p>I have table employee like,
<br>
employee
(
emp_id int primary key,
emp_name varchar(50),
mngr_id int)</p>
<p>and here mngr_id would either null or contain valid emp_id. This way it form the hierarchy of employees in the organization.</p>
<p>In order to traverse the entire hierarchy I had to write the recursive stored procedure. (in Oracle it's easy by using CONNECT BY .. START WITH)</p>
<p>So the question is that what is the performance impact of such stored procedure given that the level of hierarchy would not go beyond 10 levels !</p>
<p>Is there any other way to achieve the same ?</p>
|
[
{
"answer_id": 3318497,
"author": "Jon Black",
"author_id": 298016,
"author_profile": "https://Stackoverflow.com/users/298016",
"pm_score": 2,
"selected": false,
"text": "delimiter ;\n\ndrop procedure if exists employee_hier;\n\ndelimiter #\n\ncreate procedure employee_hier\n(\nin p_emp_id smallint unsigned\n)\nbegin\n\ndeclare p_done tinyint unsigned default(0);\ndeclare p_depth smallint unsigned default(0);\n\ncreate temporary table hier(\n boss_id smallint unsigned, \n emp_id smallint unsigned, \n depth smallint unsigned\n)engine = memory;\n\ninsert into hier values (null, p_emp_id, p_depth);\n\n/* http://dev.mysql.com/doc/refman/5.0/en/temporary-table-problems.html */\n\ncreate temporary table emps engine=memory select * from hier;\n\nwhile p_done <> 1 do\n\n if exists( select 1 from employee e inner join hier on e.boss_id = hier.emp_id and hier.depth = p_depth) then\n\n insert into hier select e.boss_id, e.emp_id, p_depth + 1 \n from employee e inner join emps on e.boss_id = emps.emp_id and emps.depth = p_depth;\n\n set p_depth = p_depth + 1; \n\n truncate table emps;\n insert into emps select * from hier where depth = p_depth;\n\n else\n set p_done = 1;\n end if;\n\nend while;\n\nselect \n e.emp_id,\n e.name as emp_name,\n b.emp_id as boss_emp_id,\n b.name as boss_name,\n hier.depth\nfrom \n hier\ninner join employee e on hier.emp_id = e.emp_id\ninner join employee b on hier.boss_id = b.emp_id;\n\ndrop temporary table if exists hier;\ndrop temporary table if exists emps;\n\nend #\n\ndelimiter ;\n\n\ncall employee_hier(1);\ncall employee_hier(3);\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/221194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/959/"
] |
221,224
|
<p>Consider the following code snippet</p>
<pre><code>private void ProcessFile(string fullPath) {
XmlTextReader rdr = new XmlTextReader("file:\\\\" + fullPath);
while (rdr.Read()) {
//Do something
}
return;
}
</code></pre>
<p>Now, this functions fine when passed a path like:</p>
<p>"C:\Work Files\Technical Information\Dummy.xml"</p>
<p>But throws an error when passed</p>
<p>"C:\Work Files\#Technical Information\Dummy.xml"</p>
<p>Note that all folders and files specified exist and that the hash character is a valid character for paths. The error details are:</p>
<p><p>System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Work Files\'.
<br> at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
<br> at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
<br> at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
<br> at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials)
<br> at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
<br> at System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver)
<br> at System.Threading.CompressedStack.runTryCode(Object userData)
<br> at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
<br> at System.Threading.CompressedStack.Run(CompressedStack compressedStack, ContextCallback callback, Object state)
<br> at System.Xml.XmlTextReaderImpl.OpenUrl()
<br> at System.Xml.XmlTextReaderImpl.Read()
<br> at System.Xml.XmlTextReader.Read()</p>
<p><p>Anybody know what's going on?</p>
|
[
{
"answer_id": 221243,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 3,
"selected": true,
"text": "file:/// # #"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/221224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1389021/"
] |
221,254
|
<p>In Visual Studio, when you compile foo.idl, MIDL generates the proxy information in foo_p.c.</p>
<p>Unfortunately, for Win32 and x64 files, it uses the same filename. For Win32, the file starts with:</p>
<pre><code>#if !defined(_M_IA64) && !defined(_M_AMD64)
</code></pre>
<p>For x64, the file starts with:</p>
<pre><code>#if defined(_M_AMD64)
</code></pre>
<p>When you build for Win32 and then immediately build for x64, it doesn't replace the foo_p.c file, meaning that the project fails to link.</p>
<p>I tried having a pre-build event that deletes the foo_p.c file if it's for the wrong architecture, but VS doesn't even bother to run that step.</p>
<p>How should I get it so that I can build one configuration and then the other?</p>
|
[
{
"answer_id": 221319,
"author": "ChrisN",
"author_id": 3853,
"author_profile": "https://Stackoverflow.com/users/3853",
"pm_score": 3,
"selected": true,
"text": "foo_p_w32.c foo_p_x64.c foo_p_x64.c"
},
{
"answer_id": 4918170,
"author": "dexblack",
"author_id": 534513,
"author_profile": "https://Stackoverflow.com/users/534513",
"pm_score": 0,
"selected": false,
"text": "<Tool\nName=\"VCMIDLTool\"\nTypeLibraryName=\"$(ProjectName).tlb\"\nOutputDirectory=\"$(SolutionDir)$(PlatformName)\"\nHeaderFileName=\"$(ProjectName)_h.h\"\nDLLDataFileName=\"$(ProjectName)_dlldata.c\"\n/>\n <Tool\n Name=\"VCMIDLTool\"\n TypeLibraryName=\"$(InputName).tlb\"\n OutputDirectory=\"$(SolutionDir)$(PlatformName)\"\n HeaderFileName=\"$(InputName)_i.h\"\n DLLDataFileName=\"$(InputName)_dlldata.c\"\n InterfaceIdentifierFileName=\"$(InputName)_i.c\"\n ProxyFileName=\"$(InputName)_p.c\"\n/>\n <Tool Name=\"VCCLCompilerTool\" ...\nAdditionalIncludeDirectories=\"...;"$(SolutionDir)$(PlatformName);"\"\n"
}
] |
2008/10/21
|
[
"https://Stackoverflow.com/questions/221254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8446/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.