qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
181,130
<p>I've just found out about Stack Overflow and I'm just checking if there are ideas for a constraint I'm having with some friends in a project, though this is more of a theoretical question to which I've been trying to find an answer for some time.</p> <p>I'm not much given into cryptography but if I'm not clear enough I'll try to edit/comment to clarify any questions.</p> <p>Trying to be brief, the environment is something like this:</p> <ul> <li><p>An application where the front-end as access to encrypt/decrypt keys and the back-end is just used for storage and queries.</p></li> <li><p>Having a database to which you can't have access for a couple of fields for example let's say "address" which is text/varchar as usual.</p></li> <li><p>You don't have access to the key for decrypting the information, and all information arrives to the database already encrypted.</p></li> </ul> <p>The main problem is something like this, how to consistently make queries on the database, it's impossible to do stuff like "where address like '%F§YU/´~#JKSks23%'". (IF there is anyone feeling with an answer for this feel free to shoot it).</p> <p>But is it ok to do <code>where address='±!NNsj3~^º-:'</code>? Or would it also completely eat up the database? </p> <p>Another restrain that might apply is that the front end doesn't have much processing power available, so already encrypting/decrypting information starts to push it to its limits. (Saying this just to avoid replies like "Exporting a join of tables to the front end and query it there".)</p> <p>Could someone point me in a direction to keep thinking about it?</p> <hr> <p>Well thanks for so fast replies at 4 AM, for a first time usage I'm really feeling impressed with this community. (Or maybe I'm it's just for the different time zone)</p> <p>Just feeding some information:</p> <p>The main problem is all around partial matching. As a mandatory requirement in most databases is to allow partial matches. The main constraint is actually <strong>the database owner would not be allowed to look inside the database for information</strong>. During the last 10 minutes I've come up with a possible solution which extends again to possible database problems, to which I'll add here:</p> <p>Possible solution to allow semi partial matching:</p> <ul> <li>The password + a couple of public fields of the user are actually the key for encrypting. For authentication the idea is to encrypt a static value and compare it within the database.</li> <li>Creating a new set of tables where information is stored in a parsed way, meaning something like: "4th Street" would become 2 encrypted rows (one for '4th' another for 'Street'). This would already allow semi-partial matching as a search could already be performed on the separate tables.</li> </ul> <p>New question:</p> <ul> <li>Would this probably eat up the database server again, or does anyone think it is a viable solution for the partial matching problem?</li> </ul> <p><em>Post Scriptum: I've unaccepted the answer from Cade Roux just to allow for further discussion and specially a possible answer to the new question.</em></p>
[ { "answer_id": 181144, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "$salt = \"123-=asd\";\n$address = \"3412 g ave\";\n\n$sql = \"INSERT INTO addresses (address) VALUES ('\" . md5($salt . $address) . \"')\";\nmysql_query($sql);\n $salt = \"123-=asd\";\n$address = \"3412 g ave\";\n\n$sql = \"SELECT address FROM addresses WHERE address = '\" . md5($salt . $address) . \"'\";\n$res = mysql_query($sql);\nif (mysql_fetch_row($res))\n // exists\nelse\n // does not\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26004/" ]
181,132
<p>On my homepage I got:</p> <pre><code>&lt;ul id="login"&gt; &lt;li&gt; &lt;a id="loginswitch" href="./login-page"&gt;log-in&lt;/a&gt; | &lt;/li&gt; &lt;li&gt; &lt;a id="signupswitch" href="./signup-page"&gt;sign-up&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>Via MooTools, I get these anchor elements by id so that once they're clicked, a flashy div will popup below them that contains the login or signup form (with methods to stop the propagation of events of course) and upon filling-up the fields the AJAX call kicks in - that's supposed to create a session and reload the page so that the user would have a visual that he is now logged in and user-level-controls appears etc..</p> <p>The ajax call is initiated by the MooTools AJAX class and <code>evalScripts</code> option is set to true. The AJAX page returns the script code:</p> <pre><code>&lt;script type="text/javascript"&gt;window.location = self.location;&lt;/script&gt; </code></pre> <p>This system works perfectly - now I'm wondering why if I change the anchors' <code>href</code> values to <code>href="#"</code> my scripts won't work anymore?</p> <p>Does it have anything to do with the window?</p> <p>Did it change its property when I clicked a link or so even when the event's propagation was stopped??</p>
[ { "answer_id": 181137, "author": "ephemient", "author_id": 20713, "author_profile": "https://Stackoverflow.com/users/20713", "pm_score": 1, "selected": false, "text": "#" }, { "answer_id": 196643, "author": "keparo", "author_id": 19468, "author_profile": "https://Stackoverflow.com/users/19468", "pm_score": 5, "selected": true, "text": "window.location = self.location;\n window.location GET /stackoverflow.com/posts/196643/index.html\nHTTP/1.1\nHost: www.stackoverflow.com\nUser-Agent: Mozilla/5.0\nIf-Modified-Since: Sun, 12 Oct 2008 20:41:31 GMT\n location.reload( true );\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24744/" ]
181,136
<p>I have a text file with multiple records. I want to search a name and date, for example if I typed <code>JULIUS CESAR</code> as name then the whole data about <code>JULIUS</code> will be extracted. What if I want only to extract information?</p> <pre><code>Record number: 1 Date: 08-Oct-08 Time: 23:45:01 Name: JULIUS CESAR Address: BAGUIO CITY, Philippines Information: I lived in Peza Loakan, Bagiou City A Computer Engineering student An OJT at TIPI. 23 years old. Record number: 2 Date: 09-Oct-08 Time: 23:45:01 Name: JOHN Castro Address: BAGUIO CITY, Philippines Information: I lived in Peza Loakan, Bagiou City A Electronics Comm. Engineering Student at SLU. An OJT at TIPI. My Hobby is Programming. Record number: 3 Date: 08-Oct-08 Time: 23:45:01 Name: CESAR JOSE Address: BAGUIO CITY, Philippines Information: Hi,, I lived Manila City A Computer Engineering student Working at TIPI. </code></pre>
[ { "answer_id": 181156, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "$name = \"JULIUS CESAR\";\n /$name/i \n /Record number: (\\d+) Date: (\\d+)-(\\w+)-(\\d+) Time: (\\d+):(\\d+):(\\d+) Name: $name Address: ([\\w\\s]+), ([\\w\\s]+?) Information: (.+?)$/i\n" }, { "answer_id": 181167, "author": "Robert Elwell", "author_id": 23102, "author_profile": "https://Stackoverflow.com/users/23102", "pm_score": -1, "selected": false, "text": "name" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
181,158
<p>i have a databound GridView in asp.net 2.0 with a row-selection link. When a row is selected, I want to programmatically add a table row below the selected row, in order to nest another grid et al.</p> <p>I am researching this for a client and for an article, and i think my google-fu is not strong tonight. Any suggestions?</p> <p>EDIT: I actually had a working solution but Visual Studio was nutted up somehow; closing and re-opening VS and rebuilding everything fixed the problem ;-)</p> <p>My solution is posted below, please tell me how to make it better if possible. Thanks!</p>
[ { "answer_id": 181168, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 4, "selected": true, "text": "protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)\n{\n if (e.Row.RowType == DataControlRowType.DataRow && \n (e.Row.RowState & DataControlRowState.Selected) > 0)\n {\n Table tbl = (Table)e.Row.Parent;\n GridViewRow tr = new GridViewRow(e.Row.RowIndex + 1, -1,\n DataControlRowType.EmptyDataRow, DataControlRowState.Normal);\n TableCell tc = new TableCell();\n tc.ColumnSpan = GridView1.Columns.Count;\n tc.Controls.Add(\n makeChildGrid(Convert.ToInt32(\n ((DataRowView)e.Row.DataItem)[\"ROW_ID_FIELD\"])));\n tr.Cells.Add(tc);\n tbl.Rows.Add(tr);\n }\n}\n\nprotected GridView makeChildGrid(int id)\n{\n GridView gv = new GridView();\n SqlDataSource sqlds = new SqlDataSource();\n sqlds.DataSourceMode = SqlDataSourceMode.DataSet;\n sqlds.ConnectionString = SqlDataSource1.ConnectionString;\n sqlds.SelectCommand = \"SELECT * from MY_TABLE_NAME \" +\n \"WHERE KEY_FIELD = \" + id.ToString();\n DataView dv = (DataView)sqlds.Select(DataSourceSelectArguments.Empty);\n gv.DataSource = dv;\n gv.DataBind(); //not sure this is necessary...?\n return gv;\n}\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181158", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9345/" ]
181,159
<p>I'm trying to generate a unique ID in php in order to store user-uploaded content on a FS without conflicts. I'm using php, and at the moment this little snippet is responsible for generating the UID:</p> <pre><code>$id = tempnam (".", ""); unlink($id); $id = substr($id, 2); </code></pre> <p>This code is hideous: it creates a temporary file on the FS and deletes it, retaining only the relevant unique part of the generated string.</p> <p>Is there any better way to do this, most preferably without any external dependencies?</p> <p>Thanks much!</p>
[ { "answer_id": 181163, "author": "Xenph Yan", "author_id": 264, "author_profile": "https://Stackoverflow.com/users/264", "pm_score": 5, "selected": true, "text": "string uniqid ([ string $prefix [, bool $more_entropy ]] )\n USAGE: $id = uniqid(rand(), true);\n" }, { "answer_id": 9010772, "author": "Will Rhodes", "author_id": 992429, "author_profile": "https://Stackoverflow.com/users/992429", "pm_score": 3, "selected": false, "text": "more_entropy" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1266/" ]
181,188
<p>In VB.NET I often <code>Catch…When</code>:</p> <pre><code>Try … Catch e As ArgumentNullException When e.ParamName.ToUpper() = "SAMPLES" … End Try </code></pre> <p>Is there a C# equivalent to <code>Catch…When</code>?</p> <p>I don't want to resort to using an <code>if</code> statement inside a <code>catch</code> if possible.</p>
[ { "answer_id": 181190, "author": "cruizer", "author_id": 6441, "author_profile": "https://Stackoverflow.com/users/6441", "pm_score": 4, "selected": false, "text": "Catch…When if catch try\n{\n …\n}\ncatch (ArgumentNullException e)\n{\n if (\"SAMPLES\" == e.ParamName.ToUpper())\n {\n … // handle exception\n }\n else\n {\n throw; // condition not fulfilled, let someone else handle the exception\n } \n}\n" }, { "answer_id": 22959433, "author": "Joe", "author_id": 1324810, "author_profile": "https://Stackoverflow.com/users/1324810", "pm_score": 5, "selected": true, "text": "try { … }\ncatch (MyException e) when (myfilter(e))\n{\n …\n}\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8280/" ]
181,189
<p>After being through numerous forums available on the net for last 5 days, I am still not able to completely track down the browser close event. My requirement is to generate a popup message, when user tries to close the browser.</p> <p>I have called my javascript function on body 'onbeforeunload' event. And I have hardcoded the conditions to check the mouse-coordinates for the red 'X' buton of browser, refresh, File-close or <kbd>Alt</kbd>-<kbd>F4</kbd>.</p> <p>My code works fine when browser window is Maximized, but fails if we shrink it after a limit. Please help me, if some body has already found the solution to a similar problem.</p> <p>Thank you.</p> <h3>Aggregated Responses of OP</h3> ------ <p>Ok, just tell me if it is possible to detect if a user has clicked on the Refresh button of the browser. Also, Refresh can be triggered by Right-click - Refresh or <kbd>Ctrl</kbd>-<kbd>R</kbd>. My requirement is to make a variable false on Refresh. I am just able to do it on <kbd>F5</kbd>, but all other ways are still out of my reach. The same would be applied to Back button.</p> <hr /> <p>Hi ppl, Thanks for all who replied at least. I have talked to my seniors regarding this and they have now understood and have compromised with the browser menu buttons. So now my task has become easy. Now, I am using a variable and making it true by default. As, I mentioned earlier I just have to catch the onbeforeunload and popup a message when user tries to leave. The message will not popup when user is navigating to other pages, as I have made the variable as false on all the links of my page using following piece of code:</p> <pre><code>document.onclick = function() { //To check if user is navigating from the page by clicking on a hyperlink. if (event.srcElement.tagName == 'A') blnShowMsg = false; //To not popup the warning message else blnShowMsg = true; //To popup the warning message } </code></pre> <p>In my case still the message is shown when user does Refresh, back or goes to any link in Favorites, etc.</p> <hr /> <p>Thanks buddy, but I have already gone through that and didn't find much help there too. My seniors are not happy with that solution as putting a flag on every link of my application is a complicated job and they fear of breaking the application. Any other suggestions would be appreciated. Thanks once again.</p> <hr /> <p>Is there no one who can think of a solution here!!! where are all the experts???</p>
[ { "answer_id": 190449, "author": "Stein G. Strindhaug", "author_id": 26115, "author_profile": "https://Stackoverflow.com/users/26115", "pm_score": 1, "selected": false, "text": "document.onclick = function()\n {\n //To check if user is navigating from the page by clicking on a hyperlink.\n if (event.srcElement.tagName == 'A')\n blnShowMsg = false; //To not popup the warning message\n else\n blnShowMsg = true; //To popup the warning message\n }\n" }, { "answer_id": 221414, "author": "Kevin Dark", "author_id": 26151, "author_profile": "https://Stackoverflow.com/users/26151", "pm_score": 1, "selected": false, "text": "<html>\n<head>\n<script language=\"Javascript\" type=\"text/javascript\">\n window.onbeforeunload = exitCheck;\n window.onunload = onCloseDoSomething;\n\n function onCloseDoSomething()\n {\n alert(\"This is executed at unload\");\n }\n\n function exitCheck(evt)\n {\n return \"Any string here.\"}\n </script>\n </head>\n\n <frameset rows=\"100%\">\n <FRAME name=\"main\" src=\"http://www.yourDomain.com/yourActualPage.aspx\">\n </frameset>\n<body>\n</body>\n</html>\n" }, { "answer_id": 261523, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 0, "selected": false, "text": "$(\"#dangerbutton\").click(function(){ \n $(\"a\").not( safeList ).click(function()\n {\n var dest = $(this).attr('href');\n someWarningFunction(function(){ \n /* Stay where we are because user opted to stay */\n },function(){ \n /* Continue Following Link because user didn't mind */\n window.location= dest; \n });\n return false;\n });\n});\n" }, { "answer_id": 5740376, "author": "Kasipan K", "author_id": 718397, "author_profile": "https://Stackoverflow.com/users/718397", "pm_score": 2, "selected": false, "text": " window.onbeforeunload = function (e)\n {\n\n e = e || window.event;\n var y = e.pageY || e.clientY;\n if (y < 0){\n return \"Do You really Want to Close the window ?\"\n }\n else {\n return \"Refreshing this page can result in data loss.\"; \n }\n\n }\n" }, { "answer_id": 34320767, "author": "Michael Cole", "author_id": 1483977, "author_profile": "https://Stackoverflow.com/users/1483977", "pm_score": 1, "selected": false, "text": "onunload onbeforeunload" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181189", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
181,191
<p>Let me preface this by saying I'm a complete amateur when it comes to RegEx and only started a few days ago. I'm trying to solve a problem formatting a file and have hit a hitch with a particular type of data. The input file is structured like this:</p> <pre> Two words,Word,Word,Word,"Number, number" </pre> <p>What I need to do is format it like this...</p> <pre> "Two words","Word",Word","Word","Number, number" </pre> <p>I have had a RegEx pattern of </p> <pre>s/,/","/g</pre> <p>working, except it also replaces the comma in the already quoted Number, number section, which causes the field to separate and breaks the file. Essentially, I need to modify my pattern to replace a comma with "," [quote comma quote], but only when that comma isn't followed by a space. Note that the other fields will never have a space following the comma, only the delimited number list.</p> <p>I managed to write up</p> <pre>s/,[A-Za-z0-9]/","/g</pre> <p>which, while matching the appropriate strings, would replace the comma AND the following letter. I have heard of backreferences and think that might be what I need to use? My understanding was that</p> <pre>s/(,)[A-Za-z0-9]\b</pre> <p>should work, but it doesn't.</p> <p>Anyone have an idea?</p>
[ { "answer_id": 181208, "author": "ephemient", "author_id": 20713, "author_profile": "https://Stackoverflow.com/users/20713", "pm_score": 2, "selected": true, "text": "s/,([^ ])/\",\"$1/ , \\1 $1 s/,(?! )/\",\"/ ," }, { "answer_id": 181255, "author": "Markus Jarderot", "author_id": 22364, "author_profile": "https://Stackoverflow.com/users/22364", "pm_score": 0, "selected": false, "text": "s/\"([^\"]*)\"|([^\",]+)/\"$1$2\"/g\n" }, { "answer_id": 181264, "author": "Robert Elwell", "author_id": 23102, "author_profile": "https://Stackoverflow.com/users/23102", "pm_score": 0, "selected": false, "text": " sed 's/[ \\\"]*,[ \\\"]*/\\\", \\\"/g'\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25045/" ]
181,209
<p>I have a function that looks like this</p> <pre><code>class NSNode { function insertAfter(NSNode $node) { ... } } </code></pre> <p>I'd like to be able to use that function to indicate that the node is being inserted at the start, therefore it is after <em>nothing</em>. The way I think about that is that <code>null</code> means "nothing", so I'd write my function call like this:</p> <pre><code>$myNode-&gt;insertAfter(null); </code></pre> <p>Except PHP throws an error saying that it was expecting an <code>NSNode</code> object. I'd like to stick to using the strict data typing in my function, but would like to be able to specify a null-esque value.</p> <p>So, short of changing it to <code>function insertAfter($node) { }</code>, is there a way I can pass something else to that function?</p> <hr> <p>Update: I've accepted Owen's answer because it answered the question itself. Everyone else's suggestions were really good and I'll actually be implementing them in this project, thanks!</p>
[ { "answer_id": 181223, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 4, "selected": true, "text": "function(NSNode $node = null) {\n// stuff....\n}\n $obj->insertAfter(); // no error\n$obj->insertAfter(new NSNode); // no error\n$obj->insertAfter($somevar); // error expected NSNode\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
181,210
<p>I have an asp.net text form that contains numerous decimal fields that are optional. I want to selectively update the database but not inserting a "0" for fields that do not have data (maintaining the null status). </p> <p>Typically, I would create multiple functions, each with a different signature to handle this. However, I am inserting the data through a webservice which does not allow a function with the same name to have multiple signatures. I can think of a couple ways to work around this, but none "pragmatically".</p>
[ { "answer_id": 181229, "author": "Jon Limjap", "author_id": 372, "author_profile": "https://Stackoverflow.com/users/372", "pm_score": 1, "selected": false, "text": "DBNull" }, { "answer_id": 181310, "author": "Vivek", "author_id": 7418, "author_profile": "https://Stackoverflow.com/users/7418", "pm_score": 3, "selected": true, "text": "decimal? dValue; // default value is null\n if(decimalValueExists)\n{\n dValue = <value read from text file>\n} \n public class MyFields\n{\n decimal req1;\n decimal? opt1; // optional field 1 \n}\n [WebMethod]\nvoid MyWSMethod(MyFields myFields)\n{/* code here will ultimately call InsertMyFields */}\n\nvoid InsertMyFields(MyFields myFields)\n{\n using (SqlConnection connection = new SqlConnection(connectionString))\n {\n // Create the command and set its properties.\n SqlCommand command = new SqlCommand();\n command.Connection = connection;\n command.CommandText = \"AddMyFields\";\n command.CommandType = CommandType.StoredProcedure;\n\n // Add the required input parameter\n SqlParameter parameter1 = new SqlParameter();\n parameter1.ParameterName = \"@ReqField1\";\n parameter1.SqlDbType = SqlDbType.NVarChar;\n parameter1.Direction = ParameterDirection.Input;\n parameter1.Value = myFields.req1;\n\n // Add the parameter to the Parameters collection. \n command.Parameters.Add(parameter1);\n\n // Add the optional parameter and set its properties.\n SqlParameter parameter2 = new SqlParameter();\n parameter2.ParameterName = \"@OptField1\";\n parameter2.SqlDbType = SqlDbType.NVarChar;\n parameter2.Direction = ParameterDirection.Input;\n parameter2.Value = myFields.opt1 ?? DBNull.Value; //null coalescing operator\n\n // Add the parameter to the Parameters collection. \n command.Parameters.Add(parameter2);\n\n //.. rest of the code\n }\n\n} \n" }, { "answer_id": 181333, "author": "Jeffrey L Whitledge", "author_id": 10174, "author_profile": "https://Stackoverflow.com/users/10174", "pm_score": 2, "selected": false, "text": "decimal? rebateAmountOrWhatever;\n new SqlParameter(\"@RebateAmount\", \n rebateAmountOrWhatever == null ? (object)DBNull.Value : (object)rebateAmountOrWhatever)\n new SqlParameter(\"@RebateAmount\", \n (object)rebateAmountOrWhatever ?? (object)DBNull.Value)\n Nullable<decimal> currentIraBalance = null;\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181210", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3149/" ]
181,214
<p>Implementing a file upload under html is fairly simple, but I just noticed that there is an 'accept' attribute that can be added to the <code>&lt;input type="file" ...&gt;</code> tag.</p> <p>Is this attribute useful as a way of limiting file uploads to images, etc? What is the best way to use it?</p> <p>Alternatively, is there a way to limit file types, preferably in the file dialog, for an html file input tag?</p>
[ { "answer_id": 181507, "author": "PhiLho", "author_id": 15459, "author_profile": "https://Stackoverflow.com/users/15459", "pm_score": 3, "selected": false, "text": "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"100000\"> UPLOAD_ERR_FORM_SIZE" }, { "answer_id": 4197455, "author": "magikMaker", "author_id": 509879, "author_profile": "https://Stackoverflow.com/users/509879", "pm_score": 5, "selected": false, "text": "accept=\"image/jpeg\"" }, { "answer_id": 10503561, "author": "0b10011", "author_id": 526741, "author_profile": "https://Stackoverflow.com/users/526741", "pm_score": 10, "selected": true, "text": "accept input h1 { font-size: 1em; margin:1em 0; }\nh1 ~ h1 { border-top: 1px solid #ccc; padding-top: 1em; } <h1>Match all image files (image/*)</h1>\n<p><label>image/* <input type=\"file\" accept=\"image/*\"></label></p>\n\n<h1>Match all video files (video/*)</h1>\n<p><label>video/* <input type=\"file\" accept=\"video/*\"></label></p>\n\n<h1>Match all audio files (audio/*)</h1>\n<p><label>audio/* <input type=\"file\" accept=\"audio/*\"></label></p>\n\n<h1>Match all image files (image/*) and files with the extension \".someext\"</h1>\n<p><label>.someext,image/* <input type=\"file\" accept=\".someext,image/*\"></label></p>\n\n<h1>Match all image files (image/*) and video files (video/*)</h1>\n<p><label>image/*,video/* <input type=\"file\" accept=\"image/*,video/*\"></label></p> accept audio/* video/* image/*" }, { "answer_id": 14839673, "author": "iconoclast", "author_id": 241142, "author_profile": "https://Stackoverflow.com/users/241142", "pm_score": 7, "selected": false, "text": "application/envoy evy\napplication/fractals fif\napplication/futuresplash spl\napplication/hta hta\napplication/internet-property-stream acx\napplication/mac-binhex40 hqx\napplication/msword doc\napplication/msword dot\napplication/octet-stream *\napplication/octet-stream bin\napplication/octet-stream class\napplication/octet-stream dms\napplication/octet-stream exe\napplication/octet-stream lha\napplication/octet-stream lzh\napplication/oda oda\napplication/olescript axs\napplication/pdf pdf\napplication/pics-rules prf\napplication/pkcs10 p10\napplication/pkix-crl crl\napplication/postscript ai\napplication/postscript eps\napplication/postscript ps\napplication/rtf rtf\napplication/set-payment-initiation setpay\napplication/set-registration-initiation setreg\napplication/vnd.ms-excel xla\napplication/vnd.ms-excel xlc\napplication/vnd.ms-excel xlm\napplication/vnd.ms-excel xls\napplication/vnd.ms-excel xlt\napplication/vnd.ms-excel xlw\napplication/vnd.ms-outlook msg\napplication/vnd.ms-pkicertstore sst\napplication/vnd.ms-pkiseccat cat\napplication/vnd.ms-pkistl stl\napplication/vnd.ms-powerpoint pot\napplication/vnd.ms-powerpoint pps\napplication/vnd.ms-powerpoint ppt\napplication/vnd.ms-project mpp\napplication/vnd.ms-works wcm\napplication/vnd.ms-works wdb\napplication/vnd.ms-works wks\napplication/vnd.ms-works wps\napplication/winhlp hlp\napplication/x-bcpio bcpio\napplication/x-cdf cdf\napplication/x-compress z\napplication/x-compressed tgz\napplication/x-cpio cpio\napplication/x-csh csh\napplication/x-director dcr\napplication/x-director dir\napplication/x-director dxr\napplication/x-dvi dvi\napplication/x-gtar gtar\napplication/x-gzip gz\napplication/x-hdf hdf\napplication/x-internet-signup ins\napplication/x-internet-signup isp\napplication/x-iphone iii\napplication/x-javascript js\napplication/x-latex latex\napplication/x-msaccess mdb\napplication/x-mscardfile crd\napplication/x-msclip clp\napplication/x-msdownload dll\napplication/x-msmediaview m13\napplication/x-msmediaview m14\napplication/x-msmediaview mvb\napplication/x-msmetafile wmf\napplication/x-msmoney mny\napplication/x-mspublisher pub\napplication/x-msschedule scd\napplication/x-msterminal trm\napplication/x-mswrite wri\napplication/x-netcdf cdf\napplication/x-netcdf nc\napplication/x-perfmon pma\napplication/x-perfmon pmc\napplication/x-perfmon pml\napplication/x-perfmon pmr\napplication/x-perfmon pmw\napplication/x-pkcs12 p12\napplication/x-pkcs12 pfx\napplication/x-pkcs7-certificates p7b\napplication/x-pkcs7-certificates spc\napplication/x-pkcs7-certreqresp p7r\napplication/x-pkcs7-mime p7c\napplication/x-pkcs7-mime p7m\napplication/x-pkcs7-signature p7s\napplication/x-sh sh\napplication/x-shar shar\napplication/x-shockwave-flash swf\napplication/x-stuffit sit\napplication/x-sv4cpio sv4cpio\napplication/x-sv4crc sv4crc\napplication/x-tar tar\napplication/x-tcl tcl\napplication/x-tex tex\napplication/x-texinfo texi\napplication/x-texinfo texinfo\napplication/x-troff roff\napplication/x-troff t\napplication/x-troff tr\napplication/x-troff-man man\napplication/x-troff-me me\napplication/x-troff-ms ms\napplication/x-ustar ustar\napplication/x-wais-source src\napplication/x-x509-ca-cert cer\napplication/x-x509-ca-cert crt\napplication/x-x509-ca-cert der\napplication/ynd.ms-pkipko pko\napplication/zip zip\naudio/basic au\naudio/basic snd\naudio/mid mid\naudio/mid rmi\naudio/mpeg mp3\naudio/x-aiff aif\naudio/x-aiff aifc\naudio/x-aiff aiff\naudio/x-mpegurl m3u\naudio/x-pn-realaudio ra\naudio/x-pn-realaudio ram\naudio/x-wav wav\nimage/bmp bmp\nimage/cis-cod cod\nimage/gif gif\nimage/ief ief\nimage/jpeg jpe\nimage/jpeg jpeg\nimage/jpeg jpg\nimage/pipeg jfif\nimage/svg+xml svg\nimage/tiff tif\nimage/tiff tiff\nimage/x-cmu-raster ras\nimage/x-cmx cmx\nimage/x-icon ico\nimage/x-portable-anymap pnm\nimage/x-portable-bitmap pbm\nimage/x-portable-graymap pgm\nimage/x-portable-pixmap ppm\nimage/x-rgb rgb\nimage/x-xbitmap xbm\nimage/x-xpixmap xpm\nimage/x-xwindowdump xwd\nmessage/rfc822 mht\nmessage/rfc822 mhtml\nmessage/rfc822 nws\ntext/css css\ntext/h323 323\ntext/html htm\ntext/html html\ntext/html stm\ntext/iuls uls\ntext/plain bas\ntext/plain c\ntext/plain h\ntext/plain txt\ntext/richtext rtx\ntext/scriptlet sct\ntext/tab-separated-values tsv\ntext/webviewhtml htt\ntext/x-component htc\ntext/x-setext etx\ntext/x-vcard vcf\nvideo/mpeg mp2\nvideo/mpeg mpa\nvideo/mpeg mpe\nvideo/mpeg mpeg\nvideo/mpeg mpg\nvideo/mpeg mpv2\nvideo/quicktime mov\nvideo/quicktime qt\nvideo/x-la-asf lsf\nvideo/x-la-asf lsx\nvideo/x-ms-asf asf\nvideo/x-ms-asf asr\nvideo/x-ms-asf asx\nvideo/x-msvideo avi\nvideo/x-sgi-movie movie\nx-world/x-vrml flr\nx-world/x-vrml vrml\nx-world/x-vrml wrl\nx-world/x-vrml wrz\nx-world/x-vrml xaf\nx-world/x-vrml xof\n" }, { "answer_id": 32005632, "author": "Christophe Roussy", "author_id": 657427, "author_profile": "https://Stackoverflow.com/users/657427", "pm_score": 6, "selected": false, "text": "accept=\".jpeg, .jpg, .jpe, .jfif, .jif\"\n image/jpeg .jpg .jpeg accept A file extension starting with the STOP character (U+002E). (e.g. .jpg, .png, .doc).\n A valid MIME type with no extensions.\n audio/* representing sound files. HTML5\n video/* representing video files. HTML5\n image/* representing image files. HTML5\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/691/" ]
181,222
<p>I have a script which calls <code>mysql_connect()</code> to connect to a MySQL DB. When I run the script in a browser, it works. However, when I run it from a command line I receive the following error:</p> <pre><code>Call to undefined function mysql_connect() </code></pre> <p>This seems completely paradoxical. Anyone have any ideas as how I can run it from the command line. Btw, I run it from a bash shell like so:</p> <pre><code>php /path/to/script.php </code></pre>
[ { "answer_id": 181236, "author": "Darryl Hein", "author_id": 5441, "author_profile": "https://Stackoverflow.com/users/5441", "pm_score": 4, "selected": false, "text": "php -c /etc/php.ini /path/to/script.php\n /etc/php.ini phpinfo();" }, { "answer_id": 23510870, "author": "Herr", "author_id": 288774, "author_profile": "https://Stackoverflow.com/users/288774", "pm_score": 1, "selected": false, "text": "php --ini\n Configuration File (php.ini) Path: /etc\nLoaded Configuration File: !!! THE CONFIG FILE IS MISSING HERE !!!\nScan for additional .ini files in: /Library/Server/Web/Config/php\nAdditional .ini files parsed: (none)\n Configuration File (php.ini) Path: /etc\nLoaded Configuration File: /etc/php.ini\nScan for additional .ini files in: /Library/Server/Web/Config/php\nAdditional .ini files parsed: (none)\n mysql.default_socket = /Applications/MAMP/tmp/mysql/mysql.sock\n" }, { "answer_id": 43798698, "author": "Dubbo", "author_id": 879944, "author_profile": "https://Stackoverflow.com/users/879944", "pm_score": 0, "selected": false, "text": "php -m\n extension=mysql.so\n rpm -ql php-mysql | grep mysql.so\n /usr/lib64/php/modules/mysql.so\n extension=/usr/lib64/php/modules/mysql.so\n service httpd restart \n php -m\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24059/" ]
181,225
<p>I'm looking for a reasonably fast event handling mechanism in Java to generate and handle events across different JVMs running on different hosts.</p> <p>For event handling across multiple threads in a single JVM, I found some good candidates like Jetlang. But in my search for a distributed equivalent , I couldn't find anything that was lightweight enough to offer good performance.</p> <p>Does anyone know of any implementations that fit the bill?</p> <p><strong>Edit:</strong> Putting numbers to indicate performance is a bit difficult. But for example, if you implement a heartbeating mechanism using events and the heartbeat interval is 5 seconds, the heartbeat receiver should receive a sent heartbeat within say a second or two.</p> <p>Generally, a lightweight implementation gives good performance. A event handling mechanism involving a web server or any kind of centralized hub requiring powerful hardware (definitely not lightweight) to give good performance is not what I'm looking for. </p>
[ { "answer_id": 247657, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "public class Sample implements MessageListener {\n\n public static void main(String[] args) { \n Sample sample = new Sample();\n Topic topic = Hazelcast.getTopic (\"default\"); \n topic.addMessageListener(sample); \n topic.publish (\"my-message-object\");\n } \n \n public void onMessage(Object msg) {\n System.out.println(\"Message received = \" + msg);\n } \n}\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21647/" ]
181,226
<p>I am using an authentication attribute on some of my actions in an asp.net mvc page to refer people to a login screen if they have not authenticated. My problem is returning them to the referring page after they have logged in. I was just keeping track of the referring action and referring controller but that becomes problematic when I also need to keep track of some parameters. Is there some nifty built in trick about which I don't know?</p>
[ { "answer_id": 181774, "author": "Casper", "author_id": 18729, "author_profile": "https://Stackoverflow.com/users/18729", "pm_score": 2, "selected": false, "text": "var urlReferrer = Request.UrlReferrer;\nif (urlReferrer != null)\n{\n var url = \"~\" + Server.UrlDecode(urlReferrer.PathAndQuery);\n\n // get routecollection\n var routeCollection = new RouteCollection();\n GlobalApplication.RegisterRoutes(routeCollection);\n\n // mcok context\n var context = new Mock<HttpContextBase>();\n var request = new Mock<HttpRequestBase>();\n context.Expect(ctx => ctx.Request).Returns(request.Object);\n\n // mock request\n // TODO: convert querystring to namevaluecollection\n // now it's just stripped\n if (url.IndexOf('?') > 0)\n {\n url = url.Substring(0, url.IndexOf('?'));\n }\n\n var mock = Mock.Get(context.Object.Request);\n\n // TODO: insert namevaluecollection of querystring\n mock.Expect(req => req.QueryString).Returns(new NameValueCollection());\n mock.Expect(req => req.AppRelativeCurrentExecutionFilePath).Returns(url);\n mock.Expect(req => req.PathInfo).Returns(string.Empty); \n\n // get routedata with mocked context\n var routeData = routeCollection.GetRouteData(context.Object);\n var values = routeData.Values;\n\n return RedirectToAction(routeData.Values[\"action\"].ToString(), values);\n}\n" }, { "answer_id": 181796, "author": "liggett78", "author_id": 19762, "author_profile": "https://Stackoverflow.com/users/19762", "pm_score": 3, "selected": true, "text": "http://www.mysite.com/Login?ReturnUrl=/Something\n <form action=\"Login?ReturnUrl=<%=Html.AttributeEncode(Request.QueryString[\"ReturnUrl\"]) %>\"></form>\n <form><input type=\"hidden\" name=\"ReturnUrl\" id=\"ReturnUrl\" value=\"<%=Html.AttributeEncode(Request.QueryString[\"ReturnUrl\"])\"%> /></form>\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/361/" ]
181,241
<p>Every time I use the "at" command, I get this message:</p> <pre><code>warning: commands will be executed using /bin/sh </code></pre> <p>What is it trying to warn me about? More importantly, how do I turn the warning off?</p>
[ { "answer_id": 181245, "author": "Jerub", "author_id": 14648, "author_profile": "https://Stackoverflow.com/users/14648", "pm_score": 4, "selected": false, "text": "username@hostname$ at 23:00 \nwarning: commands will be executed using /bin/sh\nat> rm **/*.pyc\nat> <EOT>\njob 1 at 2008-10-08 23:00\n" }, { "answer_id": 181252, "author": "warren", "author_id": 4418, "author_profile": "https://Stackoverflow.com/users/4418", "pm_score": 2, "selected": false, "text": "at and batch read commands from standard input or a specified file which are to be executed at a later time, using /bin/sh.\n" }, { "answer_id": 182525, "author": "Dave Sherohman", "author_id": 18914, "author_profile": "https://Stackoverflow.com/users/18914", "pm_score": 3, "selected": false, "text": "at [time] 2>/dev/null at> at [time] 2>&1 | grep -v warning at" }, { "answer_id": 55071622, "author": "Matija Nalis", "author_id": 2600099, "author_profile": "https://Stackoverflow.com/users/2600099", "pm_score": 2, "selected": false, "text": "at.c % echo \"echo blah\" | at now+30min 2>&1 | fgrep -v 'warning: commands will be executed using /bin/sh'\njob 628 at Fri Mar 8 23:25:00 2019\n ~/.zshrc ~/.profile at() {\n /usr/bin/at \"$@\" 2>&1 | fgrep -v 'warning: commands will be executed using /bin/sh'\n}\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7598/" ]
181,254
<p>If I have a style defined</p> <pre><code>.style1 { width: 140px; } </code></pre> <p>can I reference it from a second style?</p> <pre><code>.style2 { ref: .style1; } </code></pre> <p>Or is there a way via javascript/jQuery?</p> <p>--- Edit</p> <p>To clarify the problem, I am trying to apply whatever style is defined for a #x and #c to .x and .c without altering the CSS as the CSS is going to have updates that are out of my control.</p> <p>I used width but really the style would be something more complex with font, border and other style elements being specified.</p> <p>Specifying multiple class names does work when the style is being applied to a class so I'll mark existing responses as answers, but I need to take the style being applied to an id and also apply it to a class style ... if that makes any sense. </p>
[ { "answer_id": 181269, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 5, "selected": true, "text": "$('.style2').addClass ('style1');\n" }, { "answer_id": 181271, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 3, "selected": false, "text": "<p class=\"style1 style2\">stuff</p>\n .style1 {width:140px;}\n.style2 {height:140px;}\n .style1, .style2 {width: 140px;}\n.style2 {height: 140px;}\n\n<p class=\"style2\">i will have both width and height applied</p>\n" }, { "answer_id": 181273, "author": "Robert Elwell", "author_id": 23102, "author_profile": "https://Stackoverflow.com/users/23102", "pm_score": 3, "selected": false, "text": " .style1, .style2 { width: 140px; }\n" }, { "answer_id": 181317, "author": "Herb Caudill", "author_id": 239663, "author_profile": "https://Stackoverflow.com/users/239663", "pm_score": 1, "selected": false, "text": "div.FixedWidth {width:140px;}\ndiv.Style1 {whatever}\ndiv.Style2 {whatever}\n <div class=\"Style1 FixedWidth\">...</div>\n <div class=\"Style2 FixedWidth\">...</div>\n" }, { "answer_id": 865161, "author": "ajm", "author_id": 78738, "author_profile": "https://Stackoverflow.com/users/78738", "pm_score": 1, "selected": false, "text": "el = document.getElementById('someId');\nvar cStyle = '';\nfor(var i in el.style){\n if(el.style[i].length > 0){ cStyle += i + ':' + el.style[i] + ';';\n}\n$('.someClass').each(function(){ this.style.cssText = cStyle; });\n el = $('#someId');\nvar styleProps = {'border-top':true,'width':true,'height':true};\nvar cStyle = '';\nfor(var i in styleProps){\n cStyle += styleProps[i] + ':' + el.style(styleProps[i]) + ';';\n}\n$('.someClass').each(function(){ this.style.cssText = cStyle; });\n" }, { "answer_id": 19171505, "author": "joydesigner", "author_id": 1362554, "author_profile": "https://Stackoverflow.com/users/1362554", "pm_score": 2, "selected": false, "text": "// example of LESS\n\n#header {\nh1 {\n font-size: 26px;\n font-weight: bold;\n }\np { font-size: 12px;\n a { text-decoration: none;\n &:hover { border-width: 1px }\n }\n }\n}\n\n\n/* Compiled CSS */\n\n#header h1 {\n font-size: 26px;\n font-weight: bold;\n}\n#header p {\n font-size: 12px;\n}\n#header p a {\n text-decoration: none;\n}\n#header p a:hover {\n border-width: 1px;\n}\n" }, { "answer_id": 30131315, "author": "Mark Manning", "author_id": 928121, "author_profile": "https://Stackoverflow.com/users/928121", "pm_score": 0, "selected": false, "text": "<html><head><title>Test</title><style>\n.a { font-size: 12pt; }\n.b { font-size: 24pt; }\n.c { b }\n</style></head><body>\n<span class='c'>This is a test</span></body></html>\n <html><head><title>Test</title><style>\n.a { font-size: 12pt; }\n.b,.c { font-size: 24pt; }\n</style></head><body>\n<span class='c'>This is a test</span></body></html>\n <html>\n<head>\n<title>Test</title>\n<style>\n.a { font-size: 12pt; }\n.b,.c { font-size: 24pt; }\n.d { font-weight: normal; }\n.e,.c { font-weight: bold; }\n.f { font-family: times; }\n.g,.c { font-family: Arial; }\n</style>\n</head>\n<body>\n<span class='c'>This is a test</span>\n</body>\n</html>\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25372/" ]
181,268
<p>I have a simple iphone app that's based on the CrashLanding sample app. So basically you tap the title screen and do some stuff... all on the same "view". I want to add an "options" screen/page/view whatever with a few UISwitches. What's the easiest way to do this?</p> <p>Cheers!</p>
[ { "answer_id": 181327, "author": "fmsf", "author_id": 26004, "author_profile": "https://Stackoverflow.com/users/26004", "pm_score": 2, "selected": true, "text": "@implementation myOptions\n\n-(void)awakeFromNib\n{\n...\n @implementation previousController\n-(void)awakeFromNib\n{\n menuList = [[NSMutableArray alloc] init];\n QuartzViewController *controller;\n\n controller = [[QuartzViewController alloc] initWithTitle:@\"Options\"];\n controller.quartzViewDelegate = [[[myOptions alloc] init] autorelease];\n [menuList addObject:controller];\n [controller release];\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22471/" ]
181,272
<p>When we execute <code>select count(*) from table_name</code> it returns the number of rows.</p> <p>What does <code>count(1)</code> do? What does <code>1</code> signify here? Is this the same as <code>count(*)</code> (as it gives the same result on execution)?</p>
[ { "answer_id": 181280, "author": "ChrisHDog", "author_id": 25719, "author_profile": "https://Stackoverflow.com/users/25719", "pm_score": 3, "selected": false, "text": "SELECT * FROM table_name and SELECT 1 FROM table_name. \n SELECT 1 FROM table_name\n count(*) count(1) count(8) count(column_name)" }, { "answer_id": 181281, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 3, "selected": false, "text": "COUNT(1) COUNT(0) COUNT(42) NULL" }, { "answer_id": 181287, "author": "Thilo", "author_id": 14955, "author_profile": "https://Stackoverflow.com/users/14955", "pm_score": 3, "selected": false, "text": "SELECT COUNT(1) from <table name>\n SELECT COUNT(*) from <table name>\n SELECT COUNT(*) SELECT COUNT(col_name) from <table name>\n" }, { "answer_id": 181297, "author": "Johann Zacharee", "author_id": 24290, "author_profile": "https://Stackoverflow.com/users/24290", "pm_score": 0, "selected": false, "text": "select count(1) from random_table; select count(*) from random_table" }, { "answer_id": 22786558, "author": "Vikas Kumar", "author_id": 3485157, "author_profile": "https://Stackoverflow.com/users/3485157", "pm_score": 2, "selected": false, "text": "create table test1(\n id number,\n name varchar2(20)\n);\n\ninsert into test1 values (1,'abc');\ninsert into test1 values (1,'abc');\n\nselect * from test1;\nselect count(*) from test1;\nselect count(1) from test1;\nselect count(ALL 1) from test1;\nselect count(DISTINCT 1) from test1;\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11614/" ]
181,279
<p>How does TCP/IP report errors when packet delivery fails permanently? All Socket.write() APIs I've seen simply pass bytes to the underlying TCP/IP output buffer and transfer the data asynchronously. How then is TCP/IP supposed to notify the developer if packet delivery fails permanently (i.e. the destination host is no longer reachable)?</p> <p>Any protocol that requires the sender to wait for confirmation from the remote end will get an error message. But what happens for protocols where a sender doesn't have to read any bytes from the destination? Does TCP/IP just fail silently? Perhaps Socket.close() will return an error? Does the TCP/IP specification say anything about this?</p>
[ { "answer_id": 181293, "author": "ephemient", "author_id": 20713, "author_profile": "https://Stackoverflow.com/users/20713", "pm_score": 2, "selected": false, "text": "shutdown close" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14731/" ]
181,284
<p>I've read somewhere that functional programming is suitable to take advantage of multi-core trend in computing. I didn't really get the idea. Is it related to the lambda calculus and von neumann architecture?</p>
[ { "answer_id": 181296, "author": "DGentry", "author_id": 4761, "author_profile": "https://Stackoverflow.com/users/4761", "pm_score": 3, "selected": false, "text": "a = foo(b, c);\nd = bar(e, f);\n" }, { "answer_id": 181302, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 4, "selected": false, "text": "map() reduce()" }, { "answer_id": 3128763, "author": "J D", "author_id": 13924, "author_profile": "https://Stackoverflow.com/users/13924", "pm_score": 3, "selected": false, "text": "Parallel.For System.Threading.Tasks" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17685/" ]
181,285
<p>Is it a problem if you use the global keyword on variables you don't end up using? Compare:</p> <pre><code>function foo() { global $fu; global $bah; if (something()) { $fu-&gt;doSomething(); } else { $bah-&gt;doSomething(); } } function bar() { if (something()) { global $fu; $fu-&gt;doSomething(); } else { global $bah; $bah-&gt;doSomething(); } } </code></pre> <p>I'm quite aware that using the second method makes maintaining this code much harder, and that it's generally preferred to put all your globals at the start of functions, so: <strong>Ignoring the difference in maintainability and code-styling of the two functions, is there a difference between these two in terms of overhead?</strong></p>
[ { "answer_id": 181290, "author": "Matthew Scharley", "author_id": 15537, "author_profile": "https://Stackoverflow.com/users/15537", "pm_score": 4, "selected": true, "text": "bar()" }, { "answer_id": 181472, "author": "Darryl Hein", "author_id": 5441, "author_profile": "https://Stackoverflow.com/users/5441", "pm_score": 0, "selected": false, "text": "function foo() {\n global $fu, $bah;\n if (something()) {\n $fu->doSomething();\n } else {\n $bah->doSomething();\n }\n}\n" }, { "answer_id": 182123, "author": "troelskn", "author_id": 18180, "author_profile": "https://Stackoverflow.com/users/18180", "pm_score": -1, "selected": false, "text": "function foo($fu, $bah) {\n if (something()) {\n $fu->doSomething();\n } else {\n $bah->doSomething();\n }\n}\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
181,309
<p>In a nutshell, there's a global stylesheet:</p> <pre><code>a { font-family: Arial; } </code></pre> <p>I want to use a different font family for a particular link:</p> <pre><code>&lt;a href="..." style="font-family: Helvetica;"&gt;...&lt;/a&gt; </code></pre> <p>or</p> <pre><code>&lt;span style="font-family: Helvetica;"&gt;&lt;a href="..."&gt;...&lt;/a&gt;&lt;/span&gt; </code></pre> <p>but nothing works. Is there an easy way to do this?</p> <p>P.S. I'm dynamically (via PHP) assign different fonts to different links, so creating a special class is not an option.</p>
[ { "answer_id": 181336, "author": "Kip", "author_id": 18511, "author_profile": "https://Stackoverflow.com/users/18511", "pm_score": 3, "selected": false, "text": "a { font-family: Arial; }\na .noticed { font-family: Helvetica; }\n <a class=\"noticed\" href=\"...\">...</a>\n <font>" }, { "answer_id": 181358, "author": "Herb Caudill", "author_id": 239663, "author_profile": "https://Stackoverflow.com/users/239663", "pm_score": 3, "selected": false, "text": " <a href=\"...\" style=\"font-family: Helvetica;\">...</a>\n div a a" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17216/" ]
181,313
<p>Is there a command within the bash shell of fedora that will give me the currently assigned IP address?</p>
[ { "answer_id": 1967327, "author": "incognitus", "author_id": 239315, "author_profile": "https://Stackoverflow.com/users/239315", "pm_score": 0, "selected": false, "text": "ipconfig getifaddr eth0\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13930/" ]
181,341
<p>At my workplace, the traffic blocker/firewall has been getting progressively worse. I can't connect to my home machine on port 22, and lack of ssh access makes me sad. I was previously able to use SSH by moving it to port 5050, but I think some recent filters now treat this traffic as IM and redirect it through another proxy, maybe. That's my best guess; in any case, my ssh connections now terminate before I get to log in.</p> <p>These days I've been using Ajaxterm over HTTPS, as port 443 is still unmolested, but this is far from ideal. (Sucky terminal emulation, lack of port forwarding, my browser leaks memory at an amazing rate...) I tried setting up <code>mod_proxy_connect</code> on top of <code>mod_ssl</code>, with the idea that I could send a <code>CONNECT localhost:22 HTTP/1.1</code> request through HTTPS, and then I'd be all set. Sadly, this seems to not work; the HTTPS connection works, up until I finish sending my request; then SSL craps out. It appears as though <code>mod_proxy_connect</code> takes over the whole connection instead of continuing to pipe through <code>mod_ssl</code>, confusing the heck out of the HTTPS client.</p> <p>Is there a way to get this to work? I don't want to do this over plain HTTP, for several reasons:</p> <ul> <li>Leaving a big fat open proxy like that just stinks</li> <li>A big fat open proxy is not good over HTTPS either, but with authentication required it feels fine to me</li> <li>HTTP goes through a proxy -- I'm not <em>too</em> concerned about my traffic being sniffed, as it's ssh that'll be going "plaintext" through the tunnel -- but it's a lot more likely to be mangled than HTTPS, which fundamentally cannot be proxied</li> </ul> <p>Requirements:</p> <ul> <li>Must work over port 443, without disturbing other HTTPS traffic (i.e. I can't just put the ssh server on port 443, because I would no longer be able to serve pages over HTTPS)</li> <li>I have or can write a simple port forwarder client that runs under Windows (or Cygwin)</li> </ul> <h2>Edit</h2> <p><a href="http://dag.wieers.com/howto/ssh-http-tunneling/" rel="noreferrer">DAG: Tunnelling SSH over HTTP(S)</a> has been pointed out to me, but it doesn't help: at the end of the article, they mention <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=29744" rel="noreferrer">Bug 29744 - CONNECT does not work over existing SSL connection</a> preventing tunnelling over HTTPS, exactly the problem I was running into. At this point, I am probably looking at some CGI script, but I don't want to list that as a requirement if there's better solutions available.</p>
[ { "answer_id": 185365, "author": "Alexander", "author_id": 16724, "author_profile": "https://Stackoverflow.com/users/16724", "pm_score": 4, "selected": true, "text": "CONNECT stunnel" }, { "answer_id": 185414, "author": "Brian", "author_id": 8959, "author_profile": "https://Stackoverflow.com/users/8959", "pm_score": 3, "selected": false, "text": "iptables -t nat -A PREROUTING -p tcp -s 111.111.111.111 --dport 443 -j REDIRECT --to-port 22" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181341", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20713/" ]
181,342
<p>What is the best way to automatically install an MSI file or installer .exe? We want to do some automated testing from our build system on the installed copy of the product. Our installer has the usual license acceptance screen, install location, etc.</p> <hr> <p>As FryHard pointed out there are two options in particular that seem handy:</p> <ul> <li>"/quiet" - no use interaction</li> <li>"/passive" - process bar only, unattended mode</li> </ul>
[ { "answer_id": 181365, "author": "FryHard", "author_id": 231, "author_profile": "https://Stackoverflow.com/users/231", "pm_score": 4, "selected": false, "text": "Myproduct.MSI /?\n" }, { "answer_id": 181434, "author": "Franci Penov", "author_id": 17028, "author_profile": "https://Stackoverflow.com/users/17028", "pm_score": 6, "selected": true, "text": "msiexec.exe /qn /i mypackage.msi\n msiexec.exe /qn /i mypackage.msi ISDEBUG=1 msiexec.exe /qn /x mypackage.msi\n msiexec.exe /qn /x {B741B8A3-8DCB-44E0-B06F-2A11F56572DB}\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18437/" ]
181,344
<p>We get sometimes the following error from our partner's database:</p> <pre><code>&lt;i&gt;ORA-01438: value larger than specified precision allows for this column&lt;/i&gt; </code></pre> <p>The full response looks like the following:</p> <pre><code>&lt;?xml version="1.0" encoding="windows-1251"?&gt; &lt;response&gt; &lt;status_code&gt;&lt;/status_code&gt; &lt;error_text&gt;ORA-01438: value larger than specified precision allows for this column ORA-06512: at &amp;quot;UMAIN.PAY_NET_V1_PKG&amp;quot;, line 176 ORA-06512: at line 1&lt;/error_text&gt; &lt;pay_id&gt;5592988&lt;/pay_id&gt; &lt;time_stamp&gt;&lt;/time_stamp&gt; &lt;/response&gt; </code></pre> <p>What can be the cause for this error?</p>
[ { "answer_id": 2741455, "author": "Gary Myers", "author_id": 25714, "author_profile": "https://Stackoverflow.com/users/25714", "pm_score": 4, "selected": false, "text": "select cast (10 as number(1,2)) from dual\n *\nERROR at line 1:\nORA-01438: value larger than specified precision allowed for this column\n\nselect cast (15.33 as number(3,2)) from dual\n *\nERROR at line 1:\nORA-01438: value larger than specified precision allowed for this column\n select cast (5.33333333 as number(3,2)) from dual;\nCAST(5.33333333ASNUMBER(3,2))\n-----------------------------\n 5.33\n" }, { "answer_id": 2741885, "author": "gokhant", "author_id": 48479, "author_profile": "https://Stackoverflow.com/users/48479", "pm_score": 1, "selected": false, "text": "v_departmentid departments.department_id%TYPE;\n v_departmentid NUMBER(4)\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181344", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11104/" ]
181,348
<p>Let me start with a specific example of what I'm trying to do.</p> <p>I have an array of year, month, day, hour, minute, second and millisecond components in the form <code>[ 2008, 10, 8, 00, 16, 34, 254 ]</code>. I'd like to instantiate a Date object using the following standard constructor:</p> <pre><code>new Date(year, month, date [, hour, minute, second, millisecond ]) </code></pre> <p>How can I pass my array to this constructor to get a new Date instance? <em>[ <strong>Update</strong>: My question actually extends beyond this specific example. I'd like a general solution for built-in JavaScript classes like Date, Array, RegExp, etc. whose constructors are beyond my reach. ]</em></p> <p>I'm trying to do something like the following:</p> <pre><code>var comps = [ 2008, 10, 8, 00, 16, 34, 254 ]; var d = Date.prototype.constructor.apply(this, comps); </code></pre> <p>I probably need a "<code>new</code>" in there somewhere. The above just returns the current time as if I had called "<code>(new Date()).toString()</code>". I also acknowledge that I may be completely in the wrong direction with the above :)</p> <p><strong><em>Note</strong>: No <code>eval()</code> and no accessing the array items one by one, please. I'm pretty sure I should be able to use the array as is.</em></p> <hr> <h2>Update: Further Experiments</h2> <p>Since no one has been able to come up with a working answer yet, I've done more playing around. Here's a new discovery.</p> <p>I can do this with my own class:</p> <pre><code>function Foo(a, b) { this.a = a; this.b = b; this.toString = function () { return this.a + this.b; }; } var foo = new Foo(1, 2); Foo.prototype.constructor.apply(foo, [4, 8]); document.write(foo); // Returns 12 -- yay! </code></pre> <p>But it doesn't work with the intrinsic Date class:</p> <pre><code>var d = new Date(); Date.prototype.constructor.call(d, 1000); document.write(d); // Still returns current time :( </code></pre> <p>Neither does it work with Number:</p> <pre><code>var n = new Number(42); Number.prototype.constructor.call(n, 666); document.write(n); // Returns 42 </code></pre> <p>Maybe this just isn't possible with intrinsic objects? I'm testing with Firefox BTW.</p>
[ { "answer_id": 181680, "author": "AnthonyWJones", "author_id": 17516, "author_profile": "https://Stackoverflow.com/users/17516", "pm_score": 3, "selected": false, "text": "function writeLn(s)\n{\n //your code to write a line to stdout\n WScript.Echo(s)\n}\n\nvar a = [ 2008, 10, 8, 00, 16, 34, 254 ]\n\nvar d = NewDate.apply(null, a)\n\nfunction NewDate(year, month, date, hour, minute, second, millisecond)\n{\n return new Date(year, month, date, hour, minute, second, millisecond);\n}\n\nwriteLn(d)\n return this function Target(x , y) { this.x = x, this.y = y; return this; }\n var x = Target.apply({}, [1, 2]);\n var n = {};\nTarget.prototype = n;\nvar x = Target.apply({}, [1, 2]);\nvar b = n.isPrototypeOf(x); // returns false\nvar y = new Target(3, 4);\nb = n.isPrototypeOf(y); // returns true\n" }, { "answer_id": 184640, "author": "harley.333", "author_id": 26259, "author_profile": "https://Stackoverflow.com/users/26259", "pm_score": -1, "selected": false, "text": "var comps = [ 2008, 10, 8, 00, 16, 34, 254 ];\nvar d = eval(\"new Date(\" + comps.join(\",\") + \");\");\n" }, { "answer_id": 217042, "author": "Ates Goral", "author_id": 23501, "author_profile": "https://Stackoverflow.com/users/23501", "pm_score": 7, "selected": true, "text": "static JSBool\nDate(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)\n{\n jsdouble *date;\n JSString *str;\n jsdouble d;\n\n /* Date called as function. */\n if (!(cx->fp->flags & JSFRAME_CONSTRUCTING)) {\n int64 us, ms, us2ms;\n jsdouble msec_time;\n\n /* NSPR 2.0 docs say 'We do not support PRMJ_NowMS and PRMJ_NowS',\n * so compute ms from PRMJ_Now.\n */\n us = PRMJ_Now();\n JSLL_UI2L(us2ms, PRMJ_USEC_PER_MSEC);\n JSLL_DIV(ms, us, us2ms);\n JSLL_L2D(msec_time, ms);\n\n return date_format(cx, msec_time, FORMATSPEC_FULL, rval);\n }\n\n /* Date called as constructor. */\n // ... (from here on it checks the arg count to decide how to create the date)\n Date() Date.prototype.constructor() alert(Date()); // Returns \"Thu Oct 09 2008 23:15:54 ...\"\nalert(typeof Date()); // Returns \"string\"\n\nalert(Date(42)); // Same thing, \"Thu Oct 09 2008 23:15:54 ...\"\nalert(Date(2008, 10, 10)); // Ditto\nalert(Date(null)); // Just doesn't care\n /* Set the value of the Date.prototype date to NaN */\n proto_date = date_constructor(cx, proto);\n if (!proto_date)\n return NULL;\n *proto_date = *cx->runtime->jsNaN;\n Date.prototype NaN alert(Date.prototype); // Always returns \"Invalid Date\"\n // on Firefox, Opera, Safari, Chrome\n // but not Internet Explorer\n -1 Date(…) new Date(…) (new Date()).toString()" }, { "answer_id": 767062, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "function GeneratedConstructor (methodName, argumentCount) {\n var params = []\n\n for (var i = 0; i < argumentCount; i++) {\n params.push(\"arguments[\" + i + \"]\")\n }\n\n var code = \"return new \" + methodName + \"(\" + params.join(\",\") + \")\"\n\n var ctor = new Function(code)\n\n this.createObject = function (params) {\n return ctor.apply(this, params)\n }\n}\n var dateConstructor = new GeneratedConstructor(\"Date\", 3)\ndateConstructor.createObject( [ 1982, 03, 23 ] )\n" }, { "answer_id": 1168058, "author": "Cowboy Ben Alman", "author_id": 142339, "author_profile": "https://Stackoverflow.com/users/142339", "pm_score": 4, "selected": false, "text": "var arr = [ 2009, 6, 22, 10, 30, 9 ]; var d = new Date( arr[0], arr[1], arr[2], arr[3], arr[4], arr[5] ); var d = new Date( Date.UTC.apply( window, arr ) + ( (new Date()).getTimezoneOffset() * 60000 ) );" }, { "answer_id": 2278664, "author": "Claudiu", "author_id": 15055, "author_profile": "https://Stackoverflow.com/users/15055", "pm_score": 0, "selected": false, "text": "var newwrapper = function (constr, args) {\n var argHolder = {\"c\": constr};\n for (var i=0; i < args.length; i++) {\n argHolder[\"$\" + i] = args[i];\n }\n\n var newStr = \"new (argHolder['c'])(\";\n for (var i=0; i < args.length; i++) {\n newStr += \"argHolder['$\" + i + \"']\";\n if (i != args.length - 1) newStr += \", \";\n }\n newStr += \");\";\n\n return eval(newStr);\n}\n function Point(x,y) {\n this.x = x;\n this.y = y;\n}\nvar p = __new(Point, [10, 20]);\nalert(p.x); //10\nalert(p instanceof Point); //true\n" }, { "answer_id": 5556039, "author": "Michael Ficarra", "author_id": 693451, "author_profile": "https://Stackoverflow.com/users/693451", "pm_score": -1, "selected": false, "text": "var F = function(){};\nF.prototype = Date.prototype;\nvar d = new F();\nDate.apply(d, comps);\n" }, { "answer_id": 11762669, "author": "Quadroid", "author_id": 1279497, "author_profile": "https://Stackoverflow.com/users/1279497", "pm_score": -1, "selected": false, "text": "function createInstance(Constructor, args){\n var TempConstructor = function(){};\n TempConstructor.prototype = Constructor.prototype;\n var instance = new TempConstructor;\n var ret = Constructor.apply(instance, args);\n return ret instanceof Object ? ret : instance;\n}\n\nconsole.log( createInstance(Date, [2008, 10, 8, 00, 16, 34, 254]) )\n" }, { "answer_id": 14376325, "author": "kybernetikos", "author_id": 412335, "author_profile": "https://Stackoverflow.com/users/412335", "pm_score": 2, "selected": false, "text": "function applyToConstructor(constructor, argArray) {\n var args = [null].concat(argArray);\n var factoryFunction = constructor.bind.apply(constructor, args);\n return new factoryFunction();\n}\n\nvar d = applyToConstructor(Date, [2008, 10, 8, 00, 16, 34, 254]);\n this" }, { "answer_id": 31047577, "author": "ZERONETA", "author_id": 5048404, "author_profile": "https://Stackoverflow.com/users/5048404", "pm_score": 0, "selected": false, "text": "function gettime()\n{\n var q = new Date;\n arguments.length && q.setTime( ( arguments.length === 1\n ? typeof arguments[0] === 'number' ? arguments[0] : Date.parse( arguments[0] )\n : Date.UTC.apply( null, arguments ) ) + q.getTimezoneOffset() * 60000 );\n return q;\n};\n\ngettime(2003,8,16)\n\ngettime.apply(null,[2003,8,16])\n" }, { "answer_id": 49437744, "author": "Wysher", "author_id": 9537039, "author_profile": "https://Stackoverflow.com/users/9537039", "pm_score": 1, "selected": false, "text": "const arr = [2018, 6, 15, 12, 30, 30, 500];\nconst date = new Date(...arr);\n\nconsole.log(date);\n" }, { "answer_id": 51645182, "author": "Scott Rudiger", "author_id": 8550747, "author_profile": "https://Stackoverflow.com/users/8550747", "pm_score": 2, "selected": false, "text": "var comps = [ 2008, 10, 8, 00, 16, 34, 254 ];\n\n// with the spread operator\nvar d1 = new Date(...comps);\n\n// with Reflect.construct\nvar d2 = Reflect.construct(Date, comps);\n\nconsole.log('d1:', d1, '\\nd2:', d2);\n// or more readable:\nconsole.log(`d1: ${d1}\\nd2: ${d2}`);" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23501/" ]
181,354
<p>In a Test project in Visual Studio 2008 (Pro), I created a Test project, and I want to configure the project properties to give a command line argument to the tests. I set the properties, but then realized I have no idea how to actually use the argument. </p> <p>How do you get the arguments from MSTest?</p>
[ { "answer_id": 181404, "author": "JTew", "author_id": 25372, "author_profile": "https://Stackoverflow.com/users/25372", "pm_score": 2, "selected": true, "text": "mytest.dll\nmytest.dll.config\nlib.dll\nlib.dll.config\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3279/" ]
181,356
<p>What am I doing wrong here?</p> <pre><code>string q = "john s!"; string clean = Regex.Replace(q, @"([^a-zA-Z0-9]|^\s)", string.Empty); // clean == "johns". I want "john s"; </code></pre>
[ { "answer_id": 181371, "author": "John Sheehan", "author_id": 1786, "author_profile": "https://Stackoverflow.com/users/1786", "pm_score": 4, "selected": false, "text": "string clean = Regex.Replace(q, @\"[^a-zA-Z0-9\\s]\", string.Empty);\n" }, { "answer_id": 6628211, "author": "Evolved", "author_id": 766028, "author_profile": "https://Stackoverflow.com/users/766028", "pm_score": 5, "selected": false, "text": "string clean = Regex.Replace(dirty, \"[^a-zA-Z0-9\\x20]\", String.Empty);\n" }, { "answer_id": 6794263, "author": "Tim", "author_id": 181971, "author_profile": "https://Stackoverflow.com/users/181971", "pm_score": 7, "selected": true, "text": "string clean = Regex.Replace(q, @\"[^a-zA-Z0-9\\s]\", string.Empty);\n string clean = Regex.Replace(q, @\"[^\\w\\s]\", string.Empty);\n" }, { "answer_id": 13050834, "author": "vivek", "author_id": 1771426, "author_profile": "https://Stackoverflow.com/users/1771426", "pm_score": 3, "selected": false, "text": "Regex r = new Regex(\"^[a-zA-Z\\\\s]+\");\nr.IsMatch(textbox1.text);\n" }, { "answer_id": 50996740, "author": "zamoldar", "author_id": 1036639, "author_profile": "https://Stackoverflow.com/users/1036639", "pm_score": 1, "selected": false, "text": " string input = \"78-selim güzel667.,?\";\n Regex regex = new Regex(@\"[^\\w\\x20]|[\\d]\");\n var result= regex.Replace(input,\"\");\n //selim güzel\n" }, { "answer_id": 69391878, "author": "Paramjot Singh", "author_id": 11849033, "author_profile": "https://Stackoverflow.com/users/11849033", "pm_score": 0, "selected": false, "text": "string comparer = \"string you want to compare\";\nRegex r = new Regex(@\"^([a-zA-Z0-9]+[_\\s-]*)+$\");\n\nif (!r.IsMatch(comparer))\n{\n return false;\n} \nreturn true;\n [a-zA-Z0-9]+ comparer [_\\s-]* comparer ([a-zA-Z0-9]+[_\\s-]*)+ comparer" }, { "answer_id": 71333785, "author": "Waseem Raja Khan", "author_id": 18361896, "author_profile": "https://Stackoverflow.com/users/18361896", "pm_score": 0, "selected": false, "text": "[RegularExpression(@\"^[A-Z]+[a-zA-Z\"\"'\\s-]*$\")]\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1786/" ]
181,374
<p>I have a .net app that I've written in c#. On some forms I frequent update the display fields. In some cases every field on the form (textboxes, labels, picturebox, etc) has its value changed. Plus the frequency of the changes could possibly be every second. However, currently there is a horrible flickering everytime the form is updated. How can I stop the flickering? Is there a way to maybe double buffer? Please help! </p>
[ { "answer_id": 181384, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 3, "selected": false, "text": "SetStyle(ControlStyles.OptimizedDoubleBuffer, true);\n" }, { "answer_id": 213017, "author": "Brian Hasden", "author_id": 28926, "author_profile": "https://Stackoverflow.com/users/28926", "pm_score": 3, "selected": false, "text": "SetStyle(ControlStyles.UserPaint, true);\nSetStyle(ControlStyles.AllPaintingInWmPaint, true); \nSetStyle(ControlStyles.DoubleBuffer, true); \n" }, { "answer_id": 1028847, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "protected override void OnPaintBackground(PaintEventArgs e) \n{\n}\n" }, { "answer_id": 6512181, "author": "John Suit", "author_id": 416752, "author_profile": "https://Stackoverflow.com/users/416752", "pm_score": 2, "selected": false, "text": "protected override CreateParams CreateParams\n{\n get\n {\n CreateParams cp = base.CreateParams;\n cp.ExStyle |= 0x02000000; //WS_EX_COMPOSITED\n return cp;\n }\n}\n int intOriginalExStyle = -1;\nbool bEnableAntiFlicker = true;\n\npublic Form1()\n{\n ToggleAntiFlicker(false);\n InitializeComponent();\n this.ResizeBegin += new EventHandler(Form1_ResizeBegin);\n this.ResizeEnd += new EventHandler(Form1_ResizeEnd);\n}\n\nprotected override CreateParams CreateParams\n{\n get\n {\n if (intOriginalExStyle == -1)\n {\n intOriginalExStyle = base.CreateParams.ExStyle;\n }\n CreateParams cp = base.CreateParams;\n\n if (bEnableAntiFlicker)\n {\n cp.ExStyle |= 0x02000000; //WS_EX_COMPOSITED\n }\n else\n {\n cp.ExStyle = intOriginalExStyle;\n }\n\n return cp;\n }\n} \n\nprivate void Form1_ResizeBegin(object sender, EventArgs e)\n{\n ToggleAntiFlicker(true);\n}\n\nprivate void Form1_ResizeEnd(object sender, EventArgs e)\n{\n ToggleAntiFlicker(false);\n}\n\nprivate void ToggleAntiFlicker(bool Enable)\n{\n bEnableAntiFlicker = Enable;\n //hacky, but works\n this.MaximizeBox = true;\n}\n" }, { "answer_id": 6724577, "author": "Josip Medved", "author_id": 144245, "author_profile": "https://Stackoverflow.com/users/144245", "pm_score": 2, "selected": false, "text": "internal class DoubleBufferedListView : ListView {\n\n public DoubleBufferedListView()\n : base() {\n this.DoubleBuffered = true;\n }\n\n}\n listView1.GetType().GetProperty(\"DoubleBuffered\", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(lsvReport, true, null);\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
181,406
<p>I have been using Ruby for a while now and I find, for bigger projects, it can take up a fair amount of memory. What are some best practices for reducing memory usage in Ruby?</p> <ul> <li>Please, let each answer have one "best practice" and let the community vote it up.</li> </ul>
[ { "answer_id": 181445, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 5, "selected": true, "text": "def method(x)\n x.split( doesn't matter what the args are )\nend\n def method(x)\n x.gsub( doesn't matter what the args are )\nend\n" }, { "answer_id": 3764991, "author": "Alex Kovshovik", "author_id": 115680, "author_profile": "https://Stackoverflow.com/users/115680", "pm_score": 5, "selected": false, "text": "students.each do |student|\n cloned_student = student.clone\n ...\n cloned_student.books.detect {...}\n ca_teachers = cloned_student.teachers.detect {|teacher| teacher.address.state == 'CA'}\n ca_teachers.blah_blah\n ...\n # Not sure if the following is necessary, but we have it just in case...\n cloned_student = nil\nend\n students.each do |student|\n loop_student = Student.find(student.id) # just re-find the record into local variable.\n ...\n loop_student.books.detect {...}\n ca_teachers = loop_student.teachers.detect {|teacher| teacher.address.state == 'CA'}\n ca_teachers.blah_blah\n ...\nend\n" }, { "answer_id": 39688765, "author": "Joshua Arvin Lat", "author_id": 4765343, "author_profile": "https://Stackoverflow.com/users/4765343", "pm_score": 0, "selected": false, "text": "$ gem install busy-administrator\n require 'busy-administrator'\n\ndata = BusyAdministrator::ExampleGenerator.generate_string_with_specified_memory_size(10.mebibytes)\n\nputs BusyAdministrator::MemorySize.of(data)\n# => 10 MiB\n require 'busy-administrator'\n\nresults = BusyAdministrator::MemoryUtils.profile(gc_enabled: false) do |analyzer|\n BusyAdministrator::ExampleGenerator.generate_string_with_specified_memory_size(10.mebibytes)\nend \n\nBusyAdministrator::Display.debug(results)\n {\n memory_usage:\n {\n before: 12 MiB\n after: 22 MiB\n diff: 10 MiB\n }\n total_time: 0.406452\n gc:\n {\n count: 0\n enabled: false\n }\n specific:\n {\n }\n object_count: 151\n general:\n {\n String: 10 MiB\n Hash: 8 KiB\n BusyAdministrator::MemorySize: 0 Bytes\n Process::Status: 0 Bytes\n IO: 432 Bytes\n Array: 326 KiB\n Proc: 72 Bytes\n RubyVM::Env: 96 Bytes\n Time: 176 Bytes\n Enumerator: 80 Bytes\n }\n}\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5004/" ]
181,408
<p>What is the best way to write bytes in the middle of a file using Java?</p>
[ { "answer_id": 181416, "author": "anjanb", "author_id": 11142, "author_profile": "https://Stackoverflow.com/users/11142", "pm_score": 3, "selected": false, "text": "RandomAccessFile" }, { "answer_id": 185076, "author": "jjnguy", "author_id": 2598, "author_profile": "https://Stackoverflow.com/users/2598", "pm_score": 6, "selected": true, "text": "RandomAccessFile RandomAccessFile InputStream OutputStream File bytes public static void aMethod(){\n RandomAccessFile f = new RandomAccessFile(new File(\"whereDidIPutTHatFile\"), \"rw\");\n long aPositionWhereIWantToGo = 99;\n f.seek(aPositionWhereIWantToGo); // this basically reads n bytes in the file\n f.write(\"Im in teh fil, writn bites\".getBytes());\n f.close();\n}\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181408", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2598/" ]
181,413
<p>Before I begin, I want to clarify that this is not a command-line tool, but an application that accepts commands through it's own command-line interface.</p> <p><strong>Edit:</strong> I must apologize about my explanation from before, apparently I didn't do a very good job at explaining it. One more time...</p> <p>I am building a command-line interface application that accepts commands from a user. I have a signal handler setup to catch the signals, which then sets a flag that I need to terminate the application. The problem I'm having is all of the console functions I can find are blocking, which means that I can't detect that I need to exit from my console processing loop until the user presses a key (or enter, depending on the function).</p> <p>Is there some standard way I can do either non-block console interaction, or is there an elegant way to structure the program so that if I just terminate from the signal thread, that everything will be handled and released properly (please don't mis-understand this, I know how this could be done using locking and releasing the resources from the signaling thread, but this could get messy, so I'd rather avoid it)</p> <p>Hopefully that explanation makes more sense...</p>
[ { "answer_id": 181428, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 3, "selected": false, "text": "signal \n#include <signal.h>\n\nvoid signal_handler(int sig)\n{\n // Handle the signal\n}\n\nint main(void)\n{\n // Register the signal handler for the SIGINT signal (Ctrl+C)\n signal(SIGINT, signal_handler);\n ...\n}\n" }, { "answer_id": 181460, "author": "terson", "author_id": 22974, "author_profile": "https://Stackoverflow.com/users/22974", "pm_score": 1, "selected": false, "text": "int main(void)\n{\n // Register to ignore the SIGINT signal (Ctrl+C)\n signal(SIGINT, SIG_IGN);\n\n while(1)\n {\n retval = my_blocking_io_func();\n if(retval == -1 && errno == EINTR)\n {\n // do whatever you want to do in case of interrupt\n }\n }\n}\n" }, { "answer_id": 181594, "author": "fizzer", "author_id": 18167, "author_profile": "https://Stackoverflow.com/users/18167", "pm_score": 3, "selected": false, "text": "#include <csignal>\n#include <iostream>\n#include <ostream>\n#include <string>\nusing namespace std;\n\nnamespace\n{\n volatile sig_atomic_t quit;\n\n void signal_handler(int sig)\n {\n signal(sig, signal_handler);\n quit = 1;\n }\n}\n\nint main()\n{\n signal(SIGINT, signal_handler);\n signal(SIGTERM, signal_handler);\n#ifdef SIGBREAK\n signal(SIGBREAK, signal_handler);\n#endif\n /* etc */\n\n while (!quit)\n {\n string s;\n cin >> s;\n cout << s << endl;\n }\n cout << \"quit = \" << quit << endl;\n}\n" }, { "answer_id": 18593683, "author": "KyleL", "author_id": 804775, "author_profile": "https://Stackoverflow.com/users/804775", "pm_score": 0, "selected": false, "text": "sigset_t waitset;\nsigemptyset(&waitset);\nsigaddset(&waitset, SIGINT);\nsigaddset(&waitset, SIGTERM);\nsigaddset(&waitset, SIGPIPE);\npthread_sigmask(SIG_BLOCK, &waitset, NULL); \n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16313/" ]
181,426
<p>I'm making a Stored Procedure that basically concatenates a long string with data from many records.</p> <p>I want to do:</p> <pre><code>set @output = @output + 'aaa' + LINEBREAK </code></pre> <p>How do I specify that line break?</p>
[ { "answer_id": 181430, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 6, "selected": true, "text": "DECLARE @LINEBREAK AS varchar(2)\nSET @LINEBREAK = CHAR(13) + CHAR(10)\n" }, { "answer_id": 181431, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 1, "selected": false, "text": "set @output = @output + 'aaa' + char(13)\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3314/" ]
181,427
<p>I am currently having a hardtime understanding and implementing events in C# using delagates. I am used to the Java way of doing things:</p> <ol> <li>Define an interface for a listener type which would contain a number of method definitions</li> <li>Define adapter class for that interface to make things easier if I'm not interested in all the events defined in a listener</li> <li>Define Add, Remove and Get[] methods in the class which raises the events</li> <li>Define protected fire methods to do the dirty work of looping through the list of added listeners and calling the correct method</li> </ol> <p>This I understand (and like!) - I know I could do this exactly the same in c#, but it seems that a new (better?) system is in place for c#. After reading countless tutorials explaining the use of delegates and events in c# I still am no closer to really understanding what is going on :S</p> <hr> <p>In short, for the following methods how would I implement the event system in c#:</p> <pre><code>void computerStarted(Computer computer); void computerStopped(Computer computer); void computerReset(Computer computer); void computerError(Computer computer, Exception error); </code></pre> <p>^ The above methods are taken from a Java application I once made which I'm trying to port over to c#.</p> <p>Many many thanks!</p>
[ { "answer_id": 181451, "author": "jop", "author_id": 11830, "author_profile": "https://Stackoverflow.com/users/11830", "pm_score": 3, "selected": false, "text": "public delegate void ComputerEvent(object sender, ComputerEventArgs e);\n public class ComputerEventArgs : EventArgs\n{\n // TODO wrap in properties\n public Computer computer;\n public Exception error;\n\n public ComputerEventArgs(Computer aComputer, Exception anError)\n {\n computer = aComputer;\n error = anError;\n }\n\n public ComputerEventArgs(Computer aComputer) : this(aComputer, null)\n {\n }\n}\n public YourClass\n{\n ...\n public event ComputerEvent ComputerStarted;\n public event ComputerEvent ComputerStopped;\n public event ComputerEvent ComputerReset;\n public event ComputerEvent ComputerError;\n ...\n}\n YourClass obj = new YourClass();\nobj.ComputerStarted += new ComputerEvent(your_computer_started_handler);\n private void ComputerStartedEventHandler(object sender, ComputerEventArgs e)\n{\n // do your thing.\n}\n" }, { "answer_id": 181454, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 1, "selected": false, "text": "public delegate void ComputerStartedDelegate(Computer computer);\nprotected event ComputerStartedDelegate ComputerStarted;\npublic void OnComputerStarted(Computer computer)\n{\n if (ComputerStarted != null)\n {\n ComputerStarted.Invoke(computer);\n }\n}\nprotected void someMethod()\n{\n //...\n computer.Started = true; //or whatever\n OnComputerStarted(computer);\n //...\n}\n Computer comp = new Computer();\ncomp.ComputerStarted += new ComputerStartedDelegate(\n this.ComputerStartedHandler);\n\nprotected void ComputerStartedHandler(Computer computer)\n{\n //do something\n}\n" }, { "answer_id": 181455, "author": "Andrew Kennan", "author_id": 22506, "author_profile": "https://Stackoverflow.com/users/22506", "pm_score": 1, "selected": false, "text": "public class ComputerEventArgs : EventArgs\n{\n private Computer _computer;\n\n public ComputerEventArgs(Computer computer) {\n _computer = computer;\n }\n\n public Computer Computer { get { return _computer; } }\n}\n public class ComputerEventProducer\n{\n public event EventHandler<ComputerEventArgs> Started;\n public event EventHandler<ComputerEventArgs> Stopped;\n public event EventHandler<ComputerEventArgs> Reset;\n public event EventHandler<ComputerEventArgs> Error;\n\n /*\n // Invokes the Started event */\n private void OnStarted(Computer computer) {\n if( Started != null ) {\n Started(this, new ComputerEventArgs(computer));\n }\n }\n\n // Add OnStopped, OnReset and OnError\n\n}\n public class ComputerEventConsumer\n{\n public void ComputerEventConsumer(ComputerEventProducer producer) {\n producer.Started += new EventHandler<ComputerEventArgs>(ComputerStarted);\n // Add other event handlers\n }\n\n private void ComputerStarted(object sender, ComputerEventArgs e) {\n }\n}\n" }, { "answer_id": 181462, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "public class ExceptionEventArgs : EventArgs\n{\n private readonly Exception error;\n\n public ExceptionEventArgs(Exception error)\n {\n this.error = error;\n }\n\n public Error\n {\n get { return error; }\n }\n}\n\npublic class Computer\n{\n public event EventHandler Started = delegate{};\n public event EventHandler Stopped = delegate{};\n public event EventHandler Reset = delegate{};\n public event EventHandler<ExceptionEventArgs> Error = delegate{};\n\n protected void OnStarted()\n {\n Started(this, EventArgs.Empty);\n }\n\n protected void OnStopped()\n {\n Stopped(this, EventArgs.Empty);\n }\n\n protected void OnReset()\n {\n Reset(this, EventArgs.Empty);\n }\n\n protected void OnError(Exception e)\n {\n Error(this, new ExceptionEventArgs(e));\n }\n}\n someComputer.Started += StartEventHandler; // A method\nsomeComputer.Stopped += delegate(object o, EventArgs e)\n{ \n Console.WriteLine(\"{0} has started\", o);\n};\nsomeComputer.Reset += (o, e) => Console.WriteLine(\"{0} has been reset\");\n delegate{}" }, { "answer_id": 181487, "author": "loudej", "author_id": 6056, "author_profile": "https://Stackoverflow.com/users/6056", "pm_score": 0, "selected": false, "text": "// arguments for events\npublic class ComputerEventArgs : EventArgs\n{\n public Computer Computer { get; set; }\n}\n\npublic class ComputerErrorEventArgs : ComputerEventArgs\n{\n public Exception Error { get; set; }\n}\n\n// delegates for events\npublic delegate void ComputerEventHandler(object sender, ComputerEventArgs e);\n\npublic delegate void ComputerErrorEventHandler(object sender, ComputerErrorEventArgs e);\n\n// component that raises events\npublic class Thing\n{\n public event ComputerEventHandler Started;\n public event ComputerEventHandler Stopped;\n public event ComputerEventHandler Reset;\n public event ComputerErrorEventHandler Error;\n}\n class Program\n{\n static void Main(string[] args)\n {\n var thing = new Thing();\n thing.Started += thing_Started;\n }\n\n static void thing_Started(object sender, ComputerEventArgs e)\n {\n throw new NotImplementedException();\n }\n}\n public class Thing\n{\n public event ComputerEventHandler Started;\n\n public void OnStarted(Computer computer)\n {\n if (Started != null)\n Started(this, new ComputerEventArgs {Computer = computer});\n }\n}\n public class Thing\n{\n public event EventHandler<ComputerEventArgs> Started;\n public event EventHandler<ComputerEventArgs> Stopped;\n public event EventHandler<ComputerEventArgs> Reset;\n public event EventHandler<ComputerErrorEventArgs> Error;\n}\n" }, { "answer_id": 183077, "author": "Richard Walton", "author_id": 15075, "author_profile": "https://Stackoverflow.com/users/15075", "pm_score": 0, "selected": false, "text": "public void computerStarted(Computer computer);\npublic void computerStopped(Computer computer);\npublic void computerReset(Computer computer);\npublic void breakPointHit(Computer computer, int breakpoint);\npublic void computerError(Computer computer, Exception exception);\n" }, { "answer_id": 183703, "author": "Richard Walton", "author_id": 15075, "author_profile": "https://Stackoverflow.com/users/15075", "pm_score": 0, "selected": false, "text": " public class Computer {\n\n public event EventHandler Started;\n\n public event EventHandler Stopped;\n\n public event EventHandler Reset;\n\n public event EventHandler<BreakPointEvent> BreakPointHit;\n\n public event EventHandler<ExceptionEvent> Error;\n\n public Computer() {\n Started = delegate { };\n Stopped = delegate { };\n Reset = delegate { };\n BreakPointHit = delegate { };\n Error = delegate { };\n }\n\n protected void OnStarted() {\n Started(this, EventArgs.Empty);\n }\n\n protected void OnStopped() {\n Stopped(this, EventArgs.Empty);\n }\n\n protected void OnReset() {\n Reset(this, EventArgs.Empty);\n }\n\n protected void OnBreakPointHit(int breakPoint) {\n BreakPointHit(this, new BreakPointEvent(breakPoint));\n }\n\n protected void OnError(System.Exception exception) {\n Error(this, new ExceptionEvent(exception));\n }\n }\n}\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15075/" ]
181,432
<p>The class method to create an index path with one or more nodes is:</p> <pre><code>+ (id)indexPathWithIndexes:(NSUInteger *)indexes length:(NSUInteger)length </code></pre> <p>How do we create the "indexes" required in the first parameter? </p> <p>The documentation listed it as <em>Array of indexes to make up the index path</em> but it is expecting a (NSUinteger *). </p> <p>To create an index path of 1.2.3.4, is it simply an array of [1,2,3,4] ?</p>
[ { "answer_id": 184463, "author": "Barry Wark", "author_id": 2140, "author_profile": "https://Stackoverflow.com/users/2140", "pm_score": 7, "selected": true, "text": "NSUInteger indexArr[] = {1,2,3,4};\n\nNSIndexPath *indexPath = [NSIndexPath indexPathWithIndexes:indexArr length:4];\n" }, { "answer_id": 829160, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 5, "selected": false, "text": "+ (NSIndexPath*) indexPathForRow:(NSUInteger)row inSection:(NSUInteger)section\n" }, { "answer_id": 32511059, "author": "jungledev", "author_id": 3634990, "author_profile": "https://Stackoverflow.com/users/3634990", "pm_score": 2, "selected": false, "text": " NSMutableArray *indexPaths = [[NSMutableArray alloc] init]; \n for (int i = firstIndexYouWant; i < totalIndexPathsYouWant; i++) [indexPaths addObject:[NSIndexPath indexPathForRow:i inSection:0]];\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181432", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1987/" ]
181,442
<p>Actually, I wanted a custom cell which contains 2 image objects and 1 text object, and I decided to make a container for those objects. </p> <p>So is it possible to hold a image in object and insert that object in any of the collection objects, and later use that object to display inside cell?</p>
[ { "answer_id": 183750, "author": "lajos", "author_id": 3740, "author_profile": "https://Stackoverflow.com/users/3740", "pm_score": 3, "selected": true, "text": "//create a UIImage from a jpeg image\nUIImage *myImage = [UIImage imageWithContentsOfFile:@\"myImage.jpg\"];\nNSArray *myArray = [NSMutableArray array]; // this will autorelease, so if you need to keep it around, retain it\n[myArray addObject:myImage];\n\n\n\n//to draw this image in a UIView's drawRect method\nCGContextRef context = UIGraphicsGetCurrentContext(); // you need to find the context to draw into\nUIImage *myImage = [myArray lastObject]; // this gets the last object from an array, use the objectAtIndex: method to get a an object with a specific index\nCGImageRef *myCGImage = [myImage CGImage];\nCGContextDrawImage(context, rect, myCGImage); //rect is passed to drawRect\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/451867/" ]
181,459
<p>Is there a better way to do this?</p> <pre><code>-(NSDate *)getMidnightTommorow { NSCalendarDate *now = [NSCalendarDate date]; NSCalendarDate *tomorrow = [now dateByAddingYears:0 months:0 days:1 hours:0 minutes:0 seconds:0]; return [NSCalendarDate dateWithYear:[tomorrow yearOfCommonEra] month:[tomorrow monthOfYear] day:[tomorrow dayOfMonth] hour:0 minute:0 second:0 timeZone:[tomorrow timeZone]]; } </code></pre> <p>Note that I always want the next midnight, even if it happens to be midnight when I make that call, however if it happens to be 23:59:59, I of course want the midnight that is coming in one second.</p> <p>The natural language functions seem flaky, and I'm not sure what Cocoa would do if I pass 32 in the "day" field. (If that'd work I could drop the [now dateByAddingYears:...] call)</p>
[ { "answer_id": 181495, "author": "mmalc", "author_id": 23233, "author_profile": "https://Stackoverflow.com/users/23233", "pm_score": 6, "selected": true, "text": "NSDate *today = [NSDate date];\n\nNSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];\n\nNSDateComponents *components = [[NSDateComponents alloc] init];\ncomponents.day = 1;\nNSDate *tomorrow = [gregorian dateByAddingComponents:components toDate:today options:0];\n[components release];\n\nNSUInteger unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;\ncomponents = [gregorian components:unitFlags fromDate:tomorrow];\ncomponents.hour = 0;\ncomponents.minute = 0;\n\nNSDate *tomorrowMidnight = [gregorian dateFromComponents:components];\n\n[gregorian release];\n[components release];\n dateFromComponents:" }, { "answer_id": 860379, "author": "user58338", "author_id": 58338, "author_profile": "https://Stackoverflow.com/users/58338", "pm_score": 1, "selected": false, "text": "[NSDate dateWithNaturalLanguageString:@\"midnight tomorrow\"];\n" }, { "answer_id": 1237402, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "NSCalendar *gregorian = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];\n\nNSDate *tomorrow = [NSDate dateWithTimeIntervalSinceNow:(24 * 60 * 60)];\n\nNSDateComponents *components = [gregorian components:(NSYearCalendarUnit |\n NSMonthCalendarUnit |\n NSDayCalendarUnit)\n fromDate:tomorrow];\n\nNSDate *midnight = [gregorian dateFromComponents:components];\n" }, { "answer_id": 35535389, "author": "julia_v", "author_id": 3881449, "author_profile": "https://Stackoverflow.com/users/3881449", "pm_score": 0, "selected": false, "text": "NSCalendar *calendar = [NSCalendar currentCalendar];\nNSDateComponents *comps = [[NSDateComponents alloc] init];\n[comps setDay:1];\nNSDate *tomorrow = [calendar dateByAddingComponents:comps toDate:[NSDate date] options:0]; //it gives us tomorrow with current time\nNSDate *midnight = [calendar startOfDayForDate:tomorrow]; //here we get next midnight\n double intervalToMidnight = midnight.timeIntervalSinceNow;\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23033/" ]
181,471
<p>The new awesome <kbd>Ctrl</kbd> + <kbd>.</kbd> keyboard shortcut to show smart tags has suddenly stopped working, a week or so after I discovered it :( </p> <p>I am missing it badly, having had to revert back to <kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>F10</kbd>, which really just isn't the same.</p> <p>I recently installed F# CTP 1.9.6.2</p> <p>Has anyone else</p> <ul> <li>installed this CTP and still has <kbd>Ctrl</kbd> + <kbd>.</kbd></li> <li>Lost <kbd>Ctrl</kbd> + <kbd>.</kbd> without installing F#</li> <li>Even better, found how to get it back again?</li> </ul> <p><strong>EDIT</strong> In attempting John Sheehan recommendation, I have noticed that my available mapping schemes only include <code>Visual C# 2005</code>, should I not have a 2008?</p> <p>Also the mapped shortcut to this is</p> <pre><code>OtherContextMenus.FSIConsoleContext.CancelEvaluation </code></pre>
[ { "answer_id": 181495, "author": "mmalc", "author_id": 23233, "author_profile": "https://Stackoverflow.com/users/23233", "pm_score": 6, "selected": true, "text": "NSDate *today = [NSDate date];\n\nNSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];\n\nNSDateComponents *components = [[NSDateComponents alloc] init];\ncomponents.day = 1;\nNSDate *tomorrow = [gregorian dateByAddingComponents:components toDate:today options:0];\n[components release];\n\nNSUInteger unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;\ncomponents = [gregorian components:unitFlags fromDate:tomorrow];\ncomponents.hour = 0;\ncomponents.minute = 0;\n\nNSDate *tomorrowMidnight = [gregorian dateFromComponents:components];\n\n[gregorian release];\n[components release];\n dateFromComponents:" }, { "answer_id": 860379, "author": "user58338", "author_id": 58338, "author_profile": "https://Stackoverflow.com/users/58338", "pm_score": 1, "selected": false, "text": "[NSDate dateWithNaturalLanguageString:@\"midnight tomorrow\"];\n" }, { "answer_id": 1237402, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "NSCalendar *gregorian = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];\n\nNSDate *tomorrow = [NSDate dateWithTimeIntervalSinceNow:(24 * 60 * 60)];\n\nNSDateComponents *components = [gregorian components:(NSYearCalendarUnit |\n NSMonthCalendarUnit |\n NSDayCalendarUnit)\n fromDate:tomorrow];\n\nNSDate *midnight = [gregorian dateFromComponents:components];\n" }, { "answer_id": 35535389, "author": "julia_v", "author_id": 3881449, "author_profile": "https://Stackoverflow.com/users/3881449", "pm_score": 0, "selected": false, "text": "NSCalendar *calendar = [NSCalendar currentCalendar];\nNSDateComponents *comps = [[NSDateComponents alloc] init];\n[comps setDay:1];\nNSDate *tomorrow = [calendar dateByAddingComponents:comps toDate:[NSDate date] options:0]; //it gives us tomorrow with current time\nNSDate *midnight = [calendar startOfDayForDate:tomorrow]; //here we get next midnight\n double intervalToMidnight = midnight.timeIntervalSinceNow;\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5302/" ]
181,485
<p>I've incorporated Apple's Reachability sample into my own project so I know whether or not I have a network connection - if I don't have a network connection, I don't bother sending out and requests. I decided to go with the status notification implementation because it seemed easier to have the reachablity updated in the background and have the current results available immediately as opposed to kicking off a synchronous request whenever I want to make a network connection.</p> <p>My problem is that I start getting false negatives when on an EDGE network - the phone has connectivity, but the app thinks this isn't the case. My understanding is you don't get a notification when an EDGE connection, so my assumption is that I lost and regained the connection at some point. Restarting the app is usually sufficient to see the network connection.</p> <p>This isn't an optimal solution, so I was wondering if anybody else came across this problem and had any thoughts on a solutions.</p> <p>(I don't know whether this applies to 3G as well; I'm running a first gen iPhone).</p>
[ { "answer_id": 181529, "author": "Chris Lundie", "author_id": 20685, "author_profile": "https://Stackoverflow.com/users/20685", "pm_score": 5, "selected": true, "text": "- (void) checkReachability {\n BOOL connected = ([[Reachability sharedReachability] localWiFiConnectionStatus] == ReachableViaWiFiNetwork);\n\n // Do something...\n\n [self performSelector:@selector(checkReachability) withObject:nil afterDelay:5.0];\n}\n" }, { "answer_id": 7036286, "author": "Abhijeet", "author_id": 782653, "author_profile": "https://Stackoverflow.com/users/782653", "pm_score": 1, "selected": false, "text": "NSString *sCellNetwork; \n NSString *sNetworkReachable; \n\nif (flags & kSCNetworkFlagsReachable || flags & kSCNetworkReachabilityFlagsIsWWAN)\n\n{do it} \n\n else {\n Network fail alert; \n}\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24168/" ]
181,498
<p>I need to sort tuples according to the second element of each tuple but apparently usort/1 only works with the first element. So I have to swap the elements, usort them and swap back.Is there an easier way?Also is there a way to sort in descending order (I know sorting and reversing can be done, but just want to know).</p>
[ { "answer_id": 181520, "author": "bmdhacks", "author_id": 14032, "author_profile": "https://Stackoverflow.com/users/14032", "pm_score": 0, "selected": false, "text": "qsort([]) -> [];\nqsort([Pivot|Tail]) ->\n {PivotFirst, PivotSecond} = Pivot,\n qsort([{FirstElement, SecondElement} || {FirstElement,SecondElement} <- Tail, SecondElement < PivotSecond])\n ++ [Pivot] ++\n qsort([{FirstElement, SecondElement} || {FirstElement,SecondElement} <- Tail, SecondElement >= PivotSecond]).\n" }, { "answer_id": 181548, "author": "bmdhacks", "author_id": 14032, "author_profile": "https://Stackoverflow.com/users/14032", "pm_score": 2, "selected": false, "text": "lists:sort(Fun, List1) -> List2\n lists:sort(fun(A, B) ->\n {A1, A2} = A,\n {B1, B2} = B,\n if\n A2 > B2 ->\n false;\n true ->\n true\n end\n end, YourList).\n" }, { "answer_id": 181650, "author": "hcs42", "author_id": 17916, "author_profile": "https://Stackoverflow.com/users/17916", "pm_score": 2, "selected": false, "text": "lists:sort(fun(A, B) ->\n {_, A2} = A,\n {_, B2} = B,\n A2 =< B2\n end, YourList).\n" }, { "answer_id": 181673, "author": "Michał Kwiatkowski", "author_id": 21998, "author_profile": "https://Stackoverflow.com/users/21998", "pm_score": 3, "selected": true, "text": "> lists:reverse(lists:keysort(2, [{a,2}, {b,1}, {c, 3}])).\n[{c,3},{a,2},{b,1}]\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2727/" ]
181,530
<p>Sometimes I break long conditions in <code>if</code>s onto several lines. The most obvious way to do this is:</p> <pre><code> if (cond1 == 'val1' and cond2 == 'val2' and cond3 == 'val3' and cond4 == 'val4'): do_something </code></pre> <p>Isn't very very appealing visually, because the action blends with the conditions. However, it is the natural way using correct Python indentation of 4 spaces.</p> <p>For the moment I'm using:</p> <pre><code> if ( cond1 == 'val1' and cond2 == 'val2' and cond3 == 'val3' and cond4 == 'val4'): do_something </code></pre> <p>But this isn't very pretty. :-)</p> <p>Can you recommend an alternative way?</p>
[ { "answer_id": 181553, "author": "Federico A. Ramponi", "author_id": 18770, "author_profile": "https://Stackoverflow.com/users/18770", "pm_score": 5, "selected": false, "text": "allCondsAreOK = (cond1 == 'val1' and cond2 == 'val2' and\n cond3 == 'val3' and cond4 == 'val4')\n\nif allCondsAreOK:\n do_something\n" }, { "answer_id": 181557, "author": "Harley Holcombe", "author_id": 1057, "author_profile": "https://Stackoverflow.com/users/1057", "pm_score": 11, "selected": true, "text": "if (cond1 == 'val1' and cond2 == 'val2' and \n cond3 == 'val3' and cond4 == 'val4'):\n do_something\n if ( \n cond1 == 'val1' and cond2 == 'val2' and \n cond3 == 'val3' and cond4 == 'val4'\n ):\n do_something\nif (cond1 == 'val1' and cond2 == 'val2' and \n cond3 == 'val3' and cond4 == 'val4'):\n do_something\n if cond1 == 'val1' and cond2 == 'val2' and \\\n cond3 == 'val3' and cond4 == 'val4':\n do_something\n if cond1 == 'val1' and cond2 == 'val2' and \\\n cond3 == 'val3' and \\\n cond4 == 'val4':\n do_something\n if cond1 == 'val1' and \\\n cond2 == 'val2' and \\\n cond3 == 'val3' and \\\n cond4 == 'val4':\n do_something\n" }, { "answer_id": 181641, "author": "DzinX", "author_id": 18745, "author_profile": "https://Stackoverflow.com/users/18745", "pm_score": 4, "selected": false, "text": "and if (cond1 == 'val1' and cond2 == 'val2'\n and cond3 == 'val3' and cond4 == 'val4'):\n do_something\n" }, { "answer_id": 181848, "author": "Deestan", "author_id": 6848, "author_profile": "https://Stackoverflow.com/users/6848", "pm_score": 6, "selected": false, "text": "if (\n expr1\n and (expr2 or expr3)\n and hasattr(thingy1, '__eq__')\n or status==\"HappyTimes\"\n):\n do_stuff()\nelse:\n do_other_stuff()\n" }, { "answer_id": 182050, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 7, "selected": false, "text": "if all( [cond1 == 'val1', cond2 == 'val2', cond3 == 'val3', cond4 == 'val4'] ):\n\nif any( [cond1 == 'val1', cond2 == 'val2', cond3 == 'val3', cond4 == 'val4'] ):\n" }, { "answer_id": 182067, "author": "Anders Waldenborg", "author_id": 24082, "author_profile": "https://Stackoverflow.com/users/24082", "pm_score": 2, "selected": false, "text": "def c1():\n print \" Executed c1\"\n return False\ndef c2():\n print \" Executed c2\"\n return False\n\n\nprint \"simple and (aborts early!)\"\nif c1() and c2():\n pass\n\nprint\n\nprint \"all (executes all :( )\"\nif all((c1(),c2())):\n pass\n\nprint\n" }, { "answer_id": 183206, "author": "Kevin Little", "author_id": 14028, "author_profile": "https://Stackoverflow.com/users/14028", "pm_score": 6, "selected": false, "text": "if ( cond1 == val1\n and cond2 == val2\n and cond3 == val3\n ):\n do_stuff()\n if ( cond1 == val1\n or \n ( cond2_1 == val2_1\n and cond2_2 >= val2_2\n and cond2_3 != bad2_3\n )\n ):\n do_more_stuff()\n" }, { "answer_id": 183889, "author": "Jason Baker", "author_id": 2147, "author_profile": "https://Stackoverflow.com/users/2147", "pm_score": 1, "selected": false, "text": ">>> x = {'cond1' : 'val1', 'cond2' : 'val2'}\n>>> y = {'cond1' : 'val1', 'cond2' : 'val2'}\n>>> x == y\nTrue\n class Klass(object):\n def __init__(self, some_vars):\n #initialize conditions here\n def __nonzero__(self):\n return (self.cond1 == 'val1' and self.cond2 == 'val2' and\n self.cond3 == 'val3' and self.cond4 == 'val4')\n\nfoo = Klass()\nif foo:\n print \"foo is true!\"\nelse:\n print \"foo is false!\"\n class Klass(object):\n def __init__(self):\n #initialize conditions here\n def __eq__(self):\n return (self.cond1 == 'val1' and self.cond2 == 'val2' and\n self.cond3 == 'val3' and self.cond4 == 'val4')\n\nx = Klass(some_values)\ny = Klass(some_other_values)\nif x == y:\n print 'x == y'\nelse:\n print 'x!=y'\n" }, { "answer_id": 185748, "author": "Federico A. Ramponi", "author_id": 18770, "author_profile": "https://Stackoverflow.com/users/18770", "pm_score": 2, "selected": false, "text": "if (cond1 == 'val1' and cond2 == 'val2' and\n cond3 == 'val3' and cond4 == 'val4'):\n\n do_something\n" }, { "answer_id": 3004525, "author": "psihodelia", "author_id": 215571, "author_profile": "https://Stackoverflow.com/users/215571", "pm_score": 0, "selected": false, "text": "if False not in Conditions:\n do_something\n" }, { "answer_id": 4689224, "author": "Fred Nurk", "author_id": 511601, "author_profile": "https://Stackoverflow.com/users/511601", "pm_score": 2, "selected": false, "text": "if (cond1 == \"val1\" and cond22 == \"val2\"\nand cond333 == \"val3\" and cond4444 == \"val4\"):\n do_something\n if (cond1 == \"val1\" and cond22 == \"val2\"\nand cond333 == \"val3\" and cond4444 == \"val4\") {\n do_something\n}\n" }, { "answer_id": 4690241, "author": "krawyoti", "author_id": 130961, "author_profile": "https://Stackoverflow.com/users/130961", "pm_score": 5, "selected": false, "text": "def is_action__required(...):\n return (cond1 == 'val1' and cond2 == 'val2'\n and cond3 == 'val3' and cond4 == 'val4')\n" }, { "answer_id": 4692294, "author": "Marius Gedminas", "author_id": 110151, "author_profile": "https://Stackoverflow.com/users/110151", "pm_score": 2, "selected": false, "text": "if (cond1 == 'val1' and cond2 == 'val2'\n and cond3 == 'val3' and cond4 == 'val4'):\n do_something\n and" }, { "answer_id": 4740630, "author": "Apalala", "author_id": 545637, "author_profile": "https://Stackoverflow.com/users/545637", "pm_score": 3, "selected": false, "text": "conditions_met = (\n cond1 == 'val1' \n and cond2 == 'val2' \n and cond3 == 'val3' \n and cond4 == 'val4'\n )\nif conditions_met:\n do_something\n while" }, { "answer_id": 7511872, "author": "xorsyst", "author_id": 386465, "author_profile": "https://Stackoverflow.com/users/386465", "pm_score": 0, "selected": false, "text": "if (cond1 == 'val1' and cond2 == 'val2' and\n cond3 == 'val3' and cond4 == 'val4'):\n do_something\n" }, { "answer_id": 9682878, "author": "Dima Tisnek", "author_id": 705086, "author_profile": "https://Stackoverflow.com/users/705086", "pm_score": 0, "selected": false, "text": " if cond1 == 'val1' and \\\n cond2 == 'val2' and \\\n cond3 == 'val3' and \\\n cond4 == 'val4':\n do_something\n if cond1 == 'val1'\\\n and cond2 == 'val2'\\\n and cond3 == 'val3'\\\n and cond4 == 'val4':\n do_something\n" }, { "answer_id": 15264532, "author": "rgenito", "author_id": 1418001, "author_profile": "https://Stackoverflow.com/users/1418001", "pm_score": 3, "selected": false, "text": "if not user.isAdmin() and user.isTeacher() and not user.isStudent():\n doSomething()\n displayTeacherPanel = not user.isAdmin() and user.isTeacher() and not user.isStudent()\nif displayTeacherPanel:\n showTeacherPanel()\n if displayTeacherPanel or user.canSeeSpecialPanel():\n showSpecialPanel()\n" }, { "answer_id": 25085957, "author": "tomekwi", "author_id": 2816199, "author_profile": "https://Stackoverflow.com/users/2816199", "pm_score": 2, "selected": false, "text": "if (cond1 == 'val1' and cond2 == 'val2' and\n cond3 == 'val3' and cond4 == 'val4'\n ):\n do_something\n" }, { "answer_id": 26414728, "author": "user1487551", "author_id": 1487551, "author_profile": "https://Stackoverflow.com/users/1487551", "pm_score": 0, "selected": false, "text": "cond_list = ['cond1 == \"val1\"','cond2==\"val2\"','cond3==\"val3\"','cond4==\"val4\"']\nif all([eval(i) for i in cond_list]):\n do something\n cond_list.append('cond5==\"val5\"')\n" }, { "answer_id": 27008512, "author": "zkanda", "author_id": 3171548, "author_profile": "https://Stackoverflow.com/users/3171548", "pm_score": 3, "selected": false, "text": "condition = [cond1 == 'val1', cond2 == 'val2', cond3 == 'val3', cond4 == 'val4']\n\nif all(condition):\n do_something\n" }, { "answer_id": 27100017, "author": "ThorSummoner", "author_id": 1695680, "author_profile": "https://Stackoverflow.com/users/1695680", "pm_score": 3, "selected": false, "text": "if (\n cond1 and\n cond2\n):\n print(\"Hello World!\")\n all any if all([\n cond1,\n cond2,\n]):\n print(\"Hello World!\")\n any or all and # Check if every string in a list contains a substring:\nmy_list = [\n 'a substring is like a string', \n 'another substring'\n]\n\nif all('substring' in item for item in my_list):\n print(\"Hello World!\")\n\n# or\n\nif all(\n 'substring' in item\n for item in my_list\n):\n print(\"Hello World!\")\n" }, { "answer_id": 27279883, "author": "El Ninja Trepador", "author_id": 2026122, "author_profile": "https://Stackoverflow.com/users/2026122", "pm_score": 1, "selected": false, "text": "if bool(condition1 and\n condition2 and\n ...\n conditionN):\n foo()\n bar()\n if (((foo and\n bar and\n frob and\n ninja_bear))):\n do_stuff()\n" }, { "answer_id": 28867664, "author": "Artur Gaspar", "author_id": 286655, "author_profile": "https://Stackoverflow.com/users/286655", "pm_score": 0, "selected": false, "text": "if ((cond1 == 'val1' and cond2 == 'val2' and\n cond3 == 'val3' and cond4 == 'val4')):\n do_something()\n" }, { "answer_id": 31231248, "author": "Mark Amery", "author_id": 1709587, "author_profile": "https://Stackoverflow.com/users/1709587", "pm_score": 4, "selected": false, "text": "if if if if # No extra indentation.\nif (this_is_one_thing and\n that_is_another_thing):\n do_something()\n\n# Add a comment, which will provide some distinction in editors\n# supporting syntax highlighting.\nif (this_is_one_thing and\n that_is_another_thing):\n # Since both conditions are true, we can frobnicate.\n do_something()\n\n# Add some extra indentation on the conditional continuation line.\nif (this_is_one_thing\n and that_is_another_thing):\n do_something()\n" }, { "answer_id": 34117413, "author": "Gautam", "author_id": 582421, "author_profile": "https://Stackoverflow.com/users/582421", "pm_score": 0, "selected": false, "text": "#!/usr/bin/python\nimport sys\nnumberOfArgument =len(sys.argv)\nweblogic_username =''\nweblogic_password = ''\nweblogic_admin_server_host =''\nweblogic_admin_server_port =''\n\n\nif numberOfArgument == 5:\n weblogic_username = sys.argv[1]\n weblogic_password = sys.argv[2]\n weblogic_admin_server_host =sys.argv[3]\n weblogic_admin_server_port=sys.argv[4]\nelif numberOfArgument <5:\n print \" weblogic UserName, weblogic Password and weblogic host details are Mandatory like, defalutUser, passwordForDefaultUser, t3s://server.domainname:7001 .\"\n weblogic_username = raw_input(\"Enter Weblogic user Name\")\n weblogic_password = raw_input('Enter Weblogic user Password')\n weblogic_admin_server_host = raw_input('Enter Weblogic admin host ')\n weblogic_admin_server_port = raw_input('Enter Weblogic admin port')\n#enfelif\n#endIf\n" }, { "answer_id": 38775892, "author": "SarcasticSully", "author_id": 4318342, "author_profile": "https://Stackoverflow.com/users/4318342", "pm_score": 1, "selected": false, "text": "total = cond1 == 'val' and cond2 == 'val2' and cond3 == 'val3' and cond4 == val4\nif total:\n do_something()\n if" }, { "answer_id": 40871775, "author": "SMGreenfield", "author_id": 516545, "author_profile": "https://Stackoverflow.com/users/516545", "pm_score": 2, "selected": false, "text": "if foo is not None:\n if (cond1 == 'val1' and cond2 == 'val2' and\n cond3 == 'val3' and cond4 == 'val4'):\n # some comment about do_something\n do_something\n" }, { "answer_id": 44601456, "author": "Stof", "author_id": 1490061, "author_profile": "https://Stackoverflow.com/users/1490061", "pm_score": 2, "selected": false, "text": "condition = random.randint(0, 100) # to demonstrate\nanti_conditions = [42, 67, 12]\nif condition not in anti_conditions:\n pass\n" }, { "answer_id": 45238436, "author": "ryanjdillon", "author_id": 943773, "author_profile": "https://Stackoverflow.com/users/943773", "pm_score": 2, "selected": false, "text": "conditions = [1, 2, 3, 4]\nvalues = [1, 2, 3, 4]\nif all([c==v for c, v in zip(conditions, values)]):\n # do something\n if (condition1==value1) and (condition2==value2) and \\\n (condition3==value3) and (condition4==value4):\n iand proceed = True\nfor c, v in zip(conditions, values):\n proceed &= c==v\n\nif proceed:\n # do something\n" }, { "answer_id": 58563138, "author": "Nader Belal", "author_id": 8533804, "author_profile": "https://Stackoverflow.com/users/8533804", "pm_score": 1, "selected": false, "text": "param_Val01 = Value 01 #give a meaningful name for param_Val(i) preferable an integer\nparam_Val02 = Value 02\nparam_Val03 = Value 03\nparam_Val04 = Value 04 # and ... etc\n\nconditions = 0 # this is a value placeholder\n\n########\nAdd script that if true will make:\n\nconditions = conditions + param_Val01 #value of placeholder is updated\n########\n\n### repeat as needed\n\n\nif conditions = param_Val01 + param_Val02 + param_Val03 + param_Val04:\n do something\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
181,532
<p>I have a text string value that I'd like to persist from one web page to another without using query strings or the session/view states. I've been trying to get the ASP http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hiddenfield.aspx">HiddenField control to pass information from one web form to a <i>different</i> form.<br><br> All the hiddenfield control examples that I've seen is to preserve round trips from the client to the server for the same form.<br><br> Is there way for a form to access the ASP controls (and their values) from the previously-rendered form? Or is the initial form simply disposed of in memory by the time the second form executes it's <i>OnLoad</i> method?</p>
[ { "answer_id": 181645, "author": "Cristian Libardo", "author_id": 16526, "author_profile": "https://Stackoverflow.com/users/16526", "pm_score": 2, "selected": false, "text": "protected void Page_Load(object sender, EventArgs e)\n{\n Server.Transfer(\"~/secondpage.aspx\");\n}\n protected void Page_Load(object sender, EventArgs e)\n{\n Page previousPage = (Page) HttpContext.Current.PreviousHandler;\n Label previousPageControl = (Label) previousPage.FindControl(\"theLabel\");\n label.Text =previousPageControl.Text;\n}\n" }, { "answer_id": 181661, "author": "martin", "author_id": 8421, "author_profile": "https://Stackoverflow.com/users/8421", "pm_score": 2, "selected": false, "text": "if (Page.PreviousPage != null)\n{\n TextBox SourceTextBox = \n (TextBox)Page.PreviousPage.FindControl(\"TextBox1\");\n if (SourceTextBox != null)\n {\n Label1.Text = SourceTextBox.Text;\n }\n}\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26037/" ]
181,537
<p>So basically we have lots of SharePoint usage log files generated by our SharePoint 2007 site and we would like to make sense of them. For that we're thinking of reading the log files and dumping into a database with the appropriate columns and all. Now I was going to make an SSIS package to read all the text files and extract the data when I came across LogParser. Is there a way to use LogParser to dump data into an Sql Server database or the SSIS way is better? Or is there any other better way to use the SharePoint usage logs?</p>
[ { "answer_id": 181771, "author": "massimogentilini", "author_id": 11673, "author_profile": "https://Stackoverflow.com/users/11673", "pm_score": 2, "selected": false, "text": "LogParser \"SELECT * INTO <TABLENAME> FROM <LogFileName>\" -o:SQL -server:<servername> -database:<databasename> -driver:\"SQL Server\" -username:sa -password:xxxxx -createTable:ON\n <tablename>, <logfilename>, <servername>, <databasename>" }, { "answer_id": 182361, "author": "Nico", "author_id": 22970, "author_profile": "https://Stackoverflow.com/users/22970", "pm_score": 2, "selected": false, "text": "[Guid(\"1CC338B9-4F5F-4bf2-86AE-55C865CF7159\")]\npublic class SPUsageLogParserPlugin : ILogParserInputContext\n{\n private FileStream stream = null;\n private BinaryReader br = null;\n private object[] currentEntry = null;\n public SPUsageLogParserPlugin() { }\n\n #region LogParser\n\n protected const int GENERAL_HEADER_LENGTH = 300;\n protected const int ENTRY_HEADER_LENGTH = 50;\n protected string[] columns = {\"TimeStamp\",\n \"SiteGUID\",\n \"SiteUrl\",\n \"WebUrl\",\n \"Document\",\n \"User\",\n \"QueryString\",\n \"Referral\",\n \"UserAgent\",\n \"Command\"};\n\n protected string ReadString(BinaryReader br)\n {\n StringBuilder buffer = new StringBuilder();\n char c = br.ReadChar();\n while (c != 0) {\n buffer.Append(c);\n c = br.ReadChar();\n }\n return buffer.ToString();\n }\n\n #endregion\n\n #region ILogParserInputContext Members\n\n enum FieldType\n {\n Integer = 1,\n Real = 2,\n String = 3,\n Timestamp = 4\n }\n\n public void OpenInput(string from)\n {\n stream = File.OpenRead(from);\n br = new BinaryReader(stream);\n br.ReadBytes(GENERAL_HEADER_LENGTH);\n }\n\n public int GetFieldCount()\n {\n return columns.Length;\n }\n\n public string GetFieldName(int index)\n {\n return columns[index];\n }\n\n public int GetFieldType(int index)\n {\n if (index == 0) {\n // TimeStamp\n return (int)FieldType.Timestamp;\n } else {\n // Other fields\n return (int)FieldType.String;\n }\n }\n\n public bool ReadRecord()\n {\n if (stream.Position < stream.Length) {\n br.ReadBytes(ENTRY_HEADER_LENGTH); // Entry Header\n\n string webappguid = ReadString(br);\n\n DateTime timestamp = DateTime.ParseExact(ReadString(br), \"HH:mm:ss\", null);\n string siteUrl = ReadString(br);\n string webUrl = ReadString(br);\n string document = ReadString(br);\n string user = ReadString(br);\n string query = ReadString(br);\n string referral = ReadString(br);\n string userAgent = ReadString(br);\n string guid = ReadString(br);\n string command = ReadString(br);\n\n currentEntry = new object[] { timestamp, webappguid, siteUrl, webUrl, document, user, query, referral, userAgent, command };\n return true;\n } else {\n currentEntry = new object[] { };\n return false;\n }\n }\n\n public object GetValue(int index)\n {\n return currentEntry[index];\n }\n\n public void CloseInput(bool abort)\n {\n br.Close();\n stream.Dispose();\n stream = null;\n br = null;\n }\n\n #endregion\n}\n" }, { "answer_id": 220561, "author": "Nat", "author_id": 13813, "author_profile": "https://Stackoverflow.com/users/13813", "pm_score": 2, "selected": false, "text": "CREATE TABLE [dbo].[STSlog](\n [application] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,\n [date] [datetime] NULL,\n [time] [datetime] NULL,\n [username] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,\n [computername] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,\n [method] [varchar](16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,\n [siteURL] [varchar](2048) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,\n [webURL] [varchar](2048) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,\n [docName] [varchar](2048) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,\n [bytes] [int] NULL,\n [queryString] [varchar](2048) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,\n [userAgent] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,\n [referer] [varchar](2048) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,\n [bitFlags] [smallint] NULL,\n [status] [smallint] NULL,\n [siteGuid] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL\n) ON [PRIMARY]\n \"C:\\projects\\STSLogParser\\STSLogParser.exe\" 2005-01-01 \"c:\\projects\\STSlog\\2005-01-01\\00.log\" c:\\projects\\logparsertmp\\stslog.csv\n\"C:\\Program Files\\Log Parser 2.2\\logparser.exe\" \"SELECT 'SharePointPortal' as application, TO_DATE(TO_UTCTIME(TO_TIMESTAMP(TO_TIMESTAMP(date, 'yyyy-MM-dd'), TO_TIMESTAMP(time, 'hh:mm:ss')))) AS date, TO_TIME( TO_UTCTIME( TO_TIMESTAMP(TO_TIMESTAMP(date, 'yyyy-MM-dd'), TO_TIMESTAMP(time, 'hh:mm:ss')))), UserName as username, 'SERVERNAME' as computername, 'GET' as method, SiteURL as siteURL, WebURL as webURL, DocName as docName, cBytes as bytes, QueryString as queryString, UserAgent as userAgent, RefURL as referer, TO_INT(bitFlags) as bitFlags, TO_INT(HttpStatus) as status, TO_STRING(SiteGuid) as siteGuid INTO STSlog FROM c:\\projects\\logparsertmp\\stslog.csv WHERE (username IS NOT NULL) AND (TO_LOWERCASE(username) NOT IN (domain\\serviceaccount))\" -i:CSV -headerRow:ON -o:SQL -server:localhost -database:SharePoint_SA_IN -clearTable:ON\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181537", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1688440/" ]
181,543
<p>There seems to be a lot of heated discussion on the net about the changes to the reduce() function in python 3.0 and how it should be removed. I am having a little difficulty understanding why this is the case; I find it quite reasonable to use it in a variety of cases. If the contempt was simply subjective, I cannot imagine that such a large number of people would care about it. </p> <p>What am I missing? What is the problem with reduce()?</p>
[ { "answer_id": 181646, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 5, "selected": false, "text": "reduce() functools reduce()" }, { "answer_id": 181706, "author": "DzinX", "author_id": 18745, "author_profile": "https://Stackoverflow.com/users/18745", "pm_score": 7, "selected": true, "text": "reduce total = reduce(lambda a, b: (0, a[1] + b[1]), items)[1]\n def combine (a, b):\n return 0, a[1] + b[1]\n\ntotal = reduce(combine, items)[1]\n total = 0\nfor a, b in items:\n total += b\n total = sum(b for a,b in items)\n" }, { "answer_id": 65202390, "author": "user1153980", "author_id": 1153980, "author_profile": "https://Stackoverflow.com/users/1153980", "pm_score": -1, "selected": false, "text": "def poynomialValue(a,x):\n return reduce(lambda value, coef: value*x + coef, a)\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24530/" ]
181,551
<p>I'm working with JIntegra java com bridge. I have an object of type Object which true coclass is unknown. I need to check if that object can be casted to specific COM interface (which has a proxy class generated by JIntegra).</p>
[ { "answer_id": 189463, "author": "James Schek", "author_id": 17871, "author_profile": "https://Stackoverflow.com/users/17871", "pm_score": 2, "selected": true, "text": "queryInterface()" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181551", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26042/" ]
181,556
<p>When using py2exe to distribute Python applications with wxPython, some MSVC DLLs are usually needed to make the .exe work on freshly installed machines. In particular, the two most common DLLs are msvcp71.dll and msvcr71.dll</p> <p>The former can be included in the .exe using <a href="http://www.py2exe.org/index.cgi/OverridingCriteraForIncludingDlls" rel="noreferrer">this tip</a>. However, the latter is just placed in the <code>dist</code> dir by py2exe and not into the executable, even if I specifically ask to include it.</p> <p>Any idea how to cause py2exe to include both inside the .exe ?</p>
[ { "answer_id": 181583, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 4, "selected": true, "text": "msvcr71.dll py2exe" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
181,573
<p>I would like to be able to display <code>Notebook</code> and a <code>TxtCtrl</code> wx widgets in a single frame. Below is an example adapted from the wxpython wiki; is it possible to change their layout (maybe with something like <code>wx.SplitterWindow</code>) to display the text box below the <code>Notebook</code> in the same frame?</p> <pre><code>import wx import wx.lib.sheet as sheet class MySheet(sheet.CSheet): def __init__(self, parent): sheet.CSheet.__init__(self, parent) self.SetLabelBackgroundColour('#CCFF66') self.SetNumberRows(50) self.SetNumberCols(50) class Notebook(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, size=(600, 600)) menubar = wx.MenuBar() file = wx.Menu() file.Append(101, 'Quit', '' ) menubar.Append(file, "&amp;File") self.SetMenuBar(menubar) wx.EVT_MENU(self, 101, self.OnQuit) nb = wx.Notebook(self, -1, style=wx.NB_BOTTOM) self.sheet1 = MySheet(nb) self.sheet2 = MySheet(nb) self.sheet3 = MySheet(nb) nb.AddPage(self.sheet1, "Sheet1") nb.AddPage(self.sheet2, "Sheet2") nb.AddPage(self.sheet3, "Sheet3") self.sheet1.SetFocus() self.StatusBar() def StatusBar(self): self.statusbar = self.CreateStatusBar() def OnQuit(self, event): self.Close() class MyFrame(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(450, 400)) self.text = wx.TextCtrl(self, -1, style = wx.TE_MULTILINE) self.Center() class MyApp(wx.App): def OnInit(self): frame = Notebook(None, -1, 'notebook.py') frame.Show(True) frame.Center() frame2 = MyFrame(None, -1, '') frame2.Show(True) self.SetTopWindow(frame2) return True app = MyApp(0) app.MainLoop() </code></pre>
[ { "answer_id": 181626, "author": "DzinX", "author_id": 18745, "author_profile": "https://Stackoverflow.com/users/18745", "pm_score": 4, "selected": true, "text": "Notebook class Notebook(wx.Frame):\n def __init__(self, parent, id, title):\n wx.Frame.__init__(self, parent, id, title, size=(600, 600))\n menubar = wx.MenuBar()\n file = wx.Menu()\n file.Append(101, 'Quit', '' )\n menubar.Append(file, \"&File\")\n self.SetMenuBar(menubar)\n wx.EVT_MENU(self, 101, self.OnQuit)\n nb = wx.Notebook(self, -1, style=wx.NB_BOTTOM)\n self.sheet1 = MySheet(nb)\n self.sheet2 = MySheet(nb)\n self.sheet3 = MySheet(nb)\n nb.AddPage(self.sheet1, \"Sheet1\")\n nb.AddPage(self.sheet2, \"Sheet2\")\n nb.AddPage(self.sheet3, \"Sheet3\")\n self.sheet1.SetFocus()\n self.StatusBar()\n # new code begins here:\n # add your text ctrl:\n self.text = wx.TextCtrl(self, -1, style = wx.TE_MULTILINE)\n # create a new sizer for both controls:\n sizer = wx.BoxSizer(wx.VERTICAL)\n # add notebook first, with size factor 2:\n sizer.Add(nb, 2)\n # then text, size factor 1, maximized\n sizer.Add(self.text, 1, wx.EXPAND)\n # assign the sizer to Frame:\n self.SetSizerAndFit(sizer)\n __init__ Add" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11596/" ]
181,579
<p>List Comprehension is a very useful code mechanism that is found in several languages, such as Haskell, Python, and Ruby (just to name a few off the top of my head). I'm familiar with the construct.</p> <p>I find myself working on an Open Office Spreadsheet and I need to do something fairly common: I want to count all of the values in a range of cells that fall between a high and low bounds. I instantly thought that list comprehension would do the trick, but I can't find anything analogous in Open Office. There is a function called "COUNTIF", and it something similar, but not quite what I need.</p> <p>Is there a construct in Open Office that could be used for list comprehension?</p>
[ { "answer_id": 187158, "author": "sdkpoly", "author_id": 15640, "author_profile": "https://Stackoverflow.com/users/15640", "pm_score": 2, "selected": true, "text": "=If(AND({list_cell}>=MinVal; {list_cell}<=MaxVal); 1; 0)\n" }, { "answer_id": 70291061, "author": "tzot", "author_id": 6899, "author_profile": "https://Stackoverflow.com/users/6899", "pm_score": 0, "selected": false, "text": "=COUNTIFS(A1:A10, \">\" & B1, A1:A10, \"<\" & B2)\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19182/" ]
181,581
<p>How do you generate a X.509 public and private key pair and a signing request (CSR file) to be sent to a CA for signing in C#?</p>
[ { "answer_id": 187158, "author": "sdkpoly", "author_id": 15640, "author_profile": "https://Stackoverflow.com/users/15640", "pm_score": 2, "selected": true, "text": "=If(AND({list_cell}>=MinVal; {list_cell}<=MaxVal); 1; 0)\n" }, { "answer_id": 70291061, "author": "tzot", "author_id": 6899, "author_profile": "https://Stackoverflow.com/users/6899", "pm_score": 0, "selected": false, "text": "=COUNTIFS(A1:A10, \">\" & B1, A1:A10, \"<\" & B2)\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15158/" ]
181,585
<p>I'm using PowersHell to automate iTunes but find the error handling / waiting for com objects handling to be less than optimal.</p> <p>Example code</p> <pre><code>#Cause an RPC error $iTunes = New-Object -ComObject iTunes.Application $LibrarySource = $iTunes.LibrarySource # Get "playlist" objects for main sections foreach ($PList in $LibrarySource.Playlists) { if($Plist.name -eq "Library") { $Library = $Plist } } do { write-host -ForegroundColor Green "Running a loop" foreach ($Track in $Library.Tracks) { foreach ($FoundTrack in $Library.search("$Track.name", 5)) { # do nothing... we don't care... write-host "." -nonewline } } } while(1) #END </code></pre> <p>Go into itunes and do something that makes it pop up a message - in my case I go into the Party Shuffle and I get a banner "Party shuffle automatically blah blah...." with a "Do not display" message.</p> <p>At this point if running the script will do this repeatedly:</p> <pre><code>+ foreach ($FoundTrack in $Library.search( &lt;&lt;&lt;&lt; "$Track.name", 5)) { Exception calling "Search" with "2" argument(s): "The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVER CALL_RETRYLATER))" At C:\Documents and Settings\Me\My Documents\example.ps1:17 char:45 + foreach ($FoundTrack in $Library.search( &lt;&lt;&lt;&lt; "$Track.name", 5)) { Exception calling "Search" with "2" argument(s): "The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVER CALL_RETRYLATER))" At C:\Documents and Settings\Me\My Documents\example.ps1:17 char:45 </code></pre> <p>If you waited until you you had a dialog box before running the example then instead you'll get this repeatedly:</p> <pre><code>Running a loop You cannot call a method on a null-valued expression. At C:\Documents and Settings\Me\example.ps1:17 char:45 + foreach ($FoundTrack in $Library.search( &lt;&lt;&lt;&lt; "$Track.name", 5)) { </code></pre> <p>That'll be because the $Library handle is invalid.</p> <p>If my example was doing something important - like converting tracks and then deleting the old ones, not handling the error correctly could be fatal to tracks in itunes. I want to harden up the code so that it handles iTunes being busy and will silently retry until it has success. Any suggestions?</p>
[ { "answer_id": 217082, "author": "Emperor XLII", "author_id": 2495, "author_profile": "https://Stackoverflow.com/users/2495", "pm_score": 2, "selected": true, "text": "function retry( [scriptblock]$action, [int]$wait=2, [int]$maxRetries=100 ) {\n $results = $null\n\n $currentRetry = 0\n $success = $false\n while( -not $success ) {\n trap {\n # Set status variables at function scope.\n Set-Variable -scope 1 success $false\n Set-Variable -scope 1 currentRetry ($currentRetry + 1)\n\n if( $currentRetry -gt $maxRetries ) { break }\n\n if( $wait ) { Start-Sleep $wait }\n continue\n }\n\n $success = $true\n $results = . $action\n }\n\n return $results\n}\n foreach $FoundTracks = retry { $Library.search( \"$Track.name\", 5 ) }\nforeach ($FoundTrack in $FoundTracks) { ... }\n $wait $maxRetries $Library.search $ErrorActionPreference Stop" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5330/" ]
181,596
<p>How do you convert a numerical number to an Excel column name in C# without using automation getting the value directly from Excel.</p> <p>Excel 2007 has a possible range of 1 to 16384, which is the number of columns that it supports. The resulting values should be in the form of excel column names, e.g. A, AA, AAA etc.</p>
[ { "answer_id": 181610, "author": "Franci Penov", "author_id": 17028, "author_profile": "https://Stackoverflow.com/users/17028", "pm_score": 3, "selected": false, "text": "int nCol = 127;\nstring sChars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\nstring sCol = \"\";\nwhile (nCol >= 26)\n{\n int nChar = nCol % 26;\n nCol = (nCol - nChar) / 26;\n // You could do some trick with using nChar as offset from 'A', but I am lazy to do it right now.\n sCol = sChars[nChar] + sCol;\n}\nsCol = sChars[nCol] + sCol;\n int nCol = 127;\nstring sChars = \"0ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\nstring sCol = \"\";\nwhile (nCol > 26)\n{\n int nChar = nCol % 26;\n if (nChar == 0)\n nChar = 26;\n nCol = (nCol - nChar) / 26;\n sCol = sChars[nChar] + sCol;\n}\nif (nCol != 0)\n sCol = sChars[nCol] + sCol;\n" }, { "answer_id": 181809, "author": "Peter", "author_id": 5189, "author_profile": "https://Stackoverflow.com/users/5189", "pm_score": 3, "selected": false, "text": "public static string GetStandardExcelColumnName(int columnNumberOneBased)\n{\n int baseValue = Convert.ToInt32('A');\n int columnNumberZeroBased = columnNumberOneBased - 1;\n\n string ret = \"\";\n\n if (columnNumberOneBased > 26)\n {\n ret = GetStandardExcelColumnName(columnNumberZeroBased / 26) ;\n }\n\n return ret + Convert.ToChar(baseValue + (columnNumberZeroBased % 26) );\n}\n" }, { "answer_id": 182009, "author": "RoMa", "author_id": 7690, "author_profile": "https://Stackoverflow.com/users/7690", "pm_score": 5, "selected": false, "text": "def ColIdxToXlName(idx):\n if idx < 1:\n raise ValueError(\"Index is too small\")\n result = \"\"\n while True:\n if idx > 26:\n idx, r = divmod(idx - 1, 26)\n result = chr(r + ord('A')) + result\n else:\n return chr(idx + ord('A') - 1) + result\n\n\nfor i in xrange(1, 1024):\n print \"%4d : %s\" % (i, ColIdxToXlName(i))\n" }, { "answer_id": 182924, "author": "Graham", "author_id": 1826, "author_profile": "https://Stackoverflow.com/users/1826", "pm_score": 11, "selected": true, "text": "private string GetExcelColumnName(int columnNumber)\n{\n string columnName = \"\";\n\n while (columnNumber > 0)\n {\n int modulo = (columnNumber - 1) % 26;\n columnName = Convert.ToChar('A' + modulo) + columnName;\n columnNumber = (columnNumber - modulo) / 26;\n } \n\n return columnName;\n}\n" }, { "answer_id": 260269, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "private String getColumn(int c) {\n String s = \"\";\n do {\n s = (char)('A' + (c % 26)) + s;\n c /= 26;\n } while (c-- > 0);\n return s;\n}\n" }, { "answer_id": 262598, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "Private Function GetExcelColumnName(ByVal aiColNumber As Integer) As String\n Dim BaseValue As Integer = Convert.ToInt32((\"A\").Chars(0)) - 1\n Dim lsReturn As String = String.Empty\n\n If (aiColNumber > 26) Then\n lsReturn = GetExcelColumnName(Convert.ToInt32((Format(aiColNumber / 26, \"0.0\").Split(\".\"))(0)))\n End If\n\n GetExcelColumnName = lsReturn + Convert.ToChar(BaseValue + (aiColNumber Mod 26))\nEnd Function\n" }, { "answer_id": 495651, "author": "vzczc", "author_id": 224, "author_profile": "https://Stackoverflow.com/users/224", "pm_score": 6, "selected": false, "text": "=SUBSTITUTE(ADDRESS(1;colNum;4);\"1\";\"\")\n Function GetColumnName(colNum As Integer) As String\n Dim d As Integer\n Dim m As Integer\n Dim name As String\n d = colNum\n name = \"\"\n Do While (d > 0)\n m = (d - 1) Mod 26\n name = Chr(65 + m) + name\n d = Int((d - m) / 26)\n Loop\n GetColumnName = name\nEnd Function\n" }, { "answer_id": 981606, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "Private Function ColumnName(ByVal ColumnIndex As Integer) As String\n\n Dim Name As String = \"\"\n\n Name = (New Microsoft.Office.Interop.Owc11.Spreadsheet).Columns.Item(ColumnIndex).Address(False, False, Microsoft.Office.Interop.Owc11.XlReferenceStyle.xlA1)\n Name = Split(Name, \":\")(0)\n\n Return Name\n\nEnd Function\n" }, { "answer_id": 1188802, "author": "ShloEmi", "author_id": 2759057, "author_profile": "https://Stackoverflow.com/users/2759057", "pm_score": 2, "selected": false, "text": "public static class ExcelHelper\n{\n private static Dictionary<UInt16, String> l_DictionaryOfColumns;\n\n public static ExcelHelper() {\n l_DictionaryOfColumns = new Dictionary<ushort, string>(256);\n }\n\n public static String GetExcelColumnName(UInt16 l_Column)\n {\n UInt16 l_ColumnCopy = l_Column;\n String l_Chars = \"0ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\n String l_rVal = \"\";\n UInt16 l_Char;\n\n\n if (l_DictionaryOfColumns.ContainsKey(l_Column) == true)\n {\n l_rVal = l_DictionaryOfColumns[l_Column];\n }\n else\n {\n while (l_ColumnCopy > 26)\n {\n l_Char = l_ColumnCopy % 26;\n if (l_Char == 0)\n l_Char = 26;\n\n l_ColumnCopy = (l_ColumnCopy - l_Char) / 26;\n l_rVal = l_Chars[l_Char] + l_rVal;\n }\n if (l_ColumnCopy != 0)\n l_rVal = l_Chars[l_ColumnCopy] + l_rVal;\n\n l_DictionaryOfColumns.ContainsKey(l_Column) = l_rVal;\n }\n\n return l_rVal;\n }\n}\n" }, { "answer_id": 1188888, "author": "ShloEmi", "author_id": 2759057, "author_profile": "https://Stackoverflow.com/users/2759057", "pm_score": 0, "selected": false, "text": "private void Foo()\n{\n l_ExcelApp = new Excel.ApplicationClass();\n l_ExcelApp.ReferenceStyle = Excel.XlReferenceStyle.xlR1C1;\n // ... now reference by R[row]C[column], Ex. A1 <==> R1C1, C6 <==> R3C6, ...\n}\n" }, { "answer_id": 1924991, "author": "Stephen Fuhry", "author_id": 111033, "author_profile": "https://Stackoverflow.com/users/111033", "pm_score": 3, "selected": false, "text": "function GetExcelColumnName($columnNumber) {\n $columnName = '';\n while ($columnNumber > 0) {\n $modulo = ($columnNumber - 1) % 26;\n $columnName = chr(65 + $modulo) . $columnName;\n $columnNumber = (int)(($columnNumber - $modulo) / 26);\n }\n return $columnName;\n}\n" }, { "answer_id": 2472340, "author": "Daniel", "author_id": 296803, "author_profile": "https://Stackoverflow.com/users/296803", "pm_score": 0, "selected": false, "text": "public static string ConvertToAlphaColumnReferenceFromInteger(int columnReference)\n {\n int baseValue = ((int)('A')) - 1 ;\n string lsReturn = String.Empty; \n\n if (columnReference > 26) \n {\n lsReturn = ConvertToAlphaColumnReferenceFromInteger(Convert.ToInt32(Convert.ToDouble(columnReference / 26).ToString().Split('.')[0]));\n } \n\n return lsReturn + Convert.ToChar(baseValue + (columnReference % 26)); \n }\n" }, { "answer_id": 2538716, "author": "Rob", "author_id": 277008, "author_profile": "https://Stackoverflow.com/users/277008", "pm_score": 2, "selected": false, "text": "private var columnNumbers:Array = ['A', 'B', 'C', 'D', 'E', 'F' , 'G', 'H', 'I', 'J', 'K' ,'L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];\n\n private function getExcelColumnName(columnNumber:int) : String{\n var dividend:int = columnNumber;\n var columnName:String = \"\";\n var modulo:int;\n\n while (dividend > 0)\n {\n modulo = (dividend - 1) % 26;\n columnName = columnNumbers[modulo] + columnName;\n dividend = int((dividend - modulo) / 26);\n } \n\n return columnName;\n }\n" }, { "answer_id": 2652855, "author": "Arent Arntzen", "author_id": 318470, "author_profile": "https://Stackoverflow.com/users/318470", "pm_score": 5, "selected": false, "text": "public static string ColumnAdress(int col)\n{\n if (col <= 26) { \n return Convert.ToChar(col + 64).ToString();\n }\n int div = col / 26;\n int mod = col % 26;\n if (mod == 0) {mod = 26;div--;}\n return ColumnAdress(div) + ColumnAdress(mod);\n}\n\npublic static int ColumnNumber(string colAdress)\n{\n int[] digits = new int[colAdress.Length];\n for (int i = 0; i < colAdress.Length; ++i)\n {\n digits[i] = Convert.ToInt32(colAdress[i]) - 64;\n }\n int mul=1;int res=0;\n for (int pos = digits.Length - 1; pos >= 0; --pos)\n {\n res += digits[pos] * mul;\n mul *= 26;\n }\n return res;\n}\n" }, { "answer_id": 3444285, "author": "John", "author_id": 415561, "author_profile": "https://Stackoverflow.com/users/415561", "pm_score": 4, "selected": false, "text": " private string ExcelColumnIndexToName(int Index)\n {\n string range = string.Empty;\n if (Index < 0 ) return range;\n int a = 26;\n int x = (int)Math.Floor(Math.Log((Index) * (a - 1) / a + 1, a));\n Index -= (int)(Math.Pow(a, x) - 1) * a / (a - 1);\n for (int i = x+1; Index + i > 0; i--)\n {\n range = ((char)(65 + Index % a)).ToString() + range;\n Index /= a;\n }\n return range;\n }\n private string ExcelColumnIndexToName(int Index)\n {\n string range = \"\";\n if (Index < 0 ) return range;\n for(int i=1;Index + i > 0;i=0)\n {\n range = ((char)(65 + Index % 26)).ToString() + range;\n Index /= 26;\n }\n if (range.Length > 1) range = ((char)((int)range[0] - 1)).ToString() + range.Substring(1);\n return range;\n }\n" }, { "answer_id": 3550028, "author": "Matt Lewis", "author_id": 428667, "author_profile": "https://Stackoverflow.com/users/428667", "pm_score": 2, "selected": false, "text": "IF(COLUMN()>=26,CHAR(ROUND(COLUMN()/26,1)+64)&CHAR(MOD(COLUMN(),26)+64),CHAR(COLUMN()+64))\n" }, { "answer_id": 4161315, "author": "dirn", "author_id": 505319, "author_profile": "https://Stackoverflow.com/users/505319", "pm_score": -1, "selected": false, "text": " public string ToBase26(int number)\n {\n if (number < 0) return String.Empty;\n\n int remainder = number % 26;\n int value = number / 26;\n\n return value == 0 ?\n String.Format(\"{0}\", Convert.ToChar(65 + remainder)) :\n String.Format(\"{0}{1}\", ToBase26(value - 1), Convert.ToChar(65 + remainder));\n }\n" }, { "answer_id": 4406060, "author": "Balaji.N.S", "author_id": 409596, "author_profile": "https://Stackoverflow.com/users/409596", "pm_score": 3, "selected": false, "text": "public String getExcelColumnName (int columnNumber) \n { \n int dividend = columnNumber; \n int i;\n String columnName = \"\"; \n int modulo; \n while (dividend > 0) \n { \n modulo = (dividend - 1) % 26; \n i = 65 + modulo;\n columnName = new Character((char)i).toString() + columnName; \n dividend = (int)((dividend - modulo) / 26); \n } \n return columnName; \n } \n" }, { "answer_id": 7178621, "author": "JRL", "author_id": 859646, "author_profile": "https://Stackoverflow.com/users/859646", "pm_score": 2, "selected": false, "text": "function GetExcelColumnName(columnNumber: integer): string;\nvar\n dividend, modulo: integer;\nbegin\n Result := '';\n dividend := columnNumber;\n while dividend > 0 do begin\n modulo := (dividend - 1) mod 26;\n Result := Chr(65 + modulo) + Result;\n dividend := (dividend - modulo) div 26;\n end;\nend;\n" }, { "answer_id": 7728793, "author": "lambdapilgrim", "author_id": 329189, "author_profile": "https://Stackoverflow.com/users/329189", "pm_score": 0, "selected": false, "text": "alph = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z')\ndef labelrec(n, res):\n if n<26:\n return alph[n]+res\n else:\n rem = n%26\n res = alph[rem]+res\n n = n/26-1\n return labelrec(n, res)\n print labelrec(16383, '')\n" }, { "answer_id": 7751167, "author": "user932708", "author_id": 932708, "author_profile": "https://Stackoverflow.com/users/932708", "pm_score": 2, "selected": false, "text": "Function CL(ByVal x As Integer) As String\n If x >= 1 And x <= 26 Then\n CL = Chr(x + 64)\n Else\n CL = CL((x - x Mod 26) / 26) & Chr((x Mod 26) + 1 + 64)\n End If\nEnd Function\n" }, { "answer_id": 8739121, "author": "Kelly L", "author_id": 1131589, "author_profile": "https://Stackoverflow.com/users/1131589", "pm_score": 2, "selected": false, "text": "private static readonly string _Alphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\npublic static int ColumnNameParse(string value)\n{\n // assumes value.Length is [1,3]\n // assumes value is uppercase\n var digits = value.PadLeft(3).Select(x => _Alphabet.IndexOf(x));\n return digits.Aggregate(0, (current, index) => (current * 26) + (index + 1));\n}\n" }, { "answer_id": 9432623, "author": "Hasan", "author_id": 1060041, "author_profile": "https://Stackoverflow.com/users/1060041", "pm_score": 1, "selected": false, "text": "private String getExcelColumnName(int columnNumber) {\n\n int dividend = columnNumber;\n String columnName = \"\";\n int modulo;\n\n while (dividend > 0)\n {\n modulo = (dividend - 1) % 26;\n\n char val = Character.valueOf((char)(65 + modulo));\n\n columnName += val;\n\n dividend = (int)((dividend - modulo) / 26);\n } \n\n return columnName;\n}\n" }, { "answer_id": 10201665, "author": "Myforwik", "author_id": 70189, "author_profile": "https://Stackoverflow.com/users/70189", "pm_score": 2, "selected": false, "text": "sub excel_colname {\n my ($idx) = @_; # one-based column number\n --$idx; # zero-based column index\n my $name = \"\";\n while ($idx >= 0) {\n $name .= chr(ord(\"A\") + ($idx % 26));\n $idx = int($idx / 26) - 1;\n }\n return scalar reverse $name;\n}\n" }, { "answer_id": 14780053, "author": "user2023861", "author_id": 2023861, "author_profile": "https://Stackoverflow.com/users/2023861", "pm_score": 3, "selected": false, "text": "private static string Turn(uint col)\n{\n if (col < 1 || col > 16384) //Excel columns are one-based (one = 'A')\n throw new ArgumentException(\"col must be >= 1 and <= 16384\");\n\n if (col <= 26) //one character\n return ((char)(col + 'A' - 1)).ToString();\n\n else if (col <= 702) //two characters\n {\n char firstChar = (char)((int)((col - 1) / 26) + 'A' - 1);\n char secondChar = (char)(col % 26 + 'A' - 1);\n\n if (secondChar == '@') //Excel is one-based, but modulo operations are zero-based\n secondChar = 'Z'; //convert one-based to zero-based\n\n return string.Format(\"{0}{1}\", firstChar, secondChar);\n }\n\n else //three characters\n {\n char firstChar = (char)((int)((col - 1) / 702) + 'A' - 1);\n char secondChar = (char)((col - 1) / 26 % 26 + 'A' - 1);\n char thirdChar = (char)(col % 26 + 'A' - 1);\n\n if (thirdChar == '@') //Excel is one-based, but modulo operations are zero-based\n thirdChar = 'Z'; //convert one-based to zero-based\n\n return string.Format(\"{0}{1}{2}\", firstChar, secondChar, thirdChar);\n }\n}\n" }, { "answer_id": 15678976, "author": "MaVRoSCy", "author_id": 1387157, "author_profile": "https://Stackoverflow.com/users/1387157", "pm_score": 4, "selected": false, "text": "function getCharFromNumber(columnNumber){\n var dividend = columnNumber;\n var columnName = \"\";\n var modulo;\n\n while (dividend > 0)\n {\n modulo = (dividend - 1) % 26;\n columnName = String.fromCharCode(65 + modulo).toString() + columnName;\n dividend = parseInt((dividend - modulo) / 26);\n } \n return columnName;\n}\n" }, { "answer_id": 16327664, "author": "Ian Atkin", "author_id": 1315142, "author_profile": "https://Stackoverflow.com/users/1315142", "pm_score": 1, "selected": false, "text": "public function GetColumn($intNumber, $strCol = null) {\n\n if ($intNumber > 0) {\n $intRem = ($intNumber - 1) % 26;\n $strCol = $this->GetColumn(intval(($intNumber - $intRem) / 26), sprintf('%s%s', chr(65 + $intRem), $strCol));\n }\n\n return $strCol;\n}\n" }, { "answer_id": 19155871, "author": "Ally", "author_id": 837649, "author_profile": "https://Stackoverflow.com/users/837649", "pm_score": 2, "selected": false, "text": "/**\n * Calculate the column letter abbreviation from a 1 based index\n * @param {Number} value\n * @returns {string}\n */\ngetColumnFromIndex = function (value) {\n var base = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');\n var remainder, result = \"\";\n do {\n remainder = value % 26;\n result = base[(remainder || 26) - 1] + result;\n value = Math.floor(value / 26);\n } while (value > 0);\n return result;\n};\n" }, { "answer_id": 21330107, "author": "Ian", "author_id": 578821, "author_profile": "https://Stackoverflow.com/users/578821", "pm_score": 0, "selected": false, "text": "// Convert row and column numbers (0-based) to an Excel cell reference\nCellReference numbers = new CellReference(3, 28);\nSystem.out.println(numbers.formatAsString());\n\n// Convert an Excel cell reference back into digits\nCellReference reference = new CellReference(\"AC4\");\nSystem.out.println(reference.getRow() + \", \" + reference.getCol());\n" }, { "answer_id": 21924093, "author": "Paul Ma", "author_id": 1497459, "author_profile": "https://Stackoverflow.com/users/1497459", "pm_score": 2, "selected": false, "text": "Public Function GetColumnName(TargetCell As Range) As String\n GetColumnName = Split(CStr(TargetCell.Cells(1, 1).Address), \"$\")(1)\nEnd Function\n" }, { "answer_id": 26063181, "author": "t3dodson", "author_id": 2175572, "author_profile": "https://Stackoverflow.com/users/2175572", "pm_score": 3, "selected": false, "text": "public static class Extensions\n{\n public static string ColumnLabel(this int col)\n {\n var dividend = col;\n var columnLabel = string.Empty;\n int modulo;\n\n while (dividend > 0)\n {\n modulo = (dividend - 1) % 26;\n columnLabel = Convert.ToChar(65 + modulo).ToString() + columnLabel;\n dividend = (int)((dividend - modulo) / 26);\n } \n\n return columnLabel;\n }\n public static int ColumnIndex(this string colLabel)\n {\n // \"AD\" (1 * 26^1) + (4 * 26^0) ...\n var colIndex = 0;\n for(int ind = 0, pow = colLabel.Count()-1; ind < colLabel.Count(); ++ind, --pow)\n {\n var cVal = Convert.ToInt32(colLabel[ind]) - 64; //col A is index 1\n colIndex += cVal * ((int)Math.Pow(26, pow));\n }\n return colIndex;\n }\n}\n 30.ColumnLabel(); // \"AD\"\n\"AD\".ColumnIndex(); // 30\n" }, { "answer_id": 29550239, "author": "S_R", "author_id": 4004421, "author_profile": "https://Stackoverflow.com/users/4004421", "pm_score": 2, "selected": false, "text": " public static string NumberToExcelColumn(uint number)\n {\n uint originalNumber = number;\n\n uint numChars = 1;\n while (Math.Pow(26, numChars) < number)\n {\n numChars++;\n\n if (Math.Pow(26, numChars) + 26 >= number)\n {\n break;\n } \n }\n\n string toRet = \"\";\n uint lastValue = 0;\n\n do\n {\n number -= lastValue;\n\n double powerVal = Math.Pow(26, numChars - 1);\n byte thisCharIdx = (byte)Math.Truncate((columnNumber - 1) / powerVal);\n lastValue = (int)powerVal * thisCharIdx;\n\n if (numChars - 2 >= 0)\n {\n double powerVal_next = Math.Pow(26, numChars - 2);\n byte thisCharIdx_next = (byte)Math.Truncate((columnNumber - lastValue - 1) / powerVal_next);\n int lastValue_next = (int)Math.Pow(26, numChars - 2) * thisCharIdx_next;\n\n if (thisCharIdx_next == 0 && lastValue_next == 0 && powerVal_next == 26)\n {\n thisCharIdx--;\n lastValue = (int)powerVal * thisCharIdx;\n }\n }\n\n toRet += (char)((byte)'A' + thisCharIdx + ((numChars > 1) ? -1 : 0));\n\n numChars--;\n } while (numChars > 0);\n\n return toRet;\n }\n [TestMethod]\n public void Test()\n {\n Assert.AreEqual(\"A\", NumberToExcelColumn(1));\n Assert.AreEqual(\"Z\", NumberToExcelColumn(26));\n Assert.AreEqual(\"AA\", NumberToExcelColumn(27));\n Assert.AreEqual(\"AO\", NumberToExcelColumn(41));\n Assert.AreEqual(\"AZ\", NumberToExcelColumn(52));\n Assert.AreEqual(\"BA\", NumberToExcelColumn(53));\n Assert.AreEqual(\"ZZ\", NumberToExcelColumn(702));\n Assert.AreEqual(\"AAA\", NumberToExcelColumn(703));\n Assert.AreEqual(\"ABC\", NumberToExcelColumn(731));\n Assert.AreEqual(\"ACQ\", NumberToExcelColumn(771));\n Assert.AreEqual(\"AYZ\", NumberToExcelColumn(1352));\n Assert.AreEqual(\"AZA\", NumberToExcelColumn(1353));\n Assert.AreEqual(\"AZB\", NumberToExcelColumn(1354));\n Assert.AreEqual(\"BAA\", NumberToExcelColumn(1379));\n Assert.AreEqual(\"CNU\", NumberToExcelColumn(2413));\n Assert.AreEqual(\"GCM\", NumberToExcelColumn(4823));\n Assert.AreEqual(\"MSR\", NumberToExcelColumn(9300));\n Assert.AreEqual(\"OMB\", NumberToExcelColumn(10480));\n Assert.AreEqual(\"ULV\", NumberToExcelColumn(14530));\n Assert.AreEqual(\"XFD\", NumberToExcelColumn(16384));\n }\n" }, { "answer_id": 29846532, "author": "Iwan B.", "author_id": 731228, "author_profile": "https://Stackoverflow.com/users/731228", "pm_score": 1, "selected": false, "text": "def col_name(col_idx)\n name = \"\"\n while col_idx>0\n mod = (col_idx-1)%26\n name = (65+mod).chr + name\n col_idx = ((col_idx-mod)/26).to_i\n end\n name\nend\n" }, { "answer_id": 30913322, "author": "Hangarter", "author_id": 3938098, "author_profile": "https://Stackoverflow.com/users/3938098", "pm_score": 0, "selected": false, "text": "private static string GetColumnLetter(string colNumber)\n{\n if (string.IsNullOrEmpty(colNumber))\n {\n throw new ArgumentNullException(colNumber);\n }\n\n string colName = String.Empty;\n\n try\n {\n var colNum = Convert.ToInt32(colNumber);\n var mod = colNum % 26;\n var div = Math.Floor((double)(colNum)/26);\n colName = ((div > 0) ? GetColumnLetter((div - 1).ToString()) : String.Empty) + Convert.ToChar(mod + 65);\n }\n finally\n {\n colName = colName == String.Empty ? \"A\" : colName;\n }\n\n return colName;\n}\n" }, { "answer_id": 31757052, "author": "bpolat", "author_id": 2231118, "author_profile": "https://Stackoverflow.com/users/2231118", "pm_score": 0, "selected": false, "text": "-(NSString*)getColumnName:(int)n {\n NSString *name = @\"\";\n while (n>0) {\n n--;\n char c = (char)('A' + n%26);\n name = [NSString stringWithFormat:@\"%c%@\",c,name];\n n = n/26;\n } \n return name;\n func getColumnName(n:Int)->String{\n var columnName = \"\"\n var index = n\n while index>0 {\n index--\n let char = Character(UnicodeScalar(65 + index%26))\n columnName = \"\\(char)\\(columnName)\"\n index = index / 26\n }\n return columnName\n" }, { "answer_id": 31900180, "author": "Rob Sawyer", "author_id": 67524, "author_profile": "https://Stackoverflow.com/users/67524", "pm_score": 1, "selected": false, "text": "/**\n* getColumnFromIndex\n* Helper that returns a column value (A-XFD) for an index value (integer).\n* The column follows the Common Spreadsheet Format e.g., A, AA, AAA.\n* See https://stackoverflow.com/questions/181596/how-to-convert-a-column-number-eg-127-into-an-excel-column-eg-aa/3444285#3444285\n* @param numVal: Integer\n* @return String\n*/\ngetColumnFromIndex: function(numVal){\n var dividend = parseInt(numVal);\n var columnName = '';\n var modulo;\n while (dividend > 0) {\n modulo = (dividend - 1) % 26;\n columnName = String.fromCharCode(65 + modulo) + columnName;\n dividend = parseInt((dividend - modulo) / 26);\n }\n return columnName;\n},\n /**\n* getIndexFromColumn\n* Helper that returns an index value (integer) for a column value (A-XFD).\n* The column follows the Common Spreadsheet Format e.g., A, AA, AAA.\n* See https://stackoverflow.com/questions/9905533/convert-excel-column-alphabet-e-g-aa-to-number-e-g-25\n* @param strVal: String\n* @return Integer\n*/\ngetIndexFromColumn: function(val){\n var base = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', i, j, result = 0;\n for (i = 0, j = val.length - 1; i < val.length; i += 1, j -= 1) {\n result += Math.pow(base.length, j) * (base.indexOf(val[i]) + 1);\n }\n return result;\n}\n" }, { "answer_id": 33702966, "author": "SierraOscar", "author_id": 4240221, "author_profile": "https://Stackoverflow.com/users/4240221", "pm_score": 0, "selected": false, "text": "Function GetColLetter(ByVal colID As Integer) As String\n If colID > Columns.Count Then\n Err.Raise 9, , \"Column index out of bounds\"\n Else\n GetColLetter = Split(Cells(1, colID).Address, \"$\")(1)\n End If\nEnd Function\n" }, { "answer_id": 39018386, "author": "Herman Kan", "author_id": 1997693, "author_profile": "https://Stackoverflow.com/users/1997693", "pm_score": 2, "selected": false, "text": "modulo ToString() (int) public static string GetColumnName(int index) // zero-based\n{\n const byte BASE = 'Z' - 'A' + 1;\n string name = String.Empty;\n\n do\n {\n name = Convert.ToChar('A' + index % BASE) + name;\n index = index / BASE - 1;\n }\n while (index >= 0);\n\n return name;\n}\n" }, { "answer_id": 41148862, "author": "Maslow", "author_id": 57883, "author_profile": "https://Stackoverflow.com/users/57883", "pm_score": 1, "selected": false, "text": "let rec getExcelColumnName x = if x<26 then int 'A'+x|>char|>string else (x/26-1|>c)+ c(x%26)\n // return values start at 0\nlet getIndexFromExcelColumnName (x:string) =\n let a = int 'A'\n let fPow len i =\n Math.Pow(26., len - 1 - i |> float)\n |> int\n\n let getValue len i c = \n int c - a + 1 * fPow len i\n let f i = getValue x.Length i x.[i]\n [0 .. x.Length - 1]\n |> Seq.map f\n |> Seq.sum\n |> fun x -> x - 1\n" }, { "answer_id": 41817847, "author": "Extragorey", "author_id": 6680521, "author_profile": "https://Stackoverflow.com/users/6680521", "pm_score": 3, "selected": false, "text": "/// <summary>\n/// Gets the column letter(s) corresponding to the given column number.\n/// </summary>\n/// <param name=\"column\">The one-based column index. Must be greater than zero.</param>\n/// <returns>The desired column letter, or an empty string if the column number was invalid.</returns>\npublic static string GetColumnLetter(int column) {\n if (column < 1) return String.Empty;\n return GetColumnLetter((column - 1) / 26) + (char)('A' + (column - 1) % 26);\n}\n" }, { "answer_id": 42949724, "author": "Vlad Schnakovszki", "author_id": 1195527, "author_profile": "https://Stackoverflow.com/users/1195527", "pm_score": 1, "selected": false, "text": "public static char ColIndexToLetter(short index)\n{\n if (index < 0 || index > 25) throw new ArgumentException(\"Index must be between 0 and 25.\");\n return (char)('A' + index);\n}\n (char)('A' + index)\n" }, { "answer_id": 46165397, "author": "phlare", "author_id": 6845867, "author_profile": "https://Stackoverflow.com/users/6845867", "pm_score": 1, "selected": false, "text": "def number_to_column(number) do\n cond do\n (number > 0 && number <= 26) ->\n to_string([(number + 64)])\n (number > 26) ->\n div_col = number_to_column(div(number - 1, 26))\n remainder = rem(number, 26)\n rem_col = cond do\n (remainder == 0) ->\n number_to_column(26)\n true ->\n number_to_column(remainder)\n end\n div_col <> rem_col\n true ->\n \"\"\n end\nend\n def column_to_number(column) do\n column\n |> to_charlist\n |> Enum.reverse\n |> Enum.with_index\n |> Enum.reduce(0, fn({char, idx}, acc) ->\n ((char - 64) * :math.pow(26,idx)) + acc\n end)\n |> round\nend\n describe \"test excel functions\" do\n @excelTestData [{\"A\", 1}, {\"Z\",26}, {\"AA\", 27}, {\"AB\", 28}, {\"AZ\", 52},{\"BA\", 53}, {\"AAA\", 703}]\n\n test \"column to number\" do\n Enum.each(@excelTestData, fn({input, expected_result}) ->\n actual_result = BulkOnboardingController.column_to_number(input)\n assert actual_result == expected_result\n end)\n end\n\n test \"number to column\" do\n Enum.each(@excelTestData, fn({expected_result, input}) ->\n actual_result = BulkOnboardingController.number_to_column(input)\n assert actual_result == expected_result\n end)\n end\nend\n" }, { "answer_id": 47124842, "author": "DataEngineer", "author_id": 7271239, "author_profile": "https://Stackoverflow.com/users/7271239", "pm_score": 2, "selected": false, "text": "def excel_column_number_to_name(column_number):\n output = \"\"\n index = column_number-1\n while index >= 0:\n character = chr((index%26)+ord('A'))\n output = output + character\n index = index/26 - 1\n\n return output[::-1]\n\n\nfor i in xrange(1, 1024):\n print \"%4d : %s\" % (i, excel_column_number_to_name(i))\n" }, { "answer_id": 51805461, "author": "Phoeson", "author_id": 1799100, "author_profile": "https://Stackoverflow.com/users/1799100", "pm_score": 1, "selected": false, "text": "function (columnNumber) {\n var dividend = columnNumber;\n var columnName = \"\";\n var modulo;\n\n while (dividend > 0) {\n modulo = (dividend - 1) % 26;\n columnName = String.fromCharCode(65 + modulo) + columnName;\n dividend = parseInt((dividend - modulo) / 26);\n }\n\n return columnName;\n};\n" }, { "answer_id": 52790077, "author": "user1098928", "author_id": 1098928, "author_profile": "https://Stackoverflow.com/users/1098928", "pm_score": 2, "selected": false, "text": "function ConvertTo-ExcelColumnID {\nparam (\n [parameter(Position = 0,\n HelpMessage = \"A 1-based index to convert to an excel column ID. e.g. 2 => 'B', 29 => 'AC'\",\n Mandatory = $true)]\n [int]$index\n);\n\n[string]$result = '';\nif ($index -le 0 ) {\n return $result;\n}\n\nwhile ($index -gt 0) {\n [int]$modulo = ($index - 1) % 26;\n $character = [char]($modulo + [int][char]'A');\n $result = $character + $result;\n [int]$index = ($index - $modulo) / 26;\n}\n\nreturn $result;\n" }, { "answer_id": 53039230, "author": "grepit", "author_id": 717630, "author_profile": "https://Stackoverflow.com/users/717630", "pm_score": 1, "selected": false, "text": "def convert_num_to_column(column_num):\n result = \"\"\n quotient = column_num\n remainder = 0\n while (quotient >0):\n quotient = quotient -1\n remainder = quotient%26\n result = chr(int(remainder)+97)+result\n quotient = int(quotient/26)\n return result\n\nprint(\"--\",convert_num_to_column(1).upper())\n" }, { "answer_id": 56959174, "author": "AlishahNovin", "author_id": 212434, "author_profile": "https://Stackoverflow.com/users/212434", "pm_score": 2, "selected": false, "text": "public string IntToExcelColumn(int i)\n{\n return ((i<16926? \"\" : ((char)((((i/26)-1)%26)+65)).ToString()) + (i<2730? \"\" : ((char)((((i/26)-1)%26)+65)).ToString()) + (i<26? \"\" : ((char)((((i/26)-1)%26)+65)).ToString()) + ((char)((i%26)+65)));\n}\n" }, { "answer_id": 58386648, "author": "Ricky", "author_id": 11003725, "author_profile": "https://Stackoverflow.com/users/11003725", "pm_score": -1, "selected": false, "text": "import math\n\nnum = 3500\nrow_number = str(math.ceil(num / 702))\nletters = ''\nnum = num - 702 * math.floor(num / 702)\nwhile num:\n mod = (num - 1) % 26\n letters += chr(mod + 65)\n num = (num - 1) // 26\nresult = row_number + (\"\".join(reversed(letters)))\nprint(result)\n\n" }, { "answer_id": 59755393, "author": "Tyler", "author_id": 3640355, "author_profile": "https://Stackoverflow.com/users/3640355", "pm_score": 0, "selected": false, "text": "function lengthToExcelColumn(len: number): string {\n\n let dividend: number = len;\n let columnName: string = '';\n let modulo: number = 0;\n\n while (dividend > 0) {\n modulo = (dividend - 1) % 26;\n columnName = String.fromCharCode(65 + modulo).toString() + columnName;\n dividend = Math.floor((dividend - modulo) / 26);\n }\n return columnName;\n}\n" }, { "answer_id": 60234558, "author": "Konstantin Gredeskoul", "author_id": 542553, "author_profile": "https://Stackoverflow.com/users/542553", "pm_score": 0, "selected": false, "text": "COLUMNS # vim: ft=ruby\n class Numeric\n COLUMNS = ('A'..'Z').to_a\n\n def to_excel_column(n = self)\n n < 1 ? '' : begin\n base = COLUMNS.size\n to_excel_column((n - 1) / base) + COLUMNS[(n - 1) % base]\n end\n end\n end\n\n # verify:\n (1..52).each { |i| printf \"%4d => %4s\\n\", i, i.to_excel_column }\n 1 => A\n 2 => B\n 3 => C\n ....\n 33 => AG\n 34 => AH\n 35 => AI\n 36 => AJ\n 37 => AK\n 38 => AL\n 39 => AM\n 40 => AN\n 41 => AO\n 42 => AP\n 43 => AQ\n 44 => AR\n 45 => AS\n 46 => AT\n 47 => AU\n 48 => AV\n 49 => AW\n 50 => AX\n 51 => AY\n 52 => AZ\n" }, { "answer_id": 60323894, "author": "Pranav Mishra", "author_id": 1697718, "author_profile": "https://Stackoverflow.com/users/1697718", "pm_score": 0, "selected": false, "text": " static string GetExcelColumnName(long columnNumber)\n {\n //max number of column per row\n const long maxColPerRow = 702;\n //find row number\n long rowNum = (columnNumber / maxColPerRow);\n //find tierable columns in the row.\n long dividend = columnNumber - (maxColPerRow * rowNum);\n\n string columnName = String.Empty;\n\n long modulo;\n\n while (dividend > 0)\n {\n modulo = (dividend - 1) % 26;\n columnName = Convert.ToChar(65 + modulo).ToString() + columnName;\n dividend = (int)((dividend - modulo) / 26);\n }\n\n return rowNum+1+ columnName;\n }\n}\n" }, { "answer_id": 60853972, "author": "Agneum", "author_id": 4774960, "author_profile": "https://Stackoverflow.com/users/4774960", "pm_score": 0, "selected": false, "text": "CREATE FUNCTION dbo.getExcelColumnNameByOrdinal(@RowNum int) \nRETURNS varchar(5) \nAS \nBEGIN \n DECLARE @dividend int = @RowNum;\n DECLARE @columnName varchar(max) = '';\n DECLARE @modulo int;\n\n WHILE (@dividend > 0)\n BEGIN \n SELECT @modulo = ((@dividend - 1) % 26);\n SELECT @columnName = CHAR((65 + @modulo)) + @columnName;\n SELECT @dividend = CAST(((@dividend - @modulo) / 26) as int);\n END\n RETURN \n @columnName;\n\nEND;\n" }, { "answer_id": 63238554, "author": "Hunter", "author_id": 416207, "author_profile": "https://Stackoverflow.com/users/416207", "pm_score": 0, "selected": false, "text": " public static string GetColumnIndexNumberToExcelColumn(int columnIndex)\n {\n int offset = columnIndex % 26;\n int multiple = columnIndex / 26;\n\n int initialSeed = 65;//Represents column \"A\"\n if (multiple == 0)\n {\n return Convert.ToChar(initialSeed + offset).ToString();\n }\n\n return $\"{Convert.ToChar(initialSeed + multiple - 1)}{Convert.ToChar(initialSeed + offset)}\";\n }\n" }, { "answer_id": 66651166, "author": "Chirag Sheth", "author_id": 12910923, "author_profile": "https://Stackoverflow.com/users/12910923", "pm_score": 1, "selected": false, "text": "string columnName = columnNumber > 26 ? Convert.ToChar(64 + (columnNumber / 26)).ToString() + Convert.ToChar(64 + (columnNumber % 26)) : Convert.ToChar(64 + columnNumber).ToString();\n" }, { "answer_id": 72162327, "author": "desseim", "author_id": 3055345, "author_profile": "https://Stackoverflow.com/users/3055345", "pm_score": 3, "selected": false, "text": "702 26*26 + 26 110 1x26^2 + 1x26^1 + 0x26^0 ZZ 26x26^1 + 26x26^0 k m f m - (f(m / k) * k)\n f(m / k) f(m / k) k digit() digit(1) A fun conv(m)\n q = f(m / k)\n a = m - (q * k)\n if (q == 0)\n return digit(a)\n else\n return conv(q) + digit(a);\n ToBijective() class BijectiveNumeration {\n private int baseK;\n private Func<int, char> getDigit;\n public BijectiveNumeration(int baseK, Func<int, char> getDigit) {\n this.baseK = baseK;\n this.getDigit = getDigit;\n }\n\n public string ToBijective(double decimalValue) {\n double q = f(decimalValue / baseK);\n double a = decimalValue - (q * baseK);\n return ((q > 0) ? ToBijective(q) : \"\") + getDigit((int)a);\n }\n\n private static double f(double i) {\n return (Math.Ceiling(i) - 1);\n }\n}\n static void Main(string[] args)\n{\n BijectiveNumeration bijBase26 = new BijectiveNumeration(\n 26,\n (value) => Convert.ToChar('A' + (value - 1))\n );\n\n Console.WriteLine(bijBase26.ToBijective(1)); // prints \"A\"\n Console.WriteLine(bijBase26.ToBijective(26)); // prints \"Z\"\n Console.WriteLine(bijBase26.ToBijective(27)); // prints \"AA\"\n Console.WriteLine(bijBase26.ToBijective(702)); // prints \"ZZ\"\n Console.WriteLine(bijBase26.ToBijective(16384)); // prints \"XFD\"\n}\n 16384 XFD static void Main(string[] args)\n{\n BijectiveNumeration bijBase10 = new BijectiveNumeration(\n 10,\n (value) => value < 10 ? Convert.ToChar('0'+value) : 'A'\n );\n\n Console.WriteLine(bijBase10.ToBijective(1)); // prints \"1\"\n Console.WriteLine(bijBase10.ToBijective(10)); // prints \"A\"\n Console.WriteLine(bijBase10.ToBijective(123)); // prints \"123\"\n Console.WriteLine(bijBase10.ToBijective(20)); // prints \"1A\"\n Console.WriteLine(bijBase10.ToBijective(100)); // prints \"9A\"\n Console.WriteLine(bijBase10.ToBijective(101)); // prints \"A1\"\n Console.WriteLine(bijBase10.ToBijective(2010)); // prints \"19AA\"\n}\n" }, { "answer_id": 72744619, "author": "Ramil Shavaleev", "author_id": 7250868, "author_profile": "https://Stackoverflow.com/users/7250868", "pm_score": 0, "selected": false, "text": "internal class Program\n{\n #region get_excel_col_name\n /// <summary>\n /// Returns the name of the column by its number\n /// </summary>\n /// <param name=\"col_num\">Column number</param>\n /// <returns>Column name</returns>\n /// <remarks>Numbering columns from zero</remarks>\n private static string get_excel_col_name(int col_num)\n {\n StringBuilder sb = new StringBuilder(2);\n if (col_num >= 0)\n {\n do\n {\n sb.Insert(0, (char)(col_num % 26 + 65));\n col_num /= 26;\n }\n while (--col_num >= 0);\n }\n return sb.ToString();\n }\n #endregion\n\n private static void Main(string[] args)\n {\n Console.WriteLine(get_excel_col_name(34));//outputs AI\n Console.ReadKey(true);\n }\n}\n" }, { "answer_id": 73153547, "author": "yuriy", "author_id": 1095566, "author_profile": "https://Stackoverflow.com/users/1095566", "pm_score": 0, "selected": false, "text": " static string[] ExcelColumnAlphabetIdentifiers = new string[] { \"\", \"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\", \"J\", \"K\", \"L\", \"M\", \"N\", \n \"O\", \"P\", \"Q\", \"R\", \"S\", \"T\", \"U\", \"V\", \"W\", \"X\", \"Y\", \"Z\" };\n public static string ExcelColumnAlphabetIdentifier( int ColumnNumber)\n {\n StringBuilder sb = new StringBuilder();\n int remainder = ColumnNumber;\n do\n {\n sb.Append(ExcelColumnAlphabetIdentifiers[remainder % 26]);\n remainder = remainder / 26;\n }\n while (remainder > 0);\n return sb.ToString();\n }\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3851/" ]
181,597
<p>We are in the process of nutting out the design guidelines we would like to use in our development team and got into a discussion today around how ASP.NET controls should be named. I am talking about our good friends Label, TextBox, Button etc.</p> <p>We came up with the following three possibilities that we voted on: (Example is a TextBox to enter/display a FirstName)</p> <ol> <li>Add the control type as a postfix to your controls ID: [FirstName<code>_</code>TextBox] or [FirstName<code>_</code>tbx]</li> <li>Add the control type as a prefix to your controls ID [tbxFirstName]</li> <li>Set the ID of the control to FirstName and name related fields (like a label for the textbox or a validator) as in option 2 [lblTextBox].</li> </ol> <p>We ended up deciding to use option 2. It's not as verbose as option 1 and I like that it specifies what control it is before the name of the control.</p> <p>My question is whether Microsoft has released any guidelines for these prefixes and or if you have any comments about our decision.</p>
[ { "answer_id": 181823, "author": "WebDude", "author_id": 15360, "author_profile": "https://Stackoverflow.com/users/15360", "pm_score": 5, "selected": false, "text": "Abbr - Control\n\nbtn - Button\ncb - CheckBox\ncbl - CheckBoxList\ndd - DropDownList\ngv - GridView\nhl - Hyperlink\nimg - Image\nib - ImageButton\nlbl - Label\nlbtn - LinkButton\nlb - ListBox\nlit - Literal\npnl - Panel\nph - PlaceHolder\nrb - RadioButton\nrbl - RadioButtonList\ntxt - Textbox\n" }, { "answer_id": 182583, "author": "Davy Landman", "author_id": 11098, "author_profile": "https://Stackoverflow.com/users/11098", "pm_score": 0, "selected": false, "text": "var newCustomer = new Customer();\nnewCustomer.Name = txtName.Value;\nnewCustomer.Address = txtAddress.Value;\nnewCustomer.City = txtCity.Value;\nnewCustomer.HasEnoughMoney = cbHasMoney.Selected;\n var newCustomer = new Customer();\nnewCustomer.Name = name.Value;\nnewCustomer.Address = address.Value;\nnewCustomer.City = city.Value;\nnewCustomer.HasEnoughMoney = hasMoney.Selected;\n" }, { "answer_id": 25086425, "author": "Sherif Hamdy", "author_id": 3696206, "author_profile": "https://Stackoverflow.com/users/3696206", "pm_score": 1, "selected": false, "text": "Abbreviation || ASP.NET Control\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/202/" ]
181,605
<p>I wrote a wrapper for a COM object that only excepted strings as input, so in good OOP practice I wrapped the string up in a function so that it was easier to build and call.</p> <p>I was just wondering if anyone could think of a better way to do the following code. </p> <pre><code> Public Function OpenTable(ByVal TablePath As String, Optional ByVal OpenAs As String = Nothing, _ Optional ByVal Hide As Boolean = False, Optional ByVal AsReadOnly As Boolean = False, _ Optional ByVal Interactive As Boolean = True, Optional ByVal Password As String = Nothing, _ Optional ByVal NoIndex As Boolean = False, Optional ByVal ViewAutomatic As Boolean = True) As TableInfo If String.IsNullOrEmpty(TablePath) Then Throw New ArgumentNullException("TablePath", "TablePath cannot be null or empty") End If Dim Builder = New StringBuilder("Open Table ") Builder.AppendFormat("{0}{1}{2}", ControlChars.Quote, TablePath, ControlChars.Quote) If (Not String.IsNullOrEmpty(OpenAs)) Then Builder.AppendFormat(" as {0} ", OpenAs) If (Hide) Then Builder.Append(" Hide ") If (AsReadOnly) Then Builder.Append(" ReadOnly ") If (Interactive) Then Builder.Append(" Interactive ") If (Not String.IsNullOrEmpty(Password)) Then Builder.AppendFormat(" Password {0} ", Password) If (NoIndex) Then Builder.Append(" NoIndex ") If (ViewAutomatic) Then Builder.Append(" View Automatic ") MyComApp.Do(Builder.ToString) Dim FileInfo = New IO.FileInfo(TablePath) Return New TableInfo(FileInfo.Name.Substring(0, InStrRev(FileInfo.Name, ".") - 1)) End Function </code></pre> <p>The amount of arguments that the function has to take is my biggest worry. This one is not too bad but there are some other functions that I may have to make in the future that will take a lot more arguments, so I'm mainly looking for better ways to build large argument functions.</p>
[ { "answer_id": 181616, "author": "Alexander Morland", "author_id": 4013, "author_profile": "https://Stackoverflow.com/users/4013", "pm_score": 0, "selected": false, "text": "function OpenTable( options As array) {\n if (options is not array or options is empty) {\n Throw exception\n }\n return_string = \"\";\n if ( key is set ('readOnly', options) and is not empty) {\n return_string = return_string + ' readonly';\n }\n // repeat last 3 lines for all your params\n}\n" }, { "answer_id": 181618, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 2, "selected": false, "text": "OpenTable" }, { "answer_id": 181619, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 3, "selected": true, "text": "class COMConfiguration {\n private bool Hide = false;\n private bool AsReadOnly = false;\n //and so on...\n\n public void setHide(bool v) { Hide = v; }\n\n //only setters\n\n public string getConfigString() {\n StringBuilder sb = new StringBuilder();\n if (Hide) { sb.Append(\" Hide \"); }\n if (AsReadOnly) { sb.Append(\" ReadOnly \"); }\n //and so on\n return sb.ToString()\n }\n}\n" }, { "answer_id": 181639, "author": "Franci Penov", "author_id": 17028, "author_profile": "https://Stackoverflow.com/users/17028", "pm_score": 0, "selected": false, "text": "' Define an Enum with FlagsAttribute.\n<FlagsAttribute( )> _\nEnum TableOptions as Short\n Hide = 1\n AsReadOnly = 2\n Interactive = 4\n NoIndex = 8\n ViewAutomatic = 16\nEnd Enum\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6335/" ]
181,613
<p>This is the unabashed attempt of a similar <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c">C#</a> question.</p> <p>So what are your favorite F# hidden (or not) features?</p> <p>Most of the features I've used so far aren't exactly hidden but have been quite refreshing. Like how trivial it is to overload operators compared to say C# or VB.NET.</p> <p>And <code>Async&lt;T&gt;</code> has helped me shave off some real ugly code.</p> <p>I'm quite new to the language still so it'd be great to learn what other features are being used in the wild.</p>
[ { "answer_id": 1846680, "author": "kvb", "author_id": 82959, "author_profile": "https://Stackoverflow.com/users/82959", "pm_score": 2, "selected": false, "text": "type 'a Wrapper = Wrapper of 'a with\n static member inline (+)(Wrapper(a),Wrapper(b)) = Wrapper(a + b)\n static member inline Exp(Wrapper(a)) = Wrapper(exp a)\n\nlet objWrapper = Wrapper(obj())\nlet intWrapper = (Wrapper 1) + (Wrapper 2)\nlet fltWrapper = exp (Wrapper 1.0)\n\n(* won''t compile *)\nlet _ = exp (Wrapper 1)\n" }, { "answer_id": 1846741, "author": "kvb", "author_id": 82959, "author_profile": "https://Stackoverflow.com/users/82959", "pm_score": 5, "selected": false, "text": "NumericLiteral FromZero FromOne LanguagePrimitives.GenericZero LanguagePrimitives.GenericOne module NumericLiteralG = begin\n let inline FromZero() = LanguagePrimitives.GenericZero\n let inline FromOne() = LanguagePrimitives.GenericOne\nend\n\nlet inline genericFactorial n =\n let rec fact n = if (n = 0G) then 1G else n * (fact (n - 1G))\n fact n\n\nlet flt = genericFactorial 30.\nlet bigI = genericFactorial 30I\n" }, { "answer_id": 3138320, "author": "Brian", "author_id": 19299, "author_profile": "https://Stackoverflow.com/users/19299", "pm_score": 3, "selected": false, "text": "--warnon:1182" }, { "answer_id": 3141668, "author": "Dan Fitch", "author_id": 27614, "author_profile": "https://Stackoverflow.com/users/27614", "pm_score": 3, "selected": false, "text": "let listEven =\n \"Manipulating strings can be intriguing using F#\".Split ' '\n |> List.ofArray\n |> List.map (fun x -> (x.Length % 2 = 0, x.Contains \"i\"), x)\n |> List.choose \n ( function (true, true), s -> Some s \n | _, \"F#\" -> Some \"language\" \n | _ -> None ) \n" }, { "answer_id": 3869778, "author": "Brian", "author_id": 19299, "author_profile": "https://Stackoverflow.com/users/19299", "pm_score": 3, "selected": false, "text": "<appSettings>\n <add key=\"fsharp-navigationbar-enabled\" value=\"true\" />\n</appSettings>\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8280/" ]
181,615
<p>I have a program 'foo' running different threads, fooT1, fooT2, .. fooTn.</p> <p>Now if I want write another program 'bar', which could kill the thread fooTr, is that possible?</p> <p>Reason: One of the thread fooTr tracks product license. If this thread is killed; one may run this product indefinitely. And killing 'foo' itself is tolerable as 'foo' as that is exactly what is being done on license expiry.</p> <p>System: Fedora Distribution of Linux</p> <p>Note: The commands which start JVM and program foo are placed in /etc/init.d and anyone who has a decent knowledge of rc.1/rc.2/rc.3 structure can change/add the starting parameters to these.</p> <p>I hope my question is clear. If not, I can always edit it.</p>
[ { "answer_id": 188822, "author": "Alexander", "author_id": 16724, "author_profile": "https://Stackoverflow.com/users/16724", "pm_score": 2, "selected": false, "text": "Thread.getAllStackTraces Thread.enumerate stop() Thread.stop jdb jdb" }, { "answer_id": 874335, "author": "l0st3d", "author_id": 5100, "author_profile": "https://Stackoverflow.com/users/5100", "pm_score": 4, "selected": false, "text": "java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8888 your.app.Main\n jdb -attach 127.0.0.1:8888\n threads\n kill 0xe2e new java.lang.IllegalArgumentException(\"er\");\n killing thread: Swank REPL Thread\nThread not suspended\nExpression must evaluate to an object\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18768/" ]
181,624
<p>I'm working on a commercial (not open source) C++ project that runs on a linux-based system. I need to do some regex within the C++ code. (I know: I now have 2 problems.)</p> <p>QUESTION: What libraries do people who regularly do regex from C/C++ recommend I look into? A quick search has brought the following to my attention:</p> <p>1) Boost.Regex (I need to go read the Boost Software License, but this question is not about software licenses)</p> <p>2) C (not C++) POSIX regex (#include &lt;regex.h&gt;, regcomp, regexec, etc.)</p> <p>3) <a href="http://freshmeat.net/projects/cpp_regex/" rel="noreferrer">http://freshmeat.net/projects/cpp_regex/</a> (I know nothing about this one; seems to be GPL, therefore not usable on this project)</p>
[ { "answer_id": 8560856, "author": "matiu", "author_id": 602340, "author_profile": "https://Stackoverflow.com/users/602340", "pm_score": 4, "selected": false, "text": "clang++ -std=c++11 -lc++ -I/usr/include/c++/v1 ..." } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13022/" ]
181,643
<p>I basically need to show a wait window to the user. For this i have put two seperate window forms in the application. the first form is the main form with a button. The second one is a empty one with just a label text. On click of the button in Form1 i do the below </p> <pre><code>Form2 f = new Form2(); f.Show(); Thread.Sleep(2000); f.Close(); </code></pre> <p>My idea here is to show the wait window to the user for 2 second. But when i do this the Form 2 is not completely loaded because of which the label in it is blank. Please let me know your inputs on this.</p>
[ { "answer_id": 181683, "author": "Cristian Libardo", "author_id": 16526, "author_profile": "https://Stackoverflow.com/users/16526", "pm_score": 2, "selected": false, "text": "f.Refresh();\n Timer t = new Timer();\nt.Interval = 2000;\nt.Tick += delegate { Close(); t.Stop();};\nt.Start();\n f.ShowDialog();\n" }, { "answer_id": 181834, "author": "GvS", "author_id": 11492, "author_profile": "https://Stackoverflow.com/users/11492", "pm_score": 0, "selected": false, "text": "f.ShowDialog(this);\n" }, { "answer_id": 6380878, "author": "Trev", "author_id": 802581, "author_profile": "https://Stackoverflow.com/users/802581", "pm_score": 2, "selected": false, "text": "using WaitingBox;\nShowWaitingBox waiting = new ShowWaitingBox(\"Title Text\",\"Some Text so the user knows whats going on..\");\nwaiting.Start();\n//do something that takes a while\nwaiting.Stop();\n using System;\n using System.Collections.Generic;\n using System.ComponentModel;\n using System.Data;\n using System.Drawing;\n using System.Linq;\n using System.Text;\n using System.Windows.Forms;\n using System.Threading;\n\n\n\n namespace WaitingBox\n {\n public class ShowWaitingBox\n {\n private class WaitingForm:Form\n {\n public WaitingForm()\n {\n this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();\n this.label1 = new System.Windows.Forms.Label();\n this.progressBar1 = new System.Windows.Forms.ProgressBar();\n this.tableLayoutPanel1.SuspendLayout();\n this.SuspendLayout();\n // \n // tableLayoutPanel1\n // \n this.tableLayoutPanel1.ColumnCount = 1;\n this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));\n this.tableLayoutPanel1.Controls.Add(this.progressBar1, 0, 0);\n this.tableLayoutPanel1.Controls.Add(this.label1, 0, 2);\n this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;\n this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);\n this.tableLayoutPanel1.Name = \"tableLayoutPanel1\";\n this.tableLayoutPanel1.RowCount = 3;\n this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));\n this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 29F));\n this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));\n this.tableLayoutPanel1.Size = new System.Drawing.Size(492, 155);\n this.tableLayoutPanel1.TabIndex = 0;\n // \n // label1\n // \n this.label1.Anchor = System.Windows.Forms.AnchorStyles.Top;\n this.label1.AutoSize = true;\n this.label1.Location = new System.Drawing.Point(209, 92);\n this.label1.Name = \"label1\";\n this.label1.Size = new System.Drawing.Size(73, 13);\n this.label1.TabIndex = 3;\n this.label1.Text = \"Please Wait...\";\n // \n // progressBar1\n // \n this.progressBar1.Anchor = System.Windows.Forms.AnchorStyles.Bottom;\n this.progressBar1.Location = new System.Drawing.Point(22, 37);\n this.progressBar1.Name = \"progressBar1\";\n this.progressBar1.Size = new System.Drawing.Size(447, 23);\n this.progressBar1.TabIndex = 2;\n // \n // WaitingForm\n // \n this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\n this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\n this.ClientSize = new System.Drawing.Size(492, 155);\n this.Controls.Add(this.tableLayoutPanel1);\n this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;\n this.Name = \"WaitingForm\";\n this.Text = \"Working in the background\";\n this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.WaitingForm_FormClosing);\n this.Load += new System.EventHandler(this.WaitingForm_Load);\n this.tableLayoutPanel1.ResumeLayout(false);\n this.tableLayoutPanel1.PerformLayout();\n this.ResumeLayout(false);\n }\n\n private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;\n private System.Windows.Forms.ProgressBar progressBar1;\n private System.Windows.Forms.Label label1;\n\n private void WaitingForm_Load(object sender, EventArgs e)\n {\n progressBar1.Style = ProgressBarStyle.Marquee;\n this.BringToFront();\n this.CenterToScreen();\n }\n\n private void WaitingForm_FormClosing(object sender, FormClosingEventArgs e)\n {\n }\n\n internal void SetLabel(string p)\n {\n label1.Text = p;\n }\n }\n private WaitingForm wf = new WaitingForm();\n private string title, text;\n private Thread waiting;\n public bool IsAlive\n {\n get\n {\n return waiting.IsAlive;\n }\n set { }\n }\n public ShowWaitingBox(string Title, string Text)\n {\n this.title = string.IsNullOrEmpty(Title) ? \"Working in the Background..\": Title;\n this.text = string.IsNullOrEmpty(Text) ? \"Please wait...\" : Text;\n waiting = new Thread(new ThreadStart(Show));\n\n }\n\n public ShowWaitingBox()\n {\n waiting = new Thread(new ThreadStart(Show));\n }\n\n private void Show()\n {\n wf.Show();\n wf.Text = this.title;\n wf.SetLabel(this.text);\n while (true) {\n\n wf.Refresh();\n System.Threading.Thread.Sleep(50);\n }\n }\n public void Start()\n {\n waiting.Start();\n }\n public void Stop()\n {\n waiting.Abort();\n }\n }\n }\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20951/" ]
181,648
<p>I have problems opening a berkeley db in python using bdtables. As bdtables is used by the library I am using to access the database, I need it to work.</p> <p>The problem seems to be that the db environment I am trying to open (I got a copy of the database to open), is version 4.4 while libdb is version 4.6. I get the following error using bsddb.dbtables.bsdTableDB([dbname],[folder]):</p> <pre><code>(-30972, "DB_VERSION_MISMATCH: Database environment version mismatch -- Program version 4.6 doesn't match environment version 4.4") </code></pre> <p>However, bsddb.btopen([dbname]) works.</p> <p>I have also tried installing db4.4-util, db4.5-util and db4.6-util. Trying to use db4.6_verify results in:</p> <pre><code>db4.6_verify: Program version 4.6 doesn't match environment version 4.4 db4.6_verify: DB_ENV-&gt;open: DB_VERSION_MISMATCH: Database environment version mismatchs </code></pre> <p>db4.4_verify results in the computer just hanging, and nothing happening.</p> <p>Finally, if I run db4.4_recover on the database, that works. However, afterwards I get the following error 'No such file or directory' in python.</p>
[ { "answer_id": 185678, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 3, "selected": true, "text": "bsddb.dbtables.bsdTableDB([dbname],[folder], create=1)\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3355/" ]
181,652
<p>Let's say I have this model named <em>Product</em> with a field named <em>brand</em>. Suppose the values of <em>brand</em> are stored in the format <em>this_is_a_brand</em>. Can I define a method in the model (or anywhere else) that allows me to modify the value of <em>brand</em> before it is called. For example, if I call <em>@product.brand</em>, I want to get <em>This is a Brand</em>, instead of <em>this_is_a_brand</em>.</p>
[ { "answer_id": 181665, "author": "Josh Moore", "author_id": 5004, "author_profile": "https://Stackoverflow.com/users/5004", "pm_score": 0, "selected": false, "text": "brand def brand\n#code to modify the value that is stored in brand\nreturn modified_brand\nend\n" }, { "answer_id": 181831, "author": "tomafro", "author_id": 7126, "author_profile": "https://Stackoverflow.com/users/7126", "pm_score": 3, "selected": false, "text": "read_attribute write_attribute def brand\n b = read_attribute(:brand) \n b && b.transform_in_some_way\nend\n\ndef brand=(b)\n b && b.transform_in_some_way\n write_attribute(:brand, b)\nend\n" }, { "answer_id": 183970, "author": "two-bit-fool", "author_id": 23899, "author_profile": "https://Stackoverflow.com/users/23899", "pm_score": 5, "selected": true, "text": "[] []= read_attribute write_attribute def brand\n original = self[:brand]\n transform(original)\nend\n\ndef brand=(b)\n self[:brand] = reverse_transform(b)\nend\n" }, { "answer_id": 32418376, "author": "frankpinto", "author_id": 2456847, "author_profile": "https://Stackoverflow.com/users/2456847", "pm_score": 1, "selected": false, "text": "def brand\n super.humanize\nend\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9776/" ]
181,690
<p>my java application has a loading task which requires two server calls which can be parallelized. So I launch a Thread t1 (doing <strong>task1</strong>) and a Thread t2 (for <strong>task2</strong>). I want then to do a specific task, <strong>task3</strong> when both other tasks (1 &amp; 2) are over. Naturally I can't tell which of <strong>task1</strong> and <strong>task2</strong> will finish first...</p> <p>Which would be for you the simplest (and safest) way to code this ?</p> <p>Thank you for your help</p>
[ { "answer_id": 181692, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 2, "selected": false, "text": "join t1 t2" }, { "answer_id": 181725, "author": "mitchnull", "author_id": 18645, "author_profile": "https://Stackoverflow.com/users/18645", "pm_score": 0, "selected": false, "text": "public class Master {\n\n private Object monitor_ = new Object();\n private boolean task1Finished_;\n private boolean task2Finished_;\n\n class Task1 extends Thread {\n\n public void run() {\n // do stuff\n synchronized (monitor_) {\n task1Finished_ = true;\n monitor_.notifyAll();\n }\n // keep on working\n }\n }\n\n class Task2 extends Thread {\n\n public void run() {\n // do stuff\n synchronized (monitor_) {\n task1Finished_ = true;\n monitor_.notifyAll();\n }\n // keep on working\n }\n }\n\n class Task3 extends Thread {\n\n public void run() {\n synchronized (monitor_) {\n while (!task1Finished_ || !task2Finished_) {\n try {\n monitor_.wait();\n }\n catch (InterruptedException ignored) {\n }\n }\n }\n // do stuff\n }\n }\n // start tasks1, task2 and task3...\n}\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2965/" ]
181,693
<p>Apparently ;-) the standard containers provide some form of guarantees.</p> <p>What type of guarantees and what exactly are the differences between the different types of container?</p> <p>Working from <a href="http://www.sgi.com/tech/stl/" rel="noreferrer">the SGI page</a> (about <a href="http://en.wikipedia.org/wiki/Standard_Template_Library" rel="noreferrer">STL</a>) I have come up with this:</p> <pre><code>Container Types: ================ Container: Forward Container Reverse Container Random Access Container Sequence Front Insert Sequence Back Insert Sequence Associative Container Simple Associative Container Pair Associative Container Sorted Associative Container Multiple Associative Container Container Types mapped to Standard Containers ============================================= std::vector: Sequence Back Sequence Forward/Reverse/Random Container std::deque: Sequence Front/Back Sequence Forward/Reverse/Random Container std::list: Sequence Front/Back Sequence Forward/Reverse Container std::set: Sorted/Simple/Unique Associative Container Forward Container std::map: Sorted/Pair/Unique Associative Container Forward Container std::multiset: Sorted/Simple/Multiple Associative Container Forward Container std::multimap: Sorted/Pair/Multiple Associative Container Forward Container Container Guarantees: ===================== Simp or For Rev Rand Front Back Assoc Sort Mult Cont: Cont: Cont Cont: Sequ: Sequ: Sequ: Cont: Cont: Cont: Copy Const: O(n) Fill Const: O(n) begin() O(1) end() O(1) rbegin() O(1) rend() O(1) front() O(1) push_front() O(1) pop_front() O(1) push_back() O(1) pop_back() O(1) Insert() O(ln(n)) Insert: fill O(n) Insert: range O(n) O(kln(n)+n) size() O(1) swap() O(1) erase key O(ln(n)) erase element O(1) erase range O(ln(n)+S) count() O(log(n)+k) find() O(ln(n)) equal range O(ln(n)) Lower Bound/Upper Bound O(ln(n)) Equality O(n) InEquality O(n) Element Access O(1) </code></pre>
[ { "answer_id": 26395804, "author": "Nayana Adassuriya", "author_id": 1268258, "author_profile": "https://Stackoverflow.com/users/1268258", "pm_score": 8, "selected": true, "text": "vector<T> v; Make an empty vector. O(1)\nvector<T> v(n); Make a vector with N elements. O(n)\nvector<T> v(n, value); Make a vector with N elements, initialized to value. O(n)\nvector<T> v(begin, end); Make a vector and copy the elements from begin to end. O(n)\n v[i] Return (or set) the I'th element. O(1)\nv.at(i) Return (or set) the I'th element, with bounds checking. O(1)\nv.size() Return current number of elements. O(1)\nv.empty() Return true if vector is empty. O(1)\nv.begin() Return random access iterator to start. O(1)\nv.end() Return random access iterator to end. O(1)\nv.front() Return the first element. O(1)\nv.back() Return the last element. O(1)\nv.capacity() Return maximum number of elements. O(1)\n v.push_back(value) Add value to end. O(1) (amortized)\nv.insert(iterator, value) Insert value at the position indexed by iterator. O(n)\nv.pop_back() Remove value from end. O(1)\nv.assign(begin, end) Clear the container and copy in the elements from begin to end. O(n)\nv.erase(iterator) Erase value indexed by iterator. O(n)\nv.erase(begin, end) Erase the elements from begin to end. O(n)\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14065/" ]
181,697
<p>We have an application where people can type in multiple langugaes. Though we only have one database to store all the data. We have text columns as nvarchar ( assuming we only want text data to be in multiple languages and not all dates etc.)</p> <p>Do you think this is a feasbile solution and are there any other points to consider besides sorting and searching ?</p> <p>Thanks.</p>
[ { "answer_id": 182667, "author": "Josef", "author_id": 5581, "author_profile": "https://Stackoverflow.com/users/5581", "pm_score": 1, "selected": false, "text": "NVARCHAR SQL_MixDiction_CP1253_CS_AS" }, { "answer_id": 1034191, "author": "Yordan Georgiev", "author_id": 65706, "author_profile": "https://Stackoverflow.com/users/65706", "pm_score": 0, "selected": false, "text": " USE [db]\n GO\n\n /****** Object: Table [dbo].[CultureInfo] Script Date: 06/23/2009 21:07:38 ******/\n SET ANSI_NULLS ON\n GO\n\n SET QUOTED_IDENTIFIER ON\n GO\n\n SET ANSI_PADDING ON\n GO\n\n CREATE TABLE [dbo].[CultureInfo](\n [CultureInfoId] [int] IDENTITY(1,1) NOT NULL,\n [CultureName] [varchar](10) NOT NULL,\n [DisplayName] [varchar](50) NULL,\n [ISO_639x_Value] [nchar](6) NULL,\n [CultureCode] [nvarchar](10) NULL,\n [CollationName] [varchar](50) NULL,\n CONSTRAINT [PK_CultureInfo] PRIMARY KEY CLUSTERED \n (\n [CultureInfoId] ASC\n )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]\n ) ON [PRIMARY]\n\n GO\n\n SET ANSI_PADDING ON\n GO\n\n\n\n\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('af-ZA' , 'Afrikaans - South Africa' , '0x0436' , 'AFK' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('sq-AL' , 'Albanian - Albania' , '0x041C' , 'SQI' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ar-DZ' , 'Arabic - Algeria' , '0x1401' , 'ARG' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ar-BH' , 'Arabic - Bahrain' , '0x3C01' , 'ARH' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ar-EG' , 'Arabic - Egypt' , '0x0C01' , 'ARE' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ar-IQ' , 'Arabic - Iraq' , '0x0801' , 'ARI' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ar-JO' , 'Arabic - Jordan' , '0x2C01' , 'ARJ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ar-KW' , 'Arabic - Kuwait' , '0x3401' , 'ARK' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ar-LB' , 'Arabic - Lebanon' , '0x3001' , 'ARB' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ar-LY' , 'Arabic - Libya' , '0x1001' , 'ARL' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ar-MA' , 'Arabic - Morocco' , '0x1801' , 'ARM' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ar-OM' , 'Arabic - Oman' , '0x2001' , 'ARO' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ar-QA' , 'Arabic - Qatar' , '0x4001' , 'ARQ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ar-SA' , 'Arabic - Saudi Arabia' , '0x0401' , 'ARA' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ar-SY' , 'Arabic - Syria' , '0x2801' , 'ARS' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ar-TN' , 'Arabic - Tunisia' , '0x1C01' , 'ART' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ar-AE' , 'Arabic - United Arab Emirates' , '0x3801' , 'ARU' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ar-YE' , 'Arabic - Yemen' , '0x2401' , 'ARY' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('hy-AM' , 'Armenian - Armenia' , '0x042B' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('Cy-az-AZ' , 'Azeri (Cyrillic) - Azerbaijan' , '0x082C' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('Lt-az-AZ' , 'Azeri (Latin) - Azerbaijan' , '0x042C' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('eu-ES' , 'Basque - Basque' , '0x042D' , 'EUQ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('be-BY' , 'Belarusian - Belarus' , '0x0423' , 'BEL' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('bg-BG' , 'Bulgarian - Bulgaria' , '0x0402' , 'BGR' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ca-ES' , 'Catalan - Catalan' , '0x0403' , 'CAT' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('zh-CN' , 'Chinese - China' , '0x0804' , 'CHS' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('zh-HK' , 'Chinese - Hong Kong SAR' , '0x0C04' , 'ZHH' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('zh-MO' , 'Chinese - Macau SAR' , '0x1404' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('zh-SG' , 'Chinese - Singapore' , '0x1004' , 'ZHI' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('zh-TW' , 'Chinese - Taiwan' , '0x0404' , 'CHT' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('zh-CHS' , 'Chinese (Simplified)' , '0x0004' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('zh-CHT' , 'Chinese (Traditional)' , '0x7C04' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('hr-HR' , 'Croatian - Croatia' , '0x041A' , 'HRV' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('cs-CZ' , 'Czech - Czech Republic' , '0x0405' , 'CSY' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('da-DK' , 'Danish - Denmark' , '0x0406' , 'DAN' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('div-MV' , 'Dhivehi - Maldives' , '0x0465' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('nl-BE' , 'Dutch - Belgium' , '0x0813' , 'NLB' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('nl-NL' , 'Dutch - The Netherlands' , '0x0413' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('en-AU' , 'English - Australia' , '0x0C09' , 'ENA' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('en-BZ' , 'English - Belize' , '0x2809' , 'ENL' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('en-CA' , 'English - Canada' , '0x1009' , 'ENC' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('en-CB' , 'English - Caribbean' , '0x2409' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('en-IE' , 'English - Ireland' , '0x1809' , 'ENI' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('en-JM' , 'English - Jamaica' , '0x2009' , 'ENJ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('en-NZ' , 'English - New Zealand' , '0x1409' , 'ENZ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('en-PH' , 'English - Philippines' , '0x3409' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('en-ZA' , 'English - South Africa' , '0x1C09' , 'ENS' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('en-TT' , 'English - Trinidad and Tobago' , '0x2C09' , 'ENT' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('en-GB' , 'English - United Kingdom' , '0x0809' , 'ENG' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('en-US' , 'English - United States' , '0x0409' , 'ENU' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('en-ZW' , 'English - Zimbabwe' , '0x3009' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('et-EE' , 'Estonian - Estonia' , '0x0425' , 'ETI' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('fo-FO' , 'Faroese - Faroe Islands' , '0x0438' , 'FOS' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('fa-IR' , 'Farsi - Iran' , '0x0429' , 'FAR' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('fi-FI' , 'Finnish - Finland' , '0x040B' , 'FIN' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('fr-BE' , 'French - Belgium' , '0x080C' , 'FRB' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('fr-CA' , 'French - Canada' , '0x0C0C' , 'FRC' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('fr-FR' , 'French - France' , '0x040C' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('fr-LU' , 'French - Luxembourg' , '0x140C' , 'FRL' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('fr-MC' , 'French - Monaco' , '0x180C' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('fr-CH' , 'French - Switzerland' , '0x100C' , 'FRS' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('gl-ES' , 'Galician - Galician' , '0x0456' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ka-GE' , 'Georgian - Georgia' , '0x0437' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('de-AT' , 'German - Austria' , '0x0C07' , 'DEA' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('de-DE' , 'German - Germany' , '0x0407' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('de-LI' , 'German - Liechtenstein' , '0x1407' , 'DEC' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('de-LU' , 'German - Luxembourg' , '0x1007' , 'DEL' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('de-CH' , 'German - Switzerland' , '0x0807' , 'DES' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('el-GR' , 'Greek - Greece' , '0x0408' , 'ELL' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('gu-IN' , 'Gujarati - India' , '0x0447' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('he-IL' , 'Hebrew - Israel' , '0x040D' , 'HEB' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('hi-IN' , 'Hindi - India' , '0x0439' , 'HIN' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('hu-HU' , 'Hungarian - Hungary' , '0x040E' , 'HUN' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('is-IS' , 'Icelandic - Iceland' , '0x040F' , 'ISL' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('id-ID' , 'Indonesian - Indonesia' , '0x0421' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('it-IT' , 'Italian - Italy' , '0x0410' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('it-CH' , 'Italian - Switzerland' , '0x0810' , 'ITS' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ja-JP' , 'Japanese - Japan' , '0x0411' , 'JPN' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('kn-IN' , 'Kannada - India' , '0x044B' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('kk-KZ' , 'Kazakh - Kazakhstan' , '0x043F' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('kok-IN' , 'Konkani - India' , '0x0457' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ko-KR' , 'Korean - Korea' , '0x0412' , 'KOR' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ky-KZ' , 'Kyrgyz - Kazakhstan' , '0x0440' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('lv-LV' , 'Latvian - Latvia' , '0x0426' , 'LVI' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('lt-LT' , 'Lithuanian - Lithuania' , '0x0427' , 'LTH' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('mk-MK' , 'Macedonian (FYROM)' , '0x042F' , 'MKD' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ms-BN' , 'Malay - Brunei' , '0x083E' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ms-MY' , 'Malay - Malaysia' , '0x043E' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('mr-IN' , 'Marathi - India' , '0x044E' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('mn-MN' , 'Mongolian - Mongolia' , '0x0450' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('nb-NO' , 'Norwegian (Bokmål) - Norway' , '0x0414' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('nn-NO' , 'Norwegian (Nynorsk) - Norway' , '0x0814' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('pl-PL' , 'Polish - Poland' , '0x0415' , 'PLK' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('pt-BR' , 'Portuguese - Brazil' , '0x0416' , 'PTB' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('pt-PT' , 'Portuguese - Portugal' , '0x0816' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('pa-IN' , 'Punjabi - India' , '0x0446' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ro-RO' , 'Romanian - Romania' , '0x0418' , 'ROM' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ru-RU' , 'Russian - Russia' , '0x0419' , 'RUS' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('sa-IN' , 'Sanskrit - India' , '0x044F' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('Cy-sr-SP' , 'Serbian (Cyrillic) - Serbia' , '0x0C1A' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('Lt-sr-SP' , 'Serbian (Latin) - Serbia' , '0x081A' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('sk-SK' , 'Slovak - Slovakia' , '0x041B' , 'SKY' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('sl-SI' , 'Slovenian - Slovenia' , '0x0424' , 'SLV' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('es-AR' , 'Spanish - Argentina' , '0x2C0A' , 'ESS' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('es-BO' , 'Spanish - Bolivia' , '0x400A' , 'ESB' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('es-CL' , 'Spanish - Chile' , '0x340A' , 'ESL' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('es-CO' , 'Spanish - Colombia' , '0x240A' , 'ESO' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('es-CR' , 'Spanish - Costa Rica' , '0x140A' , 'ESC' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('es-DO' , 'Spanish - Dominican Republic' , '0x1C0A' , 'ESD' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('es-EC' , 'Spanish - Ecuador' , '0x300A' , 'ESF' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('es-SV' , 'Spanish - El Salvador' , '0x440A' , 'ESE' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('es-GT' , 'Spanish - Guatemala' , '0x100A' , 'ESG' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('es-HN' , 'Spanish - Honduras' , '0x480A' , 'ESH' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('es-MX' , 'Spanish - Mexico' , '0x080A' , 'ESM' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('es-NI' , 'Spanish - Nicaragua' , '0x4C0A' , 'ESI' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('es-PA' , 'Spanish - Panama' , '0x180A' , 'ESA' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('es-PY' , 'Spanish - Paraguay' , '0x3C0A' , 'ESZ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('es-PE' , 'Spanish - Peru' , '0x280A' , 'ESR' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('es-PR' , 'Spanish - Puerto Rico' , '0x500A' , 'ES' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('es-ES' , 'Spanish - Spain' , '0x0C0A' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('es-UY' , 'Spanish - Uruguay' , '0x380A' , 'ESY' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('es-VE' , 'Spanish - Venezuela' , '0x200A' , 'ESV' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('sw-KE' , 'Swahili - Kenya' , '0x0441' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('sv-FI' , 'Swedish - Finland' , '0x081D' , 'SVF' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('sv-SE' , 'Swedish - Sweden' , '0x041D' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('syr-SY' , 'Syriac - Syria' , '0x045A' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ta-IN' , 'Tamil - India' , '0x0449' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('tt-RU' , 'Tatar - Russia' , '0x0444' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('te-IN' , 'Telugu - India' , '0x044A' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('th-TH' , 'Thai - Thailand' , '0x041E' , 'THA' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('tr-TR' , 'Turkish - Turkey' , '0x041F' , 'TRK' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('uk-UA' , 'Ukrainian - Ukraine' , '0x0422' , 'UKR' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('ur-PK' , 'Urdu - Pakistan' , '0x0420' , 'URD' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('Cy-uz-UZ' , 'Uzbek (Cyrillic) - Uzbekistan' , '0x0843' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('Lt-uz-UZ' , 'Uzbek (Latin) - Uzbekistan' , '0x0443' , ' ' )\ninsert into CultureInfo (CultureName , DisplayName , ISO_639x_Value , CultureCode ) values ('vi-VN' , 'Vietnamese - Vietnam' , '0x042A' , 'VIT' )\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2528/" ]
181,718
<p>When I add a breakpoint and hit F5 to run in the debugger (I am using my debug build), a dialog pops up telling my my web.config file does not have debug=true in it (which is does) and I get 2 choices a) run without the debugger or b) let visual studio update my web.config file. If I choose b) the web.config is updated badly and nothing will work. If I choose a) then the site appears and I can test it out, but no debugging.</p> <p>I am an experienced developer, but I have never used visual studio and asp.net for web development before, so I am feeling rather frustrated by all the walls it is putting up to prevent me working.</p> <p>So far I have not been able to use the debugger. Is there something totally obvious that I am missing? What would you check if it was happening to you?</p>
[ { "answer_id": 181736, "author": "liggett78", "author_id": 19762, "author_profile": "https://Stackoverflow.com/users/19762", "pm_score": 3, "selected": true, "text": "<compilation defaultLanguage=\"c#\" debug=\"true\" />\n" }, { "answer_id": 181755, "author": "naspinski", "author_id": 14777, "author_profile": "https://Stackoverflow.com/users/14777", "pm_score": 1, "selected": false, "text": "<%@ Page Language=\"C#\" MasterPageFile=\"~/default.master\" AutoEventWireup=\"true\" CodeFile=\"Default.aspx.cs\" Inherits=\"_Default\" Title=\"some title\" Debug=\"false\" %>\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4012/" ]
181,719
<p>How do I start a process, such as launching a URL when the user clicks a button?</p>
[ { "answer_id": 181821, "author": "GvS", "author_id": 11492, "author_profile": "https://Stackoverflow.com/users/11492", "pm_score": 4, "selected": false, "text": "Process.Start(\"Test.Txt\");\n" }, { "answer_id": 181857, "author": "Andy McCluggage", "author_id": 3362, "author_profile": "https://Stackoverflow.com/users/3362", "pm_score": 8, "selected": false, "text": "using System.Diagnostics;\n...\nProcess.Start(\"process.exe\");\n using System.Diagnostics;\n...\nProcess process = new Process();\n// Configure the process using the StartInfo properties.\nprocess.StartInfo.FileName = \"process.exe\";\nprocess.StartInfo.Arguments = \"-n\";\nprocess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;\nprocess.Start();\nprocess.WaitForExit();// Waits here for the process to exit.\n" }, { "answer_id": 24823340, "author": "Blackvault", "author_id": 3602240, "author_profile": "https://Stackoverflow.com/users/3602240", "pm_score": 4, "selected": false, "text": "Process.Start(\"http://www.google.com/etc/etc/test.txt\")\n" }, { "answer_id": 26772447, "author": "AVIK DUTTA", "author_id": 4137130, "author_profile": "https://Stackoverflow.com/users/4137130", "pm_score": 2, "selected": false, "text": "using System.Diagnostics; Process.Start(\"Paste your URL string here!\"); using System.Web.UI;\nusing System.Web.UI.WebControls;\nusing System.Diagnostics;\n\nnamespace btnproce\n{\n public partial class WebForm1 : System.Web.UI.Page\n {\n protected void Page_Load(object sender, EventArgs e)\n {\n\n }\n\n protected void Button1_Click(object sender, EventArgs e)\n {\n string t =\"Balotelli\";\n Process.Start(\"http://google.com/search?q=\" + t);\n }\n }\n}\n" }, { "answer_id": 29357273, "author": "SimperT", "author_id": 4367485, "author_profile": "https://Stackoverflow.com/users/4367485", "pm_score": 3, "selected": false, "text": "var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, \"/YourSubDirectory/yourprogram.exe\");\nProcess.Start(new ProcessStartInfo(path));\n" }, { "answer_id": 31140674, "author": "alireza amini", "author_id": 3970128, "author_profile": "https://Stackoverflow.com/users/3970128", "pm_score": 3, "selected": false, "text": "System.Diagnostics.Process.Start(\"Example.exe\");\n () System.Diagnostics.Process.Start(\"http://www.google.com\");\n" }, { "answer_id": 31994088, "author": "Carla Jesus", "author_id": 5087231, "author_profile": "https://Stackoverflow.com/users/5087231", "pm_score": 2, "selected": false, "text": "[DllImport(\"user32\")]\nprivate static extern bool SetForegroundWindow(IntPtr hwnd);\n[DllImport(\"user32\")]\nprivate static extern bool ShowWindowAsync(IntPtr hwnd, int a);\n if (ckeckInstalled(\"example\"))\n{\n int count = Process.GetProcessesByName(\"example\").Count();\n if (count < 1)\n Process.Start(\"example.exe\");\n else\n {\n var proc = Process.GetProcessesByName(\"example\").FirstOrDefault();\n if (proc != null && proc.MainWindowHandle != IntPtr.Zero)\n {\n SetForegroundWindow(proc.MainWindowHandle);\n ShowWindowAsync(proc.MainWindowHandle, 3);\n }\n }\n}\n" }, { "answer_id": 37459732, "author": "Ravi Kumar G N", "author_id": 5680680, "author_profile": "https://Stackoverflow.com/users/5680680", "pm_score": 3, "selected": false, "text": "class ProcessStart\n{\n static void Main(string[] args)\n {\n Process notePad = new Process();\n\n notePad.StartInfo.FileName = \"notepad.exe\";\n notePad.StartInfo.Arguments = \"ProcessStart.cs\";\n\n notePad.Start();\n }\n}\n" }, { "answer_id": 39277571, "author": "user4340666", "author_id": 4340666, "author_profile": "https://Stackoverflow.com/users/4340666", "pm_score": 2, "selected": false, "text": "private void button1_Click(object sender, EventArgs e)\n{\n string ProgramName = \"winword.exe\";\n Process.Start(ProgramName);\n}\n" }, { "answer_id": 62896522, "author": "Moon Waxing", "author_id": 2234635, "author_profile": "https://Stackoverflow.com/users/2234635", "pm_score": 2, "selected": false, "text": "Process process = new Process();\nprocess.StartInfo.FileName = \"Test.txt\";\nprocess.Start();\n Process process = new Process();\nprocess.StartInfo.FileName = \"Test.txt\";\nprocess.StartInfo.UseShellExecute = true;\nprocess.Start();\n" }, { "answer_id": 66843763, "author": "NoNAME", "author_id": 14935884, "author_profile": "https://Stackoverflow.com/users/14935884", "pm_score": 0, "selected": false, "text": "private void button1_Click(object sender, EventArgs e) {\n System.Diagnostics.Process.Start(/*your file name goes here*/);\n}\n using System;\nusing System.Diagnostics;\n//rest of the code\n\nprivate void button1_Click(object sender, EventArgs e) {\n Process.Start(/*your file name goes here*/);\n}\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
181,724
<p>Since Python is a dynamic, interpreted language you don't have to compile your code before running it. Hence, it's very easy to simply write your code, run it, see what problems occur, and fix them. Using hotkeys or macros can make this incredibly quick.</p> <p>So, because it's so easy to immediately see the output of your program and any errors that may occur, I haven't uses a debugger tool yet. What situations may call for using a real debugger vs. the method I currently use?</p> <p>I'd like to know before I get into a situation and get frustrated because I don't know how to fix the problem.</p>
[ { "answer_id": 181768, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 3, "selected": false, "text": "log.debug() import pdb\npdb.set_trace ()\n" }, { "answer_id": 182010, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 3, "selected": false, "text": "core" }, { "answer_id": 183563, "author": "afternoon", "author_id": 26201, "author_profile": "https://Stackoverflow.com/users/26201", "pm_score": 1, "selected": false, "text": "import pdb; pdb.set_trace() pdb.set_trace()" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18676/" ]
181,731
<p>i need to get the color at a particular coordinate from a texture. There are 2 ways i can do this, by getting and looking at the raw png data, or by sampling my generated opengl texture. Is it possible to sample an opengl texture to get the color (RGBA) at a given UV or XY coord? If so, how?</p>
[ { "answer_id": 181747, "author": "Serafina Brocious", "author_id": 4977, "author_profile": "https://Stackoverflow.com/users/4977", "pm_score": 2, "selected": false, "text": "float3 sample(float2 coord, texture tex) {\n float x = tex.w * coord.x; // Get X coord in texture\n int ix = (int) x; // Get X coord as whole number\n float y = tex.h * coord.y;\n int iy = (int) y;\n\n float3 x1 = getTexel(ix, iy); // Get top-left pixel\n float3 x2 = getTexel(ix+1, iy); // Get top-right pixel\n float3 y1 = getTexel(ix, iy+1); // Get bottom-left pixel\n float3 y2 = getTexel(ix+1, iy+1); // Get bottom-right pixel\n\n float3 top = interpolate(x1, x2, frac(x)); // Interpolate between top two pixels based on the fractional part of the X coord\n float3 bottom = interpolate(y1, y2, frac(x)); // Interpolate between bottom two pixels\n\n return interpolate(top, bottom, frac(y)); // Interpolate between top and bottom based on fractional Y coord\n}\n" }, { "answer_id": 181843, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": true, "text": "GL_APPLE_client_storage" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25893/" ]
181,745
<p>Often when making changes to a VS2008 ASP.net project we get a message like:</p> <p>BC30560: 'mymodule_ascx' is ambiguous in the namespace 'ASP'.</p> <p>This goes away after a recompile or sometimes just waiting 10 seconds and refreshing the page. </p> <p>Any way to get rid of it?</p>
[ { "answer_id": 300955, "author": "Nathan", "author_id": 24954, "author_profile": "https://Stackoverflow.com/users/24954", "pm_score": 1, "selected": false, "text": "<%@ Page Inherits=\"_Default\" %>\n <%@ Page ClassName=\"_Default\" %>\n" }, { "answer_id": 300972, "author": "Nathan", "author_id": 24954, "author_profile": "https://Stackoverflow.com/users/24954", "pm_score": 3, "selected": true, "text": "src=\"mycontrol.ascx.cs\"\n CodeBehind=\"mycontrol.ascx.cs\"\n" }, { "answer_id": 1262428, "author": "proudgeekdad", "author_id": 702, "author_profile": "https://Stackoverflow.com/users/702", "pm_score": 4, "selected": false, "text": "<%@ Control Language=\"vb\" AutoEventWireup=\"false\" CodeBehind=\"MyModule.ascx.vb\" ClassName=\"MyModule\" %>\n" }, { "answer_id": 1502527, "author": "mrrrk", "author_id": 155791, "author_profile": "https://Stackoverflow.com/users/155791", "pm_score": 2, "selected": false, "text": "tempDirectory=\"e:\\someotherfolder\" compilation batch=\"false\"" }, { "answer_id": 9101512, "author": "jam40jeff", "author_id": 1183492, "author_profile": "https://Stackoverflow.com/users/1183492", "pm_score": 5, "selected": false, "text": "<compilation debug=\"true\" batch=\"false\">\n" }, { "answer_id": 42792928, "author": "Shwan", "author_id": 3148419, "author_profile": "https://Stackoverflow.com/users/3148419", "pm_score": 1, "selected": false, "text": "<compilation batch=\"false\">\n</compilation>\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181745", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23066/" ]
181,775
<p>Not sure what exactly is going on here, but seems like in .NET 1.1 an uninitialized event delegate can run without issues, but in .NET 2.0+ it causes a NullReferenceException. Any ideas why. The code below will run fine without issues in 1.1, in 2.0 it gives a NullReferenceException. I'm curious why does it behave differently? What changed?</p> <p>Thanks</p> <p>eg</p> <pre><code>class Class1 { public delegate void ChartJoinedRowAddedHandler(object sender); public static event ChartJoinedRowAddedHandler ChartJoinedRowAdded; public static DataTable dt; public static void Main() { dt = new DataTable(); dt.RowChanged += new DataRowChangeEventHandler(TableEventHandler); object [] obj = new object[]{1,2}; dt.Columns.Add("Name"); dt.Columns.Add("Last"); dt.NewRow(); dt.Rows.Add(obj); } private static void TableEventHandler(object sender, DataRowChangeEventArgs e) { ChartJoinedRowAdded(new object()); } } </code></pre>
[ { "answer_id": 181790, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": true, "text": " Console.WriteLine(\"Before\");\n ChartJoinedRowAdded(new object());\n Console.WriteLine(\"After\");\n" }, { "answer_id": 181826, "author": "Soraz", "author_id": 24610, "author_profile": "https://Stackoverflow.com/users/24610", "pm_score": 1, "selected": false, "text": "if (ChartJoinedRowAdded != null)\n ChartJoinedRowAdded(new object())\n" }, { "answer_id": 181984, "author": "Keith", "author_id": 905, "author_profile": "https://Stackoverflow.com/users/905", "pm_score": 0, "selected": false, "text": "dt.RowChanged += TableEventHandler;\ndt.RowChanged += null;\ndt.RowChanged += delegate (object sender, DataRowChangeEventArgs e) {\n //anon\n};\n TableEventHandler this.MyEvent = null;\n DataTable //events should just about always use this pattern: object, args\npublic static event EventHandler<MyEventArgs> ChartJoinedRowAdded;\n\n\n//inheriting classes can override this event behaviour\nprotected virtual OnChartJoinedRowAdded() {\n if( ChartJoinedRowAdded != null )\n ChartJoinedRowAdded( this, new MyEventArgs(...) );\n}\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26050/" ]
181,780
<p>I have an app where I would like to support device rotation in certain views but other don't particularly make sense in Landscape mode, so as I swapping the views out I would like to force the rotation to be set to portrait.</p> <p>There is an undocumented property setter on UIDevice that does the trick but obviously generates a compiler warning and could disappear with a future revision of the SDK.</p> <pre><code>[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait]; </code></pre> <p>Are there any documented ways to force the orientation?</p> <p><strong>Update:</strong> I thought I would provide an example as I am not looking for shouldAutorotateToInterfaceOrientation as I have already implemented that.</p> <p>I want my app to support landscape and portrait in View 1 but only portrait in View 2. I have already implemented shouldAutorotateToInterfaceOrientation for all views but if the user is in landscape mode in View 1 and then switches to View 2, I want to force the phone to rotate back to Portrait.</p>
[ { "answer_id": 183348, "author": "Martin Gordon", "author_id": 2481, "author_profile": "https://Stackoverflow.com/users/2481", "pm_score": -1, "selected": false, "text": "- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation\n NO" }, { "answer_id": 190359, "author": "kdbdallas", "author_id": 26728, "author_profile": "https://Stackoverflow.com/users/26728", "pm_score": -1, "selected": false, "text": "[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];\n[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];\n" }, { "answer_id": 464053, "author": "Bdebeez", "author_id": 35516, "author_profile": "https://Stackoverflow.com/users/35516", "pm_score": 4, "selected": false, "text": "setOrientation: #define degreesToRadian(x) (M_PI * (x) / 180.0)\n viewWillAppear: [[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO]; \nif (self.interfaceOrientation == UIInterfaceOrientationPortrait) { \n self.view.transform = CGAffineTransformIdentity;\n self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(90));\n self.view.bounds = CGRectMake(0.0, 0.0, 480, 320);\n}\n [UIView beginAnimations:@\"View Flip\" context:nil];\n[UIView setAnimationDuration:1.25];\n[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];\n\n[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO]; \nif (self.interfaceOrientation == UIInterfaceOrientationPortrait) { \n self.view.transform = CGAffineTransformIdentity;\n self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(90));\n self.view.bounds = CGRectMake(0.0, 0.0, 480, 320);\n}\n[UIView commitAnimations];\n" }, { "answer_id": 793285, "author": "Michael Gaylord", "author_id": 84290, "author_profile": "https://Stackoverflow.com/users/84290", "pm_score": 4, "selected": false, "text": "if(UIInterfaceOrientationIsLandscape(self.interfaceOrientation)){\n\n [UIView beginAnimations:@\"View Flip\" context:nil];\n [UIView setAnimationDuration:0.5f];\n [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];\n\n self.view.transform = CGAffineTransformIdentity;\n self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(90));\n self.view.bounds = CGRectMake(0.0f, 0.0f, 480.0f, 320.0f);\n self.view.center = CGPointMake(160.0f, 240.0f);\n\n [UIView commitAnimations];\n}\n" }, { "answer_id": 3526379, "author": "Andrew Vilcsak", "author_id": 418817, "author_profile": "https://Stackoverflow.com/users/418817", "pm_score": 3, "selected": false, "text": "UIViewController UINavigationController shouldAutorotateToInterfaceOrientation: - (void)selectHostingAtIndex:(int)hostingIndex {\n\n self.transitioning = YES;\n\n UIViewController *garbageController = [[[UIViewController alloc] init] autorelease];\n [self.navigationController pushViewController:garbageController animated:NO];\n [self.navigationController popViewControllerAnimated:NO];\n\n BBHostingController *hostingController = [[BBHostingController alloc] init];\n hostingController.hosting = [self.hostings objectAtIndex:hostingIndex];\n [self.navigationController pushViewController:hostingController animated:YES];\n [hostingController release];\n\n self.transitioning = NO;\n}\n\n- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {\n if (self.transitioning)\n return (toInterfaceOrientation == UIInterfaceOrientationPortrait);\n else\n return YES;\n}\n" }, { "answer_id": 4035140, "author": "Rafael Nobre", "author_id": 338514, "author_profile": "https://Stackoverflow.com/users/338514", "pm_score": 3, "selected": false, "text": "UIWindow shouldAutorotateToInterfaceOrientation:" }, { "answer_id": 4374179, "author": "Henry Cooke", "author_id": 284475, "author_profile": "https://Stackoverflow.com/users/284475", "pm_score": 2, "selected": false, "text": "-(void)rotateInterfaceToOrientation:(UIDeviceOrientation)orientation{\n\n CGRect bounds = [[ UIScreen mainScreen ] bounds ];\n CGAffineTransform t;\n CGFloat r = 0;\n switch ( orientation ) {\n case UIDeviceOrientationLandscapeRight:\n r = -(M_PI / 2);\n break;\n case UIDeviceOrientationLandscapeLeft:\n r = M_PI / 2;\n break;\n }\n if( r != 0 ){\n CGSize sz = bounds.size;\n bounds.size.width = sz.height;\n bounds.size.height = sz.width;\n }\n t = CGAffineTransformMakeRotation( r );\n\n UIApplication *application = [ UIApplication sharedApplication ];\n\n [ UIView beginAnimations:@\"InterfaceOrientation\" context: nil ];\n [ UIView setAnimationDuration: [ application statusBarOrientationAnimationDuration ] ];\n self.view.transform = t;\n self.view.bounds = bounds;\n [ UIView commitAnimations ];\n\n [ application setStatusBarOrientation: orientation animated: YES ]; \n}\n UINavigationControllerDelegate UINavigationController -(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{\n // rotate interface, if we need to\n UIDeviceOrientation orientation = [[ UIDevice currentDevice ] orientation ];\n BOOL bViewControllerDoesSupportCurrentOrientation = [ viewController shouldAutorotateToInterfaceOrientation: orientation ];\n if( !bViewControllerDoesSupportCurrentOrientation ){\n [ self rotateInterfaceToOrientation: UIDeviceOrientationPortrait ];\n }\n}\n UIViewController rotateInterfaceToOrientation -(void)onUIDeviceOrientationDidChangeNotification:(NSNotification*)notification{\n UIViewController *tvc = self.rootNavigationController.topViewController;\n UIDeviceOrientation orientation = [[ UIDevice currentDevice ] orientation ];\n // only switch if we need to (seem to get multiple notifications on device)\n if( orientation != [[ UIApplication sharedApplication ] statusBarOrientation ] ){\n if( [ tvc shouldAutorotateToInterfaceOrientation: orientation ] ){\n [ self rotateInterfaceToOrientation: orientation ];\n }\n }\n}\n UIDeviceOrientationDidChangeNotification init loadview [[ NSNotificationCenter defaultCenter ] addObserver: self\n selector: @selector(onUIDeviceOrientationDidChangeNotification:)\n name: UIDeviceOrientationDidChangeNotification\n object: nil ];\n[[ UIDevice currentDevice ] beginGeneratingDeviceOrientationNotifications ];\n" }, { "answer_id": 4915378, "author": "Josh", "author_id": 605558, "author_profile": "https://Stackoverflow.com/users/605558", "pm_score": 7, "selected": false, "text": "UIViewController *c = [[UIViewController alloc]init];\n[self presentModalViewController:c animated:NO];\n[self dismissModalViewControllerAnimated:NO];\n[c release];\n" }, { "answer_id": 5705918, "author": "user324168", "author_id": 324168, "author_profile": "https://Stackoverflow.com/users/324168", "pm_score": 2, "selected": false, "text": "[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];\n[[NSNotificationCenter defaultCenter] addObserver:self\n selector:@selector(orientationChanged:)\n name:UIDeviceOrientationDidChangeNotification\n object:nil];\n - (void)orientationChanged:(NSNotification *)notification { \n //[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];\n UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;\n CGRect bounds = [[ UIScreen mainScreen ] bounds ];\n CGAffineTransform t;\n CGFloat r = 0;\n switch ( orientation ) {\n case UIDeviceOrientationLandscapeRight:\n r = 0;\n NSLog(@\"Right\");\n break;\n case UIDeviceOrientationLandscapeLeft:\n r = M_PI;\n NSLog(@\"Left\");\n break;\n default:return;\n }\n\n t = CGAffineTransformMakeRotation( r );\n\n UIApplication *application = [ UIApplication sharedApplication ];\n [ UIView beginAnimations:@\"InterfaceOrientation\" context: nil ];\n [ UIView setAnimationDuration: [ application statusBarOrientationAnimationDuration ] ];\n self.view.transform = t;\n self.view.bounds = bounds;\n [ UIView commitAnimations ];\n\n [ application setStatusBarOrientation: orientation animated: YES ];\n}\n" }, { "answer_id": 6332405, "author": "Christian Schnorr", "author_id": 796103, "author_profile": "https://Stackoverflow.com/users/796103", "pm_score": 3, "selected": false, "text": "shouldAutorotateToInterfaceOrientation: YES [[NSNotificationCenter defaultCenter] postNotificationName:UIDeviceOrientationDidChangeNotification object:nil];\n beginAnimations: commitAnimations" }, { "answer_id": 7637322, "author": "stephencampbell", "author_id": 976918, "author_profile": "https://Stackoverflow.com/users/976918", "pm_score": 1, "selected": false, "text": "- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)pInterfaceOrientation {\n BOOL lHideNavBar = self.interfaceOrientation == UIInterfaceOrientationPortrait ? NO : YES;\n [self.navigationController setNavigationBarHidden:lHideNavBar animated:YES];\n}\n" }, { "answer_id": 10515645, "author": "Guntis Treulands", "author_id": 894671, "author_profile": "https://Stackoverflow.com/users/894671", "pm_score": 3, "selected": false, "text": "//will rotate status bar\n[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];\n\n\n//will re-rotate view according to statusbar\nUIViewController *c = [[UIViewController alloc]init];\n[self presentModalViewController:c animated:NO];\n[self dismissModalViewControllerAnimated:NO];\n[c release];\n - (NSUInteger)supportedInterfaceOrientations\n{\n return (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight);\n}\n" }, { "answer_id": 11337681, "author": "David van Dugteren", "author_id": 297201, "author_profile": "https://Stackoverflow.com/users/297201", "pm_score": 1, "selected": false, "text": " [[NSNotificationCenter defaultCenter] addObserver:self\n selector:@selector(didRotate:)\n name:UIDeviceOrientationDidChangeNotification object:nil];\n - (void) didRotate:(NSNotification *)notification\n{ if (orientationa == UIDeviceOrientationPortrait) \n {\n if (hasRotated == NO) \n {\n NSLog(@\"Rotating to portait\");\n hasRotated = YES;\n [UIView beginAnimations: @\"\" context:nil];\n [UIView setAnimationDuration: 0];\n self.view.transform = CGAffineTransformIdentity;\n self.view.transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(-90));\n self.view.bounds = CGRectMake(0.0f, 0.0f, 480.0f, 320.0f);\n self.view.frame = CGRectMake(0.0f, 0.0f, 480.0f, 320.0f);\n [UIView commitAnimations];\n\n }\n}\nelse if (UIDeviceOrientationIsLandscape( orientationa))\n{\n if (hasRotated) \n {\n NSLog(@\"Rotating to lands\");\n hasRotated = NO;\n [UIView beginAnimations: @\"\" context:nil];\n [UIView setAnimationDuration: 0];\n self.view.transform = CGAffineTransformIdentity;\n self.view.transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(0));\n self.view.bounds = CGRectMake(0.0f, 0.0f, 320.0f, 480.0f);\n self.view.frame = CGRectMake(0.0f, 0.0f, 320.0f, 480.0f);\n [UIView commitAnimations];\n\n }\n}\n" }, { "answer_id": 14299516, "author": "Bo A", "author_id": 871434, "author_profile": "https://Stackoverflow.com/users/871434", "pm_score": 1, "selected": false, "text": "[[[self window] rootViewController] presentViewController:[[UIViewController alloc] init] animated:NO completion:^{\n [[[self window] rootViewController] dismissViewControllerAnimated:NO completion:nil];\n}];\n [[self window] rootViewController] UITabBarController" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4496/" ]
181,805
<p>What's the difference between absolute path &amp; relative path when using any web server or Tomcat?</p>
[ { "answer_id": 181811, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 6, "selected": true, "text": "/foo.html\n ../part2/quux.html\n part2/blue.html\n" }, { "answer_id": 181914, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 2, "selected": false, "text": "<?php \n #bar.php\n require('../foo.php'); \n?>\n <?php\n require( realpath(dirname(__FILE__) . '/../foo.php') )\n <?php\n require( SOMECONSTANT . '/relative/path.php' ); \n <?php\n require( $_SERVER['DOCUMENT_ROOT'] . '/relative/path.php' );\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181805", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15177/" ]
181,808
<p>I have created a Dynamic Web Project in my Eclipse workspace. It is also a Maven project, and under SVN control. But in "Open Resource" (Ctrl+Alt+R) no file from this project appears, unless I check from the window's options (top right drop-down) "Show Derived Resources".</p> <p>I have checked on some of the project's folders and they are not marked as "Derived".</p> <p>I have two more (plain Java) projects in the workspace, and all the files from them are visible in "Open Resource".</p> <p>Do you know what might be wrong with either Eclipse, the Maven plugin or Subclipse (the SVN plugin)?</p>
[ { "answer_id": 490825, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": true, "text": "<modules><module>main-module</module><module>integration-test</module>" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181808", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22013/" ]
181,810
<p>I am writing a custom ant task that extends Task. I am using the log() method in the task. What I want to do is use a unit test while deveoping the task, but I don't know how to set up a context for the task to run in to initialise the task as if it were running in ant.</p> <p>This is the custom Task:</p> <pre><code>public class CopyAndSetPropertiesForFiles extends Task { public void execute() throws BuildException { log("CopyAndSetPropertiesForFiles begin execute()"); log("CopyAndSetPropertiesForFiles end execute()"); } } </code></pre> <p>This is the unit test code:</p> <pre><code>CopyAndSetPropertiesForFiles task = new CopyAndSetPropertiesForFiles(); task.execute(); </code></pre> <p>When the code is run as a test it gives a NullPointerException when it calls log.</p> <pre><code>java.lang.NullPointerException at org.apache.tools.ant.Task.log(Task.java:346) at org.apache.tools.ant.Task.log(Task.java:334) at uk.co.tbp.ant.custom.CopyAndSetPropertiesForFiles.execute(CopyAndSetPropertiesForFiles.java:40) at uk.co.tbp.ant.custom.test.TestCopyAndSetPropertiesForFiles.testCopyAndSetPropertiesForFiles(TestCopyAndSetPropertiesForFiles.java:22) </code></pre> <p>Does anybody know a way to provide a context or stubs or something similar to the task?</p> <p>Thanks,</p> <p>Rob.</p> <p>Accepted answer from Abarax. I was able to call task.setProject(new Project()); The code now executes OK (except no logging appears in th console - at least I can exercise the code :-) ).</p>
[ { "answer_id": 185806, "author": "abarax", "author_id": 24390, "author_profile": "https://Stackoverflow.com/users/24390", "pm_score": 2, "selected": true, "text": "public void log(String msg) {\n log(msg, Project.MSG_INFO);\n}\n public void log(String msg, int msgLevel) {\n if (getProject() != null) {\n getProject().log(this, msg, msgLevel);\n } else {\n super.log(msg, msgLevel);\n }\n}\n public void log(String msg, int msgLevel) {\n if (getProject() != null) {\n getProject().log(msg, msgLevel);\n } else {\n // 'reasonable' default, if the component is used without\n // a Project ( for example as a standalone Bean ).\n // Most ant components can be used this way.\n if (msgLevel <= Project.MSG_INFO) {\n System.err.println(msg);\n }\n }\n}\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26063/" ]
181,818
<p>According to the <a href="http://feedparser.org/docs/introduction.html" rel="noreferrer">feedparser documentation</a>, I can turn an RSS feed into a parsed object like this:</p> <pre><code>import feedparser d = feedparser.parse('http://feedparser.org/docs/examples/atom10.xml') </code></pre> <p>but I can't find anything showing how to go the other way; I'd like to be able do manipulate 'd' and then output the result as XML:</p> <pre><code>print d.toXML() </code></pre> <p>but there doesn't seem to be anything in feedparser for going in that direction. Am I going to have to loop through d's various elements, or is there a quicker way?</p>
[ { "answer_id": 181832, "author": "Andrea Ambu", "author_id": 21384, "author_profile": "https://Stackoverflow.com/users/21384", "pm_score": 0, "selected": false, "text": "from xml.dom import minidom\n\ndoc= minidom.parse('./your/file.xml')\nprint doc.toxml()\n" }, { "answer_id": 191899, "author": "dbr", "author_id": 745, "author_profile": "https://Stackoverflow.com/users/745", "pm_score": 4, "selected": true, "text": "#!/usr/bin/env python\nimport datetime\n\n# http://www.feedparser.org/\nimport feedparser\n# http://www.dalkescientific.com/Python/PyRSS2Gen.html\nimport PyRSS2Gen\n\n# Get the data\nparsed_feed = feedparser.parse('http://reddit.com/.rss')\n\n# Modify the parsed_feed data here\n\nitems = [\n PyRSS2Gen.RSSItem(\n title = x.title,\n link = x.link,\n description = x.summary,\n guid = x.link,\n pubDate = datetime.datetime(\n x.modified_parsed[0],\n x.modified_parsed[1],\n x.modified_parsed[2],\n x.modified_parsed[3],\n x.modified_parsed[4],\n x.modified_parsed[5])\n )\n\n for x in parsed_feed.entries\n]\n\n# make the RSS2 object\n# Try to grab the title, link, language etc from the orig feed\n\nrss = PyRSS2Gen.RSS2(\n title = parsed_feed['feed'].get(\"title\"),\n link = parsed_feed['feed'].get(\"link\"),\n description = parsed_feed['feed'].get(\"description\"),\n\n language = parsed_feed['feed'].get(\"language\"),\n copyright = parsed_feed['feed'].get(\"copyright\"),\n managingEditor = parsed_feed['feed'].get(\"managingEditor\"),\n webMaster = parsed_feed['feed'].get(\"webMaster\"),\n pubDate = parsed_feed['feed'].get(\"pubDate\"),\n lastBuildDate = parsed_feed['feed'].get(\"lastBuildDate\"),\n\n categories = parsed_feed['feed'].get(\"categories\"),\n generator = parsed_feed['feed'].get(\"generator\"),\n docs = parsed_feed['feed'].get(\"docs\"),\n\n items = items\n)\n\n\nprint rss.to_xml()\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15371/" ]
181,829
<p>I'm working in a web application using VB.NET. There is also VisualBasic code mixed in it, in particular the Date variable and the Month function of VB.</p> <p>The problem is this part:</p> <pre><code>Month("10/01/2008") </code></pre> <p>On the servers, I get 10 (October) as the month (which is supposed to be correct). On my machine, I get 1 (January) (which is supposed to be wrong).</p> <p>Two of my colleagues (on their own machines) get different answers, one got 1, the other got 10.</p> <p><strong>The question is, why is this so?</strong></p> <p>On my end, I can solve the problem by using .NET's DateTime's Parse (or ParseExact) function to force everything to be "dd/MM/yyyy" format. This works. I'm just wondering why there's an inconsistency.</p> <p>Extra info: I know the parameter for Month function is supposed to be a Date variable. The code used a string as parameter, and Option Strict was off, and the developers mainly let VB do its own conversion thing. (Legacy code maintenance has a lot of inertia...)</p> <p>If it helps, the version of Microsoft.VisualBasic.dll on the servers is 7.10.6310.4 (under the Framework folder v1.1.4322). The version on mine (and my 2 colleagues') machine is 7.10.6001.4.</p> <p>Edit: Regional settings for all machines already set to dd/MM/yyyy format (short date format).</p>
[ { "answer_id": 181860, "author": "Jan", "author_id": 25727, "author_profile": "https://Stackoverflow.com/users/25727", "pm_score": 2, "selected": false, "text": "Month(#10/01/2008#) \n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12984/" ]
181,842
<p>After discovering <a href="http://clojure.org" rel="noreferrer">Clojure</a> I have spent the last few days immersed in it.</p> <p>What project types lend themselves to Java over Clojure, vice versa, and in combination?</p> <p>What are examples of programs which you would have never attempted before Clojure?</p>
[ { "answer_id": 1565514, "author": "pmf", "author_id": 112125, "author_profile": "https://Stackoverflow.com/users/112125", "pm_score": 2, "selected": false, "text": "gen-class proxy" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4857/" ]
181,845
<p>I met a problem when deveoping a photo viewer application. I use ListBox to Show Images, which is contained in a ObservableCollection. I bind the ListBox's ItemsSource to the ObservableCollection.</p> <pre><code> &lt;DataTemplate DataType="{x:Type modeldata:ImageInfo}"&gt; &lt;Image Margin="6" Source="{Binding Thumbnail}" Width="{Binding ZoomBarWidth.Width, Source={StaticResource zoombarmanager}}" Height="{Binding ZoomBarWidth.Width, Source={StaticResource zoombarmanager}}"/&gt; &lt;/DataTemplate&gt; &lt;Grid DataContext="{StaticResource imageinfolder}"&gt; &lt;ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled"&gt; &lt;ListBox Name="PhotosListBox" IsSynchronizedWithCurrentItem="True" Style="{StaticResource PhotoListBoxStyle}" Margin="5" SelectionMode="Extended" ItemsSource="{Binding}" /&gt; &lt;/ScrollViewer&gt; </code></pre> <p>I also bind the Image'height in ListBox with a slider.(the slider's Value also bind to zoombarmanager.ZoomBarWidth.Width). But I found if the collection become larger, such as: contains more then 1000 images, If I use the slider to change the size of iamges, it become a bit slow. My Question is. 1. Why it become Slow? become it tries to zoom every images,or it just because notify("Width") is invoked more than 1000 times. 2. Is there any method to solve this kind of problem and make it faster.</p> <p>The PhotoListBoxStyle is like this:</p> <pre><code> &lt;Style~~ TargetType="{x:Type ListBox}" x:Key="PhotoListBoxStyle"&gt; &lt;Setter Property="Foreground" Value="White" /&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type ListBox}" &gt; &lt;WrapPanel Margin="5" IsItemsHost="True" Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Stretch" /&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style~~&gt; </code></pre> <p>But If I use the Style above, I have to use ScrollViewer outside ListBox, otherwise I have no idea how to get a smooth scrolling scrollerbar and the wrappanel seems have no default scrollerbar. Anyone help? It is said listbox with scrollviewer has poor performance.</p>
[ { "answer_id": 182827, "author": "Joel B Fant", "author_id": 22211, "author_profile": "https://Stackoverflow.com/users/22211", "pm_score": 2, "selected": false, "text": "IValueConverter DecodePixelWidth DecodePixelHeight BitmapImage class PathToThumbnailConverter : IValueConverter {\n public int DecodeWidth {\n get;\n set;\n }\n\n public PathToThumbnailConverter() {\n DecodeWidth = 200;\n }\n\n public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) {\n var path = value as string;\n\n if ( !string.IsNullOrEmpty( path ) ) {\n\n FileInfo info = new FileInfo( path );\n\n if ( info.Exists && info.Length > 0 ) {\n BitmapImage bi = new BitmapImage();\n\n bi.BeginInit();\n bi.DecodePixelWidth = DecodeWidth;\n bi.CacheOption = BitmapCacheOption.OnLoad;\n bi.UriSource = new Uri( info.FullName );\n bi.EndInit();\n\n return bi;\n }\n }\n\n return null;\n }\n\n public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) {\n throw new NotImplementedException();\n }\n\n}\n" }, { "answer_id": 182897, "author": "user7116", "author_id": 7116, "author_profile": "https://Stackoverflow.com/users/7116", "pm_score": 2, "selected": false, "text": "<ListBox.ItemsPanel>\n <ItemsPanelTemplate>\n <StackPanel>\n <StackPanel.LayoutTransform>\n <ScaleTransform\n ScaleX=\"{Binding Path=Value, ElementName=ZoomSlider}\"\n ScaleY=\"{Binding Path=Value, ElementName=ZoomSlider}\" />\n </StackPanel.LayoutTransform>\n </StackPanel>\n </ItemsPanelTemplate>\n</ListBox.ItemsPanel>\n" }, { "answer_id": 186187, "author": "rudigrobler", "author_id": 5147, "author_profile": "https://Stackoverflow.com/users/5147", "pm_score": 4, "selected": true, "text": "<ListBox.ItemsPanel>\n <ItemsPanelTemplate>\n <WrapPanel Orientation=\"Horizontal\"/>\n </ItemsPanelTemplate>\n</ListBox.ItemsPanel>\n <Setter Property=\"ScrollViewer.HorizontalScrollBarVisibility\" Value=\"Disabled\" />\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25749/" ]
181,853
<p>I am using Moq to mock my Repository layer so I can unit test.</p> <p>My repository layer Insert methods update the Id property of my entities when a successful db insert occurs.</p> <p>How do I configure moq to update the Id property of the entity when the Insert method is called? </p> <p>Repository code:-</p> <pre><code>void IAccountRepository.InsertAccount(AccountEntity account); </code></pre> <p>Unit Test:-</p> <pre><code>[TestInitialize()] public void MyTestInitialize() { accountRepository = new Mock&lt;IAccountRepository&gt;(); contactRepository = new Mock&lt;IContactRepository&gt;(); contractRepository = new Mock&lt;IContractRepository&gt;(); planRepository = new Mock&lt;IPlanRepository&gt;(); generator = new Mock&lt;NumberGenerator&gt;(); service = new ContractService(contractRepository.Object, accountRepository.Object, planRepository.Object, contactRepository.Object, generator.Object); } [TestMethod] public void SubmitNewContractTest() { // Setup Mock Objects planRepository .Expect(p =&gt; p.GetPlan(1)) .Returns(new PlanEntity() { Id = 1 }); generator .Expect(p =&gt; p.GenerateAccountNumber()) .Returns("AC0001"); // Not sure what to do here? // How to mock updating the Id field for Inserts? // // Creates a correctly populated NewContractRequest instance NewContractRequest request = CreateNewContractRequestFullyPopulated(); NewContractResponse response = service.SubmitNewContract(request); Assert.IsTrue(response.IsSuccessful); } </code></pre> <p>implementation snippet from ContractService class (WCF service contract).</p> <pre><code>AccountEntity account = new AccountEntity() { AccountName = request.Contact.Name, AccountNumber = accountNumber, BillingMethod = BillingMethod.CreditCard, IsInvoiceRoot = true, BillingAddressType = BillingAddressType.Postal, ContactId = request.Contact.Id.Value }; accountRepository.InsertAccount(account); if (account.Id == null) { // ERROR } </code></pre> <p>I apologise if this information may be a little lacking. I only started learning moq and mocking frameworks today. ac</p>
[ { "answer_id": 181863, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 4, "selected": true, "text": "accountRepository\n .Expect(r => r.InsertAccount(account))\n .Callback(() => account.ID = 1);\n" }, { "answer_id": 185370, "author": "Rob Gray", "author_id": 5691, "author_profile": "https://Stackoverflow.com/users/5691", "pm_score": 2, "selected": false, "text": "accountRepository\n .Expect(p => p.InsertAccount(It.Is<AccountEntity>(x => x.Id == null)))\n .Callback<AccountEntity>(a => a.Id = 1);\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5691/" ]
181,855
<p>Does anyone know of a nice (and preferably free) way to integrate Prolog and C#?</p> <p>Im looking to create a Prolog dll or similar to call from my managed code, and retrieve an answer once all the processing has been complete. Im looking for it to be predominantly one sided (c# calls Prolog).</p> <p>I have seen <a href="https://stackoverflow.com/questions/130097/real-world-prolog-usage">this question</a> which talks about Prologs real world usage but I was wondering if anyone had either any experience with c# &amp; Prolog? or a nice tutorial/article?</p>
[ { "answer_id": 181936, "author": "zuber", "author_id": 9812, "author_profile": "https://Stackoverflow.com/users/9812", "pm_score": 3, "selected": false, "text": "yield Variable" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1816/" ]
181,892
<p>The situation is this: I have a USB device (a custom device I'm trying to talk to) with two endpoints, one writing to the device, one reading from the device. Both are bulk transfers. Every communication transaction takes the form of (1) Write a command to the device (2) Read the response. I'm using libusb (version 0.1 rather than the 1.0 beta) to actually perform the communications.</p> <p>On Windows, all is well. I can connect the device, claim the interface and communicate happily. However, in Ubuntu (a standard Hardy desktop install), whilst I can connect to the device and write to it, all read operations fail with the error "error submitting URB: Invalid argument" reported from libusb (error code -22).</p> <p>If I check /var/log/messages I see a warning message logged for the same time as the read was attempted: "sysfs: duplicate filename 'usbdev4.3_ep81' can not be created" - which tallies with the device (it is indeed on that bus and it's endpoint 81 I'm trying to read from).</p> <p>So... anyone seen a similar problem using libusb, or have any idea how to fix it?</p>
[ { "answer_id": 188140, "author": "John Nilsson", "author_id": 24243, "author_profile": "https://Stackoverflow.com/users/24243", "pm_score": 1, "selected": false, "text": "SUBSYSTEM==\"usb\" ATTRS{idVendor}==\"0a81\", ATTRS{idProduct}==\"0701\", \\\n MODE=\"0666\" SYMLINK+=\"missile_launcher\"\n if(LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP)\n{\n // Detach kernel driver (usbhid) from device interface. (Linux hack)\n usb_detach_kernel_driver_np(launcher, 0);\n usb_detach_kernel_driver_np(launcher, 1);\n}\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25541/" ]
181,894
<p>I'm testing the speed of some queries in MySQL. The database is caching these queries making it difficult for me to get reliable results when testing how fast these queries are.</p> <p>Is there a way to disable caching for a query?</p> <p>System: MySQL 4 on Linux webhosting, I have access to PHPMyAdmin.</p> <p>Thanks</p>
[ { "answer_id": 181905, "author": "Jarod Elliott", "author_id": 1061, "author_profile": "https://Stackoverflow.com/users/1061", "pm_score": 9, "selected": false, "text": "SELECT SQL_NO_CACHE * FROM TABLE\n" }, { "answer_id": 190348, "author": "djt", "author_id": 26677, "author_profile": "https://Stackoverflow.com/users/26677", "pm_score": 5, "selected": false, "text": "RESET QUERY CACHE\n" }, { "answer_id": 1257976, "author": "wbharding", "author_id": 153610, "author_profile": "https://Stackoverflow.com/users/153610", "pm_score": 4, "selected": false, "text": "SELECT SQL_NO_CACHE * FROM TABLE\n" }, { "answer_id": 6408485, "author": "mediobit", "author_id": 732290, "author_profile": "https://Stackoverflow.com/users/732290", "pm_score": 6, "selected": false, "text": "SELECT *,NOW() FROM TABLE\n" }, { "answer_id": 6706731, "author": "John Carter", "author_id": 8331, "author_profile": "https://Stackoverflow.com/users/8331", "pm_score": 7, "selected": false, "text": "SET SESSION query_cache_type=0;\n" }, { "answer_id": 8862462, "author": "newtover", "author_id": 68998, "author_profile": "https://Stackoverflow.com/users/68998", "pm_score": 2, "selected": false, "text": "SQL_NO_CACHE SELECT t.*\nFROM thetable t, (SELECT @a:=NULL) as init;\n" }, { "answer_id": 19727015, "author": "Sergio Costa", "author_id": 1887713, "author_profile": "https://Stackoverflow.com/users/1887713", "pm_score": 4, "selected": false, "text": "SHOW VARIABLES LIKE 'query_cache_type';\nSET SESSION query_cache_type = OFF;\nSHOW VARIABLES LIKE 'query_cache_type';\n" }, { "answer_id": 70370487, "author": "Robert Máslo", "author_id": 12636646, "author_profile": "https://Stackoverflow.com/users/12636646", "pm_score": 0, "selected": false, "text": "function db_RunSQL($SQL, $NoCacheMode=false)\n{\n$SQL = (($NoCacheMode) ? '/*'.time().'*/ ' : '') . $SQL;\nreturn mysqli_query(db_SavedConnect(), $SQL);\n}\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
181,898
<p>In order to lighten Apache's load people often suggest using lighttpd to serve up static content.</p> <p>e.g. <a href="http://www.linux.com/feature/51673" rel="noreferrer">http://www.linux.com/feature/51673</a></p> <p>In this setup Apache passes requests for static content back to lighttpd via mod_proxy, while serving dynamic requests itself.</p> <p>My question is: how does this reduce the load on the server? Since you still have an apache process spawned for every request that comes in, how does this positively impact the load? From what I can see the size of the Apache process proxying its request through lighttpd is as large as it would be if it were serving the file itself.</p>
[ { "answer_id": 181955, "author": "Andre Bossard", "author_id": 21027, "author_profile": "https://Stackoverflow.com/users/21027", "pm_score": 2, "selected": false, "text": "Scaling" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26069/" ]
181,901
<p>I try to add an addons system to my Windows.Net application using Reflection; but it fails when there is addon with dependencie.<br><br> Addon class have to implement an interface 'IAddon' and to have an empty constructor.<br> Main program load the addon using Reflection:</p> <pre><code>Assembly assembly = Assembly.LoadFile(@"C:\Temp\TestAddon\Addon.dll"); Type t = assembly.GetType("Test.MyAddon"); ConstructorInfo ctor = t.GetConstructor(new Type[] { }); IAddon addon= (IAddon) ctor.Invoke(new object[] { }); addon.StartAddon(); </code></pre> <p>It works great when addon do not use dependencie. But if my addon reference and use an another DLL (C:\Temp\TestAddon\MyTools.dll) that is saved near the addon in disk, it fails: <br> <em>System.IO.FileNotFoundException: Could not load file or assembly 'MyTools.dll' or one of its dependencies.</em> </p> <p>I do not wants to copy the addons DLL near my executable, how can i do to tell .Net runtime to search in "C:\Temp\TestAddon\" for any dependency?</p> <p>Note that adding </p> <pre><code>Assembly assembly = Assembly.LoadFile(@"C:\Temp\TestAddon\MyTools.dll"); </code></pre> <p>do not change anything.</p>
[ { "answer_id": 181907, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 1, "selected": false, "text": "AppDomain.AssemblyResolve AppDomain System.AddIn" }, { "answer_id": 181941, "author": "Andreas Tschager", "author_id": 24467, "author_profile": "https://Stackoverflow.com/users/24467", "pm_score": 7, "selected": true, "text": "Assembly.LoadFrom Assembly.LoadFile AppDomain.AssemblyResolve" }, { "answer_id": 181988, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 1, "selected": false, "text": "Assembly. _GetReferencedAssemblies() mscorlib System.Web" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26071/" ]
181,909
<p>Are there any free tools for scripting MSSQL table data? I'll gladly write one, but am hoping it's been done, and the app matured a bit before/</p>
[ { "answer_id": 181942, "author": "ConcernedOfTunbridgeWells", "author_id": 15401, "author_profile": "https://Stackoverflow.com/users/15401", "pm_score": 4, "selected": false, "text": "-- ====================================================================\n-- === reverse_engineer_2005.sql ======================================\n-- ====================================================================\n-- \n-- Script to generate table, index, pk, view and fk definitions from\n-- a SQL Server 2005 database. Adapted from one I originally wrote \n-- for SQL Server 2000. It's not comprehensive (doesn't extract \n-- partition schemes) but it does do defaults and computed columns\n--\n-- Run the script with 'results to text' and cut/paste the output into\n-- the editor window. Set the schema as described below.\n--\n-- Copyright (c) 2004-2008 Concerned of Tunbridge Wells\n-- \n-- Permission is hereby granted, free of charge, to any person\n-- obtaining a copy of this software and associated documentation\n-- files (the \"Software\"), to deal in the Software without\n-- restriction, including without limitation the rights to use,\n-- copy, modify, merge, publish, distribute, sublicense, and/or sell\n-- copies of the Software, and to permit persons to whom the\n-- Software is furnished to do so, subject to the following\n-- conditions:\n--\n-- The above copyright notice and this permission notice shall be\n-- included in all copies or substantial portions of the Software.\n--\n-- THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n-- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n-- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n-- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n-- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n-- OTHER DEALINGS IN THE SOFTWARE.\n--\n-- ====================================================================\n--\n\nset nocount on\n\n-- This does a specific schema. Set the schema here\n--\ndeclare @schema varchar (max)\nselect @schema = 'dbo'\n\nif object_id ('tempdb..#objects') is not null begin\n drop table #objects\nend\n\nif object_id ('tempdb..#views') is not null begin\n drop table #views\nend\n\nif object_id ('tempdb..#types') is not null begin\n drop table #types\nend\n\n\n-- Gets lists of tables and views belonging to the schema\n--\nselect o.name\n ,o.object_id\n into #objects\n from sys.objects o\n join sys.schemas s\n on s.schema_id = o.schema_id\n where o.type in ('U')\n and s.name = @schema\n\n\nselect o.name\n ,o.object_id\n into #views\n from sys.objects o\n join sys.schemas s\n on s.schema_id = o.schema_id\n where o.type in ('V')\n and s.name = @schema\n\n\n-- Some metadata for rendering types\n--\nselect a.* \n into #types\n from ((select 'decimal' as typename, 6 as format) union all\n (select 'numeric', 6) union all\n (select 'varbinary', 1) union all\n (select 'varchar', 1) union all\n (select 'char', 1) union all\n (select 'nvarchar', 1) union all\n (select 'nchar', 1)) a\n\n\n\n\n\n-- This generates 'drop table' and 'drop view' statements\n--\nselect 'if exists (select 1' + char(10) +\n ' from sys.objects o' + char(10) +\n ' join sys.schemas s' + char(10) +\n ' on o.schema_id = s.schema_id' + char(10) +\n ' where o.name = ''' + o.name + '''' + char(10) +\n ' and s.name = ''' + @schema +'''' + char(10) +\n ' and o.type = ''U'') begin' + char(10) +\n ' drop table [' + @schema + '].[' + o.name + ']' + char(10) +\n 'end' + char(10) +\n 'go' + char(10)\n from sys.objects o\n join #objects o2\n on o.object_id = o2.object_id\n where o.type = 'U'\n\n\nselect 'if exists (select 1' + char(10) +\n ' from sys.objects o' + char(10) +\n ' join sys.schemas s' + char(10) +\n ' on o.schema_id = s.schema_id' + char(10) +\n ' where o.name = ''' + o.name + '''' + char(10) +\n ' and s.name = ''' + @schema + '''' + char(10) +\n ' and o.type = ''V'') begin' + char(10) +\n ' drop view [' + @schema + '].[' + o.name + ']' + char(10) +\n 'end' + char(10) +\n 'go' + char(10)\n from sys.objects o\n join #objects o2\n on o.object_id = o2.object_id\n where o.type = 'V'\n\n\n-- This generates table definitions\n--\nselect case when c.column_id = \n (select min(c2.column_id)\n from sys.columns c2\n where c2.object_id = o.object_id)\n then 'create table [' + @schema + '].[' + isnull(o.name, 'XYZZY') + '] (' + char(10)\n else ''\n end +\n left(' [' +rtrim(c.name) + '] ' +\n ' ', 48) +\n isnull(calc.text, \n t.name +\n case when tc.format & 2 = 2 \n then ' (' +convert (varchar, c.precision) +\n case when tc.format & 2 = 2\n then ', ' + convert (varchar, c.scale)\n else ''\n end + ')'\n when tc.format & 1 = 1\n then ' (' + convert (varchar, c.max_length) + ')'\n else ''\n end + ' ' + \n case when c.is_nullable <> 0 then 'null'\n else 'not null'\n end + isnull(ident.text, isnull(con.text, ''))) +\n case when c.column_id =\n (select max(c2.column_id)\n from sys.columns c2\n where c2.object_id = o.object_id)\n then char(10) + ')' + char(10) + 'go' + char(10)\n else ','\n end\n from sys.objects o\n join #objects o2\n on o.object_id = o2.object_id\n join sys.columns c\n on c.object_id = o.object_id\n join sys.types t\n on c.user_type_id = t.user_type_id\n left join \n (select object_id,\n column_id,\n 'as ' + definition as text\n from sys.computed_columns) calc\n on calc.object_id = o.object_id\n and calc.column_id = c.column_id\n left join\n (select parent_object_id,\n parent_column_id,\n ' default ' + definition as text\n from sys.default_constraints) con\n on con.parent_object_id = o.object_id\n and con.parent_column_id = c.column_id\n left join\n (select o.object_id,\n col.column_id,\n ' identity (' + convert(varchar, ident_seed(o.name)) + ', ' +\n convert(varchar, ident_incr(o.name)) + ')' as text\n from sys.objects o\n join sys.columns col\n on o.object_id = col.object_id\n where columnproperty (o.object_id, col.name, 'IsIdentity') = 1) as ident\n on ident.object_id = o.object_id\n and ident.column_id = c.column_id\n left join #types tc\n on tc.typename = t.name\n where o.type = 'U'\n order by o.name,\n c.column_id\n\n\n-- This generates view definitions \n--\nselect definition + char(10) + 'go' + char(10)\n from sys.sql_modules c\n join sys.objects o\n on c.object_id = o.object_id\n join #views o2\n on o.object_id = o2.object_id\n\n\n\n-- This generates PK and unique constraints\n--\n\nselect case when ik.key_ordinal = \n (select min(ik2.key_ordinal)\n from sys.index_columns ik2\n where ik2.object_id = ik.object_id\n and ik2.index_id = ik.index_id)\n then 'alter table [' + rtrim (s.name) + '].[' + rtrim(t.name) + ']' + char(10) +\n ' add constraint [' + rtrim (pk.name) + '] ' + \n case when pk.type = 'PK' then 'primary key'\n when pk.type = 'UQ' then 'unique'\n else 'foobar'\n end + char(10) +\n ' ('\n else ' ,'\n end +\n '[' + rtrim(c.name) + ']' +\n case when ik.key_ordinal =\n (select max(ik2.key_ordinal)\n from sys.index_columns ik2\n where ik2.object_id = ik.object_id\n and ik2.index_id = ik.index_id)\n then ')' + char(10) + 'go' + char(10)\n else ''\n end\n from sys.objects t -- table\n join #objects o\n on t.object_id = o.object_id\n join sys.schemas s\n on s.schema_id = t.schema_id\n join sys.objects pk -- key\n on pk.parent_object_id = t.object_id\n join sys.columns c -- columns\n on c.object_id = t.object_id\n join sys.indexes i -- get index for constraint\n on i.object_id = t.object_id\n and i.name = pk.name\n join sys.index_columns ik -- index column and name\n on ik.object_id = i.object_id\n and ik.index_id = i.index_id\n and ik.column_id = c.column_id -- vvv Get the right index\n where c.name = index_col('[' + s.name + '].[' + t.name + ']', i.index_id, ik.key_ordinal)\n and pk.type in ('PK', 'UQ') --probably redundant\n order by t.object_id,\n pk.object_id,\n ik.key_ordinal\n\n\n\n-- This generates indexes\n--\nselect case when ik.key_ordinal = \n (select min(ik2.key_ordinal)\n from sys.index_columns ik2\n where ik2.object_id = ik.object_id\n and ik2.index_id = ik.index_id)\n then 'create ' +\n case when is_unique_constraint = 1 then 'unique '\n else ''\n end +\n 'index [' + rtrim(i.name) + ']' + char (10) +\n ' on [' + rtrim(t.name) + ']' + char (10) +\n ' ('\n else ' ,'\n end +\n '[' + c.name + ']' +\n case when ik.key_ordinal = \n (select max(ik2.key_ordinal)\n from sys.index_columns ik2\n where ik2.object_id = ik.object_id\n and ik2.index_id = ik.index_id)\n then ')' + char(10) + 'go' + char(10)\n else ''\n end\n from sys.objects t -- table\n join #objects o\n on o.object_id = t.object_id\n join sys.columns c -- columns\n on c.object_id = t.object_id\n join sys.indexes i -- get index for constraint\n on i.object_id = t.object_id\n join sys.index_columns ik -- index column and name\n on ik.object_id = i.object_id\n and ik.index_id = i.index_id\n and ik.column_id = c.column_id -- vvv Get the right index\n where c.name = index_col(t.name, i.index_id, ik.key_ordinal)\n and t.type = 'U'\n and i.name <> t.name\n and i.name not in\n (select c2.name\n from sys.objects c2\n where c2.parent_object_id = t.object_id\n and c2.type in ('PK', 'UQ'))\n order by t.name,\n i.name,\n ik.key_ordinal\n\n\n-- This generates foreign keys\n--\nselect con.constraint_text as [--constraint_text]\n from ((select case when kc.constraint_column_id = \n (select min(k2.constraint_column_id)\n from sys.foreign_key_columns k2\n where k2.constraint_object_id = k.object_id)\n then 'alter table [' + @schema + '].[' + rtrim(t.name) + ']' + char(10) +\n ' add constraint [' + rtrim (k.name) + '] ' + char(10) +\n ' foreign key ('\n else ' ,'\n end +\n '[' + tc.name + ']' +\n case when kc.constraint_column_id =\n (select max(k2.constraint_column_id)\n from sys.foreign_key_columns k2\n where k2.constraint_object_id = k.object_id)\n then ')' \n else ''\n end as constraint_text,\n t.name as table_name,\n k.name as constraint_name,\n kc.constraint_column_id as row_order,\n t.object_id\n from sys.foreign_keys k\n join sys.objects t\n on t.object_id = k.parent_object_id\n join sys.columns tc\n on tc.object_id = t.object_id\n join sys.foreign_key_columns kc\n on kc.constraint_object_id = k.object_id\n and kc.parent_object_id = t.object_id\n and kc.parent_column_id = tc.column_id\n join sys.objects r\n on r.object_id = kc.referenced_object_id\n join sys.columns rc\n on kc.referenced_object_id = rc.object_id\n and kc.referenced_column_id = rc.column_id)\n union all\n (select case when kc.constraint_column_id = \n (select min(k2.constraint_column_id)\n from sys.foreign_key_columns k2\n where k2.constraint_object_id = k.object_id)\n then ' references [' + rtrim(r.name) + ']' + char(10) +\n ' ('\n else ' ,'\n end +\n '[' + rc.name + ']' +\n case when kc.constraint_column_id = \n (select max(k2.constraint_column_id)\n from sys.foreign_key_columns k2\n where k2.constraint_object_id = k.object_id)\n then ')' + char(10) + 'go' + char(10)\n else ''\n end as constraint_text,\n t.name as table_name,\n k.name as constraint_name,\n kc.constraint_column_id + 100 as row_order,\n t.object_id\n from sys.foreign_keys k\n join sys.objects t\n on t.object_id = k.parent_object_id\n join sys.columns tc\n on tc.object_id = t.object_id\n join sys.foreign_key_columns kc\n on kc.constraint_object_id = k.object_id\n and kc.parent_object_id = t.object_id\n and kc.parent_column_id = tc.column_id\n join sys.objects r\n on r.object_id = kc.referenced_object_id\n join sys.columns rc\n on kc.referenced_object_id = rc.object_id\n and kc.referenced_column_id = rc.column_id)) con\n join #objects o\n on con.object_id = o.object_id\n order by con.table_name, \n con.constraint_name, \n con.row_order\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8741/" ]
181,921
<p>When working on a big C/C++ project, do you have some specific rules regarding the <em>#include</em> within source or header files?</p> <p>For instance, we can imagine to follow one of these two excessive rules:</p> <ol> <li><em>#include</em> are forbidden in <em>.h</em> files; it is up to each <em>.c</em> file to include all the headers it needs</li> <li>Each <em>.h</em> file should include all its dependancies, i.e. it should be able to compile alone without any error.</li> </ol> <p>I suppose there is trade-off in between for any project, but what is yours? Do you have more specific rules? Or any link that argues for any of the solutions? </p>
[ { "answer_id": 181927, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 3, "selected": false, "text": "<iosfwd> // observer.hpp\n\nclass Observer; // Forward declaration.\n\n#ifndef MYLIB_OBSERVER_HPP\n#define MYLIB_OBSERVER_HPP\n\n#include \"subject.hpp\"\n\nstruct Observer {\n virtual ~Observer() = 0;\n virtual void Update(Subject* subject) = 0;\n};\n\n#endif\n // subject.hpp\n#include <list>\n\nstruct Subject; // Forward declaration.\n\n#ifndef MYLIB_SUBJECT_HPP\n#define MYLIB_SUBJECT_HPP\n\n#include \"observer.hpp\"\n\nstruct Subject {\n virtual ~Subject() = 0;\n void Attach(Observer* observer);\n void Detach(Observer* observer);\n void Notify();\n\nprivate:\n std::list<Observer*> m_Observers;\n};\n\n#endif\n" }, { "answer_id": 182021, "author": "Mecki", "author_id": 15809, "author_profile": "https://Stackoverflow.com/users/15809", "pm_score": 5, "selected": false, "text": "hashtable.h hashing.h hashtable.c hashtable.h" }, { "answer_id": 182270, "author": "Ferruccio", "author_id": 4086, "author_profile": "https://Stackoverflow.com/users/4086", "pm_score": 2, "selected": false, "text": "using namespace" }, { "answer_id": 237296, "author": "peterchen", "author_id": 31317, "author_profile": "https://Stackoverflow.com/users/31317", "pm_score": 0, "selected": false, "text": "// foo.c\n#include \"any header\"\n// end of foo.c\n" }, { "answer_id": 20579603, "author": "pyon", "author_id": 46571, "author_profile": "https://Stackoverflow.com/users/46571", "pm_score": 1, "selected": false, "text": "#include #include #include" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181921", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26074/" ]
181,930
<p>We have two Tables:</p> <ul> <li>Document: id, title, document_type_id, showon_id</li> <li>DocumentType: id, name</li> <li>Relationship: DocumentType hasMany Documents. (Document.document_type_id = DocumentType.id)</li> </ul> <p>We wish to retrieve a list of all document types for one given ShowOn_Id. </p> <p>We see two possiblities:</p> <pre><code>SELECT DocumentType.* FROM DocumentType WHERE DocumentType.id IN ( SELECT DISTINCT Document.document_type_id FROM Document WHERE showon_id = 42 ); SELECT DocumentType.* FROM DocumentType WHERE DocumentType.id IN ( SELECT Document.document_type_id FROM Document WHERE showon_id = 42 ); </code></pre> <p>Our question is: when and if is it better to use the DISTINCT to get the smaller record set versus retrieving the whole table and the IN statement walking the table to the first match. (We guess that's what it does ;-))</p> <p>Is this different for different databases, is there a common answer?</p> <p>Or is there a better way of doing it? (We are in .NET land)</p>
[ { "answer_id": 181974, "author": "wmasm", "author_id": 26079, "author_profile": "https://Stackoverflow.com/users/26079", "pm_score": 4, "selected": false, "text": "SELECT DISTINCT DocumentType.*\nFROM DocumentType\nINNER JOIN Document\nON DocumentType.id=Document.document_type_id\nWHERE Document.showon_id = 42\n" }, { "answer_id": 183155, "author": "Matt Rogish", "author_id": 2590, "author_profile": "https://Stackoverflow.com/users/2590", "pm_score": 2, "selected": false, "text": "SELECT whatever\n FROM DocumentType dt\n WHERE EXISTS( SELECT *\n FROM Document \n WHERE dt.id = document_type_id\n AND showon_id = 42)\n SET SHOWPLAN_TEXT ON\nGO\n\nSELECT ...\nGO\n" }, { "answer_id": 187328, "author": "Ben", "author_id": 5005, "author_profile": "https://Stackoverflow.com/users/5005", "pm_score": 0, "selected": false, "text": "SELECT DocumentType.* FROM DocumentType WHERE DocumentType.id IN (SELECT DISTINCT Document.document_type_id FROM Document WHERE showon_id = 42); SELECT DocumentType.* FROM DocumentType WHERE DocumentType.id IN (SELECT Document.document_type_id FROM Document WHERE showon_id = 42); SELECT DISTINCT DocumentType.* FROM DocumentType INNER JOIN Document ON DocumentType.id=Document.document_type_id WHERE Document.showon_id = 42; SELECT DocumentType.* FROM DocumentType WHERE EXISTS ( SELECT * FROM Document WHERE DocumentType.id=Document.document_type_id AND showon_id = 42); |--Hash Match(Right Semi Join, HASH:([Document].[document_type_id])=([DocumentType].[Id]))\n |--Hash Match(Inner Join, HASH:([Document].[Title], [Uniq1005])=([Document].[Title], [Uniq1005]), RESIDUAL:([Document].[Title] as [Document].[Title] = [Document].[Title] as [Document].[Title] AND [Uniq1005] = [Uniq1005]))\n | |--Index Seek(OBJECT:([Document].[IX_Document_3] AS [Document]), SEEK:([Document].[showon_id]=(1)) ORDERED FORWARD)\n | |--Index Scan(OBJECT:([Document].[IX_Document_1] AS [Document]))\n |--Table Scan(OBJECT:([DocumentType] AS [DocumentType]))\n" }, { "answer_id": 188515, "author": "jjacka", "author_id": 26515, "author_profile": "https://Stackoverflow.com/users/26515", "pm_score": 2, "selected": false, "text": "SELECT DISTINCT dt.* \nFROM \n DocumentType dt\n INNER JOIN Document d ON dt.id=d.document_type_id and d.showon_id = 42\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5005/" ]
181,953
<p>The more I learn about WPF and XAML, the more I realize that you can do pretty much all of your GUI initialization and event handling glue in either XAML or in code (say C# code or VB.Net code). </p> <p>My question is to those who have been working on WPF for longer and ideally those who have shipped apps with it -- where did you find was the best place to 'draw the line' between XAML and code? Did you use XAML wherever you could? Only where interfacing with non-coding UI designers? </p> <p>Any tips in this area would be extremely helpful to myself and other coders who are just getting into WPF programming and are kind of paralyzed by all the choices we can make!</p>
[ { "answer_id": 182016, "author": "Arcturus", "author_id": 900, "author_profile": "https://Stackoverflow.com/users/900", "pm_score": 2, "selected": false, "text": "ControlTemplate DataTemplates" }, { "answer_id": 2919537, "author": "akjoshi", "author_id": 45382, "author_profile": "https://Stackoverflow.com/users/45382", "pm_score": 1, "selected": false, "text": "Binding commands styles templates" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
181,956
<p>How can I prevent a user from resizing GridViewColumns withing a ListView control?</p>
[ { "answer_id": 17161092, "author": "Jonathan Alfaro", "author_id": 2495728, "author_profile": "https://Stackoverflow.com/users/2495728", "pm_score": 5, "selected": false, "text": "<GridView.ColumnHeaderContainerStyle>\n <Style TargetType=\"{x:Type GridViewColumnHeader}\">\n <Setter Property=\"IsEnabled\" Value=\"False\"/>\n </Style>\n</GridView.ColumnHeaderContainerStyle>\n <GridView.ColumnHeaderContainerStyle>\n <Style TargetType=\"{x:Type GridViewColumnHeader}\">\n <Setter Property=\"IsEnabled\" Value=\"False\"/>\n <Style.Triggers>\n <Trigger Property=\"IsEnabled\" Value=\"False\"> \n <Setter Property=\"TextElement.Foreground\" Value=\"Black\"/> \n </Trigger>\n </Style.Triggers>\n </Style>\n</GridView.ColumnHeaderContainerStyle>\n" }, { "answer_id": 19910817, "author": "InTheZone", "author_id": 1598254, "author_profile": "https://Stackoverflow.com/users/1598254", "pm_score": 5, "selected": false, "text": "IsHitTestVisible IsEnabled <GridView.ColumnHeaderContainerStyle>\n <Style BasedOn=\"{StaticResource {x:Type GridViewColumnHeader}}\" TargetType=\"{x:Type GridViewColumnHeader}\">\n <Setter Property=\"IsHitTestVisible\" Value=\"False\"/>\n </Style>\n</GridView.ColumnHeaderContainerStyle>\n" }, { "answer_id": 64045015, "author": "mca", "author_id": 3526091, "author_profile": "https://Stackoverflow.com/users/3526091", "pm_score": 0, "selected": false, "text": "<GridViewColumn ...>\n <GridViewColumn.HeaderContainerStyle>\n <Style TargetType=\"{x:Type FrameworkElement}\">\n <Setter Property=\"IsHitTestVisible\" Value=\"False\"/>\n </Style>\n </GridViewColumn.HeaderContainerStyle>\n</GridViewColumn>\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20227/" ]
181,966
<p>I want to use a template engine in a struts application and would like to know if using TILES can be recommended instead of FREEMARKER or VELOCITY.</p>
[ { "answer_id": 181983, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "Hello ${name}" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181966", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
181,967
<p>I am currently working on a leave application (which is a subset of my e-scheduler project) and I have my database design as follows:</p> <pre><code>event (event_id, dtstart, dtend... *follows icalendar standard*) event_leave (event_id*, leave_type_id*, total_days) _leave_type (leave_type_id, name, max_carry_forward) _leave_allocation (leave_allocation_id, leave_type_id*, name, user_group_id, total_days, year) _leave_carry_forward(leave_carry_forward_id, leave_type_id*, user_id, year) </code></pre> <p>Does anyone here in stackoverflow also working on an e-leave app? mind to share your database design as I am looking for a better design than mine. The problem with my current design only occurs at the beginning of the year when the system is calculating the number of days that can be carried forward. </p> <p>In total I would have to run 1 + {$number_of users} * 2 queries (the first one to find out the number of allocation rules and the maximum carry forward quota. Then for each user, I need to find out the balance, and then to insert the balance to the database)</p>
[ { "answer_id": 182149, "author": "Mark Brackett", "author_id": 2199, "author_profile": "https://Stackoverflow.com/users/2199", "pm_score": 2, "selected": false, "text": "User { User_Id (PK) }\n\n// Year may be a tricky business logic issue here...Do you charge the Start or End year\n// if the event crosses a year boundary? Or do you just do 2 different events?\n// You want year in this table, though, so you can do a FK reference to Leave_Allocation\n// Some RDBMS will let you do a FK from a View, though, so you could do that\nEvent { Event_Id (PK), User_Id, Leave_Type_Id, Year, DtStart, DtEnd, ... \n // Ensure that events are charged to leave the user has\n FK (User_Id, Leave_Type_Id, Year)->Leave_Allocation(User_Id, Leave_Type_Id, Year)\n}\n\nLeave_Type { Leave_Type_Id, Year, Max_Carry_Forward \n // Max_Carry_Forward would probably change per year\n PK (Leave_Type_Id, Year)\n}\n\n// Starting balance for each leave_type and user, per year\n// Not sure the name makes the most sense - I think of Allocated as used leave,\n// so I'd probably call this Leave_Starting_Balance or something\nLeave_Allocation { Leave_Type_Id (FK->Leave_Type.Leave_Type_Id), User_Id (FK->User.User_Id), Year, Total_Days \n PK (Leave_Type_Id, User_Id, Year)\n // Ensure that leave_type is defined for this year\n FK (Leave_Type_Id, Year)->Leave_Type(Leave_Type_Id, Year)\n}\n /* Just sum up the Total_Days for an event to make some other calcs easier */\nCREATE VIEW Event_Leave AS\n SELECT\n Event_Id,\n User_Id,\n Leave_Type_Id,\n DATEDIFF(d, DtEnd, DtStart) as Total_Days,\n Year\n FROM Event\n\n/* Subtract sum of allocated leave (Event_Leave.Total_Days) from starting balance (Leave_Allocation) */\n/* to get the current unused balance of leave */\nCREATE VIEW Leave_Current_Balance AS\n SELECT\n Leave_Allocation.User_Id,\n Leave_Allocation.Leave_Type_Id,\n Leave_Allocation.Year,\n Leave_Allocation.Total_Days - SUM(Event_Leave.Total_Days) as Leave_Balance\n FROM Leave_Allocation\n LEFT OUTER JOIN Event_Leave ON\n Leave_Allocation.User_Id = Event_Leave.User_Id\n AND Leave_Allocation.Leave_Type_Id = Event_Leave.Leave_Type_Id\n AND Leave_Allocation.Year = Event_Leave.Year\n GROUP BY\n Leave_Allocation.User_Id,\n Leave_Allocation.Leave_Type_Id,\n Leave_Allocation.Year,\n Leave_Allocation.Total_Days\n SELECT\n User_Id,\n Leave_Type_Id,\n Year,\n /* This is T-SQL syntax...your RDBMS may be different, but should be able to do the same thing */\n /* If not, you'd do a UNION ALL to Max_Carry_Forward and select MIN(BalanceOrMax) */\n CASE \n WHEN Leave_Balance < Max_Carry_Forward \n THEN Leave_Balance \n ELSE \n Max_Carry_Forward \n END as Leave_Carry_Forward\n FROM Leave_Current_Balance\n JOIN Leave_Type ON\n Leave_Current_Balance.Leave_Type_Id = Leave_Type.Leave_Type_Id\n /* This assumes max_carry_forward is how much you can carry_forward into the next year */\n /* eg,, a max_carry_forward of 300 hours for year 2008, means I can carry_forward up to 300 */\n /* hours into 2009. Otherwise, you'd join on Leave_Current_Balance.Year + 1 if it's how much */\n /* I can carry forward into *this* year. */\n AND Leave_Current_Balance.Year = Leave_Type.Year\n" }, { "answer_id": 185657, "author": "Jeffrey04", "author_id": 5742, "author_profile": "https://Stackoverflow.com/users/5742", "pm_score": 0, "selected": false, "text": "event (event_id (PK), dtstart, dtend, ... --other icalendar fields--)\n event_leave (event_id (PK/FK->event), total_days, leave_type_id (FK->leave_type))\n leave_type (leave_type_id (PK), name, require_support, require_recommend, max_carry_forward)\n leave_allocation (leave_allocation_id, year(PK), leave_type_id (PK/FK->leave_type), total_days, group_id)\n leave_carry_forward(2009) = min(leave_allocation(2008) + leave_carry_forward(2007) - leave_taken(2008), maximum_carry_forward());\n\nleave_carry_forward (leave_carry_forward_id, user_id, year, total_days)\n DROP VIEW IF EXISTS leave_remaining_days;\nCREATE OR REPLACE VIEW leave_remaining_days AS\n SELECT year, user_id, leave_type_id, SUM(total_days) as total_days\n FROM (\n SELECT allocated.year, usr.uid AS \"user_id\", allocated.leave_type_id, \n allocated.total_days\n FROM users usr\n JOIN app_event._leave_allocation allocated\n ON allocated.group_id = usr.group_id\n UNION\n SELECT EXTRACT(year FROM event.dtstart) AS \"year\", event.user_id, \n leave.leave_type_id, leave.total_days * -1 AS total_days\n FROM app_event.event event\n LEFT JOIN app_event.event_leave leave\n ON event.event_id = leave.event_id\n UNION\n SELECT year, user_id, leave_type_id, total_days\n FROM app_event._leave_carry_forward\n ) KKR\n GROUP BY year, user_id, leave_type_id;\n public function populate_allocation($year) {\n return $this->db->query(sprintf(\n 'INSERT INTO %s (%s)' .\n \"SELECT '%s' AS year, %s \" .\n 'FROM %s ' .\n 'WHERE \"year\" = %s',\n 'event_allocation',\n 'year, leave_type_id, total_days ...', //(all the fields in the table)\n empty($year) ? date('Y') : $year,\n 'leave_type_id, total_days, ..', //(all fields except year)\n $this->__table,\n empty($year) ? date('Y') - 1 : $year - 1\n ))\n ->count() > 0; // using the database query builder in Kohana PHP framework\n}\n DROP VIEW IF EXISTS user_leave_type;\nCREATE OR REPLACE VIEW user_leave_type AS\n SELECT la.year, usr.uid AS user_id, lt.leave_type_id, lt.max_carry_forward\n FROM users usr\n JOIN app_event._leave_allocation la\n JOIN app_event._leave_type lt\n ON la.leave_type_id = lt.leave_type_id\n ON usr.group_id = la.group_id\n INSERT INTO leave_carry_forward (year, user_id, leave_type_id, total_days)\n SELECT '{$this_year}' AS year, user_id, leave_type_id, MIN(carry_forward) AS total_days\n FROM (\n SELECT year, user_id, leave_type_id, total_days AS carry_forward\n FROM leave_remaining_days\n UNION\n SELECT year, user_id, leave_type_id, max_carry_forward AS carry_forward\n FROM user_leave_type\n ) KKR\n WHERE year = {$last_year}\n GROUP BY year, user_id, leave_type_id;\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5742/" ]
181,970
<p>I would like to send a (as yet undetermined) SIGnal from a bash script to a Gambas program when a specific file has been changed. </p> <p>How can I get my Gambas program to process this SIGnal?</p>
[ { "answer_id": 56855728, "author": "Benoît", "author_id": 11730064, "author_profile": "https://Stackoverflow.com/users/11730064", "pm_score": 1, "selected": false, "text": "gb.signal" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
181,975
<p>the function addresses (Rva+Base) in my MAP-file from visual studio doesn't match the one I see in the debugger (or when I manually inspect my stack frame).</p> <p>What could be causing this?</p> <p>/A.B.</p>
[ { "answer_id": 182269, "author": "Suma", "author_id": 16673, "author_profile": "https://Stackoverflow.com/users/16673", "pm_score": 1, "selected": false, "text": "static void KnownFunctionAddress(){}\n\n...\n\n// check an address of a known function\n// and compare this to the value read from the map file\n\nintptr_t CheckRelocationOffset(MapFile map)\n{\n intptr_t mapAddress = map.PhysicalAddress(\"?KnownFunctionAddress@@YAXXZ\");\n intptr_t realAddress = (intptr_t)KnownFunctionAddress;\n\n return realAddress-mapAddress;\n}\n" }, { "answer_id": 9701367, "author": "kornman00", "author_id": 444977, "author_profile": "https://Stackoverflow.com/users/444977", "pm_score": 0, "selected": false, "text": "extern \"C\" struct IMAGE_DOS_HEADER __ImageBase; // On platforms other than Win32/Win64, this MAY be a different header type...\n...\nprintf_s(\"base: %p\", &__ImageBase);\n printf_s(\"calling module's base: %p\\n\", GetModuleHandle(NULL));\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
181,977
<p>Does anyone know of a whirlwind tour of Eclipse that would help a (former) Visual Studio user get up to speed with it?</p> <p>I just want something that tells me where all the basic features are and what all the cool stuff I've heard so much about is?</p> <p>So far I've been using it mostly as a text editor and have had some luck compiling and running programs in it. But... I'm a bit confused, for instance sometimes I can't seem to get out of debug mode.</p> <p>I'me sure I'm just looking in the wrong places for everything as I'm used to a different interface.</p> <p>Are there plugins for Eclipse that make it look and feel more like Visual Studio?</p> <p>I'm using Europa at the moment because thats what the rest of my team use, howver I'm more than happy to migrate to Ganemede...</p>
[ { "answer_id": 182269, "author": "Suma", "author_id": 16673, "author_profile": "https://Stackoverflow.com/users/16673", "pm_score": 1, "selected": false, "text": "static void KnownFunctionAddress(){}\n\n...\n\n// check an address of a known function\n// and compare this to the value read from the map file\n\nintptr_t CheckRelocationOffset(MapFile map)\n{\n intptr_t mapAddress = map.PhysicalAddress(\"?KnownFunctionAddress@@YAXXZ\");\n intptr_t realAddress = (intptr_t)KnownFunctionAddress;\n\n return realAddress-mapAddress;\n}\n" }, { "answer_id": 9701367, "author": "kornman00", "author_id": 444977, "author_profile": "https://Stackoverflow.com/users/444977", "pm_score": 0, "selected": false, "text": "extern \"C\" struct IMAGE_DOS_HEADER __ImageBase; // On platforms other than Win32/Win64, this MAY be a different header type...\n...\nprintf_s(\"base: %p\", &__ImageBase);\n printf_s(\"calling module's base: %p\\n\", GetModuleHandle(NULL));\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181977", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20400/" ]
181,986
<p>Every software development professional (and especially project managers) has to deal with a never ending stream of e-mails. What is the best way of organising them in MS Outlook?</p> <p>Obviously some fancy issue tracking tools give more flexibility but I am interested in plain vanilla approach that can be deployed within most organisations. </p> <p>P.S. Finding e-mails is generally the least of the problems that needs to be addressed. Search nowdays is pretty good.</p>
[ { "answer_id": 195968, "author": "Scott James", "author_id": 6715, "author_profile": "https://Stackoverflow.com/users/6715", "pm_score": 4, "selected": true, "text": "Sub MoveToDone()\n On Error Resume Next\n\n Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder\n Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem\n\n Set objNS = Application.GetNamespace(\"MAPI\")\n Set objInbox = objNS.GetDefaultFolder(olFolderInbox)\n Set objFolder = objInbox.Folders(\"Done\")\n\n 'Assume this is a mail folder\n\n If objFolder Is Nothing Then\n MsgBox \"This folder doesn't exist!\", vbOKOnly + vbExclamation, \"INVALID FOLDER\"\n End If\n\n If Application.ActiveExplorer.Selection.Count = 0 Then\n 'Require that this procedure be called only when a message is selected\n MsgBox \"No msgs selected\", vbOKOnly + vbExclamation, \"NO_MSG_SELECTED\"\n Exit Sub\n End If\n\n For Each objItem In Application.ActiveExplorer.Selection\n If objFolder.DefaultItemType = olMailItem Then\n If objItem.Class = olMail Then\n objItem.Move objFolder\n End If\n End If\n Next\n\n\n Set objItem = Nothing\n Set objFolder = Nothing\n Set objInbox = Nothing\n Set objNS = Nothing\n\nEnd Sub\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22088/" ]
181,990
<p>I'm setting up an online ordering system but I'm in Australia and for international customers I'd like to show prices in US dollars or Euros so they don't have to make the mental effort to convert from Australian dollars.</p> <p>Does anyone know if I can pull up to date exchange rates off the net somewhere in an easy-to-parse format I can access from my PHP script ?</p> <hr> <p><strong>UPDATE:</strong> I have now written a PHP class which implements this. <a href="http://www.doctort.org/adam/general/currency-calculation-in-php.html" rel="noreferrer">You can get the code from my website</a>.</p>
[ { "answer_id": 182045, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 7, "selected": true, "text": "http://download.finance.yahoo.com/d/quotes.csv?s=GBPEUR=X&f=sl1d1t1ba&e=.csv" }, { "answer_id": 11968565, "author": "oodavid", "author_id": 1122851, "author_profile": "https://Stackoverflow.com/users/1122851", "pm_score": 2, "selected": false, "text": "function get_exchange_rate($from, $to){\n $data = file_get_contents(\"http://www.google.com/ig/calculator?hl=en&q=1{$from}=?{$to}\");\n preg_match('/rhs\\:\\s?\"([0-9\\.]+)/', $data, $m);\n return $m[1];\n}\n" }, { "answer_id": 12683606, "author": "Natsukane", "author_id": 1636256, "author_profile": "https://Stackoverflow.com/users/1636256", "pm_score": 4, "selected": false, "text": "http://www.google.com/ig/calculator?hl=en&q=1GBP=?USD\n {lhs: \"1 British pound\",rhs: \"1.6132 U.S. dollars\",error: \"\",icc: true}\n function convert_currency($amount, $from_code, $to_code){\n ini_set('max_execution_time', 60);\n $temp = 'http://www.google.com/ig/calculator?hl=en&q=' . $amount . $from_code . '=?' . $to_code;\n\n $response = file_get_contents($temp);\n $result_string = explode('\"', $response);\n\n $final_result = $result_string['3'];\n\n $float_result = preg_replace(\"/[^0-9\\.]/\", '', $full_result);\n\n return $float_result;\n}\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5324/" ]
181,994
<p>In order to verify the data coming from the <a href="http://code.google.com/apis/safebrowsing/developers_guide.html" rel="nofollow noreferrer">Google Safe Browsing API</a>, you can calculate a Message Authentication Code (MAC) for each update. The instructions to do this (from Google) are:</p> <blockquote> <p>The MAC is computed from an MD5 Digest over the following information: client_key|separator|table data|separator|client_key. The separator is the string:coolgoog: - that is a colon followed by "coolgoog" followed by a colon. The resulting 128-bit MD5 digest is websafe base-64 encoded.</p> </blockquote> <p>There's also example data to check against:</p> <pre><code>client key: "8eirwN1kTwCzgWA2HxTaRQ==" </code></pre> <p>response:</p> <pre><code>[goog-black-hash 1.180 update][mac=dRalfTU+bXwUhlk0NCGJtQ==] +8070465bdf3b9c6ad6a89c32e8162ef1 +86fa593a025714f89d6bc8c9c5a191ac +bbbd7247731cbb7ec1b3a5814ed4bc9d *Note that there are tabs at the end of each line. </code></pre> <p>I'm unable to get a match. Please either point out where I'm going wrong, or just write the couple of lines of Python code necessary to do this!</p> <p>FWIW, I expected to be able to do something like this:</p> <pre><code>&gt;&gt;&gt; s = "+8070465bdf3b9c6ad6a89c32e8162ef1\t\n+86fa593a025714f89d6bc8c9c5a191ac\t\n+bbbd7247731cbb7ec1b3a5814ed4bc9d\t" &gt;&gt;&gt; c = "8eirwN1kTwCzgWA2HxTaRQ==" &gt;&gt;&gt; hashlib.md5("%s%s%s%s%s" % (c, ":coolgoog:", s, ":coolgoog:", c)).digest().encode("base64") 'qfb50mxpHrS82yTofPkcEg==\n' </code></pre> <p>But as you can see, 'qfb50mxpHrS82yTofPkcEg==\n' != 'dRalfTU+bXwUhlk0NCGJtQ=='.</p>
[ { "answer_id": 182099, "author": "Anders Waldenborg", "author_id": 24082, "author_profile": "https://Stackoverflow.com/users/24082", "pm_score": 2, "selected": true, "text": "c=\"8eirwN1kTwCzgWA2HxTaRQ==\".decode('base64')\n" }, { "answer_id": 184617, "author": "Tony Meyer", "author_id": 4966, "author_profile": "https://Stackoverflow.com/users/4966", "pm_score": 2, "selected": false, "text": ">>> s = \"+8070465bdf3b9c6ad6a89c32e8162ef1\\t\\n+86fa593a025714f89d6bc8c9c5a191ac\\t\\n+bbbd7247731cbb7ec1b3a5814ed4bc9d\\t\\n\"\n>>> c = \"8eirwN1kTwCzgWA2HxTaRQ==\".decode('base64') \n>>> hashlib.md5(\"%s%s%s%s%s\" % (c, \":coolgoog:\", s, \":coolgoog:\", c)).digest().encode(\"base64\")\n'dRalfTU+bXwUhlk0NCGJtQ==\\n'\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/181994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4966/" ]
182,011
<p>When accessing an object in a DataTable retrieved from a database, are there any reasons not to cast the object into your desired type, or are there reasons to use convert? I know the rule is cast when we know what data type we're working with, and convert when attempting to change the data type to something it isn't. Presuming we know what data type is stored in a column, cast seems appropriate, but are there any DB type issues that mean we can't rely on this?</p>
[ { "answer_id": 182029, "author": "Joe", "author_id": 13087, "author_profile": "https://Stackoverflow.com/users/13087", "pm_score": 3, "selected": true, "text": "INSERT INTO MyTable ...\nSELECT CAST(SCOPE_IDENTITY() AS INT)\n" }, { "answer_id": 182031, "author": "Galwegian", "author_id": 3201, "author_profile": "https://Stackoverflow.com/users/3201", "pm_score": 0, "selected": false, "text": "CAST CONVERT CONVERT CAST ( expression AS data_type [ (length ) ])\n CONVERT ( data_type [ ( length ) ] , expression [ , style ] )\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/182011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2179408/" ]
182,034
<p>XP-specific answers preferred, but others are welcome too.</p>
[ { "answer_id": 182052, "author": "jop", "author_id": 11830, "author_profile": "https://Stackoverflow.com/users/11830", "pm_score": 3, "selected": true, "text": "%windir%\\System32\\Shell32.dll" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/182034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20310/" ]
182,035
<p>Internet explorer 6 seems totally ignore CSS classes or rules on select, option or optgroup tags.</p> <p>Is there a way to bypass that limitation (except install a recent version of IE) ?</p> <p><strong>Edit</strong> : to be more precise, I'm trying to build a hierarchy between options like that example:</p> <p>Here's the HTML snippet :</p> <pre><code>&lt;select name="hierarchicalList" multiple="multiple"&gt; &lt;option class="group niv0"&gt;Os developers&lt;/option&gt; &lt;option class="group niv1"&gt;Linux&lt;/option&gt; &lt;option class="user niv2"&gt;Linus Torvald&lt;/option&gt; &lt;option class="user niv2"&gt;Alan Cox&lt;/option&gt; &lt;option class="group niv1"&gt;Windows&lt;/option&gt; &lt;option class="user niv2"&gt;Paul Allen&lt;/option&gt; &lt;option class="user niv2"&gt;Bill Gates&lt;/option&gt; &lt;option class="group niv1"&gt;Mac Os&lt;/option&gt; &lt;option class="user niv2"&gt;Steve Wozniaz&lt;/option&gt; &lt;/select&gt; </code></pre> <p>And here's CSS rules, that works fine on a recent browser (like FF3) but not working at all on IE6 :</p> <pre><code> select option { line-height: 10px; } select option.group { font-weight: bold; background: url(path_to_group_icon.gif) no-repeat; padding-left: 18px; } select option.user { background: url(path_to_user_icon.gif) no-repeat; padding-left: 18px; } select option.niv0 { margin-left: 0px; } select option.niv1 { margin-left: 10px; } select option.niv2 { margin-left: 20px; } </code></pre>
[ { "answer_id": 183213, "author": "Matt", "author_id": 17020, "author_profile": "https://Stackoverflow.com/users/17020", "pm_score": 4, "selected": true, "text": "&nbsp ; \n <!--[if lt IE 7]><![endif]--> \n <!--[if IE 6]><![endif]--> \n Level 1\n<!--[if lt IE 7]>-<![endif]-->Level 2 \n<!--[if lt IE 7]>--<![endif]--> Level 3\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/182035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3122/" ]
182,040
<p>I want to create a route in my rails application along the lines of</p> <pre><code>/panda/blog /tiger/blog /dog/blog </code></pre> <p>where panda, tiger, and dog are all permalinks (for an animal class)</p> <p>The normal way of doing this</p> <pre><code>map.resources :animals do |animal| animal.resource :blog end </code></pre> <p>would create routes along the lines of</p> <pre><code>/animals/panda/blog /animals/tiger/blog /animals/dog/blog </code></pre> <p>But i do not want the first segment, as it will always be the same. </p> <p>I know I could do this by manual routing, but I want to know how to do using rails resources, as having animals and blogs is a requirement for me.</p>
[ { "answer_id": 6201691, "author": "edgerunner", "author_id": 311941, "author_profile": "https://Stackoverflow.com/users/311941", "pm_score": 4, "selected": true, "text": "path => \"\" resource resources resources :animals, :path => \"\"\n $ rake routes\n\n animals GET / {:action=>\"index\", :controller=>\"animals\"}\n POST / {:action=>\"create\", :controller=>\"animals\"}\n new_animal GET /new(.:format) {:action=>\"new\", :controller=>\"animals\"}\nedit_animal GET /:id/edit(.:format) {:action=>\"edit\", :controller=>\"animals\"}\n animal GET /:id(.:format) {:action=>\"show\", :controller=>\"animals\"}\n PUT /:id(.:format) {:action=>\"update\", :controller=>\"animals\"}\n DELETE /:id(.:format) {:action=>\"destroy\", :controller=>\"animals\"}\n" } ]
2008/10/08
[ "https://Stackoverflow.com/questions/182040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7473/" ]