qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
405,480
<p>I have a Repeater contol bound to a custom object (an EntitySpaces query) and have noticed there are a couple of ways to conditionally format the values being displayed. </p> <p>1) From my aspx I can call a method in my code-behind and pass through the bound value and use that to drive any conditional logic:</p> <pre><code> &lt;a class="star" href="&lt;%#MakePackageSelectionUrl((int)DataBinder.Eval(Container.DataItem, "PackageId"))%&gt;"&gt; and then in the code-dehind: protected string MakePackageSelectionUrl(int packageId) { return string.Format("/Packages/NoAjax/ToggleStar.aspx?p={0}&amp;amp;s={1}&amp;amp;st={2}", packageId, _streamId, (int)_phase); } </code></pre> <p>2) I can hook into the ItemDataBound event, retrieve e.Item.DataItem as a DataRowView and then go crazy:</p> <pre><code> protected void PackageList_ItemDataBound(Object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType != ListItemType.Item &amp;&amp; e.Item.ItemType != ListItemType.AlternatingItem) { return; } DataRowView details = (DataRowView)e.Item.DataItem; EncodePackageName(e, details); EncodeStatusName(e); DisplayStarImage(e, details); } private static void EncodePackageName(RepeaterItemEventArgs e, DataRowView dr) { HtmlAnchor p = (HtmlAnchor)e.Item.FindControl("packageLink"); if (p != null) { p.HRef = string.Format("/Packages/View.aspx?p={0}", dr["packageId"]); p.InnerHtml = HttpUtility.HtmlEncode((string)dr["packageName"]); } } </code></pre> <p>I've also noticed that using e.Item.FindControl() in the code-behind requires runat="server" on the control in the aspx which has a nasty habit of encoding ids and generally messing up the HTML.</p> <p>I'm keen to hear from anyone that has come up with a nice approach for dealing with these sorts of issues.</p>
[ { "answer_id": 405755, "author": "Salamander2007", "author_id": 10629, "author_profile": "https://Stackoverflow.com/users/10629", "pm_score": 3, "selected": true, "text": "RowDataBound <asp:GridView ID=\"GridView1\" runat=\"server\" onrowdatabound=\"GridView1_RowDataBound\">\n</asp:GridV...
2009/01/01
[ "https://Stackoverflow.com/questions/405480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50623/" ]
405,489
<p>Is there a built-in function/operator I could use to unpack values from a dictionary and assign it into instance variables?</p> <p>This is what I intend to do:</p> <pre><code>c = MyClass() c.foo = 123 c.bar = 123 # c.foo == 123 and c.bar == 123 d = {'bar': 456} c.update(d) # c.foo == 123 and c.bar == 456 </code></pre> <p>Something akin to dictionary <code>update()</code> which load values from another dictionary but for plain object/class instance?</p>
[ { "answer_id": 405492, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 5, "selected": false, "text": "f.__dict__.update( b )\n" }, { "answer_id": 405498, "author": "hyperboreean", "author_id": 49032, "auth...
2009/01/01
[ "https://Stackoverflow.com/questions/405489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3055/" ]
405,508
<p>Kind of related to my <a href="https://stackoverflow.com/questions/405480/best-practices-when-applying-conditional-formatting-in-data-bound-controls">other question</a> - I've only ever used HTMLControls with runat="server" and WebControls grudgingly, preferring to have control over the markup that gets generated (including the ids of the elements, etc.).</p> <p>What's your suggestion for, say, iterating over the contents of a collection and generating a table or list without resorting to databinding or using Response.Write in a loop from the code-behind? I'm interested in the different approaches for creating clean, maintainable code.</p>
[ { "answer_id": 405538, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": true, "text": " <asp:Literal ID=\"ltrResults\" runat=\"server\" />\n" }, { "answer_id": 405584, "author": "Brownie", "author_i...
2009/01/01
[ "https://Stackoverflow.com/questions/405508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50623/" ]
405,509
<p>I am writing an application where one of the features is to allow the user to write an email template using Markdown syntax.</p> <p>Besides formatting, the user must be able to use placeholders for a couple of variables that would get replaced at runtime. </p> <p>The way this is currently working is very simple: the templates have the Pythonic %(var)s placeholders and I replace those with a dictionary before applying Markdown2 formatting.</p> <p>Turns out that the end user of this system will be a tech-savvy user and I wouldn't like to make it obvious to everyone that it's written in Python. </p> <p>It's not that I don't like Python... I actually think Python is the perfect tool for the job, I just don't want to expose that to the user (would like the same even if it were written in Java, Perl, Ruby or anything else).</p> <p>So I'd like to ask for insights on what would be, in your opinion, the best way to expose placeholders for the users:</p> <ol> <li><p>What do you think is the best placeholder format (thinks like ${var}, $(var) or #{var})?</p></li> <li><p>What would be the best way to replace those placeholders?</p></li> </ol> <p>I though of using a Regular Expression to change - for instance - ${var} into %(var)s and then applying the regular Python templating substitution, but I am not sure that's the best approach.</p> <p>If you go that way, it would be very nice if you could indicate me what is a draft of that regular expression as well.</p> <p>Thanks!</p> <p><strong>Update</strong>: An user pointed out using full-blown templating systems, but I think that may not be worth it, since all I need is placeholders substitution: I won't have loops or anything like that.</p> <p><strong>Final Update</strong>: I have chosen not to use any template engines at this time. I chose to go with the simpler string.Template approach (as pointed out on a comment by <a href="https://stackoverflow.com/users/49032/hyperboreean">hyperboreean</a>). Truth is that I don't like to pick a solution because sometime in the future there may be a need. I will keep all those suggestions on my sleeve, and if on the lifespan of the application there is a clear need for one or more features offered by them, I'll revisit the idea. Right now, I really think it's an overkill. Having full blown templates that <strong>the end user</strong> can edit as he wants is, at least on my point of view, more trouble than benefit. Nevertheless, it feels much nicer being aware of the reasons I did not went down that path, than just not researching anything and choosing it. </p> <p>Thanks a lot for all the input.</p>
[ { "answer_id": 406786, "author": "bobince", "author_id": 18936, "author_profile": "https://Stackoverflow.com/users/18936", "pm_score": 0, "selected": false, "text": "'fish{chips}'.format(chips= 'x')\n" } ]
2009/01/01
[ "https://Stackoverflow.com/questions/405509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14540/" ]
405,516
<p>Using Python 2.6, is there a way to check if all the items of a sequence equals a given value, in one statement?</p> <pre><code>[pseudocode] my_sequence = (2,5,7,82,35) if all the values in (type(i) for i in my_sequence) == int: do() </code></pre> <p>Instead of, say:</p> <pre><code>my_sequence = (2,5,7,82,35) all_int = True for i in my_sequence: if type(i) is not int: all_int = False break if all_int: do() </code></pre>
[ { "answer_id": 405519, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 4, "selected": false, "text": "all( type(i) is int for i in my_list )\n is" }, { "answer_id": 405520, "author": "Autoplectic", "author_id"...
2009/01/01
[ "https://Stackoverflow.com/questions/405516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44563/" ]
405,518
<p>I am writing unit tests for my presentation class in MVP pattern.But I am having trouble to write mock setup code. </p> <p>I have a presenter and when presenter's Load method called I want to test view should load class properties, table fields, data types,set presenter.... So When I have a different thing to do when presenter load always I have to add new expectation to test. And test is getting bigger every time.</p> <pre><code> [Test] public void When_Presenter_Loads_View_Should_Display_Selected_Class_Properties() { IList&lt;string&gt; dataTypes =new List&lt;string&gt;(); IClassGenerationView view = mockRepository.StrictMock&lt;IClassGenerationView&gt;(); tableRepository = mockRepository.Stub&lt;ITableRepository&gt;(); using(mockRepository.Record()) { SetupResult.For(tableRepository.GetDataTypes()).Return(dataTypes); view.Presenter = null; LastCall.IgnoreArguments(); view.DataTypes = dataTypes; view.Show(); view.ClassProperties = classProperties; view.TableName = "Table"; view.Table = table; LastCall.IgnoreArguments(); } using(mockRepository.Playback()) { ClassGenerationPresenter presenter = new ClassGenerationPresenter(view, clazz, tableRepository); presenter.Load(); } } </code></pre> <p>Is there a code smell in this code? How Can I improve or simplify this? </p>
[ { "answer_id": 406737, "author": "caltuntas", "author_id": 36474, "author_profile": "https://Stackoverflow.com/users/36474", "pm_score": 2, "selected": true, "text": "[TestFixture]\npublic class When_Presenter_Loads\n{\n private MockRepository mockRepository;\n private ITableReposi...
2009/01/01
[ "https://Stackoverflow.com/questions/405518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36474/" ]
405,526
<p>Does anybody know of a tool that allow me to inspect what files an installer just added to a system after it ran? </p> <p>Its sounds like this should be something that should exist.</p>
[ { "answer_id": 406737, "author": "caltuntas", "author_id": 36474, "author_profile": "https://Stackoverflow.com/users/36474", "pm_score": 2, "selected": true, "text": "[TestFixture]\npublic class When_Presenter_Loads\n{\n private MockRepository mockRepository;\n private ITableReposi...
2009/01/01
[ "https://Stackoverflow.com/questions/405526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9611/" ]
405,537
<p>I'm new to C, and am confused by results I'm getting when referencing a member of a struct via a pointer. See the following code for an example. What's happening when I reference tst->number the first time? What fundamental thing am I missing here?</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; typedef struct { int number; } Test; Test* Test_New(Test t,int number) { t.number = number; return &amp;t; } int main(int argc, char** argv) { Test test; Test *tst = Test_New(test,10); printf("Test.number = %d\n",tst-&gt;number); printf("Test.number = %d\n",tst-&gt;number); printf("Test.number = %d\n",tst-&gt;number); } </code></pre> <p>The output is:</p> <pre><code>Test.number = 10 Test.number = 4206602 Test.number = 4206602 </code></pre>
[ { "answer_id": 405561, "author": "jason", "author_id": 45914, "author_profile": "https://Stackoverflow.com/users/45914", "pm_score": 1, "selected": false, "text": "t Test_New test test Test_New Test t t.number test.number t.number number t t Test_New Test* Test_New(Test* t,int number) {\...
2009/01/01
[ "https://Stackoverflow.com/questions/405537", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50758/" ]
405,540
<p>I was just reading through <a href="http://books.google.com/books?id=1HxWGezDZcgC&amp;lpg=PP1&amp;dq=learning%20python&amp;pg=PA254#v=onepage&amp;q=cyclic&amp;f=false" rel="nofollow noreferrer">"Learning Python" by Mark Lutz and came across this code sample</a>:</p> <pre><code> >>> L = ['grail'] >>> L.append(L) >>> L ['grail', [...]] </code></pre> <p>It was identified as a cyclic data structure.</p> <p>So I was wondering, and here is my question:</p> <h2><strong>What is a 'cyclic data structure' used for in real life programming?</strong></h2> <p>There seems to be a little confusion, which i think stems from the very brief code sample... here's a few more lines using the same object L</p> <pre><code> >>> L[0] 'grail' >>> L[1][0] 'grail' >>> L[1][1][0] 'grail' </code></pre>
[ { "answer_id": 405564, "author": "Charlie Martin", "author_id": 35092, "author_profile": "https://Stackoverflow.com/users/35092", "pm_score": 5, "selected": true, "text": "V=[\"Boulder\", \"Denver\", \"Colorado Springs\", \"Pueblo\", \"Limon\"]\n E=[[\"Boulder\", \"Denver\"],\n [\"Denv...
2009/01/01
[ "https://Stackoverflow.com/questions/405540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2908/" ]
405,560
<p>When I build my c# solution the .tt files will not create the .cs file outputs. But if I right click the .tt files one at a time in solution explorer and select "Run Custom Tool" the .cs is generated, so the build tool setting is correct. What do I do to get the overall solution build to force the custom tool to run on the .tt files?</p>
[ { "answer_id": 33027217, "author": "Gyromite", "author_id": 2832598, "author_profile": "https://Stackoverflow.com/users/2832598", "pm_score": 0, "selected": false, "text": "<PropertyGroup>\n <!-- Get the Visual Studio version – defaults to 10: -->\n <VisualStudioVersion Condition=\"'$(...
2009/01/01
[ "https://Stackoverflow.com/questions/405560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28343/" ]
405,583
<p>I'm trying to write a query that updates rows in a table if a certain column has a value in a list I'm providing:</p> <pre><code>UPDATE MY_TABLE SET COL1 = 'xyz' WHERE COL2 IN ('x', 'y', 'z'); </code></pre> <p>I'm getting a syntax error, but I know that this should be possible. It's essentially a single command to execute the following 3 commands:</p> <pre><code>UPDATE MY_TABLE SET COL1 = 'xyz' WHERE COL2 = 'x'; UPDATE MY_TABLE SET COL1 = 'xyz' WHERE COL2 = 'y'; UPDATE MY_TABLE SET COL1 = 'xyz' WHERE COL2 = 'z'; </code></pre> <p>The values xyz are being set dynamically by the user, and there could be an arbitrary number of values (or I would just code it the long and awful way and be done with it. The only information I can find on the <em>IN</em> clause is concerned with subqueries. Can someone help me rewrite this query?</p> <p>Many thanks.</p>
[ { "answer_id": 405655, "author": "Toby Hede", "author_id": 14971, "author_profile": "https://Stackoverflow.com/users/14971", "pm_score": -1, "selected": false, "text": "UPDATE MY_TABLE SET COL1 = 'xyz' WHERE COL2 IN ('x, y, z');\n" }, { "answer_id": 405683, "author": "Bill Ka...
2009/01/01
[ "https://Stackoverflow.com/questions/405583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23249/" ]
405,588
<p>How would you model a turn-based game server as a RESTful API? For example, a chess server, where you could play a game of chess against another client of the same API. You would need some way of requesting and negotiating a game with the other client, and some way of playing the individual moves of the game.</p> <p>Is this a good candidate for a REST (RESTful) API? Or should this be modelled a different way?</p>
[ { "answer_id": 405605, "author": "Charlie Martin", "author_id": 35092, "author_profile": "https://Stackoverflow.com/users/35092", "pm_score": 3, "selected": true, "text": "/game\n/game/gameID/gamer/gamerID\n/game/gameID/board\n" }, { "answer_id": 405637, "author": "Charlie Ma...
2009/01/01
[ "https://Stackoverflow.com/questions/405588", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29173/" ]
405,612
<p>I'm going to start of by noting that I have next to no python experience.</p> <p><a href="http://www.aquate.us/u/9986423875612301299.jpg" rel="nofollow noreferrer">alt text http://www.aquate.us/u/9986423875612301299.jpg</a></p> <p>As you may know, by simply dropping a shortcut in the Send To folder on your Windows PC, you can allow a program to take a file as an argument.</p> <p>How would I write a python program that takes this file as an argument? </p> <p>And, as a bonus if anyone gets a chance -- How would I integrate that with a urllib2 to POST the file to a PHP script on my server?</p> <p>Thanks in advance.</p> <p>Edit-- also, how do I make something show up in the Sendto menu? I was under the impression that you just drop a shortcut into the SendTo folder and it automatically adds an option in the menu... Never mind. I figured out what I was doing wrong :)</p>
[ { "answer_id": 405625, "author": "Loïc Wolff", "author_id": 12008, "author_profile": "https://Stackoverflow.com/users/12008", "pm_score": 2, "selected": false, "text": "import sys\n\nfor arg in sys.argv:\n print arg\n" } ]
2009/01/01
[ "https://Stackoverflow.com/questions/405612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50548/" ]
405,617
<p>I'm having a small problem with a Python program (below) that I'm writing. </p> <p>I want to insert two values from a MySQL table into another table from a Python program.</p> <p>The two fields are priority and product and I have selected them from the shop table and I want to insert them into the products table. </p> <p>Can anyone help? Thanks a lot. Marc.</p> <pre><code>import MySQLdb def checkOut(): db = MySQLdb.connect(host='localhost', user = 'root', passwd = '$$', db = 'fillmyfridge') cursor = db.cursor(MySQLdb.cursors.DictCursor) user_input = raw_input('please enter the product barcode that you are taking out of the fridge: \n') cursor.execute('update shops set instock=0, howmanytoorder = howmanytoorder + 1 where barcode = %s', (user_input)) db.commit() cursor.execute('select product, priority from shop where barcode = %s', (user_input)) rows = cursor.fetchall() cursor.execute('insert into products(product, barcode, priority) values (%s, %s)', (rows["product"], user_input, rows["priority"])) db.commit() print 'the following product has been removed from the fridge and needs to be ordered' </code></pre>
[ { "answer_id": 405625, "author": "Loïc Wolff", "author_id": 12008, "author_profile": "https://Stackoverflow.com/users/12008", "pm_score": 2, "selected": false, "text": "import sys\n\nfor arg in sys.argv:\n print arg\n" } ]
2009/01/01
[ "https://Stackoverflow.com/questions/405617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47204/" ]
405,619
<p>How can you check whether a <strong>string</strong> is <strong>convertible</strong> to an <strong>int?</strong></p> <p>Let's say we have data like "House", "50", "Dog", "45.99", I want to know whether I should just use the <strong>string</strong> or use the parsed <strong>int</strong> value instead.</p> <p><em>In JavaScript we had this <a href="http://www.w3schools.com/jsref/jsref_parseInt.asp" rel="noreferrer">parseInt()</a> function. If the string <strong>couldn't be parsed</strong>, it would get back <strong>NaN</strong>.</em></p>
[ { "answer_id": 405633, "author": "Johnno Nolan", "author_id": 1116, "author_profile": "https://Stackoverflow.com/users/1116", "pm_score": 7, "selected": true, "text": "Int32.TryParse(String, Int32) bool result = Int32.TryParse(value, out number);\n if (result)\n {\n Console.Write...
2009/01/01
[ "https://Stackoverflow.com/questions/405619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41021/" ]
405,652
<p>I want to do something like this:</p> <pre><code>c:\data\&gt; python myscript.py *.csv </code></pre> <p>and pass all of the .csv files in the directory to my python script (such that <code>sys.argv</code> contains <code>["file1.csv", "file2.csv"]</code>, etc.) </p> <p>But <code>sys.argv</code> just receives <code>["*.csv"]</code> indicating that the wildcard was not expanded, so this doesn't work.</p> <p>I feel like there is a simple way to do this, but can't find it on Google. Any ideas?</p>
[ { "answer_id": 405662, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 6, "selected": true, "text": "from glob import glob\nfilelist = glob('*.csv') #You can pass the sys.argv argument\n" }, { "answer_id": 4056...
2009/01/01
[ "https://Stackoverflow.com/questions/405652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49559/" ]
405,684
<p>I am having trouble with PHP regarding encoding.</p> <p>I have a JavaScript/jQuery HTML5 page interact with my PHP script using $.post. However, PHP is facing a weird problem, probably related to encoding.</p> <p>When I write</p> <pre><code>htmlentities("í") </code></pre> <p>I expect PHP to output <code>&amp;iacute;</code>. However, instead it outputs <code>&amp;Atilde;&amp;shy;</code> At the beginning, I thought that I was making some mistake with the encodings, however</p> <pre><code>htmlentities("í")=="&amp;iacute;"?"Good":"Fail"; </code></pre> <p>is outputing "Fail", where</p> <pre><code>htmlentities("í")=="&amp;Atilde;&amp;shy;"?"Good":"Fail"; </code></pre> <p>But <code>htmlentities($search, null, "utf-8")</code> works as expected.</p> <p>I want to have PHP communicate with a MySQL server, but it has encoding problems too, even if I use utf8_encode. What should I do?</p> <p>EDIT: On the SQL command, writing</p> <pre><code>SELECT id,uid,type,value FROM users,profile WHERE uid=id AND type='name' AND value='XXX'; </code></pre> <p>where XXX contains no í chars, works as expected, but it does not if there is any 'í' char.</p> <pre><code>SET NAMES 'utf8'; SET CHARACTER SET 'utf8'; SELECT id,uid,type,value FROM users,profile WHERE uid=id AND type='name' AND value='XXX'; </code></pre> <p>Not only fails for í chars, but it ALSO fails for strings without any 'special' characters. Removing the ' chars from SET NAMES and SET CHARACTER SET doesn't seem to change anything.</p> <p>I am connecting to the MySQL database using PDO.</p> <p>EDIT 2: I am using MySQL version 5.1.30 of XAMPP for Linux.</p> <p>EDIT 3: Running <code>SHOW VARIABLES LIKE '%character%'</code> from PhpMyAdmin outputs</p> <pre><code>character_set_client utf8 character_set_connection utf8 character_set_database latin1 character_set_filesystem binary character_set_results utf8 character_set_server latin1 character_set_system utf8 character_sets_dir /opt/lampp/share/mysql/charsets/ </code></pre> <p>Running the same query from my PHP script(with print_r) outputs:</p> <pre><code>Array ( [0] =&gt; Array ( [Variable_name] =&gt; character_set_client [0] =&gt; character_set_client [Value] =&gt; latin1 [1] =&gt; latin1 ) [1] =&gt; Array ( [Variable_name] =&gt; character_set_connection [0] =&gt; character_set_connection [Value] =&gt; latin1 [1] =&gt; latin1 ) [2] =&gt; Array ( [Variable_name] =&gt; character_set_database [0] =&gt; character_set_database [Value] =&gt; latin1 [1] =&gt; latin1 ) [3] =&gt; Array ( [Variable_name] =&gt; character_set_filesystem [0] =&gt; character_set_filesystem [Value] =&gt; binary [1] =&gt; binary ) [4] =&gt; Array ( [Variable_name] =&gt; character_set_results [0] =&gt; character_set_results [Value] =&gt; latin1 [1] =&gt; latin1 ) [5] =&gt; Array ( [Variable_name] =&gt; character_set_server [0] =&gt; character_set_server [Value] =&gt; latin1 [1] =&gt; latin1 ) [6] =&gt; Array ( [Variable_name] =&gt; character_set_system [0] =&gt; character_set_system [Value] =&gt; utf8 [1] =&gt; utf8 ) [7] =&gt; Array ( [Variable_name] =&gt; character_sets_dir [0] =&gt; character_sets_dir [Value] =&gt; /opt/lampp/share/mysql/charsets/ [1] =&gt; /opt/lampp/share/mysql/charsets/ ) ) </code></pre> <p>Running</p> <pre><code>SET NAMES 'utf8'; SET CHARACTER SET 'utf8'; SHOW VARIABLES LIKE '%character%' </code></pre> <p>outputs an empty array.</p>
[ { "answer_id": 405691, "author": "Eran Galperin", "author_id": 10585, "author_profile": "https://Stackoverflow.com/users/10585", "pm_score": 4, "selected": false, "text": "htmlentities($text,ENT_COMPAT,'utf-8');\n SET NAMES utf8;\nSET CHARACTER SET utf8;\n [mysqld]\ncharacter-set-server ...
2009/01/01
[ "https://Stackoverflow.com/questions/405684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32775/" ]
405,690
<p>I'd like to know how to get <code>Subversion</code> to change the name that my changes appear under.</p> <p>I'm just starting to use <code>Subversion</code>. I'm currently using it to version control code on an XP laptop where I'm always logged in under my wife's name. I'd like the subversion DB to show the changes under my name.</p> <p>Later on I'll replicate the DB so it is accessible to the whole house. My wife uses the office computer where she is always logged in under my name. I'll probably set it up so that it automatically checks in modified documents... preferably under her name.</p> <p>Eventually I'll probably be using it from a linux machine under another username.</p> <p>Is there some way to modify the user environment to change the user name that Subversion calls you? I'd expect something like setting <code>SVN_USERNAME='Mark'</code> which would override however it usually gets the name.</p> <p><strong>Update:</strong> It looks like the <code>--username</code> flag that Michael referred to does work to change the name reported by <code>"svn stat"</code>, even for local file: repositories. In addition, it is sticky so you don't need to specify it for the next command. I even rebooted and it still used the <code>"--username"</code> value from my previous boot.</p>
[ { "answer_id": 405694, "author": "Michael Ratanapintha", "author_id": 1879, "author_profile": "https://Stackoverflow.com/users/1879", "pm_score": 9, "selected": true, "text": "--username svn checkout --username myuser file:///path/to/repo file://file-server/path/to/repo svn+ssh://server/...
2009/01/01
[ "https://Stackoverflow.com/questions/405690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4662/" ]
405,749
<p>Can anyone recommend a C or Objective-C library for HTML parsing? It needs to handle messy HTML code that won't quite validate.</p> <p>Does such a library exist, or am I better off just trying to use regular expressions?</p>
[ { "answer_id": 406111, "author": "Sophie Alpert", "author_id": 49485, "author_profile": "https://Stackoverflow.com/users/49485", "pm_score": 7, "selected": true, "text": "libxml2.2 libxml/HTMLparser.h" }, { "answer_id": 1618272, "author": "Albaregar", "author_id": 152793,...
2009/01/02
[ "https://Stackoverflow.com/questions/405749", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49485/" ]
405,761
<p>In statically typed functional programming languages, like Standard ML, F#, OCaml and Haskell, a function will usually be written with the parameters separated from each other and from the function name simply by whitespace:</p> <pre><code>let add a b = a + b </code></pre> <p>The type here being "<code>int -&gt; (int -&gt; int)</code>", i.e. a function that takes an int and returns a function which its turn takes and int and which finally returns an int. Thus currying becomes possible.</p> <p>It's also possible to define a similar function that takes a tuple as an argument:</p> <pre><code>let add(a, b) = a + b </code></pre> <p>The type becomes "<code>(int * int) -&gt; int</code>" in this case.</p> <p>From the point of view of language design, is there any reason why one could not simply identify these two type patterns in the type algebra? In other words, so that "(a * b) -> c" reduces to "a -> (b -> c)", allowing both variants to be curried with equal ease.</p> <p>I assume this question must have cropped up when languages like the four I mentioned were designed. So does anyone know any reason or research indicating why all four of these languages chose not to "unify" these two type patterns?</p>
[ { "answer_id": 405765, "author": "ShreevatsaR", "author_id": 4958, "author_profile": "https://Stackoverflow.com/users/4958", "pm_score": 2, "selected": false, "text": "Prelude> let add1 a b = a+b\nPrelude> let add2 (a,b) = a+b\nPrelude> :t (uncurry add1)\n(uncurry add1) :: (Num a) => (a,...
2009/01/02
[ "https://Stackoverflow.com/questions/405761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41489/" ]
405,770
<p>I always wonder why compilers can't figure out simple things that are obvious to the human eye. They do lots of simple optimizations, but never something even a little bit complex. For example, this code takes about 6 seconds on my computer to print the value zero (using java 1.6):</p> <pre class="lang-java prettyprint-override"><code>int x = 0; for (int i = 0; i &lt; 100 * 1000 * 1000 * 1000; ++i) { x += x + x + x + x + x; } </code></pre> <pre class="lang-java prettyprint-override"><code>System.out.println(x); </code></pre> <p>It is totally obvious that x is never changed so no matter how often you add 0 to itself it stays zero. So the compiler could in theory replace this with System.out.println(0).</p> <p>Or even better, this takes 23 seconds:</p> <pre class="lang-java prettyprint-override"><code>public int slow() { String s = &quot;x&quot;; for (int i = 0; i &lt; 100000; ++i) { s += &quot;x&quot;; } return 10; } </code></pre> <p>First the compiler could notice that I am actually creating a string s of 100000 &quot;x&quot; so it could automatically use s StringBuilder instead, or even better directly replace it with the resulting string as it is always the same. Second, It does not recognize that I do not actually use the string at all, so the whole loop could be discarded!</p> <p>Why, after so much manpower is going into fast compilers, are they still so relatively dumb?</p> <p><strong>EDIT</strong>: Of course these are stupid examples that should never be used anywhere. But whenever I have to rewrite a beautiful and very readable code into something unreadable so that the compiler is happy and produces fast code, I wonder why compilers or some other automated tool can't do this work for me.</p>
[ { "answer_id": 405784, "author": "Chris Bunch", "author_id": 422, "author_profile": "https://Stackoverflow.com/users/422", "pm_score": 3, "selected": false, "text": "if int x = 1;\nint y = 1;\nint z = x - y;\nfor (int i = 0; i < 100 * 1000 * 1000 * 1000; ++i) {\n z += z + z + z + z + ...
2009/01/02
[ "https://Stackoverflow.com/questions/405770", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48181/" ]
405,782
<p>I am updating some code from the old mysql_* functions to PDO. It connects without a problem, runs the query without a problem, but the resultset is empty. PDO::query() is supposed to return a PDOStatement object, yet I am getting true in return. No errors are reported.</p> <p>Here is my code:</p> <pre><code> try { $DB = new PDO("mysql:host=localhost;dbname=dbname", "user", "pass"); $stmt = $DB->prepare("SELECT * FROM report_clientinfo"); $stmt->execute(); }catch(PDOException $e) { echo $e->getMessage() . "\n"; } echo gettype($stmt) . "\n"; if ($stmt) echo "true\n"; else echo "false\n"; $resultset = $stmt->fetchAll(); if(empty($resultset)) { exit("ERROR: getClientInfo query failed."); } $DB = null; print_r($resultset); </code></pre> <p>The output I am seeing is:</p> <p>object true ERROR: getClientInfo query failed.</p> <p>Any ideas why it is not returning any results?</p>
[ { "answer_id": 405801, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 4, "selected": true, "text": "object \ntrue \nERROR: getClientInfo query failed.\n PDOStatement $stmt true true $stmt $stmt->execute() dbname $stmt...
2009/01/02
[ "https://Stackoverflow.com/questions/405782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47858/" ]
405,786
<p>I have a Joomla site which uses <code>mod_rewrite</code> to create pretty urls.</p> <pre><code>http://www.example.com/resources/newsletter </code></pre> <p>However this created a problem. Including images like this: <code>src="images/pic.jpg"</code>, it would then look for a file at:</p> <pre><code>http://www.example.com/resources/newsletter/images/pic.jpg </code></pre> <p>...which obviously doesn't exist. To work around this, I included a <code>&lt;base&gt;</code> tag in my <code>head</code> section:</p> <pre><code>&lt;base href="http://www.example.com/" /&gt; </code></pre> <p>...which worked fine, until I tried to do a link to an anchor point (bookmark) on the same page:</p> <pre><code>&lt;!-- on http://www.example.com/resources/newsletter --&gt; &lt;a href="#footer"&gt;go to the footer&lt;/a&gt; &lt;!-- clicking that link takes you to http://www.example.com/#footer --&gt; </code></pre> <p>Changing my links to be <code>&lt;a href="resources/newsletter/#footer"&gt;</code> is not feasible, since I won't necessarily know the URL of the page when editing it. Is there any way to make some links ignore the <code>&lt;base&gt;</code> directive?</p> <p>Though I'd really prefer a straight HTML solution, I'm using jQuery on this site already, so that could be an option if I'm stuck.</p>
[ { "answer_id": 405818, "author": "Sophie Alpert", "author_id": 49485, "author_profile": "https://Stackoverflow.com/users/49485", "pm_score": 2, "selected": false, "text": "src /images/pic.jpg $('a[@href^=\"#\"]').click(function() { \n var hash = this.hash, el = $(hash), offset;\n if(!e...
2009/01/02
[ "https://Stackoverflow.com/questions/405786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
405,795
<p>I have a somewhat complex query with roughly 100K rows.</p> <p>The query runs in 13 seconds in SQL Server Express (run on my dev box)</p> <p>The same query with the same indexing and tables takes over 15+ minutes to run on MySQL 5.1 (run on my production box - much more powerful and tested with 100% resources) And sometimes the query crashes the machine with an out of memory error.</p> <p>What am I doing wrong in MySQL? Why does it take so long?</p> <pre><code>select e8.* from table_a e8 inner join ( select max(e6.id) as id, e6.category, e6.entity, e6.service_date from ( select e4.* from table_a e4 inner join ( select max(e2.id) as id, e3.rank, e2.entity, e2.provider_id, e2.service_date from table_a e2 inner join ( select min(e1.rank) as rank, e1.entity, e1.provider_id, e1.service_date from table_a e1 where e1.site_id is not null group by e1.entity, e1.provider_id, e1.service_date ) as e3 on e2.rank= e3.rank and e2.entity = e3.entity and e2.provider_id = e3.provider_id and e2.service_date = e3.service_date and e2.rank= e3.rank group by e2.entity, e2.provider_id, e2.service_date, e3.rank ) e5 on e4.id = e5.id and e4.rank= e5.rank ) e6 group by e6.category, e6.entity, e6.service_date ) e7 on e8.id = e7.id and e7.category = e8.category </code></pre>
[ { "answer_id": 406854, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 3, "selected": true, "text": "WITH e3 AS (\nselect min(e1.rank) as rank,\ne1.entity,\ne1.provider_id,\ne1.service_date\nfrom table_a e1\nwhere e1.site_...
2009/01/02
[ "https://Stackoverflow.com/questions/405795", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36902/" ]
405,810
<p>Basically you have two ways for doing this:</p> <pre><code>for (int x = 0; x &lt; UPPER_X; x++) for (int y = 0; y &lt; UPPER_Y; y++) { arr1[x, y] = get_value(); arr2[y, x] = get_value(); } </code></pre> <p>The only difference is what variable to change in the inner loop: first or second. I heard that the results differ from language to language. </p> <p>What is right order for .NET?</p>
[ { "answer_id": 405825, "author": "Mitch Wheat", "author_id": 16076, "author_profile": "https://Stackoverflow.com/users/16076", "pm_score": 2, "selected": false, "text": "double[] myArray = new double[ROW_DIM * COLUMN_DIM];\n myArray[row * COLUMN_DIM + column];\n" }, { "answer_id"...
2009/01/02
[ "https://Stackoverflow.com/questions/405810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50727/" ]
405,812
<p>I am trying to use a hyperlinkbutton in silverlight to enable the user to download a word document. I don't care if a file save as box appears or if the word doc opens in a new browser. I get the error "cannot navigate to locations relative to a page." I've seen it posted that you can do this with the absolute path (www.domain.com/filename.doc) but there's got to be a way to make this relative (/docs/filename.doc). Anyone know how?</p>
[ { "answer_id": 407626, "author": "Michael S. Scherotter", "author_id": 27306, "author_profile": "https://Stackoverflow.com/users/27306", "pm_score": 3, "selected": true, "text": "uriCurrent = System.Windows.Browser.HtmlPage.Document.DocumentUri;\nstring current = uriCurrent.OriginalStrin...
2009/01/02
[ "https://Stackoverflow.com/questions/405812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5115/" ]
405,826
<p>My problem is thus: I need a way to ensure only one given class can instantiate another. I don't want to have to make the other a nested inner class or something dumb like that. How do I do this? I forget offhand.</p>
[ { "answer_id": 405838, "author": "tcurdt", "author_id": 33165, "author_profile": "https://Stackoverflow.com/users/33165", "pm_score": 3, "selected": false, "text": "public class Creator {\n private static class Created {\n }\n}\n public class Created {\n Created() {\n }\n}\n" }, ...
2009/01/02
[ "https://Stackoverflow.com/questions/405826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19825/" ]
405,842
<p>I am wondering if you use unset variables, empty strings (or 0's), or "None" to determine if a variable is "None"?</p> <p>The case I'm thinking of is, I'm retrieving something from the database, but find that the value is not set for the record, usually determined by the fact that there are no records or a null value. This will display to the user as "None" or "Not Set".</p> <p>So the question is, when passing this value to another part of the script (ie, another function, farter on the script, template, etc), do I:</p> <ul> <li>not set the variable (and therefore check if it's set in the template)</li> <li>set the variable to an empty string or 0 (and check for the empty string in the template)</li> <li>set the variable to "None" or "Not Set" and just echo the variable</li> </ul> <p>Is there one that you usually do and why do you do it?</p> <p>(I'm using PHP, so the type of the variable is somewhat unimportant.)</p> <p>I'm looking for a general answer; I know that it won't always be true, but a general rule to follow.</p>
[ { "answer_id": 405992, "author": "Bill Zeller", "author_id": 19234, "author_profile": "https://Stackoverflow.com/users/19234", "pm_score": 0, "selected": false, "text": "if($var === FALSE)\n ...\n" }, { "answer_id": 406017, "author": "strager", "author_id": 39992, ...
2009/01/02
[ "https://Stackoverflow.com/questions/405842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5441/" ]
405,897
<p>Using Zend_Form, how would I create form elements like this:</p> <pre><code>&lt;input type="text" name="element[1]" value="" /&gt; &lt;input type="text" name="element[2]" value="" /&gt; // etc... </code></pre>
[ { "answer_id": 406268, "author": "Stefan Gehrig", "author_id": 11354, "author_profile": "https://Stackoverflow.com/users/11354", "pm_score": 6, "selected": true, "text": "$form = new Zend_Form();\n\n$subForm = new Zend_Form_SubForm();\n$subForm->addElement('Text', '1')\n ->addElem...
2009/01/02
[ "https://Stackoverflow.com/questions/405897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3765/" ]
405,901
<p>I've created an ASP.Net user control that will get placed more than once inside of web page. In this control I've defined a javascript object such as:</p> <pre><code>function MyObject( options ) { this.x = options.x; } MyObject.prototype.someFunction=function someFunctionF() { return this.x + 1; } </code></pre> <p>In the code behind I've created MyObject in a startup script --</p> <pre><code>var opts = { x: 99 }; var myObject = new MyObject( opts ); </code></pre> <p>When a certain button in the control is pressed it will call myObject.someFunction(). Now lets say the value of x will be 99 for one control but 98 for another control. The problem here is that the var myObject will be repeated and only the last instance will matter. Surely there's a way to make the var myObject unique using some concept I've haven't run across yet. Ideas?</p> <p>Thanks,</p> <p>Craig</p>
[ { "answer_id": 406005, "author": "Luca Matteis", "author_id": 50394, "author_profile": "https://Stackoverflow.com/users/50394", "pm_score": 0, "selected": false, "text": "function MyObject( options ) { MyObject.x = options.x; }\nMyObject.x = 99; // static\nMyObject.prototype.someFunction...
2009/01/02
[ "https://Stackoverflow.com/questions/405901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20651/" ]
405,909
<p>Yes, another NULL vs empty string question.</p> <p>I agree with the idea that NULL means not set, while empty string means "a value that is empty". Here's my problem: If the default value for a column is NULL, how do I allow the user to enter that NULL.</p> <p>Let's say a new user is created on a system. There is a first and last name field; last name is required while first name is not. When creating the user, the person will see 2 text inputs, one for first and one for last. The person chooses to only enter the last name. The first name is technically not set. During the insert I check the length of each field, setting all fields that are empty to NULL.</p> <p>When looking at the database, I see that the first name is not set. The question that immediately comes to mind is that maybe they never saw the first name field (ie, because of an error). But this is not the case; they left if blank.</p> <p>So, my question is, how do you decide when a field should be set to NULL or an empty string when receiving user input? How do you know that the user wants the field to be not set without detecting focus or if they deleted a value...or...or...?</p> <p>Related Question: <a href="https://stackoverflow.com/questions/167952/null-or-empty-string-to-represent-no-data-in-table-column">Should I use NULL or an empty string to represent no data in table column?</a></p>
[ { "answer_id": 405921, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": false, "text": "name is null name is null or name = ''" }, { "answer_id": 48976803, "author": "Titanium Creative", "aut...
2009/01/02
[ "https://Stackoverflow.com/questions/405909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5441/" ]
405,910
<p>I have a query to insert a row into a table, which has a field called ID, which is populated using an AUTO_INCREMENT on the column. I need to get this value for the next bit of functionality, but when I run the following, it always returns 0 even though the actual value is not 0:</p> <pre><code>MySqlCommand comm = connect.CreateCommand(); comm.CommandText = insertInvoice; comm.CommandText += "\'" + invoiceDate.ToString("yyyy:MM:dd hh:mm:ss") + "\', " + bookFee + ", " + adminFee + ", " + totalFee + ", " + customerID + ")"; int id = Convert.ToInt32(comm.ExecuteScalar()); </code></pre> <p>According to my understanding, this should return the ID column, but it just returns 0 every time. Any ideas?</p> <p><strong>EDIT:</strong></p> <p>When I run:</p> <pre><code>"INSERT INTO INVOICE (INVOICE_DATE, BOOK_FEE, ADMIN_FEE, TOTAL_FEE, CUSTOMER_ID) VALUES ('2009:01:01 10:21:12', 50, 7, 57, 2134);last_insert_id();" </code></pre> <p>I get:</p> <pre><code>{"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'last_insert_id()' at line 1"} </code></pre>
[ { "answer_id": 405922, "author": "Michael Haren", "author_id": 29, "author_profile": "https://Stackoverflow.com/users/29", "pm_score": 6, "selected": true, "text": "select last_insert_id(); MySqlCommand comm = connect.CreateCommand();\ncomm.CommandText = insertInvoice;\ncomm.CommandText ...
2009/01/02
[ "https://Stackoverflow.com/questions/405910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23249/" ]
405,935
<p>Why doesn't a textbox stretch to fill space in a stackpanel? Is this by design? In a grid, the textbox stretches as expected. </p>
[ { "answer_id": 406287, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 4, "selected": false, "text": "StackPanel TextBox TextBox" } ]
2009/01/02
[ "https://Stackoverflow.com/questions/405935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40568/" ]
405,944
<p>With CPUs being increasingly faster, hard disks spinning, bits flying around so quickly, network speeds increasing as well, it's not that simple to tell bad code from good code like it used to be.</p> <p>I remember a time when you could optimize a piece of code and undeniably perceive an improvement in performance. Those days are almost over. Instead, I guess we now have a set of rules that we follow like "Don't declare variables inside loops" etc. It's great to adhere to these so that you write good code by default. But how do you know it can't be improved even further without some tool?</p> <p>Some may argue that a couple of nanoseconds won't really make that big a difference these days. The truth is, we are stuck with so many layers that you get a staggering effect.</p> <p>I'm not saying we should optimize every little millisecond out of our code as that will be expensive and unfeasible. I believe we have to do our best, given our time constraints, to write efficient code as well.</p> <p><strong>I'm just interested to know what tools you use to profile and measure performance of code, if at all.</strong></p>
[ { "answer_id": 406013, "author": "Norman Ramsey", "author_id": 41661, "author_profile": "https://Stackoverflow.com/users/41661", "pm_score": 0, "selected": false, "text": "gprof valgrind kcachegrind" } ]
2009/01/02
[ "https://Stackoverflow.com/questions/405944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10644/" ]
405,950
<p>If there is a REST resource that I want to monitor for changes or modifications from other clients, what is the best (and most RESTful) way of doing so?</p> <p>One idea I've had for doing so is by providing specific resources that will keep the connection open rather than returning immediately if the resource does not (yet) exist. For example, given the resource:</p> <pre><code>/game/17/playerToMove </code></pre> <p>a "GET" on this resource might tell me that it's my opponent's turn to move. Rather than continually polling this resource to find out when it's my turn to move, I might note the move number (say 5) and attempt to retrieve the next move:</p> <pre><code>/game/17/move/5 </code></pre> <p>In a "normal" REST model, it seems a GET request for this URL would return a 404 (not found) error. However, if instead, the server kept the connection open until my opponent played his move, i.e.:</p> <pre><code>PUT /game/17/move/5 </code></pre> <p>then the server could return the contents that my opponent PUT into that resource. This would both provide me with the data I need, as well as a sort of notification for when my opponent has moved without requiring polling.</p> <p>Is this sort of scheme RESTful? Or does it violate some sort of REST principle?</p>
[ { "answer_id": 406037, "author": "dbr", "author_id": 745, "author_profile": "https://Stackoverflow.com/users/745", "pm_score": 6, "selected": true, "text": "/game/17/move/5 /game/17/move/5 move/6/ twisted" } ]
2009/01/02
[ "https://Stackoverflow.com/questions/405950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29173/" ]
405,967
<p>The WPF <code>TextBox</code> natively makes use of the System Highlight color for painting the background of selected text. I would like to override this and make it consistent since it varies by OS/user theme.</p> <p>For <code>ListBoxItem</code>s, there is a <a href="http://blogs.msdn.com/wpfsdk/archive/2007/08/31/specifying-the-selection-color-content-alignment-and-background-color-for-items-in-a-listbox.aspx" rel="nofollow noreferrer">neat trick</a> (see below) where you can override the resource key for the <code>HighlightBrushKey</code> to customize the System Highlight color in a focused setting:</p> <pre><code>&lt;Style TargetType=&quot;ListBoxItem&quot;&gt; &lt;Style.Resources&gt; &lt;SolidColorBrush x:Key=&quot;{x:Static SystemColors.HighlightBrushKey}&quot; Color=&quot;LightGreen&quot;/&gt; &lt;/Style.Resources&gt; &lt;/Style&gt; </code></pre> <p>The same trick does not work for the <code>TextBox</code> unfortunately. Does anyone have any other ideas, besides &quot;override the <code>ControlTemplate</code>&quot;?</p> <p><a href="http://blogs.msdn.com/llobo/archive/2009/10/27/new-wpf-features-caretbrush-selectionbrush.aspx" rel="nofollow noreferrer">NOTE: This behavior appears to be added to WPF 4.</a></p>
[ { "answer_id": 406328, "author": "Jobi Joy", "author_id": 8091, "author_profile": "https://Stackoverflow.com/users/8091", "pm_score": -1, "selected": false, "text": "<Style x:Key=\"{x:Type TextBox}\" TargetType=\"{x:Type TextBox}\">\n" }, { "answer_id": 19119533, "author": "C...
2009/01/02
[ "https://Stackoverflow.com/questions/405967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41693/" ]
405,995
<p>Could you, please, give a code snippet showing how to use Lua embedded in OCaml?</p> <p>A simple example could be a &quot;Hello, World&quot; variant. Have OCaml prompt the user for a name. Then pass that name to a Lua function. Have Lua print a greeting and return the length of the name. Then have OCaml print a message about the length of the name.</p> <p>Example:</p> <blockquote> <p>user@desktop:~$ <b><i>./hello.opt</i></b></p> <p>Name? <b><i>User</i></b></p> <p>Hello, User.</p> <p>Your name is 4 letters long.</p> <p>user@desktop:~$</p> </blockquote> <p><b>[Edit]</b></p> <p>As a non-C programmer, could I implement this without having to write an intermediary C program to pass the data between Lua and OCaml?</p> <p>Following is a theoretical idea of what I would like to try. Unfortunately, line 3 of ocaml_hello.ml would need to know how to call the function defined in lua_hello.lua in order for the code to be valid.</p> <p><b>lua_hello.lua</b> Defines lua_hello, which prints an argument and returns its length.</p> <pre><code>1 function lua_hello (name) 2 print (&quot;Hello, &quot;..name..&quot;.&quot;) 3 return (string.len (name)) 4 end </code></pre> <p><b>ocaml_hello.ml</b> OCaml prompts for a name, calls the Lua function, and prints the return value.</p> <pre><code>1 let () = print_string &quot;Name? &quot;; flush stdout in 2 let name = input_line stdin in 3 let len = Lua_hello.lua_hello name in 4 Printf.printf &quot;Your name is %d letters long.&quot; len; flush stdout;; </code></pre>
[ { "answer_id": 406036, "author": "Norman Ramsey", "author_id": 41661, "author_profile": "https://Stackoverflow.com/users/41661", "pm_score": 4, "selected": true, "text": "let lua = Lua.new() (* create Lua interpreter *)\nlet chunk = LuaL.loadfile lua \"hello.lua\" (* load and compile th...
2009/01/02
[ "https://Stackoverflow.com/questions/405995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50797/" ]
406,010
<p>There is a pointer-to-an-Array of Arrays i.e. NameList in the code. I want the contents of each of the Arrays in the Pointer(NameList) to get printed one by one. The below code is not able do the task. Pls. help.</p> <pre><code>int Data1[] = {10,10}; int Data2[] = {20,20}; int Data3[] = {30,30}; int *NameList[] = {Data1, Data2, Data3}; main() { Function(NameList); } Function(int *ArrayPointer) { int i, j, index=0; for (i=0; i &lt; 3; i++) { for (j=0; j &lt; 2; j++) { //It does not print the data printf("\nName: %s", ArrayPointer[index++]); } index=0; //Counter reset to 0 ArrayPointer++; //Pointer is incremented by one to pick next array in the pointer } } print("code sample"); </code></pre> <p>Another note from the original poster of the question:</p> <p>I have completed a pacman game in Turbo C. I was polishing some graphics routines so that it can be reused again easily. This is only a small sample created for the purpose of help and understanding the concept. All data in the code actually are char arrays for sprites. Now i simply want to call a function passing the pointer so that each arrays in the pointer are drawn to the screen. How can this code be modified to handle this? Im actually stuck up here.</p>
[ { "answer_id": 406032, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 0, "selected": false, "text": "int Data1[]\n int *\n int *NameList[]\n int **\n Function(int **ArrayPointer)\n void int main() { ... }\nvoid Function() {...
2009/01/02
[ "https://Stackoverflow.com/questions/406010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
406,016
<p>I am crafting an application and cannot decide whether to use the terms <strong>Login/out</strong> or <strong>Logon/off</strong>. Is there a <em>more correct</em> option between these two? Should I use something else entirely (like "Sign on/off").</p> <p>In terms of usability, as long as I am consistent it probably doesn't matter which terms I choose, but I did wonder about the origins of the terms - and whether one or another makes more grammatical sense. I also care deeply about the application I am creating, and want to take the time to investigate all aspects of its user experience.</p>
[ { "answer_id": 406035, "author": "Adam Liss", "author_id": 29157, "author_profile": "https://Stackoverflow.com/users/29157", "pm_score": 9, "selected": true, "text": "\"Please enter your login credentials.\"\n\"I see three logons but only two logoffs from this user.\"\n \"Please log in t...
2009/01/02
[ "https://Stackoverflow.com/questions/406016", "https://Stackoverflow.com", "https://Stackoverflow.com/users/708/" ]
406,020
<p>I use the following code to create countdowns in Javascript. n is the number of times to repeat, freq is the number of milliseconds to wait before executing, funN is a function to call on each iteration (typically a function that updates part of the DOM) and funDone is the function to call when the countdown is complete. </p> <pre><code>function timer(n, freq, funN, funDone) { if(n == 0){ funDone(); }else{ setTimeout(function(){funN(n-1); timer(n-1, freq, funN, funDone);}, freq); } } </code></pre> <p>It can be called like so:</p> <pre><code> timer(10, 1000, /* 1 second */ function(n){console.log("(A) Counting: "+n);}, function() {console.log("(A) Done!");} ); timer(10, 500, function(n){console.log("(B) Counting: "+n);}, function() {console.log("(B) Done!");} ); </code></pre> <p>The advantage of this is that I can call timer() as many times as I want without worrying about global variables etc. Is there a better way to do this? Is there a clean way to make setInterval stop after a certain number of calls (without using global variables)? This code also creates a new lambda function with each call to setTimeout which seems like it could be problematic for large countdowns (I'm not sure how javascript's garbage collector handles this). </p> <p>Is there a better way to do this? Thanks.</p>
[ { "answer_id": 406056, "author": "BenAlabaster", "author_id": 40650, "author_profile": "https://Stackoverflow.com/users/40650", "pm_score": 3, "selected": true, "text": "TimedIteration = function(interval, iterations, methodToRun, completedMethod){\n\n var counter = iterations;\n var t...
2009/01/02
[ "https://Stackoverflow.com/questions/406020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19234/" ]
406,030
<p>I am working on a web project where I need to use WebDataGrid of Infragistics controls and customise the header layout. I did not find event like InitializeLayout in UltraWebGrid. My problem is that i want to row in header. What do I do?</p>
[ { "answer_id": 406042, "author": "deadbug", "author_id": 4646, "author_profile": "https://Stackoverflow.com/users/4646", "pm_score": 0, "selected": false, "text": "e.Layout.Bands[0].Columns.FromKey(<data field>).Header...\n" }, { "answer_id": 10107383, "author": "Radoslav Min...
2009/01/02
[ "https://Stackoverflow.com/questions/406030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
406,038
<p>I am just starting to use "Subversion" with "Tortoise SVN client" for one of my opensource project which is hosted on "Google Code". I would like to get some best practices on using it. I am following the default folder structure(trunk,branch,tag). Following are the questions</p> <ol> <li>When will you do the initial checkin? Is it only after finished a set of features or from the first day of development? </li> <li>To which directory the initial checkin goes? Is it into "trunk" or you checkin to "branch" and merge to "trunk" once a feature is complete. In this case "trunk" will be empty until the feature is done.</li> <li>When ever changes are made, will you checkin to "trunk" directly? If not your working copy will be always using "branch" directory, right? </li> </ol> <p>Any help would be appreciated.</p>
[ { "answer_id": 406153, "author": "Todd Smith", "author_id": 31624, "author_profile": "https://Stackoverflow.com/users/31624", "pm_score": 0, "selected": false, "text": "/svn/users/me/project1\n /svn/project1/trunk\n" } ]
2009/01/02
[ "https://Stackoverflow.com/questions/406038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50419/" ]
406,043
<p>What does it mean by POD type?cv-qualified?</p>
[ { "answer_id": 406050, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 3, "selected": false, "text": "// non cv_qualified\nint one; \nchar *two; \n\n// cv-qualified \nconst int three; \nvolatile char * four; \n st...
2009/01/02
[ "https://Stackoverflow.com/questions/406043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22076/" ]
406,045
<p>If you are doing something like the following:</p> <pre><code>var i = $('input[@name=some_field]'); if (i.val() != '' &amp;&amp; !(i.val() &gt;=1 &amp;&amp; i.val() &lt;= 36) || i.val() == 'OT')) { i.focus(); } </code></pre> <p>is <code>i.val()</code> fast enough to use it multiple times or should you do:</p> <pre><code>var value = i.val(); </code></pre> <p>first and then use value in the if statement, like:</p> <pre><code>var i = $('input[@name=some_field]'); var value = i.val(); if (value != '' &amp;&amp; !(value &gt;=1 &amp;&amp; value &lt;= 36) || value == 'OT')) { i.focus(); } </code></pre> <p>...?</p>
[ { "answer_id": 406051, "author": "jb.", "author_id": 37522, "author_profile": "https://Stackoverflow.com/users/37522", "pm_score": 1, "selected": false, "text": "val val val" } ]
2009/01/02
[ "https://Stackoverflow.com/questions/406045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5441/" ]
406,053
<p>When referencing class variables, why do people prepend it with <code>this</code>? I'm not talking about the case when <code>this</code> is used to disambiguate from method parameters, but rather when it seems unnecessary.</p> <p>Example:</p> <pre><code>public class Person { private String name; public String toString() { return this.name; } } </code></pre> <p>In <code>toString</code>, why not just reference <code>name</code> as <code>name</code>?</p> <pre><code>return name; </code></pre> <p>What does <code>this.name</code> buy?</p> <p><a href="https://stackoverflow.com/questions/404278/java-calendar-time-minute-is-wrong">Here's</a> a stackoverflow question whose code has <code>this</code> pre-pending.</p>
[ { "answer_id": 406064, "author": "Daniel Spiewak", "author_id": 9815, "author_profile": "https://Stackoverflow.com/users/9815", "pm_score": 5, "selected": false, "text": "public void setFoo(Bar foo) {\n this.foo = foo;\n}\n this.blah" }, { "answer_id": 406066, "author": "G...
2009/01/02
[ "https://Stackoverflow.com/questions/406053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24396/" ]
406,076
<p>Is there any way to have a 'Resizable' panel in GWT.</p> <p>By resizable I mean that if you you drag on the edge of Panel it can be resized accordingly.</p>
[ { "answer_id": 409099, "author": "Ratn Deo--Dev", "author_id": 15476, "author_profile": "https://Stackoverflow.com/users/15476", "pm_score": 4, "selected": true, "text": "public class DraggablePanel extends VerticalPanel {\n private boolean isBeingDragged = false;\n private boolean...
2009/01/02
[ "https://Stackoverflow.com/questions/406076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15476/" ]
406,081
<p>Is it a good concept to use multiple inheritance or can I do other things instead?</p>
[ { "answer_id": 406095, "author": "billybob", "author_id": 49464, "author_profile": "https://Stackoverflow.com/users/49464", "pm_score": 5, "selected": false, "text": "class GrandParent;\nclass Parent1 : public GrandParent;\nclass Parent2 : public GrandParent;\nclass Child : public Parent...
2009/01/02
[ "https://Stackoverflow.com/questions/406081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50754/" ]
406,097
<p>There's a lot of capital C, capital S computer science going into Javascript via the Tracemonkey, Squirrelfish, and V8 projects. Do any of these projects (or others) address the performance of DOM operations, or are they purely Javascript computation related?</p>
[ { "answer_id": 406323, "author": "olliej", "author_id": 784, "author_profile": "https://Stackoverflow.com/users/784", "pm_score": 5, "selected": true, "text": "a*b a b a=Math.floor(0.5) a=(Math.floor == realFloor) ? inline : Math.floor(0.5) a.x * a.y\n a.x a.y a a.x a.y" } ]
2009/01/02
[ "https://Stackoverflow.com/questions/406097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4668/" ]
406,121
<p>Is there a simple way to flatten a list of iterables with a list comprehension, or failing that, what would you all consider to be the best way to flatten a shallow list like this, balancing performance and readability?</p> <p>I tried to flatten such a list with a nested list comprehension, like this:</p> <pre><code>[image for image in menuitem for menuitem in list_of_menuitems] </code></pre> <p>But I get in trouble of the <code>NameError</code> variety there, because the <code>name 'menuitem' is not defined</code>. After googling and looking around on Stack Overflow, I got the desired results with a <code>reduce</code> statement:</p> <pre><code>reduce(list.__add__, map(lambda x: list(x), list_of_menuitems)) </code></pre> <p>But this method is fairly unreadable because I need that <code>list(x)</code> call there because x is a Django <code>QuerySet</code> object.</p> <p><strong>Conclusion</strong>: </p> <p>Thanks to everyone who contributed to this question. Here is a summary of what I learned. I'm also making this a community wiki in case others want to add to or correct these observations.</p> <p>My original reduce statement is redundant and is better written this way:</p> <pre><code>&gt;&gt;&gt; reduce(list.__add__, (list(mi) for mi in list_of_menuitems)) </code></pre> <p>This is the correct syntax for a nested list comprehension (Brilliant summary <a href="https://stackoverflow.com/users/3002/df">dF</a>!):</p> <pre><code>&gt;&gt;&gt; [image for mi in list_of_menuitems for image in mi] </code></pre> <p>But neither of these methods are as efficient as using <code>itertools.chain</code>:</p> <pre><code>&gt;&gt;&gt; from itertools import chain &gt;&gt;&gt; list(chain(*list_of_menuitems)) </code></pre> <p>And as @cdleary notes, it's probably better style to avoid * operator magic by using <code>chain.from_iterable</code> like so:</p> <pre><code>&gt;&gt;&gt; chain = itertools.chain.from_iterable([[1,2],[3],[5,89],[],[6]]) &gt;&gt;&gt; print(list(chain)) &gt;&gt;&gt; [1, 2, 3, 5, 89, 6] </code></pre>
[ { "answer_id": 406141, "author": "recursive", "author_id": 44743, "author_profile": "https://Stackoverflow.com/users/44743", "pm_score": 3, "selected": false, "text": "reduce(list.__add__, map(list, [mi.image_set.all() for mi in list_of_menuitems]))\n reduce(list.__add__, [list(mi.image_...
2009/01/02
[ "https://Stackoverflow.com/questions/406121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27462/" ]
406,133
<p>I'm trying to configure an installer for some software we use within the company.</p> <p>The installer is pushed out to target machines via SMS, and it performs the following steps:</p> <ol> <li>Terminate any currently running instances of the app (the app is a utility, so this isn't an impact on the user).</li> <li>Remove the previous version.</li> <li>Install the updated version.</li> </ol> <p>What we want it to do is launch the installed executable (as the currently logged in user, not the system account which the SMS job runs as) once step 3 is completed.</p> <p>I've tried adding a custom action as follows:</p> <pre><code>&lt;CustomAction Id="Relaunch" Impersonate="yes" Return="asyncNoWait" FileKey="AppExeFile" Execute="commit" ExeCommand="acm" /&gt; </code></pre> <p>And in the <code>InstallExecuteSequence</code> element I have the following:</p> <pre><code>&lt;Custom Action="Relaunch" OnExit="success" /&gt; </code></pre> <p>However when we try this, either as a SMS job or executing as an administrator nothing happens (e.g. the app isn't relaunched).</p> <p>Any suggestions?</p>
[ { "answer_id": 406141, "author": "recursive", "author_id": 44743, "author_profile": "https://Stackoverflow.com/users/44743", "pm_score": 3, "selected": false, "text": "reduce(list.__add__, map(list, [mi.image_set.all() for mi in list_of_menuitems]))\n reduce(list.__add__, [list(mi.image_...
2009/01/02
[ "https://Stackoverflow.com/questions/406133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18434/" ]
406,155
<p>I am using SVN for development tasks, but still have many files managed with RCS, because it does not seem reasonable to edit them in my private SVN repository working copy (since they're often just configuration files that are also best tested in-place). It also doesn't seem reasonable to have a working copy of the repository wherever there are files to put under SVN control, so I just use RCS instead.</p> <p>What is your approach for managing files that should ideally not be moved around / are edited and tested in-place?</p> <p>To be more precise: I'd like to have the equivalent of</p> <ul> <li>having a write-protected file.txt</li> <li>a command like "co -l file.txt" (RCS) to make it editable</li> <li>the ability to edit it in place and test it immediately</li> <li>a command like "ci -u file.txt" (RCS) to record the change, add a comment and make it read-only again</li> <li>other users should also be able to do this in the same place</li> <li>but, the version info should go to a safe place (the svn rep presumably), on a different server</li> </ul>
[ { "answer_id": 409034, "author": "Adam Byrtek", "author_id": 36656, "author_profile": "https://Stackoverflow.com/users/36656", "pm_score": 2, "selected": false, "text": "cd ~/directory\nhg init\n cd ~/directory\ngit init\ngit add .\n .svn /etc" } ]
2009/01/02
[ "https://Stackoverflow.com/questions/406155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2128202/" ]
406,161
<p>Am working on web based Job search application using Lucene.User on my site can search for jobs which are within a radius of 100 miles from say "Boston,MA" or any other location. Also, I need to show the search results sorted by "relevance"(ie. Score returned by lucene) in descending order.</p> <p>I'm using a 3rd party API to fetch all the cities within given radius of a city.This API returns me around 864 cities within 100 miles radius of "Boston,MA".</p> <p>I'm building the city/state Lucene query using the following logic which is part of my "BuildNearestCitiesQuery" method. Here nearestCities is a hashtable returned by the above API.It contains 864 cities with CityName ass key and StateCode as value. And finalQuery is a Lucene BooleanQuery object which contains other search criteria entered by the user like:skills,keywords,etc.</p> <pre><code>foreach (string city in nearestCities.Keys) { BooleanQuery tempFinalQuery = finalQuery; cityStateQuery = new BooleanQuery(); queryCity = queryParserCity.Parse(city); queryState = queryParserState.Parse(((string[])nearestCities[city])[1]); cityStateQuery.Add(queryCity, BooleanClause.Occur.MUST); //must is like an AND cityStateQuery.Add(queryState, BooleanClause.Occur.MUST); } nearestCityQuery.Add(cityStateQuery, BooleanClause.Occur.SHOULD); //should is like an OR finalQuery.Add(nearestCityQuery, BooleanClause.Occur.MUST); </code></pre> <p>I then input finalQuery object to Lucene's Search method to get all the jobs within 100 miles radius.:</p> <pre><code>searcher.Search(finalQuery, collector); </code></pre> <p>I found out this BuildNearestCitiesQuery method takes a whopping 29 seconds on an average to execute which obviously is unacceptable by any standards of a website.I also found out that the statements involving "Parse" take a considerable amount of time to execute as compared to other statements.</p> <p>A job for a given location is a dynamic attribute in the sense that a city could have 2 jobs(meeting a particular search criteria) today,but zero job for the same search criteria after 3 days.So,I cannot use any "Caching" over here.</p> <p>Is there any way I can optimize this logic?or for that matter my whole approach/algorithm towards finding all jobs within 100 miles using Lucene?</p> <p>FYI,here is how my indexing in Lucene looks like:</p> <pre><code>doc.Add(new Field("jobId", job.JobID.ToString().Trim(), Field.Store.YES, Field.Index.UN_TOKENIZED)); doc.Add(new Field("title", job.JobTitle.Trim(), Field.Store.YES, Field.Index.TOKENIZED)); doc.Add(new Field("description", job.JobDescription.Trim(), Field.Store.NO, Field.Index.TOKENIZED)); doc.Add(new Field("city", job.City.Trim(), Field.Store.YES, Field.Index.TOKENIZED , Field.TermVector.YES)); doc.Add(new Field("state", job.StateCode.Trim(), Field.Store.YES, Field.Index.TOKENIZED, Field.TermVector.YES)); doc.Add(new Field("citystate", job.City.Trim() + ", " + job.StateCode.Trim(), Field.Store.YES, Field.Index.UN_TOKENIZED , Field.TermVector.YES)); doc.Add(new Field("datePosted", jobPostedDateTime, Field.Store.YES, Field.Index.UN_TOKENIZED)); doc.Add(new Field("company", job.HiringCoName.Trim(), Field.Store.YES, Field.Index.TOKENIZED)); doc.Add(new Field("jobType", job.JobTypeID.ToString(), Field.Store.NO, Field.Index.UN_TOKENIZED,Field.TermVector.YES)); doc.Add(new Field("sector", job.SectorID.ToString(), Field.Store.NO, Field.Index.UN_TOKENIZED, Field.TermVector.YES)); doc.Add(new Field("showAllJobs", "yy", Field.Store.NO, Field.Index.UN_TOKENIZED)); </code></pre> <p>Thanks a ton for reading!I would really appreciate your help on this.</p> <p>Janis</p>
[ { "answer_id": 406846, "author": "James Brady", "author_id": 29903, "author_profile": "https://Stackoverflow.com/users/29903", "pm_score": 0, "selected": false, "text": "tempFinalQuery Parse" }, { "answer_id": 1050513, "author": "Anirvan", "author_id": 31100, "author_...
2009/01/02
[ "https://Stackoverflow.com/questions/406161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40907/" ]
406,179
<p>I need to write a small program that can detect that it has been changed. Please give me a suggestion!</p> <p>Thank you.</p>
[ { "answer_id": 406271, "author": "wilhelmtell", "author_id": 456, "author_profile": "https://Stackoverflow.com/users/456", "pm_score": 0, "selected": false, "text": "#!/bin/bash\ncat $0\n" } ]
2009/01/02
[ "https://Stackoverflow.com/questions/406179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50819/" ]
406,192
<p>I am using jQuery. How do I get the path of the current URL and assign it to a variable?</p> <p>Example URL:</p> <pre><code>http://localhost/menuname.de?foo=bar&amp;amp;number=0 </code></pre>
[ { "answer_id": 406200, "author": "clawr", "author_id": 46201, "author_profile": "https://Stackoverflow.com/users/46201", "pm_score": 6, "selected": false, "text": "window.location" }, { "answer_id": 406208, "author": "Ryan Doherty", "author_id": 956, "author_profile":...
2009/01/02
[ "https://Stackoverflow.com/questions/406192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44984/" ]
406,207
<p>I am developing a web application. When I build the application I can see the statement "Build Succeeded" in status bar even the syntax of object declaration is wrong in a aspx.cs file. I cleaned the solution again I tried to rebuild the application. But I did not get any error. If I am adding any block of code in that page it is not executing in run time.</p>
[ { "answer_id": 406217, "author": "icelava", "author_id": 2663, "author_profile": "https://Stackoverflow.com/users/2663", "pm_score": 0, "selected": false, "text": "<%@ Page Language=\"C#\" AutoEventWireup=\"true\" CodeFile=\"I_AM_MODIFYING_THIS_PAGE.aspx.cs\" Inherits=\"I_AM_MODIFYING_T...
2009/01/02
[ "https://Stackoverflow.com/questions/406207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
406,210
<p>A long time ago I had the following directory structure in my SVN repository</p> <pre><code>trunk/ data/ levels/ 1.level 2.level ... ... ... </code></pre> <p>But I deleted the 'levels' directory long ago. Now I want to add a single text file called 'levels' to the 'data' directory, so it will look like this:</p> <pre><code>trunk/ data/ levels ... ... </code></pre> <p>Now when I try to add the file 'levels', I get this message:</p> <pre><code>$ svn add data/levels svn: Can't replace 'data/levels' with a node of a differing type; the deletion m ust be committed and the parent updated before adding 'data/levels' </code></pre> <p>How can I solve this?</p>
[ { "answer_id": 406214, "author": "Lily Ballard", "author_id": 582, "author_profile": "https://Stackoverflow.com/users/582", "pm_score": 4, "selected": true, "text": "svn update svn status" }, { "answer_id": 413869, "author": "matpie", "author_id": 51021, "author_profi...
2009/01/02
[ "https://Stackoverflow.com/questions/406210", "https://Stackoverflow.com", "https://Stackoverflow.com/users/813/" ]
406,212
<p>How would one modify the following snippet (in a tableView:cellForRowAtIndexPath: UITableViewController method) from the "09a - PrefsTable" recipe from Chapter 6 of The iPhone Developer's Cookbook:</p> <pre><code>if (row == 1) { // Create a big word-wrapped UILabel cell = [tableView dequeueReusableCellWithIdentifier:@"libertyCell"]; if (!cell) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"libertyCell"] autorelease]; [cell addSubview:[[UILabel alloc] initWithFrame:CGRectMake(20.0f, 10.0f, 280.0f, 330.0f)]]; } UILabel *sv = [[cell subviews] lastObject]; sv.text =  @"When in the Course of human events, it becomes necessary for one people to dissolve the political bands which have connected them with another, and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation."; sv.textAlignment = UITextAlignmentCenter; sv.lineBreakMode = UILineBreakModeWordWrap; sv.numberOfLines = 9999; return cell; } </code></pre> <p>...to size the "sv" UILabel subview and the "cell" UITableViewCell to be sized just big enough to fit the text (and work with more or less text, and other types of text alignment)?  I looked at the UILabel textRectForBounds:limitedToNumberOfLines: method, but the documentation states that it should not be called directly (and should only be overridden).  I experimented with the UIView sizeToFit method, without success.</p> <p><strong>Update:</strong> <a href="https://stackoverflow.com/questions/419222/how-do-i-get-nsstrings-sizewithfontforwidthlinebreakmode-method-from-the-ip">I asked a new question about my problem with the NSString -sizeWithFont:forWidth:lineBreakMode: method</a>.</p>
[ { "answer_id": 406216, "author": "Lily Ballard", "author_id": 582, "author_profile": "https://Stackoverflow.com/users/582", "pm_score": 4, "selected": false, "text": "-sizeWithFont:forWidth:lineBreakMode:" }, { "answer_id": 406219, "author": "Sophie Alpert", "author_id": ...
2009/01/02
[ "https://Stackoverflow.com/questions/406212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4766/" ]
406,226
<p>I can't find the documentation for the NSString sizeWithFont:forWidth:lineBreakMode: method (see <a href="https://stackoverflow.com/users/582/kevin-ballard">Kevin Ballard</a>'s answer to "<a href="https://stackoverflow.com/questions/406212/sizing-a-uilabel-in-the-iphone-sdk-to-fit">Sizing a UILabel (in the iPhone SDK) to fit?</a>") in the NSString Class Reference in the iPhone SDK Developer Documentation. Where should I look?</p> <p><strong>Update</strong>: I hadn't subscribed to an iPhone OS Library doc set, so my search didn't work.</p>
[ { "answer_id": 406231, "author": "Athena", "author_id": 17846, "author_profile": "https://Stackoverflow.com/users/17846", "pm_score": 4, "selected": true, "text": "sizeWithFont:forWidth:lineBreakMode:" } ]
2009/01/02
[ "https://Stackoverflow.com/questions/406226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4766/" ]
406,230
<p>I know it's possible to match a word and then reverse the matches using other tools (e.g. <code>grep -v</code>). However, is it possible to match lines that do not contain a specific word, e.g. <code>hede</code>, using a regular expression?</p> <h5>Input:</h5> <pre><code>hoho hihi haha hede </code></pre> <h5>Code:</h5> <pre><code>grep &quot;&lt;Regex for 'doesn't contain hede'&gt;&quot; input </code></pre> <h5>Desired output:</h5> <pre><code>hoho hihi haha </code></pre>
[ { "answer_id": 406243, "author": "Athena", "author_id": 17846, "author_profile": "https://Stackoverflow.com/users/17846", "pm_score": 8, "selected": false, "text": "grep -v hede grep -v" }, { "answer_id": 406408, "author": "Bart Kiers", "author_id": 50476, "author_pro...
2009/01/02
[ "https://Stackoverflow.com/questions/406230", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36830/" ]
406,247
<p>OSGi has a problem with split packages, i.e. same package but hosted in multiple bundles.</p> <p>Are there any edge cases that split packages might pose problems in plain java (without OSGi) ?</p> <p>Just curious.</p>
[ { "answer_id": 406617, "author": "Tom Hawtin - tackline", "author_id": 4725, "author_profile": "https://Stackoverflow.com/users/4725", "pm_score": 2, "selected": false, "text": "\"Sealed: true\"" }, { "answer_id": 882319, "author": "Steve Powell", "author_id": 57171, ...
2009/01/02
[ "https://Stackoverflow.com/questions/406247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24457/" ]
406,249
<p>I'm working on an IPhone application that works with a Google App Engine application. I manage to get logged by using a google account and I get the authentication token. I'm also able to GET data from the GAE service (I did it after reading another question written here) but now I need to POST data so I need to send the authentication token in the header of the POST request. I tried several options but none of them worked. </p> <p>Here is the code I use to put that auth into the header:</p> <pre><code>NSString* urlStr = [NSString stringWithFormat:@"%@%@", HOST, url]; NSMutableURLRequest* urlPost = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlStr]]; NSString* authStr = [NSString stringWithFormat:@"GoogleLogin auth=%@", token]; [urlPost addValue:authStr forHTTPHeaderField:@"Authorization"]; </code></pre> <p>but it doesn't work.</p> <p>Any help?</p>
[ { "answer_id": 406733, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 2, "selected": false, "text": "[request setHTTPMethod: @\"POST\"] [request setHTTPBody: postdata]" } ]
2009/01/02
[ "https://Stackoverflow.com/questions/406249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
406,252
<p>A workmate floated the idea of using rake as a build system for a non-ruby project. Is it possible to extend rake to compliment other languages where the autoconf toolset would usually be used?</p>
[ { "answer_id": 422071, "author": "rkj", "author_id": 37086, "author_profile": "https://Stackoverflow.com/users/37086", "pm_score": 1, "selected": false, "text": "<target name=\"custom_task\">\n <exec executable=\"/usr/bin/env\">\n <arg value=\"rake\"/>\n <arg value=\"som...
2009/01/02
[ "https://Stackoverflow.com/questions/406252", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9532/" ]
406,253
<p>I have tried one where clause in Linq to get details about <code>User</code>s those who are <code>Active</code> and <code>AllowLogin</code> is also true.</p> <p>So how can I compare the table values (both are boolean values) with true or false?</p>
[ { "answer_id": 406261, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": false, "text": "var query = from user in context.Users\n where user.Active && user.AllowLogin\n select user;\n var...
2009/01/02
[ "https://Stackoverflow.com/questions/406253", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
406,258
<p>According to the Perl source code page on CPAN, 5.8.9 is now 14 days old, and will be the last 5.8 release. 5.10.0 is over a year old and presumably ready for use in Production.</p> <p>Leaving aside discussion of Perl 6 for now, can I ask what versions of Perl folks are testing, rolling out and using in production? We have currently standardized on 5.8.8 on our Ubuntu (workstation) and Solaris (production) platforms, and I'm wondering about the pros and cons of making small step to 5.8.9 or a larger one to 5.10.0.</p>
[ { "answer_id": 408617, "author": "Brad Gilbert", "author_id": 1337, "author_profile": "https://Stackoverflow.com/users/1337", "pm_score": 1, "selected": false, "text": "Perl 5.10 Perl6" }, { "answer_id": 409837, "author": "Schwern", "author_id": 14660, "author_profile...
2009/01/02
[ "https://Stackoverflow.com/questions/406258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45284/" ]
406,288
<p>I recently started working in Java and was introduced to the wild and crazy world of getters and setters for everything. I hated it at first, but quickly got used to it. Too used to it.</p> <p>I have been spending a lot of time lately thinking more about class design. One of the things I am trying to do is avoid the trap of doing getters and setters for everything. However, much of the work I do is with entities that are mainly data containers and I am not certain that getters and setters are actually inappropriate in these cases.</p> <p>Here is a simple example using public properties.</p> <pre><code>class Space { public String name; public String description; Space(final String name, final String description) { this.name = name; this.description = description; } } </code></pre> <p>Here is a simple example using private properties and using getters and setters.</p> <pre><code>class Space { private String name; private String description; Space(final String name, final String description) { this.name = name; this.description = description; } public String getName() { return this.name; } public void setName(final String name) { this.name = name; } public String getDescription() { return this.description; } public void setDescription(final String description) { this.description = description; } } </code></pre> <p>In these examples, both the <code>name</code> and the <code>description</code> fields should be able to be changed.</p> <p>I feel like the getter/setter example is more clear and hides the implementation details of what <code>name</code> and <code>description</code> are. It would also allow for validation on set later if needed.</p> <p>I have read several discussions about getters and setters being evil and/or an anti-pattern, but it really feels like those might not apply to this situation.</p> <p>Maybe there are some options I have not yet considered. I'm open for suggestions!</p>
[ { "answer_id": 406303, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 3, "selected": false, "text": "public class Space {\n private final String name;\n private final String description;\n\n public Space(final Strin...
2009/01/02
[ "https://Stackoverflow.com/questions/406288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50453/" ]
406,293
<p>C# 2.0 gives me access to nullable types. This seems very convenient when I want the DateTime variable in the database to be null. Is there anything I should worry about when using nullable types or can I go overboard and make every type I have nullable?</p>
[ { "answer_id": 406304, "author": "Mitch Wheat", "author_id": 16076, "author_profile": "https://Stackoverflow.com/users/16076", "pm_score": 2, "selected": false, "text": "DBNull null" }, { "answer_id": 406319, "author": "Jon Skeet", "author_id": 22656, "author_profile"...
2009/01/02
[ "https://Stackoverflow.com/questions/406293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10352/" ]
406,294
<p>What is the difference between <code>LEFT JOIN</code> and <code>LEFT OUTER JOIN</code>?</p>
[ { "answer_id": 406299, "author": "Mitch Wheat", "author_id": 16076, "author_profile": "https://Stackoverflow.com/users/16076", "pm_score": 9, "selected": false, "text": "LEFT JOIN LEFT OUTER JOIN" }, { "answer_id": 406333, "author": "Lasse V. Karlsen", "author_id": 267, ...
2009/01/02
[ "https://Stackoverflow.com/questions/406294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48581/" ]
406,298
<p>I am trying to join tableA with some data to an empty set of another tableB. The main purpose is to get all the columns of tableB. I do not need any data of tableB.</p> <p>I have constucted the following SQL:</p> <pre><code>SELECT uar.*, s.screen_id, s.screen_name FROM crs_screens LEFT JOIN crs\_user\_access\_right uar ON s.rid IS NOT NULL AND uar.rid IS NULL </code></pre> <p>This SQL runs perfectly on TOAD but it returns an error when I use it in my VB.NET OracleDataAdapter.Fill(DataTable) statement.</p> <p>It is fine if there is a work-around to achieve same effect. Thank you very much.</p> <hr> <p>Error message:</p> <blockquote> <p>OCI-22060: argument [2] is an invalid or uninitialized number</p> </blockquote> <hr> <p>Config:</p> <p>.NET framework: 1.1</p> <p>Oracle 9i</p>
[ { "answer_id": 406299, "author": "Mitch Wheat", "author_id": 16076, "author_profile": "https://Stackoverflow.com/users/16076", "pm_score": 9, "selected": false, "text": "LEFT JOIN LEFT OUTER JOIN" }, { "answer_id": 406333, "author": "Lasse V. Karlsen", "author_id": 267, ...
2009/01/02
[ "https://Stackoverflow.com/questions/406298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46971/" ]
406,312
<p>Here is my class:</p> <pre><code>public class User { public int Id { get; set; } public string Name { get; set; } public ISet&lt;User&gt; Friends { get; set; } } </code></pre> <p>Here is my mapping:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Test" assembly="test"&gt; &lt;class name="User" table="Users"&gt; &lt;id name="Id" column="id"&gt; &lt;generator class="native"/&gt; &lt;/id&gt; &lt;property name="Name" column="name"/&gt; &lt;set name="Friends" table="Friends"&gt; &lt;key column="user_id"/&gt; &lt;many-to-many class="User" column="friend_id"/&gt; &lt;/set&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt; </code></pre> <p>Here is the problem:</p> <pre><code>User user = session.Load&lt;User&gt;(1); User friend = new User(); friend.Name = "new friend"; user.Friends.Add(friend); </code></pre> <p>At the last line [user.Friends.Add(friend)], I noticed that it will initialize the Friends collection before add new friend to it.</p> <p>My question is: Is there anyway to avoid this behavior in NHibernate? Because I just want to have only single INSERT command to be executed for performance reason.</p>
[ { "answer_id": 406348, "author": "Darin Dimitrov", "author_id": 29407, "author_profile": "https://Stackoverflow.com/users/29407", "pm_score": 0, "selected": false, "text": "User user = session\n .CreateCriteria(typeof(User))\n .SetFetchMode(\"Friends\", FetchMode.Eager)\n .Add(E...
2009/01/02
[ "https://Stackoverflow.com/questions/406312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50275/" ]
406,315
<p>This problem involved me not knowing enough of C++. I am trying to access a specific value that I had placed in the Heap, but I'm unsure of how to access it. In my problem, I had placed a value in a heap from a data member function in an object, and I am trying to access it in another data member function. Problem is I do not know how, and I had searched examples online, but none were what I needed as they were all in int main() and were not specifically what I needed.</p> <p>In the first data member function, I declare the value I want to be sent to the Heap; Here's an example of what my first data member function.</p> <pre><code>void Grid::HeapValues() { //Initializing Variable value = 2; //The type is already declared //Pointers point a type towards the Heap int* pValue = new int; //Initialize an a value of in the Heap *pValue = value; } </code></pre> <p>And in data member function This is what want:</p> <pre><code>void Grid::AccessHeap() { //Extracting heap: int heap_value = *pValue; //*pValue does not exist in this function cout &lt;&lt; heap_value; //Delays the value 2, which is found //in the first data member function } </code></pre> <p>I feel foolish for asking, but I am unable to find the answers and do not how. Does anyone know how to access a value from the heap in a simple way? And I would need it to be able to access in more then two data member function.</p>
[ { "answer_id": 406326, "author": "abelenky", "author_id": 34824, "author_profile": "https://Stackoverflow.com/users/34824", "pm_score": 5, "selected": true, "text": "class Grid\n{\n private: int* pValue;\n public: void HeapValues();\n void AccessHeap();\n};\n" }, { "an...
2009/01/02
[ "https://Stackoverflow.com/questions/406315", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
406,316
<p>How do I pass have a Javascript script request a PHP page and pass data to it? How do I then have the PHP script pass data back to the Javascript script?</p> <p>client.js:</p> <pre><code>data = {tohex: 4919, sum: [1, 3, 5]}; // how would this script pass data to server.php and access the response? </code></pre> <p>server.php:</p> <pre><code>$tohex = ... ; // How would this be set to data.tohex? $sum = ...; // How would this be set to data.sum? // How would this be sent to client.js? array(base_convert($tohex, 16), array_sum($sum)) </code></pre>
[ { "answer_id": 406324, "author": "Kezzer", "author_id": 39693, "author_profile": "https://Stackoverflow.com/users/39693", "pm_score": 2, "selected": false, "text": "<script language=\"javascript\" type=\"text/javascript\">\n function _vals(target, value){\n form1.all(\"target\").value=...
2009/01/02
[ "https://Stackoverflow.com/questions/406316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49318/" ]
406,351
<p>Is there any good way convert a binary (base 2) strings to integers in T-SQL (if not I guess I can write a function...)</p> <p>'0110' => 6 etc.</p>
[ { "answer_id": 406359, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": true, "text": "SELECT (8 * CONVERT(int, SUBSTRING(@x, 1, 1)))\n + (4 * CONVERT(int, SUBSTRING(@x, 2, 1)))\n + (2 * CONVERT(int, ...
2009/01/02
[ "https://Stackoverflow.com/questions/406351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40939/" ]
406,352
<p>I'm experiencing some issues regarding my javabuilder-compiled matlab-code. My application is basically split up like this:</p> <ul> <li>GUI: Java</li> <li>Calculations: Matlab</li> </ul> <p>The main problem is that when compiling my matlab-code with the javabuilder in Matlab (R17, 2007a), I have less memory available than I have when I compile the same code to an exe-file. I have confirmed this with the "feature('memstats')" function. My arrays are typically of size orders 1000000 x 25, and this is not initializable when run from java, as the largest contiguous memory space is too small (the biggest one is about 65MB, as opposed to about 1200MB when run as a ML exe-file). My rig is running Windows XP Professional x86 and has 4GB of memory.</p> <p>I've tried these two matlab/c-compilators (set up with the "mbuild -setup" command in the matlab command line):</p> <ul> <li>Lcc-win32 C 2.4.1</li> <li>Microsoft Visual C++ 6.0 (also with the /LARGEADDRESSAWARE flag, which does not seem to help at all)</li> </ul> <p>Any suggestions?</p>
[ { "answer_id": 406690, "author": "atsjoo", "author_id": 37257, "author_profile": "https://Stackoverflow.com/users/37257", "pm_score": 0, "selected": false, "text": "Physical Memory (RAM):\n In Use: 1568 MB (62059000)\n Free: ...
2009/01/02
[ "https://Stackoverflow.com/questions/406352", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37257/" ]
406,358
<p>How to protect a SQL Server database from viewing others?</p>
[ { "answer_id": 406690, "author": "atsjoo", "author_id": 37257, "author_profile": "https://Stackoverflow.com/users/37257", "pm_score": 0, "selected": false, "text": "Physical Memory (RAM):\n In Use: 1568 MB (62059000)\n Free: ...
2009/01/02
[ "https://Stackoverflow.com/questions/406358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
406,361
<p>My code:</p> <pre><code>a = '2.3' </code></pre> <p>I wanted to display <code>a</code> as a floating point value.</p> <p>Since <code>a</code> is a string, I tried:</p> <pre><code>float(a) </code></pre> <p>The result I got was :</p> <pre><code>2.2999999999999998 </code></pre> <p>I want a solution for this problem. Please, kindly help me.</p> <p>I was following <a href="http://docs.python.org/tutorial/floatingpoint.html" rel="noreferrer">this tutorial</a>.</p>
[ { "answer_id": 407366, "author": "Ali Afshar", "author_id": 28380, "author_profile": "https://Stackoverflow.com/users/28380", "pm_score": 3, "selected": false, "text": ">>> from decimal import Decimal\n>>> a = Decimal('2.3')\n>>> print a\n2.3\n" } ]
2009/01/02
[ "https://Stackoverflow.com/questions/406361", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46646/" ]
406,380
<p>I am using Infragistics wingrid in my application. I have assigned a datasource to my wingrid. Now i want to add a new column at a specific location.</p> <p>Can any one please tell me how can this be performed?</p> <p>Regards, Savan.</p>
[ { "answer_id": 407366, "author": "Ali Afshar", "author_id": 28380, "author_profile": "https://Stackoverflow.com/users/28380", "pm_score": 3, "selected": false, "text": ">>> from decimal import Decimal\n>>> a = Decimal('2.3')\n>>> print a\n2.3\n" } ]
2009/01/02
[ "https://Stackoverflow.com/questions/406380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40293/" ]
406,385
<p>I wanted to set some handler for all the unexpected exceptions that I might not have caught inside my code. In <code>Program.Main()</code> I used the following code:</p> <pre><code>AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ErrorHandler.HandleException); </code></pre> <p>But it didn't work as I expected. When I started the application in debugging mode and threw an exception it did call the handler, but afterwards the exception helper in Visual Studio popped up as if the exception occurred without any handling. I tried Application.Exit() inside the handler but it didn't work as well.</p> <p>What I would like to achieve is that the exception is handled with my handler and then the application closes nicely. Is there any other way to do it or am I using the code above in the wrong way?</p>
[ { "answer_id": 406394, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": false, "text": "Application.ThreadException Main()" }, { "answer_id": 406473, "author": "peSHIr", "author_id": 50846,...
2009/01/02
[ "https://Stackoverflow.com/questions/406385", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40872/" ]
406,386
<p>Where can I find a Visual Studio plug-in that automatically generates documentation header for methods and properties?</p> <p>Example the comment to a property could look like this:</p> <pre><code>/// &lt;summary&gt; /// Gets or sets the value of message /// &lt;/summary&gt; public static string Message { get { return message; } set { message = value; } } </code></pre>
[ { "answer_id": 409708, "author": "Matthew", "author_id": 20162, "author_profile": "https://Stackoverflow.com/users/20162", "pm_score": 2, "selected": false, "text": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Web;\n\nnamespace MvcWidgets.Models\n{\...
2009/01/02
[ "https://Stackoverflow.com/questions/406386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18631/" ]
406,396
<p>I am trying to prefix a string (<code>reference_</code>) to the names of all the *.bmp files in all the directories as well sub-directories. The first time we run the silk script, it will create directories as well subdirectories, and under each subdirectory it will store each mobile application's sceenshot with <code>.bmp</code> extension.</p> <p>When I run the automated silkscript for second time it will again create the *.bmp files in all the subdirectories. Before running the script for second time I want to prefix all the *.bmp with a string <code>reference_</code>.</p> <p>For example <code>first_screen.bmp</code> to <code>reference_first_screen.bmp</code>, I have the directory structure as below:</p> <pre><code>C:\Image_Repository\BG_Images\second ... C:\Image_Repository\BG_Images\sixth </code></pre> <p>having <code>first_screen.bmp</code> and <code>first_screen.bmp</code> files etc...</p> <p>Could any one help me out?</p> <p>How can I prefix all the image file names with <code>reference_</code> string?</p> <p>When I run the script for second time, the Perl script in silk will take both the images from the sub-directory and compare them both pixel by pixel. I am trying with code below. Could you please guide me how can I proceed to complete this task.</p> <pre><code>#!/usr/bin/perl -w &amp;one; &amp;two; sub one { use Cwd; my $dir ="C:\\Image_Repository"; #print "$dir\n"; opendir(DIR,"+&lt;$dir") or "die $!\n"; my @dir = readdir DIR; #$lines=@dir; delete $dir[-1]; print "$lines\n"; foreach my $item (@dir) { print "$item\n"; } closedir DIR; } sub two { use Cwd; my $dir1 ="C:\\Image_Repository\\BG_Images"; #print "$dir1\n"; opendir(D,"+&lt;$dir1") or "die $!\n"; my @dire = readdir D; #$lines=@dire; delete $dire[-1]; #print "$lines\n"; foreach my $item (@dire) { #print "$item\n"; $dir2="C:\\Image_Repository\\BG_Images\\$item"; print $dir2; opendir(D1,"+&lt;$dir2") or die " $!\n"; my @files=readdir D1; #print "@files\n"; foreach $one (@files) { $one="reference_".$one; print "$one\n"; #rename $one,Reference_.$one; } } closedir DIR; } </code></pre> <p>I tried open call with '+&lt;' mode but I am getting compilation error for the read and write mode. When I am running this code, it shows the files in BG_images folder with prefixed string but actually it's not updating the files in the sub-directories.</p>
[ { "answer_id": 406441, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 2, "selected": false, "text": "reference_ reference_ reference_ use strict; -w @files foreach my $one (@files)\n {\n my $new = \"ref...
2009/01/02
[ "https://Stackoverflow.com/questions/406396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45284/" ]
406,400
<p>I have a div that contains other floating divs:</p> <p>&lt;div id="parent"&gt;<br /> &nbsp;&nbsp;&lt;div style="float:left;"&gt;text&lt;/div&gt;<br /> &nbsp;&nbsp;&lt;div style="float:left;"&gt;text&lt;/div&gt;<br /> &nbsp;&nbsp;&lt;div style="float:right;"&gt;text&lt;/div&gt;<br /> &lt;/div&gt;</p> <p>How can I add bottom padding to the parent div and make it work in IE6 (or in other words avoid the bugs in IE6)?</p> <p>Thanks</p>
[ { "answer_id": 406451, "author": "bochgoch", "author_id": 50450, "author_profile": "https://Stackoverflow.com/users/50450", "pm_score": 1, "selected": false, "text": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n \"http://www.w3.org/TR/html4/strict.dtd\">\n\n<html>\n<head>\n<titl...
2009/01/02
[ "https://Stackoverflow.com/questions/406400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/676066/" ]
406,402
<p>I wrote this code </p> <h2>I have these errors</h2> <p>Cannot implicitly convert type x.Program.TreeNode' to 'int' // on findmin</p> <p>Cannot implicitly convert type x.Program.TreeNode' to 'int' // on findmax</p> <p>and is my main correct or missing somethin?</p> <p>and how i can count the nodes,leaves and get the hight (need only hints)</p> <pre><code>class Program { static void Main(string[] args) { BinarySearchTree t = new BinarySearchTree(); t.insert(ref t.root, 10); t.insert(ref t.root, 5); t.insert(ref t.root, 6); t.insert(ref t.root, 17); t.insert(ref t.root, 2); t.insert(ref t.root, 3); BinarySearchTree.print(t.root); } public class TreeNode { public int n; public TreeNode _left; public TreeNode _right; public TreeNode(int n, TreeNode _left, TreeNode _right) { this.n = n; this._left = _left; this._right = _right; } public void DisplayNode() { Console.Write(n); } } public class BinarySearchTree { public TreeNode root; public BinarySearchTree() { root = null; } public void insert(ref TreeNode root, int x) { if (root == null) { root = new TreeNode(x, null, null); } else if (x &lt; root.n) insert(ref root._left, x); else insert(ref root._right, x); } public int FindMin() { TreeNode current = root; while (current._left != null) current = current._left; return current; } public int FindMax() { TreeNode current = root; while (current._right != null) current = current._right; return current; } public TreeNode Find(int key) { TreeNode current = root; while (current.n != key) { if (key &lt; current.n) current = current._left; else current = current._right; if (current == null) return null; } return current; } public void InOrder(ref TreeNode root) { if (root != null) { InOrder(ref root._left); root.DisplayNode(); InOrder(ref root._right); } } public static void print(TreeNode root) { if (root != null) { print(root._left); Console.WriteLine(root.n.ToString()); print(root._right); } } </code></pre>
[ { "answer_id": 406409, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": true, "text": "FindMin FindMax int current.n TreeNode public int CountNodes()\n {\n int count = 1; // me!\n if (...
2009/01/02
[ "https://Stackoverflow.com/questions/406402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
406,433
<p>Which one is better when performance is taken into consideration an <strong>if else if</strong> or <strong>switch case</strong></p> <p>Duplicate: <a href="https://stackoverflow.com/questions/395618/ifelse-vs-switch">Is there any significant difference between using if/else and switch-case in C#?</a></p>
[ { "answer_id": 406438, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 0, "selected": false, "text": "switch switch switch" } ]
2009/01/02
[ "https://Stackoverflow.com/questions/406433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47738/" ]
406,446
<p>I haven't used a statically typed language in many years and have set myself the task of getting up to speed with C#. I'm using my usual trick of following the fifteen exercises here <a href="http://www.jobsnake.com/seek/articles/index.cgi?openarticle&amp;8533" rel="noreferrer">http://www.jobsnake.com/seek/articles/index.cgi?openarticle&amp;8533</a> as my first task.</p> <p>I've just finished the second Fibonacci task which didn't take to long and works just fine but in my opinion looks ugly and I'm sure could be achieved in far fewer lines of more elegant code.</p> <p>I usually like to learn by pair programming with someone who already knows what they're doing, but that option isn't open to me today, so I'm hoping posting here will be the next best thing.</p> <p>So to all the C# Jedi's out there, if you were going to refactor the code below, what would it look like?</p> <pre><code>using System; using System.Collections; namespace Exercises { class MainClass { public static void Main(string[] args) { Console.WriteLine("Find all fibinacci numbers between:"); int from = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("And:"); int to = Convert.ToInt32(Console.ReadLine()); Fibonacci fibonacci = new Fibonacci(); fibonacci.PrintArrayList(fibonacci.Between(from, to)); } } class Fibonacci { public ArrayList Between(int from, int to) { int last = 1; int penultimate = 0; ArrayList results = new ArrayList(); results.Add(penultimate); results.Add(last); while(last&lt;to) { int fib = last + penultimate; penultimate = last; last = fib; if (fib&gt;from &amp;&amp; fib&lt;to) results.Add(fib.ToString()); } return results; } public void PrintArrayList(ArrayList arrayList) { Console.WriteLine("Your Fibonacci sequence:"); Console.Write(arrayList[0]); for(int i = 1; i&lt;arrayList.Count; i++) { Console.Write("," + arrayList[i]); } Console.WriteLine(""); } } } </code></pre> <p>Regards,</p> <p>Chris</p>
[ { "answer_id": 406448, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 7, "selected": true, "text": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nstatic class Program {\n static IEnumerable...
2009/01/02
[ "https://Stackoverflow.com/questions/406446", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37196/" ]
406,463
<p>I want all the Method-ClassName from namespace</p> <p>like i have system.windows.Forms</p> <p>wehen in visual studio we rigt system.windows.Forms. it will suggest box of all the related method,class,enum extra</p> <p>i need to fetch the same ,how can i do that in C#</p>
[ { "answer_id": 406467, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": false, "text": "var types = assembly.GetTypes().Where(type => type.Namespace == desiredNamespace);\n" } ]
2009/01/02
[ "https://Stackoverflow.com/questions/406463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
406,485
<p>How do you do it? Given a byte array:</p> <pre><code>byte[] foo = new byte[4096]; </code></pre> <p>How would I get the first x bytes of the array as a separate array? (Specifically, I need it as an <code>IEnumerable&lt;byte&gt;</code>)</p> <p>This is for working with <code>Socket</code>s. I figure the easiest way would be array slicing, similar to Perls syntax:</p> <pre><code>@bar = @foo[0..40]; </code></pre> <p>Which would return the first 41 elements into the <code>@bar</code> array. Is there something in C# that I'm just missing, or is there some other thing I should be doing?</p> <p>LINQ is an option for me (.NET 3.5), if that helps any.</p>
[ { "answer_id": 406489, "author": "Arjan Einbu", "author_id": 19594, "author_profile": "https://Stackoverflow.com/users/19594", "pm_score": 7, "selected": false, "text": "CopyTo() Skip() Take() byte[] arr = {1, 2, 3, 4, 5, 6, 7, 8};\nvar subset = arr.Skip(2).Take(2);\n" }, { "answ...
2009/01/02
[ "https://Stackoverflow.com/questions/406485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15537/" ]
406,487
<p>I have a DateTime class and wish to display it according to some format... in this case, I specifically want to format it as YYYYMMDD format.</p> <p>What's the best C#/.NET API function for doing this?</p>
[ { "answer_id": 406490, "author": "Will Dean", "author_id": 987, "author_profile": "https://Stackoverflow.com/users/987", "pm_score": 0, "selected": false, "text": "DateTime.ToString(<format string>)\n" }, { "answer_id": 406491, "author": "Marc Gravell", "author_id": 23354...
2009/01/02
[ "https://Stackoverflow.com/questions/406487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34685/" ]
406,504
<p>Say I have textboxes, dropdownlists and submit buttons. They are all inline-elements. Which means that "officially" margin, padding, width and height properties should be ignored (in practice not really). If I were to go the right way to set the height to a button I would write something like display:block and then define the height. But there are considerations that a block level element would expand itself unexpectedly so I'd better set its width to some fixed value. The problem is that I don't know its width since it can be dynamically defined upon the text of the button.</p> <p>Another scenario: I wish to create a menu via <code>&lt;ul&gt;</code> and <code>&lt;li&gt;</code>. I want to have it horizontally aligned, with some items grouped to the left, and with a few stretched to the right. Both <code>&lt;ul&gt;</code> and <code>&lt;li&gt;</code> are block-level elements. Since I wish my menu to take all available horizontal space, then to play with the items height and to have menu items pushed to both sides, the block-mode is fine to me. I'll just use float:left and float:right to achieve the task. But again use should kinda set a width to menu elements, since they are block elements. I do not know their widths because the text of the items can vary. But it seems that everything is rendered just fine as it is.</p> <p>I have not noticed any issues with both inline elements forced to render as block elements without being floated or width set, or with the list item example. It works just fine in IE7, FF3, Opera 9 and Safari whatever the current version is. The question remains: should I worry about these inline-to-block elements or real block elements floated but without the width set or just leave everything as it is? Am I missing something or is it just one more of those things you simply should not expect to get right?</p>
[ { "answer_id": 406588, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": true, "text": "<li>" }, { "answer_id": 406783, "author": "Ionuț Staicu", "author_id": 23810, "author_profile": "https://St...
2009/01/02
[ "https://Stackoverflow.com/questions/406504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50855/" ]
406,514
<p>I got this ajax form in a ASP.NET MVC beta application :</p> <pre><code> &lt;%using (this.Ajax.BeginForm("Edit", "Subscriber", new AjaxOptions { OnSuccess = "onEditResult", HttpMethod = "GET" })) {%&gt; &lt;%=Html.Hidden("idSub", p.Id.ToString())%&gt; &lt;input type="submit" value="Edit"/&gt;&lt;% } %&gt; </code></pre> <p>And my controller method : </p> <pre><code>[AcceptVerbs(HttpVerbs.Get)] public JsonResult Edit(String idSub) { (...) } </code></pre> <p>But the idSub is always null, before upgrading to the beta I swear I see this method working !</p> <p>I have upgraded the JS files (Microsoft Ajax) and the assemblies as recommended.</p>
[ { "answer_id": 406588, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": true, "text": "<li>" }, { "answer_id": 406783, "author": "Ionuț Staicu", "author_id": 23810, "author_profile": "https://St...
2009/01/02
[ "https://Stackoverflow.com/questions/406514", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3109/" ]
406,520
<p>Hi i executed the following stored procedure in .net web application. Then run the application. I got this error</p> <p>" Divide By zero error "</p> <p>Stored procedure:</p> <pre><code>CREATE procedure Details(@Stringtext varchar(8000),@SearchStringtext varchar(100)) as begin SELECT ({fn LENGTH(@Stringtext)}- {fn LENGTH({fn REPLACE(@Stringtext, @SearchStringtext, '')})})/ { fn LENGTH(@SearchStringtext)}AS String_Count end </code></pre>
[ { "answer_id": 406521, "author": "slim", "author_id": 7512, "author_profile": "https://Stackoverflow.com/users/7512", "pm_score": 2, "selected": false, "text": "{ fn LENGTH(@SearchStringtext)}\n" }, { "answer_id": 406525, "author": "Spoike", "author_id": 3713, "author...
2009/01/02
[ "https://Stackoverflow.com/questions/406520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
406,526
<p>I need to define new UI Elements as well as data binding in code because they will be implemented after run-time. Here is a simplified version of what I am trying to do.</p> <p>Data Model:</p> <pre><code>public class AddressBook : INotifyPropertyChanged { private int _houseNumber; public int HouseNumber { get { return _houseNumber; } set { _houseNumber = value; NotifyPropertyChanged("HouseNumber"); } } public event PropertyChangedEventHandler PropertyChanged; protected void NotifyPropertyChanged(string sProp) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(sProp)); } } } </code></pre> <p>Binding in Code:</p> <pre><code>AddressBook book = new AddressBook(); book.HouseNumber = 123; TextBlock tb = new TextBlock(); Binding bind = new Binding("HouseNumber"); bind.Source = book; bind.Mode = BindingMode.OneWay; tb.SetBinding(TextBlock.TextProperty, bind); // Text block displays "123" myGrid.Children.Add(tb); book.HouseNumber = 456; // Text block displays "123" but PropertyChanged event fires </code></pre> <p>When the data is first bound, the text block is updated with the correct house number. Then, if I change the house number in code later, the book's PropertyChanged event fires, but the text block is not updated. Can anyone tell me why?</p> <p>Thanks, Ben</p>
[ { "answer_id": 406546, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 0, "selected": false, "text": "_houseNumber" }, { "answer_id": 406555, "author": "Cameron MacFarland", "author_id": 3820, "autho...
2009/01/02
[ "https://Stackoverflow.com/questions/406526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50859/" ]
406,533
<p>Which dependency should be added in pom file to import <code>org.apache.tiles.controller</code>?</p>
[ { "answer_id": 406562, "author": "Andrew Newdigate", "author_id": 50131, "author_profile": "https://Stackoverflow.com/users/50131", "pm_score": 1, "selected": false, "text": "<dependency>\n <groupId>org.apache.struts</groupId>\n <artifactId>struts-tiles</artifactId>\n <version>1...
2009/01/02
[ "https://Stackoverflow.com/questions/406533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40933/" ]
406,550
<p>I am trying to find the best way to design the database in order to allow the following scenario:</p> <ol> <li>The user is presented with a dropdown list of Universities (for example)</li> <li>The user selects his/her university from the list if it exists</li> <li>If the university does not exist, he should enter his own university in a text box (sort of like Other: [___________])</li> </ol> <p>how should I design the database to handle such situation given that I might want to sort using the university ID for example (probably only for the built in universities and not the ones entered by users)</p> <p>thanks!</p> <p>I just want to make it similar to how Facebook handles this situation. If the user selects his Education (by actually typing in the combobox which is not my concern) and choosing one of the returned values, what would Facebook do?</p> <p>In my guess, it would insert the UserID and the EducationID in a many-to-many table. Now what if the user is entering is not in the database at all? It is still stored in his profile, but where? <a href="https://i.stack.imgur.com/OR6UP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OR6UP.jpg" alt="typing &quot;St&quot;...suggesting Stanford"></a> </p> <p><a href="https://i.stack.imgur.com/JWq07.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JWq07.jpg" alt="typing non-existing university"></a> </p>
[ { "answer_id": 406560, "author": "Kezzer", "author_id": 39693, "author_profile": "https://Stackoverflow.com/users/39693", "pm_score": -1, "selected": false, "text": "INSERT INTO MyTable Name VALUES ('myval'); SELECT @@SCOPE_IDENTITY()\n" }, { "answer_id": 406563, "author": "S...
2009/01/02
[ "https://Stackoverflow.com/questions/406550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47582/" ]
406,552
<p>I cannot seem to access the context object using a loop context is set: <code>var context = [id1, id2, id3];</code></p> <p>This callback function works:</p> <pre><code>function OnChangeSucceeded(result, context, methodName) { document.getElementById(context[0]).disabled = result; document.getElementById(context[1]).disabled = result; document.getElementById(context[2]).disabled = result; } </code></pre> <p>This callback function fails:</p> <pre><code>function OnChangeSucceeded(result, context, methodName) { for(var indx = 0; indx &lt; context.length; indx++) { document.getElementById(context[indx]).disabled = result; } } </code></pre>
[ { "answer_id": 406560, "author": "Kezzer", "author_id": 39693, "author_profile": "https://Stackoverflow.com/users/39693", "pm_score": -1, "selected": false, "text": "INSERT INTO MyTable Name VALUES ('myval'); SELECT @@SCOPE_IDENTITY()\n" }, { "answer_id": 406563, "author": "S...
2009/01/02
[ "https://Stackoverflow.com/questions/406552", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3416/" ]
406,558
<p>I usually get so confused with UML and this situation is no different. Let's say I have an interface IAnimal, class Food and Cat:</p> <pre><code>interface IAnimal { void Feed(Food food); } class Cat : IAnimal { void Feed(Food food) { //code } } </code></pre> <p>I've got 3 questions about drawing UML class diagram for these 3 elements: </p> <ul> <li><p>I assume I should use association between IAnimal and Food or Cat and Food. Should there be an arrow on one side of the association line, if yes, then on which side and why there? </p></li> <li><p>if I write Feed as an IAnimal method on diagram, should I write a method Feed inside class Cat or do I write only additional Cat methods?</p></li> <li><p>the most important: should the association be between IAnimal and Food, Cat and Food, or both? </p></li> </ul>
[ { "answer_id": 406581, "author": "Arne Burmeister", "author_id": 12890, "author_profile": "https://Stackoverflow.com/users/12890", "pm_score": 0, "selected": false, "text": " IAnimal ----> Food\n ^ ^\n // \\\\\n // \\\\\n Cat Dog\n" }, { "answer_id": 4065...
2009/01/02
[ "https://Stackoverflow.com/questions/406558", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40872/" ]
406,561
<p>I have a file "atest.txt" that have some text..</p> <p>I want to print this text at files "asdasd.txt asgfaya.txt asdjfusfdgh.txt asyeiuyhavujh.txt"</p> <p>This files is not exist on my server..</p> <p>I'm running Debian.. What can i do?</p>
[ { "answer_id": 406571, "author": "Eineki", "author_id": 29125, "author_profile": "https://Stackoverflow.com/users/29125", "pm_score": 1, "selected": false, "text": "#!/bin/bash\n$TEXT=\"hello\\nthis is a test\\nthank you\"\nfor i in `seq 1 $1`; do echo -e $TEXT >text$i.txt; done\n #!/bin...
2009/01/02
[ "https://Stackoverflow.com/questions/406561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
406,587
<p>I'm working on an 'advanced search' page on a site where you would enter a keyword such as 'I like apples' and it can search the database using the following options:</p> <blockquote> <p>Find : With all the words, With the exact phrase , With at least one of the words, Without the words</p> </blockquote> <p>I can take care of the 'Exact phrase' by:</p> <pre><code>SELECT * FROM myTable WHERE field='$keyword'; </code></pre> <p>'At least one of the words' by:</p> <pre><code>SELECT * FROM myTable WHERE field LIKE '%$keyword%';//Let me know if this is the wrong approach </code></pre> <p>But its the 'With at least one of the words' and 'Without the words' that I'm stuck on. </p> <p>Any suggestions on how to implement these two?</p> <p><strong>Edit:</strong> Regarding 'At least one word' it wouldn't be a good approach to use explode() to break the keywords into words, and run a loop to add </p> <pre><code>(field='$keywords') OR ($field='$keywords) (OR).... </code></pre> <p>Because there are some other AND/OR clauses in the query also and I'm not aware of the maximum number of clauses there can be.</p>
[ { "answer_id": 406596, "author": "Re0sless", "author_id": 2098, "author_profile": "https://Stackoverflow.com/users/2098", "pm_score": 2, "selected": false, "text": "SELECT * FROM myTable WHERE field LIKE '%$keyword%' \nor field LIKE '%$keyword2%' \nor field LIKE '%$keyword3%';\n SELECT *...
2009/01/02
[ "https://Stackoverflow.com/questions/406587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49153/" ]
406,613
<p>I recently wrote a piece of code which did</p> <pre><code>SomeClass someObject; mysqlpp::StoreQueryResult result = someObject.getResult(); </code></pre> <p>where SomeClass::getResult() looks like:</p> <pre><code>mysqlpp::StoreQueryResult SomeClass::getResult() { mysqlpp::StoreQueryResult res = ...&lt;something&gt;...; return res; } </code></pre> <p>Now, using the example in the first code snippet, when I compiled and ran, the program crashed with an ABORT signal. I then changed the first snippet to:</p> <pre><code>SomeClass someObject; mysqlpp::StoreQueryResult result(someObject.getResult()); </code></pre> <p>which worked fine. Also, just to try it out, I changed it again to:</p> <pre><code>SomeClass someObject; mysqlpp::StoreQueryResult result; result = someObject.getResult(); </code></pre> <p>which also worked fine.</p> <p>Now, I just can't figure out why the first example failed, and the next two succeeded. As I understand, in the first example, the copy constructor is used to initialise result. But isn't this also the case in the second example? So why did the second example succeed? The 3rd example makes a bit more sense - since the copy const isn't used, we just assign after construction.</p> <p>In short, what's the difference between:</p> <pre><code>FooClass a = someObject.someMethodReturningFooClassInstance(); </code></pre> <p>and </p> <pre><code>FooClass a(someObject.someMethodReturningFooClassInstance());? </code></pre> <p>Muchos thanks!</p>
[ { "answer_id": 406633, "author": "erikkallen", "author_id": 47161, "author_profile": "https://Stackoverflow.com/users/47161", "pm_score": 0, "selected": false, "text": "SomeClass someObject;\nmysqlpp::StoreQueryResult result;\nresult = someObject.getResult();\n" } ]
2009/01/02
[ "https://Stackoverflow.com/questions/406613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42387/" ]
406,616
<p>I want to display an image gallery, and on the view page, one should be able to have a look at a bunch of thumbnails: the current picture, wrapped with the two previous entries and the two next ones.</p> <p>The problem of fetching two next/prev is that I can't (unless I'm mistaken) select something like MAX(id) WHERE idxx.</p> <p>Any idea?</p> <p>note: of course the ids do not follow as they should be the result of multiple WHERE instances.</p> <p>Thanks Marshall</p>
[ { "answer_id": 406652, "author": "Garry Shutler", "author_id": 6369, "author_profile": "https://Stackoverflow.com/users/6369", "pm_score": 2, "selected": false, "text": "where id >= @id-2 and id <= @id+2\n union top order by select *\nfrom table\nwhere id = @id\n\nunion\n\nselect top 2 *...
2009/01/02
[ "https://Stackoverflow.com/questions/406616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50871/" ]
406,637
<p>See code below, for some reason it only works when I put a breakpoint on line 2 (*) is there some delay? Is it starting the next line before it finishes the 2nd one?</p> <pre><code>dp.SSLCertStoreType = nsoftware.IBizPayPal.DirectpaymentSSLCertStoreTypes.sstPEMKey *dp.SSLCertStore = My.Computer.FileSystem.ReadAllText(Server.MapPath("\cert_key_pem.txt")) dp.SSLCertSubject = "*" </code></pre> <p>Note: The error is thrown on the 3rd line only when the breakpoint is set on the 2nd line, after releasing the break the program executes my paypal purchase via credit card.</p> <p>I will post the error again I am replicating it now...</p> <p>System error: Could not acquire security credentials: error 8009030E.</p> <p>There it is, while it should say "Order Confirmed!" type message if working correctly.</p>
[ { "answer_id": 406650, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": 3, "selected": true, "text": "nsoftware.IBizPayPal" } ]
2009/01/02
[ "https://Stackoverflow.com/questions/406637", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18309/" ]
406,640
<p>I am trying to vertically center an anchor within a fieldset using CSS but it always appears to align to bottom. Is there any tricks to this?</p>
[ { "answer_id": 407064, "author": "bochgoch", "author_id": 50450, "author_profile": "https://Stackoverflow.com/users/50450", "pm_score": 0, "selected": false, "text": "<a href=\"www.google.com\" style=\"vertical-align:middle;\">google</a>\n" } ]
2009/01/02
[ "https://Stackoverflow.com/questions/406640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27294/" ]