qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
227,305
<p>I am building up a view with various text and image elements.</p> <p>I want to display some text in the view with a blurry copy of the text behind it, but not just a text shadow.</p> <p>How do I apply Gaussian blurred text onto a UIImage or layer?</p>
[ { "answer_id": 1256500, "author": "mahboudz", "author_id": 86020, "author_profile": "https://Stackoverflow.com/users/86020", "pm_score": 3, "selected": false, "text": "static void blur(V2fT2f *quad, float t) // t = 1\n{\n GLint tex;\n V2fT2f tmpquad[4];\n float offw = t / Input....
2008/10/22
[ "https://Stackoverflow.com/questions/227305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30342/" ]
227,312
<p>Currently we are using prototype and jQuery as our js frameworks. Right now, jQuery is set to $j() to prevent conflicts from prototype.</p> <p>In the past, we've used a lot of prototype's Element.down(), Element.next(), and Element.previous() to traverse the DOM. However, I need a simple way to retrieve the last child element. I know i can loop through an array by using Element.childElements() but I would like something inline that reads cleanly and can be pipelined.</p> <p>Just thought I would ask before I go reinventing the wheel. Here's a snippet of code that has lastChild in it that needs to be replaced:</p> <pre><code>_find : function(rows, address) { var obj = null; for (var i=0; i &lt; rows.length &amp;&amp; obj == null; i++) { if (rows[i].down().className == 'b') obj = this._find(rows[i].lastChild.down().down().childElements(), address); else if (rows[i].lastChild.getAttribute('tabAddress') == address) return rows[i].lastChild; } return obj; } </code></pre>
[ { "answer_id": 227323, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 1, "selected": false, "text": "var lastChild = $(\"#parent :last-child\");\n" }, { "answer_id": 227342, "author": "John Topley", "author_i...
2008/10/22
[ "https://Stackoverflow.com/questions/227312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5203/" ]
227,318
<p>I need to write a browser interface for an application running embedded on a single board computer (<a href="http://www.gumstix.com/store/catalog/product_info.php?products_id=178" rel="nofollow noreferrer">Gumstix Verdex</a> for anyone who's interested), so I won't be able to use any web frameworks due to space and processor constraints (and availability for the environment I'm running in). I'm limited to the core Python and cgi modules to create pages that will communicate with a C++ application.</p> <p>Can anyone recommend a good resource (web or book form, but books are preferred) for learning CGI programming in Python?</p> <p>What I need the application to do is fairly simple. I have a C++ program running on the same device and I need to create a browser based user interface so the configuration settings of that application can be changed. The UI needs to communicate with the C++ application, where the final data validation will be done. Preliminary validation can be done on the UI using Javascript, then again on the server using Python, but the final validation has to be done in the application itself, since it's getting its initial config from a file anyway. The configuration data takes all forms (booleans, ints, floats, and strings).</p>
[ { "answer_id": 227857, "author": "Florian Bösch", "author_id": 19435, "author_profile": "https://Stackoverflow.com/users/19435", "pm_score": 1, "selected": false, "text": "from wsgiref.simple_server import make_server\n\ndef application(environ, start_response):\n start_response('200 ...
2008/10/22
[ "https://Stackoverflow.com/questions/227318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1288/" ]
227,340
<p>For our software we use hardware dongles to protect the software. No protection is perfect but this commercial solution is affordable and keeps honest people honest (as mentioned in another thread). The advantage is the 128 bit key that is stored 'unreadable' on the hardware dongle. </p> <p>We want to remove this hardware dongle and start using software protection. Basically we can use a commercial product, but on the other hand that won't be unbreakable either. I don't know much about encryption and that's why I am posting this. How do I store a key on a Windows computer that will not be possible to read by using Reflector or something else? However I should be able to access the key for testing the license code.</p> <p>I would just like a simple solution that can't be hacked by simply using Reflector.</p> <p>Or am I asking a very stupid question?</p> <hr> <p>Thank you all for your very fast and useful replies. I don't want to use licensing over the internet, since the application is running not always on computers that are connected. I will then get probably more problems then solving them. We will now most probably go for a commercial solution. It seems that protection is not that trivial. </p> <p>Thanks a lot!!</p>
[ { "answer_id": 227453, "author": "Hallgrim", "author_id": 15454, "author_profile": "https://Stackoverflow.com/users/15454", "pm_score": 0, "selected": false, "text": "bool CheckKey(string keyFromUser) \n return SHA1(key) == \"ABC2983CF293892CD298392FG\";\n}\n" } ]
2008/10/22
[ "https://Stackoverflow.com/questions/227340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30507/" ]
227,351
<p>I want to expose the functionality of an SAP program (transaction) as a BAPI. I need to call a report and supply range filters such that the GUI is bypassed.</p> <p>Does anyone have a working example of the SUBMIT ... WITH ... ABAP construct, or other suggestions on how to accomplish what I need to do?</p>
[ { "answer_id": 231587, "author": "Esti", "author_id": 25687, "author_profile": "https://Stackoverflow.com/users/25687", "pm_score": 2, "selected": false, "text": "SUBMIT SAPF140 \n TO SAP-SPOOL \"optional\"\n SPOOL PARAMETERS print_parameters \"optional\"...
2008/10/22
[ "https://Stackoverflow.com/questions/227351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26652/" ]
227,357
<p>I have a master page, with a help link in the top menu. This link should contain the a dynamic bookmark from the current page, so that the user scrolls to the help for the page he is currently seeing.</p> <pre><code>&lt;a href="help.aspx#[NameOfCurentPage]"&gt;Help&lt;/a&gt; </code></pre> <p>How would you implement this?</p>
[ { "answer_id": 227387, "author": "JPrescottSanders", "author_id": 19444, "author_profile": "https://Stackoverflow.com/users/19444", "pm_score": 1, "selected": false, "text": "Path.GetFileName(Request.PhysicalPath).ToUpper()\n" }, { "answer_id": 227406, "author": "Dillie-O", ...
2008/10/22
[ "https://Stackoverflow.com/questions/227357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8547/" ]
227,376
<p>I need to round a value up to the nearest multiple of 2.5.</p> <p>For example:<br> 6 --> 7.5<br> 7.6 --> 10<br> etc. </p> <p>This seems like the best way to do this?</p> <pre><code> Function RoundToIncrement(ByVal originalNumber As Decimal, ByVal increment As Decimal) As Decimal Dim num = Math.Round(originalNumber / increment, MidpointRounding.AwayFromZero) * increment If originalNumber Mod increment &lt;&gt; 0 And num &lt; originalNumber Then num += increment End If Return num End Function </code></pre>
[ { "answer_id": 227384, "author": "harpo", "author_id": 4525, "author_profile": "https://Stackoverflow.com/users/4525", "pm_score": 6, "selected": true, "text": "Function RoundToIncrement(ByVal orignialNumber As Decimal, ByVal increment As Decimal) As Decimal\n Return Math.Ceiling( ori...
2008/10/22
[ "https://Stackoverflow.com/questions/227376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34548/" ]
227,380
<p>Consider the following code:</p> <pre><code>abstract class SomeClassX&lt;T&gt; { // blah } class SomeClassY: SomeClassX&lt;int&gt; { // blah } class SomeClassZ: SomeClassX&lt;long&gt; { // blah } </code></pre> <p>I want a collection of SomeClassX&lt;T&gt;'s, however, this isn't possible since SomeClassX&lt;int&gt; != SomeClassX&lt;long&gt; and List&lt;SomeClassX&lt;&gt;&gt; isn't allowed.</p> <p>So my solution is to have SomeClassX&lt;T&gt; implement an interface and define my collection as, where ISomeClassX is the interface:</p> <pre><code>class CollectionOfSomeClassX: List&lt;ISomeClassX&gt; { // blah } </code></pre> <p>Is this the best way to do this, or is there better way?</p>
[ { "answer_id": 227384, "author": "harpo", "author_id": 4525, "author_profile": "https://Stackoverflow.com/users/4525", "pm_score": 6, "selected": true, "text": "Function RoundToIncrement(ByVal orignialNumber As Decimal, ByVal increment As Decimal) As Decimal\n Return Math.Ceiling( ori...
2008/10/22
[ "https://Stackoverflow.com/questions/227380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30521/" ]
227,383
<p>How do I programmatically return the maximum of two integers without using any comparison operators and without using <code>if</code>, <code>else</code>, etc?</p>
[ { "answer_id": 227393, "author": "bobwienholt", "author_id": 24257, "author_profile": "https://Stackoverflow.com/users/24257", "pm_score": 2, "selected": false, "text": "int max(int a, int b)\n{\n int x = (a - b) >> 31;\n int y = ~x;\n return (y & a) | (x & b); \n}\n...
2008/10/22
[ "https://Stackoverflow.com/questions/227383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22471/" ]
227,401
<p>I would like to be able to know, in run-time in my code, how much memory a certain object is taking (a Dataset in this case, but i'm looking for a "general" solution).</p> <p>Is this possible through reflection?</p> <p>This is for .Net 2.0.</p> <p>Thanks!</p>
[ { "answer_id": 227499, "author": "justin.m.chase", "author_id": 12958, "author_profile": "https://Stackoverflow.com/users/12958", "pm_score": 0, "selected": false, "text": "int size = Marshal.SizeOf(typeof(int));\n" } ]
2008/10/22
[ "https://Stackoverflow.com/questions/227401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3314/" ]
227,417
<p>I've run across the following line in a VB6 application.</p> <pre><code>mobjParentWrkBk.ExcelWorkBook.Application.Selection.Insert Shift:=xlToRight </code></pre> <p>Unfortunately Google and other search engines have not been very useful as they seem to omit the := part. </p> <p>What would be a C# equivalent?</p>
[ { "answer_id": 227431, "author": "John Rudy", "author_id": 14048, "author_profile": "https://Stackoverflow.com/users/14048", "pm_score": 5, "selected": true, "text": "Insert" }, { "answer_id": 227448, "author": "shahkalpesh", "author_id": 23574, "author_profile": "htt...
2008/10/22
[ "https://Stackoverflow.com/questions/227417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14177/" ]
227,428
<p>I am planning a PHP application that needs to store date/times in an MSSQL database. (For the curious, it is a calendar application.) What is the preferred format to store this information?</p> <p>MSSQL has its own datetime data type, which works well in the database itself and is very readable. However, there aren't any MSSQL functions to translate datetime values to PHP's preferred format--UNIX timestamp. This makes it a bit more painful to use with PHP. UNIX timestamp is attractive because that's what PHP likes, but it's certainly not as readable and there aren't a bunch of nice built-in MSSQL functions for working with the data.</p> <p>Would you store this information as datetime data type, as UNIX timestamps (as int, bigint, or varchar datatype), as both formats side by side, or as something else entirely?</p>
[ { "answer_id": 227451, "author": "Kris", "author_id": 18565, "author_profile": "https://Stackoverflow.com/users/18565", "pm_score": 3, "selected": false, "text": "date('Y-m-d H:i:s', $myTimeStampInSeconds);" }, { "answer_id": 227508, "author": "Adam Ness", "author_id": 21...
2008/10/22
[ "https://Stackoverflow.com/questions/227428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18986/" ]
227,430
<p>Here is my function (<strong>updated</strong>):</p> <pre><code>Public Shared Function shortenUrl(ByVal URL As String) As String Return shortenUrl(URL, 32) End Function Public Shared Function shortenUrl(ByVal URL As String, ByVal maxLength As Integer) As String If URL.Length &gt; maxLength Then String.Format("{0}...{1}", URL.Substring(0, (maxLength / 2)), URL.Substring(URL.Length - ((maxLength / 2) - 3))) Else Return URL End If End Function </code></pre> <p>I fixed the problem where it didn't return <code>maxLength</code> chars because it didn't take into account the ellipses.</p> <hr> <p>It seems to me that it is too complicated; any suggestions, comments, concerns are more than welcome.</p>
[ { "answer_id": 227445, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 2, "selected": true, "text": "Public Shared Function shortenUrl(ByVal URL As String) As String\n Return shortenUrl(URL, 29)\nEnd Function\nPub...
2008/10/22
[ "https://Stackoverflow.com/questions/227430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25515/" ]
227,434
<p>I have an XML schema that includes multiple addresses:</p> <pre><code>&lt;xs:element name="personal_address" maxOccurs="1"&gt; &lt;!-- address fields go here --&gt; &lt;/xs:element&gt; &lt;xs:element name="business_address" maxOccurs="1"&gt; &lt;!-- address fields go here --&gt; &lt;/xs:element&gt; </code></pre> <p>Within each address element, I include a "US State" enumeration:</p> <pre><code>&lt;xs:simpleType name="state"&gt; &lt;xs:restriction base="xs:string"&gt; &lt;xs:enumeration value="AL" /&gt; &lt;xs:enumeration value="AK" /&gt; &lt;xs:enumeration value="AS" /&gt; .... &lt;xs:enumeration value="WY" /&gt; &lt;/xs:restriction&gt; &lt;/xs:simpleType&gt; </code></pre> <p>How do I go about writing the "US State" enumeration once and re-using it in each of my address elements? I apologize in advance if this is a n00b question -- I've never written an XSD before.</p> <p>My initial stab at it is the following:</p> <pre><code>&lt;xs:element name="business_address" maxOccurs="1"&gt; &lt;!-- address fields go here --&gt; &lt;xs:element name="business_address_state" type="state" maxOccurs="1"&gt;&lt;/xs:element&gt; &lt;/xs:element&gt; </code></pre>
[ { "answer_id": 227522, "author": "toolkit", "author_id": 3295, "author_profile": "https://Stackoverflow.com/users/3295", "pm_score": 4, "selected": true, "text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\n targetNamespace=\"h...
2008/10/22
[ "https://Stackoverflow.com/questions/227434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10040/" ]
227,438
<p>I'm attempting to determine the row length in bytes of a table by executing the following stored procedure:</p> <pre><code>CREATE TABLE #tmp ( [ID] int, Column_name varchar(640), Type varchar(640), Computed varchar(640), Length int, Prec int, Scale int, Nullable varchar(640), TrimTrailingBlanks varchar(640), FixedLenNullInSource varchar(640), Collation varchar(256) ) INSERT INTO #tmp exec sp_help MyTable SELECT SUM(Length) FROM #tmp DROP TABLE #tmp </code></pre> <p>The problem is that I don't know the table definition (data types, etc..) of the table returned by 'sp_help.'</p> <p>I get the following error:</p> <pre><code>Insert Error: Column name or number of supplied values does not match table definition. </code></pre> <p>Looking at the sp_help stored procedure does not give me any clues.</p> <p>What is the proper CREATE TABLE statement to insert the results of a sp_help?</p>
[ { "answer_id": 227516, "author": "Vendoran", "author_id": 24666, "author_profile": "https://Stackoverflow.com/users/24666", "pm_score": 3, "selected": false, "text": "CREATE TABLE tblShowContig\n(\n ObjectName CHAR (255),\n ObjectId INT,\n IndexName CHAR (255),\n IndexId INT,...
2008/10/22
[ "https://Stackoverflow.com/questions/227438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21826/" ]
227,440
<p>I have a Rails application that in the erb code, I use a select box. What I would like to do is reload the page passing the sort parameter. My controller already handles it, but I don't know how to reload the page with the selected value from my select box. Here is my code:</p> <pre><code>&lt;% @options = {:latest =&gt; 'lastest' , :alphabetical =&gt; 'alphabetical', :pricelow =&gt; 'price-low', :pricehigh =&gt;'pricehigh'} %&gt; &lt;%= select_tag 'sort[]', options_for_select(@options), :include_blank =&gt; true,:onchange =&gt; "location.reload('location?sort='+this.value)"%&gt; </code></pre>
[ { "answer_id": 227829, "author": "workmad3", "author_id": 16035, "author_profile": "https://Stackoverflow.com/users/16035", "pm_score": 3, "selected": true, "text": "<% @options = {:latest => 'lastest' , :alphabetical => 'alphabetical', :pricelow => 'price-low', :pricehigh =>'pricehigh'}...
2008/10/22
[ "https://Stackoverflow.com/questions/227440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18642/" ]
227,447
<p>When I use this code to output some XML I parsed (and modified) with <code>XmlParser</code></p> <pre><code>XmlParser parser = new XmlParser() def root = parser.parseText(feedUrl.toURL().text) def writer = new StringWriter() new XmlNodePrinter(new PrintWriter(writer)).print(root) println writer.toString() </code></pre> <p>the namespace declarations on the root node are not printed, even though they are there in the <code>toString()</code> of <em>root</em>... any ideas?</p>
[ { "answer_id": 228593, "author": "Ted Naleid", "author_id": 8912, "author_profile": "https://Stackoverflow.com/users/8912", "pm_score": 2, "selected": true, "text": "<feed xmlns=\"http://www.w3.org/2005/Atom\" xmlns:creativeCommons=\"http://backend.userland.com/creativeCommonsRssModule\"...
2008/10/22
[ "https://Stackoverflow.com/questions/227447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2031/" ]
227,449
<p>I'm fairly new to JavaScript. </p> <p>Given a local machine's folder path (Windows), I was wondering how you can extract the names of all the possible folders in the current path, without the knowledge of how many folders there are or what they are called.</p> <p>Thank you very much in advance.</p>
[ { "answer_id": 227582, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 3, "selected": false, "text": "var fso = new ActiveXObject(\"Scripting.FileSystemObject\");\nvar shell = new ActiveXObject(\"WScript.Shell\");\nvar pat...
2008/10/22
[ "https://Stackoverflow.com/questions/227449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
227,457
<p>I'm writing a query to summarize some data. I have a flag in the table that is basically boolean, so I need some sums and counts based on one value of it, and then the same thing for the other value, like so:</p> <pre><code>select location ,count(*) ,sum(duration) from my.table where type = 'X' and location = @location and date(some_tstamp) = @date group by location </code></pre> <p>And then the same for another value of the type column. If I join this table twice, how do I still group so I can only get aggregation for each table, i.e. count(a.<code>*</code>) instead of count(*)...</p> <p>Would it be better to write two separate queries?</p> <p><strong>EDIT</strong></p> <p>Thanks everybody, but that's not what I meant. I need to get a summary where type = 'X' and a summary where type = 'Y' separately...let me post a better example. What I meant was a query like this:</p> <pre><code>select a.location ,count(a.*) ,sum(a.duration) ,count(b.*) ,sum(b.duration) from my.table a, my.table b where a.type = 'X' and a.location = @location and date(a.some_tstamp) = @date and b.location = @location and date(b.some_tstamp) = @date and b.type = 'Y' group by a.location </code></pre> <p>What do I need to group by? Also, DB2 doesn't like count(a.<code>*</code>), it's a syntax error.</p>
[ { "answer_id": 227475, "author": "George Eadon", "author_id": 30530, "author_profile": "https://Stackoverflow.com/users/30530", "pm_score": 3, "selected": false, "text": "select\n type\n ,location\n ,count(*)\n ,sum(duration)\nfrom my.table\nwhere type IN ('X', 'Y')\n and location ...
2008/10/22
[ "https://Stackoverflow.com/questions/227457", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13791/" ]
227,459
<p>How do I get the <a href="http://en.wikipedia.org/wiki/ASCII" rel="noreferrer">ASCII</a> value of a character as an <code>int</code> in Python?</p>
[ { "answer_id": 227466, "author": "Jacob Krall", "author_id": 3140, "author_profile": "https://Stackoverflow.com/users/3140", "pm_score": 6, "selected": false, "text": "ord()\n" }, { "answer_id": 227472, "author": "Matt J", "author_id": 18528, "author_profile": "https:...
2008/10/22
[ "https://Stackoverflow.com/questions/227459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17693/" ]
227,461
<p>I want to do some basic filtering on a file. Read it, do processing, write it back. </p> <p>I'm not looking for "golfing", but want the simplest and most elegant method to achieve this. I came up with:</p> <pre><code>from __future__ import with_statement filename = "..." # or sys.argv... with open(filename) as f: new_txt = # ...some translation of f.read() open(filename, 'w').write(new_txt) </code></pre> <p>The <code>with</code> statement makes things shorter since I don't have to explicitly open and close the file.</p> <p>Any other ideas ?</p>
[ { "answer_id": 227721, "author": "Federico A. Ramponi", "author_id": 18770, "author_profile": "https://Stackoverflow.com/users/18770", "pm_score": 2, "selected": false, "text": "with open(filename, \"r+\") as f:\n new_txt = process(f.read())\n f.truncate(0)\n f.write(new_txt)\n"...
2008/10/22
[ "https://Stackoverflow.com/questions/227461", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
227,470
<p>I have a search form on each of my pages. If I use form helper, it defaults to <code>$_POST</code>. I'd like the search term to show up in the URI:</p> <pre><code>http://example.com/search/KEYWORD </code></pre> <p>I've been on Google for about an hour, but to no avail. I've only found articles on how <code>$_GET</code> is basically disabled, because of the native URI convention. I can't be the first person to want this kind of functionality, am I? Thanks in advance!</p>
[ { "answer_id": 227494, "author": "Justin Voss", "author_id": 5616, "author_profile": "https://Stackoverflow.com/users/5616", "pm_score": -1, "selected": false, "text": "$_GET" }, { "answer_id": 227496, "author": "64BitBob", "author_id": 16339, "author_profile": "https...
2008/10/22
[ "https://Stackoverflow.com/questions/227470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24708/" ]
227,473
<p>I need a well tested Regular Expression (.net style preferred), or some other simple bit of code that will parse a USA/CA phone number into component parts, so:</p> <ul> <li>3035551234122</li> <li>1-303-555-1234x122</li> <li>(303)555-1234-122</li> <li>1 (303) 555 -1234-122</li> </ul> <p>etc...</p> <p>all parse into:</p> <ul> <li>AreaCode: 303</li> <li>Exchange: 555</li> <li>Suffix: 1234</li> <li>Extension: 122</li> </ul>
[ { "answer_id": 227509, "author": "Philip Rieck", "author_id": 12643, "author_profile": "https://Stackoverflow.com/users/12643", "pm_score": 2, "selected": false, "text": "^(?:(?:[\\+]?(?<CountryCode>[\\d]{1,3}(?:[ ]+|[\\-.])))?[(]?(?<AreaCode>[\\d]{3})[\\-/)]?(?:[ ]+)?)?(?<Number>[a-zA-Z...
2008/10/22
[ "https://Stackoverflow.com/questions/227473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30529/" ]
227,485
<p>I have a little demonstration below of a peculiar problem.</p> <pre><code>using System; using System.Windows.Forms; namespace WindowsApplication1 { public class TestForm : Form { private System.Windows.Forms.TabControl tabControl1; private System.Windows.Forms.TabPage tabPage1; private System.Windows.Forms.TabPage tabPage2; private System.Windows.Forms.TextBox textBox1; public TestForm() { //Controls this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); this.tabPage2 = new System.Windows.Forms.TabPage(); this.textBox1 = new System.Windows.Forms.TextBox(); // tabControl1 this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.tabControl1.Controls.Add(this.tabPage1); this.tabControl1.Controls.Add(this.tabPage2); this.tabControl1.Location = new System.Drawing.Point(12, 12); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; this.tabControl1.Size = new System.Drawing.Size(260, 240); this.tabControl1.TabIndex = 0; this.tabControl1.Selected += new System.Windows.Forms.TabControlEventHandler(this.tabControl1_Selected); // tabPage1 this.tabPage1.Controls.Add(this.textBox1); this.tabPage1.Location = new System.Drawing.Point(4, 22); this.tabPage1.Name = "tabPage1"; this.tabPage1.Size = new System.Drawing.Size(252, 214); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "tabPage1"; // tabPage2 this.tabPage2.Location = new System.Drawing.Point(4, 22); this.tabPage2.Name = "tabPage2"; this.tabPage2.Size = new System.Drawing.Size(192, 74); this.tabPage2.TabIndex = 1; this.tabPage2.Text = "tabPage2"; // textBox1 this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.textBox1.Location = new System.Drawing.Point(6, 38); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(240, 20); this.textBox1.TabIndex = 0; // TestForm this.ClientSize = new System.Drawing.Size(284, 264); this.Controls.Add(this.tabControl1); this.Name = "Form1"; this.Text = "Form1"; } //Tab Selected private void tabControl1_Selected(object sender, EventArgs e) { this.Text = "TextBox Width: " + this.textBox1.Width.ToString(); } } //Main static class Program { static void Main() { Application.Run(new TestForm()); } } } </code></pre> <p>If you run the above C# code you will have a small form containing a tabcontrol. Within the tabcontrol is a texbox on the first tab. If you follow these steps you will see the problem:</p> <ol> <li>Select tabPage2 (textBox1's width is reported in the form title)</li> <li>Resize the form</li> <li>Select tabPage1 (The wrong textBox1 width is reported)</li> </ol> <p>Any ideas what is going on here? The textbox is obviously bigger than what is being reported. If you click again on tabPage2 the correct size is then updated. Obviously there is an event updating the width of textBox1. Can i trigger this when tabPage1 is selected?</p>
[ { "answer_id": 227528, "author": "OwenP", "author_id": 2547, "author_profile": "https://Stackoverflow.com/users/2547", "pm_score": 1, "selected": false, "text": "Selected" } ]
2008/10/22
[ "https://Stackoverflow.com/questions/227485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13227/" ]
227,486
<p>Does anyone know how to programmaticly find out where the java classloader actually loads the class from? </p> <p>I often work on large projects where the classpath gets very long and manual searching is not really an option. I recently had a <a href="https://stackoverflow.com/questions/226280/eclipse-class-version-bug" title="problem">problem</a> where the classloader was loading an incorrect version of a class because it was on the classpath in two different places.</p> <p>So how can I get the classloader to tell me where on disk the actual class file is coming from?</p> <p><strong><em>Edit:</em></strong> What about if the classloader actually fails to load the class due to a version mismatch (or something else), is there anyway we could find out what file its trying to read before it reads it?</p>
[ { "answer_id": 227492, "author": "Daniel Spiewak", "author_id": 9815, "author_profile": "https://Stackoverflow.com/users/9815", "pm_score": -1, "selected": false, "text": "MyClass" }, { "answer_id": 227569, "author": "Jon Skeet", "author_id": 22656, "author_profile": ...
2008/10/22
[ "https://Stackoverflow.com/questions/227486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25920/" ]
227,500
<p>I'm working on a JSP where I need to call methods on object that come from a Bean. The previous version of the page does not use JSTL and it works properly. My new version has a set up like this:</p> <pre><code>&lt;jsp:useBean id="pageBean" scope="request" type="com.epicentric.page.website.PageBean" /&gt; &lt;c:set var="pageDividers" value="&lt;%= pageBean.getPageDividers() %&gt;" /&gt; &lt;c:set var="numColumns" value="${pageDividers.size()}" /&gt; </code></pre> <p>The variable <code>pageDividers</code> is a <code>List</code> object.</p> <p>I'm encountering this issue: when I ask for <code>pageDivider</code>'s size, an exception is thrown. I know this is a simple JTSL error -- what am I doing wrong?</p> <p>The error message is:</p> <blockquote> <p>The function size must be used with a prefix when a default namespace is not specified</p> </blockquote> <p>How do I correctly access or call the methods of my <code>pageDividers</code> object?</p>
[ { "answer_id": 227511, "author": "Vincent Ramdhanie", "author_id": 27439, "author_profile": "https://Stackoverflow.com/users/27439", "pm_score": 2, "selected": false, "text": "${pageDividers.size}\n" }, { "answer_id": 227551, "author": "abahgat", "author_id": 27565, "...
2008/10/22
[ "https://Stackoverflow.com/questions/227500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18265/" ]
227,507
<p>How can I read an Open Office 3.0 spreadsheet (.ods) from Groovy? I'd like to select specific columns from a named worksheet. Ideally, it would be useful to add a 'where' clause, or other criteria clause.</p>
[ { "answer_id": 12933631, "author": "Aaron Digulla", "author_id": 34088, "author_profile": "https://Stackoverflow.com/users/34088", "pm_score": 0, "selected": false, "text": "content.xml" } ]
2008/10/22
[ "https://Stackoverflow.com/questions/227507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
227,519
<p>I am writing a tool to help students learn regular expressions. I will probably be writing it in Java.</p> <p>The idea is this: the student types in a regular expression and the tool shows which parts of a text will get matched by the regex. Simple enough.</p> <p>But I want to support several different regex "flavors" such as:</p> <ul> <li>Basic regular expressions (think: grep)</li> <li>Extended regular expressions (think: egrep)</li> <li>A subset of Perl regular expressions, including the character classes \w, \s, etc.</li> <li>Sed-style regular expressions</li> </ul> <p>Java has the java.util.Regex class, but it supports only Perl-style regular expressions, which is a superset of the basic and extended REs. What I think I need is a way to take any given regular expression and escape the meta-characters that aren't part of a given flavor. Then I could give it to the Regex object and it would behave as if it was written for the selected RE interpreter.</p> <p>For example, given the following regex:</p> <pre><code>^\w+[0-9]{5}-(\d{4})?$ </code></pre> <p>As a basic regular expression, it would be interpreted as:</p> <pre><code>^\\w\+[0-9]\{5\}-\(\\d\{4\}\)\?$ </code></pre> <p>As an extended regular expression, it would be:</p> <pre><code>^\\w+[0-9]{5}-(\\d{4})?$ </code></pre> <p>And as a Perl-style regex, it would be the same as the original expression.</p> <p>Is there a "regular expression for regular expressions" than I could run through a regex search-and-replace to quote the non-meta characters? What else could I do? Are there alternative Java classes I could use?</p>
[ { "answer_id": 227626, "author": "Markus Jarderot", "author_id": 22364, "author_profile": "https://Stackoverflow.com/users/22364", "pm_score": 1, "selected": false, "text": "[^?+*{}()[\\]\\\\] # literal characters\n\\\\[A-Za-z] # Character classes\n\\\\...
2008/10/22
[ "https://Stackoverflow.com/questions/227519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17312/" ]
227,545
<p>When I build a unit test project before the tests are executed the test output is copied to a TestResults folder and then the tests are executed. The issue I'm having is that not all the files in the Debug/bin directory are copied to the TestResults project.</p> <p>How can I get a file that is copied to the Debug/bin directory to also be copied to the TestResults folder?</p>
[ { "answer_id": 227713, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 8, "selected": true, "text": ".testrunconfig" }, { "answer_id": 3447009, "author": "Sanjay10", "author_id": 61102, "author_profile"...
2008/10/22
[ "https://Stackoverflow.com/questions/227545", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3957/" ]
227,552
<p>I am trying to debug a JavaScript script that gets read in a Firefox extension and executed. I only can see errors via the Firebug console (my code is invisible to Firebug), and it's reporting a "unterminated string literal." </p> <p>I checked the line and the lines around it and everything seems fine-parentheses, braces, and quotes are balanced, etc. What are other possible causes that I should be looking for?</p>
[ { "answer_id": 1373122, "author": "VoY", "author_id": 6254, "author_profile": "https://Stackoverflow.com/users/6254", "pm_score": 7, "selected": true, "text": "var foo = \"</script>\";\n" }, { "answer_id": 4334841, "author": "Ipsoratio", "author_id": 527943, "author_p...
2008/10/22
[ "https://Stackoverflow.com/questions/227552", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1227001/" ]
227,566
<p>Does anyone have a good articles or tutorial on correctly using dispose and IDisposable. I am trying to explain this to some junior dev and wanted to get some extra material, examples, etc.</p>
[ { "answer_id": 228326, "author": "NotDan", "author_id": 3291, "author_profile": "https://Stackoverflow.com/users/3291", "pm_score": 0, "selected": false, "text": "using (MyDisposable obj = new MyDisposable())\n{\n obj.some_stuff();\n\n} //obj is disposed here\n" } ]
2008/10/22
[ "https://Stackoverflow.com/questions/227566", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4653/" ]
227,575
<p>Here is a snippet of the code :</p> <pre><code>HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(request.RawUrl); WebRequest.DefaultWebProxy = null;//Ensure that we will not loop by going again in the proxy HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse(); string charSet = response.CharacterSet; Encoding encoding; if (String.IsNullOrEmpty(charSet)) encoding = Encoding.Default; else encoding = Encoding.GetEncoding(charSet); StreamReader resStream = new StreamReader(response.GetResponseStream(), encoding); return resStream.ReadToEnd(); </code></pre> <p>The problem is if I test with : <a href="http://www.google.fr" rel="noreferrer">http://www.google.fr</a></p> <p>All &quot;é&quot; are not displaying well. I have try to change ASCII to UTF8 and it still display wrong. I have tested the html file in a browser and the browser display the html text well so I am pretty sure the problem is in the method I use to download the html file.</p> <p>What should I change?</p> <p><em>removed dead ImageShack link</em></p> <h3>Update 1: Code and test file changed</h3>
[ { "answer_id": 227598, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 6, "selected": true, "text": "HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(myURL);\nusing (HttpWebResponse response = (HttpWebResponse...
2008/10/22
[ "https://Stackoverflow.com/questions/227575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13913/" ]
227,590
<p>For an iPhone app that submits images to a server I need somehow to tie all the images from a particular phone together. With every submit I'd like to send some unique phone id. Looked at <pre> [[UIDevice mainDevice] uniqueIdentifier]<br> and [[NSUserDefaults standardDefaults] stringForKey:@"SBFormattedPhoneNumber"] </pre></p> <p>but getting errors in the simulator.</p> <p>Is there an Apple sanctioned way of doing this?</p>
[ { "answer_id": 227654, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 6, "selected": true, "text": "[[UIDevice currentDevice] uniqueIdentifier]" }, { "answer_id": 228230, "author": "Jason Harris", "author...
2008/10/22
[ "https://Stackoverflow.com/questions/227590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30541/" ]
227,596
<p>This has been bugging me, I can't get my head around it. I will use the foodstuffs analogy to try and simplify my probelm.</p> <p>1000 members of the public where asked to pick a variety from each of 13 categories of footstuff. These selections were then stored in a mysql database against their name.</p> <pre><code>e.g. billy mary etc. etc. milk....semi. .skimmed... bread...white...brown.... cheese..edam.....edam.... fruit...apple...orange... veg....potato...sprout... meat....beef.....beef.... sweet..bonbons..liquorice.. fish...trout....salmon... crisp....s&amp;v....plain.... biscuit..hovis..rich tea.. wine.....red.....red..... beer....stella..carlsburg.. carb....coke.....pepsi.... </code></pre> <p>One of those 1000 was then asked to select anywhere from zero to 13 of their selections via checkboxes.</p> <p>By searching the database how many others selected the same varieties?</p> <p>Display in a table showing all their names and what they selected for all 13 varieties.</p> <p>Does that make sense? I hope so 'cause it's driving me mad.</p>
[ { "answer_id": 227794, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 2, "selected": false, "text": "PersonId What_Milk What_Bread What_Cheese\n 1 Semi Wheat Swiss\n 2 Skimmed Rolls Fre...
2008/10/22
[ "https://Stackoverflow.com/questions/227596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
227,604
<p>Is there a good way to read RAW image files (especially Canon CR2 and Adobe DNG files) as GDI+ bitmaps that is reasonably fast?</p> <p>I found an example running under WPF that would read an image using any installed image codec and then display it in an image control. And I modified this example to create a GDI+ bitmap by writing the WPF image to a MemoryStream and creating the Bitmap from that. But this process is slow! Horribly slow! Opening a simple image takes around 10 seconds on my computer. This solution also requires references to the WPF assemblies and that doesn't feel right, especially not since I would like to run the code in an ASP.NET project. </p> <p>There are programs that will do batch conversions of the images, but I would prefer converting the images dynamically when requested. </p> <p>So, any suggestions? </p>
[ { "answer_id": 229045, "author": "Rune Grimstad", "author_id": 30366, "author_profile": "https://Stackoverflow.com/users/30366", "pm_score": 2, "selected": false, "text": "Process.Start" }, { "answer_id": 4256784, "author": "glenneroo", "author_id": 209866, "author_pr...
2008/10/22
[ "https://Stackoverflow.com/questions/227604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30366/" ]
227,608
<p>Is there a simple way to parse a date that may be in MM/DD/yyyy, or M/D/yyyy, or some combination? i.e. the zero is optional before a single digit day or month.</p> <p>To do it manually, one could use:</p> <pre><code>String[] dateFields = dateString.split("/"); int month = Integer.parseInt(dateFields[0]); int day = Integer.parseInt(dateFields[1]); int year = Integer.parseInt(dateFields[2]); </code></pre> <p>And validate with:</p> <pre><code>dateString.matches("\\d\\d?/\\d\\d?/\\d\\d\\d\\d") </code></pre> <p>Is there a call to SimpleDateFormat or JodaTime that would handle this?</p>
[ { "answer_id": 227625, "author": "toolkit", "author_id": 3295, "author_profile": "https://Stackoverflow.com/users/3295", "pm_score": 4, "selected": false, "text": "DateFormat df = new SimpleDateFormat(\"MM/dd/yyyy\");\ndf.setLenient(true);\nSystem.out.println(df.parse(\"05/05/1999\"));\n...
2008/10/22
[ "https://Stackoverflow.com/questions/227608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2046/" ]
227,612
<p>I am inserting a column in a DataGridView programmatically (i.e., not bound to any data tables/databases) as follows:</p> <pre><code>int lastIndex = m_DGV.Columns.Count - 1; // Count = 4 in this case DataGridViewTextBoxColumn col = (DataGridViewTextBoxColumn)m_DGV.Columns[lastIndex]; m_DGV.Columns.RemoveAt(lastIndex); m_DGV.Columns.Insert(insertIndex, col); // insertIndex = 2 </code></pre> <p>I have found that my columns are visually out of order sometimes using this method. A workaround is to manually set the DisplayIndex property of the column afterwards. Adding this code "fixes it", but I don't understand why it behaves this way.</p> <pre><code>Console.Write(m_DGV.Columns[0].DisplayIndex); // Has value of 0 Console.Write(m_DGV.Columns[1].DisplayIndex); // Has value of 1 Console.Write(m_DGV.Columns[2].DisplayIndex); // Has value of 3 Console.Write(m_DGV.Columns[3].DisplayIndex); // Has value of 2 col.DisplayIndex = insertIndex; Console.Write(m_DGV.Columns[0].DisplayIndex); // Has value of 0 Console.Write(m_DGV.Columns[1].DisplayIndex); // Has value of 1 Console.Write(m_DGV.Columns[2].DisplayIndex); // Has value of 2 Console.Write(m_DGV.Columns[3].DisplayIndex); // Has value of 3 </code></pre> <p>As an aside, my grid can grow its column count dynamically. I wanted to grow it in chunks, so each insert didn't require a column allocation (and associated initialization). Each "new" column would then be added by grabbing an unused column from the end, inserting it into the desired position, and making it visible.</p>
[ { "answer_id": 241167, "author": "e-holder", "author_id": 22252, "author_profile": "https://Stackoverflow.com/users/22252", "pm_score": 0, "selected": false, "text": "Insert" }, { "answer_id": 355463, "author": "lc.", "author_id": 44853, "author_profile": "https://Sta...
2008/10/22
[ "https://Stackoverflow.com/questions/227612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22252/" ]
227,613
<p>How do I copy a directory including sub directories excluding files or directories that match a certain regex on a Windows system?</p>
[ { "answer_id": 227636, "author": "Niniki", "author_id": 4155, "author_profile": "https://Stackoverflow.com/users/4155", "pm_score": 1, "selected": false, "text": "ls -R1 | grep -v <regex to exclude> | awk '{printf(\"cp %s /destination/path\",$1)}' | /bin/sh\n" }, { "answer_id": 2...
2008/10/22
[ "https://Stackoverflow.com/questions/227613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2133/" ]
227,624
<p>I am trying to create controller actions which will return either JSON or partial html depending upon a parameter. What is the best way to get the result returned to an MVC page asynchronously?</p>
[ { "answer_id": 227638, "author": "Haacked", "author_id": 598, "author_profile": "https://Stackoverflow.com/users/598", "pm_score": 10, "selected": true, "text": "public ActionResult SomeActionMethod() {\n return Json(new {foo=\"bar\", baz=\"Blech\"});\n}\n" }, { "answer_id": 227...
2008/10/22
[ "https://Stackoverflow.com/questions/227624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30544/" ]
227,627
<p>I have this 'simplified' fortran code</p> <pre><code>real B(100, 200) real A(100,200) ... initialize B array code. do I = 1, 100 do J = 1, 200 A(J,I) = B(J,I) end do end do </code></pre> <p>One of the programming gurus warned me, that fortran accesses data efficiently in column order, while c accesses data efficiently in row order. He suggested that I take a good hard look at the code, and be prepared to switch loops around to maintain the speed of the old program.</p> <p>Being the lazy programmer that I am, and recognizing the days of effort involved, and the mistakes I am likely to make, I started wondering if there might a #define technique that would let me convert this code safely, and easily.</p> <p>Do you have any suggestions?</p>
[ { "answer_id": 227680, "author": "itsmatt", "author_id": 7862, "author_profile": "https://Stackoverflow.com/users/7862", "pm_score": 2, "selected": false, "text": "real B(100, 200) \nreal A(100,200)\n\n... initialize B array code.\n\ndo I = 1, 100\n do J = 1, 200\n A(I,J) = B(I,J)\n ...
2008/10/22
[ "https://Stackoverflow.com/questions/227627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7734/" ]
227,634
<p>I am copying a repository by using svnsync and am receiving this error on the same revision every time.</p> <blockquote> <p>Transmitting file data ...svnsync: REPORT of '<a href="https://svn1.avlux.net/xxxxxx.net" rel="nofollow noreferrer">https://svn1.avlux.net/xxxxxx.net</a>': Could not read response body: Secure connection truncated <a href="https://svn1.avlux.net" rel="nofollow noreferrer">https://svn1.avlux.net</a>)</p> </blockquote> <p>It is a large revision and I don't have admin access to the server. Is there a way around this, even if it involves checking out and copying the revision manually?</p>
[ { "answer_id": 228427, "author": "Mike Deck", "author_id": 1247, "author_profile": "https://Stackoverflow.com/users/1247", "pm_score": 3, "selected": true, "text": "svn diff -r134:135 http://your/repo/url > patch.diff\n" } ]
2008/10/22
[ "https://Stackoverflow.com/questions/227634", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5233/" ]
227,650
<p>Say I have an MSSQL table with two columns: an int ID column that's the identity column and some other datetime or whatever column. Say the table has 10 records with IDs 1-10. Now I delete the record with ID = 5.</p> <p>Are there any scenarios where another record will "fill-in" that missing ID? I.e. when would a record be inserted and given an ID of 5?</p>
[ { "answer_id": 229079, "author": "onedaywhen", "author_id": 15354, "author_profile": "https://Stackoverflow.com/users/15354", "pm_score": 0, "selected": false, "text": "CREATE TABLE Test \n(\n ID INTEGER IDENTITY(1, 1) NOT NULL, \n data_col INTEGER NOT NULL\n);\n\nINSERT INTO Test (d...
2008/10/22
[ "https://Stackoverflow.com/questions/227650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22471/" ]
227,667
<p>What type of exception is caught by the beanshell catch(ex): Exception or Throwable?.</p> <p>Example:</p> <pre><code>try { .... } catch (ex) { } </code></pre>
[ { "answer_id": 232275, "author": "Bob Cross", "author_id": 5812, "author_profile": "https://Stackoverflow.com/users/5812", "pm_score": 3, "selected": false, "text": "try {\n new Throwable(\"Something Exceptional\");\n} catch (ex) {\n System.err.println(ex.getMessage());\n}\n" } ]
2008/10/22
[ "https://Stackoverflow.com/questions/227667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
227,674
<p>I've got a few very short audio clips (less than a second long) to be played on various events (button hover, click, etc). However, there is usually a significant lag between the action and the actual playing of the sound. I have tried both embedding the sound in the .swf, and loading it externally at the start, but both lead to the same results. Likewise, I've tried with compressed and uncompressed audio.</p> <p>What it <em>seems</em> like is that the audio buffers are just a lot longer than I need them to be, like perhaps Flash is optimized more towards playing longer sounds without any stutter at the expense of a little more latency in starting sounds. Could this be it? Is there any way to change them? Since what I'm working on will never need to play sounds more than a second or so long and will always be loaded completely at the start, it wouldn't hurt it at all to have really short buffers.</p> <p>One other possible thing that might be the cause: if I use .wav files when using loadSound()... I can't get it to actually play the sounds. There's no errors, and everything returns as it should, but no actual sound is played, which is why I have them as .mp3 currently. Perhaps when using .mp3 audio (or any compressed audio), there just will be lag in decoding it? The reason I still have doubts about this, though, is that when embedding them in the .swf as .wav files (by importing them into the library), they still have the same latency on playback.</p> <p>Just for a sanity check, I'll include the code I've got, minus irrelevant parts and error checking. First, loading them at runtime:</p> <pre><code>var soundArray:Array = new Array(); loadSound( "click", "sounds/buttondroop4.mp3" ); loadSound( "hover", "sounds/Dink-Public_D-146.mp3" ); function loadSound( name:String, url:String ):void { var req:URLRequest = new URLRequest( url ); soundArray[ name ] = new Sound( req ); soundArray[ name ].addEventListener( Event.COMPLETE, soundLoaded ); } function soundLoaded( event:Event ):void { for( var name:String in soundArray ) { if( event.target == soundArray[name] ) { trace( "Loaded sound [" + name + "]" ); return; } } } function playSound( name:String ):void { for( var nameSrc:String in soundArray ) { if( name == nameSrc ) { var channel:SoundChannel = soundArray[ name ].play(); return; } } } // Sometime later, well after soundLoaded() callback is triggered... playSound( "click" ); playSound( "hover" ); </code></pre> <p>And an alternate way, embedding them in the library as classes and going from there:</p> <pre><code>var sClick:soundClick = new soundClick(); var sHover:soundHover = new soundHover(); sClick.play(); sHover.play(); </code></pre> <p>The sound files are tiny, less than 10kb generally. The lag is apparent enough that one of the first complaints someone had when looking at it was that the sound effects on button hovers seemed delayed, so it wasn't just me being picky. I feel like I must just be doing something wrong; there's too many flash things out there that have snappy sound effects without anywhere near this kind of lag.</p> <p>edit: In response to the first response about sound files themselves, I've already checked, and the sound starts immediately at the start of the file (even clipping out everything but the very first millisecond of sound, I can still hear the start of the 'tick' noise it makes).</p>
[ { "answer_id": 238176, "author": "James Fassett", "author_id": 27081, "author_profile": "https://Stackoverflow.com/users/27081", "pm_score": 4, "selected": true, "text": "function playSound( name:String ):void\n{\n for( var nameSrc:String in soundArray )\n {\n if( name == nameSr...
2008/10/22
[ "https://Stackoverflow.com/questions/227674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9330/" ]
227,701
<p>I can't for the life of me find a form that doesn't email the results that you submit.</p> <p>I'm looking to find a form that I can have users enter simple data that i can then spit back out at them in different arrangements. If they submit First and Last, I'll spit out, amongst other things, FirstLast@domain.com. I'm willing to scrounge the code manually to do this, but I cant find a simple form that would allow me to do this. </p> <p><strong>Edit:</strong> PHP or similar simple languages. I've never touched .NET before.</p>
[ { "answer_id": 227891, "author": "Kornel", "author_id": 27009, "author_profile": "https://Stackoverflow.com/users/27009", "pm_score": 0, "selected": false, "text": "<form onsubmit=\"magic(this);return false\">\n <p><label>First <input name=first/></label>\n <p><label>Last <input na...
2008/10/22
[ "https://Stackoverflow.com/questions/227701", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
227,708
<p>I would like to apply some logic to a page containing a CheckBoxList control when the user checks or unchecks individual checkbox items. Say, for instance to dynamically show or hide a related control.</p> <p>I came up with a way using ASP.Net 2.0 callback mechanism (AJAX) with a combination of client-side Javascript and server-side logic in the code-behind. However, this solution is not very bullet-proof (i.e. most likely suffers from timing issues). It is not portable, because the code needs to know the sequential ids of individual items, etc.</p> <p>The code I came up with is separated in two functions, one handling the <code>onclick</code> event, and the other processing the returned callback string :</p> <pre><code>&lt;script type="text/javascript"&gt; function OnCheckBoxClicked() { // gathers the semi-colon separated list of labels, // associated with the currently checked items var texts = ''; // iterate over each individual checkbox item // items in a checkboxlist are sequential, so // stop iteration at the first missing sequence number for (var index = 0; index &lt; 99; index++) { var checkbox = document.getElementById('ctl00_cphAdmin_cblCategories_' + index); if (checkbox == null) break; if (checkbox.checked) { // find label associated with the current checkbox item var labels = document.getElementsByTagName('label'); for (var index_ = 0; index_ &lt; labels.length; index_ ++) { if (labels[index_].htmlFor == checkbox.id) { texts = texts + labels[index_].innerHTML + ';'; break; } } } } // perform callback request // result will be processed by the UpdateCheckBoxes function WebForm_DoCallback('__Page', '_checkbox' + texts, UpdateCheckBoxes, 'checkbox', null, true /* synchronous */); } &lt;/script&gt; </code></pre> <p>In this example, my checkboxes match categories of a blog post.</p> <p>I need to process the resulting callback string as containing a list of semicolon-separated names of checkboxes to check/uncheck, in order to make sure that related parent/child categories are synchronized correctly. This string results from logic executed on the server.</p> <p>In other cases, the resulting callback string might be something else.</p> <pre><code>&lt;script type="text/javascript"&gt; function UpdateCheckBoxes(returnmessage, context) { if (returnmessage == null || returnmessage == '') return ; // iterate over each individual checkbox item // items in a checkboxlist are sequential, so // stop iteration at the first missing sequence number for (var index = 0; index &lt; 99; index++) { var checkbox = document.getElementById('ctl00_cphAdmin_cblCategories_' + index); if (checkbox == null) break; // find label associated with the current checkbox item var label = ''; var labels = document.getElementsByTagName('label'); for (var index_ = 0; index_ &lt; labels.length; index_ ++) { if (labels[index_].htmlFor == checkbox.id) { label = ';' + labels[index_].innerHTML + ';'; break; } } // perform custom processing based on the contents // of the returned callback string // for instance, here we check whether the returnmessage // contains the string ';' + label + ';' if (returnmessage.indexOf(label, 1) &gt; 0) { // do something } } } &lt;/script&gt; </code></pre> <p>Isn't there a more elegant solution to this problem?</p>
[ { "answer_id": 228448, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": true, "text": " <label for=\"something\">CheckBox 1</label>\n <input type='checkbox' id='ctl00_....' value='1' onclick=\"OnCheckBoxCl...
2008/10/22
[ "https://Stackoverflow.com/questions/227708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18865/" ]
227,711
<p>I found <a href="http://www.jenitennison.com/xslt/grouping/muenchian.html" rel="noreferrer">this page</a> describing the Muenchian method, but I think I'm applying it wrong.</p> <p>Consider that this would return a set of ages:</p> <pre><code>/doc/class/person/descriptive[(@name='age')]/value </code></pre> <blockquote> <p>1..2..2..2..3..3..4..7</p> </blockquote> <p>But I would like a nodeset only one node for each age.</p> <blockquote> <p>1..2..3..4..7</p> </blockquote> <p>Each of these seem to return all of the values, instead of unique values:</p> <pre><code>/doc/class/person/descriptive[(@name='age')][not(value=preceding-sibling::value)]/value /doc/class/person/descriptive[(@name='age')]/value[not(value=preceding-sibling::value)] </code></pre> <p>What am I missing?</p>
[ { "answer_id": 227765, "author": "JacobE", "author_id": 30056, "author_profile": "https://Stackoverflow.com/users/30056", "pm_score": 1, "selected": false, "text": "/doc/class/person/descriptive[(@name='age')][not(value=preceding-sibling::descriptive[@name='age']/value)]/value\n" }, ...
2008/10/22
[ "https://Stackoverflow.com/questions/227711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/525/" ]
227,717
<p>I need to be able to launch a process and read the output into a variable. Then based on the return of the command I can choose to show the full output or just a selected subset.</p> <p>So to be clear, I want to launch a text based process (psexec actually) and read the output from that command (stdout, stderr, etc) into a variable rather than have it directly outputted to the console.</p>
[ { "answer_id": 227748, "author": "Pseudo Masochist", "author_id": 8529, "author_profile": "https://Stackoverflow.com/users/8529", "pm_score": 4, "selected": true, "text": "System.Diagnostics.Process" }, { "answer_id": 227784, "author": "alastairs", "author_id": 5296, ...
2008/10/22
[ "https://Stackoverflow.com/questions/227717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24279/" ]
227,729
<p>I am a self taught vb6 programmer who uses DAO. Below is an example of a typical piece of code that I could churn out:</p> <pre><code>Sub cmdMultiplier_Click() 'Button on form, user interface ' dim Rec1 as recordset dim strSQL as string strSQL = "select * from tblCustomers where ID = " &amp; CurrentCustomerID 'inline SQL ' set rec1 = GlobalDataBase.openrecordset(strSQL) ' Data access ' if rec1.bof &lt;&gt; true or rec1.eof &lt;&gt; true then if rec1.fields("Category").value = 1 then PriceMultiplier = 0.9 ' Business Logic ' else priceMultiplier = 1 end if end if End Sub </code></pre> <p>Please pretend that the above is the entire source code of a CRUD application. I know this design is bad, everything is mixed up together. Ideally it should have three distinct layers, user interface, business logic and data access. I sort-of get why this is desirable but I don't know how it's done and I suspect that's why I don't fully get why such a separation is good. I think I'd be a lot further down the road if someone could refactor the above ridiculously trivial example into 3 tiers. </p>
[ { "answer_id": 227764, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "function getCustomer(CurrentCustomerID as Long)\n\nstrSQL = \"select * from tblCustomers where ID = \" & CurrentCustomerID\nse...
2008/10/22
[ "https://Stackoverflow.com/questions/227729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6164/" ]
227,731
<p>I need to do some large integer math. Are there any classes or structs out there that represent a 128-bit integer and implement all of the usual operators?</p> <p>BTW, I realize that <code>decimal</code> can be used to represent a 96-bit int.</p>
[ { "answer_id": 227795, "author": "Larsenal", "author_id": 337, "author_profile": "https://Stackoverflow.com/users/337", "pm_score": 7, "selected": true, "text": "var i = System.Numerics.BigInteger.Parse(\"10000000000000000000000000000000\");\n" }, { "answer_id": 228874, "auth...
2008/10/22
[ "https://Stackoverflow.com/questions/227731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4066/" ]
227,738
<p>I have a case where a 3rd party ad is bleeding through my modal window implementation. I'd like to up the z-index of the modal overlay as high as possible so the ad won't show on top of it. Is there a limit to z-index values? I'm sure if there is it varies by browser. Anyone know?</p>
[ { "answer_id": 227782, "author": "Kornel", "author_id": 27009, "author_profile": "https://Stackoverflow.com/users/27009", "pm_score": 5, "selected": true, "text": "z-index" } ]
2008/10/22
[ "https://Stackoverflow.com/questions/227738", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11577/" ]
227,743
<p>Someone told me that it's faster to concatenate strings with StringBuilder. I have changed my code but I do not see any Properties or Methods to get the final build string. </p> <p>How can I get the string?</p>
[ { "answer_id": 227744, "author": "BlackWasp", "author_id": 21862, "author_profile": "https://Stackoverflow.com/users/21862", "pm_score": 4, "selected": false, "text": "using System;\nusing System.Text;\n\npublic sealed class App \n{\n static void Main() \n {\n // Create a St...
2008/10/22
[ "https://Stackoverflow.com/questions/227743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14441/" ]
227,762
<p>I am working on an embedded systems project and have run into an issue of the compiler being programatically embedded in the Paradigm C++ IDE. I would like to be able to automate building.</p> <p>The processor is the AMD186ES. I am not working with the OS - just baremetal stuff. I need to generate real-mode 16-bit 8086 machine code from C++. </p> <p>My googling indicates that G++ can build such code. </p> <p>My questions are: </p> <p>Can g++ be configured to build this machine code?</p> <p>Are there other C++ compilers that can do it as well?</p>
[ { "answer_id": 12829806, "author": "Hawken", "author_id": 800270, "author_profile": "https://Stackoverflow.com/users/800270", "pm_score": 4, "selected": true, "text": "as" } ]
2008/10/22
[ "https://Stackoverflow.com/questions/227762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26227/" ]
227,775
<p>Let's say I have a class in my web app called class "Foo". It has an initialise() method that is called when the bean is created using Spring. The initialise() method then tries to load an external service and assign it to a field. If the service could not be contacted, the field will be set to null. </p> <pre><code>private Service service; public void initialise() { // load external service // set field to the loaded service if contacted // set to field to null if service could not be contacted } </code></pre> <p>When someone calls the method get() on the class "Foo" the service will be invoked if it was started in the initialise() method. If the field for the service is null, I want to try and load the external service.</p> <pre><code>public String get() { if (service == null) { // try and load the service again } // perform operation on the service is service is not null } </code></pre> <p>Is it possible that I may have sync issues if I would do something like this?</p>
[ { "answer_id": 227812, "author": "toolkit", "author_id": 3295, "author_profile": "https://Stackoverflow.com/users/3295", "pm_score": 0, "selected": false, "text": "public class FooServlet extends HttpServlet {\n\n private MyBean myBean;\n\n public void init() {\n myBean = (M...
2008/10/22
[ "https://Stackoverflow.com/questions/227775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30563/" ]
227,790
<p>So I'm teaching myself Python, and I'm having an issue with lists. I want to pass my function a list and pop items off it while retaining the original list. How do I make python "instance" the passed list rather that passing a pointer to the original one?</p> <p>Example:</p> <pre><code>def burninate(b): c = [] for i in range(3): c.append(b.pop()) return c a = range(6) d = burninate(a) print a, d </code></pre> <p>Output: [0, 1, 2] [5, 4, 3]<br> Desired output: [0, 1, 2, 3, 4, 5] [5, 4, 3]</p> <p>Thanks!</p>
[ { "answer_id": 227802, "author": "mhawke", "author_id": 21945, "author_profile": "https://Stackoverflow.com/users/21945", "pm_score": 3, "selected": false, "text": "burninate()" }, { "answer_id": 227810, "author": "Greg Hewgill", "author_id": 893, "author_profile": "h...
2008/10/22
[ "https://Stackoverflow.com/questions/227790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5625/" ]
227,797
<p>In my cross-platform architecture, I would like to act on a context menu click (right button click) during a mouse click event. In Cocoa, can you detect that the user either Ctrl-Clicked or double-tapped on touchpad (right-click equivalent) DURING the mouseDown event? I am aware of NSView's menuForEvent but do not wish to handle it here.</p>
[ { "answer_id": 227816, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 5, "selected": true, "text": "-[NSResponder rightMouseDown:]" }, { "answer_id": 237156, "author": "Wil Shipley", "author_id": 30602, ...
2008/10/22
[ "https://Stackoverflow.com/questions/227797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8761/" ]
227,807
<p>I have a Rails app that sets a cookie and does a redirect to another server once the user is logged in. However, the cookie that the Rails app sets isn't seen by the server for some reason. I've tried setting http_only to false but I still can't even see the cookie unless the domain is the same as my Rails app. Here's the code I'm using to set the cookie:</p> <pre><code>cookies[:dev_appserver_login] = { :value =&gt; "#{email}:#{nick}:#{admin}:#{hsh}", :domain =&gt; "webserver-to-redirect-to", :expires =&gt; 30.days.from_now } redirect_to session[:dest_url] </code></pre> <p>If I manually create a cookie with the <a href="https://addons.mozilla.org/en-US/firefox/addon/60" rel="nofollow noreferrer">Web Developer extension</a> in Firefox it works fine, but not when Rails does it. Any ideas?</p>
[ { "answer_id": 24663350, "author": "Elocution Safari", "author_id": 43670, "author_profile": "https://Stackoverflow.com/users/43670", "pm_score": 0, "selected": false, "text": "127.0.0.1 app1.localdev.com, app2.localdev.com" } ]
2008/10/22
[ "https://Stackoverflow.com/questions/227807", "https://Stackoverflow.com", "https://Stackoverflow.com/users/422/" ]
227,820
<p>I was just writing some quick code and noticed this complier error </p> <blockquote> <p>Using the iteration variable in a lambda expression may have unexpected results.<br> Instead, create a local variable within the loop and assign it the value of the iteration variable.</p> </blockquote> <p>I know what it means and I can easily fix it, not a big deal.<br> But I was wondering why it is a bad idea to use a iteration variable in a lambda?<br> What problems can I cause later on?</p>
[ { "answer_id": 227833, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": true, "text": "List<Action> actions = new List<Action>();\n\nfor (int i = 0; i < 10; i++)\n{\n actions.Add(() => Console.WriteLine(i)...
2008/10/22
[ "https://Stackoverflow.com/questions/227820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6335/" ]
227,856
<p>It seems that the decision to make your objects fully cognizant of their roles within the system, and still avoid having too many dependencies within the domain model on the database, and service layers?</p> <p>For example: Say that I've got an entity with a revision history, and several "lookup tables" that the data references, your entity object should have methods to get the details from some of the lookup tables, whether by providing access to the lookup table rows, or by delegating methods down to them, but in order to do so it depends on the database layer to read the data from those rows. Also, when the entity is saved, It needs to know not only how to save itself, but also to save entries into the revision history. Is it necessary to pass references to dozens of different data layer objects and service objects to the model object? This seems like it makes the logic far more complex to understand than just passing back and forth thin models to service layer objects, but I've heard many "wise men" recommending this sort of structure.</p>
[ { "answer_id": 228001, "author": "moffdub", "author_id": 10759, "author_profile": "https://Stackoverflow.com/users/10759", "pm_score": 5, "selected": true, "text": "entity.saveIn(repository);\n" }, { "answer_id": 1890255, "author": "Steve", "author_id": 229889, "autho...
2008/10/22
[ "https://Stackoverflow.com/questions/227856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21973/" ]
227,886
<p>How do I determine the dependencies of a .NET application? Does <a href="http://www.dependencywalker.com/" rel="noreferrer">Dependency Walker</a> work with managed apps? I've downloaded the latest and tried profiling the app, but it just exits without much of an explanation. If it doesn't work with .NET, then is there some other tool that would help me debug a run-time DLL loading issue?</p>
[ { "answer_id": 308256, "author": "Patrick from NDepend team", "author_id": 27194, "author_profile": "https://Stackoverflow.com/users/27194", "pm_score": 4, "selected": false, "text": "from m in Methods \nlet depth = m.DepthOfIsUsing(\"NHibernate.NHibernateUtil.Entity(Type)\") \nwhere dep...
2008/10/22
[ "https://Stackoverflow.com/questions/227886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3114/" ]
227,897
<p>I just finished a test as part of a job interview, and one question stumped me, even using Google for reference. I'd like to see what the StackOverflow crew can do with it:</p> <blockquote> <p>The <code>memset_16aligned</code> function requires a 16-byte aligned pointer passed to it, or it will crash.</p> <p>a) How would you allocate 1024 bytes of memory, and align it to a 16 byte boundary?<br /> b) Free the memory after the <code>memset_16aligned</code> has executed.</p> </blockquote> <pre><code>{ void *mem; void *ptr; // answer a) here memset_16aligned(ptr, 0, 1024); // answer b) here } </code></pre>
[ { "answer_id": 227900, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 10, "selected": true, "text": "{\n void *mem = malloc(1024+16);\n void *ptr = ((char *)mem+16) & ~ 0x0F;\n memset_16aligned(ptr, 0, 102...
2008/10/22
[ "https://Stackoverflow.com/questions/227897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63/" ]
227,907
<p>I am trying to debug an ActiveResource call that is not working.</p> <p>What's the best way to view the HTTP response to the request ActiveResource is making?</p>
[ { "answer_id": 236378, "author": "Ian Terrell", "author_id": 9269, "author_profile": "https://Stackoverflow.com/users/9269", "pm_score": 3, "selected": true, "text": "puts response.inspect" }, { "answer_id": 237776, "author": "derfred", "author_id": 10286, "author_pro...
2008/10/22
[ "https://Stackoverflow.com/questions/227907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17965/" ]
227,909
<p>I could use some advice on tracking down the cause of memory leaks in C#. I understand what is a memory leak and I get why they occur in C# but I'm wondering what tools/strategies have you used in the past to resolve them?</p> <p>I am using .NET Memory Profiler and I've found that one of my huge main objects is staying in memory after I close the window it manages but I'm not sure what to do to severe all links to it.</p> <p>If I'm not being clear enough just post an answer with a question and I'll edit my question in response. Thanks!</p>
[ { "answer_id": 227966, "author": "Daniel Earwicker", "author_id": 27423, "author_profile": "https://Stackoverflow.com/users/27423", "pm_score": 5, "selected": false, "text": ".load C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\sos.dll\n" } ]
2008/10/22
[ "https://Stackoverflow.com/questions/227909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9401/" ]
227,924
<p>I can't see the 'Collection of Repositories" page after adding authentication and access rules to svn. 'guest' can navigate to mydomain.com/svn/public and admin can see both svn/public and svn/private, but none of the users can see /svn. </p> <p>Is it possible to have 'guest' access mydomain.com/svn and only see a /public link?</p> <p>Here's what I have setup...</p> <p><strong>subversion.conf:</strong></p> <pre><code>&lt;location /svn&gt; DAV svn SVNParentPath /home/subversion SVNListParentPath on AuthzSVNAccessFile /etc/svn-access-file AuthType Basic AuthName "Subversion Repository" AuthUserFile /etc/svn-auth-file Require valid-user &lt;/Location&gt; </code></pre> <p><strong>svn-access-file:</strong></p> <pre><code>[public:/] guest = r @admin = rw [private:/] @admin = rw [groups] admin = karl.r </code></pre> <p>Thanks.</p>
[ { "answer_id": 229104, "author": "remmelt", "author_id": 30709, "author_profile": "https://Stackoverflow.com/users/30709", "pm_score": 2, "selected": true, "text": "<Location /websvn>\n AuthType Basic\n AuthName \"Company WebSVN\"\n AuthUserFile /home/svn/dav_svn.passwd\n Require...
2008/10/22
[ "https://Stackoverflow.com/questions/227924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22934/" ]
227,928
<p>I'm building an open source project that uses python and c++ in Windows. I came to the following error message:</p> <pre><code> ImportError: No module named win32con </code></pre> <p>The same happened in a "prebuilt" code that it's working ( except in my computer :P ) </p> <p>I think this is kind of "popular" module in python because I've saw several messages in other forums but none that could help me.</p> <p>I have Python2.6, should I have that module already installed? Is that something of VC++?</p> <p>Thank you for the help.</p> <p>I got this url <a href="http://sourceforge.net/projects/pywin32/" rel="noreferrer">http://sourceforge.net/projects/pywin32/</a> but I'm not sure what to do with the executable :S</p>
[ { "answer_id": 39329641, "author": "anatoly techtonik", "author_id": 239247, "author_profile": "https://Stackoverflow.com/users/239247", "pm_score": 6, "selected": false, "text": "pip install pypiwin32\n" }, { "answer_id": 61448846, "author": "Thomas Ducrot", "author_id":...
2008/10/22
[ "https://Stackoverflow.com/questions/227928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20654/" ]
227,935
<p>In response to a rightMouse event I want to call a function that displays a context menu, runs it, and responds to the selected menu item. In Windows I can use TrackPopupMenu with the TPM_RETURNCMD flag.</p> <p>What is the easiest way to implement this in Cocoa? It seems NSMenu:popUpContextMenu wants to post an event to the specified NSView. Must I create a dummy view and wait for the event before returning? If so, how do I "wait" or flush events given I am not returning to my main ?</p>
[ { "answer_id": 227975, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 2, "selected": false, "text": "[NSView nextEventMatchingMask:]" }, { "answer_id": 228492, "author": "Peter Hosey", "author_id": 30461,...
2008/10/22
[ "https://Stackoverflow.com/questions/227935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8761/" ]
227,939
<p>We're using HAProxy as a load balancer at the moment, and it regularly makes requests to the downstream boxes to make sure they're alive using an OPTIONS request:</p> <blockquote> <p>OPTIONS /index.html HTTP/1.0</p> </blockquote> <p>I'm working with getting nginx set up as a reverse proxy with caching (using ncache). For some reason, nginx is returning a 405 when an OPTIONS request comes in:</p> <blockquote> <p>192.168.1.10 - - [22/Oct/2008:16:36:21 -0700] "OPTIONS /index.html HTTP/1.0" 405 325 "-" "-" 192.168.1.10</p> </blockquote> <p>When hitting the downstream webserver directly, I get a proper 200 response. My question is: how to you make nginx pass that response along to HAProxy, or, how can I set the response in the nginx.conf?</p>
[ { "answer_id": 4662858, "author": "Mark Rose", "author_id": 438631, "author_profile": "https://Stackoverflow.com/users/438631", "pm_score": 2, "selected": false, "text": "httpchk GET http://example.com/check.php\n" }, { "answer_id": 9197143, "author": "rogeriopvl", "autho...
2008/10/22
[ "https://Stackoverflow.com/questions/227939", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30575/" ]
227,950
<p>I need to compare 2 strings as equal such as these:</p> <blockquote> <p>Lubeck == Lübeck</p> </blockquote> <p>In JavaScript.</p> <p>Why? Well, I have an auto-completion field that's going out to a Java service using Lucene, where place names are stored naturally (as Lübeck), but also indexed as normalized text, </p> <pre><code>import sun.text.Normalizer; oDoc.setNameLC = Normalizer.normalize(oLocName, Normalizer.DECOMP, 0) .toLowerCase().replaceAll("[^\\p{ASCII}]",""); </code></pre> <p>This way some-one who doesn't know to type "Mèxico" can type "mexico" and get a match which returns "Mèxico" (among a lot of other possible hits, like "Café Mèxico, Dubai, UAE").</p> <p>Now the thing is I don't have the ability to change the service to do any highlighting on the server side, therefore I am highlighting on the client JavaScript side with something like:</p> <pre><code>return result.replace( input.replace(/[aeiou]/g,"."), "&lt;b&gt;$1&lt;/b&gt;"); </code></pre> <p>It's a little more fancy because I am escaping special regex characters in the input. This is fine for simple one word matches at the beginning of a hit, but it really breaks down if you suddenly wish to support multi-word matches like "london cafe":</p> <pre><code>input = input.strip().toLowerCase(); //fyi prototype's strip is like trim re = new RegEx(input.replace(/[aeiou]/g,".").replace(/\s+/g,"|"),"gi"); return result.replace(re, "&lt;b&gt;$1&lt;/b&gt;"); </code></pre> <p>This doesn't work for say "london ca" (was typing london cafe), because it would mark "Jack London Cabin, Dawson City, Canada" as: <code>"Ja&lt;b&gt;ck&lt;/b&gt; &lt;b&gt;London&lt;/b&gt; &lt;b&gt;ca&lt;/b&gt;bin, Dawson &lt;b&gt;Ci&lt;/b&gt;ty, &lt;b&gt;Ca&lt;b/&gt;nada"</code> [note the "ck" and "Ci" particularly]</p> <p>Therefore I'm sort of looking for something that's not as crazy as:</p> <pre><code>input = input.strip().toLowerCase(); input = input.replace(/a/g,"[ÀàÁáÂâÃãÄäÅ寿ĀāĂ㥹]"); input = input.replace(/e/g,"[ÈèÉéÊêËëĒēĔĕĖėĘęĚě]"); // ditto for i, o, u, y, c, n, maybe also d, g, h, j, k, l, r, s, t, w, z re = new RegEx(input.replace(/\s+/g,"|"),"gi"); return result.replace(re, "&lt;b&gt;$1&lt;/b&gt;"); </code></pre> <p>Is there a compiled table I can refer to mapping a range of characters which are accented versions of an other character to that character, by which I don't mean the plain unicode chart. And if so, could I avoid using weird, possibly slow, RegEx statements?</p> <p><em>About the bounty:</em><br> Before I started a bounty there were two answers, the one pointing me to doing it in Ruby, and <a href="https://stackoverflow.com/questions/227950/programatic-accent-reduction-in-javascript-aka-text-normalization-or-unaccenting/228006#228006">the one</a> that <a href="https://stackoverflow.com/users/22364/mizardx">MizzardX</a> wrote which was a completion of the basic form I'd put in my question. Now don't get me wrong, I really appreciate working it out as completely as he did, but I just wished that there might be another way. It seems so far that everyone who's dropped by to look at the question and answer has decided that MizzardX covers it just fine, or that they have no different approach. I would be interested in a different approach, and if it simply isn't available before the bounty closes, MizzardX will win the bounty (though in a cruel twist, his edits mad it a community wiki answer, so I'm not sure if he'll get the bounty!)</p>
[ { "answer_id": 228006, "author": "Markus Jarderot", "author_id": 22364, "author_profile": "https://Stackoverflow.com/users/22364", "pm_score": 7, "selected": true, "text": "/**\n * Creates a RegExp that matches the words in the search string.\n * Case and accent insensitive.\n */\nfuncti...
2008/10/22
[ "https://Stackoverflow.com/questions/227950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/459/" ]
227,973
<p>I've got an application that needs quite a bit of data (1000s of records) to do appropriate testing. The only way I've found to get a decent set of testable, sensible data is to use a <strong>subset of my production DB</strong>. I've converted this to YAML fixtures in the normal `test/fixtures' location.</p> <p>This works, but now I have a bunch of seemingly brittle tests and assertions that depend on their being a particular number of records that meet condition X...</p> <p>example</p> <pre><code>def test_children_association p = Parent.find(1) assert_equal 18, p.children.count, "Parent.children isn't providing the right records" end </code></pre> <p>This doesn't seem like a good idea to me, but <strong>I'm not sure if there is a better / accepted way</strong> to test an application that needs a large hierarchy of data.</p>
[ { "answer_id": 229188, "author": "derfred", "author_id": 10286, "author_profile": "https://Stackoverflow.com/users/10286", "pm_score": 0, "selected": false, "text": "def test_foo\n project = Project.create valid_project.merge(....)\n *do assertions here*\nend\n" }, { "answer_...
2008/10/22
[ "https://Stackoverflow.com/questions/227973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13216/" ]
227,977
<p>Is there a CSS style that IE7 and Firefox will obey that changes the behaviour of a TEXTAREA so that it behaves more like.... um..... more like the thing I'm typing into right now!</p>
[ { "answer_id": 227998, "author": "lewinski", "author_id": 30491, "author_profile": "https://Stackoverflow.com/users/30491", "pm_score": 0, "selected": false, "text": "<textarea wrap=\"soft\"></textarea>\n" }, { "answer_id": 228071, "author": "lock", "author_id": 24744, ...
2008/10/23
[ "https://Stackoverflow.com/questions/227977", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9328/" ]
227,984
<p>I have a JSP page that will display the exact content of another web page on a different server. My understanding was that c:import from the JSTL should be able to include content from files that are not part of the current web application.</p> <p>I added c:import url="page on my server in a different application" and it works fine, but when I try to include a page from another server it fails.</p> <p>Any suggestions as to what might be wrong?</p> <p><strong>EDIT:</strong> The exact error is: "The server encountered an internal error () that prevented it from fulfilling this request.". However, requesting a page from the same server, different app works...I get the content of the page.</p>
[ { "answer_id": 228240, "author": "Vladimir Dyuzhev", "author_id": 1163802, "author_profile": "https://Stackoverflow.com/users/1163802", "pm_score": 1, "selected": false, "text": "<%@ taglib prefix=\"c\" uri=\"http://java.sun.com/jstl/core\" %>\n...\n<c:import \n url=\"http://www.truenor...
2008/10/23
[ "https://Stackoverflow.com/questions/227984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27439/" ]
227,993
<p>I want to create a DTS Package to pull data from an Oracle table into a SQL2K table. How can I insert rows that are not already in the SQL2K table and update rows that already exist in the SQL2K table?</p> <p>I guess I could truncate and repopulate the entire table or create a temporary table and then do updates/inserts from the temp table into the destination table.</p> <p>Is there any easier way using DTS?</p> <p>Thanks,</p> <p>Rokal</p>
[ { "answer_id": 232976, "author": "Timothy Khouri", "author_id": 11917, "author_profile": "https://Stackoverflow.com/users/11917", "pm_score": 0, "selected": false, "text": "DELETE FROM dbo.WhateverTable \nWHERE WhateverTableID IN (SELECT WhateverTableID FROM MySource)\n" }, { "an...
2008/10/23
[ "https://Stackoverflow.com/questions/227993", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24358/" ]
227,994
<p>We have the following simple Stored Procedure that runs as an overnight SQL server agent job. Usually it runs in 20 minutes, but recently the MatchEvent and MatchResult tables have grown to over 9 million rows each. This has resulted in the store procedure taking over 2 hours to run, with all 8GB of memory on our SQL box being used up. This renders the database unavailable to the regular queries that are trying to access it.</p> <p>I assume the problem is that temp table is too large and is causing the memory and database unavailablity issues.</p> <p>How can I rewrite the stored procedure to make it more efficient and less memory intensive?</p> <p>Note: I have edited the SQL to indicate that there is come condition affecting the initial SELECT statement. I had previously left this out for simplicity. Also, when the query runs CPU usage is at 1-2%, but memoery, as previously stated, is maxed out</p> <p><pre><code> CREATE TABLE #tempMatchResult ( matchId VARCHAR(50) )</p> <p>INSERT INTO #tempMatchResult SELECT MatchId FROM MatchResult WHERE SOME_CONDITION</p> <p>DELETE FROM MatchEvent WHERE<br> MatchId IN (SELECT MatchId FROM #tempMatchResult)</p> <p>DELETE FROM MatchResult WHERE MatchId In (SELECT MatchId FROM #tempMatchResult)</p> <p>DROP TABLE #tempMatchResult </pre></code></p>
[ { "answer_id": 228003, "author": "shahkalpesh", "author_id": 23574, "author_profile": "https://Stackoverflow.com/users/23574", "pm_score": 0, "selected": false, "text": "\nDELETE FROM MatchEvent WHERE\nMatchId IN (SELECT MatchId FROM MatchResult)\n\n\nDELETE FROM MatchResult\n-- OR Trunc...
2008/10/23
[ "https://Stackoverflow.com/questions/227994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17765/" ]
228,005
<p>I was wondering if there was an alternative to <code>itoa()</code> for converting an integer to a string because when I run it in visual Studio I get warnings, and when I try to build my program under Linux, I get a compilation error.</p>
[ { "answer_id": 228010, "author": "Leon Timmermans", "author_id": 4727, "author_profile": "https://Stackoverflow.com/users/4727", "pm_score": 6, "selected": false, "text": "#include <boost/lexical_cast.hpp>\nint main(int argc, char** argv) {\n std::string foo = boost::lexical_cast<std:...
2008/10/23
[ "https://Stackoverflow.com/questions/228005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29326/" ]
228,025
<p>How do you insert/update a column through Linq To SQL and Linq To SQL use the default values? In particular I'm concerned with a timestamp field.</p> <p>I've tried setting that column to readonly and autogenerated, so it stopped trying to put in DateTime.MinValue, but it doesn't seem to be updating on updates.</p>
[ { "answer_id": 228080, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 3, "selected": true, "text": "public partial class YourDatabaseDataContext\n{\n partial void InsertYourTable(YourTable instance)\n {\n ...
2008/10/23
[ "https://Stackoverflow.com/questions/228025", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4050/" ]
228,036
<p>I have the following problem using template instantiation [*]. </p> <p>file <strong>foo.h</strong></p> <pre><code>class Foo { public: template &lt;typename F&gt; void func(F f) private: int member_; }; </code></pre> <p>file <strong>foo.cc</strong></p> <pre><code>template &lt;typename F&gt; Foo::func(F f) { f(member_); } </code></pre> <p>file <strong>caller.cc</strong></p> <pre><code>Foo::func(boost::bind(&amp;Bar::bar_func, bar_instance, _1)); </code></pre> <p>While this compiles fine, the linker complains about an undefined symbol:</p> <p><code>void Foo::func&lt;boost::_bi::bind_t...&gt;</code></p> <p>How can I instantiate the <em>function</em> <code>Foo::func</code>? Since it takes a function as argument, I am little bit confused. I tried to add an instantiation function in <strong>foo.cc</strong>, as I am used to with regular <em>non-function</em> types:</p> <pre><code>instantiate() { template&lt;&gt; void Foo::func&lt;boost::function&lt;void(int)&gt; &gt;(boost::function&lt;void(int)&gt;); } </code></pre> <p>Obviously, this does not work. I would appreciate if someone can point me in the right direction.</p> <p>Thanks!</p> <p>[*] Yes, I read the parashift FAQ lite.</p>
[ { "answer_id": 228370, "author": "Head Geek", "author_id": 12193, "author_profile": "https://Stackoverflow.com/users/12193", "pm_score": 1, "selected": false, "text": "#include" }, { "answer_id": 228372, "author": "SCFrench", "author_id": 4928, "author_profile": "http...
2008/10/23
[ "https://Stackoverflow.com/questions/228036", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1170277/" ]
228,038
<p>I've just had to write a string reverse function in C# 2.0 (i.e. LINQ not available) and came up with this:</p> <pre><code>public string Reverse(string text) { char[] cArray = text.ToCharArray(); string reverse = String.Empty; for (int i = cArray.Length - 1; i &gt; -1; i--) { reverse += cArray[i]; } return reverse; } </code></pre> <p>Personally I'm not crazy about the function and am convinced that there's a better way to do it. Is there?</p>
[ { "answer_id": 228055, "author": "Mike Thompson", "author_id": 2754, "author_profile": "https://Stackoverflow.com/users/2754", "pm_score": 4, "selected": false, "text": "string s = \"olleh\";\ns.Reverse();\n" }, { "answer_id": 228056, "author": "Greg Beech", "author_id": ...
2008/10/23
[ "https://Stackoverflow.com/questions/228038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
228,081
<p>I'm looking for ideas for a heap-manager to handle a very specific situation: Lots and lots of very small allocations, ranging from 12 to 64 bytes each. Anything bigger, I will pass on to the regular heap-manager, so only tiny blocks need be catered for. Only 4-byte alignment is needed.</p> <p>My main concerns are</p> <ol> <li>Overhead. The regular libc heap will typically round up an allocation to a multiple of 16 bytes, then add another 16 byte header - this means over 50% overhead on a 20-byte allocation, which sucks.</li> <li>Performance</li> </ol> <p>One helpful aspect is that Lua (which is the user of this heap) will tell you the size of the block it's freeing when it calls free() - this may enable certain optimisations.</p> <p>I'll post my current approach, which works ok, but I'd like to improve on it if at all possible. Any ideas?</p>
[ { "answer_id": 228132, "author": "hazzen", "author_id": 5066, "author_profile": "https://Stackoverflow.com/users/5066", "pm_score": 0, "selected": false, "text": "typedef struct _allocator {\n void* buffer;\n int start;\n int max;\n} allocator;\n\nvoid init_allocator(size_t size...
2008/10/23
[ "https://Stackoverflow.com/questions/228081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29539/" ]
228,102
<pre><code>&lt;div&gt; &lt;span&gt;left&lt;/span&gt; &lt;span&gt;right&lt;/span&gt; &lt;!-- new line break, so no more content on that line --&gt; &lt;table&gt; ... &lt;/table&gt; &lt;/div&gt; </code></pre> <p>How can I position those spans (they can be changed to any element) so that depending on how big the table is (not defined anywhere, and shouldn't be) the spans are positioned just on top of the left side of the table and the right side of the table.</p> <p>Example:</p> <pre> a b table0 table1 table2 </pre> <p>(where a is the left span, and b is the right span)</p> <p>P.S. You can change anything bar inner table html.</p>
[ { "answer_id": 228126, "author": "Rob Allen", "author_id": 149, "author_profile": "https://Stackoverflow.com/users/149", "pm_score": 3, "selected": false, "text": "<style type=\"text/css\">\n #wrapper, #top, #tableArea\n {\n width: 100%;\n padding: 10px;\n margin...
2008/10/23
[ "https://Stackoverflow.com/questions/228102", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
228,125
<p>I am after a regular expression that validates a percentage from 0 100 and allows two decimal places. </p> <p>Does anyone know how to do this or know of good web site that has example of common regular expressions used for client side validation in javascript?</p> <p>@Tom - Thanks for the questions. Ideally there would be no leading 0's or other trailing characters.</p> <p>Thanks to all those who have replied so far. I have found the comments really interesting.</p>
[ { "answer_id": 228152, "author": "Julien Grenier", "author_id": 23051, "author_profile": "https://Stackoverflow.com/users/23051", "pm_score": 0, "selected": false, "text": "(100|[0-9]{1,2})(\\.[0-9]{1,2})?" }, { "answer_id": 228158, "author": "Czimi", "author_id": 3906, ...
2008/10/23
[ "https://Stackoverflow.com/questions/228125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5360/" ]
228,134
<p>I like Steve Yegge's <a href="http://steve-yegge.blogspot.com/2008/10/universal-design-pattern.html" rel="noreferrer">Prototype Pattern example</a> and decided to whip up a quick proof of concept example.</p> <p>However, I didn't really think things through. While it is great for dynamically specifying the behaviour of objects and is an easy solution to Steve's <a href="http://steve.yegge.googlepages.com/when-polymorphism-fails" rel="noreferrer">opinionated elf</a> example, I'm still trying to work out the best way to handle instance variables.</p> <p>For instance, let's say I have an AwesomeDragon object. I then want to make an AwesomeDragonImmuneToFire object so I make a new child of the AwesomeDragon (AwesomeDragonImmuneToFire inherits properties from AwesomeDragon) and 'put' "ImmuneToFire" as a property with a value of 'true'. So far so good. Now let's say I want to send my AwesomeDragon object on a tour of nearby peasant villages. This will involve updating the 'position' property of AwesomeDragon. However, the moment I do this AwesomeDragonImmuneToFire will take off as well.</p> <p>Is the best solution to override instance values upon object creation e.g. immediately 'put' the 'position' value on AwesomeDragonImmuneToFire to the current 'get' value of 'position'?</p>
[ { "answer_id": 228232, "author": "Jonny Buchanan", "author_id": 6760, "author_profile": "https://Stackoverflow.com/users/6760", "pm_score": 4, "selected": true, "text": "prototype" } ]
2008/10/23
[ "https://Stackoverflow.com/questions/228134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/364/" ]
228,145
<p>I am progamatically creating a SharePoint site using </p> <pre><code>SPWeb spWeb = spSite.AllWebs.Add(...); </code></pre> <p>What code do I need run to set the spWeb to turn off the "Show pages in navigation" option?</p> <p><strong>Answer:</strong></p> <pre><code>publishingWeb.IncludePagesInNavigation = false; </code></pre>
[ { "answer_id": 228211, "author": "Brian Schmitt", "author_id": 30492, "author_profile": "https://Stackoverflow.com/users/30492", "pm_score": 4, "selected": true, "text": "publishingWeb.InheritGlobalNavigation = false;\n" } ]
2008/10/23
[ "https://Stackoverflow.com/questions/228145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13813/" ]
228,164
<p>The glorified global variable - becomes a gloried global class. Some say breaking object-oriented design.</p> <p>Give me scenarios, other than the good old logger where it makes sense to use the singleton.</p>
[ { "answer_id": 383919, "author": "Schwern", "author_id": 14660, "author_profile": "https://Stackoverflow.com/users/14660", "pm_score": 3, "selected": false, "text": "new()" }, { "answer_id": 4081829, "author": "Ozgur Zeren", "author_id": 495232, "author_profile": "htt...
2008/10/23
[ "https://Stackoverflow.com/questions/228164", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21537/" ]
228,165
<p>I stumbled across my rather ancient photo objects disks, and sadly found out the company (hemera) doesn't provide support for it anymore. this has left me with a whole pile of .hpi files. Luckily, I found <a href="http://www.halley.cc/ed/linux/interop/hemera.html" rel="nofollow noreferrer">this information</a> on extracting the jpg and png components of the file.</p> <p>Unfortunately, I haven't been able to get it to work. Can anyone figure out what's wrong with this code? I'd be happy with a PHP or Python solution if Perl isn't your thing. :)</p> <pre><code>open(I, "$name") || die; binmode(I); $_ = &lt;I&gt;; close(I); my ($j, $p) = m|^.{32}(.*)(\211PNG.*)$|s; open(J, "&gt;$name.jpg") &amp;&amp; do { binmode(J); print J $j; close J; }; open(P, "&gt;$name.png") &amp;&amp; do { binmode(P); print P $p; close P; }; </code></pre> <p>The hexdump of the current test file I snagged off a CD is here, if it helps at all:</p> <pre><code>0000000 89 48 50 49 0d 0a 1a 0a 64 00 00 00 20 00 00 00 0000010 45 89 00 00 65 89 00 00 0a 21 00 00 00 d0 d0 00 </code></pre>
[ { "answer_id": 228192, "author": "ypnos", "author_id": 21974, "author_profile": "https://Stackoverflow.com/users/21974", "pm_score": 3, "selected": true, "text": "#include <stdio.h>\n#include <stdlib.h>\n\n#define MAX_SIZE 1048576\n\nchar stuff[MAX_SIZE];\n\nint main (int argc, char **ar...
2008/10/23
[ "https://Stackoverflow.com/questions/228165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4853/" ]
228,175
<p>When using SubSonic, do you return the data as a dataset or do you put that in a strongly typed custom collection or a generic object?</p> <p>I ran through the subsonic project and for the four stored procs I have in my DB, it gave me a Sps.cs with 4 methods which return a StoredProcedure object.</p> <p>If you used a MVC, do you usually use the StoredProcedure object or wrap that around your business logic and return a dataset, list, collection or something else?</p> <p>Are datasets still the norm or is that replaced by something else?</p>
[ { "answer_id": 228190, "author": "John Sheehan", "author_id": 1786, "author_profile": "https://Stackoverflow.com/users/1786", "pm_score": 3, "selected": false, "text": "ProductCollection coll = new ProductCollection();\ncoll.LoadAndCloseReader(SPs.GetProducts(1).GetReader());\n" }, {...
2008/10/23
[ "https://Stackoverflow.com/questions/228175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
228,200
<p><code>%AX = (%AH + %AL)</code></p> <p>So why not <code>%EAX = (%SOME_REGISTER + %AX)</code> for some register <code>%SOME_REGISTER</code>? </p>
[ { "answer_id": 228367, "author": "Mike Thompson", "author_id": 2754, "author_profile": "https://Stackoverflow.com/users/2754", "pm_score": 8, "selected": true, "text": "8080/Z80 8086\nA AX\nBC BX\nDE CX\nHL DX\nIX SI \nIY DI\n" }, { ...
2008/10/23
[ "https://Stackoverflow.com/questions/228200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10432/" ]
228,205
<p>How do you handle update refresh rate from your worker function to your UI ?</p> <p>Sending everything to the UI or maybe using a timer (from which side ? worker or UI ?)</p>
[ { "answer_id": 228367, "author": "Mike Thompson", "author_id": 2754, "author_profile": "https://Stackoverflow.com/users/2754", "pm_score": 8, "selected": true, "text": "8080/Z80 8086\nA AX\nBC BX\nDE CX\nHL DX\nIX SI \nIY DI\n" }, { ...
2008/10/23
[ "https://Stackoverflow.com/questions/228205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2566/" ]
228,218
<p>I am very new to Java. My assignment is to create my own method and then create a class to test it in. My question, do I create the method separate of the class, or within the class? If it is separate of the class, how do I get the class to access my method?</p> <p>(Are they saved as two separate files?)</p> <p>This is what I have so far, but I am getting an error that I have to initialize KILOWATT in class DWindmill. I thought I did already in the method??? Any suggestions?</p> <pre><code>//This is the method Windmill import java.util.*; import static java.lang.Math.*; class DWindmill { public static void Windmill(){ //create the method for the Windmill class int miles = 50; //int miles = 200; //int miles = 250; int KILOWATT = (miles / 50);} static Scanner console = new Scanner(System.in); { System.out.println("Enter miles per hour:"); miles = console.nextInt(); Windmill(); System.out.println(+ KILOWATT + "kilowatts"); } } </code></pre>
[ { "answer_id": 228226, "author": "Dave Markle", "author_id": 24995, "author_profile": "https://Stackoverflow.com/users/24995", "pm_score": 2, "selected": false, "text": "public class MyClass {\n\n public static void Hello() {\n //This is your method!\n }\n\n public static void...
2008/10/23
[ "https://Stackoverflow.com/questions/228218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30606/" ]
228,220
<p>Let's say we have 2 php variables:</p> <ul> <li><strong>$name</strong> = 'caption';</li> <li><strong>$url</strong> = '<a href="http://domain.com/photo.jpg" rel="nofollow noreferrer">http://domain.com/photo.jpg</a>';</li> </ul> <p>The input string of <code>'{@url,&lt;img src="," alt="{@name}" /&gt;}'</code> should return:</p> <p><code>'&lt;img src="http://domain.com/photo.jpg" alt="caption" /&gt;'</code></p> <p>The <code>{tag}</code> takes up to 3 parameters: <code>{@variable[,text_before][,text_after]}</code>.</p> <p>What regex would be needed to make this happen? The tricky part is that a <code>{@..}</code> tag is nested within another.</p>
[ { "answer_id": 228307, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": -1, "selected": false, "text": "<p>Link: <a href=\"{@url}\">{@name}</a> - {@date}</p>" } ]
2008/10/23
[ "https://Stackoverflow.com/questions/228220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
228,221
<p>I know that I can insert multiple rows using a single statement, if I use the syntax in <a href="https://stackoverflow.com/questions/39576/best-way-to-do-multi-row-insert-in-oracle#39602">this answer</a>. </p> <p>However, one of the values I am inserting is taken from a sequence, i.e. </p> <pre><code>insert into TABLE_NAME (COL1,COL2) select MY_SEQ.nextval,'some value' from dual union all select MY_SEQ.nextval,'another value' from dual ; </code></pre> <p>If I try to run it, I get an ORA-02287 error. Is there any way around this, or should I just use a lot of INSERT statements?</p> <p>EDIT:<br> If I have to specify column names for all other columns other than the sequence, I lose the original brevity, so it's just not worth it. In that case I'll just use multiple INSERT statements.</p>
[ { "answer_id": 228294, "author": "WW.", "author_id": 14663, "author_profile": "https://Stackoverflow.com/users/14663", "pm_score": 6, "selected": true, "text": "insert into TABLE_NAME (COL1,COL2)\nselect my_seq.nextval, a\nfrom\n(SELECT 'SOME VALUE' as a FROM DUAL\n UNION ALL\n SELECT 'A...
2008/10/23
[ "https://Stackoverflow.com/questions/228221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3751/" ]
228,225
<p>Is it possible to prevent the browser from following redirects when sending XMLHttpRequest-s (i.e. to get the redirect status code back and handle it myself)?</p>
[ { "answer_id": 28411170, "author": "Roland Pihlakas", "author_id": 193017, "author_profile": "https://Stackoverflow.com/users/193017", "pm_score": 4, "selected": false, "text": "responseURL" }, { "answer_id": 33578947, "author": "user", "author_id": 3075942, "author_p...
2008/10/23
[ "https://Stackoverflow.com/questions/228225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30609/" ]
228,256
<p>Is there a good, up-to-date listing anywhere that maps User-Agent HTTP Header strings --> operating systems?</p>
[ { "answer_id": 228298, "author": "Dan Herbert", "author_id": 392, "author_profile": "https://Stackoverflow.com/users/392", "pm_score": 4, "selected": false, "text": "browser.php" }, { "answer_id": 261012, "author": "Osama Al-Maadeed", "author_id": 25544, "author_profi...
2008/10/23
[ "https://Stackoverflow.com/questions/228256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5682/" ]
228,265
<p>I'm hoping this question isn't too obscure <em>cross fingers</em></p> <p>I'm looking for a decent reference for <a href="http://netsuite.com" rel="noreferrer">netsuite</a> scripting and api (both of which are based on ASP)</p> <p>does anybody know where to find this stuff? The netsuite help pages are mediocre at best, and the forums aren't very active. (I suppose these two things are already bad signs, but it's worth a try right?)</p>
[ { "answer_id": 11965724, "author": "Web Developer", "author_id": 1600039, "author_profile": "https://Stackoverflow.com/users/1600039", "pm_score": 2, "selected": false, "text": "nlapiGetFieldValue();\nrecord.getFieldValue();\nrec.getValue();\n" } ]
2008/10/23
[ "https://Stackoverflow.com/questions/228265", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2908/" ]
228,268
<p><a href="http://blogs.msdn.com/drnick/archive/2007/03/23/preventing-anonymous-access.aspx" rel="noreferrer">http://blogs.msdn.com/drnick/archive/2007/03/23/preventing-anonymous-access.aspx</a> </p> <p>Can someone clarify whether it is possible to use wsHttpBinding in WCF and disable anonymous access in IIS without transport (ssl) or message security being required?</p>
[ { "answer_id": 265895, "author": "Tobias Hertkorn", "author_id": 33827, "author_profile": "https://Stackoverflow.com/users/33827", "pm_score": 2, "selected": false, "text": "public class TestService : ITestService\n{\n [PrincipalPermission(SecurityAction.Demand, Name = \"testdomain\\\\a...
2008/10/23
[ "https://Stackoverflow.com/questions/228268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25255/" ]
228,288
<p>Is it possible to subscribe to a Windows event that fires when Windows is going into or coming out of Sleep or Hibernate state?</p> <p>I need my application to be made aware when the computer is going to sleep to do some cleanup and avoid timing issues when it comes out of sleep.</p>
[ { "answer_id": 228405, "author": "Jeff Yates", "author_id": 23234, "author_profile": "https://Stackoverflow.com/users/23234", "pm_score": 5, "selected": true, "text": "Microsoft.Win32.SystemEvents.PowerModeChanged" }, { "answer_id": 31033210, "author": "Richard Chambers", ...
2008/10/23
[ "https://Stackoverflow.com/questions/228288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5982/" ]
228,300
<p>I need to recover form an error case where a file gets left in a locked state. How can I in c# tell this file to reset it's locks? I need to add to this the file is opened by a 3rd party dll and I don't actually have access to the file handle.</p>
[ { "answer_id": 228351, "author": "LizB", "author_id": 13616, "author_profile": "https://Stackoverflow.com/users/13616", "pm_score": 1, "selected": false, "text": " try {\n thirdPartyObj = new ThirdPartObj();\n // Some possible error causing object actions\n catch(Exception ex) {\n ...
2008/10/23
[ "https://Stackoverflow.com/questions/228300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22835/" ]
228,319
<p>I am using a navigation controller, and I have the style set to :</p> <pre><code>navController.navigationBar.barStyle = UIBarStyleBlackTranslucent; </code></pre> <p>But when I run my program, the navigation controller looks like it is on top of a white background, not my background. When I push a controller, left or right, all my view, the current one, shifts to the top exactly the size of the navigation bar. And it is there where I can see my background through the navigation controller bar. Any ideas? When my barStyle is set to opaque, everything looks fine. I was thinking on setting my view frame a negative 'y' value, but I think there should a more elegant way.</p>
[ { "answer_id": 2876401, "author": "Shizam", "author_id": 155513, "author_profile": "https://Stackoverflow.com/users/155513", "pm_score": 2, "selected": false, "text": " self.navigationController.navigationBar.tintColor = [UIColor blackColor];\n self.navigationController.navigationB...
2008/10/23
[ "https://Stackoverflow.com/questions/228319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29642/" ]
228,321
<p>On an embedded target I use far pointers to access some parts of the memory map. </p> <p>near pointer (without explicitely specifying __near):</p> <pre>unsigned int *VariableOnePtr;</pre> <p>Pointer to near pointer: <pre>unsigned int **VariableOnePtrPtr;</pre></p> <p>far pointer: <pre>unsigned int *__far VariableTwoPtr;</pre> </p> <p>What is the correct way to declare a pointer to a far pointer? Does this pointer have to be a far pointer itself?</p>
[ { "answer_id": 228331, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 4, "selected": true, "text": "unsigned int * __far *VariableThreePtrPtr;\n" }, { "answer_id": 228482, "author": "dmityugov", "author_id"...
2008/10/23
[ "https://Stackoverflow.com/questions/228321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2386/" ]
228,353
<p>A lambda expression which takes a function (of one argument) and a number, and applies the function to twice the number.</p>
[ { "answer_id": 228361, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 3, "selected": false, "text": "(lambda (f x) (f (* 2 x)))\n" }, { "answer_id": 228456, "author": "grettke", "author_id": 121526, "au...
2008/10/23
[ "https://Stackoverflow.com/questions/228353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30622/" ]
228,375
<p>How to get the path of the current csproject?</p> <p>Let's say I have a csproject name <code>MyProj.csproj</code>, inside there is a class that wants to know what is the file path of this csproj, any idea on how to do this? thanks.</p>
[ { "answer_id": 33606582, "author": "weiky", "author_id": 3346178, "author_profile": "https://Stackoverflow.com/users/3346178", "pm_score": 1, "selected": false, "text": "string solutionPath = @\"C:\\Users\\...\\PathToSolution\\MySolution.sln\";\nvar msWorkspace = MSBuildWorkspace.Create(...
2008/10/23
[ "https://Stackoverflow.com/questions/228375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3834/" ]