qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
299,723
<p>I need to do transactions (begin, commit or rollback), locks (select for update). How can I do it in a document model db?</p> <p>Edit:</p> <p>The case is this:</p> <ul> <li>I want to run an auctions site.</li> <li>And I think how to direct purchase as well.</li> <li>In a direct purchase I have to decrement the quantity field in the item record, but only if the quantity is greater than zero. That is why I need locks and transactions.</li> <li>I don't know how to address that without locks and/or transactions.</li> </ul> <p>Can I solve this with CouchDB?</p>
[ { "answer_id": 299744, "author": "MrKurt", "author_id": 35296, "author_profile": "https://Stackoverflow.com/users/35296", "pm_score": 8, "selected": true, "text": "_rev _rev _rev _rev product_key claimed_by hammer-1 hammer-2 function(doc) \n{ \n if (doc.type == 'inventory_ticket' && doc.claimed_by == null ) { \n emit(doc.product_key, { 'inventory_ticket' :doc.id, '_rev' : doc._rev }); \n } \n}\n id _rev function (keys, values, combine) {\n return values.length;\n}\n inventory_ticket" }, { "answer_id": 18151254, "author": "wallacer", "author_id": 147458, "author_profile": "https://Stackoverflow.com/users/147458", "pm_score": 3, "selected": false, "text": "function( doc )\n{\n if( doc.InventoryChange != undefined ) {\n for( product_key in doc.InventoryChange ) {\n emit( product_key, 1 );\n }\n }\n}\n _sum\n {\n \"_id\": \"abc123\",\n \"InventoryChange\": {\n \"hammer_1234\": 10,\n \"saw_4321\": 25\n }\n}\n {\n \"_id\": \"def456\",\n \"InventoryChange\": {\n \"hammer_1234\": -5\n }\n}\n" }, { "answer_id": 44666742, "author": "Ravinder Payal", "author_id": 2988776, "author_profile": "https://Stackoverflow.com/users/2988776", "pm_score": 0, "selected": false, "text": "txn_id , txn_attribute1, txn_attribute2,......,txn_status\ndhwdhwu$sg1 x y added/replicated\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1356709/" ]
299,728
<p>I am running a script on a solaris Box. specifically SunOS 5.7. I am not root. I am trying to execute a script similar to the following:</p> <blockquote> <blockquote> <p>newgrp thegroup &lt;&lt; FOO<br> source .login_stuff<br> echo "hello world"<br> FOO</p> </blockquote> </blockquote> <p>The Script runs. The problem is it returns back to the calling process which puts me in the old group with the source .login_stuff not being sourced. I understand this behavior. What I am looking for is a way to stay in the sub shell. Now I know I could put an xterm&amp; (see below) in the script and that would do it, but having a new xterm is undesirable. </p> <blockquote> <p>Passing your current pid as a parameter.</p> <blockquote> <p>newgrp thegroup &lt;&lt; FOO<br> source .login_stuff<br> xterm&amp;<br> echo $1<br> kill -9 $1<br> FOO</p> </blockquote> </blockquote> <p>I do not have sg available. Also, newgrp is necessary.</p>
[ { "answer_id": 299767, "author": "nobody", "author_id": 19405, "author_profile": "https://Stackoverflow.com/users/19405", "pm_score": 0, "selected": false, "text": "exec $SHELL\n" }, { "answer_id": 299896, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 4, "selected": false, "text": "newgrp newgrp exec newgrp newgrp newgrp su sudo newgid newgrp asroot asroot: Configured for use by jleffler only\nUsage: asroot [-hnpxzV] [<uid controls>] [<gid controls>] [-m umask] [--] command [arguments]\n <uid controls> = [-u usr|-U uid] [-s euser|-S euid][-i user]\n <gid controls> = [-C] [-g grp|-G gid] [-a grp][-A gid] [-r egrp|-R egid]\nUse -h for more help\n\nOption summary:\n -a group Add auxilliary group (by name)\n -A gid Add auxilliary group (by number)\n -C Cancel all auxilliary groups\n -g group Run with specified real GID (by name)\n -G gid Run with specified real GID (by number)\n -h Print this message and exit\n -i Initialize UID and GIDs as if for user (by name or number)\n -m umask Set umask to given value\n -n Do not run program\n\n -p Print privileges to be set\n -r euser Run with specified effective UID (by name)\n -R euid Run with specified effective UID (by number)\n -s egroup Run with specified effective GID (by name)\n -S egid Run with specified effective GID (by number)\n -u user Run with specified real UID (by name)\n -U uid Run with specified real UID (by number)\n -V Print version and exit\n -x Trace commands that are executed\n -z Do not verify the UID/GID numbers\nMnemonic for effective UID/GID:\n s is second letter of user;\n r is second letter of group\n" }, { "answer_id": 3667256, "author": "plijnzaad", "author_id": 442359, "author_profile": "https://Stackoverflow.com/users/442359", "pm_score": 4, "selected": false, "text": "### first become another group\ngroup=admin\n\nif [ $(id -gn) != $group ]; then\n exec sg $group \"$0 $*\"\nfi\n\n### now continue with rest of the script\n" }, { "answer_id": 8363574, "author": "Mark E. Hamilton", "author_id": 1078332, "author_profile": "https://Stackoverflow.com/users/1078332", "pm_score": 3, "selected": false, "text": "#!/bin/bash\ngroup=wg-sierra-admin\nif [ $(id -gn) != $group ]\nthen\n # Construct an array which quotes all the command-line parameters.\n arr=(\"${@/#/\\\"}\")\n arr=(\"${arr[*]/%/\\\"}\")\n exec sg $group \"$0 ${arr[@]}\"\nfi\n\n### now continue with rest of the script\n# This is a simple test to show that it works.\necho \"group: $(id -gn)\"\n# Show all command line parameters.\nfor i in $(seq 1 $#)\ndo\n eval echo \"$i:\\${$i}\"\ndone\n % ./sg.test 'a b' 'c d e' f 'g h' 'i j k' 'l m' 'n o' p q r s t 'u v' 'w x y z'\ngroup: wg-sierra-admin\n1:a b\n2:c d e\n3:f\n4:g h\n5:i j k\n6:l m\n7:n o\n8:p\n9:q\n10:r\n11:s\n12:t\n13:u v\n14:w x y z\n" }, { "answer_id": 10080117, "author": "Mr. B", "author_id": 712522, "author_profile": "https://Stackoverflow.com/users/712522", "pm_score": 4, "selected": true, "text": "newgrp adm << ANYNAME\n# You can do more lines than just this.\necho This is running as group \\$(id -gn)\nANYNAME\n This is running as group adm\n newgrp adm << END\n# You can do more lines than just this.\necho 'This is running as group $(id -gn)'\nEND\n This is running as group users\n" }, { "answer_id": 22096309, "author": "Adam Goodman", "author_id": 3364973, "author_profile": "https://Stackoverflow.com/users/3364973", "pm_score": 0, "selected": false, "text": "#! /bin/ksh\n/bin/ksh -c \"newgrp thegroup\"\n >> groups fred\noldgroup\n>> tst.ksh\n\n>> groups fred\nthegroup\n" }, { "answer_id": 49529725, "author": "user2141182", "author_id": 2141182, "author_profile": "https://Stackoverflow.com/users/2141182", "pm_score": 0, "selected": false, "text": "sudo su - [user-name] -c exit;\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34531/" ]
299,729
<p>I am trying to call a Actionscript function from javascript but I am having problems in Internet Explorer. I am using Swiff.remote in mootools 1.2.1 to call the actionscript function ie:</p> <pre><code>Swiff.remote(playSwf.toElement(), 'sendResult', result, plays, name); </code></pre> <p>This all works fine in FireFox, Safari and Opera but I'm getting an "unspecified" error in Internet Explorer 6 and 7. I have tried using the bog standard:</p> <pre><code>window['flash'].sendResult(result, plays, name); </code></pre> <p>To no avail.</p> <p>Thanks for any help. Mark</p>
[ { "answer_id": 299882, "author": "picardo", "author_id": 32816, "author_profile": "https://Stackoverflow.com/users/32816", "pm_score": 3, "selected": false, "text": "//1. calling javascript function from Flash.\nExternalInterface.call(\"sendData\",tempStr);\n// argument 1: javascript function, argument 2: data/variables to pass out.\n//2. calling javascript function from Flash with recursion.\nvar returnValue:String = ExternalInterface.call(\"sendReturn\",tempStr).toString();\n//3. setting up a callback function for javascript\nExternalInterface.addCallback(\"callFlash\",flashResponse);\n// argument 1: function name called by javascript, argument 2: function on the Flash side.\n// AS2 version looks like this : ExternalInterface.addCallback(\"callFlash\",null,flashResponse);\n //1. javascript function as called from Flash.\nfunction sendData(val){\n alert(val);\n document.flashForm.flashOutput.value = val;\n}\n\n//2. javascript function with recursion.\nfunction sendReturn(val){\n var tempData = \"Hello from JS\";\n return tempData + ' :return';\n}\n\n//3. calling Flash function with javascript.\nfunction sendToFlash(val){\n window['flash'].callFlash(val);\n}\n" }, { "answer_id": 300031, "author": "picardo", "author_id": 32816, "author_profile": "https://Stackoverflow.com/users/32816", "pm_score": 2, "selected": false, "text": "<form>\n <input type=\"button\" onclick=\"callExternalInterface(id)\" value=\"Call ExternalInterface\" />\n</form>\n<script>\nfunction callExternalInterface(id) {\n thisMovie(\"externalInterfaceExample\").callAS(id);\n}\n\nfunction thisMovie(movieName) {\n if (navigator.appName.indexOf(\"Microsoft\") != -1) {\n return window[movieName]\n }\n else {\n return document[movieName]\n }\n}\n</script>\n" }, { "answer_id": 305941, "author": "discorax", "author_id": 30408, "author_profile": "https://Stackoverflow.com/users/30408", "pm_score": 0, "selected": false, "text": "import flash.external.*;\n package com\n{\n import flash.external.ExternalInterface;\n public class Main \n {\n }\n}\n" }, { "answer_id": 331138, "author": "digitarald", "author_id": 24147, "author_profile": "https://Stackoverflow.com/users/24147", "pm_score": 0, "selected": false, "text": "playSwf.remote('sendResult', result, plays, name)\n sendResult ExternalInterface.addCallback()" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
299,754
<p>I recently started facelets development, and a couple of days ago made my first useful custom tag. Now I would like to have auto-completion support in eclipse, like I have for standard taglibs like h, c and ui.</p> <p>Is there any easy way (less than 30 min work) to enable tool support for custom tags?</p> <p>I'm using eclipse 3.4 with jboss tools.</p>
[ { "answer_id": 299783, "author": "matt b", "author_id": 4249, "author_profile": "https://Stackoverflow.com/users/4249", "pm_score": 0, "selected": false, "text": "<%@ include file=\"...\" %> <form:blah> <%@ taglib prefix=\"form\" uri=\"http://www.springframework.org/tags/form\" %>\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9987/" ]
299,755
<p>I am working on a small team of web application developers. We edit JSPs in Eclipse on our own machines and then move them over to a shared application server to test the changes. I have an Ant script that will take ALL the JSPs on my machine and move them over to the application server, but will only overwrite JSPs if the ones on my machine are "newer". This works well most of the time, but not all of the time. Our update method doesn't preserve file change day/times, so it is possible that an Update on my machine will set the file day/time to now instead of when the file was actually last changed. If someone else worked on that file 1 hour ago (but hasn't committed the changes yet), then the older file on my PC will actually have a newer date. So when I run the Ant script it will overwrite their changes with an older file.</p> <p>What I am looking for is an easy way to just move the file I am currently working on. Is there a way to specify the "current" file in an Ant script? Or an easy way to move the current file within Eclipse? Perhaps a good plugin to do this kind of stuff? I could go out to Windows Explorer to separately move the file, but I would much prefer to be able to do it from within Eclipse.</p>
[ { "answer_id": 299773, "author": "matt b", "author_id": 4249, "author_profile": "https://Stackoverflow.com/users/4249", "pm_score": 0, "selected": false, "text": "-D <copy file=${myfile} todir=\"blah\"/>\n" }, { "answer_id": 299862, "author": "Ken Gentle", "author_id": 8709, "author_profile": "https://Stackoverflow.com/users/8709", "pm_score": 2, "selected": true, "text": "resource_name" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37036/" ]
299,770
<p>I am trying to convert a working MS Access query to run on an Oracle database being accessed via VB Script (.asp). This is the last section of the WHERE clause:</p> <pre><code>sql = sql &amp; "WHERE (UAT.HB.MB_MODE = 'A' AND UAT.HB.PRINT_DATE &gt;= '" &amp; SD &amp; "' AND UAT.HB.PRINT_DATE &lt;= '" &amp; ED &amp;"' )" </code></pre> <p>The variable "SD" (i.e. "start date") is a text string that can contain a value such as "11/11/2008". The same goes for the variable "ED" (i.e. "end date").</p> <p>However, the dates do not work. Does Oracle require a special way to use dates?</p> <p>Do the dates have to be converted? Do I surround them with the '#' keyword like you would in MS Access?</p>
[ { "answer_id": 299788, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 4, "selected": false, "text": "DATE '2008-11-11'\n TO_DATE('11/11/2008', 'MM/DD/YYYY')\n" }, { "answer_id": 299791, "author": "Vincent Ramdhanie", "author_id": 27439, "author_profile": "https://Stackoverflow.com/users/27439", "pm_score": 1, "selected": false, "text": "to_date('19960725','YYYYMMDD')\n" }, { "answer_id": 299803, "author": "gpojd", "author_id": 28071, "author_profile": "https://Stackoverflow.com/users/28071", "pm_score": 3, "selected": false, "text": "TO_DATE('2008-11-18 14:13:59', 'YYYY-MM-DD HH24:Mi:SS')\n" }, { "answer_id": 299809, "author": "rich", "author_id": 25502, "author_profile": "https://Stackoverflow.com/users/25502", "pm_score": 0, "selected": false, "text": "select to_date('2008/11/18:12:00:00AM', 'yyyy/mm/dd:hh:mi:ssam') from dual select to_char(sysdate, 'mm/dd/yyyy') from dual" }, { "answer_id": 301487, "author": "hamishmcn", "author_id": 3590, "author_profile": "https://Stackoverflow.com/users/3590", "pm_score": 0, "selected": false, "text": "start_date, print_date, end_date print_date >= start_date AND print_date <= end_date print_date end_date start_date end_date print_date" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299770", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26883/" ]
299,778
<p>I have done this on Websphere (re: title of this topic) using wsdl2java for generating wsdl to java mapping xml file. My endpoint is a generic stateless EJB. The code in EJB is generated by traversing the each wsdl and getting the wsdl operation and stuck it in the generated remote EJB interface. Each EJB method impl is generic and handles all the services the same. Used instructions on this doc to do this on WAS: <a href="http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/twbs_devwbsjaxrpcwsdl.html" rel="nofollow noreferrer">http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/twbs_devwbsjaxrpcwsdl.html</a></p> <p>Now, I am asking you all for help if anyone has done something similar in Sun AS 9.1.</p> <p>Starting from existing WSDL (and xsd) files. Knowing the sole EJB service endpoint implementation for each services are the same, and generating an EAR file (webservices.xml, ejb-jar.xml, etc).</p> <p>Have struggled with wscompile and alike, but not getting anyware in the same fashion I did for WebSphere.</p> <p>Thanks for help.</p>
[ { "answer_id": 436060, "author": "Fabian Steeg", "author_id": 18154, "author_profile": "https://Stackoverflow.com/users/18154", "pm_score": 0, "selected": false, "text": "wsdlLocation() WebService" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299778", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
299,797
<p>I'm executing several discrete queries in a single batch against SQL Server. For example:</p> <pre> update tableX set colA = 'freedom'; select lastName from customers; insert into tableY (a,b,c) values (x,y,z); </pre> <p>Now, I want to capture the result in a DataSet (from select statement) which is easy enough to do...but how do I also capture the "meta" response from that command similar to the way Query Analyzer/SQL Mgt Studio does when it displays the "Messages" tab and diplays something similar to:</p> <pre> (1 Row affected) (2 Rows Updated) </pre>
[ { "answer_id": 299925, "author": "Nick DeVore", "author_id": 1380, "author_profile": "https://Stackoverflow.com/users/1380", "pm_score": 2, "selected": false, "text": "declare @rowsAffected int, @error int\n\nselect * from sometable\n select @rowsAffected = @@rowcount, @error = @@error\n\nif @@error <> 0 goto errorCleanup\n" }, { "answer_id": 301209, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "@@ROWCOUNT SET NOCOUNT ON" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4398/" ]
299,802
<p>In Mootools, I'd just run <code>if ($('target')) { ... }</code>. Does <code>if ($('#target')) { ... }</code> in jQuery work the same way?</p>
[ { "answer_id": 299812, "author": "redsquare", "author_id": 6440, "author_profile": "https://Stackoverflow.com/users/6440", "pm_score": 7, "selected": false, "text": "if ( $('#someDiv').length ){\n\n}\n" }, { "answer_id": 299821, "author": "Pat", "author_id": 238, "author_profile": "https://Stackoverflow.com/users/238", "pm_score": 11, "selected": true, "text": "if ($(selector).length ) {\n // Do something\n}\n jQuery.fn.exists = function(){return this.length>0;}\n if ($(selector).exists()) {\n // Do something\n}\n" }, { "answer_id": 301401, "author": "James", "author_id": 21677, "author_profile": "https://Stackoverflow.com/users/21677", "pm_score": 2, "selected": false, "text": "if( jQuery('#elem').get(0) ) {}\n" }, { "answer_id": 444389, "author": "Jon Erickson", "author_id": 1950, "author_profile": "https://Stackoverflow.com/users/1950", "pm_score": 5, "selected": false, "text": "jQuery.fn.exists = function(){return ($(this).length > 0);}\nif ($(selector).exists()) { }\n jQuery.exists = function(selector) {return ($(selector).length > 0);}\nif ($.exists(selector)) { }\n" }, { "answer_id": 2918443, "author": "Sean Curtis", "author_id": 351576, "author_profile": "https://Stackoverflow.com/users/351576", "pm_score": 4, "selected": false, "text": "if ($('#elem')[0]) {\n // do stuff\n}\n" }, { "answer_id": 3994871, "author": "PhilT", "author_id": 357012, "author_profile": "https://Stackoverflow.com/users/357012", "pm_score": 4, "selected": false, "text": "$('#elem').each(function(){\n // do stuff\n});\n" }, { "answer_id": 9112047, "author": "Maurice Montreuil", "author_id": 1185062, "author_profile": "https://Stackoverflow.com/users/1185062", "pm_score": -1, "selected": false, "text": ".exists if ($(\"#elem\").index() ! = -1) {}\n" }, { "answer_id": 9759925, "author": "skqr", "author_id": 177871, "author_profile": "https://Stackoverflow.com/users/177871", "pm_score": 4, "selected": false, "text": "$(':YEAH');\n\"Syntax error, unrecognized expression: YEAH\"\n if ($.expr[':']['YEAH']) {\n // Query for your :YEAH selector with ease of mind.\n}\n" }, { "answer_id": 11917151, "author": "user1134422", "author_id": 1134422, "author_profile": "https://Stackoverflow.com/users/1134422", "pm_score": 1, "selected": false, "text": " if (jQuery(\"#anyElement\").is(\"*\")){...}\n" }, { "answer_id": 19090002, "author": "Zsolt Takács", "author_id": 555167, "author_profile": "https://Stackoverflow.com/users/555167", "pm_score": -1, "selected": false, "text": "$.fn.is_exists = function(){ return document.getElementById(selector) }\n if($(selector).is_exists()){ ... }\n" }, { "answer_id": 21310207, "author": "logrox", "author_id": 1875100, "author_profile": "https://Stackoverflow.com/users/1875100", "pm_score": 2, "selected": false, "text": "jQuery.fn.exists = function(selector, callback) {\n var $this = $(this);\n $this.each(function() {\n callback.call(this, ($(this).find(selector).length > 0));\n });\n};\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38666/" ]
299,806
<p>I'd like to have my Eclipse plugin cause a URL to be opened by the users' default browser. This seems like pretty standard behavior, but I haven't been able to find any docs on how to do this.</p> <p>Can anyone help?</p>
[ { "answer_id": 300143, "author": "John Stoneham", "author_id": 2040146, "author_profile": "https://Stackoverflow.com/users/2040146", "pm_score": 4, "selected": true, "text": "final IWebBrowser browser = PlatformUI.getWorkbench().getBrowserSupport().createBrowser( ... );\nbrowser.openURL(url);\n" }, { "answer_id": 301309, "author": "zvikico", "author_id": 2823, "author_profile": "https://Stackoverflow.com/users/2823", "pm_score": 4, "selected": false, "text": "PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL(\"http://www.example.com/\"));\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4465/" ]
299,811
<p>I'm reloading a web page that has the following code:</p> <pre><code>&lt;label for="showimage"&gt;Show Image&lt;/label&gt; &lt;input id="showimage" name="showimage" type="checkbox" value="1" /&gt; </code></pre> <p>Even though the HTML stays sent to the browser is the same for each reload of the page, the checkbox always takes on the checked value when a reload was performed. In other words, if the user checks the checkbox and reloads, the checkbox is still checked.</p> <p>Is there some caching going on here? </p> <p><strong>Edit</strong>: I tried Gordon Bell's solution below and find that this is still happening even after removing the value="1". Anything else I might be missing?</p> <pre><code>&lt;label for="showimage"&gt;Show Image&lt;/label&gt; &lt;input id="showimage" name="showimage" type="checkbox" /&gt; </code></pre>
[ { "answer_id": 299849, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 6, "selected": true, "text": "Cache-Control: no-store\n" }, { "answer_id": 301943, "author": "Aleksandar", "author_id": 29511, "author_profile": "https://Stackoverflow.com/users/29511", "pm_score": 0, "selected": false, "text": "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\"> \n<META HTTP-EQUIV=\"Expires\" CONTENT=\"-1\">\n" }, { "answer_id": 471140, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 8, "selected": false, "text": "autocomplete=\"off\"" }, { "answer_id": 1123382, "author": "RainChen", "author_id": 130353, "author_profile": "https://Stackoverflow.com/users/130353", "pm_score": 5, "selected": false, "text": "$(\":checkbox\").attr(\"autocomplete\", \"off\");\n" }, { "answer_id": 46084245, "author": "Mohamed Gomah", "author_id": 4171618, "author_profile": "https://Stackoverflow.com/users/4171618", "pm_score": 0, "selected": false, "text": "<form>\n<checkbox>\n<reset>\n</form>\n\n$(reset).trigger(\"click\");//to clear the cache and input \n$(checkbox).trigger(\"click\");//to mark checkbox\n" }, { "answer_id": 56759837, "author": "cmshnrblu", "author_id": 8162220, "author_profile": "https://Stackoverflow.com/users/8162220", "pm_score": 2, "selected": false, "text": " document.getElementById('formId').reset();\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4883/" ]
299,814
<p>I'm trying to setup an alert to let me know via email (SMTP) when free disk space on one of my servers is less than a specified value. To do this I'm using PerfMon alerts, as described at <a href="http://support.microsoft.com/kb/324796" rel="nofollow noreferrer">MSFT Technet</a>. I have the alert working and writing to the system log, but when I try to set it to 'Run Program' it fails. The log alert fires but the program fails.</p> <p>The program I'm using is a small C# app I wrote to send an smtp email. I have tested the app independently from this server, running it manually and it works fine, without any user interaction (console app). But when I have it set to run via the alert trigger it fails.</p>
[ { "answer_id": 299849, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 6, "selected": true, "text": "Cache-Control: no-store\n" }, { "answer_id": 301943, "author": "Aleksandar", "author_id": 29511, "author_profile": "https://Stackoverflow.com/users/29511", "pm_score": 0, "selected": false, "text": "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\"> \n<META HTTP-EQUIV=\"Expires\" CONTENT=\"-1\">\n" }, { "answer_id": 471140, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 8, "selected": false, "text": "autocomplete=\"off\"" }, { "answer_id": 1123382, "author": "RainChen", "author_id": 130353, "author_profile": "https://Stackoverflow.com/users/130353", "pm_score": 5, "selected": false, "text": "$(\":checkbox\").attr(\"autocomplete\", \"off\");\n" }, { "answer_id": 46084245, "author": "Mohamed Gomah", "author_id": 4171618, "author_profile": "https://Stackoverflow.com/users/4171618", "pm_score": 0, "selected": false, "text": "<form>\n<checkbox>\n<reset>\n</form>\n\n$(reset).trigger(\"click\");//to clear the cache and input \n$(checkbox).trigger(\"click\");//to mark checkbox\n" }, { "answer_id": 56759837, "author": "cmshnrblu", "author_id": 8162220, "author_profile": "https://Stackoverflow.com/users/8162220", "pm_score": 2, "selected": false, "text": " document.getElementById('formId').reset();\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32474/" ]
299,851
<p>CodeIgniter allows access to POSTed data via:</p> <pre><code>$this-&gt;input-&gt;post('input_name'); </code></pre> <p>where 'input_name' is the name of a form field. This works well for a static form where each input name in known ahead of time.</p> <p>In my case, I am loading a collection of key/value pairs from the database. The form contains a text input for each key/value pair.</p> <p>I am wondering, <strong>is there a way to get an array of posted data via the CodeIgniter api?</strong></p> <p>Thanks!</p>
[ { "answer_id": 299865, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 4, "selected": true, "text": "array_keys($_POST)" }, { "answer_id": 299873, "author": "Tom Haigh", "author_id": 22224, "author_profile": "https://Stackoverflow.com/users/22224", "pm_score": 1, "selected": false, "text": "foreach ($arrayFromDb as $key => $value) {\n $newValue = $this->input->post($key);\n}\n" }, { "answer_id": 3172492, "author": "Poelinca Dorin", "author_id": 382809, "author_profile": "https://Stackoverflow.com/users/382809", "pm_score": 1, "selected": false, "text": "$array_db_columns = $this->db->query('SHOW COLUMNS FROM ci_props');\n $array_db_columns = $array_db_columns->result_array();\n $array_save_values = array();\n foreach ( $array_db_columns as $value )\n {\n $array_save_values[$value['Field']] = $this->input->post($value['Field']);\n }\n $this->db->insert('props', $array_save_values); $this->db->where('id',$id); $this->db->update('props',$array_save_values);" }, { "answer_id": 5903207, "author": "Harpreet Bhatia", "author_id": 156909, "author_profile": "https://Stackoverflow.com/users/156909", "pm_score": 3, "selected": false, "text": "foreach($this->input->post() as $key => $val) { echo \"<p>Key: \".$key. \" Value:\" . $val . \"</p>\\n\"; } \n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3238/" ]
299,869
<p>I am using a ResourceDictionary, but I would like to be able to look up the value or the key with the other item. Each is always unique, so that is not a problem. Is there a type that has this double sided lookup feature?</p>
[ { "answer_id": 299878, "author": "Craig Wilson", "author_id": 25333, "author_profile": "https://Stackoverflow.com/users/25333", "pm_score": 4, "selected": true, "text": "public class DoubleLookup<TKey, TValue>\n{\n private IDictionary<TKey, TValue> keys;\n private IDictionary<TValue, TKey> values;\n\n //stuff...\n\n public void Add(TKey key, TValue value)\n {\n this.keys.Add(key, value);\n this.values.Add(value, key);\n }\n\n public TKey GetKeyFromValue(TValue value)\n {\n return this.values[value];\n }\n\n public TValue GetValueFromKey(TKey key)\n {\n return this.keys[key];\n }\n\n\n}\n" }, { "answer_id": 300016, "author": "benjismith", "author_id": 22979, "author_profile": "https://Stackoverflow.com/users/22979", "pm_score": 2, "selected": false, "text": "Map<K, V> lookupTable = ...;\nMultiMap<V, K> reverseLookupTable = MapUtil.invert(lookupTable);\n\nV value = ...;\nif (reverseLookupTable.containsKey(value)) {\n Set<K> keys = reverseLookupTable.get(value);\n}\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30838/" ]
299,870
<p>How can I center an image horizontally and aligned to the bottom of the container at the same time? </p> <p>I have been able to center the image horizontally by its self. I have also been able to align the bottom of the container by its self. But I have not been able to do both at the same time. </p> <p>Here is what I have:</p> <pre><code>.image_block { width: 175px; height: 175px; position: relative; margin: 0 auto; } .image_block a img { position: absolute; bottom: 0; } &lt;div class="image_block"&gt; &lt;a href="..."&gt;&lt;img src="..." border="0"&gt;&lt;/a&gt; &lt;/div&gt; </code></pre> <p>That code aligns the image to the bottom of the div. What do I need to add/change to make it also center the image horizontally inside the div? The image size is not known before hand but it will be 175x175 or less.</p>
[ { "answer_id": 299884, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 0, "selected": false, "text": "position: relative;" }, { "answer_id": 299889, "author": "Pim Jager", "author_id": 35197, "author_profile": "https://Stackoverflow.com/users/35197", "pm_score": 2, "selected": false, "text": "margin-left:auto;\nmargin-right:auto;\n .image_block .image_block text-align:center;\n position:relative;" }, { "answer_id": 299929, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 7, "selected": true, "text": ".image_block {\n width: 175px;\n height: 175px;\n position: relative;\n}\n\n.image_block a {\n width: 100%;\n text-align: center;\n position: absolute;\n bottom: 0px;\n}\n\n.image_block img {\n/* nothing specific */\n}\n .image_block <a> .image_block text-align: center <a> .image_block <img> <a>" }, { "answer_id": 299930, "author": "workmad3", "author_id": 16035, "author_profile": "https://Stackoverflow.com/users/16035", "pm_score": 0, "selected": false, "text": ".image_block{\ntext-align: center;\nvertical-align: bottom;\n}\n" }, { "answer_id": 299933, "author": "One Crayon", "author_id": 38666, "author_profile": "https://Stackoverflow.com/users/38666", "pm_score": 2, "selected": false, "text": ".image_block {\n width: 175px;\n height: 175px;\n line-height: 175px;\n text-align: center;\n vertical-align: bottom;\n}\n vertical-align vertical-align line-height" }, { "answer_id": 14155983, "author": "vdua", "author_id": 1523245, "author_profile": "https://Stackoverflow.com/users/1523245", "pm_score": 5, "selected": false, "text": ".image_block {\n height: 175px;\n width:175px;\n position:relative;\n}\n.image_block a img{\n margin:auto; /* Required */\n position:absolute; /* Required */\n bottom:0; /* Aligns at the bottom */\n left:0;right:0; /* Aligns horizontal center */\n max-height:100%; /* images bigger than 175 px */\n max-width:100%; /* will be shrinked to size */ \n}\n" }, { "answer_id": 32996816, "author": "dfortun", "author_id": 1187735, "author_profile": "https://Stackoverflow.com/users/1187735", "pm_score": 0, "selected": false, "text": "#header2\n{\n display: table-cell;\n vertical-align: bottom;\n background-color:Red;\n}\n\n\n<div style=\"text-align:center; height:300px; width:50%;\" id=\"header2\">\n<div class=\"right\" id=\"header-content2\">\n <p>this is a test</p>\n</div>\n</div>\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13778/" ]
299,876
<p>In some editors there exist plugins implementing a feature called "hungry backspace" or "hungry delete".</p> <p>If this mode is active in a text editor then one hit to the backspace key will automatically delete all whitespace chars backwards from the current cursor position up to the first non-whitespace character.</p> <p>For example, this feature exists for <a href="http://www.gnu.org/software/emacs/manual/html_node/ccmode/Hungry-WS-Deletion.html" rel="nofollow noreferrer">Emacs</a> and <a href="http://plugins.intellij.net/plugin/?id=162" rel="nofollow noreferrer">IntelliJ IDEA</a>.</p> <p>Does anyone know if it is also available in Eclipse?</p>
[ { "answer_id": 299944, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 2, "selected": false, "text": "function(); (4 spaces)\n function\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33433/" ]
299,895
<p>When I call this function, everything works, as long as I don't try to recursively call the function again. In other words if I uncomment the line:</p> <pre><code>GetChilds rsData("AcctID"), intLevel + 1 </code></pre> <p>Then the function breaks. </p> <pre><code>&lt;% Function GetChilds(ParentID, intLevel) Set rsData= Server.CreateObject("ADODB.Recordset") sSQL = "SELECT AcctID, ParentID FROM Accounts WHERE ParentID='" &amp; ParentID &amp;"'" rsData.Open sSQL, conDB, adOpenKeyset, adLockOptimistic If IsRSEmpty(rsData) Then Response.Write("Empty") Else Do Until rsData.EOF Response.Write rsData("AcctID") &amp; "&lt;br /&gt;" 'GetChilds rsData("AcctID"), intLevel + 1 rsData.MoveNext Loop End If rsData.close: set rsData = nothing End Function Call GetChilds(1,0) %&gt; </code></pre> <p>*Edited after feedback</p> <p>Thanks everyone,</p> <p>Other than the usual error:</p> <pre><code>Error Type: (0x80020009) Exception occurred. </code></pre> <p>I wasn't sure what was causing the problems. I understand that is probably due to a couple of factors.</p> <ol> <li>Not closing the connection and attempting to re-open the same connection.</li> <li>To many concurrent connections to the database.</li> </ol> <p>The database content is as follows:</p> <pre><code>AcctID | ParentID 1 Null 2 1 3 1 4 2 5 2 6 3 7 4 </code></pre> <p>The idea is so that I can have a Master Account with Child Accounts, and those Child Accounts can have Child Accounts of their Own. Eventually there will be Another Master Account with a ParentID of Null that will have childs of its own. With that in mind, am I going about this the correct way?</p> <p>Thanks for the quick responses.</p> <hr> <p>Thanks everyone,</p> <p>Other than the usual error:</p> <blockquote> <p>Error Type: (0x80020009) Exception occurred.</p> </blockquote> <p>I wasn't sure what was causing the problems. I understand that is probably due to a couple of factors.</p> <ol> <li>Not closing the connection and attempting to re-open the same connection.</li> <li>To many concurrent connections to the database.</li> </ol> <p>The database content is as follows:</p> <pre><code>AcctID | ParentID 1 Null 2 1 3 1 4 2 5 2 6 3 7 4 </code></pre> <p>The idea is so that I can have a Master Account with Child Accounts, and those Child Accounts can have Child Accounts of their Own. Eventually there will be Another Master Account with a ParentID of Null that will have childs of its own. With that in mind, am I going about this the correct way?</p> <p>Thanks for the quick responses.</p>
[ { "answer_id": 299908, "author": "devio", "author_id": 21336, "author_profile": "https://Stackoverflow.com/users/21336", "pm_score": 0, "selected": false, "text": "Function GetChilds(ParentID, intLevel)\nDim rsData, sSQL\nSet ...\n" }, { "answer_id": 299918, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 3, "selected": true, "text": "int intLevel" }, { "answer_id": 300131, "author": "jesusOmar", "author_id": 38678, "author_profile": "https://Stackoverflow.com/users/38678", "pm_score": 0, "selected": false, "text": "Function GetChilds(ParentID, intLevel)\n 'Open my Database Connection and Query the current Parent ID\n Set rsData= Server.CreateObject(\"ADODB.Recordset\")\n sSQL = \"SELECT AcctID, ParentID FROM Accounts WHERE ParentID='\" & ParentID &\"'\"\n rsData.Open sSQL, conDB, adOpenKeyset, adLockOptimistic\n 'If the Record Set is not empty continue\n If Not IsRSEmpty(rsData) Then\n Dim myAccts()\n ReDim myAccts(rsData.RecordCount)\n Dim i\n i = 0\n Do Until rsData.EOF\n Response.Write \"Account ID: \" & rsData(\"AcctID\") & \" ParentID: \" & rsData(\"ParentID\") & \"<br />\"\n 'Add the Childs of the current Parent ID to an array.\n myAccts(i) = rsData(\"AcctID\")\n i = i + 1\n rsData.MoveNext\n Loop\n 'Close the SQL connection and get it ready for reopen. (I know not the best way but hey I am just learning this stuff)\n rsData.close: set rsData = nothing\n 'For each Child found in the previous query, now lets get their childs.\n For i = 0 To UBound(myAccts)\n Call GetChilds(myAccts(i), intLevel + 1)\n Next\n End If\n End Function\n\n Call GetChilds(1,0)\n" }, { "answer_id": 15117947, "author": "mendel", "author_id": 1058214, "author_profile": "https://Stackoverflow.com/users/1058214", "pm_score": 0, "selected": false, "text": "...\nrsData.CursorLocation = adUseClient\nrsData.Open sSQL, conDB, adOpenKeyset, adLockOptimistic\nrsData.ActiveConnectcion = Nothing\n...\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38678/" ]
299,931
<p>I have been tasked with developing a solution that tracks changes to a database.</p> <p>For updates I need to capture:</p> <ul> <li>date of update</li> <li>old value</li> <li>new value</li> <li>field affected</li> <li>person doing change</li> <li>record id</li> <li>table record is in</li> </ul> <p>For deletes:</p> <ul> <li>date of delete</li> <li>person doing delete</li> <li>The title/description/id of record deleted. The tables I am tracking changes on all have a title or description field. I'd like to capture this before the record is deleted.</li> <li>table record was in</li> </ul> <p>For inserts:</p> <ul> <li>date of insert</li> <li>person doing change</li> <li>record id</li> <li>table record is in</li> </ul> <p>I've thought of a few ways to do this:</p> <ul> <li>I am using stored procedures for any updates/deletes/inserts. I would create a generic "tracking" table. It would have enough fields to capture all the data. I would then add another line in each stored proc to the effect of "Insert record into tracking table". <ul> <li>downside: all updates/deletes/inserts are all jumbled in the same table</li> <li>lots of NULLed fields</li> <li>how do I track batch updates/deletes/inserts? &lt;---- this might not be an issue. I don't really do any thing like this in the application.</li> <li>how do I capture the user making the update. The database just sees one account.</li> <li>edit a lot of existing code to edit.</li> </ul></li> <li>Lastly, I could create a trigger that is called after updates/deletes/inserts. Many of the same downsides as the first solution except: I would have to edit as much code. I am not sure how I would track updates. It doesn't look like there's a way using triggers to see recently updated records.</li> </ul> <p>I am using asp.net, C#, sql server 2005, iis6, windows 2003. I have no budget so sadly I can't buy anything to help me with this.</p> <p>Thanks for your answers!</p>
[ { "answer_id": 11559583, "author": "Nisarg Shah", "author_id": 1071338, "author_profile": "https://Stackoverflow.com/users/1071338", "pm_score": 2, "selected": false, "text": " CREATE TABLE te_Page([Id] [int] IDENTITY(1,1) NOT NULL, [Name] [varchar](200) NOT NULL, [Description] [varchar](200) NULL,[CreatedBy] [uniqueidentifier] NULL, [CreatedDate] [datetime] NOT NULL, [UpdatedBy] [uniqueidentifier] NULL, [UpdatedDate] [datetime] NULL, [IsDeleted] [bit] NULL, [RowHistory] [xml] NULL, CONSTRAINT [PK_tm_Page] PRIMARY KEY CLUSTERED ([Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]\n ALTER Trigger [dbo].[Trg_Te_Page] \n On [dbo].[te_Page] \n After Update \n As \n --If @@rowcount = 0 Or Update(RowHistory) \n --Return \n\n Declare @xml NVARCHAR(MAX) \n Declare @currentxml NVARCHAR(MAX) \n Declare @node NVARCHAR(MAX) \n Declare @ishistoryexists XML \n\n Declare @FormLineAttributeValueId int \n\n -- new Values \n Declare @new_Name varchar(200) \n Declare @new_Description varchar(200) \n\n Declare @new_CreatedBy UNIQUEIDENTIFIER \n Declare @new_CreatedDate DATETIME \n Declare @new_UpdatedBy UNIQUEIDENTIFIER \n Declare @new_UpdatedDate DATETIME \n Declare @new_IsDeleted BIT \n\n --old values \n Declare @old_Name varchar(200) \n Declare @old_Description varchar(200) \n\n Declare @old_CreatedBy UNIQUEIDENTIFIER \n Declare @old_CreatedDate DATETIME \n Declare @old_UpdatedBy UNIQUEIDENTIFIER \n Declare @old_UpdatedDate DATETIME \n Declare @old_IsDeleted BIT \n\n\n -- declare temp fmId \n Declare @fmId int \n -- declare cursor \n DECLARE curFormId cursor \n FOR select Id from INSERTED \n -- open cursor \n OPEN curFormId \n -- fetch row \n FETCH NEXT FROM curFormId INTO @fmId \n\n WHILE @@FETCH_STATUS = 0 \n BEGIN \n\n Select \n @FormLineAttributeValueId = Id, \n @old_Name = Name, \n @old_Description = [Description], \n\n @old_CreatedBy = CreatedBy, \n @old_CreatedDate =CreatedDate, \n @old_UpdatedBy =UpdatedBy, \n @old_UpdatedDate =UpdatedDate, \n @old_IsDeleted = IsDeleted, \n @currentxml = cast(RowHistory as NVARCHAR(MAX)) \n From DELETED where Id=@fmId \n\n\n\n Select \n @new_Name = Name, \n @new_Description = [Description], \n\n @new_CreatedBy = CreatedBy, \n @new_CreatedDate =CreatedDate, \n @new_UpdatedBy =UpdatedBy, \n @new_UpdatedDate =UpdatedDate, \n @new_IsDeleted = IsDeleted \n From INSERTED where Id=@fmId \n\n set @old_Name = Replace(@old_Name,'&','&amp;')\n set @old_Name = Replace(@old_Name,'>','&gt;') \n set @old_Name = Replace(@old_Name,'<','&lt;') \n set @old_Name = Replace(@old_Name,'\"','&quot;')\n set @old_Name = Replace(@old_Name,'''','&apos;') \n\n set @new_Name = Replace(@new_Name,'&','&amp;') \n set @new_Name = Replace(@new_Name,'>','&gt;') \n set @new_Name = Replace(@new_Name,'<','&lt;') \n set @new_Name = Replace(@new_Name,'\"','&quot;')\n set @new_Name = Replace(@new_Name,'''','&apos;') \n\n set @old_Description = Replace(@old_Description,'&','&amp;')\n set @old_Description = Replace(@old_Description,'>','&gt;') \n set @old_Description = Replace(@old_Description,'<','&lt;') \n set @old_Description = Replace(@old_Description,'\"','&quot;')\n set @old_Description = Replace(@old_Description,'''','&apos;') \n\n set @new_Description = Replace(@new_Description,'&','&amp;') \n set @new_Description = Replace(@new_Description,'>','&gt;') \n set @new_Description = Replace(@new_Description,'<','&lt;') \n set @new_Description = Replace(@new_Description,'\"','&quot;')\n set @new_Description = Replace(@new_Description,'''','&apos;') \n\n set @xml = '' \n\n BEGIN \n\n -- for Name \n If ltrim(rtrim(IsNull(@new_Name,''))) != ltrim(rtrim(IsNull(@old_Name,''))) \n set @xml = @xml + '<ColumnInfo ColumnName=\"Name\" OldValue=\"'+ @old_Name + '\" NewValue=\"' + @new_Name + '\"/>' \n\n -- for Description \n If ltrim(rtrim(IsNull(@new_Description,''))) != ltrim(rtrim(IsNull(@old_Description,''))) \n set @xml = @xml + '<ColumnInfo ColumnName=\"Description\" OldValue=\"'+ @old_Description + '\" NewValue=\"' + @new_Description + '\"/>' \n\n -- CreatedDate \n If IsNull(@new_CreatedDate,'') != IsNull(@old_CreatedDate,'') \n set @xml = @xml + '<ColumnInfo ColumnName=\"CreatedDate\" OldValue=\"'+ cast(isnull(@old_CreatedDate,'') as varchar(100)) + '\" NewValue=\"' + cast(isnull(@new_CreatedDate,'') as varchar(100)) + '\"/>' \n\n -- CreatedBy \n If cast(IsNull(@new_CreatedBy,'00000000-0000-0000-0000-000000000000')as varchar (36)) != cast(IsNull(@old_CreatedBy,'00000000-0000-0000-0000-000000000000')as varchar(36)) \n set @xml = @xml + '<ColumnInfo ColumnName=\"CreatedBy\" OldValue=\"'+ cast(IsNull(@old_CreatedBy,'00000000-0000-0000-0000-000000000000') as varchar(36)) + '\" NewValue=\"' + cast(isnull(@new_CreatedBy,'00000000-0000-0000-0000-000000000000') as varchar(36))+\n '\"/>' \n\n -- UpdatedDate \n If IsNull(@new_UpdatedDate,'') != IsNull(@old_UpdatedDate,'') \n set @xml = @xml + '<ColumnInfo ColumnName=\"UpdatedDate\" OldValue=\"'+ cast(IsNull(@old_UpdatedDate,'') as varchar(100)) + '\" NewValue=\"' + cast(IsNull(@new_UpdatedDate,'') as varchar(100)) + '\"/>' \n\n -- UpdatedBy \n If cast(IsNull(@new_UpdatedBy,'00000000-0000-0000-0000-000000000000') as varchar(36)) != cast(IsNull(@old_UpdatedBy,'00000000-0000-0000-0000-000000000000') as varchar(36)) \n set @xml = @xml + '<ColumnInfo ColumnName=\"UpdatedBy\" OldValue=\"'+ cast(IsNull(@old_UpdatedBy,'00000000-0000-0000-0000-000000000000') as varchar(36)) + '\" NewValue=\"' + cast(IsNull(@new_UpdatedBy,'00000000-0000-0000-0000-000000000000') as varchar(36))+\n '\"/>' \n\n -- IsDeleted \n If cast(IsNull(@new_IsDeleted,'') as varchar(10)) != cast(IsNull(@old_IsDeleted,'') as varchar(10)) \n set @xml = @xml + '<ColumnInfo ColumnName=\"IsDeleted\" OldValue=\"'+ cast(IsNull(@old_IsDeleted,'') as varchar(10)) + '\" NewValue=\"' + cast(IsNull(@new_IsDeleted,'') as varchar(10)) + '\" />' \n\n END \n\n Set @xml = '<RowInfo TableName=\"te_Page\" UpdatedBy=\"' + cast(IsNull(@new_UpdatedBy,'00000000-0000-0000-0000-000000000000') as varchar(50)) + '\" UpdatedDate=\"' + Convert(Varchar(20),GetDate()) + '\">' + @xml + '</RowInfo>' \n Select @ishistoryexists = RowHistory From DELETED \n\n --print @ishistoryexists \n\n\n If @ishistoryexists is null \n Begin \n Set @xml = '<History>' + @xml + '</History>' \n Update te_Page \n Set \n RowHistory = @xml \n Where \n Id = @FormLineAttributeValueId \n\n End \n\n Else \n Begin \n set @xml = REPLACE(@currentxml, '<History>', '<History>' + @xml) \n Update te_Page \n Set \n RowHistory = @xml \n Where \n Id = @FormLineAttributeValueId \n End \n\n\n FETCH NEXT FROM curFormId INTO @fmId \n END \n\n\n CLOSE curFormId \n DEALLOCATE curFormId \n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38613/" ]
299,940
<p>The following code works for me:</p> <pre><code>var webProxy = WebProxy.GetDefaultProxy(); webProxy.UseDefaultCredentials = true; WebRequest.DefaultWebProxy = webProxy; </code></pre> <p>Unfortunately, <code>WebProxy.GetDefaultProxy()</code> is deprecated. What else should I be doing?</p> <p>(using app.config to set the defaultProxy settings is not allowed in my deployment)</p>
[ { "answer_id": 300738, "author": "Martin Hollingsworth", "author_id": 29491, "author_profile": "https://Stackoverflow.com/users/29491", "pm_score": 7, "selected": true, "text": "WebRequest webRequest = WebRequest.Create(\"http://stackoverflow.com/\");\nwebRequest.Proxy = new WebProxy(\"http://proxyserver:80/\",true);\n WebRequest.DefaultWebProxy = new WebProxy(\"http://proxyserver:80/\",true);\n webRequest.Proxy.GetProxy(new Uri(\"http://google.com.au\")) webRequest.Proxy WebRequest.DefaultWebProxy = null new DefaultProxy()" }, { "answer_id": 4718638, "author": "Jim Scott", "author_id": 94043, "author_profile": "https://Stackoverflow.com/users/94043", "pm_score": 0, "selected": false, "text": "WebRequest.GetSystemWebProxy();\n" }, { "answer_id": 8180854, "author": "Bellarmine Head", "author_id": 98689, "author_profile": "https://Stackoverflow.com/users/98689", "pm_score": 7, "selected": false, "text": "<system.net>\n <defaultProxy useDefaultCredentials=\"true\" />\n</system.net>\n" }, { "answer_id": 11429866, "author": "André", "author_id": 1517351, "author_profile": "https://Stackoverflow.com/users/1517351", "pm_score": 3, "selected": false, "text": "UseDefaultCredentials System.Reflection.PropertyInfo pInfo = System.Net.WebRequest.DefaultWebProxy.GetType().GetProperty(\"WebProxy\", \nSystem.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);\n\n((System.Net.WebProxy)pInfo.GetValue(System.Net.WebRequest.DefaultWebProxy, null)).UseDefaultCredentials = true;\n" }, { "answer_id": 16067719, "author": "jyz", "author_id": 437095, "author_profile": "https://Stackoverflow.com/users/437095", "pm_score": 1, "selected": false, "text": " IWebProxy proxy = WebRequest.GetSystemWebProxy();\n proxy.Credentials = CredentialCache.DefaultCredentials;\n\n WebClient wc = new WebClient();\n wc.UseDefaultCredentials = true;\n wc.Proxy = proxy;\n" }, { "answer_id": 19086729, "author": "Thariq Nugrohotomo", "author_id": 1878585, "author_profile": "https://Stackoverflow.com/users/1878585", "pm_score": 4, "selected": false, "text": "DefaultWebProxy UseDefaultCredentials = true WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultNetworkCredentials;\n WebRequest" }, { "answer_id": 20516530, "author": "smack", "author_id": 1455584, "author_profile": "https://Stackoverflow.com/users/1455584", "pm_score": 2, "selected": false, "text": " WebRequest.DefaultWebProxy.Credentials = new NetworkCredential(\"ProxyUsername\", \"ProxyPassword\");\n" }, { "answer_id": 41848189, "author": "Daniel Weber", "author_id": 7468236, "author_profile": "https://Stackoverflow.com/users/7468236", "pm_score": 2, "selected": false, "text": "<system.net>\n <defaultProxy enabled=\"true\" useDefaultCredentials=\"true\">\n <proxy usesystemdefault=\"True\" />\n </defaultProxy>\n</system.net>\n" }, { "answer_id": 64799026, "author": "Tolga", "author_id": 181296, "author_profile": "https://Stackoverflow.com/users/181296", "pm_score": 0, "selected": false, "text": "[System.Net.WebRequest]::GetSystemWebProxy().Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials;\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36687/" ]
299,942
<p>I have a string of test like this:</p> <pre><code>&lt;customtag&gt;hey&lt;/customtag&gt; </code></pre> <p>I want to use a RegEx to modify the text between the "customtag" tags so that it might look like this:</p> <pre><code>&lt;customtag&gt;hey, this is changed!&lt;/customtag&gt; </code></pre> <p>I know that I can use a MatchEvaluator to modify the text, but I'm unsure of the proper RegEx syntax to use. Any help would be much appreciated.</p>
[ { "answer_id": 299951, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 3, "selected": false, "text": "<customtag> <" }, { "answer_id": 299966, "author": "Tjofras", "author_id": 37486, "author_profile": "https://Stackoverflow.com/users/37486", "pm_score": 5, "selected": true, "text": "<customtag>(.+?)</customtag>" }, { "answer_id": 301238, "author": "Jan Goyvaerts", "author_id": 33358, "author_profile": "https://Stackoverflow.com/users/33358", "pm_score": 1, "selected": false, "text": "<customtag>[^<>]*</customtag>\n" }, { "answer_id": 2872111, "author": "sajoshi", "author_id": 193078, "author_profile": "https://Stackoverflow.com/users/193078", "pm_score": 0, "selected": false, "text": "//This is to replace all HTML Text\n\nvar re = new RegExp(\"<[^>]*>\", \"g\");\n\nvar x2 = Content.replace(re,\"\");\n\n//This is to replace all &nbsp;\n\nvar x3 = x2.replace(/\\u00a0/g,'');\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/343/" ]
299,949
<p>Does SQL Server's (2000) <strong>Soundex function work on Asian character sets</strong>? I used it in a query and it appears to have not worked properly but I realize that it could be because I don't know how to read Chinese...</p> <p>Furthermore, are there any other languages where the function might have trouble working on? (Russian for example)</p> <p>Thank you,<br>Frank</p>
[ { "answer_id": 68911994, "author": "HGF", "author_id": 1901545, "author_profile": "https://Stackoverflow.com/users/1901545", "pm_score": 0, "selected": false, "text": "SELECT" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18196/" ]
299,950
<p>I am trying to use a Generic Linked List to hold some WorkFlow steps in my application. Here is how I'm persisting it to my database.</p> <p>OrderID&nbsp;&nbsp;WorkFlowStepID&nbsp;&nbsp;ParentWorkFlowStepID<br/> 178373&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NULL<br/> 178373&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1<br/> 178373&nbsp;&nbsp;&nbsp;&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2<br/></p> <p>I get this dataset back in a datareader object. I then loop through the datareader and create a WorkFlowStep object that includes a WorkFlowStepID property and a ParentWorkFlowStepID property. I add the first object to my LinkedList by using the .AddFirst() method. My next idea is to create the next object and then insert it after the object in the LinkedList where it's WorkFlowStepID is equal to the new object's ParentWorkFlowStepID. I can't figure out of to find the object in the LinkedList. The find() method is asking for a value, but I don't understand what value it is, or how I can find it.</p>
[ { "answer_id": 299979, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "Find LinkedListNode<T> public static IEnumerable<LinkedListNode<T>> GetNodes<T>(this LinkedList<T> list)\n{\n LinkedListNode<T> current = list.First;\n while (current != null)\n {\n yield return current;\n current = current.Next;\n }\n}\n var node = list.GetNodes().FirstOrDefault(x.Value.WorkFlowerStepID = parentWorkFlowStepID);\nif (node != null)\n{\n list.AddAfter(node, newItem);\n}\nelse\n{\n // Whatever. Add to tail?\n}\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37347/" ]
299,956
<p>I have a CompositeDataBoundControl and im trying to add a ItemCommand to it, ala the System.Web.UI.WebControls.Repeater - so like a numpty, I just thought if I reflector'ed and added the code like so, it should work:</p> <pre><code>private static readonly object EventItemCommand = new object(); protected override bool OnBubbleEvent(object sender, EventArgs e) { // throw new Exception(); bool flag = false; if (e is RepeaterCommandEventArgs) { this.OnItemCommand((RepeaterCommandEventArgs)e); flag = true; } return flag; } protected virtual void OnItemCommand(RepeaterCommandEventArgs e) { RepeaterCommandEventHandler handler = (RepeaterCommandEventHandler)base.Events[EventItemCommand]; if (handler != null) { handler(this, e); } } public event RepeaterCommandEventHandler ItemCommand { add { base.Events.AddHandler(EventItemCommand, value); } remove { base.Events.RemoveHandler(EventItemCommand, value); } } </code></pre> <p>Unfortunatly, even though I have the event bound, it does not seem to fire. Iv tried to go down the route of IPostBackEventHandler, but its still not quite right (I can fire an empty event off with no args, but I cant see a decent way to call the OnItemCommand with the RepeaterCommandEventArgs</p> <p>Any ideas how to get this to work? </p> <p>Iv been sitting on the office for the last 4 hours trying to get this to work! Help!</p>
[ { "answer_id": 300345, "author": "Atanas Korchev", "author_id": 10141, "author_profile": "https://Stackoverflow.com/users/10141", "pm_score": 3, "selected": true, "text": "protected override bool OnBubbleEvent(object source, EventArgs e)\n{\n if (e is CommandEventArgs)\n {\n RepeaterCommandEventArgs args = new RepeaterCommandEventArgs(this, source, (CommandEventArgs) e);\n base.RaiseBubbleEvent(this, args);\n return true;\n }\n return false;\n}\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1276/" ]
299,969
<p>I have form with 2 DDL named</p> <p>State and City</p> <p>State:</p> <pre><code>&lt;asp:UpdatePanel ID="States" runat="server" UpdateMode="Conditional"&gt; &lt;Triggers&gt; &lt;asp:AsyncPostBackTrigger ControlID="States"EventName="SelectedIndexChanged" /&gt; &lt;/Triggers&gt; &lt;ContentTemplate&gt; &lt;asp:DropDownList ID="States" runat="server" AutoPostBack="True" DataSourceID="StatesObjectDataSource" AppendDataBoundItems="true" onselectedindexchanged="States_SelectedIndexChanged"&gt; &lt;asp:ListItem Value="-1" Text="- None -"/&gt; &lt;/asp:DropDownList&gt; &lt;asp:ObjectDataSource ID="StatesObjectDataSource" runat="server" onselecting="StatesObjectDataSource_Selecting" SelectMethod="GetStates" TypeName="Something"&gt; &lt;/asp:ObjectDataSource&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; </code></pre> <p>City:</p> <pre><code>&lt;asp:DropDownList ID="Cities" runat="server"&gt; &lt;/asp:DropDownList&gt; </code></pre> <p>When they choose a state I want to populate the Cities DDL with all the cities for that state.</p> <p>In code behind I am able to get to </p> <pre><code>States_SelectedIndexChanged(object sender, EventArgs e) </code></pre> <p>and i try to populate the Cities DDL by this</p> <pre><code>Cities.Items.Add(new ListItem(city,city)); </code></pre> <p>However, I do not see my Cities DDL populated</p>
[ { "answer_id": 300452, "author": "Chris Marisic", "author_id": 37055, "author_profile": "https://Stackoverflow.com/users/37055", "pm_score": 2, "selected": false, "text": "<asp:DropDownList runat=\"server\" ID=\"ddlCity\" DataValueField=\"Key\" DataTextField=\"Value\">\n</asp:DropDownList>\n private List<KeyValuePair<string, string>> ListData\n{\n get { return (List<KeyValuePair<string, string>>) (ViewState[\"ListData\"] ?? \n (ViewState[\"ListData\"] = new List<KeyValuePair<string, string>>())); }\n set { ViewState[\"ListData\"] = value; }\n}\n\nprotected void States_SelectedIndexChanged_SelectedIndexChanged(object sender, EventArgs e)\n{\n ListData.Add(new KeyValuePair<string, string>(ddlCitys.SelectedValue, ddlCitys.SelectedValue));\n ddlCitys.DataSource = ListData;\n ddlCitys.DataBind();\n}\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38230/" ]
299,978
<p>I am in the process of creating an XML Schema and one of my values is a year. As such, I'd like to ensure that all values have exactly 4 characters. To do so, I am using the following syntax:</p> <pre><code>&lt;xs:element name="publish_year" maxOccurs="1"&gt; &lt;xs:simpleType&gt; &lt;xs:restriction base="xs:positiveInteger"&gt; &lt;xs:totalDigits value="4"/&gt; &lt;/xs:restriction&gt; &lt;/xs:simpleType&gt; &lt;/xs:element&gt; </code></pre> <p>If I'm understanding "totalDigits" correctly, someone could pass in a "publish_year" value of "2008" or "200". Both would be valid. As such, how can I structure my XSD to ensure 4 digits are required? At first blush, I'm guessing I'd use a regex, but I'd like to know if I'm overlooking something that's already baked in (like "totalDigits")</p> <p>UPDATE:</p> <p>I went with the following solution. It may be overkill, but it gets the point across:</p> <pre><code>&lt;xs:simpleType&gt; &lt;xs:restriction base="xs:positiveInteger"&gt; &lt;xs:totalDigits value="4" fixed="true"/&gt; &lt;xs:minInclusive value="1900"/&gt; &lt;xs:pattern value="^([1][9]\d\d|[2]\d\d\d)$"/&gt; &lt;/xs:restriction&gt; &lt;/xs:simpleType&gt; </code></pre>
[ { "answer_id": 299988, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 4, "selected": true, "text": "<xs:minInclusive value=\"1900\"/> et <xs:maxInclusive value=\"2008\"/>\n fixed <xs:totalDigits value=\"4\" fixed=\"true\" />\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10040/" ]
299,986
<p>I'm working with PHP &amp; mySQL. I've finally got my head around source control and am quite happy with the whole development (testing) v production v repository thing for the PHP part.</p> <p>My new quandary is what to do with the database. Do I create one for the test environment and one for the production environment? I currently have just the one which both environments use, leaving my test data sitting there. I kind of feel that I should have two, but I'm nervous in terms of making sure that my production database looks and feels exactly the same as my test one.</p> <p>Any thoughts on which way to go? And, if you think the latter, what the best way is to keep the two databases the same (apart from the data, of course...)?</p>
[ { "answer_id": 300004, "author": "John MacIntyre", "author_id": 29043, "author_profile": "https://Stackoverflow.com/users/29043", "pm_score": 0, "selected": false, "text": "deploy.001.description.sql\ndeploy.002.description.sql\ndeploy.003.description.sql\n... etc..\n \\deploy.YYMMDD\\\n" }, { "answer_id": 7683054, "author": "JW.", "author_id": 205814, "author_profile": "https://Stackoverflow.com/users/205814", "pm_score": 0, "selected": false, "text": "production db development db production db development db local db dev db live-read-only db connection local db live-readonly db dev db production db local db live-read-only db" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1444/" ]
299,987
<p>How can I select the good method (I have in the example below show 2 differents way that doesn't work). I was using instead of a variable of type Object with a IF and IS to do the job but I am trying to avoid using Object and boxing/unboxing. So I thought that Generic could do the job but I am stuck here.</p> <p>Here is a small snippet of code that illustrate my question:</p> <pre><code>class Program { static void Main(string[] args) { Parser p = new Parser(); ObjectType1 o1 = new ObjectType1(); p.execute(o1); Console.Read(); } } class Parser { public T execute&lt;T&gt;(T obj) { /* if (obj is ObjectType1) this.action((ObjectType1)obj); else if (obj is ObjectType2) this.action((ObjectType2)obj); */ this.action(obj); return obj; } private void action(ObjectType1 objectType1) { Console.WriteLine("1"); } private void action(ObjectType2 objectType2) { Console.WriteLine("2"); } } class ObjectType1 { } class ObjectType2 { } </code></pre> <h2>Update</h2> <p>I do not want interface and class. Sorry. I knew that it's not the goal of the question.</p> <p>Casting with (ObjectType)obj doesn't work but if you do :</p> <pre><code> if (obj is ObjectType1) this.action(obj as ObjectType1); else if (obj is ObjectType2) this.action(obj as ObjectType1); </code></pre> <p>it works... why?</p> <p>And... I cannot overload for all type the execute method because this method is from an Interface. This is why all need to be called from this method.</p>
[ { "answer_id": 300008, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "using System;\n\nclass Test\n{ \n static void Main()\n {\n string x = \"hello\";\n string y = string.Copy(x);\n\n Console.WriteLine(x==y); // Overload used\n Compare(x, y);\n }\n\n static void Compare<T>(T x, T y) where T : class\n {\n Console.WriteLine(x == y); // Reference comparison\n }\n}\n" }, { "answer_id": 300010, "author": "Rob Prouse", "author_id": 30827, "author_profile": "https://Stackoverflow.com/users/30827", "pm_score": 2, "selected": false, "text": "public T execute<T>(T obj)\n{\n this.action((T)obj);\n return obj;\n}\n public T execute<T>(T obj)\n{\n this.action(obj as T);\n return obj;\n}\n" }, { "answer_id": 300020, "author": "workmad3", "author_id": 16035, "author_profile": "https://Stackoverflow.com/users/16035", "pm_score": 2, "selected": false, "text": "interface IAction\n{\n void action();\n}\n\nclass ObjectType1 : IAction\n{\n void action() {\n Console.WriteLine(\"1\");\n }\n}\n\nclass ObjectType2 : IAction\n{\n void action() {\n Console.WriteLine(\"2\");\n }\n}\n\nclass Parser\n{\n public IAction execute(IAction obj)\n {\n obj.action();\n return obj;\n }\n}\n" }, { "answer_id": 300041, "author": "BCS", "author_id": 1343, "author_profile": "https://Stackoverflow.com/users/1343", "pm_score": 0, "selected": false, "text": "public T execute<T>(T obj) where : /* somthing */\n{\n}\n" }, { "answer_id": 300068, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 2, "selected": false, "text": "class Parser\n{\n public ObjectType1 action(ObjectType1 objectType1)\n {\n Console.WriteLine(\"1\");\n return objectType1;\n }\n public ObjectType2 action(ObjectType2 objectType2)\n {\n Console.WriteLine(\"2\");\n return objectType2;\n }\n}\n\nclass ObjectType1 { }\nstruct ObjectType2 { }\n Parser p = new Parser();\np.action(new ObjectType1());\np.action(new ObjectType2());\n" }, { "answer_id": 300105, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 1, "selected": false, "text": "public T execute<T>(T obj) \n{ \n this.action(obj);\n return obj;\n}\n public int execute(int obj) \n { \n this.action(obj);\n return obj;\n }\n\n public void action(int obj)\n {\n obj = obj + 1;\n }\n int x = p.execute(1);\n" }, { "answer_id": 300135, "author": "Guge", "author_id": 37771, "author_profile": "https://Stackoverflow.com/users/37771", "pm_score": 0, "selected": false, "text": " public object execute(object obj) \n {\n MethodInfo m = typeof(Parser).GetMethod(\n \"action\", \n BindingFlags.Instance | BindingFlags.NonPublic, \n null, \n new Type[] { obj.GetType() }, \n null);\n m.Invoke(this, new object[] { obj });\n return obj; \n } \n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13913/" ]
299,992
<p>I'm working on some Silverlight controls and I would like to explicitly handle the way they appear in Blend. Specifically, these controls have dependencies that are initialized at runtime, and thus throw exceptions in the designer. But even in the absence of the exception, I would like to make them appear a certain way in Blend.</p> <p>I know that this is possible with WPF (using myassembly.VisualStudio.Design.dll), but I haven't been able to find info on doing this with Silverlight.</p> <p>I have seen the hack described <a href="http://blogs.msdn.com/expression/archive/2008/10/27/simulating-sample-data-in-blend-2-sp1.aspx" rel="nofollow noreferrer">here</a> that checks does this:</p> <pre><code>bool designTime = (System.Windows.Browser.HtmlPage.IsEnabled == false); </code></pre> <p>I would prefer a more explicit solution though.</p>
[ { "answer_id": 399557, "author": "Michael S. Scherotter", "author_id": 27306, "author_profile": "https://Stackoverflow.com/users/27306", "pm_score": 2, "selected": false, "text": "DesignerProperties using System.ComponentModel.DesignerProperties\n\nif (DesignerProperties.GetIsInDesignMode(this))\n{\n}\n this DependencyObject" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299992", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6855/" ]
299,998
<p>I have got a template class as follows:</p> <pre><code>class MyClass&lt;T&gt; { T field; public void myMethod() { field = new T(); // gives compiler error } } </code></pre> <p>How do I create a new instance of T in my class?</p>
[ { "answer_id": 300013, "author": "erickson", "author_id": 3474, "author_profile": "https://Stackoverflow.com/users/3474", "pm_score": 8, "selected": true, "text": "T Object T Supplier<T> class MyClass<T> {\n\n private final Supplier<? extends T> ctor;\n\n private T field;\n\n MyClass(Supplier<? extends T> ctor) {\n this.ctor = Objects.requireNonNull(ctor);\n }\n\n public void myMethod() {\n field = ctor.get();\n }\n\n}\n MyClass<StringBuilder> it = new MyClass<>(StringBuilder::new);\n Class<T> class MyClass<T> {\n\n private final Constructor<? extends T> ctor;\n\n private T field;\n\n MyClass(Class<? extends T> impl) throws NoSuchMethodException {\n this.ctor = impl.getConstructor();\n }\n\n public void myMethod() throws Exception {\n field = ctor.newInstance();\n }\n\n}\n" }, { "answer_id": 300526, "author": "Dan Hodge", "author_id": 38739, "author_profile": "https://Stackoverflow.com/users/38739", "pm_score": 4, "selected": false, "text": "interface MyFactory<T> \n{\n T newObject();\n}\n\nclass MyClass<T> \n{\n T field;\n public void myMethod(MyFactory<T> factory)\n {\n field = factory.newObject()\n }\n}\n" }, { "answer_id": 303553, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": false, "text": "public interface Builder<T> {\n public T build();\n}\n Builder<T> T T" }, { "answer_id": 47364949, "author": "Kevendra", "author_id": 1469995, "author_profile": "https://Stackoverflow.com/users/1469995", "pm_score": -1, "selected": false, "text": " try {\n t = classOfT.newInstance();//new T(); NOTE: type parameter T cannot be instantiated directly\n } catch (Exception e) {\n e.printStackTrace();\n }\n" }, { "answer_id": 65334783, "author": "Zakir", "author_id": 11516148, "author_profile": "https://Stackoverflow.com/users/11516148", "pm_score": -1, "selected": false, "text": "{field = (T) new Object();}\n" }, { "answer_id": 68899592, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "T static class MyClass<T> {\n Class<?> clazz;\n\n @SafeVarargs\n public MyClass(T... dummy) {\n if (dummy.length > 0)\n throw new IllegalArgumentException(\"Do not specify arguments\");\n clazz = dummy.getClass().componentType();\n }\n\n @Override\n public String toString() {\n return \"MyClass<T = \" + clazz.getName() + \">\";\n }\n}\n\npublic static void main(String[] args) {\n MyClass<String> s = new MyClass<>();\n System.out.println(s);\n Object i = new MyClass<Integer>();\n System.out.println(i);\n}\n MyClass<T = java.lang.String>\nMyClass<T = java.lang.Integer>\n T clazz.getConstructor().newInstance();\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36858/" ]
299,999
<p>Here's the code:</p> <pre><code>render :file =&gt; @somedir + "/blah.xml" </code></pre> <p>...but the resulting MIME type is text/html when I check in FireBug. How do I specify a MIME type in this case?</p>
[ { "answer_id": 300257, "author": "blindgaenger", "author_id": 38045, "author_profile": "https://Stackoverflow.com/users/38045", "pm_score": 5, "selected": false, "text": "class FileController < ApplicationController\n\n def index\n filename = 'some.xml'\n\n extname = File.extname(filename)[1..-1]\n mime_type = Mime::Type.lookup_by_extension(extname)\n content_type = mime_type.to_s unless mime_type.nil?\n\n # 1\n #headers['Content-Type'] = content_type\n #render :file => filename\n\n # 2\n render :file => filename, :content_type => content_type\n end\n\nend\n" }, { "answer_id": 300258, "author": "Honza", "author_id": 8621, "author_profile": "https://Stackoverflow.com/users/8621", "pm_score": 2, "selected": false, "text": "headers[\"Content-Type\"] = \"text/xml\"\n" }, { "answer_id": 1103206, "author": "gerrit", "author_id": 44198, "author_profile": "https://Stackoverflow.com/users/44198", "pm_score": 4, "selected": false, "text": "render :file => @somedir + \"/blah.xml\", :content_type => Mime::XML\n" }, { "answer_id": 51355158, "author": "konyak", "author_id": 1408866, "author_profile": "https://Stackoverflow.com/users/1408866", "pm_score": 0, "selected": false, "text": "render file: @somedir + \"/blah.xml\", mime_type: Mime::Type.lookup(\"text/xml\") \n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/299999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38684/" ]
300,055
<p>In C# if I want to convert a double (1.71472) to an int then I get the answer 2. If I do this in Java using intValue() method, I get 1 as the answer.</p> <p>Does Java round down on conversions?</p> <p>Why do the Java API docs have such scant information about their classes i.e. </p> <blockquote> <p>Returns the value of the specified number as an int. This may involve rounding or truncation.</p> </blockquote> <p>A bit more info about the rounding would have been helpful!</p>
[ { "answer_id": 300067, "author": "erickson", "author_id": 3474, "author_profile": "https://Stackoverflow.com/users/3474", "pm_score": 3, "selected": false, "text": "Number" }, { "answer_id": 300074, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "Convert.ToInt32 double d = 1.71472;\nint x = (int) d; // x = 1\nint y = Convert.ToInt32(d); // y = 2\n Number Double BigDecimal" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5175/" ]
300,078
<p>I know this specific question has been <a href="https://stackoverflow.com/questions/185235/jquery-tabs-getting-newly-selected-index">asked before</a>, but I am not getting any results using the <code>bind()</code> event on the <code>jQuery UI Tabs</code> plugin. </p> <p>I just need the <code>index</code> of the newly selected tab to perform an action when the tab is clicked. <code>bind()</code> allows me to hook into the select event, but my usual method of getting the currently selected tab does not work. It returns the previously selected tab index, not the new one:</p> <pre><code>var selectedTab = $("#TabList").tabs().data("selected.tabs"); </code></pre> <p>Here is the code I am attempting to use to get the currently selected tab:</p> <pre><code>$("#TabList").bind("tabsselect", function(event, ui) { }); </code></pre> <p><strong>When I use this code, the ui object comes back <code>undefined</code></strong>. From the documentation, this should be the object I'm using to hook into the newly selected index using ui.tab. I have tried this on the initial <code>tabs()</code> call and also on its own. Am I doing something wrong here?</p>
[ { "answer_id": 300221, "author": "redsquare", "author_id": 6440, "author_profile": "https://Stackoverflow.com/users/6440", "pm_score": 7, "selected": true, "text": "ui.index event" }, { "answer_id": 300846, "author": "Ben Koehler", "author_id": 11996, "author_profile": "https://Stackoverflow.com/users/11996", "pm_score": 4, "selected": false, "text": "var selectedTab = $(\"#TabList\").tabs().data(\"selected.tabs\");\n $(\"#TabList\").bind(\"tabsselect\", function(event, ui) {\n var selectedTab = $(\"#TabList\").tabs().data(\"selected.tabs\");\n});\n" }, { "answer_id": 1335299, "author": "Contra", "author_id": 112508, "author_profile": "https://Stackoverflow.com/users/112508", "pm_score": 8, "selected": false, "text": "function getSelectedTabIndex() { \n return $(\"#TabList\").tabs('option', 'selected');\n}\n $(\"#TabList\").tabs('option', 'active')\n" }, { "answer_id": 4407217, "author": "Paresh", "author_id": 537615, "author_profile": "https://Stackoverflow.com/users/537615", "pm_score": 0, "selected": false, "text": "'<input type=\"hidden\" id=\"sel_tab\" name=\"sel_tab\" value=\"\" />' <li><a href=\"#tabs-0\" onclick=\"document.getElementById('sel_tab').value=0;\" >TAB -1</a></li>\n<li><a href=\"#tabs-1\" onclick=\"document.getElementById('sel_tab').value=1;\" >TAB -2</a></li>\n" }, { "answer_id": 5735132, "author": "Lance", "author_id": 717718, "author_profile": "https://Stackoverflow.com/users/717718", "pm_score": 3, "selected": false, "text": "div <li class=\"ui-state-default ui-corner-top ui-tabs-selected ui-state-active ui-state-focus\"><a href=\"#tabs-4\">Tab 5</a></li>\n href jQuery('.ui-tabs-selected a',window.parent.document).attr('href')\n $tabs.tabs('option', 'selected');" }, { "answer_id": 7898453, "author": "chrism", "author_id": 844623, "author_profile": "https://Stackoverflow.com/users/844623", "pm_score": 1, "selected": false, "text": "var index = jQuery('#tabs').data('tabs').options.selected;\n" }, { "answer_id": 7967944, "author": "SpYk3HH", "author_id": 900807, "author_profile": "https://Stackoverflow.com/users/900807", "pm_score": 5, "selected": false, "text": "ui-tabs-selected ui-tabs-active var curTab = $('.ui-tabs-panel:not(.ui-tabs-hide)');\n var $tabs = $('#example').tabs();\nvar selected = $tabs.tabs('option', 'selected'); // => 0\n var curTab = $('.ui-tabs-panel:not(.ui-tabs-hide)'),\n curTabIndex = curTab.index(),\n curTabID = curTab.prop(\"id\"),\n curTabCls = curTab.attr(\"class\");\n // etc ....\n $('#example-1').tabs();\n$('#example-2').tabs();\n var curTabPanel = $('#example-2 .ui-tabs-panel:not(.ui-tabs-hide)');\n // for page with only one set of tabs\nvar curTab = $('.ui-tabs-selected'); // '.ui-tabs-active' in jQuery 1.9+\n\n// for page with multiple sets of tabs\nvar curTab2 = $('#example-2 .ui-tabs-selected'); // '.ui-tabs-active' in jQuery 1.9+\n" }, { "answer_id": 9570153, "author": "Fabio", "author_id": 1250283, "author_profile": "https://Stackoverflow.com/users/1250283", "pm_score": 2, "selected": false, "text": "var $tabs = $('#tabs-menu').tabs();\n\nvar selected = $tabs.tabs('option', 'selected');\n\nvar divAssocAtual = $('#tabs-menu ul li').tabs()[selected].hash;\n" }, { "answer_id": 14779122, "author": "user1714346", "author_id": 1714346, "author_profile": "https://Stackoverflow.com/users/1714346", "pm_score": 3, "selected": false, "text": " $(document).ready(function () {\n $('#tabs').tabs({\n activate: function (event, ui) {\n var act = $(\"#tabs\").tabs(\"option\", \"active\");\n $(\"#<%= hidLastTab.ClientID %>\").val(act);\n //console.log($(ui.newTab));\n //console.log($(ui.oldTab));\n }\n });\n\n if ($(\"#<%= hidLastTab.ClientID %>\").val() != \"\") \n {\n $(\"#tabs\").tabs(\"option\", \"active\", $(\"#<%= hidLastTab.ClientID %>\").val());\n }\n\n\n });\n" }, { "answer_id": 15362640, "author": "MeneerBij", "author_id": 2002926, "author_profile": "https://Stackoverflow.com/users/2002926", "pm_score": 4, "selected": false, "text": "var $tabs = $('#tabs-menu').tabs();\n// jquery ui 1.8\nvar selected = $tabs.tabs('option', 'selected');\n// jquery ui 1.9+\nvar active = $tabs.tabs('option', 'active');\n" }, { "answer_id": 15550093, "author": "Qin Wang", "author_id": 2008441, "author_profile": "https://Stackoverflow.com/users/2008441", "pm_score": 2, "selected": false, "text": "$( \"#tabs\" ).tabs( \"option\", \"active\" )\n" }, { "answer_id": 15788941, "author": "Vishal Sharma", "author_id": 1018054, "author_profile": "https://Stackoverflow.com/users/1018054", "pm_score": 3, "selected": false, "text": "$(\"#tabs div[aria-hidden='false']\");\n $(\"#tabs div[aria-hidden='false']\").index();\n" }, { "answer_id": 16097717, "author": "Chandre Gowda", "author_id": 2297717, "author_profile": "https://Stackoverflow.com/users/2297717", "pm_score": 1, "selected": false, "text": "$(\"#tabs\").tabs({ \n load: function(event, ui){ \n var anchor = ui.tab.find(\".ui-tabs-anchor\"); \n var url = anchor.attr('href'); \n } \n}); \n" }, { "answer_id": 17600169, "author": "aked", "author_id": 1060656, "author_profile": "https://Stackoverflow.com/users/1060656", "pm_score": 2, "selected": false, "text": "var activeIndex = $(\"#panel\").tabs('option', 'active');\n // this will return the html element\nvar element= $(\"#panel\").find( \".ui-tabs-panel\" )[activeIndex]; \n var tabContent$ = $(element);\n .ui-tabs-nav .ui-tabs-panel" }, { "answer_id": 18707996, "author": "Brian M", "author_id": 2697075, "author_profile": "https://Stackoverflow.com/users/2697075", "pm_score": 2, "selected": false, "text": "$(\"#tabs\").tabs({\n activate: function (e, ui) {\n currentTabIndex =ui.newTab.index().toString();\n }\n});\n" }, { "answer_id": 26110974, "author": "prograhammer", "author_id": 1110941, "author_profile": "https://Stackoverflow.com/users/1110941", "pm_score": 0, "selected": false, "text": "ui.newTab.index() $(\"#tabs\").tabs({\n activate: function(event, ui){\n alert(ui.newTab.index());\n // You can also use this to set another tab, see fiddle...\n // $(\"#other-tabs\").tabs(\"option\", \"active\", ui.newTab.index()); \n },\n});\n" }, { "answer_id": 32838127, "author": "Mike Clark", "author_id": 4261022, "author_profile": "https://Stackoverflow.com/users/4261022", "pm_score": 2, "selected": false, "text": "var selectedTabIndex= $(\"#tabs\").tabs('option', 'active');\n" }, { "answer_id": 51695323, "author": "iman64", "author_id": 4399356, "author_profile": "https://Stackoverflow.com/users/4399356", "pm_score": 0, "selected": false, "text": "$(\"#tabs\").tabs({\n activate: function(event, ui) {\n new_index = ui.newTab.index()+1;\n //do anything\n }\n});\n" }, { "answer_id": 61914262, "author": "Pertr Pavliuk", "author_id": 5082729, "author_profile": "https://Stackoverflow.com/users/5082729", "pm_score": 2, "selected": false, "text": "$(yourEl).tabs({\n activate: function(event, ui) {\n console.log(ui.newPanel.index());\n }\n});\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1284/" ]
300,086
<p>I am writing a text editor for Mac OS X. I need to display hidden characters in an NSTextView (such as spaces, tabs, and special characters). I have spent a lot of time searching for how to do this but so far I have not found an answer. If anyone could point me in the right direction I would be grateful.</p>
[ { "answer_id": 300148, "author": "e.James", "author_id": 33686, "author_profile": "https://Stackoverflow.com/users/33686", "pm_score": 4, "selected": true, "text": "replaceGlyphAtIndex:withGlyph:" }, { "answer_id": 301169, "author": "titaniumdecoy", "author_id": 18091, "author_profile": "https://Stackoverflow.com/users/18091", "pm_score": 2, "selected": false, "text": "- (void)drawGlyphsForGlyphRange:(NSRange)range atPoint:(NSPoint)origin\n{\n NSFont *font = [[CURRENT_TEXT_VIEW typingAttributes]\n objectForKey:NSFontAttributeName];\n\n NSGlyph bullet = [font glyphWithName:@\"bullet\"];\n\n for (int i = range.location; i != range.location + range.length; i++)\n {\n unsigned charIndex = [self characterIndexForGlyphAtIndex:i];\n\n unichar c =[[[self textStorage] string] characterAtIndex:charIndex];\n\n if (c == ' ')\n [self replaceGlyphAtIndex:charIndex withGlyph:bullet];\n }\n\n [super drawGlyphsForGlyphRange:range atPoint:origin];\n}" }, { "answer_id": 576642, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "- (void)drawGlyphsForGlyphRange:(NSRange)glyphRange atPoint:(NSPoint)containerOrigin\n{\n if ([[[[MJDocumentController sharedDocumentController] currentDocument] editor] showInvisibles])\n {\n //init glyphs\n unichar crlf = 0x00B6; \n NSString *CRLF = [[NSString alloc] initWithCharacters:&crlf length:1];\n unichar space = 0x00B7;\n NSString *SPACE = [[NSString alloc] initWithCharacters:&space length:1];\n unichar tab = 0x2192; \n NSString *TAB = [[NSString alloc] initWithCharacters:&tab length:1];\n\n NSString *docContents = [[self textStorage] string];\n NSString *glyph;\n NSPoint glyphPoint;\n NSRect glyphRect;\n NSDictionary *attr = [[NSDictionary alloc] initWithObjectsAndKeys:[NSUnarchiver unarchiveObjectWithData:[[NSUserDefaults standardUserDefaults] objectForKey:@\"invisiblesColor\"]], NSForegroundColorAttributeName, nil];\n\n //loop thru current range, drawing glyphs\n int i;\n for (i = glyphRange.location; i < NSMaxRange(glyphRange); i++)\n {\n glyph = @\"\";\n\n //look for special chars\n switch ([docContents characterAtIndex:i])\n {\n //space\n case ' ':\n glyph = SPACE;\n break;\n\n //tab\n case '\\t':\n glyph = TAB;\n break;\n\n //eol\n case 0x2028:\n case 0x2029:\n case '\\n':\n case '\\r':\n glyph = CRLF;\n break;\n\n //do nothing\n default:\n glyph = @\"\";\n break; \n }\n\n //should we draw?\n if ([glyph length])\n {\n glyphPoint = [self locationForGlyphAtIndex:i];\n glyphRect = [self lineFragmentRectForGlyphAtIndex:i effectiveRange:NULL];\n glyphPoint.x += glyphRect.origin.x;\n glyphPoint.y = glyphRect.origin.y;\n [glyph drawAtPoint:glyphPoint withAttributes:attr];\n }\n }\n }\n\n [super drawGlyphsForGlyphRange:glyphRange atPoint:containerOrigin];\n}\n" }, { "answer_id": 29681234, "author": "Pol", "author_id": 463432, "author_profile": "https://Stackoverflow.com/users/463432", "pm_score": 3, "selected": false, "text": "@interface GILayoutManager : NSLayoutManager\n@end\n\n@implementation GILayoutManager\n\n- (void)drawGlyphsForGlyphRange:(NSRange)range atPoint:(NSPoint)point {\n NSTextStorage* storage = self.textStorage;\n NSString* string = storage.string;\n for (NSUInteger glyphIndex = range.location; glyphIndex < range.location + range.length; glyphIndex++) {\n NSUInteger characterIndex = [self characterIndexForGlyphAtIndex: glyphIndex];\n switch ([string characterAtIndex:characterIndex]) {\n\n case ' ': {\n NSFont* font = [storage attribute:NSFontAttributeName atIndex:characterIndex effectiveRange:NULL];\n [self replaceGlyphAtIndex:glyphIndex withGlyph:[font glyphWithName:@\"periodcentered\"]];\n break;\n }\n\n case '\\n': {\n NSFont* font = [storage attribute:NSFontAttributeName atIndex:characterIndex effectiveRange:NULL];\n [self replaceGlyphAtIndex:glyphIndex withGlyph:[font glyphWithName:@\"carriagereturn\"]];\n break;\n }\n\n }\n }\n\n [super drawGlyphsForGlyphRange:range atPoint:point];\n}\n\n@end\n [myTextView.textContainer replaceLayoutManager:[[GILayoutManager alloc] init]];\n CGFontRef font = CGFontCreateWithFontName(CFSTR(\"Menlo-Regular\"));\nfor (size_t i = 0; i < CGFontGetNumberOfGlyphs(font); ++i) {\n printf(\"%s\\n\", [CFBridgingRelease(CGFontCopyGlyphNameForGlyph(font, i)) UTF8String]);\n}\n" }, { "answer_id": 33891871, "author": "user3717478", "author_id": 3717478, "author_profile": "https://Stackoverflow.com/users/3717478", "pm_score": 2, "selected": false, "text": "class MyLayoutManager: NSLayoutManager {\n override func drawGlyphsForGlyphRange(glyphsToShow: NSRange, atPoint origin: NSPoint) {\n if let storage = self.textStorage {\n let s = storage.string\n let startIndex = s.startIndex\n for var glyphIndex = glyphsToShow.location; glyphIndex < glyphsToShow.location + glyphsToShow.length; glyphIndex++ {\n let characterIndex = self.characterIndexForGlyphAtIndex(glyphIndex)\n let ch = s[startIndex.advancedBy(characterIndex)]\n switch ch {\n case \" \":\n let attrs = storage.attributesAtIndex(characterIndex, effectiveRange: nil)\n if let font = attrs[NSFontAttributeName] {\n let g = font.glyphWithName(\"periodcentered\")\n self.replaceGlyphAtIndex(glyphIndex, withGlyph: g)\n }\n case \"\\n\":\n let attrs = storage.attributesAtIndex(characterIndex, effectiveRange: nil)\n if let font = attrs[NSFontAttributeName] {\n// let g = font.glyphWithName(\"carriagereturn\")\n let g = font.glyphWithName(\"paragraph\")\n self.replaceGlyphAtIndex(glyphIndex, withGlyph: g)\n }\n case \"\\t\":\n let attrs = storage.attributesAtIndex(characterIndex, effectiveRange: nil)\n if let font = attrs[NSFontAttributeName] {\n let g = font.glyphWithName(\"arrowdblright\")\n self.replaceGlyphAtIndex(glyphIndex, withGlyph: g)\n }\n default:\n break\n }\n }\n }\n super.drawGlyphsForGlyphRange(glyphsToShow, atPoint: origin)\n }\n}\n func listFonts() {\n let font = CGFontCreateWithFontName(\"Menlo-Regular\")\n for var i:UInt16 = 0; i < UInt16(CGFontGetNumberOfGlyphs(font)); i++ {\n if let name = CGFontCopyGlyphNameForGlyph(font, i) {\n print(\"name: \\(name) at index \\(i)\")\n }\n }\n }\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300086", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18091/" ]
300,089
<p>Does anyone know a way to find out programatically which physical disk holds a given partition? Manually, I can find this info using Start->Run->diskmgmt.msc , where I can see that (on my computer) that partitions C: and D: are on disk 1, E: &amp; F: on disk 0.</p> <p>This is for optimizing some file crunching operations by doing them in parallel if the files are on different physical disks.</p>
[ { "answer_id": 300249, "author": "Cristian Diaconescu", "author_id": 11545, "author_profile": "https://Stackoverflow.com/users/11545", "pm_score": 1, "selected": false, "text": "\\\\\\\\.\\\\PHYSICALDRIVE0 C:" }, { "answer_id": 14113018, "author": "STTR", "author_id": 1938938, "author_profile": "https://Stackoverflow.com/users/1938938", "pm_score": 1, "selected": false, "text": "wmic path CIM_BasedOn get * > wmic-path-CIM_BasedOn-get.txt\nwmic path CIM_DiskPartition get * > wmic-path-CIM_DiskPartition-get.txt\nwmic path CIM_StorageExtent get * > wmic-path-CIM_StorageExtent-get.txt\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11545/" ]
300,091
<p>Assuming a class called <code>Bar</code> in a namespace called <code>foo</code>, which syntax do you prefer for your source (.cpp/.cc) file?</p> <pre><code>namespace foo { ... void Bar::SomeMethod() { ... } } // foo </code></pre> <p>or</p> <pre><code>void foo::Bar::SomeMethod() { ... } </code></pre> <p>I use namespaces heavily and prefer the first syntax, but when adding code using the Visual Studio Class Wizard (WM_COMMAND handlers, etc.) the auto-generated code uses the second. Are there any advantages of one syntax over the other?</p>
[ { "answer_id": 300108, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 4, "selected": true, "text": "namespace bar { \n struct foo { void f(); };\n}\n\nnamespace baz { \n struct foo { void f(); };\n}\n\nusing namespace bar;\nusing namespace baz;\n\nvoid foo::f() { // which foo??\n\n}\n namespace foo {\nvoid Bar::SomeMethod() {\n // something in here\n}\n}\n" }, { "answer_id": 300109, "author": "hazzen", "author_id": 5066, "author_profile": "https://Stackoverflow.com/users/5066", "pm_score": 3, "selected": false, "text": "namespace foo {\n\nvoid Bar::SomeMethod()\n{\n ...\n}\n\n} // foo namespace\n" }, { "answer_id": 300368, "author": "David Rodríguez - dribeas", "author_id": 36565, "author_profile": "https://Stackoverflow.com/users/36565", "pm_score": 2, "selected": false, "text": "namespace TheNamespace {\nvoid TheClass::TheMethod() {\n // code\n}\n}\n void TheNamespace::TheClass::TheMethod() {\n // code\n}\n class TheClass1\n{\n class TheClass2\n {\n void TheMethod();\n }\n};\n\nvoid TheClass1::TheClass2::TheMethod() {\n // code\n}\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9236/" ]
300,093
<p>In the Application_Error method in Global.asax I am trying to retrieve a value from session state.</p> <p>I am able to access session state as long as I throw the exception. EG: </p> <pre><code>thow new Exception("Test exception"); </code></pre> <p>However if it is an unhandled exception, i get the following error when trying to access session state: "Session state is not available in this context.".</p> <p>Why the differences in behavior, is there a work around? </p> <p>Thanks.</p>
[ { "answer_id": 302959, "author": "Ryan Sampson", "author_id": 1375, "author_profile": "https://Stackoverflow.com/users/1375", "pm_score": 2, "selected": false, "text": "Response.Redirect(\"thispagedoesnotexist.aspx\", false); \n throw new Exception(\"test\");\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1375/" ]
300,095
<p>Where is the best documentation of ffmpeg and libavcodec?</p> <p>It appears that ffmpeg supports many undocumented options that it is very hard to find a good reference.</p>
[ { "answer_id": 305859, "author": "teeks99", "author_id": 17949, "author_profile": "https://Stackoverflow.com/users/17949", "pm_score": 3, "selected": false, "text": "ffmpeg -formats\n" }, { "answer_id": 18641580, "author": "wyatt8740", "author_id": 2751276, "author_profile": "https://Stackoverflow.com/users/2751276", "pm_score": 1, "selected": false, "text": "ffmpeg --help ffmpeg -formats ffmpeg -codecs ffmpeg - man ffmpeg ffmpeg -decoders ffmpeg -encoders ffmpeg -protocols ffmpeg -filters" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4697/" ]
300,118
<p>I have 2 tables, an active table and an inactive table. I want to <em>move</em> rows from the active to the inactive table. My first thought was</p> <pre><code>insert into inactive select * from active where ... delete from active active where ... </code></pre> <p>However about .42 seconds later I noticed this will drop/duplicate rows if updates alter what the where clause selects.</p> <p>In this case, I can easily prevent that but what should I do in cases where I can't?</p> <p>edit: From the answers it look like there isn't an easy/trivial way to do this. I'm really surprised by this. I would think that there would be some substantial benefits to having it.</p>
[ { "answer_id": 300126, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 4, "selected": true, "text": "UPDATE old_data SET move=\"MARKED\";\nINSERT INTO somewhere... SELECT where move=\"MARKED\";\nDELETE FROM old_data WHERE move=\"MARKED\";\n" }, { "answer_id": 300128, "author": "Arvo", "author_id": 35777, "author_profile": "https://Stackoverflow.com/users/35777", "pm_score": 2, "selected": false, "text": "begin tran\n\ninsert into inactive\nselect * from active with (updlock)\nwhere ...\n\ndelete from active\nwhere ...\n\ncommit tran\n" }, { "answer_id": 300139, "author": "John MacIntyre", "author_id": 29043, "author_profile": "https://Stackoverflow.com/users/29043", "pm_score": 1, "selected": false, "text": "delete from active where rowid in (select rowid in inactive)\n delete from active as a \nwhere exists (select * \n from inactive \n where pkfld1=a.pkfld1 \n and pkfld2=a.pkfld2)\n" }, { "answer_id": 300166, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 0, "selected": false, "text": "DECLARE @MyTable TABLE\n(\n TheKey int PRIMARY KEY\n)\n--\nINSERT INTO @MyTable(TheKey)\nSELECT TheKey FROM SourceTable WHERE rows I want\n--\nINSERT INTO Inactive(fieldlist)\nSELECT fieldlist\nFROM Active\nWHERE TheKey IN (SELECT TheKey FROM @MyTable)\n--\nDELETE\nFROM Active\nWHERE TheKey IN (SELECT TheKey FROM @MyTable)\n" }, { "answer_id": 302052, "author": "Örjan Jämte", "author_id": 19311, "author_profile": "https://Stackoverflow.com/users/19311", "pm_score": 2, "selected": false, "text": "delete active with (readpast)\noutput DELETED.*\ninto inactive\nwhere ...\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
300,160
<p>We were working on a design, and for that we created the skeleton of the classes in our main branch. Now, we are starting to code, and for that we got a new branch. So, it would be nice if I can move all the new files in the main branch into the new branch. However, I cannot check them in yet. So, is it possible to integrate the checked out changelist? Thanks.</p>
[ { "answer_id": 16940796, "author": "Gareth Rees", "author_id": 68063, "author_profile": "https://Stackoverflow.com/users/68063", "pm_score": 3, "selected": false, "text": "shelve unshelve $ p4 shelve ...\nChange 182535 created with 10 open file(s).\nShelving files for change 182535.\nedit //info.ravenbrook.com/project/mps/master/code/arenavm.c#26\n# etc.\n -b $ p4 unshelve -b mps/branch/2013-06-05/diag -s 182535\n... //info.ravenbrook.com/project/mps/branch/2013-06-05/diag/code/arenavm.c - must resolve //info.ravenbrook.com/project/mps/master/code/arenavm.c@=182535 before submitting\n# etc.\n unshelve p4 resolve -as p4 resolve $ p4 resolve -as\n//gdr-peewit/info.ravenbrook.com/project/mps/branch/2013-06-05/diag/code/arenavm.c - copy from //info.ravenbrook.com/project/mps/master/code/arenavm.c\n# etc.\n$ p4 resolve\nNo file(s) to resolve.\n" }, { "answer_id": 24178183, "author": "Andrei Pokrovsky", "author_id": 231742, "author_profile": "https://Stackoverflow.com/users/231742", "pm_score": 0, "selected": false, "text": "p4 unshelve -b target_branchspec -s changelist\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38703/" ]
300,175
<p>I've got a css menu like this:</p> <pre><code>&lt;ul&gt; &lt;li&gt;&lt;a&gt;Item1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a&gt;Item Two&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a&gt;Item C&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a&gt;A Rather Long Menu Item Down Here&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I want to create this:</p> <pre> |-----------------------------------| | Item1 | |-----------------------------------| | Item Two | |-----------------------------------| | Item C | |-----------------------------------| | A Rather Long Menu Item Down Here | |-----------------------------------| </pre> <p>but I'm getting this:</p> <pre> -------- | Item1 | |----------- | Item Two | |----------- | Item C | |----------------------------------- | A Rather Long Menu Item Down Here | ----------------------------------- </pre> <p>If I set either the [li] or [a] tags to display:block, they stretch to fill the maximum possible width. I want them all to have the same width, which is dynamically determined by the widest item, rather than by manually putting a width on the [ul] tag.</p> <p>Oh, and the target is IE6. :)</p> <h3>Update:</h3> <p><code>width:1px, overflow:visible</code> didn't work. (Got the same squashed effect as without the display:blocked anchors.)</p> <p>This is for an intranet where IE6 is the target, so I'm stuck there. (In other projects, I've stopped worrying about it.) JS is a requirement, so maybe I'll use that. (I always hate doing that, though.)</p>
[ { "answer_id": 300329, "author": "eimaj", "author_id": 38371, "author_profile": "https://Stackoverflow.com/users/38371", "pm_score": 1, "selected": false, "text": "ul,li {float:left;}\nul {overflow:hidden;}\nli {clear:left;}\n ul,li {float:left;}\nul {overflow:hidden;}\nli {clear:left;width:expression(this.parentNode.offsetWidth);}\n" }, { "answer_id": 300803, "author": "Ola Tuvesson", "author_id": 6903, "author_profile": "https://Stackoverflow.com/users/6903", "pm_score": 3, "selected": false, "text": "<style>\nul {\nfloat: left;\n}\n ul li a {\n display: block;\n white-space: nowrap;\n border: 1px solid blue;\n }\n</style>\n\n<ul>\n <li><a>Item1</a></li>\n <li><a>Item Two</a></li>\n <li><a>Item C</a></li>\n <li><a>A Rather Long Menu Item Down Here</a></li>\n</ul>\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24197/" ]
300,181
<p>In a C# program, I have an abstract base class with a static "Create" method. The Create method is used to create an instance of the class and store it locally for later use. Since the base class is abstract, implementation objects will always derive from it.</p> <p>I want to be able to derive an object from the base class, call the static Create method (implemented once in the base class) through the derived class, and create an instance of the derived object.</p> <p>Are there any facilities within the C# language that will allow me to pull this off. My current fallback position is to pass an instance of the derived class as one of the arguments to the Create function, i.e.: </p> <pre><code>objDerived.Create(new objDerived(), "Arg1", "Arg2"); </code></pre>
[ { "answer_id": 300207, "author": "chilltemp", "author_id": 28736, "author_profile": "https://Stackoverflow.com/users/28736", "pm_score": 5, "selected": true, "text": "public static BaseClass Create<T>() where T : BaseClass, new()\n{\n T newVar = new T();\n // Do something with newVar\n return T;\n}\n DerivedClass d = BaseClass.Create<DerivedClass>();\n" }, { "answer_id": 300253, "author": "Charles Bretana", "author_id": 32632, "author_profile": "https://Stackoverflow.com/users/32632", "pm_score": 2, "selected": false, "text": " public abstract class MyBase\n {\n public static T GetNewDerived<T>() where T : MyBase, new()\n {\n return new T();\n } \n }\n public class DerivedA : MyBase\n {\n public static DerivedA GetNewDerived()\n {\n return GetNewDerived<DerivedA>();\n }\n }\n\n public class DerivedB : MyBase\n {\n public static DerivedB GetNewDerived()\n {\n return GetNewDerived<DerivedB>();\n }\n } \n" }, { "answer_id": 300347, "author": "Jeff Yates", "author_id": 23234, "author_profile": "https://Stackoverflow.com/users/23234", "pm_score": 3, "selected": false, "text": "abstract class BaseClass\n{\n public static BaseClass Create<T>() where T : BaseClass, new()\n {\n return new T();\n }\n}\n DerivedClass derivedInstance = BaseClass.Create<DerivedClass>();\n abstract class BaseClass\n{\n public static BaseClass Create(Type derivedType)\n {\n // Cast will throw at runtime if the created class\n // doesn't derive from BaseClass.\n return (BaseClass)Activator.CreateInstance(derivedType);\n }\n}\n DerivedClass derivedClass\n = (DerivedClass)BaseClass.Create(typeof(DerivedClass));\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19853/" ]
300,185
<p>Which version of JavaScript does Google Chrome support in relation to Mozilla Firefox? In other words, does Chrome support JavaScript 1.6, 1.7, or 1.8 which Firefox also supports or some combination of them?</p>
[ { "answer_id": 300231, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 3, "selected": false, "text": "<script language=\"javascript1.7\">alert(1.7);</script> - Alerts\n<script language=\"javascript1.8\">alert(1.8);</script> - Doesn't alert\n" }, { "answer_id": 1125353, "author": "Ben Combee", "author_id": 1323, "author_profile": "https://Stackoverflow.com/users/1323", "pm_score": 6, "selected": true, "text": "<script language=\"javascript\" type=\"application/javascript;version=1.7\">\n function foo(){ let a = 4; alert(a); }; foo();\n</script>\n" }, { "answer_id": 2028443, "author": "Tobu", "author_id": 229753, "author_profile": "https://Stackoverflow.com/users/229753", "pm_score": 4, "selected": false, "text": "for each (variable in object)\n statement\n" }, { "answer_id": 5655707, "author": "Jens Larsen", "author_id": 706848, "author_profile": "https://Stackoverflow.com/users/706848", "pm_score": 2, "selected": false, "text": "function foo(){\n let a = 4;\n alert(a);\n}\nfoo();\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/208/" ]
300,187
<p>We have 2 flowdocuments that we'd like to compare similar to when using a diff viewer (winmerge, beyond compare, etc). Has anybody done this or know how to get the text out of a flowdocument to do a compare?</p>
[ { "answer_id": 300231, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 3, "selected": false, "text": "<script language=\"javascript1.7\">alert(1.7);</script> - Alerts\n<script language=\"javascript1.8\">alert(1.8);</script> - Doesn't alert\n" }, { "answer_id": 1125353, "author": "Ben Combee", "author_id": 1323, "author_profile": "https://Stackoverflow.com/users/1323", "pm_score": 6, "selected": true, "text": "<script language=\"javascript\" type=\"application/javascript;version=1.7\">\n function foo(){ let a = 4; alert(a); }; foo();\n</script>\n" }, { "answer_id": 2028443, "author": "Tobu", "author_id": 229753, "author_profile": "https://Stackoverflow.com/users/229753", "pm_score": 4, "selected": false, "text": "for each (variable in object)\n statement\n" }, { "answer_id": 5655707, "author": "Jens Larsen", "author_id": 706848, "author_profile": "https://Stackoverflow.com/users/706848", "pm_score": 2, "selected": false, "text": "function foo(){\n let a = 4;\n alert(a);\n}\nfoo();\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3047/" ]
300,196
<p>I work on a W3C XML Schema (not written by me). One tool, xmllint, refuses to use the schema:</p> <pre><code>traceroute.xsd:658: element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'maxOccurs': The value '4294967295' is not valid. Expected is '(xs:nonNegativeInteger | unbounded)'. </code></pre> <p>4294967295 is 2^32-1 so, clearly, xmllint implements integers with signed 32bits number and that's not enough.</p> <p>Is xmllint right? The standard apparently does not limit the size of integers:</p> <p><a href="http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/structures.html#p-max_occurs" rel="nofollow noreferrer">http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/structures.html#p-max_occurs</a> <a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#nonNegativeInteger" rel="nofollow noreferrer">http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#nonNegativeInteger</a></p> <blockquote> <p>The value space of nonNegativeInteger is the infinite set {0,1,2,...}.</p> </blockquote> <p>So, implementors are supposed to use infinite integers...</p> <p>What are the best practices? </p> <p>Should implementors use bigints or similar things? (In that case, xmllint is wrong.)</p> <p>Should schema authors limit themselves to "reasonable" values for maxOccurs? (In that case, I will report the issue to the schema authors.)</p>
[ { "answer_id": 300256, "author": "David Hall", "author_id": 2660, "author_profile": "https://Stackoverflow.com/users/2660", "pm_score": 2, "selected": false, "text": "maxOccurs maxOccurs unbounded 4294967295 int32 unbounded" }, { "answer_id": 360794, "author": "bortzmeyer", "author_id": 15625, "author_profile": "https://Stackoverflow.com/users/15625", "pm_score": 2, "selected": false, "text": " <xs:element maxOccurs=\"2147483647\" minOccurs=\"0\"\n name=\"Measurement\">\n <xs:complexType>\n <xs:sequence>\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15625/" ]
300,200
<p>I want to embed a swf over a html page, like a floating video watching panel. I already have a swf file which will automatically adjust its size according to the browser size, and the swf file is partially transparent. I thought I can just add a div tag, make the position absolute and change z-index bigger, but that doesn't work because the swf just replaced everything that's on the page. </p> <p>Here's what I did</p> <pre><code>&lt;script&gt; swfobject.embedSWF("swf/float.swf", "header", "100%", "100%", "9.0.0"); &lt;/script&gt; &lt;body bgcolor="#000000"&gt; &lt;div id="header"&gt;&lt;/div&gt; &lt;div id="shell"&gt; things in my html &lt;/div&gt; &lt;/body&gt; #header { position:absolute; z-index:100; } </code></pre> <p>Any idea? Thanks.</p>
[ { "answer_id": 300338, "author": "Adam", "author_id": 36324, "author_profile": "https://Stackoverflow.com/users/36324", "pm_score": 0, "selected": false, "text": "<object /> swfobject.embedSWF <div id=\"header\"></div> <object /> <script>\n swfobject.embedSWF(\"swf/float.swf\", \"header\", \"100%\", \"100%\", \"9.0.0\");\n</script>\n\n<body bgcolor=\"#000000\">\n <div id=\"wrapper\">\n <div id=\"header\"></div>\n </div>\n <div id=\"shell\">\n things in my html\n </div>\n</body>\n\n#wrapper {\n position:absolute;\n z-index:100;\n width:100%;\n height:100%;\n}\n" }, { "answer_id": 300552, "author": "grapefrukt", "author_id": 914, "author_profile": "https://Stackoverflow.com/users/914", "pm_score": 4, "selected": true, "text": "<script type=\"text/javascript\">\n\nvar flashvars = {};\nvar params = {wmode : \"transparent\"};\nvar attributes = {};\n\nswfobject.embedSWF(\"myContent.swf\", \"myContent\", \"300\", \"120\", \"9.0.0\",\"expressInstall.swf\", flashvars, params, attributes);\n\n</script>\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34797/" ]
300,208
<p>for the following:</p> <pre><code>( a != b ) ? cout&lt;&lt;"not equal" : cout&lt;&lt;"equal"; </code></pre> <p>suppose I don't care if it's equal, how can I use the above statement by substituting <code>cout&lt;&lt;"equal"</code> with a no-op.</p>
[ { "answer_id": 300223, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 1, "selected": false, "text": "cond ? cout << \"equal\" : cout;\n if" }, { "answer_id": 300225, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 6, "selected": true, "text": "if (a!=b) cout << \"not equal\";\n" }, { "answer_id": 300226, "author": "NotMe", "author_id": 2424, "author_profile": "https://Stackoverflow.com/users/2424", "pm_score": 0, "selected": false, "text": "if (a!=b) cout<<\"not equal\";\n" }, { "answer_id": 300229, "author": "altruic", "author_id": 38620, "author_profile": "https://Stackoverflow.com/users/38620", "pm_score": 3, "selected": false, "text": "if (a != b)\n cout << \"not equal\";\n (a != b) ? cout << \"not equal\" : cout;\n" }, { "answer_id": 300247, "author": "SoapBox", "author_id": 36384, "author_profile": "https://Stackoverflow.com/users/36384", "pm_score": 3, "selected": false, "text": "(a != b) ? : printf(\"equal\\n\");" }, { "answer_id": 302092, "author": "Richard Corden", "author_id": 11698, "author_profile": "https://Stackoverflow.com/users/11698", "pm_score": 2, "selected": false, "text": "(a != b) && (cout << \"equal\");\n" }, { "answer_id": 302145, "author": "Greg D", "author_id": 6932, "author_profile": "https://Stackoverflow.com/users/6932", "pm_score": 1, "selected": false, "text": "cout << (cond ? \"not equal\" : \"\");\n" }, { "answer_id": 342568, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "( a != b ) ? cout<<\"not equal\" : NULL;\n\n( a != b ) ? NULL : cout<<\"equal\";\n" }, { "answer_id": 11544631, "author": "QBziZ", "author_id": 11572, "author_profile": "https://Stackoverflow.com/users/11572", "pm_score": 1, "selected": false, "text": "somecondition ? foo() : [] {} () ;\n somecondition1 ? foo1() :\nsomecondition2 ? foo2() :\nsomecondition3 ? foo3() :\n flip_out_because_unhandled_condition() ;\n somecondition1 ? foo1() :\nsomecondition2 ? foo2() :\nsomecondition3 ? foo3() :\nsomecondition4 ? []{}() :\n flip_out_because_unhandled_condition() ;\n" }, { "answer_id": 15297407, "author": "Regular Guy", "author_id": 2146917, "author_profile": "https://Stackoverflow.com/users/2146917", "pm_score": 2, "selected": false, "text": "(void)0; expr?false:true ( a != b ) ? (void)0 : cout<<\"equal\";" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8661/" ]
300,210
<p>I am designing a web app and I intent to embed data on an xml island so that I can dynamically render it on an HTML table on the client-side based on options the users will select.</p> <p>I have the broad concepts, but I need pointers on how to use DOM in navigating my xml. And how to update my xml island possibly for posting back to the server?</p> <p>Please any links to online resources or a quick advice will be very appreciated.</p> <p>NB: I understand most of the dynamic HTML concepts and server and client side stuff, so don't shy being very technical in your response:)</p>
[ { "answer_id": 300290, "author": "Kornel", "author_id": 27009, "author_profile": "https://Stackoverflow.com/users/27009", "pm_score": 4, "selected": true, "text": "class title data-* element.childNodes .nextSibling .getAttribute()" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300210", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13370/" ]
300,217
<p>In javascript how do I get a handle on the frame that I'm in based on an element in that frame?</p> <pre><code>function myFunction(elementInFrame){ // here I want to get a handle on the frame that elementInFrame lives in } </code></pre>
[ { "answer_id": 300279, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 2, "selected": false, "text": "elementInFrame.document.parentWindow" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24908/" ]
300,220
<p>Does anyone know how I can prevent the text in a table cell from wrapping? This is for the header of a table, and the heading is a lot longer than the data under it, but I need it to display on only one line. It is okay if the column is very wide.</p> <p>The HTML of my (simplified) table looks like this:</p> <pre><code>&lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt; &lt;div&gt;Really long column heading&lt;/div&gt; &lt;/th&gt; &lt;th&gt; &lt;div&gt;Really long column heading&lt;/div&gt; &lt;/th&gt; &lt;th&gt; &lt;div&gt;Really long column heading&lt;/div&gt; &lt;/th&gt; &lt;th&gt; &lt;div&gt;Really long column heading&lt;/div&gt; &lt;/th&gt; &lt;th&gt; &lt;div&gt;Really long column heading&lt;/div&gt; &lt;/th&gt; &lt;th&gt; &lt;div&gt;Really long column heading&lt;/div&gt; &lt;/th&gt; &lt;th&gt; &lt;div&gt;Really long column heading&lt;/div&gt; &lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt; &lt;div&gt;data&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;div&gt;data&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;div&gt;data&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;div&gt;data&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;div&gt;data&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;div&gt;data&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;div&gt;data&lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>The heading itself is wrapped in a div inside the <code>th</code> tag for reasons pertaining to the javascript on the page. </p> <p>The table is coming out with the headings wrapping onto multiple lines. This seems to only happen when the table is sufficiently wide, as the browser is trying to avoid horizontal scrolling. In my case, though, I want horizontal scrolling.</p> <p>Any ideas?</p>
[ { "answer_id": 300235, "author": "Sergey Golovchenko", "author_id": 26592, "author_profile": "https://Stackoverflow.com/users/26592", "pm_score": 5, "selected": false, "text": "<th nowrap=\"nowrap\">Really long column heading</th>\n <th>Really&nbsp;long&nbsp;column&nbsp;heading</th>\n" }, { "answer_id": 300237, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 10, "selected": true, "text": "white-space th {\n white-space: nowrap;\n}\n <th> white-space" }, { "answer_id": 300238, "author": "Grant Wagner", "author_id": 9254, "author_profile": "https://Stackoverflow.com/users/9254", "pm_score": 6, "selected": false, "text": "<th nowrap=\"nowrap\">\n <th style=\"white-space:nowrap;\">\n <th class=\"nowrap\">\n<style type=\"text/css\">\n.nowrap { white-space: nowrap; }\n</style>\n" }, { "answer_id": 28928832, "author": "cssyphus", "author_id": 1447509, "author_profile": "https://Stackoverflow.com/users/1447509", "pm_score": 4, "selected": false, "text": "<td><nobr>Table Text</nobr></td>\n" }, { "answer_id": 60998700, "author": "Davis Jones", "author_id": 6576083, "author_profile": "https://Stackoverflow.com/users/6576083", "pm_score": -1, "selected": false, "text": "<TableHead> <TableHead style={{ whiteSpace: 'nowrap'}}>\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4257/" ]
300,252
<p>I've saved an entire webpage's html to a string, and now <b>I want to grab the "href" values</b> from the links, preferably with the ability to save them to different strings later. What's the best way to do this?</p> <p>I've tried saving the string as an .xml doc and parsing it using an XPathDocument navigator, but (surprise surprise) it doesn't navigate a not-really-an-xml-document too well.</p> <p>Are regular expressions the <b>best</b> way to achieve what I'm trying to accomplish?</p>
[ { "answer_id": 300280, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 0, "selected": false, "text": "href= href=" }, { "answer_id": 300297, "author": "Tim Jarvis", "author_id": 10387, "author_profile": "https://Stackoverflow.com/users/10387", "pm_score": 1, "selected": false, "text": "href=[\\\"\\'](http:\\/\\/|\\.\\/|\\/)?\\w+(\\.\\w+)*(\\/\\w+(\\.\\w+)?)*(\\/|\\?\\w*=\\w*(&\\w*=\\w*)*)?[\\\"\\']\n" }, { "answer_id": 300322, "author": "Jeff Donnici", "author_id": 821, "author_profile": "https://Stackoverflow.com/users/821", "pm_score": 6, "selected": false, "text": "HtmlDocument yourDoc = // load your HTML;\nint someCount = yourDoc.DocumentNode.SelectNodes(\"your_xpath\").Count;\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300252", "https://Stackoverflow.com", "https://Stackoverflow.com/users/557/" ]
300,259
<p>I am sending the echo to mail function via PHP from variable that includes HTML code. The strange thing is, that this </p> <pre><code>&lt;����}im� </code></pre> <p>shows up AFTER the string.. but I do not manipulate with it anymore. The charset of mail function (the attachment) is same as charset of HTML code.</p>
[ { "answer_id": 306086, "author": "Skuta", "author_id": 21209, "author_profile": "https://Stackoverflow.com/users/21209", "pm_score": 0, "selected": false, "text": "$to = 'email@email.com';\n$subject = 'Invoice';\n$random_hash = md5(date('r', time()));\n$headers = \"From: mymail@mymail.com\\r\\nReply-To: webmaster@example.com\";\n$headers .= \"\\r\\nContent-Type: multipart/mixed; boundary=\\\"PHP-mixed-\".$random_hash.\"\\\"\";\n$body=rtrim(chunk_split(base64_encode($body))); \n//define the body of the message.\nob_start(); //Turn on output buffering\n?>\n--PHP-mixed-<?php echo $random_hash; ?> \nContent-Type: multipart/alternative; boundary=\"PHP-alt-<?php echo $random_hash; ?>\"\n\n--PHP-alt-<?php echo $random_hash; ?> \nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 7bit\n\nHello World!!!\nThis is simple text email message.\n\n--PHP-alt-<?php echo $random_hash; ?> \nContent-Type: text/html; charset=\"UTF-8\"\nContent-Transfer-Encoding: 7bit\n\nText Emailu.\n\n--PHP-alt-<?php echo $random_hash; ?>--\n\n--PHP-mixed-<?php echo $random_hash; ?> \nContent-Type: text/html; charset=\"UTF-8\"; name=\"faktura.html\" \nContent-Transfer-Encoding: base64 \nContent-Disposition: attachment \n\n<?php echo htmlentities($body); ?>\n--PHP-mixed-<?php echo $random_hash; ?>--\n\n<?php\n//copy current buffer contents into $message variable and delete current output buffer\n$message = ob_get_clean();\n//send the email\n$mail_sent = @mail( $to, $subject, $message, $headers );\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21209/" ]
300,286
<p>Let's say we have</p> <pre><code>public interface ITimestampProvider { DateTime GetTimestamp(); } </code></pre> <p>and a class which consumes it</p> <pre><code>public class Timestamped { private ITimestampProvider _timestampProvider public Timestamped(ITimestampProvider timestampProvider) { // arg null check _timestampProvider = timestampProvider; } public DateTime Timestamp { get; private set; } public void Stamp() { this.Timestamp = _timestampProvider.GetTimestamp(); } } </code></pre> <p>and a default implementation of:</p> <pre><code>public sealed class SystemTimestampProvider : ITimestampProvider { public DateTime GetTimestamp() { return DateTime.Now; } } </code></pre> <p>Is it helpful or harfmful to introduce this constructor?</p> <pre><code>public Timestamped() : this(new SystemTimestampProvider()) {} </code></pre> <p>This is a general question, i.e. timestamping is not the interesting part.</p>
[ { "answer_id": 300305, "author": "Charles Bretana", "author_id": 32632, "author_profile": "https://Stackoverflow.com/users/32632", "pm_score": 2, "selected": false, "text": " public class EventsLogic\n { \n private readonly IEventDAL ievtDal;\n public IEventDAL IEventDAL { get { return ievtDal; } }\n\n public EventsLogic(): this(null) {}\n public EventsLogic(IIEEWSDAL wsDal, IEventDAL evtDal)\n {\n ievtDal = evtDal ?? new EventDAL();\n }\n }\n" }, { "answer_id": 300319, "author": "Michael Meadows", "author_id": 7643, "author_profile": "https://Stackoverflow.com/users/7643", "pm_score": 0, "selected": false, "text": "public DateTime Timestamp\n{\n get { return _timestampProvider??new SystemTimestampProvider(); }\n set { _timestampProvider = value; }\n}\n" }, { "answer_id": 300484, "author": "Jason Hernandez", "author_id": 34863, "author_profile": "https://Stackoverflow.com/users/34863", "pm_score": 0, "selected": false, "text": "public class Timestamped\n{\n private readonly ITimestampProvider _timestampProvider;\n\n public Timestamped(ITimestampProvider timestampProvider)\n {\n _timestampProvider = timestampProvider;\n }\n\n public Timestamped(): this(new SystemTimestampProvider())\n { }\n}\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37815/" ]
300,298
<p>If I have an embedded browser in a windows form, is it possible to initiate a javascript method from the container application? </p>
[ { "answer_id": 300311, "author": "Quintin Robinson", "author_id": 12707, "author_profile": "https://Stackoverflow.com/users/12707", "pm_score": 1, "selected": false, "text": "webBrowser.Document.InvokeScript(\"doSomething()\");\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9266/" ]
300,303
<p>I have an html like this:</p> <pre><code>&lt;div id="container1"&gt; &lt;div class="dragme"&gt;drag me&lt;/div&gt; &lt;/div&gt; &lt;div id="container2"&gt; &lt;div class="dragme"&gt;drag me&lt;/div&gt; &lt;/div&gt; &lt;div id="droponme"&gt;&lt;/div&gt; $(".dragme").draggable(); $("#droponme").droppable({ accept: ".dragme", drop: function(e, u) { alert( /* find id of the container here*/ ); }; }); </code></pre> <p>I want to find the container of the draggable object on drop event handler. How can I do this?</p>
[ { "answer_id": 300364, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 3, "selected": true, "text": "$(\".dragme\").draggable();\n$(\"#droponme\").droppable({\n accept: \".dragme\",\n drop: function(e, u) {\n alert(u.draggable.parent().attr('id') );\n // in your example: container1 or container2\n }\n});\n" }, { "answer_id": 24266771, "author": "user2675708", "author_id": 2675708, "author_profile": "https://Stackoverflow.com/users/2675708", "pm_score": 0, "selected": false, "text": "$(\".dragme\").draggable();\n$(\"#droponme\").droppable({\n accept: \".dragme\",\n drop: function(e, u) {\n alert(e.toElement);\n }\n});\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31505/" ]
300,306
<p>What I'm looking for looks like this in jQuery:</p> <pre><code>jQuery.ajaxSetup({ 'beforeSend': function(xhr) { xhr.setRequestHeader("Accept", "text/javascript"); } }); ... $("#my_form").submit({ $.post($(this).attr("action", $(this).serialize(), null, "script"); return false; }); </code></pre> <p>Then, when my server returns some Javascript (the Accept-header bit), jQuery executes it (that last "script" parameter).</p> <p>I'm trying to get the same effect in Dojo. My best guess is:</p> <pre><code>form = dojo.byId("my_form") form.onsubmit = function() { dojo.xhrGet({ url: form.action, form: form, handleAs: "javascript" }) } </code></pre> <p>The <code>handleAs: "javascript"</code> should cause Dojo to execute the response as JS. My problem is that I can't figure out how to set the header so that my web server (a <code>respond_to do |format|</code> block in Rails) knows what to return.</p>
[ { "answer_id": 300478, "author": "James A. Rosen", "author_id": 1190, "author_profile": "https://Stackoverflow.com/users/1190", "pm_score": 2, "selected": false, "text": "form = dojo.byId(\"my_form\")\n form.onsubmit = function() {\n dojo.xhrGet({\n url: form.action,\n form: form,\n handleAs: \"javascript\",\n headers: { \"Accept\": \"text/javascript\" }\n })\n}\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1190/" ]
300,315
<p>Is there a way to force IE or FF into a handheld mode for testing "@media handheld" stylesheets?</p> <p>Or, do I have to publish the pages and test with my Blackberry?</p> <p>I'd prefer to test this without pushing the application to the live server as the application is already in use.</p> <p>Any ideas for me?</p>
[ { "answer_id": 300502, "author": "Kornel", "author_id": 27009, "author_profile": "https://Stackoverflow.com/users/27009", "pm_score": 0, "selected": false, "text": "html {max-width:240px} media=screen handheld" }, { "answer_id": 996796, "author": "ilya n.", "author_id": 115200, "author_profile": "https://Stackoverflow.com/users/115200", "pm_score": 2, "selected": false, "text": "@media handheld, screen and (max-width: 500px) { /* your css */ }\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300315", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20848/" ]
300,316
<p>Here's the deal. I have a hash map containing data I call "program codes", it lives in an object, like so:</p> <pre><code>Class Metadata { private HashMap validProgramCodes; public HashMap getValidProgramCodes() { return validProgramCodes; } public void setValidProgramCodes(HashMap h) { validProgramCodes = h; } } </code></pre> <p>I have lots and lots of reader threads each of which will call getValidProgramCodes() once and then use that hashmap as a read-only resource.</p> <p>So far so good. Here's where we get interesting.</p> <p>I want to put in a timer which every so often generates a new list of valid program codes (never mind how), and calls setValidProgramCodes.</p> <p>My theory -- which I need help to validate -- is that I can continue using the code as is, without putting in explicit synchronization. It goes like this: At the time that validProgramCodes are updated, the value of validProgramCodes is always good -- it is a pointer to either the new or the old hashmap. <em>This is the assumption upon which everything hinges.</em> A reader who has the old hashmap is okay; he can continue to use the old value, as it will not be garbage collected until he releases it. Each reader is transient; it will die soon and be replaced by a new one who will pick up the new value.</p> <p>Does this hold water? My main goal is to avoid costly synchronization and blocking in the overwhelming majority of cases where no update is happening. We only update once per hour or so, and readers are constantly flickering in and out.</p>
[ { "answer_id": 300330, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": -1, "selected": false, "text": "FastHashMap validProgramCodes volatile" }, { "answer_id": 300341, "author": "erickson", "author_id": 3474, "author_profile": "https://Stackoverflow.com/users/3474", "pm_score": 5, "selected": false, "text": "import java.util.Collections;\n\nclass Metadata {\n\n private volatile Map validProgramCodes = Collections.emptyMap();\n\n public Map getValidProgramCodes() { \n return validProgramCodes; \n }\n\n public void setValidProgramCodes(Map h) { \n if (h == null)\n throw new NullPointerException(\"validProgramCodes == null\");\n validProgramCodes = Collections.unmodifiableMap(new HashMap(h));\n }\n\n}\n unmodifiableMap new HashMap(h) List Map ArrayList HashMap. volatile HashMap codes = new HashMap();\ncodes.putAll(source);\nmeta.setValidProgramCodes(codes);\n setValidCodes validProgramCodes = h; 1: meta.validProgramCodes = codes = new HashMap();\n 2: codes.putAll(source);\n 1: Map codes = meta.getValidProgramCodes();\n 2: Iterator i = codes.entrySet().iterator();\n 3: while (i.hasNext()) {\n 4: Map.Entry e = (Map.Entry) i.next();\n 5: // Do something with e.\n 6: }\n volatile synchronized" }, { "answer_id": 300365, "author": "bruno conde", "author_id": 31136, "author_profile": "https://Stackoverflow.com/users/31136", "pm_score": 2, "selected": false, "text": "validProgramCodes private volatile HashMap validProgramCodes;\n validProgramCodes HasMap" }, { "answer_id": 300394, "author": "Ken Gentle", "author_id": 8709, "author_profile": "https://Stackoverflow.com/users/8709", "pm_score": -1, "selected": false, "text": "Hashmap volatile HashMap" }, { "answer_id": 302165, "author": "Tom Hawtin - tackline", "author_id": 4725, "author_profile": "https://Stackoverflow.com/users/4725", "pm_score": 2, "selected": false, "text": "HashMap volatile" }, { "answer_id": 305725, "author": "Alex Miller", "author_id": 7671, "author_profile": "https://Stackoverflow.com/users/7671", "pm_score": 2, "selected": false, "text": " public class Metadata\n {\n private HashMap validProgramCodes;\n private ReadWriteLock lock = new ReentrantReadWriteLock();\n\n public HashMap getValidProgramCodes() { \n lock.readLock().lock();\n try {\n return validProgramCodes; \n } finally {\n lock.readLock().unlock();\n }\n }\n\n public void setValidProgramCodes(HashMap h) { \n lock.writeLock().lock();\n try {\n validProgramCodes = h; \n } finally {\n lock.writeLock().unlock();\n }\n }\n }\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38716/" ]
300,321
<p>Do you localize your javascript to the page, or have a master "application.js" or similar?</p> <p>If it's the latter, what is the best practice to make sure your .js isn't executing on the wrong pages?</p> <p>EDIT: by javascript I mean custom javascript you write as a developer, not js libraries. I can't imagine anyone would copy/paste the jQuery source into their page but you never know.</p>
[ { "answer_id": 300375, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 3, "selected": false, "text": "SITE/javascripts script script script onload" }, { "answer_id": 300438, "author": "Karim", "author_id": 2494, "author_profile": "https://Stackoverflow.com/users/2494", "pm_score": 0, "selected": false, "text": "return array('prototype.js','mycalendar.js');\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34133/" ]
300,327
<p>I'm jealous of the rails guys. They can do this:</p> <pre><code>&lt;%= javascript_include_tag "all_min" %&gt; </code></pre> <p>... and I'm stuck doing this:</p> <pre><code>&lt;script src="/public/javascript/jquery/jquery.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="/public/javascript/jquery/jquery.tablesorter.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="/public/javascript/jquery/jquery.tablehover.pack.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="/public/javascript/jquery/jquery.validate.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="/public/javascript/jquery/jquery.form.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="/public/javascript/jquery/application.js" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>Are there any libraries to compress, gzip and combine multiple js files? How about CSS files?</p>
[ { "answer_id": 300371, "author": "bdukes", "author_id": 2688, "author_profile": "https://Stackoverflow.com/users/2688", "pm_score": 3, "selected": false, "text": "<asp:ScriptManager runat=\"server\">\n <CompositeScript>\n <Scripts>\n <asp:ScriptReference Path=\"~/public/javascript/jquery/jquery.js\" />\n <asp:ScriptReference Path=\"~/public/javascript/jquery/jquery.tablesorter.js\" />\n <asp:ScriptReference Path=\"~/public/javascript/jquery/jquery.tablehover.pack.js\" />\n <asp:ScriptReference Path=\"~/public/javascript/jquery/jquery.validate.js\" />\n <asp:ScriptReference Path=\"~/public/javascript/jquery/jquery.form.js\" />\n <asp:ScriptReference Path=\"~/public/javascript/jquery/application.js\" />\n </Scripts>\n </CompositeScript>\n</asp:ScriptManager>\n" }, { "answer_id": 300379, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 2, "selected": false, "text": "<%= javascript_include_tag \"all_min\" %>\n <%= %> Response.Write" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34133/" ]
300,328
<p>I have a third-party library in my SVN repository and I'd like to associate source/javadoc with it locally in Eclipse. I.e., there should be some local setting (for example, an entry in the <code>local.properties</code> file) that associates the source/javadoc with the JAR file, but which doesn't introduce local dependencies into the repository via <code>.classpath</code>. Ideally I'd have</p> <pre><code>lib_src_dir = /my/path/to/lib/src </code></pre> <p>in <code>local.properties</code> and then</p> <pre><code>&lt;classpathentry kind="lib" path="lib.jar" sourcepath="${lib_src_dir}"&gt; </code></pre> <p>in <code>.classpath</code>. Can this be done? </p> <p>[EDIT] @VonC's answer is helpful... Is there a way to load Path Variables from a text file (e.g., <code>local.properties</code>) instead of going through Window -> Preferences -> General -> Workspace -> Linked Resources?</p>
[ { "answer_id": 300346, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 5, "selected": true, "text": "/my/path/to/lib/src Linked Resources classpathentry source [myPrefs.epf] pathvariable /instance/org.eclipse.core.resources/pathvariable.MY_DIRECTORY=/my/path/to/lib/src\n Linked Resources .epf README.txt Task Tasks" }, { "answer_id": 303201, "author": "erickson", "author_id": 3474, "author_profile": "https://Stackoverflow.com/users/3474", "pm_score": 1, "selected": false, "text": "common/ \n lib/\n java/ <-- JAVA_LIB_DIR variable points to this directory\n axis/\n bitronix/\n 1.0/bitronix.jar \"extension\" is \"bitronix/1.0/bitronix.jar\"\n ...\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1412/" ]
300,334
<p>I have a process that runs on a UNIX (Solaris) server that runs nightly and needs to be able to send out encrypted emails.</p> <p>I only need the "encryption" portion, NOT the digital signature / self-repudiation part of PKI.</p> <p>I use MS Outlook in a corporate setting and I am assuming that when a user clicks "Publish to GAL..." under Tools -> Options -> Security, this will publish their PUBLIC KEY to the Global Address List (GAL).</p> <p>So I am thinking that I need a way to connect to the Exchange Server that the GAL is on from my UNIX server. Then I would need to retrieve the recepients PUBLIC KEY. Then I could encrypt the email using the recepients PUBLIC KEY. This would encrypt the email and only allow someone with the recepients PRIVATE KEY to read the email right? Then I would send out the email. But, what I am not sure about, is how to encrypt the email using only the recepients PUBLIC KEY (no KEYS on the UNIX side) in a way that MS Outlook will be able to read the email when the recepient receives it?</p> <p>Would this work? Anybody out there run into a similiar problem and come up with a solution? Java code is preferred, but any langauge would do to start with.</p> <p>Any additional details required in order to get a reasonable answer?</p> <p>Thanks</p>
[ { "answer_id": 401914, "author": "bethlakshmi", "author_id": 49962, "author_profile": "https://Stackoverflow.com/users/49962", "pm_score": 3, "selected": false, "text": "cryptoAlgorithm(plaintext, public key) = ciphertext\n\ncryptoAlgorithm(ciphertext, private key) = plaintext\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
300,339
<p>Can anyone tell me how to display all the selected value of my multi value parameter in SSRS report. When giving <code>parameter.value</code> option it gives error.</p>
[ { "answer_id": 300362, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 7, "selected": false, "text": "=Join(Parameters!Product.Label, \",\")\n" }, { "answer_id": 627853, "author": "Booji Boy", "author_id": 1433, "author_profile": "https://Stackoverflow.com/users/1433", "pm_score": 3, "selected": false, "text": "Public Function ShowParmValues(ByVal parm as Parameter) as string\n Dim s as String \n\n For i as integer = 0 to parm.Count-1\n s &= CStr(parm.value(i)) & IIF( i < parm.Count-1, \", \",\"\")\n Next\n Return s\nEnd Function \n" }, { "answer_id": 53882311, "author": "Markive", "author_id": 181197, "author_profile": "https://Stackoverflow.com/users/181197", "pm_score": 0, "selected": false, "text": "= \"Select * from tProducts Where 1 = 1 \" \nIIF(Parameters!ProductID.Value(0)=-1,Nothing,\" And ProductID In (\" & Join(Parameters!ProductID.Value,\"','\") & \")\")\n SELECT -1 As ProductID, 'All' as ProductName Union All\n Select \n tProducts.ProductID,tProducts.ProductName\n FROM\n tProducts\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
300,344
<p>I have a class which has a private member <code>$content</code>. This is wrapped by a get-method:</p> <pre><code>class ContentHolder { private $content; public function __construct() { $this-&gt;content = ""; } public function getContent() { return $this-&gt;content; } } $c = new ContentHolder(); $foo = array(); $foo['c'] = $c-&gt;getContent(); </code></pre> <p>Now <code>$foo['c']</code> is a reference to <code>content</code>, which is what I don't understand. How can I get the value? Thank You in advance.</p>
[ { "answer_id": 300358, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 1, "selected": false, "text": "$foo = new array(); $foo = array(); var_dump($foo);\n array(1) {\n [\"c\"]=>\n string(0) \"\"\n}\n echo echo \"foo[c] = '\" . $foo['c'] . \"'\\n\";\n foo[c] = ''\n" }, { "answer_id": 300378, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 2, "selected": false, "text": "public function __construct() {\n $this->content = \"test\";\n}\n\n$c = new ContentHolder();\n$foo = array();\n$foo['c'] = $c->getContent();\n\nprint $foo['c']; // prints \"test\"\nprint $c->getContent(); // prints \"test\"\n" }, { "answer_id": 300388, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 3, "selected": false, "text": "$foo['c'] $content $foo['c'] $content public function &getContent()\n{\n return $this->content;\n}\n $foo['c'] = &$c->getContent();\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300344", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
300,360
<p>I want to create buttons with icons in Flex dynamically using Actionscript.</p> <p>I tried this, with no success:</p> <pre><code>var closeButton = new Button(); closeButton.setStyle("icon", "@Embed(source='images/closeWindowUp.png"); </code></pre>
[ { "answer_id": 300431, "author": "HanClinto", "author_id": 26933, "author_profile": "https://Stackoverflow.com/users/26933", "pm_score": 0, "selected": false, "text": "closeButton.setStyle(\"icon\", \"@Embed(source='images/closeWindowUp.png\");\n closeButton.setStyle(\"icon\", \"@Embed(source='images/closeWindowUp.png')\");\n" }, { "answer_id": 300768, "author": "Kevin Beck", "author_id": 24734, "author_profile": "https://Stackoverflow.com/users/24734", "pm_score": 5, "selected": true, "text": "// Classes for icons\n[Embed(source='images/closeWindowUp.png')]\npublic static var CloseWindowUp:Class;\n[Embed(source='/images/Down_Up.png')]\npublic static var Down_Up:Class;\n[Embed(source='/images/Up_Up.png')]\npublic static var Up_Up:Class;\n var buttonHBox:HBox = new HBox();\nvar closeButton:Button = new Button();\nvar upButton:Button = new Button();\nvar downButton:Button = new Button();\n\ncloseButton.setStyle(\"icon\", SimpleWLM.CloseWindowUp);\nbuttonHBox.addChild(closeButton);\n\nupButton.setStyle(\"icon\", SimpleWLM.Up_Up);\nbuttonHBox.addChild(upButton);\n\ndownButton.setStyle(\"icon\", SimpleWLM.Down_Up);\nbuttonHBox.addChild(downButton);\n" }, { "answer_id": 301628, "author": "Theo", "author_id": 1109, "author_profile": "https://Stackoverflow.com/users/1109", "pm_score": 2, "selected": false, "text": "@Embed closeButton.setStyle(\"icon\", @Embed(source=\"images/closeWindowUp.png\"));\n" }, { "answer_id": 2735570, "author": "Vadim Sluzky", "author_id": 313985, "author_profile": "https://Stackoverflow.com/users/313985", "pm_score": 2, "selected": false, "text": "[Embed(source='com/images/play.png')]\n[Bindable]\npublic var imagePlay:Class; \n\n[Embed(source='com/images/pause.png')]\n[Bindable]\npublic var imagePause:Class;\n private function playpause():void\n{\n if (seesmicVideo.playing)\n {\n seesmicVideo.pause();\n btn_play.setStyle(\"icon\",imagePlay);\n }\n else\n {\n seesmicVideo.play();\n btn_play.setStyle(\"icon\",imagePause);\n }\n} \n" }, { "answer_id": 21018643, "author": "Zac", "author_id": 971443, "author_profile": "https://Stackoverflow.com/users/971443", "pm_score": 1, "selected": false, "text": "<mx:Button id=\"buttonPlay\" label=\"Play\" click=\"playButtonClicked();\" enabled=\"false\" icon=\"@Embed('./play.png')\"/>\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24734/" ]
300,376
<p>I'm trying to select the "name" field from the author node in an ATOM feed using LINQ. I can get all the fields I need like so:</p> <pre><code>XDocument stories = XDocument.Parse(xmlContent); XNamespace xmlns = "http://www.w3.org/2005/Atom"; var story = from entry in stories.Descendants(xmlns + "entry") select new Story { Title = entry.Element(xmlns + "title").Value, Content = entry.Element(xmlns + "content").Value }; </code></pre> <p>How would I go about selecting the author -> name field in this scenario? </p>
[ { "answer_id": 300418, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "entry.Element(xmlns + \"author\").Element(xmlns + \"name\").Value\n" }, { "answer_id": 300501, "author": "bruno conde", "author_id": 31136, "author_profile": "https://Stackoverflow.com/users/31136", "pm_score": 2, "selected": false, "text": " var story = from entry in stories.Descendants(xmlns + \"entry\")\n from a in entry.Descendants(xmlns + \"author\")\n select new Story\n {\n Title = entry.Element(xmlns + \"title\").Value,\n Content = entry.Element(xmlns + \"subtitle\").Value,\n Author = new AuthorInfo(\n a.Element(xmlns + \"name\").Value,\n a.Element(xmlns + \"email\").Value,\n a.Element(xmlns + \"uri\").Value\n )\n };\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2913/" ]
300,380
<p>Something's slowing down my Javascript code in IE6 to where there's a noticeable lag on hover. It's fine in FF, so using firebug isn't that helpful. What tools are out there to help debug this in IE?</p> <p><strong>A little more info:</strong> I don't think there's actually any JS running on the objects that I'm mousing over. (At least none that I've put in.) Just css :hover stuff. Also, I've got both jquery and dojo running on the project, so who knows what they're doing in the background.</p>
[ { "answer_id": 300934, "author": "some", "author_id": 36866, "author_profile": "https://Stackoverflow.com/users/36866", "pm_score": 3, "selected": false, "text": "for (var i=0, i < 200; i++) { s = s + \"something\";}\n var s=[];\nfor (var i=0; i < 200; i++) s.push(\"something\");\ns=s.join(\"\");\n" }, { "answer_id": 302039, "author": "Rakesh Pai", "author_id": 20089, "author_profile": "https://Stackoverflow.com/users/20089", "pm_score": 3, "selected": false, "text": "var startTime = new Date();\n// Lots of heavy code here\nconsole.log(\"Processing time: \", new Date() - startTime, \" ms\");\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24197/" ]
300,383
<p>I have some Jasper reports which are displayed in HTML format. I would like the width of the columns in the HTML tables to automatically resize to fit the content of the widest cell (in that column), such that all the data is displayed.</p> <p>Currently this does not happen because the HTML generated by Jasper specifies fixed widths for the &lt;table&gt; and some &lt;td&gt; elements, e.g.</p> <pre><code>&lt;td style="width: 20px; height: 17px;"&gt; &lt;span style="font-family: Arial; font-size: 11px;"&gt;foo-bar-baz@examp&lt;/span&gt; &lt;/td&gt; </code></pre> <p>I can't simply remove all these width properties (using JavaScript), because (as shown in the HTML above) any data that would be hidden when using these widths is not even returned to the client-side</p> <p>Cheers, Don</p>
[ { "answer_id": 306816, "author": "Jamie Love", "author_id": 27308, "author_profile": "https://Stackoverflow.com/users/27308", "pm_score": 3, "selected": false, "text": "<textField isStretchWithOverflow=\"true\" hyperlinkType=\"None\">\n <reportElement style=\"Report Sub-Title\" x=\"0\" y=\"84\" width=\"802\" height=\"20\"/>\n <textElement/>\n <textFieldExpression class=\"java.lang.String\">\n <![CDATA[\"For the period ...]]>\n </textFieldExpression>\n</textField>\n" }, { "answer_id": 5584936, "author": "Dave Jarvis", "author_id": 59087, "author_profile": "https://Stackoverflow.com/users/59087", "pm_score": 3, "selected": false, "text": "FastReportBuilder drb = new FastReportBuilder();\ndrb.addColumn(\"State\", \"state\", String.class.getName(),20)\n .addColumn(\"Branch\", \"branch\", String.class.getName(),30)\n .addColumn(\"Quantity\", \"quantity\", Long.class.getName(),60,true)\n .addColumn(\"Amount\", \"amount\", Float.class.getName(),70,true)\n .addBarcodeColumn(\"Bar-Code\", \"amount\", Long.class.getName(), BarcodeTypes.USD3, true,\nfalse,null, 100, true, ImageScaleMode.FILL, null)\n .addGroups(1)\n .setDetailHeight(30)\n .setTitle(\"November 2006 sales report\")\n .setSubtitle(\"This report was generated at \" + new Date())\n .setUseFullPageWidth(true); \n\nDynamicReport dr = drb.build();\n true addColumn false setUseFullPageWidth( true )" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
300,389
<p>i am programatically adding Webcontrols in to a User Control i am also adding a javascript event passing the controlID as a parameter but the clientID is the one i assigned a it does not contain the one that asp.net generates</p> <pre><code> var txt = new TextBox(); txt.ID = "MyID"+Number; chkBox.Attributes.Add("onClick", "EnableTxtBox('" +txt.ClientID + "');"); </code></pre> <p>i can workAround this by adding the parent control ID</p> <pre><code> chkBox.Attributes.Add("onClick", "EnableTxtBox('" + this.ClientID+"_"+txt.ClientID + "');"); </code></pre> <p>On which Page life cycle are the Client IDs generated?</p>
[ { "answer_id": 300466, "author": "baretta", "author_id": 30052, "author_profile": "https://Stackoverflow.com/users/30052", "pm_score": 4, "selected": true, "text": " var txt = new TextBox();\n txt.ID = \"MyID\"+Number;\n Controls.Add ( txt );\n chkBox.Attributes.Add(\"onClick\", \"EnableTxtBox('\" +txt.ClientID + \"');\");\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14440/" ]
300,402
<p>When I make the same query twice, the second time it does not return new rows form the database (I guess it just uses the cache).</p> <p>This is a Windows Form application, where I create the dataContext when the application starts.</p> <p>How can I force Linq to SQL not to use the cache?</p> <p>Here is a sample function where I have the problem:</p> <pre><code>public IEnumerable&lt;Orders&gt; NewOrders() { return from order in dataContext.Orders where order.Status == 1 select order; } </code></pre>
[ { "answer_id": 300409, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "public IEnumerable<Orders> NewOrders()\n{\n return dataContext.Orders.Where(order => order.Status == 1);\n}\n" }, { "answer_id": 7185756, "author": "Simon_Weaver", "author_id": 16940, "author_profile": "https://Stackoverflow.com/users/16940", "pm_score": 0, "selected": false, "text": "var transaction = new InventoryTransaction()\n {\n AdjustmentDate = currentTime,\n QtyAdjustment = 5,\n InventoryProductId = inventoryProductId\n };\n\ndbContext.InventoryTransactions.Add(transaction);\ndbContext.SubmitChanges();\n InventoryTransactions var transaction = new InventoryTransaction()\n {\n AdjustmentDate = currentTime,\n QtyAdjustment = 5\n };\n\ninventoryProduct.InventoryTransactions.Add(transaction);\ndbContext.SubmitChanges();\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8547/" ]
300,416
<p>For my IIS website, I'd like to redirect ALL requests to ONE page. The purpose of this is that I want to do some maintenance on the database (take it off-line) that all my web applications use. I have about 50 web apps running under this website, so I'd like to avoid visiting each of them to change something. I'm thinking I could make a single change in machine.config? Any hints would be appreciated.</p>
[ { "answer_id": 2659831, "author": "se_pavel", "author_id": 80917, "author_profile": "https://Stackoverflow.com/users/80917", "pm_score": 6, "selected": false, "text": " <rewrite>\n <rules>\n <rule name=\"redirect all requests\" stopProcessing=\"true\">\n <match url=\"^(.*)$\" ignoreCase=\"false\" />\n <conditions logicalGrouping=\"MatchAll\">\n <add input=\"{REQUEST_FILENAME}\" matchType=\"IsFile\" negate=\"true\" pattern=\"\" ignoreCase=\"false\" />\n </conditions>\n <action type=\"Rewrite\" url=\"index.php\" appendQueryString=\"true\" />\n </rule>\n </rules>\n </rewrite>\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300416", "https://Stackoverflow.com", "https://Stackoverflow.com/users/415491/" ]
300,417
<p>Say I have the following route:</p> <pre><code>routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "" }); </code></pre> <p>Lets also say that my controller has the following methods: <code>Index(Int32 id)</code> and <code>Edit(Int32 id)</code>.</p> <p>So <code>/MyController/Index/1</code> is a valid URL for that route. So is <code>/MyController/Edit/1</code></p> <p>However, if a URL is received that correctly maps to my controller but not to an existing action, how do I define a "Default Action" to execute instead of letting the MVC framework throw up an error screen?</p> <p>Basically I'd like the URLs <code>/MyController/Preview/1</code> and <code>/MyController/Whatever/1</code> to execute an action that I specify ahead of time when the {action} token can't be mapped to an existing action on my controller.</p> <p>I see that the MvcContrib project on Codeplex has an attribute that enables this for use with the ConventionController, but I'd like to keep this with pure MS ASP.NET MVC for now.</p> <p>I also see that <a href="http://fredrik.nsquared2.com/viewpost.aspx?PostID=460" rel="noreferrer">Fredrik</a> mentions a <code>[ControllerAction(DefaultAction = true)]</code> attribute, but I can't find mention of it anywhere except his blog (and my app won't compile when I try it in my controller).</p>
[ { "answer_id": 300729, "author": "Haacked", "author_id": 598, "author_profile": "https://Stackoverflow.com/users/598", "pm_score": 5, "selected": true, "text": "protected override void HandleUnknownAction(string actionName) {\n //your code here.\n}\n routes.MapRoute(\"default-action\", \"{controller}/{actionName}/{id}\", new {action=\"DefaultAction\"});\n public ActionResult DefaultAction(string actionName, string id) {\n //handle default action\n}\n" }, { "answer_id": 9724702, "author": "Matthew Nichols", "author_id": 165031, "author_profile": "https://Stackoverflow.com/users/165031", "pm_score": 3, "selected": false, "text": "protected override void HandleUnknownAction(string actionName)\n{\n this.View(actionName).ExecuteResult(ControllerContext);\n}\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32588/" ]
300,424
<p>I have HTML code edited by FCKEditor stored in a database and would like to display (well render) it onto a view. So, for instance, something stored as:</p> <pre><code>&amp;lt;&amp;gt;pre&amp;lt;&amp;gt;This is some sample text&amp;lt;&amp;gt;pre&amp;lt;/&amp;gt </code></pre> <p>Will be displayed to the user as:</p> <pre><code>This is some sample text </code></pre> <p>(With the appropriate style for pre-formatted-text)</p> <p>The view already has the required string to display from <code>ViewData</code>, I'm just not sure what the best way to show it to the user is.</p>
[ { "answer_id": 300464, "author": "Pure.Krome", "author_id": 30674, "author_profile": "https://Stackoverflow.com/users/30674", "pm_score": 7, "selected": true, "text": "<%= System.Web.HttpUtility.HtmlDecode(yourEncodedHtmlFromYouDatabase) %>\n" }, { "answer_id": 11877792, "author": "whoblitz", "author_id": 587776, "author_profile": "https://Stackoverflow.com/users/587776", "pm_score": 6, "selected": false, "text": "@Html.Raw(System.Web.HttpUtility.HtmlDecode(Model.yourEncodedHtmlFromYourDatabase))\n @Html.Raw(Server.HtmlDecode(Model.yourEncodedHtmlFromYourDatabase))\n" }, { "answer_id": 44556456, "author": "Nerdroid", "author_id": 1592884, "author_profile": "https://Stackoverflow.com/users/1592884", "pm_score": 2, "selected": false, "text": "@Html.Raw(str)" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9913/" ]
300,427
<p>Is it possible to create a parameterized SQL statement that will taken an arbitrary number of parameters? I'm trying to allow users to filter a list based on multiple keywords, each separated by a semicolon. So the input would be something like "Oakland;City;Planning" and the WHERE clause would come out something equivalent to the below:</p> <pre>WHERE ProjectName LIKE '%Oakland%' AND ProjectName Like '%City%' AND ProjectName Like '%Planning%'</pre> <p>It's really easy to create such a list with concatenation, but I don't want to take that approach because of the SQL injection vulnerabilities. What are my options? Do I create a bunch of parameters and hope that users never try to use more parameters that I've defined? Or is there a way to create parameterized SQL on the fly safely?</p> <p>Performance isn't much of an issue because the table is only about 900 rows right now, and won't be growing very quickly, maybe 50 to 100 rows per year.</p>
[ { "answer_id": 300483, "author": "Ken Gentle", "author_id": 8709, "author_profile": "https://Stackoverflow.com/users/8709", "pm_score": 2, "selected": false, "text": "CONTAINS CONTAINSTABLE" }, { "answer_id": 303079, "author": "Kevin Fairchild", "author_id": 3743, "author_profile": "https://Stackoverflow.com/users/3743", "pm_score": 4, "selected": true, "text": "--Search Parameters\n\nDECLARE @SearchString VARCHAR(MAX)\nSET @SearchString='Oakland;City;Planning' --Using your example search\nDECLARE @Delim CHAR(1)\nSET @Delim=';' --Using your deliminator from the example\n\n--I didn't know your table name, so I'm making it... along with a few extra rows...\n\nDECLARE @Projects TABLE (ProjectID INT, ProjectName VARCHAR(200))\nINSERT INTO @Projects (ProjectID, ProjectName) SELECT 1, 'Oakland City Planning'\nINSERT INTO @Projects (ProjectID, ProjectName) SELECT 2, 'Oakland City Construction'\nINSERT INTO @Projects (ProjectID, ProjectName) SELECT 3, 'Skunk Works'\nINSERT INTO @Projects (ProjectID, ProjectName) SELECT 4, 'Oakland Town Hall'\nINSERT INTO @Projects (ProjectID, ProjectName) SELECT 5, 'Oakland Mall'\nINSERT INTO @Projects (ProjectID, ProjectName) SELECT 6, 'StackOverflow Answer Planning'\n\n--*** MAIN PROGRAM CODE STARTS HERE ***\n\nDECLARE @Keywords TABLE (Keyword VARCHAR(MAX))\n\nDECLARE @index int \nSET @index = -1 \n\n--Each keyword gets inserted into the table\n--Single keywords are handled, but I did not add code to remove duplicates\n--since that affects performance only, not the result.\n\nWHILE (LEN(@SearchString) > 0) \n BEGIN \n SET @index = CHARINDEX(@Delim , @SearchString) \n IF (@index = 0) AND (LEN(@SearchString) > 0) \n BEGIN \n INSERT INTO @Keywords VALUES (@SearchString)\n BREAK \n END \n IF (@index > 1) \n BEGIN \n INSERT INTO @Keywords VALUES (LEFT(@SearchString, @index - 1)) \n SET @SearchString = RIGHT(@SearchString, (LEN(@SearchString) - @index)) \n END \n ELSE \n SET @SearchString = RIGHT(@SearchString, (LEN(@SearchString) - @index)) \nEND\n\n\n--This way, only a project with all of our keywords will be shown...\n\nSELECT * \nFROM @Projects\nWHERE ProjectID NOT IN (SELECT ProjectID FROM @Projects Projects INNER JOIN @Keywords Keywords ON CHARINDEX(Keywords.Keyword,Projects.ProjectName)=0)\n" }, { "answer_id": 303083, "author": "DiningPhilanderer", "author_id": 30934, "author_profile": "https://Stackoverflow.com/users/30934", "pm_score": 1, "selected": false, "text": " INSERT INTO #ERXMLRead (ExpenseReportID)\n SELECT ParamValues.ID.value('.','VARCHAR(20)')\n FROM @ExpenseReportIDs.nodes('/Root/ExpenseReportID') as ParamValues(ID)\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21979/" ]
300,445
<p>I have a unicode string like "Tanım" which is encoded as "Tan%u0131m" somehow. How can i convert this encoded string back to original unicode. Apparently urllib.unquote does not support unicode.</p>
[ { "answer_id": 300531, "author": "Markus Jarderot", "author_id": 22364, "author_profile": "https://Stackoverflow.com/users/22364", "pm_score": 4, "selected": false, "text": "def unquote(text):\n def unicode_unquoter(match):\n return unichr(int(match.group(1),16))\n return re.sub(r'%u([0-9a-fA-F]{4})',unicode_unquoter,text)\n" }, { "answer_id": 300533, "author": "Aaron Maenpaa", "author_id": 2603, "author_profile": "https://Stackoverflow.com/users/2603", "pm_score": 7, "selected": true, "text": ">>> urllib2.unquote(\"%0a\")\n'\\n'\n >>> u\"Tanım\"\nu'Tan\\u0131m'\n>>> url = urllib.quote(u\"Tanım\".encode('utf8'))\n>>> urllib.unquote(url).decode('utf8')\nu'Tan\\u0131m'\n" }, { "answer_id": 300556, "author": "Ali Afshar", "author_id": 28380, "author_profile": "https://Stackoverflow.com/users/28380", "pm_score": 3, "selected": false, "text": "from urllib import unquote\n\ndef unquote_u(source):\n result = unquote(source)\n if '%u' in result:\n result = result.replace('%u','\\\\u').decode('unicode_escape')\n return result\n\nprint unquote_u('Tan%u0131m')\n\n> Tanım\n" }, { "answer_id": 370365, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "def unquote_u(source):\n result = source\n if '%u' in result:\n result = result.replace('%u','\\\\u').decode('unicode_escape')\n result = unquote(result)\n return result\n" }, { "answer_id": 55046446, "author": "Martijn Pieters", "author_id": 100297, "author_profile": "https://Stackoverflow.com/users/100297", "pm_score": 2, "selected": false, "text": "urllib.parse.unquote() %uhhhh %hh str try:\n # Python 3\n from urllib.parse import unquote\n unichr = chr\nexcept ImportError:\n # Python 2\n from urllib import unquote\n\ndef unquote_unicode(string, _cache={}):\n string = unquote(string) # handle two-digit %hh components first\n parts = string.split(u'%u')\n if len(parts) == 1:\n return parts\n r = [parts[0]]\n append = r.append\n for part in parts[1:]:\n try:\n digits = part[:4].lower()\n if len(digits) < 4:\n raise ValueError\n ch = _cache.get(digits)\n if ch is None:\n ch = _cache[digits] = unichr(int(digits, 16))\n if (\n not r[-1] and\n u'\\uDC00' <= ch <= u'\\uDFFF' and\n u'\\uD800' <= r[-2] <= u'\\uDBFF'\n ):\n # UTF-16 surrogate pair, replace with single non-BMP codepoint\n r[-2] = (r[-2] + ch).encode(\n 'utf-16', 'surrogatepass').decode('utf-16')\n else:\n append(ch)\n append(part[4:])\n except ValueError:\n append(u'%u')\n append(part)\n return u''.join(r)\n >>> print(unquote_unicode('Tan%u0131m'))\nTanım\n>>> print(unquote_unicode('%u05D0%u05D9%u05DA%20%u05DE%u05DE%u05D9%u05E8%u05D9%u05DD%20%u05D0%u05EA%20%u05D4%u05D8%u05E7%u05E1%u05D8%20%u05D4%u05D6%u05D4'))\nאיך ממירים את הטקסט הזה\n>>> print(unquote_unicode('%ud83c%udfd6')) # surrogate pair\n\n>>> print(unquote_unicode('%ufoobar%u666')) # incomplete\n%ufoobar%u666\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12785/" ]
300,448
<p>On the user pages of Stack Overflow where the tabs are (Stats, Recent, Responses, etc.) you get the illusion that the tabs are extensions of the line they're sitting on. Stack Overflow creates this effect by defining pure CSS borders. I want to achieve the same effect but I have images both for the tabs and for the line they're sitting on.</p> <p>I have a box with rounded corners (white background, grey outline). Tabs are across the top, same colors. The tabs have rounded top corners and no bottom border. The tabs are in a div before the box's div.</p> <p>To accomplish the aforementioned effect, I imagine that the tab will have to come down and cover that part of the box's border where they meet. I accomplished this in Firefox but in IE you can still see the line of the box's border.</p> <p>How can you adjust this to work in both browsers?</p> <p>Here's my example that works in FF but not in IE: <a href="http://www.mcrackan.com/recipes/csstest-loggedin.htm" rel="nofollow noreferrer">http://www.mcrackan.com/recipes/csstest-loggedin.htm</a></p> <p>[<strong>Edit:</strong> fixed URL]</p>
[ { "answer_id": 300628, "author": "Ola Tuvesson", "author_id": 6903, "author_profile": "https://Stackoverflow.com/users/6903", "pm_score": 2, "selected": true, "text": "<style>\nul.tabs {\nborder-bottom: 1px solid blue;\nheight: 20px;\nmargin: 0;\npadding: 0;\nlist-style-type: none;\n}\n ul.tabs li {\n float: left;\n position: relative;\n bottom: 5px;\n margin: 0;\n padding: 0;\n }\n ul.tabs li img {\n float: left;\n height: 20px;\n width: 50px;\n border: none;\n }\n ul.tabs li.selected {\n bottom: -1px;\n }\n</style>\n\n<ul class=\"tabs\">\n <li><a href=\"\"><img src=\"tab1.gif\" /></a></li>\n <li class=\"selected\"><a href=\"\"><img src=\"tab2.gif\" /></a></li>\n <li><a href=\"\"><img src=\"tab3.gif\" /></a></li>\n</ul>\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/356/" ]
300,449
<p>I'm trying to get a list of processes currently owned by the current user (<code>Environment.UserName</code>). Unfortunately, the <code>Process</code> class doesn't have any way of getting the UserName of the user owning a process.</p> <p>How do you get the UserName of the user which is the owner of a process using the <code>Process</code> class so I can compare it to <code>Environment.UserName</code>? </p> <p>If your solution requires a <code>pinvoke</code>, please provide a code example.</p>
[ { "answer_id": 300535, "author": "Andrew Moore", "author_id": 26210, "author_profile": "https://Stackoverflow.com/users/26210", "pm_score": 4, "selected": false, "text": "public class App\n{\n public static void Main(string[] Args)\n {\n Management.ManagementObjectSearcher Processes = new Management.ManagementObjectSearcher(\"SELECT * FROM Win32_Process\");\n\n foreach (Management.ManagementObject Process in Processes.Get()) {\n if (Process[\"ExecutablePath\"] != null) {\n string ExecutablePath = Process[\"ExecutablePath\"].ToString();\n\n string[] OwnerInfo = new string[2];\n Process.InvokeMethod(\"GetOwner\", (object[]) OwnerInfo);\n\n Console.WriteLine(string.Format(\"{0}: {1}\", IO.Path.GetFileName(ExecutablePath), OwnerInfo[0]));\n }\n }\n\n Console.ReadLine();\n }\n}\n" }, { "answer_id": 15110597, "author": "sean.net", "author_id": 762688, "author_profile": "https://Stackoverflow.com/users/762688", "pm_score": 2, "selected": false, "text": "private string GetUserName(string procName)\n{\n string query = \"SELECT * FROM Win32_Process WHERE Name = \\'\" + procName + \"\\'\";\n var procs = new System.Management.ManagementObjectSearcher(query);\n foreach (System.Management.ManagementObject p in procs.Get())\n {\n var path = p[\"ExecutablePath\"];\n if (path != null)\n {\n string executablePath = path.ToString();\n string[] ownerInfo = new string[2];\n p.InvokeMethod(\"GetOwner\", (object[])ownerInfo);\n return ownerInfo[0];\n }\n }\n return null;\n}\n" }, { "answer_id": 46816625, "author": "Jesus is Lord", "author_id": 569302, "author_profile": "https://Stackoverflow.com/users/569302", "pm_score": 0, "selected": false, "text": "using System.Linq;\nusing System.Management;\n\nclass Program\n{\n /// <summary>\n /// Adapted from https://www.codeproject.com/Articles/14828/How-To-Get-Process-Owner-ID-and-Current-User-SID\n /// </summary>\n public static void GetProcessOwnerByProcessId(int processId, out string user, out string domain)\n {\n user = \"???\";\n domain = \"???\";\n\n var sq = new ObjectQuery(\"Select * from Win32_Process Where ProcessID = '\" + processId + \"'\");\n var searcher = new ManagementObjectSearcher(sq);\n if (searcher.Get().Count != 1)\n {\n return;\n }\n var process = searcher.Get().Cast<ManagementObject>().First();\n var ownerInfo = new string[2];\n process.InvokeMethod(\"GetOwner\", ownerInfo);\n\n if (user != null)\n {\n user = ownerInfo[0];\n }\n if (domain != null)\n {\n domain = ownerInfo[1];\n }\n }\n\n public static void Main()\n {\n var processId = System.Diagnostics.Process.GetCurrentProcess().Id;\n string user;\n string domain;\n GetProcessOwnerByProcessId(processId, out user, out domain);\n System.Console.WriteLine(domain + \"\\\\\" + user);\n }\n}\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26210/" ]
300,472
<p>Looking in the gnuwin32/bin directory, there is an odd-looking program file named <code>[.exe</code></p> <p>I couldn't find it in the documentation, gnuwin32.sourceforge.net or in a google search, so I ran it and got:</p> <pre><code>$ [ [: missing `]' $ </code></pre> <p>so I gave it ] as a parameter and got</p> <pre><code>$ [ ] $ </code></pre> <p>It didn't complain, so I assumed it was on the right track. I tried:</p> <pre><code>$ [ hello ] </code></pre> <p>again, no complaints. so I tried an arithmetic expression:</p> <pre><code>$ [ 1 + 1 ] [: +: binary operator expected $ </code></pre> <p>I tried a bunch of different combinations, including prefix &amp; postfix notation but nothing seemed to work. What does this thing do?</p>
[ { "answer_id": 300477, "author": "tusho", "author_id": 22331, "author_profile": "https://Stackoverflow.com/users/22331", "pm_score": 3, "selected": false, "text": "test a\n [ a ]\n" }, { "answer_id": 300508, "author": "Cristian Diaconescu", "author_id": 11545, "author_profile": "https://Stackoverflow.com/users/11545", "pm_score": 4, "selected": true, "text": "test if [ \"$LOGNAME\" = \"scott\" ]\nthen\n echo \"Logged in as Scott\"\nelse\n echo \"incorrect user\"\nfi\n [ [ [\"$LOGNAME\" expr" }, { "answer_id": 301541, "author": "CesarB", "author_id": 28258, "author_profile": "https://Stackoverflow.com/users/28258", "pm_score": 0, "selected": false, "text": "test help help test" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4086/" ]
300,491
<p>I'm trying to implement paging using row-based limiting (for example: <code>setFirstResult(5)</code> and <code>setMaxResults(10)</code>) on a Hibernate Criteria query that has joins to other tables.</p> <p>Understandably, data is getting cut off randomly; and the reason for that is explained <a href="https://developer.jboss.org/wiki/HibernateFAQ-AdvancedProblems#jive_content_id_Hibernate_does_not_return_distinct_results_for_a_query_with_outer_join_fetching_enabled_for_a_collection_even_if_I_use_the_distinct_keyword" rel="noreferrer">here</a>.</p> <p>As a solution, the page suggests using a "second sql select" instead of a join. </p> <p>How can I convert my existing criteria query (which has joins using <code>createAlias()</code>) to use a nested select instead?</p>
[ { "answer_id": 300708, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 8, "selected": true, "text": "criteria.setProjection(Projections.distinct(Projections.property(\"id\")));\n" }, { "answer_id": 2652385, "author": "JJ.", "author_id": 318415, "author_profile": "https://Stackoverflow.com/users/318415", "pm_score": 3, "selected": false, "text": "criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);\n" }, { "answer_id": 2864361, "author": "Krzysztof Barczyński", "author_id": 344916, "author_profile": "https://Stackoverflow.com/users/344916", "pm_score": -1, "selected": false, "text": "NullPointerException criteria.setProjection(Projections.distinct(Projections.property(\"id\"))) List result = getSession().createSQLQuery(\n\"SELECT distinct u.id as usrId, b.currentBillingAccountType as oldUser_type,\"\n+ \" r.accountTypeWhenRegister as newUser_type, count(r.accountTypeWhenRegister) as numOfRegUsers\"\n+ \" FROM recommendations r, users u, billing_accounts b WHERE \"\n+ \" r.user_fk = u.id and\"\n+ \" b.user_fk = u.id and\"\n+ \" r.activated = true and\"\n+ \" r.audit_CD > :monthAgo and\"\n+ \" r.bonusExceeded is null and\"\n+ \" group by u.id, r.accountTypeWhenRegister\")\n.addScalar(\"usrId\", Hibernate.LONG)\n.addScalar(\"oldUser_type\", Hibernate.INTEGER)\n.addScalar(\"newUser_type\", Hibernate.INTEGER)\n.addScalar(\"numOfRegUsers\", Hibernate.BIG_INTEGER)\n.setParameter(\"monthAgo\", monthAgo)\n.setMaxResults(20)\n.list();\n criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);\n" }, { "answer_id": 6280980, "author": "nikita", "author_id": 195565, "author_profile": "https://Stackoverflow.com/users/195565", "pm_score": 3, "selected": false, "text": "criteria.setProjection(Projections.distinct(Projections.id()));\n" }, { "answer_id": 7911803, "author": "Daniel Alexiuc", "author_id": 34553, "author_profile": "https://Stackoverflow.com/users/34553", "pm_score": 5, "selected": false, "text": "DetachedCriteria idsOnlyCriteria = DetachedCriteria.forClass(MyClass.class);\n//add other joins and query params here\nidsOnlyCriteria.setProjection(Projections.distinct(Projections.id()));\n\nCriteria criteria = getSession().createCriteria(myClass);\ncriteria.add(Subqueries.propertyIn(\"id\", idsOnlyCriteria));\ncriteria.setFirstResult(0).setMaxResults(50);\nreturn criteria.list();\n" }, { "answer_id": 11364451, "author": "Andreas Hartmann-schneevoigt", "author_id": 1211957, "author_profile": "https://Stackoverflow.com/users/1211957", "pm_score": 1, "selected": false, "text": "public static List<String> resolveCollectionProperties(Class<?> type) {\n List<String> ret = new ArrayList<String>();\n try {\n BeanInfo beanInfo = Introspector.getBeanInfo(type);\n for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {\n if (Collection.class.isAssignableFrom(pd.getPropertyType()))\n ret.add(pd.getName());\n }\n } catch (IntrospectionException e) {\n e.printStackTrace();\n }\n return ret;\n}\n Criteria criteria = …\n\n// … add your expression here …\n\n// set fetchmode for every Collection Property to SELECT\nfor (String property : ReflectUtil.resolveCollectionProperties(YourEntity.class)) {\n criteria.setFetchMode(property, org.hibernate.FetchMode.SELECT);\n}\ncriteria.setFirstResult(firstResult);\ncriteria.setMaxResults(maxResults);\ncriteria.list();\n" }, { "answer_id": 14210039, "author": "Yashpal Singla", "author_id": 1784818, "author_profile": "https://Stackoverflow.com/users/1784818", "pm_score": 0, "selected": false, "text": " package org.hibernate.criterion;\n\nimport org.hibernate.Criteria;\nimport org.hibernate.Hibernate;\nimport org.hibernate.HibernateException;\nimport org.hibernate.type.Type;\n\n/**\n* A count for style : count (distinct (a || b || c))\n*/\npublic class MultipleCountProjection extends AggregateProjection {\n\n private boolean distinct;\n\n protected MultipleCountProjection(String prop) {\n super(\"count\", prop);\n }\n\n public String toString() {\n if(distinct) {\n return \"distinct \" + super.toString();\n } else {\n return super.toString();\n }\n }\n\n public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery) \n throws HibernateException {\n return new Type[] { Hibernate.INTEGER };\n }\n\n public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery) \n throws HibernateException {\n StringBuffer buf = new StringBuffer();\n buf.append(\"count(\");\n if (distinct) buf.append(\"distinct \");\n String[] properties = propertyName.split(\";\");\n for (int i = 0; i < properties.length; i++) {\n buf.append( criteriaQuery.getColumn(criteria, properties[i]) );\n if(i != properties.length - 1) \n buf.append(\" || \");\n }\n buf.append(\") as y\");\n buf.append(position);\n buf.append('_');\n return buf.toString();\n }\n\n public MultipleCountProjection setDistinct() {\n distinct = true;\n return this;\n }\n\n}\n package org.hibernate.criterion; \n\npublic final class ExtraProjections\n{ \n public static MultipleCountProjection countMultipleDistinct(String propertyNames) {\n return new MultipleCountProjection(propertyNames).setDistinct();\n }\n}\n String propertyNames = \"titleName;titleDescr;titleVersion\"\n\ncriteria countCriteria = ....\n\ncountCriteria.setProjection(ExtraProjections.countMultipleDistinct(propertyNames);\n" }, { "answer_id": 14502188, "author": "Andoy Abarquez", "author_id": 1520102, "author_profile": "https://Stackoverflow.com/users/1520102", "pm_score": 2, "selected": false, "text": "session = (Session) getEntityManager().getDelegate();\nCriteria criteria = session.createCriteria(ComputedProdDaily.class);\nProjectionList projList = Projections.projectionList();\nprojList.add(Projections.property(\"user.id\"), \"userid\");\nprojList.add(Projections.property(\"loanState\"), \"state\");\ncriteria.setProjection(Projections.distinct(projList));\ncriteria.add(Restrictions.isNotNull(\"this.loanState\"));\ncriteria.setResultTransformer(Transformers.aliasToBean(UserStateTransformer.class));\n" }, { "answer_id": 24740802, "author": "rekinyz", "author_id": 1146450, "author_profile": "https://Stackoverflow.com/users/1146450", "pm_score": 2, "selected": false, "text": "criteria.setProjection(\n Projections.distinct(\n Projections.projectionList()\n .add(Projections.id())\n .add(Projections.property(\"the property that you want to ordered by\"))\n )\n);\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34553/" ]
300,498
<p>I have a FooController that responds to HTML and JS (AJAX) queries:</p> <pre><code># app/controllers/foo_controller.rb: class FooController &lt; ApplicationController layout 'foo' def bar respond_to do |format| format.html # foo/bar.html.erb format.js # foo/bar.js.erb end end end </code></pre> <p>The templates to support it:</p> <pre><code># app/views/layouts/foo.html.erb: &lt;html&gt;...&lt;%= yield %&gt;...&lt;/html&gt; # app/views/layouts/foo.json.erb: &lt;%= yield %&gt; </code></pre> <p>And an AJAX template in which I want to render a partial:</p> <pre><code># app/views/foo/bar.js.erb: dojo.byID('some_div').innerHTML = "&lt;%= escape_javascript(render(:partial =&gt; 'some/partial')) %&gt;"; </code></pre> <p>If the JS template just has plain old JS in it (like <code>alert('hi');</code>), it uses my JS template. When I put in the render(:partial), though, it makes the whole response use the HTML template, which means it's no longer valid JS.</p> <p>A possible solution is to use a function for the layout:</p> <pre><code>class FooController &lt; ApplicationController layout :choose_layout ... private def choose_layout return nil if request.xhr? 'foo' end end </code></pre> <p>But my version <em>should</em> work! Why doesn't it?</p>
[ { "answer_id": 301899, "author": "mwilliams", "author_id": 23909, "author_profile": "https://Stackoverflow.com/users/23909", "pm_score": 3, "selected": false, "text": "// views/reviews/create.js.erb\n$(\"#new_review\").before('<div id=\"flash_notice\"><%= escape_javascript(flash.delete(:notice)) %></div>');\n$(\"#reviews_count\").html(\"<%= pluralize(@review.product.reviews.count, 'Review') %>\");\n$(\"#reviews\").append(\"<%= escape_javascript(render(:partial => @review)) %>\");\n$(\"#new_review\")[0].reset();\n" }, { "answer_id": 574266, "author": "cowboysmall", "author_id": 69485, "author_profile": "https://Stackoverflow.com/users/69485", "pm_score": 1, "selected": false, "text": "class FooController < ApplicationController\n layout 'foo'\n def bar\n respond_to do |format|\n format.html\n format.js { render :layout => false }\n end\n end\nend\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1190/" ]
300,499
<p>When we talk about the .NET world the CLR is what everything we do depends on. What is the minimum knowledge of CLR a .NET programmer must have to be a good programmer? Can you give me one/many you think is/are the most important subjects: GC?, AppDomain?, Threads?, Processes?, Assemblies/Fusion? </p> <p>I will very much appreciate if you post a links to articles, blogs, books or other on the topic where more information could be found.</p> <p>Update: I noticed from some of comments that my question was not clear to some. When I say CLR I don't mean .Net Framework. It is NOT about memorizing .NET libraries, it is rather to understand how does the execution environment (in which those libraries live on runtime) work. </p> <p>My question was directly inspired by John Robbins the author of "Debugging Applications for Microsoft® .NET" book (which I recommend) and colleague of here cited Jeffrey Richter at Wintellect. In one of introductory chapters he is saying that "...any .NET programmer should know what is probing and how assemblies are loaded into runtime". Do you think there are other such things? </p> <p>Last Update: After having read first 5 chapters of "CLR via C#" I must say to anyone reading this. If you haven't allready, read this book!</p>
[ { "answer_id": 300511, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 6, "selected": true, "text": "string x = \"hello\";\n x x x" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2921654/" ]
300,509
<p>From a Java program, I need to launch the default browser on a local HTML file, pointed to an anchor inside the file. In Java SE 6, the java.awt.Desktop.browse method will open the file, but will not honor the anchor, so something like the following opens the file at the top, but does not page the browser to the anchor:</p> <pre><code>Desktop.getDesktop("file:///C:/foo/bar.html#anchor"); </code></pre> <p>Sun says here <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6477862" rel="noreferrer">http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6477862</a> that anchors are not supported in the file URI protocol.</p> <p>Does anyone have a better answer?</p> <p>I can use Java SE 6. I would be OK with a Windows only solution.</p>
[ { "answer_id": 323170, "author": "Lawrence Dol", "author_id": 8946, "author_profile": "https://Stackoverflow.com/users/8946", "pm_score": 0, "selected": false, "text": "System.exec(\"cmd.exe start file:///C:/foo/bar.html#anchor\")\n" }, { "answer_id": 9199838, "author": "Adam Rofer", "author_id": 1084078, "author_profile": "https://Stackoverflow.com/users/1084078", "pm_score": 0, "selected": false, "text": "cmd start file:///c:/temp/test.html#anchor Runtime.getRuntime().exec(\"cmd.exe start iexplore \" + myURL)" }, { "answer_id": 13277401, "author": "memnoch_proxy", "author_id": 198652, "author_profile": "https://Stackoverflow.com/users/198652", "pm_score": 2, "selected": false, "text": "File tmpfile = File.createTempFile(\"apphelp\", \".html\") <html><head>\n<meta http-equiv=\"refresh\" content=\"0;url=help.html#set_filter\" />\n</head></html>\n Runtime.getRuntime().exec(\n \"rundll32 url.dll,FileProtocolHandler \\\"\" \n +tmpfile.toURI().toString()+ \"\\\"\");\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15988/" ]
300,519
<p>Is there really that much of a difference between the performance of <code>Vector</code> and <code>ArrayList</code>? Is it good practice to use ArrayLists at all times when thread safety isn't an issue?</p>
[ { "answer_id": 300539, "author": "Aaron", "author_id": 19130, "author_profile": "https://Stackoverflow.com/users/19130", "pm_score": 4, "selected": false, "text": "ArrayList List if (!myList.isEmpty()) { \n myList.get(0);\n}\n synchronized (myList) {\n if (!myList.isEmpty()) { \n myList.get(0);\n }\n}\n" }, { "answer_id": 300541, "author": "Christian P.", "author_id": 9479, "author_profile": "https://Stackoverflow.com/users/9479", "pm_score": 6, "selected": true, "text": "Collections.synchronizedList(new ArrayList<type>);" }, { "answer_id": 300555, "author": "bruno conde", "author_id": 31136, "author_profile": "https://Stackoverflow.com/users/31136", "pm_score": 3, "selected": false, "text": "ArrayList ArrayList Vector" }, { "answer_id": 303799, "author": "James Schek", "author_id": 17871, "author_profile": "https://Stackoverflow.com/users/17871", "pm_score": 3, "selected": false, "text": "Vector ArrayList Vector ArrayList ArrayList ArrayList std::vector" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1459442/" ]
300,521
<p>I am looking for a LaTeX package that does syntax highlighting on code. For example, right now I use the verbatim block to write code:</p> <pre><code>\begin{verbatim} &lt;html&gt; &lt;head&gt; &lt;title&gt;Hello&lt;/title&gt; &lt;/head&gt; &lt;body&gt;Hello&lt;/body&gt; &lt;/html&gt; \end{verbatim} </code></pre> <p>And this works fine to display the code on my document. But, suppose I wanted to highlight the HTML markup the way an IDE would in the output document? <strong>Is there a package that could help?</strong></p> <p>I would like to do the same for various languages such as Java, C#, HTML, CSS and so on.</p>
[ { "answer_id": 300573, "author": "ChrisN", "author_id": 3853, "author_profile": "https://Stackoverflow.com/users/3853", "pm_score": 8, "selected": true, "text": "\\documentclass{article}\n\\usepackage{listings}\n\n\\begin{document}\n\\begin{lstlisting}[language=html]\n<html>\n <head>\n <title>Hello</title>\n </head>\n <body>Hello</body>\n</html>\n\\end{lstlisting}\n\\end{document}\n" }, { "answer_id": 2126808, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 7, "selected": false, "text": "texments minted" }, { "answer_id": 33565482, "author": "Adam", "author_id": 2311074, "author_profile": "https://Stackoverflow.com/users/2311074", "pm_score": 4, "selected": false, "text": "\\documentclass{article}\n\\usepackage{listings}\n\n\\begin{document}\n\\begin{lstlisting}[language=html]\n<html>\n <head>\n <title>Hello</title>\n </head>\n <body>Hello</body>\n</html>\n\\end{lstlisting}\n\\end{document}\n python --version\n sudo apt-get install python-pygments\n pdflatex -shell-escape yourfile.tex\n \\documentclass{article}\n\\usepackage{minted}\n\\begin{document}\n\n\\begin{minted}{html}\n <!DOCTYPE html>\n <html>\n <head>\n <title>Hello</title>\n </head>\n\n <body>Hello</body>\n </html>\n\\end{minted}\n\\end{document}\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300521", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27439/" ]
300,522
<p>From using a number of programming languages and libraries I have noticed various terms used for the total number of elements in a collection.</p> <p>The most common seem to be <code>length</code>, <code>count</code>, and <code>size</code>.</p> <p>eg.</p> <pre><code>array.length vector.size() collection.count </code></pre> <p>Is there any preferred term to be used? Does it depend on what type of collection it is? ie. mutable/immutable</p> <p>Is there a preference for it being a property instead of a method?</p>
[ { "answer_id": 300540, "author": "gbjbaanb", "author_id": 13744, "author_profile": "https://Stackoverflow.com/users/13744", "pm_score": 9, "selected": true, "text": "Length() Count() Size() Capacity()" }, { "answer_id": 300550, "author": "Ken Gentle", "author_id": 8709, "author_profile": "https://Stackoverflow.com/users/8709", "pm_score": 2, "selected": false, "text": "count count" }, { "answer_id": 300641, "author": "Mecki", "author_id": 15809, "author_profile": "https://Stackoverflow.com/users/15809", "pm_score": 4, "selected": false, "text": "length() size() count() elementCount() length() size()" }, { "answer_id": 1507072, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 5, "selected": false, "text": "size() Array.Length" }, { "answer_id": 37813801, "author": "brightball", "author_id": 1741899, "author_profile": "https://Stackoverflow.com/users/1741899", "pm_score": 1, "selected": false, "text": "size length" }, { "answer_id": 67109461, "author": "Kochchy", "author_id": 2291718, "author_profile": "https://Stackoverflow.com/users/2291718", "pm_score": 2, "selected": false, "text": "/**\n * Returns the number of elements in this collection.\n */\n@kotlin.internal.InlineOnly\npublic inline fun <T> Collection<T>.count(): Int {\n return size\n}\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11293/" ]
300,551
<pre><code> (define a 42) (set! 'a 10) (define a 42) (define (symbol) 'a) (set! (symbol) 10) (define a (cons 1 2)) (set! (car a) 10) </code></pre> <p>I tried running them in DrScheme and they don't work. Why?</p>
[ { "answer_id": 300597, "author": "mweiss", "author_id": 33254, "author_profile": "https://Stackoverflow.com/users/33254", "pm_score": 3, "selected": true, "text": ">(define pair (cons 1 2))\n>pair\n(1 . 2)\n>(set-car! pair 3)\n(3 . 2)\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300551", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
300,559
<p>Is there a standard Java library that handles common file operations such as moving/copying files/folders?</p>
[ { "answer_id": 909376, "author": "Rigo Vides", "author_id": 100408, "author_profile": "https://Stackoverflow.com/users/100408", "pm_score": 7, "selected": true, "text": "java.nio public static void copyFile(File sourceFile, File destFile) throws IOException {\n if(!destFile.exists()) {\n destFile.createNewFile();\n }\n\n FileChannel source = null;\n FileChannel destination = null;\n try {\n source = new FileInputStream(sourceFile).getChannel();\n destination = new FileOutputStream(destFile).getChannel();\n\n // previous code: destination.transferFrom(source, 0, source.size());\n // to avoid infinite loops, should be:\n long count = 0;\n long size = source.size(); \n while((count += destination.transferFrom(source, count, size-count))<size);\n }\n finally {\n if(source != null) {\n source.close();\n }\n if(destination != null) {\n destination.close();\n }\n }\n}\n" }, { "answer_id": 10914753, "author": "ntg", "author_id": 508907, "author_profile": "https://Stackoverflow.com/users/508907", "pm_score": 3, "selected": false, "text": "File f1= new File(\"C:\\\\Users\\\\.....\\\\foo\");\nFile f2= new File(\"C:\\\\Users\\\\......\\\\foo.old\");\nSystem.err.println(\"Result of move:\"+f1.renameTo(f2));\n System.err.println(\"Move:\" +f1.toURI() +\"--->>>>\"+f2.toURI());\nPath b1=Files.move(f1.toPath(), f2.toPath(), StandardCopyOption.ATOMIC_MOVE ,StandardCopyOption.REPLACE_EXISTING ););\nSystem.err.println(\"Move: RETURNS:\"+b1);\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19026/" ]
300,578
<p>How do get the startup path ( system.windows.forms.application.StartupPath ) of my exe without adding a reference to system.windows.forms?</p>
[ { "answer_id": 300591, "author": "Mitch Wheat", "author_id": 16076, "author_profile": "https://Stackoverflow.com/users/16076", "pm_score": 2, "selected": false, "text": "System.AppDomain.CurrentDomain.BaseDirectory\n System.Reflection Assembly.GetExecutingAssembly().Location\n Assembly.GetEntryAssembly().Location\n" }, { "answer_id": 300626, "author": "Andrew Moore", "author_id": 26210, "author_profile": "https://Stackoverflow.com/users/26210", "pm_score": 2, "selected": false, "text": "IO.Path.GetDirectoryName(Diagnostics.Process.GetCurrentProcess().MainModule.FileName)\n" }, { "answer_id": 300632, "author": "JamesSugrue", "author_id": 1075, "author_profile": "https://Stackoverflow.com/users/1075", "pm_score": 5, "selected": true, "text": "System.AppDomain.CurrentDomain.BaseDirectory\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1632/" ]
300,581
<p>I have an application with my object types that inherit from a base class that contains the majority of properties for the application objects. All the object types are stored in one table in the database. The "ClassType" column determines what object type I cast the SqlDataReader row to. </p> <p>Here is my current implementation:</p> <pre><code>SqlDataReader dr = SqlServerHelper.ExecuteReader("MyStoreProc", MySqlParmas); if(dr.HasRows) { while(dr.Read()) { switch(dr["ClassType"].ToString()) { case "ClassA": //cast sqldatareader a ClassA object ClassA a = new ClassFactory.CreateClassA(object p1, object p2); case "ClassB": //cast sqldatareader a ClassB object ClassB b = new ClassFactory.CreateClassB(object p1, object p2); //it continues for all objects with app.... } } } dr.Close() </code></pre> <p>My question is is their a better implementation for this type of processing?</p>
[ { "answer_id": 300604, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 3, "selected": false, "text": " private Dictionary<String, Type> _objectTypes = new Dictionary<String, Type>();\n\n public ObjectFactory()\n {\n // Preload the Object Types into a dictionary so we can look them up later\n foreach (Type type in typeof(ObjectFactory).Assembly.GetTypes())\n {\n if (type.IsSubclassOf(typeof(BaseEntity)))\n {\n _objectTypes[type.Name.ToLower()] = type;\n }\n }\n }\n string objectName = dr[\"ClassType\"].ToString().ToLower();\n Type objectType;\n\n if (_objectTypes.TryGetValue(objectName, out objectType))\n {\n return (BaseEntity)Activator.CreateInstance(objectType,reader);\n } \n" }, { "answer_id": 300640, "author": "Michael Kniskern", "author_id": 26327, "author_profile": "https://Stackoverflow.com/users/26327", "pm_score": 0, "selected": false, "text": "public class BaseClass\n{\n public BaseClass() { }\n\n public object p1 { get; set;}\n\n public object p2 { get; set; }\n\n public virtual void ImplementLogic() \n {\n //do some fun stuff....\n }\n}\n\npublic class ClassA : BaseClass\n{\n public ClassA { }\n\n public override void ImplementLogic()\n {\n //make it rain.....\n }\n} \n\npublic class ClassB : BaseClass\n{\n public ClassB { } \n\n public override void ImplementLogic()\n {\n //do some more fun stuff\n }\n}\n" }, { "answer_id": 300688, "author": "Gabe Moothart", "author_id": 13356, "author_profile": "https://Stackoverflow.com/users/13356", "pm_score": 0, "selected": false, "text": "Activator.GetInstance" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26327/" ]
300,582
<p>Has anyone been able to use the SSCrypto Framework for Cocoa to encrypt text and then decrypt it in C#/.NET ? Or can someone offer some guidance?</p> <p>I'm pretty sure my issue has to do with getting the crypto settings correct but I am far from fluent in Cocoa so I can't really tell what settings are being used in the library. However my attempt at deciphering it seems like md5 hashing, CBC mode, padding with zeros and I have no idea if the IV is set or not...</p> <p>My C# code looks like this:</p> <pre><code> public static string Decrypt( string toDecrypt, string key, bool useHashing ) { byte[] keyArray; byte[] toEncryptArray = Convert.FromBase64String( toDecrypt ); if( useHashing ) { MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider(); keyArray = hashmd5.ComputeHash( UTF8Encoding.UTF8.GetBytes( key ) ); hashmd5.Clear(); } else keyArray = UTF8Encoding.UTF8.GetBytes( key ); TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider(); tdes.Key = keyArray; tdes.Mode = CipherMode.CBC; tdes.Padding = PaddingMode.Zeros; ICryptoTransform cTransform = tdes.CreateDecryptor(); byte[] resultArray = cTransform.TransformFinalBlock( toEncryptArray, 0, toEncryptArray.Length ); tdes.Clear(); return UTF8Encoding.UTF8.GetString( resultArray ); } </code></pre> <p>When I run encryption on the Cocoa side I get the encrypted text:</p> <p>UMldOZh8sBnHAbfN6E/9KfS1VyWAa7RN</p> <p>but that won't decrypt on the C# side with the same key.</p> <p>Any help is appreciated, thanks.</p>
[ { "answer_id": 475322, "author": "Codingday", "author_id": 38242, "author_profile": "https://Stackoverflow.com/users/38242", "pm_score": 0, "selected": false, "text": "var reversedArr = Array.Reverse(toEncrytArray)\nbyte[] resultArray = cTransform.TransformFinalBlock( reversedArr, 0, reversedArr.Length );\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
300,592
<p>At one point I had looked at implementing a class/template in C++ that would support an Enum that would behave like it does in Ada. It has been some time since I thought about this problem and I was wondering if anyone has ever solved this problem?</p> <p>EDIT:</p> <p>My apologies, I should clarify what functionality I thought were useful in the Ada implementation of the Enum. Given the enumeration</p> <pre><code>type fruit is (apple, banana, cherry, peach, grape); </code></pre> <p>We know that fruit is one of the listed fruits: apple, banana, cherry, peach, grape. Nothing really different there from C++.</p> <p>What is very useful are the following pieces of functionality that you get with every enum in Ada without any additional work:</p> <ul> <li>printing out an enumerated value generates the string version </li> <li>you can increment the enumerated variable</li> <li>you can decrement the enumerated variable</li> </ul> <p>I hope this defines the problem a bit more.</p> <hr> <p><em>Notes added from comments</em>:</p> <ul> <li>See: <a href="http://en.wikipedia.org/wiki/Enumerated_type#Ada" rel="nofollow noreferrer">Wikipedia</a> (Judah Himango, 2008-11-19 at 0:09) </li> <li>See: <a href="http://en.wikibooks.org/wiki/Ada_Programming/Types/Enumeration" rel="nofollow noreferrer">Wikibooks</a></li> </ul> <h2>Useful features of Ada enumerations</h2> <ul> <li>The first value in the enumeration is <code>fruit'first</code> which gives <code>apple</code>.</li> <li>The last value in the enumeration is <code>fruit'last</code> which gives <code>grape</code>.</li> <li>The increment operation is <code>fruit'succ(apple)</code> which gives <code>banana</code>.</li> <li>The decrement operation is <code>fruit'pred(cherry)</code> which also gives <code>banana</code>.</li> <li>The conversion from enumeration to integer is <code>fruit'pos(cherry)</code> which returns <code>2</code> because Ada uses 0-based enumerations.</li> <li>The conversion from integer to enumeration is <code>fruit'val(2)</code> which returns <code>cherry</code>.</li> <li>The conversion from enumeration to string is <code>fruit'Image(apple)</code> which returns the (upper-case) string <code>"APPLE"</code>.</li> <li>The conversion from string to enumeration is <code>fruit'Value("apple")</code> which returns the value <code>apple</code>.</li> </ul> <hr> <p>See also related SO questions:</p> <ul> <li><a href="https://stackoverflow.com/questions/217549/which-typesafe-enum-in-c-are-you-using">Which Typesafe Enum in C++ Are You Using?</a></li> <li><a href="https://stackoverflow.com/questions/430264/next-or-previous-enum">Next or previous enum</a></li> </ul>
[ { "answer_id": 303811, "author": "Mecki", "author_id": 15809, "author_profile": "https://Stackoverflow.com/users/15809", "pm_score": 2, "selected": false, "text": "enum fruit { apple, banana, cherry, peach, grape };\n enum fruit { apple = 0, banana, cherry = 20, peach, grape };\n enum fruit { apple = 0, banana, cherry, peach, grape };\nenum fruit myFruit = banana;\nmyFruit++;\n// myFruit is now cherry\nprintf(\"My fruit is cherry? %s\\n\", myFruit == cherry ? \"YES\" : \"NO\");\n enum fruit { apple = 0, banana, cherry = 20, peach, grape };\nenum fruit myFruit = banana;\nmyFruit++;\n// myFruit is now cherry\nprintf(\"My fruit is cherry? %s\\n\", myFruit == cherry ? \"YES\" : \"NO\");\n typedef enum fruit { apple = 0, banana, cherry, peach, grape } fruit;\n\nfruit myFruit;\n typedef enum fruit {\n apple = 0,\n banana,\n cherry,\n peach,\n grape\n} fruit;\n\n#define STR_CASE(x) case x: return #x\nconst char * enum_fruit_to_string(fruit f) {\n switch (f) {\n STR_CASE(apple); STR_CASE(banana); STR_CASE(cherry);\n STR_CASE(peach); STR_CASE(grape);\n }\n return NULL;\n}\n#undef STR_CASE\n\nstatic void testCall(fruit f) {\n // I have no idea what fruit will be passed to me, but I know it is\n // a fruit and I want to print the name at runtime\n printf(\"I got called with fruit %s\\n\", enum_fruit_to_string(f));\n}\n\nint main(int argc, char ** argv) {\n printf(\"%s\\n\", enum_fruit_to_string(banana));\n fruit myFruit = cherry;\n myFruit++; // myFruit is now peach\n printf(\"%s\\n\", enum_fruit_to_string(myFruit));\n // I can also pass an enumeration to a function\n testCall(grape);\n return 0;\n}\n banana\npeach\nI got called with fruit grape\n" }, { "answer_id": 303828, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "$ cat Fruit.enum\n(def-enum \"Fruit\" ((\"apple\")\n (\"banana\")\n (\"cherry\")\n (\"peach\")\n (\"grape\")\n (\"INVALID_\")))\n\n$ enumgen Fruit.enum\nUsing clisp\n;; Loading file /tmp/enumgen/enumgen.lisp ...\n;; Loaded file /tmp/enumgen/enumgen.lisp\nloading def file:\n;; Loading file /tmp/enumgen/enumgen.def ...\n;; Loaded file /tmp/enumgen/enumgen.def\ngenerating output:\n Fruit.cpp\n Fruit.ipp\n Fruit.hpp\nDONE\n" }, { "answer_id": 1436615, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 2, "selected": false, "text": "enum_iterator ENUM #include <iostream>\n#include \"enum.hpp\"\n\nENUM(FooEnum, \n (N)\n (A = 1)\n (B = 2)\n (C = 4)\n (D = 8));\n\nint main() {\n litb::enum_iterator< FooEnum, litb::SparseRange<FooEnum> > i = N, end;\n while(i != end) {\n std::cout << i.to_string() << \": \" << *i << std::endl;\n ++i;\n }\n}\n litb::ConsequtiveRange<>" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1265473/" ]
300,595
<p>What would be a clever way to make a 'please wait' control for a Flex application for long running operations like calling a webservice.</p> <p>I am not asking about the graphical portion of it - just the 'controller' part. How should I trigger it and hide it. I am planning to make just a simple canvas with text in.</p> <p>For instance :</p> <ul> <li>can I somehow intercept all web service calls - and not have to activate it for every web service</li> <li>how should i add it to my canvas. should it be added to 'stage' as a top level component? </li> <li>should it have a 'cancel' button to cancel the web service request if it takes too long. that sounds kind of complicated because I'm not even sure if I can terminate a running async web request?</li> </ul> <p>FYI: This is for a reporting application so long running queries are to be expected</p>
[ { "answer_id": 302118, "author": "mmattax", "author_id": 1638, "author_profile": "https://Stackoverflow.com/users/1638", "pm_score": 2, "selected": true, "text": "\n<mx:Application>\n <mx:Script>\n [Bindable]public var ws_count:int = 0;\n </mx:Script>\n <mx:Label text = \"loading...\" visible=\"{ws_count > 0}\" />\n</mx:Application>\n\n \npackage ws {\n import mx.core.Application;\n public class WSCounter {\n public static function sent():void {\n Application.application.ws_count += 1;\n }\n public static function receive():void {\n Application.application.ws_count -= 1;\n }\n }\n}\n \nimport ws.WSCounter;\nimport mx.rpc.http.HTTPService;\n\nvar srv:HTTPService = new HTTPService();\nsrv.url = \"http://localhost/service.py\";\nsrv.addEventListener(ResultEvent.RESULT,function(event:ResultEvent):void {\n WSCounter.receive();\n});\nsrv.send();\nWSCounter.sent();\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940/" ]
300,606
<p>I need to convert strings with optional trailing signs into actual numbers using Powershell.</p> <p>Possible strings are:</p> <ul> <li>1000-</li> <li>323+</li> <li>456</li> </ul> <p>I'm trying to use System.Int.TryParse with a NumberStyles of AllowTrailingSign, but I can't work out how to make System.Globalization.NumberStyles available to Powershell.</p>
[ { "answer_id": 300649, "author": "Peter Seale", "author_id": 25911, "author_profile": "https://Stackoverflow.com/users/25911", "pm_score": 2, "selected": false, "text": "[System.Globalization.NumberStyles]::AllowTrailingSign\n \"AllowTrailingSign\"\n [System.Globalization.NumberStyles] | gm -static\n" }, { "answer_id": 300659, "author": "Jim Burger", "author_id": 20164, "author_profile": "https://Stackoverflow.com/users/20164", "pm_score": 4, "selected": true, "text": "$foo = \"300-\";\n$bar = 0;\n$numberStyles = [System.Globalization.NumberStyles];\n$cultureInfo = [System.Globalization.CultureInfo];\n\n[int]::TryParse($foo, $numberStyles::AllowTrailingSign, $cultureInfo::CurrentCulture, [ref]$bar);\n" }, { "answer_id": 300913, "author": "halr9000", "author_id": 6637, "author_profile": "https://Stackoverflow.com/users/6637", "pm_score": 1, "selected": false, "text": "$type = [System.Globalization.NumberStyles]\n[enum]::GetValues($type)\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11571/" ]
300,607
<p>In Windows Mobile, when you open Internet Explorer and type in a URL that your device can't connect to, you are notified of this and prompted to (manually) navigate to the screen where you can actually do something about this as a user (Network Management), like so:</p> <p><a href="http://www.freeimagehosting.net/uploads/d3d95e00d2.gif" rel="nofollow noreferrer">alt text http://www.freeimagehosting.net/uploads/d3d95e00d2.gif</a></p> <p>However, if a .NET Compact Framework application tries to connect to a webservice and the webservice URL is not reachable, the "Cannot Connect" bubble does not appear, and instead the call to the webservice just fails. Sometimes we end up talking customers through <em>this</em> process on the phone:</p> <p><a href="http://www.freeimagehosting.net/uploads/e74a0d4230.gif" rel="nofollow noreferrer">alt text http://www.freeimagehosting.net/uploads/e74a0d4230.gif</a></p> <p>and then they still have another 2 steps to go.</p> <p><strong>Question 1: Is it possible to programmatically control (in C#) what the two ComboBoxes on the Network Management screen are set to?</strong></p> <p>Usually fixing a customer's connectivity problems involves fiddling with these two boxes until they can connect. The problem is that because customers can freely alter their network stuff here themselves, I often don't know what to tell them to set it to ("it says what?" is something I say a lot). From my searches so far, it looks like <strong>DMProcessConfigXML</strong> is the way this would be done, but all I know so far is that you call this method and pass it some XML.</p> <p><strong>Question 2: Is it possible to programmatically (C#) trigger the "Cannot Connect" bubble, or better yet is it possible to programmatically make the Network Management screen appear immediately?</strong> </p> <p>Presumably, if my code can't see the webservice URL it could trigger the bubble or go directly to the screen.</p>
[ { "answer_id": 2421523, "author": "Matt", "author_id": 124006, "author_profile": "https://Stackoverflow.com/users/124006", "pm_score": 3, "selected": true, "text": "Process.Start(@\"\\windows\\ctlpnl.exe\", \"cplmain.cpl,19\");\n <wap-provisioningdoc>\n <characteristic type=\"CM_ProxyEntries\">\n <characteristic type=\"HTTP-{ADB0B001-10B5-3F39-27C6-9742E785FCD4}\">\n <parm name=\"SrcId\" value=\"{ADB0B001-10B5-3F39-27C6-9742E785FCD4}\" options=\"My Work Network{18AD9FBD-F716-ACB6-FD8A-1965DB95B814}My ISP{ADB0B001-10B5-3F39-27C6-9742E785FCD4}Work{A1182988-0D73-439E-87AD-2A5B369F808B}Secure WAP Network{F28D1F74-72BE-4394-A4A7-4E296219390C}The WAP Network{7022E968-5A97-4051-BC1C-C578E2FBA5D9}The Internet{436EF144-B4FB-4863-A041-8F905A62C572}\" />\n <parm name=\"DestId\" value=\"{436EF144-B4FB-4863-A041-8F905A62C572}\" options=\"My Work Network{18AD9FBD-F716-ACB6-FD8A-1965DB95B814}My ISP{ADB0B001-10B5-3F39-27C6-9742E785FCD4}Work{A1182988-0D73-439E-87AD-2A5B369F808B}Secure WAP Network{F28D1F74-72BE-4394-A4A7-4E296219390C}The WAP Network{7022E968-5A97-4051-BC1C-C578E2FBA5D9}The Internet{436EF144-B4FB-4863-A041-8F905A62C572}\" />\n <parm name=\"Proxy\" value=\"new-inet:1159\" />\n <parm name=\"Override\" value=\"\" />\n <parm name=\"Enable\" value=\"1\" />\n <parm name=\"Type\" value=\"0\" />\n <parm name=\"Username\" value=\"\" />\n <parm name=\"Password\" value=\"\" />\n <parm name=\"ExtraInfo\" value=\"\" />\n </characteristic>\n <characteristic type=\"null-corp-{ADB0B001-10B5-3F39-27C6-9742E785FCD4}\">\n <parm name=\"SrcId\" value=\"{ADB0B001-10B5-3F39-27C6-9742E785FCD4}\" options=\"My Work Network{18AD9FBD-F716-ACB6-FD8A-1965DB95B814}My ISP{ADB0B001-10B5-3F39-27C6-9742E785FCD4}Work{A1182988-0D73-439E-87AD-2A5B369F808B}Secure WAP Network{F28D1F74-72BE-4394-A4A7-4E296219390C}The WAP Network{7022E968-5A97-4051-BC1C-C578E2FBA5D9}The Internet{436EF144-B4FB-4863-A041-8F905A62C572}\" />\n <parm name=\"DestId\" value=\"{A1182988-0D73-439E-87AD-2A5B369F808B}\" options=\"My Work Network{18AD9FBD-F716-ACB6-FD8A-1965DB95B814}My ISP{ADB0B001-10B5-3F39-27C6-9742E785FCD4}Work{A1182988-0D73-439E-87AD-2A5B369F808B}Secure WAP Network{F28D1F74-72BE-4394-A4A7-4E296219390C}The WAP Network{7022E968-5A97-4051-BC1C-C578E2FBA5D9}The Internet{436EF144-B4FB-4863-A041-8F905A62C572}\" />\n <parm name=\"Proxy\" value=\"\" />\n <parm name=\"Override\" value=\"\" />\n <parm name=\"Enable\" value=\"1\" />\n <parm name=\"Type\" value=\"0\" />\n <parm name=\"Username\" value=\"\" />\n <parm name=\"Password\" value=\"\" />\n <parm name=\"ExtraInfo\" value=\"\" />\n </characteristic>\n </characteristic>\n </wap-provisioningdoc>\n <wap-provisioningdoc>\n <characteristic-query type=\"CM_Mappings\" recursive=\"true\"/>\n <characteristic-query type=\"CM_Planner\" recursive=\"true\"/>\n <characteristic-query type=\"CM_Networks\" recursive=\"true\"/>\n <characteristic-query type=\"CM_ProxyEntries\" recursive=\"true\"/>\n <characteristic-query type=\"Wi-Fi\" recursive=\"true\"/>\n <characteristic-query type=\"CM_PPPEntries\" recursive=\"true\"/>\n <characteristic-query type=\"CM_VPNEntries\" recursive=\"true\"/>\n <characteristic-query type=\"CM_NetEntries\" recursive=\"true\"/>\n <characteristic-query type=\"CM_GPRSEntries\" recursive=\"true\"/>\n</wap-provisioningdoc>\n" } ]
2008/11/18
[ "https://Stackoverflow.com/questions/300607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14606/" ]
300,618
<p>My application is a viewer for a custom format, a zip file with a well defined XML manifest and resources, such as images and movies. I use zlib to open up the zip file in memory and then proceed to display said resources. </p> <p>One problem I've ran into is that I'm unable to properly display videos, apparently because QTMovie cannot determine the mime-type. Movie loaded from file ([QTMovie movieWithFile]) works perfectly. Loaded from memory ([QTMovie movieWithData]) refuses to work. </p> <p>This makes sense, because lacking the file extension, QTMovie cannot determine the mime-type information. After a bit of a search, I've resorted to using QTDataReference in the following mannner:</p> <pre><code>NSData *movieData = ...read from memory...; QTDataReference *movieDataReference = [[QTDataReference alloc] initWithReferenceToData:movieData name:fileName MIMEType:@"video/x-m4v"]; QTMovie *mov = [QTMovie movieWithDataReference:movieDataReference error:&amp;err]; </code></pre> <p>This works nicely, however hardcoding MIMEType is far from ideal. I have access to the filename and the extension, so I've attempted to find the mime-type using UTI (thanks to the nice folks on #macdev):</p> <pre><code>- (NSString*)mimeTypeForExtension:(NSString*)ext { CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension,(CFStringRef)ext,NULL); return NSMakeCollectable(UTTypeCopyPreferredTagWithClass((CFStringRef)UTI,kUTTagClassMIMEType)); } </code></pre> <p>This however doesn't work. Clearly, there's an internal OS X database of extensions and corresponding mime-types, somewhere. Otherwise from-disk movies wouldn't work. How do I get access to it?</p> <p>Thanks!</p>
[ { "answer_id": 303709, "author": "Jason Coco", "author_id": 34218, "author_profile": "https://Stackoverflow.com/users/34218", "pm_score": 4, "selected": true, "text": "-(NSString*)mimeTypeForExtension:(NSString*)ext\n{\n NSAssert( ext, @\"Extension cannot be nil\" );\n NSString* mimeType = nil;\n\n CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension,\n (CFStringRef)ext, NULL);\n if( !UTI ) return nil;\n\n CFStringRef registeredType = UTTypeCopyPreferredTagWithClass(UTI, kUTTagClassMIMEType);\n if( !registeredType ) // check for edge case\n {\n if( [ext isEqualToString:@\"m4v\"] )\n mimeType = @\"video/x-m4v\";\n else if( [ext isEqualToString:@\"m4p\"] )\n mimeType = @\"audio/x-m4p\";\n // handle anything else here that you know is not registered\n } else {\n mimeType = NSMakeCollectable(registeredType);\n }\n\n CFRelease(UTI);\n return mimeType;\n}\n" }, { "answer_id": 1763923, "author": "rsms", "author_id": 184070, "author_profile": "https://Stackoverflow.com/users/184070", "pm_score": 3, "selected": false, "text": "-(NSString *)mimeTypeForFileAtPath:(NSString *)path error:(NSError **)err {\n NSString *uti, *mimeType = nil;\n\n if (!(uti = [[NSWorkspace sharedWorkspace] typeOfFile:path error:err]))\n return nil;\n if (err)\n *err = nil;\n\n if ((mimeType = (NSString *)UTTypeCopyPreferredTagWithClass((CFStringRef)uti, kUTTagClassMIMEType)))\n mimeType = NSMakeCollectable(mimeType);\n\n return mimeType;\n}\n" } ]
2008/11/19
[ "https://Stackoverflow.com/questions/300618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38753/" ]
300,629
<p>I'm writing a direct3d application and after noticing strange bugs such as anti-aliasing occurring even when it was turned off and the mouse pointer not lining up to things with the same coordinates as itself I discovered that when creating a window the width and height parameters include the border. The program was rendering a 800x600 graphics output to a window of the same size, but because of the borders it was squished into 792x566 rectangle. I've increased the size of the window to compensate, but this does not work if the system uses a border style other the standard XP style. (Classic style, for example)</p> <p>Is there a way to tell what the border width and heights will be before I create the window?</p>
[ { "answer_id": 300638, "author": "DocMax", "author_id": 6234, "author_profile": "https://Stackoverflow.com/users/6234", "pm_score": 3, "selected": true, "text": "GetSystemMetrics(SM_CXBORDER)\n" } ]
2008/11/19
[ "https://Stackoverflow.com/questions/300629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2222/" ]
300,639
<p>I have seen many apps that take instrument classes and take <code>-javaagent</code> as a param when loading also put a <code>-noverify</code> to the command line.</p> <p>The Java doc says that <code>-noverify</code> turns off class verification.</p> <p>However why would anyone want to turn off verification even if they are instrumenting classes?</p>
[ { "answer_id": 6872885, "author": "Esko Luontola", "author_id": 62130, "author_profile": "https://Stackoverflow.com/users/62130", "pm_score": 3, "selected": false, "text": "-noverify -noverify" }, { "answer_id": 13710970, "author": "Cephalopod", "author_id": 340556, "author_profile": "https://Stackoverflow.com/users/340556", "pm_score": 6, "selected": false, "text": "-javaagent this -noverify" } ]
2008/11/19
[ "https://Stackoverflow.com/questions/300639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14316/" ]
300,656
<p>I'm using a WPF RichTextBox control to input some text with user formatting capability, including font size adjustment. The built-in commands for IncreaseFontSize and DecreaseFontSize will adjust the font size by 0.75pt each time the command is executed. I would like to increase the granularity to 2pt.</p> <p>Can this be done without implementing my own custom commands?</p>
[ { "answer_id": 321798, "author": "ligaz", "author_id": 6409, "author_profile": "https://Stackoverflow.com/users/6409", "pm_score": 1, "selected": false, "text": "var range = new TextRange( rtb.Document.ContentStart, rtb.Document.ContentEnd );\nrange.ApplyPropertyValue( TextElement.FontSizeProperty, 30.0 );\n" } ]
2008/11/19
[ "https://Stackoverflow.com/questions/300656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25879/" ]
300,658
<p>How would you use set! in a simple procedure f such that evaluating (+ (f 0) (f 1)) will return 0 if the arguments to + are evaluated from left to right but will return 1 if the arguments are evaluated from right to left?</p>
[ { "answer_id": 300678, "author": "Andrew Beyer", "author_id": 38691, "author_profile": "https://Stackoverflow.com/users/38691", "pm_score": 3, "selected": false, "text": "(define x 0)\n(define (f n) (let ((tmp x)) (set! x n) tmp))\n" }, { "answer_id": 776156, "author": "finnw", "author_id": 12048, "author_profile": "https://Stackoverflow.com/users/12048", "pm_score": -1, "selected": false, "text": "(define (f)\n (call/cc\n (lambda (c) (+ (c 0) (c 1)))))\n\n(write (f))\n + f" } ]
2008/11/19
[ "https://Stackoverflow.com/questions/300658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
300,660
<p>I know I can loop over the string or build a regex or invert the set (ASCII isn't that big after all) and search for the first instance of that, but Yuck.</p> <p>What I'm looking for is a nice one liner.</p> <p>fewer features is better, LINQ is out (for me, don't ask, it's a <em>long</em> story)</p> <hr> <p>The solution I'm going with (unless I see something better)</p> <pre><code>static int FirstNotMeta(int i, string str) { for(; i &lt; str.Length; i++) switch(str[i]) { case '\\': case '/': case '.': continue; default: return i; } return -1; } </code></pre> <p>OK, I cheated, I know in advance what char's I care about.</p>
[ { "answer_id": 300666, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "char f(string str, IEnumerable<char> list)\n{\n return str.ToCharArray().First(c => !list.Contains(c))\n}\n" }, { "answer_id": 300668, "author": "Robert Wagner", "author_id": 10784, "author_profile": "https://Stackoverflow.com/users/10784", "pm_score": 2, "selected": false, "text": "public static char? GetFirstChar(string str, char[] list)\n{\n foreach (char c in str) if (!list.Contains(c)) return c;\n return null;\n}\n char[] list = { 'A', 'B' };\nstring str = \"AABAGAF\";\n\nchar first = str.ToArray().Where(c => !list.Contains(c)).FirstOrDefault();\n char? first = str.ToArray().Cast<char?>().Where(\n c => !list.Contains(c.Value)).FirstOrDefault();\n var query = from char c in str\n where !list.Contains(c)\n select (char?)c;\nchar? first = query.FirstOrDefault();\n" }, { "answer_id": 300689, "author": "Jeff B", "author_id": 25879, "author_profile": "https://Stackoverflow.com/users/25879", "pm_score": 4, "selected": true, "text": "public static char FindFirstNotAny(this string value, params char[] charset)\n{\n return value.TrimStart(charset)[0];\n}\n" }, { "answer_id": 300735, "author": "Adam Liss", "author_id": 29157, "author_profile": "https://Stackoverflow.com/users/29157", "pm_score": 1, "selected": false, "text": "char *strToSearch = \"This is the one liner you want\"\nchar *skipChars = \"Tthise\";\nsize_f numToSkip = strcspn(strToSearch, skipChars);\n strcspn()" } ]
2008/11/19
[ "https://Stackoverflow.com/questions/300660", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
300,662
<p>I want to insert something into a STL list in C++, but I only have a reverse iterator. What is the usual way to accomplish this?</p> <p>This works: (of course it does)</p> <pre><code>std::list&lt;int&gt; l; std::list&lt;int&gt;::iterator forward = l.begin(); l.insert(forward, 5); </code></pre> <p>This doesn't work: (what should I do instead?)</p> <pre><code>std::list&lt;int&gt; l; std::list&lt;int&gt;::reverse_iterator reverse = l.rbegin(); l.insert(reverse, 10); </code></pre>
[ { "answer_id": 300693, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 6, "selected": true, "text": "l.insert(reverse.base(), 10); l.rbegin().base() == l.end()" }, { "answer_id": 300709, "author": "Mike Kale", "author_id": 4627, "author_profile": "https://Stackoverflow.com/users/4627", "pm_score": 4, "selected": false, "text": "reverse_iterator base() l.insert(reverse.base(), 10);\n base() reverse_iterator rbegin() rend()" }, { "answer_id": 69215896, "author": "lakeweb", "author_id": 3166476, "author_profile": "https://Stackoverflow.com/users/3166476", "pm_score": 0, "selected": false, "text": "rbegin std::stringstream sprint fmt_currency std::isalnum std::wstring fmt_long(long val) {//for now, no options? Just insert commas\n std::wstring str(std::to_wstring(val));\n std::size_t pos{ 0 };\n for (auto r = rbegin(str) + 1; r != str.rend() && std::isalnum(*r); ++r) {\n if (!(++pos % 3)) {\n r = std::make_reverse_iterator(str.insert(r.base(), L','));\n }\n }\n return str;\n}\n" } ]
2008/11/19
[ "https://Stackoverflow.com/questions/300662", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25164/" ]